Skip to content

Commit

Permalink
move fixture to conftest
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Feb 2, 2018
1 parent 64b0c08 commit be1e2e1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
18 changes: 17 additions & 1 deletion pandas/tests/indexes/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import pytest
import numpy as np
import pandas as pd

import pandas.util.testing as tm
from pandas.core.indexes.api import Index, MultiIndex
from pandas.compat import lzip
from pandas.compat import lzip, long


@pytest.fixture(params=[tm.makeUnicodeIndex(100),
Expand All @@ -29,3 +30,18 @@ def indices(request):
def one(request):
# zero-dim integer array behaves like an integer
return request.param


zeros = [box([0] * 5, dtype=dtype)
for box in [pd.Index, np.array]
for dtype in [np.int64, np.uint64, np.float64]]
zeros.extend([np.array(0, dtype=dtype)
for dtype in [np.int64, np.uint64, np.float64]])
zeros.extend([0, 0.0, long(0)])


@pytest.fixture(params=zeros)
def zero(request):
# For testing division by (or of) zero for Index with length 5, this
# gives several scalar-zeros and length-5 vector-zeros
return request.param
16 changes: 1 addition & 15 deletions pandas/tests/indexes/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

from datetime import datetime
from pandas.compat import range, PY3, long
from pandas.compat import range, PY3

import numpy as np

Expand All @@ -18,16 +18,6 @@
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 = [box([0] * 5, dtype=dtype)
for box in [pd.Index, np.array]
for dtype in [np.int64, np.uint64, np.float64]]
zeros.extend([np.array(0, dtype=dtype)
for dtype in [np.int64, np.uint64, np.float64]])
zeros.extend([0, 0.0, long(0)])


def full_like(array, value):
"""Compatibility for numpy<1.8.0
"""
Expand Down Expand Up @@ -167,7 +157,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 @@ -178,7 +167,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 @@ -189,7 +177,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 @@ -200,7 +187,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 be1e2e1

Please sign in to comment.