-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
DEPR: Deprecate passing range-like arguments to DatetimeIndex, TimedeltaIndex #23919
Conversation
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.
Thanks! Looks good to me, a minor comment.
Further, can you add an assertion for the warning on verify_integrity
?
Also, small suggestion: you now left one DatetimeIndex in there with an assert_produces_warning
. I would maybe do such an assertion in a separate test (now that assertion is a bit buried in a bigger test that is for the rest using date_range
)
@@ -385,7 +385,7 @@ def test_groupby_groups_datetimeindex(self): | |||
groups = grouped.groups | |||
assert isinstance(list(groups.keys())[0], datetime) | |||
|
|||
# GH 11442 | |||
# GH#11442 |
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.
not important, but was just wondering: why are you adding the '#' everywhere?
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.
Mostly for internal consistency (not a big deal, but for grepping purposes). A little bit because I was curious how long it would take before someone asked about it.
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.
we have have the gh-xxxx style as well, slight prefernce for that
with warnings.catch_warnings(): | ||
# we ignore warnings from passing verify_integrity=False | ||
# TODO: If we knew what was going in to **d, we might be able to | ||
# go through _simple_new instead |
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.
you can check __reduce__
, d
should be _data
and the attributes dict
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.
good idea, that seems to work; just pushed
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 like this broke the legacy pickle tests; reverted.
Codecov Report
@@ Coverage Diff @@
## master #23919 +/- ##
=========================================
Coverage ? 92.31%
=========================================
Files ? 161
Lines ? 51489
Branches ? 0
=========================================
Hits ? 47533
Misses ? 3956
Partials ? 0
Continue to review full report at Codecov.
|
pandas/core/indexes/timedeltas.py
Outdated
@@ -131,10 +132,18 @@ def __new__(cls, data=None, unit=None, freq=None, start=None, end=None, | |||
periods=None, closed=None, dtype=None, copy=False, | |||
name=None, verify_integrity=True): | |||
|
|||
if verify_integrity is not True: |
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.
why isn't the default of verify_integrity 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.
Because by default we do verify the integrity of a passed frequency. Best guess as to initial motivation is that verify_integrity=False
is kind of like fastpath=True
and was never really intended to be user-facing.
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.
right but aren't you deprecating it?
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. In the future it will just be set to verify_integrity=True
at the top of __new__
. (and when the time comes, in the TDA/DTA constructors it will always be True.
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.
We still need the variable to exist because there are cases in which we can determine it is not necessary, in which case we can skip a potentially-expensive check.
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.
I don't recall that (and dont see how it would work), but yah, not passing freq would make verify_integrity unnecessary.
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.
We still need the variable to exist because there are cases in which we can determine it is not necessary, in which case we can skip a potentially-expensive check.
@jbrockmendel Isn't the end goal to actually remove the verify_integrity
keyword from the Index constructors? (not just keep it with a fixed True value). Because otherwise, why are you deprecating verify_integrity=False
if we actually want to use it ourselves?
In cases that we determine the check is not necessary, we can use _simple_new
?
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.
Eventually verify-integrity will not be in the signature. The first line of the method will just define it to be True.
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.
OK, but then as @jreback said, we should put it at None so we can also deprecate the case for somebody setting it to True explicitly.
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.
done
@@ -385,7 +385,7 @@ def test_groupby_groups_datetimeindex(self): | |||
groups = grouped.groups | |||
assert isinstance(list(groups.keys())[0], datetime) | |||
|
|||
# GH 11442 | |||
# GH#11442 |
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.
we have have the gh-xxxx style as well, slight prefernce for that
lgtm |
circle fail is Hypothesis; de-facto green |
Shouldn't we do the same for |
Possibly. There are also |
thanks! |
Also
verify_integrity
since allowing that to be False complicates things, and internally if its False we should be using simple_new anywaygit diff upstream/master -u -- "*.py" | flake8 --diff