Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spurious(?) all-NaN slice RuntimeWarning #35

Open
anntzer opened this issue Mar 25, 2021 · 3 comments
Open

Spurious(?) all-NaN slice RuntimeWarning #35

anntzer opened this issue Mar 25, 2021 · 3 comments

Comments

@anntzer
Copy link

anntzer commented Mar 25, 2021

For example, the first example given in the README (using the 'scatter_density' method) currently emits

.../lib/python3.9/site-packages/mpl_scatter_density/generic_density_artist.py:77: RuntimeWarning: All-NaN slice encountered
  vmin = self._density_vmin(array)
.../lib/python3.9/site-packages/mpl_scatter_density/generic_density_artist.py:82: RuntimeWarning: All-NaN slice encountered
  vmax = self._density_vmax(array)

when run with numpy 1.20.1, matplotlib 3.3.0, mpl-scatter-density 0.7.

@wphilips
Copy link

The issue is caused by the call self.set_array(EMPTY_IMAGE) in base_image_artist.py(70);
EMPTY_IMAGE is an array with a single Nan entry
At some point this calls vmin = self._density_vmin(array) in generic_density_artist.py(77)
and this generates the warning.

I hope it can be fixed.

@ba05
Copy link

ba05 commented Nov 20, 2023

Any fix?

@ba05
Copy link

ba05 commented Jan 26, 2024

This is a numpy issue occuring in numpy\lib\nanfunctions.py
https://github.com/numpy/numpy/blob/v1.26.0/numpy/lib/nanfunctions.py#L236-L361

Can suppress the warning by wrapping the code section causing the warning with a warning ignore statement. See this post:
https://stackoverflow.com/questions/29688168/mean-nanmean-and-warning-mean-of-empty-slice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants