Skip to content

Commit 7e184f0

Browse files
jbrockmendeljreback
authored andcommitted
move misplaced modulo test (#23827)
1 parent 70b99bc commit 7e184f0

File tree

2 files changed

+38
-36
lines changed

2 files changed

+38
-36
lines changed

pandas/tests/arithmetic/test_numeric.py

+38
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,44 @@ def test_operators_frame(self):
597597
tm.assert_series_equal(ts / ts, ts / df['A'],
598598
check_names=False)
599599

600+
# TODO: this came from tests.series.test_analytics, needs cleannup and
601+
# de-duplication with test_modulo above
602+
def test_modulo2(self):
603+
with np.errstate(all='ignore'):
604+
605+
# GH#3590, modulo as ints
606+
p = pd.DataFrame({'first': [3, 4, 5, 8], 'second': [0, 0, 0, 3]})
607+
result = p['first'] % p['second']
608+
expected = Series(p['first'].values % p['second'].values,
609+
dtype='float64')
610+
expected.iloc[0:3] = np.nan
611+
tm.assert_series_equal(result, expected)
612+
613+
result = p['first'] % 0
614+
expected = Series(np.nan, index=p.index, name='first')
615+
tm.assert_series_equal(result, expected)
616+
617+
p = p.astype('float64')
618+
result = p['first'] % p['second']
619+
expected = Series(p['first'].values % p['second'].values)
620+
tm.assert_series_equal(result, expected)
621+
622+
p = p.astype('float64')
623+
result = p['first'] % p['second']
624+
result2 = p['second'] % p['first']
625+
assert not result.equals(result2)
626+
627+
# GH#9144
628+
s = Series([0, 1])
629+
630+
result = s % 0
631+
expected = Series([np.nan, np.nan])
632+
tm.assert_series_equal(result, expected)
633+
634+
result = 0 % s
635+
expected = Series([np.nan, 0.0])
636+
tm.assert_series_equal(result, expected)
637+
600638

601639
class TestAdditionSubtraction(object):
602640
# __add__, __sub__, __radd__, __rsub__, __iadd__, __isub__

pandas/tests/series/test_analytics.py

-36
Original file line numberDiff line numberDiff line change
@@ -681,42 +681,6 @@ def test_all_any_params(self):
681681
pytest.raises(NotImplementedError, s.any, bool_only=True)
682682
pytest.raises(NotImplementedError, s.all, bool_only=True)
683683

684-
def test_modulo(self):
685-
with np.errstate(all='ignore'):
686-
687-
# GH3590, modulo as ints
688-
p = DataFrame({'first': [3, 4, 5, 8], 'second': [0, 0, 0, 3]})
689-
result = p['first'] % p['second']
690-
expected = Series(p['first'].values % p['second'].values,
691-
dtype='float64')
692-
expected.iloc[0:3] = np.nan
693-
assert_series_equal(result, expected)
694-
695-
result = p['first'] % 0
696-
expected = Series(np.nan, index=p.index, name='first')
697-
assert_series_equal(result, expected)
698-
699-
p = p.astype('float64')
700-
result = p['first'] % p['second']
701-
expected = Series(p['first'].values % p['second'].values)
702-
assert_series_equal(result, expected)
703-
704-
p = p.astype('float64')
705-
result = p['first'] % p['second']
706-
result2 = p['second'] % p['first']
707-
assert not result.equals(result2)
708-
709-
# GH 9144
710-
s = Series([0, 1])
711-
712-
result = s % 0
713-
expected = Series([nan, nan])
714-
assert_series_equal(result, expected)
715-
716-
result = 0 % s
717-
expected = Series([nan, 0.0])
718-
assert_series_equal(result, expected)
719-
720684
@td.skip_if_no_scipy
721685
def test_corr(self, datetime_series):
722686
import scipy.stats as stats

0 commit comments

Comments
 (0)