Skip to content

Commit d2fd1e4

Browse files
topper-123victor
authored and
victor
committed
make conftest._cython_table deterministic for Python<3.6 (pandas-dev#22157)
1 parent 5118762 commit d2fd1e4

File tree

2 files changed

+25
-28
lines changed

2 files changed

+25
-28
lines changed

pandas/conftest.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,10 @@ def all_arithmetic_operators(request):
123123
return request.param
124124

125125

126-
# use sorted as dicts in py<3.6 have random order, which xdist doesn't like
127-
_cython_table = sorted(((key, value) for key, value in
128-
pd.core.base.SelectionMixin._cython_table.items()),
129-
key=lambda x: x[0].__name__)
126+
_cython_table = pd.core.base.SelectionMixin._cython_table.items()
130127

131128

132-
@pytest.fixture(params=_cython_table)
129+
@pytest.fixture(params=list(_cython_table))
133130
def cython_table_items(request):
134131
return request.param
135132

pandas/core/base.py

+23-23
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import pandas.core.nanops as nanops
2424
import pandas._libs.lib as lib
2525
from pandas.compat.numpy import function as nv
26-
from pandas.compat import PYPY
26+
from pandas.compat import PYPY, OrderedDict
2727
from pandas.util._decorators import (Appender, cache_readonly,
2828
deprecate_kwarg, Substitution)
2929

@@ -179,28 +179,28 @@ class SelectionMixin(object):
179179
_selection = None
180180
_internal_names = ['_cache', '__setstate__']
181181
_internal_names_set = set(_internal_names)
182-
_builtin_table = {
183-
builtins.sum: np.sum,
184-
builtins.max: np.max,
185-
builtins.min: np.min
186-
}
187-
_cython_table = {
188-
builtins.sum: 'sum',
189-
builtins.max: 'max',
190-
builtins.min: 'min',
191-
np.all: 'all',
192-
np.any: 'any',
193-
np.sum: 'sum',
194-
np.mean: 'mean',
195-
np.prod: 'prod',
196-
np.std: 'std',
197-
np.var: 'var',
198-
np.median: 'median',
199-
np.max: 'max',
200-
np.min: 'min',
201-
np.cumprod: 'cumprod',
202-
np.cumsum: 'cumsum'
203-
}
182+
_builtin_table = OrderedDict((
183+
(builtins.sum, np.sum),
184+
(builtins.max, np.max),
185+
(builtins.min, np.min),
186+
))
187+
_cython_table = OrderedDict((
188+
(builtins.sum, 'sum'),
189+
(builtins.max, 'max'),
190+
(builtins.min, 'min'),
191+
(np.all, 'all'),
192+
(np.any, 'any'),
193+
(np.sum, 'sum'),
194+
(np.mean, 'mean'),
195+
(np.prod, 'prod'),
196+
(np.std, 'std'),
197+
(np.var, 'var'),
198+
(np.median, 'median'),
199+
(np.max, 'max'),
200+
(np.min, 'min'),
201+
(np.cumprod, 'cumprod'),
202+
(np.cumsum, 'cumsum'),
203+
))
204204

205205
@property
206206
def _selection_name(self):

0 commit comments

Comments
 (0)