31
31
assert_numpy_array_equal , assert_series_equal ,
32
32
assert_produces_warning )
33
33
from pandas .compat import PY3 , reduce
34
+ from pandas .core .computation .expressions import (
35
+ _ne_version_under_2_6_9 )
36
+
34
37
35
38
_series_frame_incompatible = _bool_ops_syms
36
39
_scalar_skip = 'in' , 'not in'
@@ -54,6 +57,19 @@ def parser(request):
54
57
return request .param
55
58
56
59
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
+
57
73
def engine_has_neg_frac (engine ):
58
74
return _engines [engine ].has_neg_frac
59
75
@@ -1625,24 +1641,31 @@ def eval(self, *args, **kwargs):
1625
1641
def test_unary_functions (self ):
1626
1642
df = DataFrame ({'a' : np .random .randn (10 )})
1627
1643
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 :
1629
1647
expr = "{0}(a)" .format (fn )
1648
+ got = self .eval (expr )
1630
1649
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 )
1635
1659
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 ):
1637
1661
df = DataFrame ({'a' : np .random .randn (10 )})
1638
1662
a = df .a
1639
- for fn in self . unary_fns :
1663
+ for fn in ( 'floor' , 'ceil' ) :
1640
1664
expr = "{0}(a)" .format (fn )
1665
+ got = self .eval (expr )
1641
1666
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 )
1646
1669
1647
1670
def test_binary_functions (self ):
1648
1671
df = DataFrame ({'a' : np .random .randn (10 ),
0 commit comments