Before raising an issue on github, I wanted to ask, whether I try to do something note quite legal. I would like to clean up the implementation of the ==, and != binary operators in ulab, and I don't get what I expect. Namely, the following code does what it is supposed to
Code: Select all
import ulab
a = ulab.array([1, 2, 3], dtype=ulab.uint8)
b = ulab.array([2, 2, 2])
print(b)
print(a == b)
print(a < 2)
Code: Select all
import ulab
a = ulab.array([1, 2, 3], dtype=ulab.uint8)
print(a == 2)
Code: Select all
mp_obj_t ndarray_binary_op(mp_binary_op_t _op, mp_obj_t lhs, mp_obj_t rhs) {
printf("in binary_op");
// if the ndarray stands on the right hand side of the expression, simply swap the operands
ndarray_obj_t *ol, *or;
mp_binary_op_t op = _op;
I presume, this has to do with how binary operators are resolved in runtime.c. Is this reasoning correct, or there is something I could do without having to tamper with the micropython core?
Thanks,
Zoltán