Skip to content

TST: move misplaced modulo test #23827

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 1 commit into from
Nov 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions pandas/tests/arithmetic/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,44 @@ def test_operators_frame(self):
tm.assert_series_equal(ts / ts, ts / df['A'],
check_names=False)

# TODO: this came from tests.series.test_analytics, needs cleannup and
# de-duplication with test_modulo above
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to do that todo here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Un-commited changes in my local branch make this a hassle I'd rather avoid.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah let's not increase scope of things, plenty to do already.

def test_modulo2(self):
with np.errstate(all='ignore'):

# GH#3590, modulo as ints
p = pd.DataFrame({'first': [3, 4, 5, 8], 'second': [0, 0, 0, 3]})
result = p['first'] % p['second']
expected = Series(p['first'].values % p['second'].values,
dtype='float64')
expected.iloc[0:3] = np.nan
tm.assert_series_equal(result, expected)

result = p['first'] % 0
expected = Series(np.nan, index=p.index, name='first')
tm.assert_series_equal(result, expected)

p = p.astype('float64')
result = p['first'] % p['second']
expected = Series(p['first'].values % p['second'].values)
tm.assert_series_equal(result, expected)

p = p.astype('float64')
result = p['first'] % p['second']
result2 = p['second'] % p['first']
assert not result.equals(result2)

# GH#9144
s = Series([0, 1])

result = s % 0
expected = Series([np.nan, np.nan])
tm.assert_series_equal(result, expected)

result = 0 % s
expected = Series([np.nan, 0.0])
tm.assert_series_equal(result, expected)


class TestAdditionSubtraction(object):
# __add__, __sub__, __radd__, __rsub__, __iadd__, __isub__
Expand Down
36 changes: 0 additions & 36 deletions pandas/tests/series/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,42 +681,6 @@ def test_all_any_params(self):
pytest.raises(NotImplementedError, s.any, bool_only=True)
pytest.raises(NotImplementedError, s.all, bool_only=True)

def test_modulo(self):
with np.errstate(all='ignore'):

# GH3590, modulo as ints
p = DataFrame({'first': [3, 4, 5, 8], 'second': [0, 0, 0, 3]})
result = p['first'] % p['second']
expected = Series(p['first'].values % p['second'].values,
dtype='float64')
expected.iloc[0:3] = np.nan
assert_series_equal(result, expected)

result = p['first'] % 0
expected = Series(np.nan, index=p.index, name='first')
assert_series_equal(result, expected)

p = p.astype('float64')
result = p['first'] % p['second']
expected = Series(p['first'].values % p['second'].values)
assert_series_equal(result, expected)

p = p.astype('float64')
result = p['first'] % p['second']
result2 = p['second'] % p['first']
assert not result.equals(result2)

# GH 9144
s = Series([0, 1])

result = s % 0
expected = Series([nan, nan])
assert_series_equal(result, expected)

result = 0 % s
expected = Series([nan, 0.0])
assert_series_equal(result, expected)

@td.skip_if_no_scipy
def test_corr(self, datetime_series):
import scipy.stats as stats
Expand Down