Skip to content

Commit 967bd95

Browse files
leeyspauljreback
authored andcommitted
PERF: Suppress ix warnings benchmarks (#27304)
1 parent afe4a1e commit 967bd95

File tree

4 files changed

+44
-27
lines changed

4 files changed

+44
-27
lines changed

asv_bench/benchmarks/frame_methods.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
import string
23

34
import numpy as np
@@ -320,9 +321,10 @@ class Dropna:
320321

321322
def setup(self, how, axis):
322323
self.df = DataFrame(np.random.randn(10000, 1000))
323-
self.df.ix[50:1000, 20:50] = np.nan
324-
self.df.ix[2000:3000] = np.nan
325-
self.df.ix[:, 60:70] = np.nan
324+
with warnings.catch_warnings(record=True):
325+
self.df.ix[50:1000, 20:50] = np.nan
326+
self.df.ix[2000:3000] = np.nan
327+
self.df.ix[:, 60:70] = np.nan
326328
self.df_mixed = self.df.copy()
327329
self.df_mixed["foo"] = "bar"
328330

@@ -340,9 +342,10 @@ class Count:
340342

341343
def setup(self, axis):
342344
self.df = DataFrame(np.random.randn(10000, 1000))
343-
self.df.ix[50:1000, 20:50] = np.nan
344-
self.df.ix[2000:3000] = np.nan
345-
self.df.ix[:, 60:70] = np.nan
345+
with warnings.catch_warnings(record=True):
346+
self.df.ix[50:1000, 20:50] = np.nan
347+
self.df.ix[2000:3000] = np.nan
348+
self.df.ix[:, 60:70] = np.nan
346349
self.df_mixed = self.df.copy()
347350
self.df_mixed["foo"] = "bar"
348351

@@ -561,7 +564,8 @@ def setup(self):
561564
self.df = DataFrame(np.random.randn(10, 10000))
562565

563566
def time_frame_get_dtype_counts(self):
564-
self.df.get_dtype_counts()
567+
with warnings.catch_warnings(record=True):
568+
self.df.get_dtype_counts()
565569

566570
def time_info(self):
567571
self.df.info()

asv_bench/benchmarks/indexing.py

+29-19
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,20 @@ def time_iloc_slice(self, index, index_structure):
6767
self.data.iloc[:800000]
6868

6969
def time_ix_array(self, index, index_structure):
70-
self.data.ix[self.array]
70+
with warnings.catch_warnings(record=True):
71+
self.data.ix[self.array]
7172

7273
def time_ix_list_like(self, index, index_structure):
73-
self.data.ix[[800000]]
74+
with warnings.catch_warnings(record=True):
75+
self.data.ix[[800000]]
7476

7577
def time_ix_scalar(self, index, index_structure):
76-
self.data.ix[800000]
78+
with warnings.catch_warnings(record=True):
79+
self.data.ix[800000]
7780

7881
def time_ix_slice(self, index, index_structure):
79-
self.data.ix[:800000]
82+
with warnings.catch_warnings(record=True):
83+
self.data.ix[:800000]
8084

8185
def time_loc_array(self, index, index_structure):
8286
self.data.loc[self.array]
@@ -140,7 +144,8 @@ class DataFrameStringIndexing:
140144
def setup(self):
141145
index = tm.makeStringIndex(1000)
142146
columns = tm.makeStringIndex(30)
143-
self.df = DataFrame(np.random.randn(1000, 30), index=index, columns=columns)
147+
with warnings.catch_warnings(record=True):
148+
self.df = DataFrame(np.random.randn(1000, 30), index=index, columns=columns)
144149
self.idx_scalar = index[100]
145150
self.col_scalar = columns[10]
146151
self.bool_indexer = self.df[self.col_scalar] > 0
@@ -151,7 +156,8 @@ def time_get_value(self):
151156
self.df.get_value(self.idx_scalar, self.col_scalar)
152157

153158
def time_ix(self):
154-
self.df.ix[self.idx_scalar, self.col_scalar]
159+
with warnings.catch_warnings(record=True):
160+
self.df.ix[self.idx_scalar, self.col_scalar]
155161

156162
def time_loc(self):
157163
self.df.loc[self.idx_scalar, self.col_scalar]
@@ -215,24 +221,27 @@ def setup(self):
215221
self.df = DataFrame(self.s)
216222

217223
n = 100000
218-
self.mdt = DataFrame(
219-
{
220-
"A": np.random.choice(range(10000, 45000, 1000), n),
221-
"B": np.random.choice(range(10, 400), n),
222-
"C": np.random.choice(range(1, 150), n),
223-
"D": np.random.choice(range(10000, 45000), n),
224-
"x": np.random.choice(range(400), n),
225-
"y": np.random.choice(range(25), n),
226-
}
227-
)
224+
with warnings.catch_warnings(record=True):
225+
self.mdt = DataFrame(
226+
{
227+
"A": np.random.choice(range(10000, 45000, 1000), n),
228+
"B": np.random.choice(range(10, 400), n),
229+
"C": np.random.choice(range(1, 150), n),
230+
"D": np.random.choice(range(10000, 45000), n),
231+
"x": np.random.choice(range(400), n),
232+
"y": np.random.choice(range(25), n),
233+
}
234+
)
228235
self.idx = IndexSlice[20000:30000, 20:30, 35:45, 30000:40000]
229236
self.mdt = self.mdt.set_index(["A", "B", "C", "D"]).sort_index()
230237

231238
def time_series_ix(self):
232-
self.s.ix[999]
239+
with warnings.catch_warnings(record=True):
240+
self.s.ix[999]
233241

234242
def time_frame_ix(self):
235-
self.df.ix[999]
243+
with warnings.catch_warnings(record=True):
244+
self.df.ix[999]
236245

237246
def time_index_slice(self):
238247
self.mdt.loc[self.idx, :]
@@ -309,7 +318,8 @@ def time_lookup_iloc(self, s):
309318
s.iloc
310319

311320
def time_lookup_ix(self, s):
312-
s.ix
321+
with warnings.catch_warnings(record=True):
322+
s.ix
313323

314324
def time_lookup_loc(self, s):
315325
s.loc

asv_bench/benchmarks/io/msgpack.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
import numpy as np
23
from pandas import DataFrame, date_range, read_msgpack
34
import pandas.util.testing as tm
@@ -16,7 +17,8 @@ def setup(self):
1617
index=date_range("20000101", periods=N, freq="H"),
1718
)
1819
self.df["object"] = tm.makeStringIndex(N)
19-
self.df.to_msgpack(self.fname)
20+
with warnings.catch_warnings(record=True):
21+
self.df.to_msgpack(self.fname)
2022

2123
def time_read_msgpack(self):
2224
read_msgpack(self.fname)

pandas/core/generic.py

+1
Original file line numberDiff line numberDiff line change
@@ -5603,6 +5603,7 @@ def get_dtype_counts(self):
56035603
FutureWarning,
56045604
stacklevel=2,
56055605
)
5606+
56065607
from pandas import Series
56075608

56085609
return Series(self._data.get_dtype_counts())

0 commit comments

Comments
 (0)