-
Notifications
You must be signed in to change notification settings - Fork 212
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
When doing power operation issue encountered TypeError: '<' not supported between instances of 'str' and 'int' #434
Comments
This is a point where I'm unsure what the intention of the original authors was with regards to the attribute The documentation for
So, yeah, unsure how this code was intended to work. I might need to go way back in Git to guess. |
Hi robmcleod, I have debug a little, the attribute .value is supposed to link to .astKind but somehow .value is str, the astkind is forgotten to change; well I only add a condition and solve the problem; I will also go further to check the mechanism |
things are really bad, I have understood the intention of the power function https://stackoverflow.com/questions/43287311/why-cant-i-raise-to-a-negative-power-in-numpy but as I dig more, things go bad as following example; if the b is a constant node, then we can raise the error here but if y is a the expression, we can not access the variable at this function |
I think in terms of having negative numbers in arrays we probably just have to accept the behaviour of the C++ virtual machine (which outputs zero if the exponent is a negative integer). The problem is these code shortcuts for singletons. The simplest answer may simply be to remove the shortcuts. They're not very helpful from a performance perspective because the typical use case is when people are using NumExpr as a parser. IIRC, it takes about 1 ms to spin up the virtual machine in 2.X. |
Thanks for the reply, I spent hours on this and you are right we just need to accept the behavior of the C++ virtual machine. |
…orted between instances of 'str' and 'int' pydata#434
Closing with release of 2.8.5. |
TypeError: '<' not supported between instances of 'str' and 'int'
code:
import numexpr as ne
A = 10
B = 2
print(ne.evaluate("A**B"))
The text was updated successfully, but these errors were encountered: