Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: remove patches to pandas.util.testing.N #24826

Merged
merged 2 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pandas/tests/indexing/multiindex/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ def multiindex_dataframe_random_data():


@pytest.fixture
def multiindex_year_month_day_dataframe_random_data():
def multiindex_year_month_day_dataframe_random_data(monkeypatch):
"""DataFrame with 3 level MultiIndex (year, month, day) covering
first 100 business days from 2000-01-01 with random data"""
tm.N = 100
tdf = tm.makeTimeDataFrame()
with monkeypatch.context() as m:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do all this, makeTimeDataFrame(100) will do this

m.setattr("pandas.util.testing.N", 100)
tdf = tm.makeTimeDataFrame()
ymd = tdf.groupby([lambda x: x.year, lambda x: x.month,
lambda x: x.day]).sum()
# use Int64Index, to make sure things work
Expand Down
9 changes: 4 additions & 5 deletions pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,10 @@ def test_business_freq(self):
assert PeriodIndex(data=idx).freqstr == 'B'

@pytest.mark.slow
def test_business_freq_convert(self):
n = tm.N
tm.N = 300
bts = tm.makeTimeSeries().asfreq('BM')
tm.N = n
def test_business_freq_convert(self, monkeypatch):
with monkeypatch.context() as m:
m.setattr("pandas.util.testing.N", 300)
bts = tm.makeTimeSeries().asfreq('BM')
ts = bts.to_period('M')
_, ax = self.plt.subplots()
bts.plot(ax=ax)
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/reshape/merge/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,11 +697,11 @@ def test_panel_join_overlap(self):
expected = no_overlap.join(p1_suf.join(p2_suf))
tm.assert_panel_equal(joined, expected)

def test_panel_join_many(self):
def test_panel_join_many(self, monkeypatch):
with catch_warnings(record=True):
tm.K = 10
panel = tm.makePanel()
tm.K = 4
with monkeypatch.context() as m:
m.setattr("pandas.util.testing.K", 10)
panel = tm.makePanel()

panels = [panel.iloc[:2], panel.iloc[2:6], panel.iloc[6:]]

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/series/test_alter_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def test_setindex(self, string_series):
string_series.index = None

# wrong length
msg = (r"Length mismatch: Expected axis has (30|100) elements, new"
r" values have (29|99) elements")
msg = ("Length mismatch: Expected axis has 30 elements, new"
" values have 29 elements")
with pytest.raises(ValueError, match=msg):
string_series.index = np.arange(len(string_series) - 1)

Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/test_multilevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ def setup_method(self, method):
s[3] = np.NaN
self.series = s

n = tm.N
tm.N = 100
self.tdf = tm.makeTimeDataFrame()
tm.N = n
self.ymd = self.tdf.groupby([lambda x: x.year, lambda x: x.month,
lambda x: x.day]).sum()

Expand Down