Skip to content

Commit

Permalink
make zero a fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Jan 31, 2018
1 parent 965f721 commit 37efd51
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pandas/tests/indexes/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@

from pandas.tests.indexes.common import Base

# For testing division by (or of) zero for Series with length 5, this
# gives several scalar-zeros and length-5 vector-zeros

zeros = tm.gen_zeros(5)
zeros = [x for x in zeros if not isinstance(x, Series)]

@pytest.fixture(params=zeros)
def zero(request):
"""
For testing division by (or of) zero for Series with length 5, this
gives several scalar-zeros and length-5 vector-zeros
"""
return request.param


def full_like(array, value):
"""Compatibility for numpy<1.8.0
Expand Down Expand Up @@ -162,7 +169,6 @@ def test_divmod_series(self):
for r, e in zip(result, expected):
tm.assert_series_equal(r, e)

@pytest.mark.parametrize('zero', zeros)
def test_div_zero(self, zero):
idx = self.create_index()

Expand All @@ -173,7 +179,6 @@ def test_div_zero(self, zero):
ser_compat = Series(idx).astype('i8') / np.array(zero).astype('i8')
tm.assert_series_equal(ser_compat, Series(result))

@pytest.mark.parametrize('zero', zeros)
def test_floordiv_zero(self, zero):
idx = self.create_index()
expected = Index([np.nan, np.inf, np.inf, np.inf, np.inf],
Expand All @@ -184,7 +189,6 @@ def test_floordiv_zero(self, zero):
ser_compat = Series(idx).astype('i8') // np.array(zero).astype('i8')
tm.assert_series_equal(ser_compat, Series(result))

@pytest.mark.parametrize('zero', zeros)
def test_mod_zero(self, zero):
idx = self.create_index()

Expand All @@ -195,7 +199,6 @@ def test_mod_zero(self, zero):
ser_compat = Series(idx).astype('i8') % np.array(zero).astype('i8')
tm.assert_series_equal(ser_compat, Series(result))

@pytest.mark.parametrize('zero', zeros)
def test_divmod_zero(self, zero):
idx = self.create_index()

Expand Down

0 comments on commit 37efd51

Please sign in to comment.