Skip to content

Commit

Permalink
Remove TestData from series-tests test_rank.py
Browse files Browse the repository at this point in the history
* Replaced TestData usage in pandas/tests/series/test_rank.py with
  fixtures
  • Loading branch information
SaturnFromTitan committed Oct 21, 2019
1 parent 04893a9 commit fda2cf2
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions pandas/tests/series/test_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

from pandas import NaT, Series, Timestamp, date_range
from pandas.api.types import CategoricalDtype
from pandas.tests.series.common import TestData
import pandas.util.testing as tm
from pandas.util.testing import assert_series_equal


class TestSeriesRank(TestData):
class TestSeriesRank:
s = Series([1, 3, 4, 2, np.nan, 2, 1, 5, np.nan, 3])

results = {
Expand All @@ -25,20 +24,20 @@ class TestSeriesRank(TestData):
"dense": np.array([1, 3, 4, 2, np.nan, 2, 1, 5, np.nan, 3]),
}

def test_rank(self):
def test_rank(self, datetime_series):
pytest.importorskip("scipy.stats.special")
rankdata = pytest.importorskip("scipy.stats.rankdata")

self.ts[::2] = np.nan
self.ts[:10][::3] = 4.0
datetime_series[::2] = np.nan
datetime_series[:10][::3] = 4.0

ranks = self.ts.rank()
oranks = self.ts.astype("O").rank()
ranks = datetime_series.rank()
oranks = datetime_series.astype("O").rank()

assert_series_equal(ranks, oranks)

mask = np.isnan(self.ts)
filled = self.ts.fillna(np.inf)
mask = np.isnan(datetime_series)
filled = datetime_series.fillna(np.inf)

# rankdata returns a ndarray
exp = Series(rankdata(filled), index=filled.index, name="ts")
Expand Down

0 comments on commit fda2cf2

Please sign in to comment.