DEP: Formally deprecate np.typeDict#17586
Conversation
|
My main concern here is that maybe we should be doing the deprecation in the other direction... How many callers of
|
Roughly speaking there about twice as many callers of
Switching the deprecation around would fix the first issue; though Personally I don't have any particularly strong opinion about which on to keep and which one to discard. |
|
I suppose the other option is we just deprecate both. |
|
The only department where |
Do we have a canonical way to get this information without these dictionaries? |
Not as far as I'm aware, no. |
Is there a valid reason for a user to actually want this? This is the type of trap that leads to users iterating over these names when they should just be iterating over the types themselves. |
The main reason I can think of is for the purpose of documentation, as the current arrays.scalars docs |
|
Right - it's useful internally for generating documentation if we want to go down that route, but any downstream project using it probably is doing the wrong thing. |
|
In the docs
Agreed. I checked scipy, pandas, scikit-learn, scikit-image, statsmodels and astropy, and there's only two usages in SciPy that look correct but weird. Given that |
|
@BvB93 needs a rebase. |
`typeDict` is a deprecated alias for `sctypeDict` and has been so for >= 14 years (numpy@6689502)
See numpy#17586 (comment) Co-Authored-By: Eric Wieser <425260+eric-wieser@users.noreply.github.com>
* Add a deprecation comment to `numpy/__init__.py` * Replace a `getattr()` operation with `core.numerictypes.typeDict` * Remove a redundant call to `np.sctypeDict` Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@rgommers do you feel it would be worthwhile to add a comment in the release note discouraging the use of |
|
A release note sounds like a good idea, as context with this PR. I'm not sure many people read it though; adding that note to https://numpy.org/devdocs/reference/arrays.dtypes.html is probably more effective long-term. |
|
This looks ready to go. Comments? |
|
Thanks Bas. |
MAINT: Replace use of deprecated np.typeDict with np.sctypeDict See numpy/numpy#17586 for more details.
* sctypeDict no longer has single-letter codes, numpy/numpy#17586 (comment) suggests just instantiating dtype.
* sctypeDict no longer has single-letter codes, numpy/numpy#17586 (comment) suggests just instantiating dtype.
Closes #17585.
The
np.typeDictdictionary is a deprecated alias fornp.sctypeDictand has been so for over 14 years (6689502).This PR formally marks it a such, the module-level
__getattr__now issuing a deprecation warning whenever gettingnp.typeDict.