Skip to content

When doing power operation issue encountered TypeError: '<' not supp… #436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions numexpr/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,17 @@ 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
# Numpy Error: Integers to negative integer powers are not allowed.
# if a is a vector of numpy integer, b is not allowed to be a negative integer(number or vector).
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]
Expand Down