35
35
36
36
from numexpr import interpreter
37
37
38
- class Expression (object ):
39
- def __init__ (self ):
40
- object .__init__ (self )
38
+ class Expression ():
41
39
42
40
def __getattr__ (self , name ):
43
41
if name .startswith ('_' ):
@@ -271,17 +269,13 @@ def rtruediv_op(a, b):
271
269
272
270
@ophelper
273
271
def pow_op (a , b ):
274
- if (b .astKind in ('int' , 'long' ) and
275
- a .astKind in ('int' , 'long' ) and
276
- numpy .any (b .value < 0 )):
277
-
278
- raise ValueError (
279
- 'Integers to negative integer powers are not allowed.' )
280
-
281
- if allConstantNodes ([a , b ]):
282
- return ConstantNode (a .value ** b .value )
272
+
283
273
if isinstance (b , ConstantNode ):
284
274
x = b .value
275
+ if ( a .astKind in ('int' , 'long' ) and
276
+ b .astKind in ('int' , 'long' ) and x < 0 ) :
277
+ raise ValueError (
278
+ 'Integers to negative integer powers are not allowed.' )
285
279
if get_optimization () == 'aggressive' :
286
280
RANGE = 50 # Approximate break even point with pow(x,y)
287
281
# Optimize all integral and half integral powers in [-RANGE, RANGE]
@@ -379,7 +373,7 @@ def multiply(x, y):
379
373
}
380
374
381
375
382
- class ExpressionNode (object ):
376
+ class ExpressionNode ():
383
377
"""
384
378
An object that represents a generic number object.
385
379
@@ -389,7 +383,6 @@ class ExpressionNode(object):
389
383
astType = 'generic'
390
384
391
385
def __init__ (self , value = None , kind = None , children = None ):
392
- object .__init__ (self )
393
386
self .value = value
394
387
if kind is None :
395
388
kind = 'none'
@@ -477,7 +470,7 @@ def __init__(self, value=None, kind=None, children=None):
477
470
LeafNode .__init__ (self , value = value , kind = kind )
478
471
479
472
480
- class RawNode (object ):
473
+ class RawNode ():
481
474
"""
482
475
Used to pass raw integers to interpreter.
483
476
For instance, for selecting what function to use in func1.
0 commit comments