Skip to content

Commit

Permalink
Remove makePeriodSeries
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Nov 24, 2023
1 parent 185cdfc commit 72b798d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 39 deletions.
22 changes: 0 additions & 22 deletions pandas/_testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,24 +519,10 @@ def makeTimeSeries(nper=None, freq: Frequency = "B", name=None) -> Series:
)


def makePeriodSeries(nper=None, name=None) -> Series:
if nper is None:
nper = _N
return Series(
np.random.default_rng(2).standard_normal(nper),
index=makePeriodIndex(nper),
name=name,
)


def getTimeSeriesData(nper=None, freq: Frequency = "B") -> dict[str, Series]:
return {c: makeTimeSeries(nper, freq) for c in getCols(_K)}


def getPeriodData(nper=None) -> dict[str, Series]:
return {c: makePeriodSeries(nper) for c in getCols(_K)}


# make frame
def makeTimeDataFrame(nper=None, freq: Frequency = "B") -> DataFrame:
data = getTimeSeriesData(nper, freq)
Expand Down Expand Up @@ -565,11 +551,6 @@ def makeMixedDataFrame() -> DataFrame:
return DataFrame(getMixedTypeDict()[1])


def makePeriodFrame(nper=None) -> DataFrame:
data = getPeriodData(nper)
return DataFrame(data)


def makeCustomIndex(
nentries,
nlevels,
Expand Down Expand Up @@ -1102,7 +1083,6 @@ def shares_memory(left, right) -> bool:
"get_finest_unit",
"get_obj",
"get_op_from_name",
"getPeriodData",
"getSeriesData",
"getTimeSeriesData",
"iat",
Expand All @@ -1122,9 +1102,7 @@ def shares_memory(left, right) -> bool:
"makeMultiIndex",
"makeNumericIndex",
"makeObjectSeries",
"makePeriodFrame",
"makePeriodIndex",
"makePeriodSeries",
"make_rand_series",
"makeRangeIndex",
"makeStringIndex",
Expand Down
23 changes: 17 additions & 6 deletions pandas/tests/dtypes/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
Series,
TimedeltaIndex,
date_range,
period_range,
)
import pandas._testing as tm

Expand Down Expand Up @@ -81,7 +82,7 @@ def test_notna_notnull(notna_f):
tm.makeStringSeries(),
tm.makeObjectSeries(),
tm.makeTimeSeries(),
tm.makePeriodSeries(),
Series(range(5), period_range("2020-01-01", periods=5)),
],
)
def test_null_check_is_series(null_func, ser):
Expand Down Expand Up @@ -124,15 +125,25 @@ def test_isna_isnull(self, isna_f):

@pytest.mark.parametrize("isna_f", [isna, isnull])
@pytest.mark.parametrize(
"df",
"data",
[
tm.makeTimeDataFrame(),
tm.makePeriodFrame(),
tm.makeMixedDataFrame(),
np.arange(4, dtype=float),
[0.0, 1.0, 0.0, 1.0],
list("abcd"),
date_range("2020-01-01", periods=4),
],
)
def test_isna_isnull_frame(self, isna_f, df):
@pytest.mark.parametrize(
"index",
[
date_range("2020-01-01", periods=4),
range(4),
period_range("2020-01-01", periods=4),
],
)
def test_isna_isnull_frame(self, isna_f, data, index):
# frame
df = pd.DataFrame(data, index=index)
result = isna_f(df)
expected = df.apply(isna_f)
tm.assert_frame_equal(result, expected)
Expand Down
8 changes: 5 additions & 3 deletions pandas/tests/frame/methods/test_shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ def test_shift_by_offset(self, datetime_frame, frame_or_series):

def test_shift_with_periodindex(self, frame_or_series):
# Shifting with PeriodIndex
ps = tm.makePeriodFrame()
ps = DataFrame(
np.arange(4, dtype=float), index=pd.period_range("2020-01-01", periods=4)
)
ps = tm.get_obj(ps, frame_or_series)

shifted = ps.shift(1)
Expand Down Expand Up @@ -492,7 +494,7 @@ def test_shift_axis1_multiple_blocks_with_int_fill(self):
tm.assert_frame_equal(result, expected)

def test_period_index_frame_shift_with_freq(self, frame_or_series):
ps = tm.makePeriodFrame()
ps = DataFrame(range(4), index=pd.period_range("2020-01-01", periods=4))
ps = tm.get_obj(ps, frame_or_series)

shifted = ps.shift(1, freq="infer")
Expand Down Expand Up @@ -529,7 +531,7 @@ def test_datetime_frame_shift_with_freq(self, datetime_frame, frame_or_series):
tm.assert_equal(unshifted, inferred_ts)

def test_period_index_frame_shift_with_freq_error(self, frame_or_series):
ps = tm.makePeriodFrame()
ps = DataFrame(range(4), index=pd.period_range("2020-01-01", periods=4))
ps = tm.get_obj(ps, frame_or_series)
msg = "Given freq M does not match PeriodIndex freq D"
with pytest.raises(ValueError, match=msg):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def test_irregular_datetime64_repr_bug(self):
assert rs == xp

def test_business_freq(self):
bts = tm.makePeriodSeries()
bts = Series(range(5), period_range("2020-01-01", periods=5))
msg = r"PeriodDtype\[B\] is deprecated"
dt = bts.index[0].to_timestamp()
with tm.assert_produces_warning(FutureWarning, match=msg):
Expand Down
11 changes: 4 additions & 7 deletions pandas/tests/plotting/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
DataFrame,
Series,
date_range,
period_range,
plotting,
)
import pandas._testing as tm
Expand Down Expand Up @@ -45,11 +46,6 @@ def series():
return tm.makeStringSeries(name="series")


@pytest.fixture
def iseries():
return tm.makePeriodSeries(name="iseries")


class TestSeriesPlots:
@pytest.mark.slow
@pytest.mark.parametrize("kwargs", [{"label": "foo"}, {"use_index": False}])
Expand Down Expand Up @@ -82,8 +78,9 @@ def test_plot_ts_bar(self, ts):
def test_plot_ts_area_stacked(self, ts):
_check_plot_works(ts.plot.area, stacked=False)

def test_plot_iseries(self, iseries):
_check_plot_works(iseries.plot)
def test_plot_iseries(self):
ser = Series(range(5), period_range("2020-01-01", periods=5))
_check_plot_works(ser.plot)

@pytest.mark.parametrize(
"kind",
Expand Down

0 comments on commit 72b798d

Please sign in to comment.