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

Skip to content

Conversation

@kmaehashi
Copy link
Member

@kmaehashi kmaehashi commented Jan 9, 2023

Part of NumPy 1.24 support #7243.

NumPy 1.24:

>>> import numpy as np
>>> np.arange(10)[[1,2,[3]]]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (3,) + inhomogeneous part.

NumPy 1.23:

>>> import numpy as np
>>> np.arange(10)[[1,2,[3]]]
<stdin>:1: 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.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

@kmaehashi kmaehashi changed the title Check if it has inhomogeneous shape before converting it to array Check if the slice does not have inhomogeneous shape before converting it to array Jan 9, 2023
@kmaehashi kmaehashi mentioned this pull request Jan 9, 2023
8 tasks
@kmaehashi
Copy link
Member Author

/test mini

@kmaehashi
Copy link
Member Author

/test head

(Expects test_ndarray_adv_indexing.py to be fixed)

Copy link
Contributor

@takagi takagi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@takagi
Copy link
Contributor

takagi commented Jan 10, 2023

test_ndarray_adv_indexing.py passes. Other Ci failures are not related.

@takagi takagi added this to the v12.0.0b3 milestone Jan 10, 2023
@takagi takagi merged commit 3726d13 into cupy:master Jan 10, 2023
@kmaehashi kmaehashi deleted the fix-numpy-1.24-indexing branch January 10, 2023 06:07
kmaehashi added a commit to kmaehashi/cupy that referenced this pull request Jan 10, 2023
@kmaehashi
Copy link
Member Author

Tests for v11 updated in #7287.

takagi added a commit that referenced this pull request Jan 13, 2023
[v11] Fix tests for NumPy 1.24 (c.f. #7286)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat:numpy-compat Follow the NumPy/SciPy spec changes prio:medium

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants