-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Skipif no lzma ne #18820
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
Skipif no lzma ne #18820
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,14 @@ | |
makeCustomDataframe as mkdf) | ||
|
||
import pandas.util.testing as tm | ||
import pandas.util._test_decorators as td | ||
from pandas.core.computation.check import _NUMEXPR_INSTALLED | ||
|
||
from pandas.tests.frame.common import TestData | ||
|
||
|
||
PARSERS = 'python', 'pandas' | ||
ENGINES = 'python', 'numexpr' | ||
ENGINES = 'python', pytest.param('numexpr', marks=td.skip_if_no_ne) | ||
|
||
|
||
@pytest.fixture(params=PARSERS, ids=lambda x: x) | ||
|
@@ -41,13 +42,6 @@ def skip_if_no_pandas_parser(parser): | |
pytest.skip("cannot evaluate with parser {0!r}".format(parser)) | ||
|
||
|
||
def skip_if_no_ne(engine='numexpr'): | ||
if engine == 'numexpr': | ||
if not _NUMEXPR_INSTALLED: | ||
pytest.skip("cannot query engine numexpr when numexpr not " | ||
"installed") | ||
|
||
|
||
class TestCompat(object): | ||
|
||
def setup_method(self, method): | ||
|
@@ -175,7 +169,6 @@ def test_eval_resolvers_as_list(self): | |
class TestDataFrameQueryWithMultiIndex(object): | ||
|
||
def test_query_with_named_multiindex(self, parser, engine): | ||
tm.skip_if_no_ne(engine) | ||
skip_if_no_pandas_parser(parser) | ||
a = np.random.choice(['red', 'green'], size=10) | ||
b = np.random.choice(['eggs', 'ham'], size=10) | ||
|
@@ -225,7 +218,6 @@ def test_query_with_named_multiindex(self, parser, engine): | |
assert_frame_equal(res2, exp) | ||
|
||
def test_query_with_unnamed_multiindex(self, parser, engine): | ||
tm.skip_if_no_ne(engine) | ||
skip_if_no_pandas_parser(parser) | ||
a = np.random.choice(['red', 'green'], size=10) | ||
b = np.random.choice(['eggs', 'ham'], size=10) | ||
|
@@ -316,7 +308,6 @@ def test_query_with_unnamed_multiindex(self, parser, engine): | |
assert_frame_equal(res2, exp) | ||
|
||
def test_query_with_partially_named_multiindex(self, parser, engine): | ||
tm.skip_if_no_ne(engine) | ||
skip_if_no_pandas_parser(parser) | ||
a = np.random.choice(['red', 'green'], size=10) | ||
b = np.arange(10) | ||
|
@@ -370,27 +361,25 @@ def to_series(mi, level): | |
raise AssertionError("object must be a Series or Index") | ||
|
||
def test_raise_on_panel_with_multiindex(self, parser, engine): | ||
tm.skip_if_no_ne() | ||
p = tm.makePanel(7) | ||
p.items = tm.makeCustomIndex(len(p.items), nlevels=2) | ||
with pytest.raises(NotImplementedError): | ||
pd.eval('p + 1', parser=parser, engine=engine) | ||
|
||
def test_raise_on_panel4d_with_multiindex(self, parser, engine): | ||
tm.skip_if_no_ne() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same bug as above |
||
p4d = tm.makePanel4D(7) | ||
p4d.items = tm.makeCustomIndex(len(p4d.items), nlevels=2) | ||
with pytest.raises(NotImplementedError): | ||
pd.eval('p4d + 1', parser=parser, engine=engine) | ||
|
||
|
||
@td.skip_if_no_ne | ||
class TestDataFrameQueryNumExprPandas(object): | ||
|
||
@classmethod | ||
def setup_class(cls): | ||
cls.engine = 'numexpr' | ||
cls.parser = 'pandas' | ||
tm.skip_if_no_ne(cls.engine) | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
|
@@ -714,14 +703,14 @@ def test_inf(self): | |
assert_frame_equal(result, expected) | ||
|
||
|
||
@td.skip_if_no_ne | ||
class TestDataFrameQueryNumExprPython(TestDataFrameQueryNumExprPandas): | ||
|
||
@classmethod | ||
def setup_class(cls): | ||
super(TestDataFrameQueryNumExprPython, cls).setup_class() | ||
cls.engine = 'numexpr' | ||
cls.parser = 'python' | ||
tm.skip_if_no_ne(cls.engine) | ||
cls.frame = TestData().frame | ||
|
||
def test_date_query_no_attribute_access(self): | ||
|
@@ -859,7 +848,6 @@ def test_query_builtin(self): | |
class TestDataFrameQueryStrings(object): | ||
|
||
def test_str_query_method(self, parser, engine): | ||
tm.skip_if_no_ne(engine) | ||
df = DataFrame(randn(10, 1), columns=['b']) | ||
df['strings'] = Series(list('aabbccddee')) | ||
expect = df[df.strings == 'a'] | ||
|
@@ -896,7 +884,6 @@ def test_str_query_method(self, parser, engine): | |
assert_frame_equal(res, df[~df.strings.isin(['a'])]) | ||
|
||
def test_str_list_query_method(self, parser, engine): | ||
tm.skip_if_no_ne(engine) | ||
df = DataFrame(randn(10, 1), columns=['b']) | ||
df['strings'] = Series(list('aabbccddee')) | ||
expect = df[df.strings.isin(['a', 'b'])] | ||
|
@@ -935,7 +922,6 @@ def test_str_list_query_method(self, parser, engine): | |
assert_frame_equal(res, expect) | ||
|
||
def test_query_with_string_columns(self, parser, engine): | ||
tm.skip_if_no_ne(engine) | ||
df = DataFrame({'a': list('aaaabbbbcccc'), | ||
'b': list('aabbccddeeff'), | ||
'c': np.random.randint(5, size=12), | ||
|
@@ -956,7 +942,6 @@ def test_query_with_string_columns(self, parser, engine): | |
df.query('a in b and c < d', parser=parser, engine=engine) | ||
|
||
def test_object_array_eq_ne(self, parser, engine): | ||
tm.skip_if_no_ne(engine) | ||
df = DataFrame({'a': list('aaaabbbbcccc'), | ||
'b': list('aabbccddeeff'), | ||
'c': np.random.randint(5, size=12), | ||
|
@@ -970,7 +955,6 @@ def test_object_array_eq_ne(self, parser, engine): | |
assert_frame_equal(res, exp) | ||
|
||
def test_query_with_nested_strings(self, parser, engine): | ||
tm.skip_if_no_ne(engine) | ||
skip_if_no_pandas_parser(parser) | ||
raw = """id event timestamp | ||
1 "page 1 load" 1/1/2014 0:00:01 | ||
|
@@ -995,15 +979,13 @@ def test_query_with_nested_strings(self, parser, engine): | |
|
||
def test_query_with_nested_special_character(self, parser, engine): | ||
skip_if_no_pandas_parser(parser) | ||
tm.skip_if_no_ne(engine) | ||
df = DataFrame({'a': ['a', 'b', 'test & test'], | ||
'b': [1, 2, 3]}) | ||
res = df.query('a == "test & test"', parser=parser, engine=engine) | ||
expec = df[df.a == 'test & test'] | ||
assert_frame_equal(res, expec) | ||
|
||
def test_query_lex_compare_strings(self, parser, engine): | ||
tm.skip_if_no_ne(engine=engine) | ||
import operator as opr | ||
|
||
a = Series(np.random.choice(list('abcde'), 20)) | ||
|
@@ -1018,7 +1000,6 @@ def test_query_lex_compare_strings(self, parser, engine): | |
assert_frame_equal(res, expected) | ||
|
||
def test_query_single_element_booleans(self, parser, engine): | ||
tm.skip_if_no_ne(engine) | ||
columns = 'bid', 'bidsize', 'ask', 'asksize' | ||
data = np.random.randint(2, size=(1, len(columns))).astype(bool) | ||
df = DataFrame(data, columns=columns) | ||
|
@@ -1027,7 +1008,6 @@ def test_query_single_element_booleans(self, parser, engine): | |
assert_frame_equal(res, expected) | ||
|
||
def test_query_string_scalar_variable(self, parser, engine): | ||
tm.skip_if_no_ne(engine) | ||
skip_if_no_pandas_parser(parser) | ||
df = pd.DataFrame({'Symbol': ['BUD US', 'BUD US', 'IBM US', 'IBM US'], | ||
'Price': [109.70, 109.72, 183.30, 183.35]}) | ||
|
@@ -1037,63 +1017,29 @@ def test_query_string_scalar_variable(self, parser, engine): | |
assert_frame_equal(e, r) | ||
|
||
|
||
class TestDataFrameEvalNumExprPandas(object): | ||
|
||
@classmethod | ||
def setup_class(cls): | ||
cls.engine = 'numexpr' | ||
cls.parser = 'pandas' | ||
tm.skip_if_no_ne() | ||
class TestDataFrameEvalWithFrame(object): | ||
|
||
def setup_method(self, method): | ||
self.frame = DataFrame(randn(10, 3), columns=list('abc')) | ||
|
||
def teardown_method(self, method): | ||
del self.frame | ||
|
||
def test_simple_expr(self): | ||
res = self.frame.eval('a + b', engine=self.engine, parser=self.parser) | ||
def test_simple_expr(self, parser, engine): | ||
res = self.frame.eval('a + b', engine=engine, parser=parser) | ||
expect = self.frame.a + self.frame.b | ||
assert_series_equal(res, expect) | ||
|
||
def test_bool_arith_expr(self): | ||
res = self.frame.eval('a[a < 1] + b', engine=self.engine, | ||
parser=self.parser) | ||
def test_bool_arith_expr(self, parser, engine): | ||
res = self.frame.eval('a[a < 1] + b', engine=engine, parser=parser) | ||
expect = self.frame.a[self.frame.a < 1] + self.frame.b | ||
assert_series_equal(res, expect) | ||
|
||
def test_invalid_type_for_operator_raises(self): | ||
def test_invalid_type_for_operator_raises(self, parser, engine): | ||
df = DataFrame({'a': [1, 2], 'b': ['c', 'd']}) | ||
ops = '+', '-', '*', '/' | ||
for op in ops: | ||
with tm.assert_raises_regex(TypeError, | ||
"unsupported operand type\(s\) " | ||
"for .+: '.+' and '.+'"): | ||
df.eval('a {0} b'.format(op), engine=self.engine, | ||
parser=self.parser) | ||
|
||
|
||
class TestDataFrameEvalNumExprPython(TestDataFrameEvalNumExprPandas): | ||
|
||
@classmethod | ||
def setup_class(cls): | ||
super(TestDataFrameEvalNumExprPython, cls).setup_class() | ||
cls.engine = 'numexpr' | ||
cls.parser = 'python' | ||
tm.skip_if_no_ne(cls.engine) | ||
|
||
|
||
class TestDataFrameEvalPythonPandas(TestDataFrameEvalNumExprPandas): | ||
|
||
@classmethod | ||
def setup_class(cls): | ||
super(TestDataFrameEvalPythonPandas, cls).setup_class() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The call to the super |
||
cls.engine = 'python' | ||
cls.parser = 'pandas' | ||
|
||
|
||
class TestDataFrameEvalPythonPython(TestDataFrameEvalNumExprPython): | ||
|
||
@classmethod | ||
def setup_class(cls): | ||
cls.engine = cls.parser = 'python' | ||
df.eval('a {0} b'.format(op), engine=engine, parser=parser) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor bug before where this wasn't passing
engine
as an argument to the skip_if function, so this test was always being skipped on systems lackingnumexpr
, even for non-numexpr
engines