Skip to content

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

Merged
merged 16 commits into from
Jan 15, 2018

Conversation

jbrockmendel
Copy link
Member

Orthogonal to #19166 since this does not touch TestTimedeltaSeriesArithmetic.

Fix (some) flake8 complaints about 1-letter variable names.

@@ -343,27 +344,26 @@ def test_nat_comparisons_scalar(self):
pd.Period('2011-03', freq='M')]]

for l in data:
Copy link
Contributor

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
Copy link
Contributor

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):
Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Contributor

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])
Copy link
Contributor

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))


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to tests/frame

@jreback jreback added Testing pandas testing functions or related to the test suite Datetime Datetime data dtype Numeric Operations Arithmetic, Comparison, and Logical operations Timedelta Timedelta data type labels Jan 11, 2018
@codecov
Copy link

codecov bot commented Jan 11, 2018

Codecov Report

Merging #19173 into master will decrease coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 89.9% <ø> (-0.03%) ⬇️
#single 41.7% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/plotting/_converter.py 65.22% <0%> (-1.74%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 787ab55...c3cd064. Read the comment docs.

@@ -1613,7 +1602,7 @@ def timedelta64(*args):

try:
assert_series_equal(lhs, rhs)
except:
Copy link
Contributor

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 :<

Copy link
Member Author

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.

Copy link
Contributor

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

@jbrockmendel
Copy link
Member Author

ping

@jreback
Copy link
Contributor

jreback commented Jan 13, 2018

lgtm. needs a rebase as I just merged a pr fixing some delta things. png on green.

@jreback jreback added this to the 0.23.0 milestone Jan 13, 2018
Copy link
Contributor

@jreback jreback left a 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)
Copy link
Contributor

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')])

Copy link
Contributor

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',
Copy link
Contributor

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

@jbrockmendel
Copy link
Member Author

ping

@jreback jreback merged commit aa9e002 into pandas-dev:master Jan 15, 2018
@jreback
Copy link
Contributor

jreback commented Jan 15, 2018

thanks. next PR should be to split operators tests up into sub-files.

@jbrockmendel jbrockmendel deleted the refactor_ops_tests branch January 15, 2018 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Numeric Operations Arithmetic, Comparison, and Logical operations Testing pandas testing functions or related to the test suite Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants