-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
DEP: Deprecate constructing dtypes from any object having a .dtype attribute #25306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi! I appreciate the motivation for this, but one data point: as proposed, this will make jax scalar type aliases (e.g. Some background: JAX made the choice early to not have distinct scalar type classes, but rather to represent scalars as 0-dimensional arrays. What this means is that when it comes to the Unfortunately, a common pattern in numpy is to use scalar constructors as dtype arguments; e.g. Perhaps it would be possible to replace this with some other better-defined mechanism, e.g. using a |
Adding a designed-for-purpose mechanism like |
Thanks for the comments. Makes sense. |
I don't really see it fitting there. We are talking about mixing different implementations and I would say it is better if it is But yes, I agree with the idea that it is odd, but also agree that it needs a replacement since JAX and probably also pandas rely on it. |
Circling back here: has there been any more discussion of replacing |
I don't think it matters, as we should just deprecate |
Uh oh!
There was an error while loading. Please reload this page.
Proposed new feature or change:
I suggest to deprecate this feature. This is essentially already alluded in "we could consider deprecating even more" in #13578 (comment).
It seems too permissive (allowing sloppy user code) and complicates NumPy code (e.g. #13003). Users should instead dereference the
.dtype
attribute explicitly ("explicit is better than implicit"), e.g.Also, the current documentation is not exactly correct. It claims
but NumPy explicitly disallows this for ndarrays - for good reason, because
np.array(data, dtype=other_array)
would be semantically sloppy.OTOH, I can for example do this with a pandas.Series (
np.array(data, dtype=series)
). IMHO this should not work for pandas.Series or other objects. An additional unwanted side effect is that one can have quite strange comparions due to dtypes comparing True to valid data type specificationsThe text was updated successfully, but these errors were encountered: