Skip to content

BUG: make conftest._cython_table deterministic for Python<3.6 #22157

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

Merged
merged 1 commit into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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: 2 additions & 5 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,10 @@ def all_arithmetic_operators(request):
return request.param


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


@pytest.fixture(params=_cython_table)
@pytest.fixture(params=list(_cython_table))
def cython_table_items(request):
return request.param

Expand Down
46 changes: 23 additions & 23 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import pandas.core.nanops as nanops
import pandas._libs.lib as lib
from pandas.compat.numpy import function as nv
from pandas.compat import PYPY
from pandas.compat import PYPY, OrderedDict
from pandas.util._decorators import (Appender, cache_readonly,
deprecate_kwarg, Substitution)

Expand Down Expand Up @@ -179,28 +179,28 @@ class SelectionMixin(object):
_selection = None
_internal_names = ['_cache', '__setstate__']
_internal_names_set = set(_internal_names)
_builtin_table = {
builtins.sum: np.sum,
builtins.max: np.max,
builtins.min: np.min
}
_cython_table = {
builtins.sum: 'sum',
builtins.max: 'max',
builtins.min: 'min',
np.all: 'all',
np.any: 'any',
np.sum: 'sum',
np.mean: 'mean',
np.prod: 'prod',
np.std: 'std',
np.var: 'var',
np.median: 'median',
np.max: 'max',
np.min: 'min',
np.cumprod: 'cumprod',
np.cumsum: 'cumsum'
}
_builtin_table = OrderedDict((
(builtins.sum, np.sum),
(builtins.max, np.max),
(builtins.min, np.min),
))
_cython_table = OrderedDict((
(builtins.sum, 'sum'),
(builtins.max, 'max'),
(builtins.min, 'min'),
(np.all, 'all'),
(np.any, 'any'),
(np.sum, 'sum'),
(np.mean, 'mean'),
(np.prod, 'prod'),
(np.std, 'std'),
(np.var, 'var'),
(np.median, 'median'),
(np.max, 'max'),
(np.min, 'min'),
(np.cumprod, 'cumprod'),
(np.cumsum, 'cumsum'),
))

@property
def _selection_name(self):
Expand Down