Skip to content

Commit 1f15d10

Browse files
committed
CI: ASV fixups
1 parent a0a37cc commit 1f15d10

File tree

6 files changed

+33
-43
lines changed

6 files changed

+33
-43
lines changed

asv_bench/benchmarks/algorithms.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import warnings
21
from importlib import import_module
32

43
import numpy as np
4+
55
import pandas as pd
66
from pandas.util import testing as tm
77

8+
from .pandas_vb_common import setup # noqa: F401
9+
810
for imp in ['pandas.util', 'pandas.tools.hashing']:
911
try:
1012
hashing = import_module(imp)
@@ -73,10 +75,6 @@ def setup(self):
7375
self.uniques = tm.makeStringIndex(1000).values
7476
self.all = self.uniques.repeat(10)
7577

76-
def time_match_string(self):
77-
with warnings.catch_warnings(record=True):
78-
pd.match(self.all, self.uniques)
79-
8078

8179
class Hashing(object):
8280

@@ -114,6 +112,3 @@ def time_series_timedeltas(self, df):
114112

115113
def time_series_dates(self, df):
116114
hashing.hash_pandas_object(df['dates'])
117-
118-
119-
from .pandas_vb_common import setup # noqa: F401

asv_bench/benchmarks/frame_methods.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import string
22

33
import numpy as np
4+
5+
from pandas import (
6+
DataFrame, MultiIndex, NaT, Series, date_range, isnull, period_range)
47
import pandas.util.testing as tm
5-
from pandas import (DataFrame, Series, MultiIndex, date_range, period_range,
6-
isnull, NaT)
8+
9+
from .pandas_vb_common import setup # noqa: F401
710

811

912
class GetNumericData(object):
@@ -60,9 +63,6 @@ def time_reindex_axis1(self):
6063
def time_reindex_both_axes(self):
6164
self.df.reindex(index=self.idx, columns=self.idx)
6265

63-
def time_reindex_both_axes_ix(self):
64-
self.df.ix[self.idx, self.idx]
65-
6666
def time_reindex_upcast(self):
6767
self.df2.reindex(np.random.permutation(range(1200)))
6868

@@ -521,6 +521,3 @@ def time_series_describe(self):
521521

522522
def time_dataframe_describe(self):
523523
self.df.describe()
524-
525-
526-
from .pandas_vb_common import setup # noqa: F401

asv_bench/benchmarks/groupby.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import warnings
2-
from string import ascii_letters
3-
from itertools import product
41
from functools import partial
2+
from itertools import product
3+
from string import ascii_letters
4+
import warnings
55

66
import numpy as np
7-
from pandas import (DataFrame, Series, MultiIndex, date_range, period_range,
8-
TimeGrouper, Categorical, Timestamp)
7+
8+
from pandas import (
9+
Categorical, DataFrame, MultiIndex, Series, TimeGrouper, Timestamp,
10+
date_range, period_range)
911
import pandas.util.testing as tm
1012

13+
from .pandas_vb_common import setup # noqa: F401
1114

1215
method_blacklist = {
1316
'object': {'median', 'prod', 'sem', 'cumsum', 'sum', 'cummin', 'mean',
@@ -210,7 +213,7 @@ def time_multi_int_nunique(self, df):
210213

211214
class AggFunctions(object):
212215

213-
def setup_cache():
216+
def setup_cache(self):
214217
N = 10**5
215218
fac1 = np.array(['A', 'B', 'C'], dtype='O')
216219
fac2 = np.array(['one', 'two'], dtype='O')
@@ -535,6 +538,3 @@ def setup(self):
535538

536539
def time_first(self):
537540
self.df_nans.groupby('key').transform('first')
538-
539-
540-
from .pandas_vb_common import setup # noqa: F401

pandas/core/sparse/scipy_sparse.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,7 @@ def _get_label_to_i_dict(labels, sort_labels=False):
5858
return (d)
5959

6060
def _get_index_subset_to_coord_dict(index, subset, sort_labels=False):
61-
def robust_get_level_values(i):
62-
# if index has labels (that are not None) use those,
63-
# else use the level location
64-
try:
65-
return index.get_level_values(index.names[i])
66-
except KeyError:
67-
return index.get_level_values(i)
68-
69-
ilabels = list(zip(*[robust_get_level_values(i) for i in subset]))
61+
ilabels = list(zip(*[index._get_level_values(i) for i in subset]))
7062
labels_to_i = _get_label_to_i_dict(ilabels,
7163
sort_labels=sort_labels)
7264
labels_to_i = Series(labels_to_i)

pandas/io/formats/html.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,7 @@ def write_result(self, buf):
161161
_classes.extend(self.classes)
162162

163163
if self.notebook:
164-
div_style = ''
165-
try:
166-
import IPython
167-
if IPython.__version__ < LooseVersion('3.0.0'):
168-
div_style = ' style="max-width:1500px;overflow:auto;"'
169-
except (ImportError, AttributeError):
170-
pass
171-
172-
self.write('<div{style}>'.format(style=div_style))
164+
self.write('<div>')
173165

174166
self.write_style()
175167

pandas/tests/sparse/frame/test_to_from_scipy.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
import numpy as np
3+
import pandas as pd
34
from pandas.util import testing as tm
45
from pandas import SparseDataFrame, SparseSeries
56
from pandas.core.sparse.api import SparseDtype
@@ -168,3 +169,16 @@ def test_from_scipy_fillna(spmatrix):
168169
expected[col].fill_value = -1
169170

170171
tm.assert_sp_frame_equal(sdf, expected)
172+
173+
174+
def test_index_names_multiple_nones():
175+
# https://github.com/pandas-dev/pandas/pull/24092
176+
sparse = pytest.importorskip("scipy.sparse")
177+
178+
s = (pd.Series(1, index=pd.MultiIndex.from_product([['A', 'B'], [0, 1]]))
179+
.to_sparse())
180+
result, _, _ = s.to_coo()
181+
assert isinstance(result, sparse.coo_matrix)
182+
result = result.toarray()
183+
expected = np.ones((2, 2), dtype=int)
184+
tm.assert_numpy_array_equal(result, expected)

0 commit comments

Comments
 (0)