`kde_contour_plot_2d` does not support boolean `ncompress`
Closed this issue · 1 comments
ThomasGesseyJones commented
Describe the bug
The documentation for kde_contour_plot_2d
states the kwarg parameter ncompress
can be given as True
or False
, with the former being equivalent to 'entropy'
and the latter using no compression. However, if you try to use either of these you get an error stating the functions expected an integer.
To Reproduce
Here is a minimal working example
import numpy as np
import matplotlib.pyplot as plt
from anesthetic.plot import kde_contour_plot_2d
fig, ax = plt.subplots()
np.random.seed(0)
data_x = np.random.randn(1000)
data_y = np.random.randn(1000)
kde_contour_plot_2d(ax, data_x, data_y, ncompress=1000, nplot_2d=900) # Works
plt.show()
fig, ax = plt.subplots()
kde_contour_plot_2d(ax, data_x, data_y, ncompress=False, nplot_2d=900) # Doesn't but docs say it should
plt.show()
and the error output
Traceback (most recent call last):
File "/home/thomas/Documents/Research/HERA_and_SCS/4_anesthetic_bug/mwe.py", line 13, in <module>
kde_contour_plot_2d(ax, data_x, data_y, ncompress=False, nplot_2d=900) # Doesn't but docs say it should
File "/home/thomas/.virtualenvs/4_anesthetic_bug/lib/python3.8/site-packages/anesthetic/plot.py", line 1178, in kde_contour_plot_2d
tri, w = triangular_sample_compression_2d(data_x, data_y, cov,
File "/home/thomas/.virtualenvs/4_anesthetic_bug/lib/python3.8/site-packages/anesthetic/utils.py", line 466, in triangular_sample_compression_2d
i = np.random.choice(x.index, size=n, replace=False, p=w/w.sum())
File "mtrand.pyx", line 994, in numpy.random.mtrand.RandomState.choice
TypeError: expected a sequence of integers or a single integer, got 'False'
lukashergt commented
Thanks for reporting this! #350 should address this, would you be willing to review that PR?