File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -542,7 +542,7 @@ def __unicode__(self):
542
542
class FuncNode (object ):
543
543
544
544
def __init__ (self , name ):
545
- if name not in _mathops :
545
+ if name not in _mathops or not hasattr ( np , name ) :
546
546
raise ValueError (
547
547
"\" {0}\" is not a supported function" .format (name ))
548
548
self .name = name
Original file line number Diff line number Diff line change @@ -1627,10 +1627,21 @@ def test_unary_functions(self):
1627
1627
a = df .a
1628
1628
for fn in self .unary_fns :
1629
1629
expr = "{0}(a)" .format (fn )
1630
- got = self .eval (expr )
1631
1630
with np .errstate (all = 'ignore' ):
1632
- expect = getattr (np , fn )(a )
1633
- tm .assert_series_equal (got , expect , check_names = False )
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 )
1635
+
1636
+ def test_all_unary_functions_not_supported_in_numpy_112 (self ):
1637
+ df = DataFrame ({'a' : np .random .randn (10 )})
1638
+ for fn in self .unary_fns :
1639
+ expr = "{0}(a)" .format (fn )
1640
+ with np .errstate (all = 'ignore' ):
1641
+ if not hasattr (np , fn ):
1642
+ msg = f"\" { fn } \" is not a supported function"
1643
+ with pytest .raises (ValueError , match = msg ):
1644
+ self .eval (expr )
1634
1645
1635
1646
def test_binary_functions (self ):
1636
1647
df = DataFrame ({'a' : np .random .randn (10 ),
You can’t perform that action at this time.
0 commit comments