Set conditions as NDArray Type
opticodi opened this issue · 3 comments
Hi henon,
thanks for this great work.
I have some trouble to set conditions elementwise in NDArray type, like its needed for e.g. np.where() - function.
I hope to explain my issue right here with the following lines:
"import numpy as np
x = np.arange(-2,2,1)
a = (x != np.zeros_like(x))"
In "real" numpy I get a=[True True False True], but when I try the same in Numpy.NET I get a=True.
So my question:
How do I make Numpy.NET to test the condition element-wise?
I lack knowledge about how to do this via the API to python. I know how we could use Expressions in C# to formulate that condition but I don't know how to convert the AST of such an expression into something that python accepts. I don't even know how numpy does this in Python, i.e. what method of np or NdArray it calls etc.
or maybe all we need to do is clever operator overloading, maybe that is how numpy does it in Python.
Hi, I appreciate for your quick answer.
Now, I found some circumvention for my issue:
I can use the numpy logic functions to get the element-wise answer.
For the example above:
"import numpy as np
x = np.arange(-2,2,1)
a = np.equal(x,np.zeros_like(x))"
gets me to a=[True True False True].
This type of expression I can also use to setup the boolean NDarray "conditions" for functions like np.where().