3131 assert_numpy_array_equal , assert_series_equal ,
3232 assert_produces_warning )
3333from pandas .compat import PY3 , reduce
34+ from pandas .core .computation .expressions import (
35+ _ne_version_under_2_6_9 )
36+
3437
3538_series_frame_incompatible = _bool_ops_syms
3639_scalar_skip = 'in' , 'not in'
@@ -54,6 +57,19 @@ def parser(request):
5457 return request .param
5558
5659
60+ @pytest .fixture
61+ def ne_lt_2_6_9 ():
62+ if not _ne_version_under_2_6_9 :
63+ pytest .skip ("numexpr is > 2.6.9" )
64+ return 'numexpr'
65+
66+ @pytest .fixture
67+ def ne_gt_2_6_9 ():
68+ if _ne_version_under_2_6_9 :
69+ pytest .skip ("numexpr is < 2.6.9" )
70+ return 'numexpr'
71+
72+
5773def engine_has_neg_frac (engine ):
5874 return _engines [engine ].has_neg_frac
5975
@@ -1625,24 +1641,31 @@ def eval(self, *args, **kwargs):
16251641 def test_unary_functions (self ):
16261642 df = DataFrame ({'a' : np .random .randn (10 )})
16271643 a = df .a
1628- for fn in self .unary_fns :
1644+ unary_functions = [x for x in self .unary_fns
1645+ if x not in ('floor' , 'ceil' )]
1646+ for fn in unary_functions :
16291647 expr = "{0}(a)" .format (fn )
1648+ got = self .eval (expr )
16301649 with np .errstate (all = 'ignore' ):
1631- if hasattr (np , fn ):
1632- got = self .eval (expr )
1633- expect = getattr (np , fn )(a )
1634- tm .assert_series_equal (got , expect , check_names = False )
1650+ expect = getattr (np , fn )(a )
1651+ tm .assert_series_equal (got , expect , check_names = False )
1652+
1653+ def test_floor_and_ceil_functions_raise_error (self , ne_lt_2_6_9 ):
1654+ for fn in ('floor' , 'ceil' ):
1655+ msg = "\" {0}\" is not a supported function" .format (fn )
1656+ with pytest .raises (ValueError , match = msg ):
1657+ expr = "{0}(100)" .format (fn )
1658+ self .eval (expr )
16351659
1636- def test_all_unary_functions_not_supported_in_numpy_112 (self ):
1660+ def test_floor_and_ceil_functions_evaluate_expressions (self , ne_gt_2_6_9 ):
16371661 df = DataFrame ({'a' : np .random .randn (10 )})
16381662 a = df .a
1639- for fn in self . unary_fns :
1663+ for fn in ( 'floor' , 'ceil' ) :
16401664 expr = "{0}(a)" .format (fn )
1665+ got = self .eval (expr )
16411666 with np .errstate (all = 'ignore' ):
1642- if not hasattr (np , fn ):
1643- msg = '"{0}" is not a supported function' .format (fn )
1644- with pytest .raises (ValueError , match = msg ):
1645- self .eval (expr )
1667+ expect = getattr (np , fn )(a )
1668+ tm .assert_series_equal (got , expect , check_names = False )
16461669
16471670 def test_binary_functions (self ):
16481671 df = DataFrame ({'a' : np .random .randn (10 ),
0 commit comments