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
Functions like equal, greater, and so on (and the operator equivalents) don't allow comparing non-promotable dtypes. This is particularly annoying because it makes it impossible to actually compare uint64 with int64, since the two cannot promote.
>>>importarray_api_strictasxp>>>xp.asarray(0, dtype=xp.int64) <xp.asarray(1, dtype=xp.uint64)
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"/Users/aaronmeurer/Documents/array-api-strict/array_api_strict/_array_object.py", line717, in__lt__other=self._check_allowed_dtypes(other, "real numeric", "__lt__")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/Users/aaronmeurer/Documents/array-api-strict/array_api_strict/_array_object.py", line179, in_check_allowed_dtypesres_dtype=_result_type(self.dtype, other.dtype)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/Users/aaronmeurer/Documents/array-api-strict/array_api_strict/_dtypes.py", line217, in_result_typeraiseTypeError(f"{type1} and {type2} cannot be type promoted together")
TypeError: array_api_strict.int64andarray_api_strict.uint64cannotbe type promotedtogether
However, the standard doesn't actually say anywhere in greater or __gt__ that the input types must be promotable:
Although we can probably just fallback to what NumPy does for now. The only potential problem is pre-2.0 promotion behavior, which is another argument for making 2.0 a hard dependency #21. I also need to double check that NumPy 2.0 isn't internally promoting uint64 and int64 to float64, although if it is I doubt I can reasonably work around it.
Functions like equal, greater, and so on (and the operator equivalents) don't allow comparing non-promotable dtypes. This is particularly annoying because it makes it impossible to actually compare uint64 with int64, since the two cannot promote.
However, the standard doesn't actually say anywhere in
greater
or__gt__
that the input types must be promotable:https://data-apis.org/array-api/latest/API_specification/generated/array_api.greater.html#greater
https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.__gt__.html
just that they should be real numeric. So in principle, these operators should even work when comparing floats and integers.
And
equal
allows any data type https://data-apis.org/array-api/latest/API_specification/generated/array_api.equal.html#equal, https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.__eq__.htmlIt might be good to get some clarification in the standard about this, for instance, on how
==
should behave for mixing certain dtype combinations.The text was updated successfully, but these errors were encountered: