-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Closed as not planned
Closed as not planned
Copy link
Labels
33 - QuestionQuestion about NumPy usage or developmentQuestion about NumPy usage or development
Description
Describe the issue:
I have encountered an odd behavior when dealing with tuples.
In place substitution of numpy arrays in tuples using the -= syntax throws an exception on one hand but changes the values of the array on the other hand. At the very least this behavior is not what I'd expect as a developer.
Reproduce the code example:
import numpy as np
arr = np.where(np.array([0,1,1,0,0,1]) == 0)
print(arr[0])
for i in arr[0]:
arr[0] -= 100 # This throws an exception
print(i)
print(arr[0]) # We'll see that even though an exception was thrown, the values of the array changed.
for i in arr[0]:
arr[0] = arr[0] - 100 # This does not throw an exception
print(i)Error message:
Python and NumPy Versions:
2.2.2
3.12.8 (main, Jan 14 2025, 22:49:36) [MSC v.1942 64 bit (AMD64)]
Runtime Environment:
No response
Context for the issue:
No response
Metadata
Metadata
Assignees
Labels
33 - QuestionQuestion about NumPy usage or developmentQuestion about NumPy usage or development