Skip to content
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

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

Closed
vcfgv opened this issue Jan 13, 2023 · 0 comments · Fixed by #3323
Closed

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

vcfgv opened this issue Jan 13, 2023 · 0 comments · Fixed by #3323

Comments

@vcfgv
Copy link
Contributor

vcfgv commented Jan 13, 2023

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.

@vcfgv vcfgv changed the title [BUG] Creating an ndarray from ragged nested sequences is deprecated since numpy 1.24 which will cause tensor error [BUG] Creating an ndarray from ragged nested sequences is deprecated since numpy 1.24 Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant