Numpy error at setting hue_mask
allermat opened this issue · 3 comments
Hi,
I'm getting the following error when executing cell 16 in the python tutorial with my own data. I'm using numpy 1.24.3. Basically, instead of np.bool
, it should be just bool
in line 61 and 64 in PtitPrince.py. I tested it and it works fine that way.
Best wishes,
Máté
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[8], line 3
1 f, ax = plt.subplots(figsize=(7, 5))
2 dx = 'condition'; dy = 'response_time'; ort = 'h'; pal = sns.color_palette(n_colors=1)
----> 3 ax=pt.RainCloud(x = dx, y = dy, data = rt_df_sub, palette = pal, bw = 0.3,
4 order=['match', 'total_mismatch', 'partial_mismatch_onset', 'partial_mismatch_offset'],
5 width_viol=0.7, ax = ax, orient = ort, move = 0.2)
6 f.savefig('../../results/figure_rt_raincloud.svg')
File [~/.conda/envs/my_mne1.4_fix/lib/python3.11/site-packages/ptitprince/PtitPrince.py:779](https://vscode-remote+ssh-002dremote-002blogin-002dj01.vscode-resource.vscode-cdn.net/imaging/davis/Projects/SpeechMisperceptionMEEG/code/analysis/~/.conda/envs/my_mne1.4_fix/lib/python3.11/site-packages/ptitprince/PtitPrince.py:779), in RainCloud(x, y, hue, data, order, hue_order, orient, width_viol, width_box, palette, bw, linewidth, cut, scale, jitter, move, offset, point_size, ax, pointplot, alpha, dodge, linecolor, **kwargs)
776 _ = plt.setp(ax.collections + ax.artists, alpha = alpha)
778 # Draw rain/stripplot
--> 779 ax = stripplot (x = x, y = y, hue = hue, data = data, orient = orient,
780 order = order, hue_order = hue_order, palette = palette,
781 move = move, size = point_size, jitter = jitter, dodge = dodge,
782 width = width_box, ax = ax, **kwrain)
784 # Add pointplot
785 if pointplot:
File [~/.conda/envs/my_mne1.4_fix/lib/python3.11/site-packages/ptitprince/PtitPrince.py:671](https://vscode-remote+ssh-002dremote-002blogin-002dj01.vscode-resource.vscode-cdn.net/imaging/davis/Projects/SpeechMisperceptionMEEG/code/analysis/~/.conda/envs/my_mne1.4_fix/lib/python3.11/site-packages/ptitprince/PtitPrince.py:671), in stripplot(x, y, hue, data, order, hue_order, jitter, dodge, orient, color, palette, move, size, edgecolor, linewidth, ax, width, **kwargs)
666 edgecolor = plotter.gray
667 kwargs.update(dict(s=size ** 2,
668 edgecolor=edgecolor,
669 linewidth=linewidth))
--> 671 plotter.plot(ax, kwargs)
672 return ax
File [~/.conda/envs/my_mne1.4_fix/lib/python3.11/site-packages/ptitprince/PtitPrince.py:98](https://vscode-remote+ssh-002dremote-002blogin-002dj01.vscode-resource.vscode-cdn.net/imaging/davis/Projects/SpeechMisperceptionMEEG/code/analysis/~/.conda/envs/my_mne1.4_fix/lib/python3.11/site-packages/ptitprince/PtitPrince.py:98), in _StripPlotter.plot(self, ax, kws)
96 def plot(self, ax, kws):
97 """Make the plot."""
---> 98 self.draw_stripplot(ax, kws)
99 self.add_legend_data(ax)
100 self.annotate_axes(ax)
File [~/.conda/envs/my_mne1.4_fix/lib/python3.11/site-packages/ptitprince/PtitPrince.py:61](https://vscode-remote+ssh-002dremote-002blogin-002dj01.vscode-resource.vscode-cdn.net/imaging/davis/Projects/SpeechMisperceptionMEEG/code/analysis/~/.conda/envs/my_mne1.4_fix/lib/python3.11/site-packages/ptitprince/PtitPrince.py:61), in _StripPlotter.draw_stripplot(self, ax, kws)
58 if self.plot_hues is None or not self.dodge:
60 if self.hue_names is None:
---> 61 hue_mask = np.ones(group_data.size, np.bool)
62 else:
63 hue_mask = np.array([h in self.hue_names
64 for h in self.plot_hues[i]], np.bool)
File [~/.conda/envs/my_mne1.4_fix/lib/python3.11/site-packages/numpy/__init__.py:305](https://vscode-remote+ssh-002dremote-002blogin-002dj01.vscode-resource.vscode-cdn.net/imaging/davis/Projects/SpeechMisperceptionMEEG/code/analysis/~/.conda/envs/my_mne1.4_fix/lib/python3.11/site-packages/numpy/__init__.py:305), in __getattr__(attr)
300 warnings.warn(
301 f"In the future `np.{attr}` will be defined as the "
302 "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
304 if attr in __former_attrs__:
--> 305 raise AttributeError(__former_attrs__[attr])
307 # Importing Tester requires importing all of UnitTest which is not a
308 # cheap import Since it is mainly used in test suits, we lazy import it
309 # here to save on the order of 10 ms of import time for most users
310 #
311 # The previous way Tester was imported also had a side effect of adding
312 # the full `numpy.testing` namespace
...
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
pip install and conda install both lead to this error, even though the issue seems to be resolved on the github repo.
@allermat I'm getting the same error here. Just like @saurabhr said, it was solved like that here too #36. Is there a way to update the PyPi package so we don't have to clone the repo directly?
AttributeError: module 'numpy' has no attribute 'bool'.
np.bool
was a deprecated alias for the builtinbool
. To avoid this error in existing code, usebool
by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, usenp.bool_
here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
solved in version 0.2.7
.