Skip to content

Commit 289bf85

Browse files
committed
When doing power operation issue encountered TypeError: '<' not supported between instances of 'str' and 'int' pydata#434
1 parent 7fdec20 commit 289bf85

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

numexpr/expressions.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -271,17 +271,17 @@ def rtruediv_op(a, b):
271271

272272
@ophelper
273273
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-
281274
if allConstantNodes([a, b]):
282275
return ConstantNode(a.value ** b.value)
283276
if isinstance(b, ConstantNode):
284277
x = b.value
278+
# Numpy Error: Integers to negative integer powers are not allowed.
279+
# if a is a vector of numpy integer, b is not allowed to be a negative integer(number or vector).
280+
if (a.astKind in ('int', 'long') and
281+
b.astKind in ('int', 'long') and
282+
x < 0) :
283+
raise ValueError(
284+
'Integers to negative integer powers are not allowed.')
285285
if get_optimization() == 'aggressive':
286286
RANGE = 50 # Approximate break even point with pow(x,y)
287287
# Optimize all integral and half integral powers in [-RANGE, RANGE]

0 commit comments

Comments
 (0)