-
Couldn't load subscription status.
- Fork 52
Open
Milestone
Description
Description
upstream context: numpy/numpy#28800
in short: modifying an array's dtype attribute in place is planned for a deprecation in some future version of numpy.
We do have a couple public APIs where this is used:
unyt_array.convert_to_*functions, which are explicitly documented as doing in-place modifications)unyt_array.__array_ufunc__has special logic for handling anoutargument with an integer dtype
In the latter, I don't think we have any options other than dropping support for this special, ill defined case.
The former however could go different ways:
- pure and simple deprecation, with a warning saying that this will break for sufficiently recent versions of numpy (seems impossible given the amount of code that relies on these methods, in yt alone)
- renounce in-place mutation and instead produce copies, unconditionally (seems like violating a promise)
- add a new argument for handling cases where in-place conversions cannot be done without mutating
dtype. Options could be:- do everything in place whenever possible, but allow copies if necessary
- always return a copy
- never return a copy, error if this constraints cannot be satisfied
Note that the last option (a new keyword argument) matches how the copy keyword argument works in many APIs in numpy 2.0+ (options are None (default), True and False), so it should be pretty straight forward to understand for new users.
What to you think @jzuhone ?
Metadata
Metadata
Assignees
Labels
No labels