-
-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
BUG: Fix timedelta64+Timestamp, closes #24775 #26916
Conversation
@@ -112,3 +112,9 @@ def test_addition_subtraction_preserve_frequency(self): | |||
td64 = np.timedelta64(1, 'D') | |||
assert (ts + td64).freq == original_freq | |||
assert (ts - td64).freq == original_freq | |||
|
|||
def test_radd_timedelta64(self): |
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.
seems like a lone test; can u co-locate with same for Timedelta and (or parametrize)
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.
This is definitely the appropriate place. I think there are other tests in tests.scalar.timestamp that belong in this file
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.
my point is to also include pd.Timedelta here as well via parameterization. I suspect we already test this elsewhere, so rather than add a one-off, should add elsewhere (or simply combine / move them here if this is the final destination).
(pandas) bash-3.2$ grep -r _radd pandas/tests/ --include '*.py'
pandas/tests//tseries/offsets/test_offsets.py: def test_radd(self):
pandas/tests//frame/test_query_eval.py: for op_str, op, rop in [('+', '__add__', '__radd__'),
pandas/tests//arithmetic/test_datetime64.py: if op_str not in ['__add__', '__radd__', '__sub__']:
pandas/tests//arithmetic/test_datetime64.py: if op_str not in ['__add__', '__radd__', '__sub__', '__rsub__']:
pandas/tests//arithmetic/test_datetime64.py: @pytest.mark.parametrize('op', ['__add__', '__radd__',
pandas/tests//arithmetic/test_timedelta64.py: # Tests for timedelta64[ns] __add__, __sub__, __radd__, __rsub__
pandas/tests//arithmetic/test_numeric.py: # __add__, __sub__, __radd__, __rsub__, __iadd__, __isub__
pandas/tests//arithmetic/test_numeric.py: def test_series_frame_radd_bug(self):
pandas/tests//arithmetic/test_object.py: def test_objarr_radd_str(self, box):
pandas/tests//arithmetic/test_object.py: def test_objarr_radd_str_invalid(self, dtype, data, box):
pandas/tests//arithmetic/test_object.py: def test_series_with_dtype_radd_timedelta(self, dtype):
pandas/tests//scalar/timedelta/test_arithmetic.py: __add__, __radd__,
pandas/tests//scalar/timedelta/test_arithmetic.py: # datetime + Timedelta does _not_ call Timedelta.__radd__,
pandas/tests//indexes/test_category.py: (lambda idx: ['a', 'b'] + idx, '__radd__'),
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 suspect we already test this elsewhere, so rather than add a one-off, should add elsewhere (or simply combine / move them here if this is the final destination).
well we don't already test this specifically, since this test fails on master. Most of the grep results posted are for non-scalars; we definitely don't want to start mixing the scalar tests in with those. I'll collect other Timestamp arithmetic tests that are currently misplaced and put them in this file.
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 suspect we already test this elsewhere, so rather than add a one-off, should add elsewhere (or simply combine / move them here if this is the final destination).
well we don't already test this specifically, since this test fails on master. Most of the grep results posted are for non-scalars; we definitely don't want to start mixing the scalar tests in with those. I'll collect other Timestamp arithmetic tests that are currently misplaced and put them in this file.
If you read my point is that we certaily test this for Timedelta
. so these belong together.
Codecov Report
@@ Coverage Diff @@
## master #26916 +/- ##
===========================================
- Coverage 91.87% 41.1% -50.77%
===========================================
Files 180 180
Lines 50712 50712
===========================================
- Hits 46590 20845 -25745
- Misses 4122 29867 +25745
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #26916 +/- ##
==========================================
- Coverage 91.99% 91.98% -0.01%
==========================================
Files 180 180
Lines 50774 50774
==========================================
- Hits 46712 46707 -5
- Misses 4062 4067 +5
Continue to review full report at Codecov.
|
@@ -112,3 +112,9 @@ def test_addition_subtraction_preserve_frequency(self): | |||
td64 = np.timedelta64(1, 'D') | |||
assert (ts + td64).freq == original_freq | |||
assert (ts - td64).freq == original_freq | |||
|
|||
def test_radd_timedelta64(self): |
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.
my point is to also include pd.Timedelta here as well via parameterization. I suspect we already test this elsewhere, so rather than add a one-off, should add elsewhere (or simply combine / move them here if this is the final destination).
(pandas) bash-3.2$ grep -r _radd pandas/tests/ --include '*.py'
pandas/tests//tseries/offsets/test_offsets.py: def test_radd(self):
pandas/tests//frame/test_query_eval.py: for op_str, op, rop in [('+', '__add__', '__radd__'),
pandas/tests//arithmetic/test_datetime64.py: if op_str not in ['__add__', '__radd__', '__sub__']:
pandas/tests//arithmetic/test_datetime64.py: if op_str not in ['__add__', '__radd__', '__sub__', '__rsub__']:
pandas/tests//arithmetic/test_datetime64.py: @pytest.mark.parametrize('op', ['__add__', '__radd__',
pandas/tests//arithmetic/test_timedelta64.py: # Tests for timedelta64[ns] __add__, __sub__, __radd__, __rsub__
pandas/tests//arithmetic/test_numeric.py: # __add__, __sub__, __radd__, __rsub__, __iadd__, __isub__
pandas/tests//arithmetic/test_numeric.py: def test_series_frame_radd_bug(self):
pandas/tests//arithmetic/test_object.py: def test_objarr_radd_str(self, box):
pandas/tests//arithmetic/test_object.py: def test_objarr_radd_str_invalid(self, dtype, data, box):
pandas/tests//arithmetic/test_object.py: def test_series_with_dtype_radd_timedelta(self, dtype):
pandas/tests//scalar/timedelta/test_arithmetic.py: __add__, __radd__,
pandas/tests//scalar/timedelta/test_arithmetic.py: # datetime + Timedelta does _not_ call Timedelta.__radd__,
pandas/tests//indexes/test_category.py: (lambda idx: ['a', 'b'] + idx, '__radd__'),
def test_compare_zerodim_array(self): | ||
# GH#26916 | ||
ts = Timestamp.now() | ||
td64 = np.datetime64('2016-01-01', 'ns') |
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.
this is odd named td64 no?
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.
typo, will update
Fixed typo, determined there's only a couple other dedicated Timestamp arith tests, moved them over to the appropriate place and parametrized them. We've done a good job at making tslibs self-contained, less so with the tests. At some point I'd like to change that, hopefully make it easier to identify gaps in isolated coverage. |
yep i here ya increasing coverage always +1 |
td = np.timedelta64(3, 'h') | ||
assert td + ts == ts + td | ||
|
||
@pytest.mark.parametrize('other,exdiff', [ |
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 do: exdiff -> expected_difference
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.
This seems good. Can you fix the merge conflict and merge on green?
i have some open requests here |
I think your open request is that we put this with the Timedelta arithmetic tests. But doing so would break the organization of the Timedelta tests. |
no my requests are to parametrize over a Timedelta the tests u added |
added. |
thanks @jbrockmendel |
git diff upstream/master -u -- "*.py" | flake8 --diff