Skip to content

Commit 7575ba2

Browse files
author
Francesc Alted
committed
Using constants instead of literals for numexpr version
1 parent 7a275ce commit 7575ba2

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

pandas/computation/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
from distutils.version import LooseVersion
44

55
_NUMEXPR_INSTALLED = False
6+
_MIN_NUMEXPR_VERSION = "2.4.6"
67

78
try:
89
import numexpr as ne
910
ver = ne.__version__
10-
_NUMEXPR_INSTALLED = ver >= LooseVersion('2.4.6')
11+
_NUMEXPR_INSTALLED = ver >= LooseVersion(_MIN_NUMEXPR_VERSION)
1112

1213
if not _NUMEXPR_INSTALLED:
1314
warnings.warn(
1415
"The installed version of numexpr {ver} is not supported "
1516
"in pandas and will be not be used\nThe minimum supported "
16-
"version is 2.4.6\n".format(ver=ver), UserWarning)
17+
"version is {min_ver}\n".format(ver=ver,
18+
min_ver=_MIN_NUMEXPR_VERSION), UserWarning)
1719

1820
except ImportError: # pragma: no cover
1921
pass

pandas/tests/computation/test_compat.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
from pandas.computation.engines import _engines
1212
import pandas.computation.expr as expr
13+
from pandas.computation import _MIN_NUMEXPR_VERSION
14+
1315

1416
ENGINES_PARSERS = list(product(_engines, expr._parsers))
1517

@@ -21,7 +23,7 @@ def test_compat():
2123
try:
2224
import numexpr as ne
2325
ver = ne.__version__
24-
if ver < LooseVersion('2.4.6'):
26+
if ver < LooseVersion(_MIN_NUMEXPR_VERSION):
2527
with tm.assert_produces_warning(UserWarning,
2628
check_stacklevel=False):
2729
assert not _NUMEXPR_INSTALLED
@@ -49,12 +51,10 @@ def testit():
4951
except ImportError:
5052
pytest.skip("no numexpr")
5153
else:
52-
if ne.__version__ < LooseVersion('2.1'):
54+
if ne.__version__ < LooseVersion(_MIN_NUMEXPR_VERSION):
5355
with tm.assertRaisesRegexp(ImportError, "'numexpr' version is "
54-
".+, must be >= 2.1"):
56+
".+, must be >= %s" % _MIN_NUMEXPR_VERSION):
5557
testit()
56-
elif ne.__version__ == LooseVersion('2.4.4'):
57-
pytest.skip("numexpr version==2.4.4")
5858
else:
5959
testit()
6060
else:

0 commit comments

Comments
 (0)