Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: VisibleDeprecationWarning in boxplot #16353

Closed
@bashtage

Description

@bashtage

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesMaintenance

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions