I’d like to implement
sympy.Piecewise
on numpy arrays.
Consider:
<code>x = np.array([0.1,1,2])
y = np.array([10,10,10])
Piecewise((x * y, x > 0.9),(0, True))
</code>
<code>x = np.array([0.1,1,2])
y = np.array([10,10,10])
Piecewise((x * y, x > 0.9),(0, True))
</code>
x = np.array([0.1,1,2])
y = np.array([10,10,10])
Piecewise((x * y, x > 0.9),(0, True))
However, I got this:
TypeError: Argument must be a Basic object, not ndarray
Is there a way to get around this?
I’ve tried list comprehension. However, it gets more difficult when there are more variables involved.
New contributor
Hazim M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.