Skip to content

Fix for NumPy 1.23#6807

Merged
toslunar merged 3 commits intocupy:masterfrom
takagi:numpy-1.23
Jun 28, 2022
Merged

Fix for NumPy 1.23#6807
toslunar merged 3 commits intocupy:masterfrom
takagi:numpy-1.23

Conversation

@takagi
Copy link
Contributor

@takagi takagi commented Jun 24, 2022

Rel #6764.

@toslunar
Copy link
Member

For CuPy v11, I'd follow NumPy 1.23's behavior by removing these lines

elif isinstance(slices, list):
slice_list = list(slices) # copy list
for s in slice_list:
if not isinstance(s, int):
warnings.warn(
'Using a non-tuple sequence for multidimensional indexing '
'is deprecated; use `arr[tuple(seq)]` instead of '
'`arr[seq]`. In the future this will be interpreted as an '
'array index, `arr[cupy.array(seq)]`, which will result '
'either in an error or a different result.',
FutureWarning)
break

@takagi
Copy link
Contributor Author

takagi commented Jun 24, 2022

Sure! (I completely had misunderstanding about that...)

@takagi
Copy link
Contributor Author

takagi commented Jun 27, 2022

/test mini

@takagi
Copy link
Contributor Author

takagi commented Jun 27, 2022

/test mini

@takagi takagi marked this pull request as ready for review June 27, 2022 04:09
@emcastillo emcastillo added cat:numpy-compat Follow the NumPy/SciPy spec changes prio:high to-be-backported Pull-requests to be backported to stable branch blocking Issue/pull-request is mandatory for the upcoming release labels Jun 27, 2022
@takagi
Copy link
Contributor Author

takagi commented Jun 27, 2022

/test mini

Comment on lines -165 to -168
{'shape': (0,), 'indexes': True},
{'shape': (0,), 'indexes': (True,)},
{'shape': (0,), 'indexes': numpy.ones((), dtype=numpy.bool_)},
{'shape': (0,), 'indexes': numpy.zeros((), dtype=numpy.bool_)},
Copy link
Contributor Author

@takagi takagi Jun 27, 2022

Choose a reason for hiding this comment

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

These tests were split from TestArrayAdvancedIndexingGetitemParametrized in #1503 for NumPy 1.13 support, so I've made them back there in this PR as numpy<1.13 is already dropped.

Comment on lines -558 to -561
{'shape': (0,), 'indexes': True, 'value': 1},
{'shape': (0,), 'indexes': (True,), 'value': 1},
{'shape': (0,), 'indexes': numpy.ones((), dtype=numpy.bool_), 'value': 1},
{'shape': (0,), 'indexes': numpy.zeros((), dtype=numpy.bool_), 'value': 1},
Copy link
Contributor Author

@takagi takagi Jun 27, 2022

Choose a reason for hiding this comment

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

These tests were split from TestArrayAdvancedIndexingSetitemScalarValue in #1503 for NumPy 1.13 support, so I've made them back there in this PR as numpy<1.13 is already dropped.

ast.Sub: arithmetic.subtract,
ast.Mult: arithmetic.multiply,
ast.Pow: arithmetic.power,
ast.Div: _numpy_scalar_true_divide,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems that we don't need _numpy_scalar_true_divide anymore.

Copy link
Member

Choose a reason for hiding this comment

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

It seems so to me, too.

@asi1024 Do you have any comment?

Copy link
Member

Choose a reason for hiding this comment

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

I agree to use arithmetic.true_divide!

@kmaehashi
Copy link
Member

@toslunar, do you think this can be in the RC release this Thursday? If needed I think it's worth delaying the release, as v11 is a goog chance to bump the API baseline version to v1.23.

toslunar
toslunar previously approved these changes Jun 27, 2022
Copy link
Member

@toslunar toslunar left a comment

Choose a reason for hiding this comment

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

LGTM

I left some minor comments that seem optional to be fixed in this PR.

DeprecationWarning)
axis = 0
else:
# Don't mention the deprecated F-contiguous support
Copy link
Member

Choose a reason for hiding this comment

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

nit: This line can be removed, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, thanks!

st = 1

# For some cases, the strides are all set to zero if the shape is
# zero-sized since NumPy 1.23.
Copy link
Member

Choose a reason for hiding this comment

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

Do you know whether NumPy intentionally kept the behavior for no copy reshape? Maybe it's good to report to NumPy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I couldn't search the source enough last night. As you say, it's a kind of weird behavior. I'm going to see it again.

Copy link
Contributor Author

@takagi takagi Jun 28, 2022

Choose a reason for hiding this comment

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

It seems the change in creation (zero strides) was introduced in numpy/numpy#21477 (ctors.c). numpy/numpy#21477 (review)

ast.Sub: arithmetic.subtract,
ast.Mult: arithmetic.multiply,
ast.Pow: arithmetic.power,
ast.Div: _numpy_scalar_true_divide,
Copy link
Member

Choose a reason for hiding this comment

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

It seems so to me, too.

@asi1024 Do you have any comment?

@toslunar
Copy link
Member

/test mini

@toslunar toslunar enabled auto-merge June 28, 2022 04:57
@toslunar toslunar added this to the v11.0.0rc1 milestone Jun 28, 2022
@toslunar toslunar removed the to-be-backported Pull-requests to be backported to stable branch label Jun 28, 2022
@toslunar
Copy link
Member

v10 fix will be @testing.with_requires('numpy<1.23').

@kmaehashi kmaehashi mentioned this pull request Jun 28, 2022
8 tasks
@toslunar toslunar merged commit e43e348 into cupy:master Jun 28, 2022
@takagi takagi deleted the numpy-1.23 branch June 28, 2022 09:16
@takagi takagi restored the numpy-1.23 branch June 28, 2022 11:29
@takagi takagi deleted the numpy-1.23 branch June 28, 2022 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocking Issue/pull-request is mandatory for the upcoming release cat:numpy-compat Follow the NumPy/SciPy spec changes prio:high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants