-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
ENH: make "closed" part of IntervalDtype #38394
Conversation
…h-interval-dtype
…h-interval-dtype
added whatsnew for deprecation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good a few questions. biggest issue is the II repr is now duplicative. should fix here, though would increase the diff a lot, followon ok.
pandas/core/dtypes/dtypes.py
Outdated
@@ -1047,14 +1080,32 @@ def __new__(cls, subtype=None): | |||
) | |||
raise TypeError(msg) | |||
|
|||
if closed is None and subtype is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we have this one do we need to warn on L1058? (e.g. which one is getting hit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you respond to this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they are both hit separately
pandas/core/dtypes/dtypes.py
Outdated
self._closed = state.pop("closed", None) | ||
if self._closed is None: | ||
warnings.warn( | ||
"Unpickled legacy IntervalDtype does not specify 'closed' " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we have tests for all of the newly-added warning/raising cases in the IntervalDtype constructor. (just added a missing consistency check https://github.com/pandas-dev/pandas/pull/38394/files#diff-f99ef42afad339d00e36197a60ccc76d74c6a94c30e05aef69d18e0ec4b10d4eR1055)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woops, dont have a test for this one. will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, this is definitely reached, but tm.assert_produces_warning isnt seeing anything
cc @jschendel if you can have a look. |
|
There's an annoying new failure mode:
|
lgtm. @jorisvandenbossche @jschendel if you can take a look. |
…h-interval-dtype
Why is it needed to deprecate the default value for |
ATM there is (presumably) code in the wild calling the IntervalDtype constructor without specifying any |
Yes, but so the question is: why does it need to eventually raise? Another option could also be to have it "not initialized" as default, to enable inferring it from the passed Interval objects |
id be OK with this |
then the default should be 'infer' (which we can do if we have an unitialized value) |
ok ill give this a shot and update |
ping when ready here |
this was ok, can you merge master |
Most recent discussion is that I need to do a partial re-write, which I haven't gotten around to yet. |
ok! |
updated as discussed. agreed this is much nicer |
I must be missing it, where exactly is the FutureWarning in the Dtype constructor triggered? |
this no longer deprecates? |
correct. passing "closed" to IntervalDtype is optional now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. I would add a whatsnew note in other enhancements or create an interval bug fix section and say that the repr for Interval is changing.
let's save that for the follow-up that changes that is aimed specifically at the repr |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Most of the work here is in accomodating backwards-compat.