FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: Refactor of hexbin for 3.6.0 crashes with empty arrays and log scaling · Issue #23922 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: Refactor of hexbin for 3.6.0 crashes with empty arrays and log scaling #23922

Closed

Description

Bug summary

With 3.5 and previously, doing hexbin with empty arrays and log scaling just produced an empty plot. With 3.6.0 it crashes.

Code for reproduction

import matplotlib.pyplot as plt

plt.hexbin([], [], bins='log')

Actual outcome

...

File ~/miniforge3/envs/mpl36/lib/python3.10/site-packages/numpy/core/_methods.py:44, in _amin(a, axis, out, keepdims, initial, where)
42 def _amin(a, axis=None, out=None, keepdims=False,
43 initial=_NoValue, where=True):
---> 44 return umr_minimum(a, axis, None, out, keepdims, initial, where)

ValueError: zero-size array to reduction operation minimum which has no identity

Expected outcome

It just runs and then a plt.show() gives an empty rectangle.

Additional information

No response

Operating system

macos arm64

Matplotlib Version

3.6.0

Matplotlib Backend

MacOSX

Python version

3.10

Jupyter version

No response

Installation

conda

Activity

  1. greglucas commented on Sep 17, 2022

    Contributor

    bisects to: #21989

  2. added this to the v3.6.1 milestone on Sep 17, 2022
  3. erykoff commented on Sep 18, 2022

    ContributorAuthor

    Ah, so it seems that the change from super().autoscale(np.ma.array(A, mask=(A <= 0))) (which does produce min/max values for a fully masked array) to super().autoscale(in_trf_domain) (where in_trf_domain is a zero-length array) is the key change. I believe this would crash if log-scale is used any time all the bins are zero or negative.

    I don't know what the correct solution is; is it as simple as putting a guard in autoscale like in autoscale_None that checks if A has a non-zero size? I don't know if this would have other bad downstream effects.

  4. tacaswell commented on Sep 18, 2022

    Member

    I suspect adding that guard is the right thing to do. It is impossible to correctly autoscale with no data so it is a bit of an undefined operation. In this case doing anything is better than crashing. It would be best if we still maintained the old behavior.

  5. erykoff commented on Sep 18, 2022

    ContributorAuthor

    Putting in a guard (hacking my installation and not running a full test) does work in terms of not crashing, but leaves the hexbin (in particular) with no background rather than the default bluish background. I'm not sure if this is a problem, but it is different from the previous behavior (and the behavior without log scaling), but I don't know what the default values of vmin and vmax used to be in this case.

  6. QuLogic commented on Sep 23, 2022

    Member

    Closed by #23944.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL