mars-project / mars

Mars is a tensor-based unified framework for large-scale data computation which scales numpy, pandas, scikit-learn and Python functions.
https://mars-project.readthedocs.io
Apache License 2.0
2.68k stars 325 forks source link

[BUG] Creating an ndarray from ragged nested sequences is deprecated since numpy 1.24 #3322

Closed vcfgv closed 1 year ago

vcfgv commented 1 year ago

Describe the bug Numpy 1.24 deprecates ragged array creation will now always raise a ValueError unless dtype=object is passed. This includes very deeply nested sequences. Previously, 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. will be thown. Test case in test_multiclass.py, i.e. [np.array([]), np.array([1, 2, 3])], will raise AttributeError: 'list' object has no attribute 'array'

To Reproduce To help us reproducing this bug, please provide information below:

  1. Your Python version: v3.8.13
  2. The version of Mars you use: master
  3. Versions of crucial packages: numpy v1.24.1
  4. Full stack of the error.
  5. Minimized code to reproduce the error.

pytest mars/learn/utils/tests/test_multiclass.py::test_unique_labels_non_specific or

import numpy as np a = [np.array([]), np.array([1, 2, 3])] np.asarray(a)

Expected behavior ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

Additional context Add any other context about the problem here.