forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes pandas-dev#12489 closes pandas-dev#12511
- Loading branch information
Showing
8 changed files
with
110 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ html5lib | |
patsy | ||
beautiful-soup | ||
scipy | ||
numexpr | ||
numexpr=2.4.4 | ||
pytables | ||
matplotlib | ||
lxml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
import warnings | ||
from distutils.version import LooseVersion | ||
|
||
_NUMEXPR_INSTALLED = False | ||
|
||
try: | ||
import numexpr as ne | ||
ver = ne.__version__ | ||
_NUMEXPR_INSTALLED = ver >= LooseVersion('2.1') | ||
|
||
# we specifically disallow 2.4.4 as | ||
# has some hard-to-diagnose bugs | ||
if ver == LooseVersion('2.4.4'): | ||
_NUMEXPR_INSTALLED = False | ||
warnings.warn( | ||
"The installed version of numexpr {ver} is not supported " | ||
"in pandas and will be not be used\n".format(ver=ver), | ||
UserWarning) | ||
|
||
elif not _NUMEXPR_INSTALLED: | ||
warnings.warn( | ||
"The installed version of numexpr {ver} is not supported " | ||
"in pandas and will be not be used\nThe minimum supported " | ||
"version is 2.1\n".format(ver=ver), UserWarning) | ||
|
||
except ImportError: # pragma: no cover | ||
pass | ||
|
||
__all__ = ['_NUMEXPR_INSTALLED'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env python | ||
|
||
# flake8: noqa | ||
|
||
import nose | ||
from itertools import product | ||
from distutils.version import LooseVersion | ||
|
||
import pandas as pd | ||
from pandas.util import testing as tm | ||
|
||
from pandas.computation.engines import _engines | ||
import pandas.computation.expr as expr | ||
|
||
ENGINES_PARSERS = list(product(_engines, expr._parsers)) | ||
|
||
|
||
def test_compat(): | ||
# test we have compat with our version of nu | ||
|
||
from pandas.computation import _NUMEXPR_INSTALLED | ||
try: | ||
import numexpr as ne | ||
ver = ne.__version__ | ||
if ver == LooseVersion('2.4.4'): | ||
assert not _NUMEXPR_INSTALLED | ||
elif ver < LooseVersion('2.1'): | ||
with tm.assert_produces_warning(UserWarning, | ||
check_stacklevel=False): | ||
assert not _NUMEXPR_INSTALLED | ||
else: | ||
assert _NUMEXPR_INSTALLED | ||
|
||
except ImportError: | ||
raise nose.SkipTest("not testing numexpr version compat") | ||
|
||
|
||
def test_invalid_numexpr_version(): | ||
for engine, parser in ENGINES_PARSERS: | ||
yield check_invalid_numexpr_version, engine, parser | ||
|
||
|
||
def check_invalid_numexpr_version(engine, parser): | ||
def testit(): | ||
a, b = 1, 2 | ||
res = pd.eval('a + b', engine=engine, parser=parser) | ||
tm.assert_equal(res, 3) | ||
|
||
if engine == 'numexpr': | ||
try: | ||
import numexpr as ne | ||
except ImportError: | ||
raise nose.SkipTest("no numexpr") | ||
else: | ||
if ne.__version__ < LooseVersion('2.1'): | ||
with tm.assertRaisesRegexp(ImportError, "'numexpr' version is " | ||
".+, must be >= 2.1"): | ||
testit() | ||
elif ne.__version__ == LooseVersion('2.4.4'): | ||
raise nose.SkipTest("numexpr version==2.4.4") | ||
else: | ||
testit() | ||
else: | ||
testit() | ||
|
||
|
||
if __name__ == '__main__': | ||
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'], | ||
exit=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters