diff --git a/numexpr/expressions.py b/numexpr/expressions.py index 18edabd..419d7dc 100644 --- a/numexpr/expressions.py +++ b/numexpr/expressions.py @@ -35,9 +35,7 @@ from numexpr import interpreter -class Expression(object): - def __init__(self): - object.__init__(self) +class Expression(): def __getattr__(self, name): if name.startswith('_'): @@ -271,17 +269,13 @@ def rtruediv_op(a, b): @ophelper def pow_op(a, b): - if (b.astKind in ('int', 'long') and - a.astKind in ('int', 'long') and - numpy.any(b.value < 0)): - - raise ValueError( - 'Integers to negative integer powers are not allowed.') - - if allConstantNodes([a, b]): - return ConstantNode(a.value ** b.value) + if isinstance(b, ConstantNode): x = b.value + if ( a.astKind in ('int', 'long') and + b.astKind in ('int', 'long') and x < 0) : + raise ValueError( + 'Integers to negative integer powers are not allowed.') if get_optimization() == 'aggressive': RANGE = 50 # Approximate break even point with pow(x,y) # Optimize all integral and half integral powers in [-RANGE, RANGE] @@ -379,7 +373,7 @@ def multiply(x, y): } -class ExpressionNode(object): +class ExpressionNode(): """ An object that represents a generic number object. @@ -389,7 +383,6 @@ class ExpressionNode(object): astType = 'generic' def __init__(self, value=None, kind=None, children=None): - object.__init__(self) self.value = value if kind is None: kind = 'none' @@ -477,7 +470,7 @@ def __init__(self, value=None, kind=None, children=None): LeafNode.__init__(self, value=value, kind=kind) -class RawNode(object): +class RawNode(): """ Used to pass raw integers to interpreter. For instance, for selecting what function to use in func1. diff --git a/numexpr/necompiler.py b/numexpr/necompiler.py index 6bbc70f..37052ac 100644 --- a/numexpr/necompiler.py +++ b/numexpr/necompiler.py @@ -69,7 +69,7 @@ ] -class ASTNode(object): +class ASTNode(): """Abstract Syntax Tree node. Members: @@ -84,7 +84,6 @@ class ASTNode(object): cmpnames = ['astType', 'astKind', 'value', 'children'] def __init__(self, astType='generic', astKind='unknown', value=None, children=()): - object.__init__(self) self.astType = astType self.astKind = astKind self.value = value @@ -219,7 +218,7 @@ def typeCompileAst(ast): [typeCompileAst(c) for c in children]) -class Register(object): +class Register(): """Abstraction for a register in the VM. Members: