-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
disallow normalize=True with Tick classes #21427
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #21427 +/- ##
==========================================
+ Coverage 91.9% 91.9% +<.01%
==========================================
Files 153 153
Lines 49606 49608 +2
==========================================
+ Hits 45589 45591 +2
Misses 4017 4017
Continue to review full report at Codecov.
|
pandas/tseries/offsets.py
Outdated
@@ -2219,6 +2219,9 @@ class Tick(SingleConstructorOffset): | |||
def __init__(self, n=1, normalize=False): | |||
# TODO: do Tick classes with normalize=True make sense? |
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.
It seems like this was a broader API design question. Depending on how things go, creating an issue to "close" with this PR might be appropriate.
cc @jreback
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.
@jbrockmendel : Could you remove this comment? Looks like your fix is here to say. 😄
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -112,7 +112,7 @@ Timezones | |||
Offsets | |||
^^^^^^^ | |||
|
|||
- | |||
- :class:`Tick` subclasses can no longer be created with the argument `normalize=True` (:issue:`????`) |
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.
In cases like these, reference the PR itself (unless an issue is created as pointed out here).
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.
The same goes for the test case (i.e. add a comment referencing the PR).
@jbrockmendel : If this is the correct way to fix (I'm not 100% sure @jreback ), then your PR is good to go. |
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.
is there an associated issue?
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -112,7 +112,7 @@ Timezones | |||
Offsets | |||
^^^^^^^ | |||
|
|||
- | |||
- :class:`Tick` subclasses can no longer be created with the argument `normalize=True` (:issue:`21427`) |
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.
double backticks here. I would be a little more informative (say for example Minute, Second).
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.
Will do.
@jreback : No, there isn't AFAIK. I suggested to @jbrockmendel that one be opened only if there was disagreement about the fix. |
Opened #21434, extends the example given in the OP and mentions that |
@jbrockmendel you didn’t need to make an issue, but ok can u make a sub section with an example in whatsnew |
Just added a whatsnew section, not sure it adds much on top of the one-line note (also fleshed out) |
doc/source/whatsnew/v0.24.0.txt
Outdated
|
||
.. ipython:: python | ||
|
||
ts = pd.Timestamp('2018-06-11 18:01:14') |
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.
show ts and tic here
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.
Will do. Does showing the tic here work given that the line that defines it will raise in the new version?
doc/source/whatsnew/v0.24.0.txt
Outdated
|
||
.. code-block:: ipython | ||
|
||
In [2]: ts = pd.Timestamp('2018-06-11 18:01:14') |
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 don't need to repeat ts & tic here, just the calculations
|
||
In [5]: ts + tic + tic + tic == ts + (tic + tic + tic) | ||
Out [5]: False | ||
|
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.
add the Current behavior via an ipython block (obviously w/o normalize passed)
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. And just the same ts + tic + tic + tic == ts + (tic + tic + tic)
demonstration? With normalize=False
that behavior is unchanged.
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -26,6 +26,33 @@ Backwards incompatible API changes | |||
|
|||
.. _whatsnew_0240.api.datetimelike: | |||
|
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.
add a ref to this section (this is a new one, like: _whatsnew_0240.api.datetimelike.normalize )
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -112,7 +139,7 @@ Timezones | |||
Offsets | |||
^^^^^^^ | |||
|
|||
- |
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 you have a subsection, you don't need a note, the subsection IS the note.
doc/source/whatsnew/v0.24.0.txt
Outdated
Creating a ``Tick`` object (:class:``Day``, :class:``Hour``, :class:``Minute``, | ||
:class:``Second``, :class:``Milli``, :class:``Micro``, :class:``Nano``) with | ||
`normalize=True` is no longer supported. This prevents unexpected behavior | ||
where addition could fail to be monotone or associative. |
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.
add the issue number here
thanks @jbrockmendel |
The problem: allowing
Tick
objects withnormalize=True
causes addition to lose monotonicity/associativity