-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Split and parametrize test_operators #19173
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
@@ -343,27 +344,26 @@ def test_nat_comparisons_scalar(self): | |||
pd.Period('2011-03', freq='M')]] | |||
|
|||
for l in data: |
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 an parametrize over data here
# smoke tests for valid DateOffsets | ||
ser = Series([Timestamp('20130101 9:01'), Timestamp('20130101 9:02')]) | ||
|
||
# valid DateOffsets |
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.
parameterize (I think you already have these classes as a fixture in offsets somewhere)
@@ -1281,7 +1271,7 @@ def test_sub_datetime_compat(self): | |||
assert_series_equal(s - dt, exp) | |||
assert_series_equal(s - Timestamp(dt), exp) | |||
|
|||
def test_datetime_series_with_timedelta(self): | |||
def test_dt64series_with_timedelta(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.
don't run words together, dt64 is ok, but generally don't abbreviate
def test_dt64series_astype_object(self): | ||
dt64ser = Series(date_range('20130101', periods=3)) | ||
result = dt64ser.astype(object) | ||
assert isinstance(result.iloc[0], datetime) |
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 construct the expected directly and compare. astype tests should be in test_dtypes.py
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.
and I think these are dupes anyhow
result = ser + pd.Timedelta('3 days') | ||
assert_series_equal(result, expected) | ||
|
||
@pytest.mark.parametrize('dtype', [None, object]) |
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.
at the very least should split test_operators to timestamp, timedelta, numeric sub-modules (next PR)
@@ -2240,3 +2229,51 @@ def test_idxminmax_with_inf(self): | |||
assert np.isnan(s.idxmin(skipna=False)) | |||
assert s.idxmax() == 0 | |||
np.isnan(s.idxmax(skipna=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.
move to tests/frame
Codecov Report
@@ Coverage Diff @@
## master #19173 +/- ##
==========================================
- Coverage 91.55% 91.53% -0.03%
==========================================
Files 147 147
Lines 48812 48812
==========================================
- Hits 44690 44678 -12
- Misses 4122 4134 +12
Continue to review full report at Codecov.
|
@@ -1613,7 +1602,7 @@ def timedelta64(*args): | |||
|
|||
try: | |||
assert_series_equal(lhs, rhs) | |||
except: |
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.
what the heck is this? don't try/except and then raise an assertion :<
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 can only speculate that the original author wanted to customize the exception message.
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.
pls remove it’s not necessary
the asserts all do this now
ping |
lgtm. needs a rebase as I just merged a pr fixing some delta things. png on green. |
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.
fine. some follow up notes for later. ping on green.
expected = Series([Timestamp('20130101 9:01:05'), | ||
Timestamp('20130101 9:02:05')]) | ||
|
||
result = ser + pd.offsets.Second(5) |
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.
followup note to cycle thru all Tick offsets
expected = Series([Timestamp('20130101 9:00:55'), | ||
Timestamp('20130101 9:01:55')]) | ||
|
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.
same here
with pytest.raises(TypeError): | ||
pd.offsets.Second(5) - ser | ||
|
||
@pytest.mark.parametrize('cls_name', ['Day', 'Hour', '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.
follow up to make this a fixture (to use above as well), prob could move the fixtures in tests/tseries/offsets to the top-level conftest
ping |
thanks. next PR should be to split operators tests up into sub-files. |
Orthogonal to #19166 since this does not touch
TestTimedeltaSeriesArithmetic
.Fix (some) flake8 complaints about 1-letter variable names.