8000 BUG: VisibleDeprecationWarning in boxplot · Issue #16353 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

BUG: VisibleDeprecationWarning in boxplot #16353

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

Closed
bashtage opened this issue Jan 28, 2020 · 3 comments · Fixed by #17289
Closed

BUG: VisibleDeprecationWarning in boxplot #16353

bashtage opened this issue Jan 28, 2020 · 3 comments · Fixed by #17289
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Maintenance
Milestone

Comments

@bashtage
Copy link

Bug report

Bug summary

boxplot is calling asarray on lists of arrays they do not have the same shape. In future NumPy ragged array construction will raise an error unless dtype='object' is explicitly passed.

This issue happens in

def _reshape_2D(X, name):

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt
x = [np.random.standard_normal(v) for v in np.random.randint(100,200,5)]
plt.boxplot(x)

You need NumPy 1.19dev0 to see this warning.

Actual outcome

numpy.VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray

Expected outcome

No warning

Matplotlib version

  • Operating system: Ubuntu 18.04
  • Matplotlib version: 3.2.0rc2+1221.g20805b805
  • Matplotlib backend (print(matplotlib.get_backend())): agg
  • Python version: 3.8.0
  • Jupyter version (if applicable):
  • Other libraries: numpy: 1.19.0.dev0+32aa66e

This is on a statsmodels "pre" build that uses the latest nightlies on rackcdn.

@timhoffm
Copy link
Member
timhoffm commented Feb 16, 2020

numpy/numpy#15083 would have allowed an easy fix. But it's closed with the comment that downstream libraries don't need it anymore 😢. Using dtype=object is not a solution in our case, because we might also have regularly shaped arrays that we do not want to convert to object.

Probably we need to rewrite the whole _reshape_2D logic to not try to fit it into a single array in the first place.

@tacaswell tacaswell modified the milestones: v3.3.0, v3.2.1 Feb 16, 2020
@tacaswell
Copy link
Member

attn @phobson

@phobson
Copy link
Member
phobson commented Feb 17, 2020

Hmmm. I wonder if a std-lib list of arrays would work for us. I might be able to think about this at some point this week. If someone else comes up with a solution, feel free to propose it here or in a PR that I'll happily review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Maintenance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
0