Skip to content

Commit 26d7e10

Browse files
committed
Partial fix for issue #434 as suggested by timbrist
1 parent d631645 commit 26d7e10

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

numexpr/expressions.py

+8-15
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535

3636
from numexpr import interpreter
3737

38-
class Expression(object):
39-
def __init__(self):
40-
object.__init__(self)
38+
class Expression():
4139

4240
def __getattr__(self, name):
4341
if name.startswith('_'):
@@ -271,17 +269,13 @@ def rtruediv_op(a, b):
271269

272270
@ophelper
273271
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+
283273
if isinstance(b, ConstantNode):
284274
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.')
285279
if get_optimization() == 'aggressive':
286280
RANGE = 50 # Approximate break even point with pow(x,y)
287281
# Optimize all integral and half integral powers in [-RANGE, RANGE]
@@ -379,7 +373,7 @@ def multiply(x, y):
379373
}
380374

381375

382-
class ExpressionNode(object):
376+
class ExpressionNode():
383377
"""
384378
An object that represents a generic number object.
385379
@@ -389,7 +383,6 @@ class ExpressionNode(object):
389383
astType = 'generic'
390384

391385
def __init__(self, value=None, kind=None, children=None):
392-
object.__init__(self)
393386
self.value = value
394387
if kind is None:
395388
kind = 'none'
@@ -477,7 +470,7 @@ def __init__(self, value=None, kind=None, children=None):
477470
LeafNode.__init__(self, value=value, kind=kind)
478471

479472

480-
class RawNode(object):
473+
class RawNode():
481474
"""
482475
Used to pass raw integers to interpreter.
483476
For instance, for selecting what function to use in func1.

numexpr/necompiler.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
]
7070

7171

72-
class ASTNode(object):
72+
class ASTNode():
7373
"""Abstract Syntax Tree node.
7474
7575
Members:
@@ -84,7 +84,6 @@ class ASTNode(object):
8484
cmpnames = ['astType', 'astKind', 'value', 'children']
8585

8686
def __init__(self, astType='generic', astKind='unknown', value=None, children=()):
87-
object.__init__(self)
8887
self.astType = astType
8988
self.astKind = astKind
9089
self.value = value
@@ -219,7 +218,7 @@ def typeCompileAst(ast):
219218
[typeCompileAst(c) for c in children])
220219

221220

222-
class Register(object):
221+
class Register():
223222
"""Abstraction for a register in the VM.
224223
225224
Members:

0 commit comments

Comments
 (0)