Message402991
This has nothing to do with properties, it's 100% about using augmented assignment with numpy arrays and mixed types. An equivalent reproducer is:
a = np.array([1,2,3]) # Implicitly of dtype np.int64
a += 0.5 # Throws the same error, no properties involved
The problem is that += is intended to operate in-place on mutable types, numpy arrays *are* mutable types (unlike normal integers in Python), you're trying to compute a result that can't be stored in a numpy array of integers, and numpy isn't willing to silently make augmented assignment with incompatible types make a new copy with a different dtype (they *could* do this, but it would lead to surprising behavior, like += on the *same* numpy array either operating in place or creating a new array with a different dtype and replacing the original based on the type on the right-hand side).
The short form is: If your numpy computation is intended to produce a new array with a different data type, you can't use augmented assignment. And this isn't a bug in CPython in any event; it's purely about the choices (reasonable ones IMO) numpy made implementing their __iadd__ overload. |
|
Date |
User |
Action |
Args |
2021-09-30 23:48:59 | josh.r | set | recipients:
+ josh.r, mark.dickinson, eric.smith, chovey |
2021-09-30 23:48:58 | josh.r | set | messageid: <1633045738.91.0.445757643458.issue45333@roundup.psfhosted.org> |
2021-09-30 23:48:58 | josh.r | link | issue45333 messages |
2021-09-30 23:48:58 | josh.r | create | |
|