You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which is fair enough in a sense. Our scalars are weird...
This also makes some stranger things work though:
class myf:
def __radd__(self, other):
return f"called backward with {type(other)}"
f32 + myf()
# "called backward with <class 'float'>"
This works by first dispatching to the ufunc machinery, which converts both to arrays, which then casts f32 to object and then calls the full operator (both ways in principle).
Now, that would enter a recursive call of course if it would not convert to the float32 to a python float, so that:
myf() + np.float128()
segfaults due to infinite recursion I guess. If you swap the order, things are more OK, although it probably crashes just as much if np.float128 was instead a subclass of float128...
The text was updated successfully, but these errors were encountered:
Consider the NumPy float32:
which is fair enough in a sense. Our scalars are weird...
This also makes some stranger things work though:
This works by first dispatching to the ufunc machinery, which converts both to arrays, which then casts
f32
to object and then calls the full operator (both ways in principle).Now, that would enter a recursive call of course if it would not convert to the
float32
to a python float, so that:segfaults due to infinite recursion I guess. If you swap the order, things are more OK, although it probably crashes just as much if
np.float128
was instead a subclass of float128...The text was updated successfully, but these errors were encountered: