Skip to content

Prepare for ragged array warnings in NumPy 1.19 #17289

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

Merged
merged 7 commits into from
May 22, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow object arrays in cbook._combine_masks.
This function accepts almost anything list-like, so we really do want
conversion to object arrays if the input is ragged. For example, this
might occur for `scatter()` if passed different types of `colors`, like
in the `test_scatter_marker` test.
  • Loading branch information
QuLogic committed May 22, 2020
commit a0aac5a0533a5bc887fe68128f04e91a99e4cf41
7 changes: 6 additions & 1 deletion lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,12 @@ def _combine_masks(*args):
else:
if isinstance(x, np.ma.MaskedArray) and x.ndim > 1:
raise ValueError("Masked arrays must be 1-D")
x = np.asanyarray(x)
try:
x = np.asanyarray(x)
except (np.VisibleDeprecationWarning, ValueError):
# NumPy 1.19 raises a warning about ragged arrays, but we want
# to accept basically anything here.
x = np.asanyarray(x, dtype=object)
if x.ndim == 1:
x = safe_masked_invalid(x)
seqlist[i] = True
Expand Down