Skip to content
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

DEP: Deprecate data_type.dtype if attribute is not already a dtype #13578

Merged
merged 6 commits into from Jan 6, 2021

Conversation

seberg
Copy link
Member

@seberg seberg commented May 16, 2019

Followup from gh-13003, marking as draft because that one needs to be merged (and then this one rebased) before it can go in.

This could hit the mailing list, but I think the deprecation here should be pretty uncontroversial, since it only enforces that something.dtype returns a dtype in statements such as np.dtype(something). It does not actually force the user to write the .dtype yet.

@seberg seberg force-pushed the dtype-deprecate-dtypeattr-not-dtype branch from 66aab05 to 0d7b8ed Compare July 25, 2019 00:03
@seberg seberg marked this pull request as ready for review July 25, 2019 00:04
@seberg seberg force-pushed the dtype-deprecate-dtypeattr-not-dtype branch 2 times, most recently from d0c7b4e to 28da717 Compare February 8, 2020 02:07
@BvB93
Copy link
Member

BvB93 commented Oct 19, 2020

A question: is it the plan to (eventually) move forward with this PR or is that still undecided?

@seberg
Copy link
Member Author

seberg commented Oct 19, 2020

Not sure why it stalled, unless anyone knows of a user who expects obj.dtype.dtype to be called, and even if, this is just a deprecation.

Comment on lines 133 to 135
"`np.dtype(data_type.dtype)`. This will raise an error "
"in NumPy 1.19.") < 0) {
/* NumPy 1.19, 2020-02-07 */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"`np.dtype(data_type.dtype)`. This will raise an error "
"in NumPy 1.19.") < 0) {
/* NumPy 1.19, 2020-02-07 */
"`np.dtype(data_type.dtype)`.") < 0) {
/* NumPy 1.20, 2020-10-19 */

@BvB93
Copy link
Member

BvB93 commented Oct 19, 2020

IMO it seems like a reasonable change and it makes typing a bit easier, so +1.

@seberg seberg force-pushed the dtype-deprecate-dtypeattr-not-dtype branch from ff5686c to 1c8e1e4 Compare October 19, 2020 16:44
@mattip
Copy link
Member

mattip commented Oct 19, 2020

hmm. The circelCI merge-before-build command seems to be causing problems. Maybe we should allow it to fail silently.

@mattip
Copy link
Member

mattip commented Oct 19, 2020

The deprecation warning is leaking out into tests

@seberg
Copy link
Member Author

seberg commented Oct 19, 2020

@BvB93 its a new typing test that is failing (and not running locally with the slow flag). Should the test be modified or catch the warning?

@BvB93
Copy link
Member

BvB93 commented Oct 19, 2020

Should the test be modified or catch the warning?

Ah yes, the dtype value should be changed from float to something along the lines of np.dtype(float):

class Test:
dtype = float

@seberg
Copy link
Member Author

seberg commented Oct 19, 2020

Thanks! Just wasn't sure which direction to fix it best.

@seberg
Copy link
Member Author

seberg commented Oct 19, 2020

@mattip I think the circleci is probably only because I had it set up on my branch. Disabled it now, it is not something I use regularly anyway.

array, alltrue, ndarray, zeros, dtype, intp, clongdouble
)
import numpy as np

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change required to avoid the deprecation warning? Does that mean all user code must now change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, don't remember why I did it here, but it is just maintanence, there must have been an issue with dtype being overshadowed somewhere.

@seberg seberg closed this Jan 6, 2021
@seberg seberg reopened this Jan 6, 2021
@seberg seberg force-pushed the dtype-deprecate-dtypeattr-not-dtype branch from 2173a20 to 92275af Compare January 6, 2021 01:10
@mattip
Copy link
Member

mattip commented Jan 6, 2021

Could you move the deprecation test to the proper file? Otherwise this looks good to me.

@seberg seberg force-pushed the dtype-deprecate-dtypeattr-not-dtype branch from 92275af to 97eab33 Compare January 6, 2021 16:18
@seberg
Copy link
Member Author

seberg commented Jan 6, 2021

Done, we could consider deprecating even more, but I guess this might be a good (and easy) first step.

Yeah, I think I first wrote that at a time when I was considering to stop relying on that file so much (The original reason, and most of the magic in that file, was to work around python issues with warnings, which were eventually fixed).

@mattip mattip merged commit 5363cfa into numpy:master Jan 6, 2021
@mattip
Copy link
Member

mattip commented Jan 6, 2021

Thanks @seberg

BvB93 pushed a commit to BvB93/numpy that referenced this pull request Jan 26, 2021
@charris
Copy link
Member

charris commented Jun 18, 2021

@seberg I notice that this created changelog/13578.deprecation.rst in the root directory. What is that about? Should it be in the release notes?

@seberg
Copy link
Member Author

seberg commented Jun 18, 2021

Oh wow, that is a while ago. Yeah wrong place, should have been part of the release notes...

@charris
Copy link
Member

charris commented Jun 18, 2021

OK, I'll make a PR to get rid of it in main and take care of it in the 1.21.x branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants