Skip to content

Commit bb601b5

Browse files
committed
CLN/TST: DRY skip_if_no_ne
1 parent f04f1f9 commit bb601b5

File tree

4 files changed

+64
-62
lines changed

4 files changed

+64
-62
lines changed

ci/script.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ echo "inside $0"
55
if [ -n "$LOCALE_OVERRIDE" ]; then
66
export LC_ALL="$LOCALE_OVERRIDE";
77
echo "Setting LC_ALL to $LOCALE_OVERRIDE"
8+
curdir="$(pwd)"
9+
cd /tmp
810
pycmd='import pandas; print("pandas detected console encoding: %s" % pandas.get_option("display.encoding"))'
911
python -c "$pycmd"
12+
cd "$curdir"
1013
fi
1114

12-
echo nosetests -v --exe -w /tmp -A "$NOSE_ARGS" pandas --with-xunit --xunit-file=/tmp/nosetests.xml
13-
nosetests -v --exe -w /tmp -A "$NOSE_ARGS" pandas --with-xunit --xunit-file=/tmp/nosetests.xml
15+
echo nosetests --exe -w /tmp -A "$NOSE_ARGS" pandas --with-xunit --xunit-file=/tmp/nosetests.xml
16+
nosetests --exe -w /tmp -A "$NOSE_ARGS" pandas --with-xunit --xunit-file=/tmp/nosetests.xml

pandas/computation/tests/test_eval.py

+26-33
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from pandas.util.testing import makeCustomDataframe as mkdf
1919

2020
from pandas.computation import pytables
21-
from pandas.computation.expressions import _USE_NUMEXPR
2221
from pandas.computation.engines import _engines
2322
from pandas.computation.expr import PythonExprVisitor, PandasExprVisitor
2423
from pandas.computation.ops import (_binary_ops_dict,
@@ -37,11 +36,6 @@
3736
_scalar_skip = 'in', 'not in'
3837

3938

40-
def skip_if_no_ne(engine='numexpr'):
41-
if not _USE_NUMEXPR and engine == 'numexpr':
42-
raise nose.SkipTest("numexpr engine not installed or disabled")
43-
44-
4539
def engine_has_neg_frac(engine):
4640
return _engines[engine].has_neg_frac
4741

@@ -110,7 +104,7 @@ class TestEvalNumexprPandas(tm.TestCase):
110104
@classmethod
111105
def setUpClass(cls):
112106
super(TestEvalNumexprPandas, cls).setUpClass()
113-
skip_if_no_ne()
107+
tm.skip_if_no_ne()
114108
import numexpr as ne
115109
cls.ne = ne
116110
cls.engine = 'numexpr'
@@ -428,7 +422,7 @@ def check_single_invert_op(self, lhs, cmp1, rhs):
428422
assert_array_equal(expected, result)
429423

430424
for engine in self.current_engines:
431-
skip_if_no_ne(engine)
425+
tm.skip_if_no_ne(engine)
432426
assert_array_equal(result, pd.eval('~elb', engine=engine,
433427
parser=self.parser))
434428

@@ -459,7 +453,7 @@ def check_compound_invert_op(self, lhs, cmp1, rhs):
459453

460454
# make sure the other engines work the same as this one
461455
for engine in self.current_engines:
462-
skip_if_no_ne(engine)
456+
tm.skip_if_no_ne(engine)
463457
ev = pd.eval(ex, engine=self.engine, parser=self.parser)
464458
assert_array_equal(ev, result)
465459

@@ -711,7 +705,7 @@ class TestEvalNumexprPython(TestEvalNumexprPandas):
711705
@classmethod
712706
def setUpClass(cls):
713707
super(TestEvalNumexprPython, cls).setUpClass()
714-
skip_if_no_ne()
708+
tm.skip_if_no_ne()
715709
import numexpr as ne
716710
cls.ne = ne
717711
cls.engine = 'numexpr'
@@ -790,7 +784,7 @@ class TestAlignment(object):
790784
lhs_index_types = index_types + ('s',) # 'p'
791785

792786
def check_align_nested_unary_op(self, engine, parser):
793-
skip_if_no_ne(engine)
787+
tm.skip_if_no_ne(engine)
794788
s = 'df * ~2'
795789
df = mkdf(5, 3, data_gen_f=f)
796790
res = pd.eval(s, engine=engine, parser=parser)
@@ -801,7 +795,7 @@ def test_align_nested_unary_op(self):
801795
yield self.check_align_nested_unary_op, engine, parser
802796

803797
def check_basic_frame_alignment(self, engine, parser):
804-
skip_if_no_ne(engine)
798+
tm.skip_if_no_ne(engine)
805799
args = product(self.lhs_index_types, self.index_types,
806800
self.index_types)
807801
for lr_idx_type, rr_idx_type, c_idx_type in args:
@@ -817,7 +811,7 @@ def test_basic_frame_alignment(self):
817811
yield self.check_basic_frame_alignment, engine, parser
818812

819813
def check_frame_comparison(self, engine, parser):
820-
skip_if_no_ne(engine)
814+
tm.skip_if_no_ne(engine)
821815
args = product(self.lhs_index_types, repeat=2)
822816
for r_idx_type, c_idx_type in args:
823817
df = mkdf(10, 10, data_gen_f=f, r_idx_type=r_idx_type,
@@ -835,7 +829,7 @@ def test_frame_comparison(self):
835829
yield self.check_frame_comparison, engine, parser
836830

837831
def check_medium_complex_frame_alignment(self, engine, parser):
838-
skip_if_no_ne(engine)
832+
tm.skip_if_no_ne(engine)
839833
args = product(self.lhs_index_types, self.index_types,
840834
self.index_types, self.index_types)
841835

@@ -852,7 +846,7 @@ def test_medium_complex_frame_alignment(self):
852846
yield self.check_medium_complex_frame_alignment, engine, parser
853847

854848
def check_basic_frame_series_alignment(self, engine, parser):
855-
skip_if_no_ne(engine)
849+
tm.skip_if_no_ne(engine)
856850

857851
def testit(r_idx_type, c_idx_type, index_name):
858852
df = mkdf(10, 10, data_gen_f=f, r_idx_type=r_idx_type,
@@ -880,7 +874,7 @@ def test_basic_frame_series_alignment(self):
880874
yield self.check_basic_frame_series_alignment, engine, parser
881875

882876
def check_basic_series_frame_alignment(self, engine, parser):
883-
skip_if_no_ne(engine)
877+
tm.skip_if_no_ne(engine)
884878

885879
def testit(r_idx_type, c_idx_type, index_name):
886880
df = mkdf(10, 7, data_gen_f=f, r_idx_type=r_idx_type,
@@ -913,7 +907,7 @@ def test_basic_series_frame_alignment(self):
913907
yield self.check_basic_series_frame_alignment, engine, parser
914908

915909
def check_series_frame_commutativity(self, engine, parser):
916-
skip_if_no_ne(engine)
910+
tm.skip_if_no_ne(engine)
917911
args = product(self.lhs_index_types, self.index_types, ('+', '*'),
918912
('index', 'columns'))
919913
for r_idx_type, c_idx_type, op, index_name in args:
@@ -936,7 +930,7 @@ def test_series_frame_commutativity(self):
936930
yield self.check_series_frame_commutativity, engine, parser
937931

938932
def check_complex_series_frame_alignment(self, engine, parser):
939-
skip_if_no_ne(engine)
933+
tm.skip_if_no_ne(engine)
940934

941935
import random
942936
args = product(self.lhs_index_types, self.index_types,
@@ -980,7 +974,7 @@ def test_complex_series_frame_alignment(self):
980974
yield self.check_complex_series_frame_alignment, engine, parser
981975

982976
def check_performance_warning_for_poor_alignment(self, engine, parser):
983-
skip_if_no_ne(engine)
977+
tm.skip_if_no_ne(engine)
984978
df = DataFrame(randn(1000, 10))
985979
s = Series(randn(10000))
986980
if engine == 'numexpr':
@@ -1036,7 +1030,7 @@ class TestOperationsNumExprPandas(tm.TestCase):
10361030
@classmethod
10371031
def setUpClass(cls):
10381032
super(TestOperationsNumExprPandas, cls).setUpClass()
1039-
skip_if_no_ne()
1033+
tm.skip_if_no_ne()
10401034
cls.engine = 'numexpr'
10411035
cls.parser = 'pandas'
10421036
cls.arith_ops = expr._arith_ops_syms + expr._cmp_ops_syms
@@ -1196,7 +1190,7 @@ def test_assignment_fails(self):
11961190
local_dict={'df': df, 'df2': df2})
11971191

11981192
def test_assignment_column(self):
1199-
skip_if_no_ne('numexpr')
1193+
tm.skip_if_no_ne('numexpr')
12001194
df = DataFrame(np.random.randn(5, 2), columns=list('ab'))
12011195
orig_df = df.copy()
12021196

@@ -1347,10 +1341,9 @@ class TestOperationsNumExprPython(TestOperationsNumExprPandas):
13471341
@classmethod
13481342
def setUpClass(cls):
13491343
super(TestOperationsNumExprPython, cls).setUpClass()
1350-
if not _USE_NUMEXPR:
1351-
raise nose.SkipTest("numexpr engine not installed")
13521344
cls.engine = 'numexpr'
13531345
cls.parser = 'python'
1346+
tm.skip_if_no_ne(cls.engine)
13541347
cls.arith_ops = expr._arith_ops_syms + expr._cmp_ops_syms
13551348
cls.arith_ops = filter(lambda x: x not in ('in', 'not in'),
13561349
cls.arith_ops)
@@ -1437,7 +1430,7 @@ def setUpClass(cls):
14371430
class TestScope(object):
14381431

14391432
def check_global_scope(self, e, engine, parser):
1440-
skip_if_no_ne(engine)
1433+
tm.skip_if_no_ne(engine)
14411434
assert_array_equal(_var_s * 2, pd.eval(e, engine=engine,
14421435
parser=parser))
14431436

@@ -1447,7 +1440,7 @@ def test_global_scope(self):
14471440
yield self.check_global_scope, e, engine, parser
14481441

14491442
def check_no_new_locals(self, engine, parser):
1450-
skip_if_no_ne(engine)
1443+
tm.skip_if_no_ne(engine)
14511444
x = 1
14521445
lcls = locals().copy()
14531446
pd.eval('x + 1', local_dict=lcls, engine=engine, parser=parser)
@@ -1460,7 +1453,7 @@ def test_no_new_locals(self):
14601453
yield self.check_no_new_locals, engine, parser
14611454

14621455
def check_no_new_globals(self, engine, parser):
1463-
skip_if_no_ne(engine)
1456+
tm.skip_if_no_ne(engine)
14641457
x = 1
14651458
gbls = globals().copy()
14661459
pd.eval('x + 1', engine=engine, parser=parser)
@@ -1473,21 +1466,21 @@ def test_no_new_globals(self):
14731466

14741467

14751468
def test_invalid_engine():
1476-
skip_if_no_ne()
1469+
tm.skip_if_no_ne()
14771470
assertRaisesRegexp(KeyError, 'Invalid engine \'asdf\' passed',
14781471
pd.eval, 'x + y', local_dict={'x': 1, 'y': 2},
14791472
engine='asdf')
14801473

14811474

14821475
def test_invalid_parser():
1483-
skip_if_no_ne()
1476+
tm.skip_if_no_ne()
14841477
assertRaisesRegexp(KeyError, 'Invalid parser \'asdf\' passed',
14851478
pd.eval, 'x + y', local_dict={'x': 1, 'y': 2},
14861479
parser='asdf')
14871480

14881481

14891482
def check_is_expr_syntax(engine):
1490-
skip_if_no_ne(engine)
1483+
tm.skip_if_no_ne(engine)
14911484
s = 1
14921485
valid1 = 's + 1'
14931486
valid2 = '__y + _xx'
@@ -1496,7 +1489,7 @@ def check_is_expr_syntax(engine):
14961489

14971490

14981491
def check_is_expr_names(engine):
1499-
skip_if_no_ne(engine)
1492+
tm.skip_if_no_ne(engine)
15001493
r, s = 1, 2
15011494
valid = 's + r'
15021495
invalid = '__y + __x'
@@ -1519,7 +1512,7 @@ def test_is_expr_names():
15191512

15201513

15211514
def check_disallowed_nodes(engine, parser):
1522-
skip_if_no_ne(engine)
1515+
tm.skip_if_no_ne(engine)
15231516
VisitorClass = _parsers[parser]
15241517
uns_ops = VisitorClass.unsupported_nodes
15251518
inst = VisitorClass('x + 1', engine, parser)
@@ -1534,7 +1527,7 @@ def test_disallowed_nodes():
15341527

15351528

15361529
def check_syntax_error_exprs(engine, parser):
1537-
skip_if_no_ne(engine)
1530+
tm.skip_if_no_ne(engine)
15381531
e = 's +'
15391532
assert_raises(SyntaxError, pd.eval, e, engine=engine, parser=parser)
15401533

@@ -1545,7 +1538,7 @@ def test_syntax_error_exprs():
15451538

15461539

15471540
def check_name_error_exprs(engine, parser):
1548-
skip_if_no_ne(engine)
1541+
tm.skip_if_no_ne(engine)
15491542
e = 's + t'
15501543
assert_raises(NameError, pd.eval, e, engine=engine, parser=parser)
15511544

0 commit comments

Comments
 (0)