DEP: deprecate numpy.lib.user_array.container#30284
Conversation
c89abe3 to
7a06475
Compare
| astype | ||
|
|
||
| """ | ||
| def __init_subclass__(cls) -> None: |
There was a problem hiding this comment.
Does this work? AFAICT, it will only be called when a subclass is instantiated.
There was a problem hiding this comment.
First thing I tried was warning on import, but distutils didn't like that for some reason, so I went with this approach.
If you prefer, I could try the module-level __getattr__ trick?
There was a problem hiding this comment.
I think you can test with:
python numpy/lib/_user_array_impl.py
There is also an existing error in that test :)
Why not add the deprecation to the __init__ ?
There was a problem hiding this comment.
I think you can test with:
python numpy/lib/_user_array_impl.py
I kinda assumed that the only use-case of contasiner was as a base class. I doubt that anyone would use it directly like done in this test. But maybe I'm wrong 🤷
There is also an existing error in that test :)
That's pretty funny haha
Why not add the deprecation to the
__init__?
There's a higher chance of someone overriding that I guess. But I maybe I could do both; what do you think?
There was a problem hiding this comment.
Let's ping @stefanv, he is one of the early editors of the file.
|
This class is actually documented in and offers units as another application. I suspect the motivation was difficulty inheriting from C classes. In any case, you are correct that the resulting Python class was intended as a base class. I'm not sure it wasn't a better idea than the current masked array implementation :) Have you tested |
Ohh, that goes pretty far back then!
Yup: from numpy.lib.user_array import container
class MyArray(container):
passRunning this |
|
Sounds good them. Should probably leave a note in the documentation as well, search for UserArray. |
|
Oh, and please add a comment with the date and release, something like: |
Sharp; I completely forgot about that |
Co-authored-by: Charles Harris <[email protected]>
|
Thanks Joren. |
* DEP: deprecate ``numpy.lib.user_array.container`` * DEP: add deprecation notice for ``numpy.lib.user_array.container`` * DEP: add deprecation comment with date to ``lib.user_array.container`` Co-authored-by: Charles Harris <[email protected]> --------- Co-authored-by: Charles Harris <[email protected]>
* DEP: deprecate ``numpy.lib.user_array.container`` * DEP: add deprecation notice for ``numpy.lib.user_array.container`` * DEP: add deprecation comment with date to ``lib.user_array.container`` Co-authored-by: Charles Harris <[email protected]> --------- Co-authored-by: Charles Harris <[email protected]>
Closes #30283