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
Somewhat similar to #51 (I've still no idea how to open an enhancement request against the standard itself).
The difference to #51 is that one can argue that int/int division is float; for comparisons however the limitation to matching dtypes serves no obvious purpose.
In [1]: import array_api_strict as xp
In [2]: xp.arange(5) < 3.0
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[2], line 1
----> 1 xp.arange(5) < 3.0
File ~/miniforge3/envs/scipy-dev/lib/python3.12/site-packages/array_api_strict/_array_object.py:717, in Array.__lt__(self, other)
713 def __lt__(self: Array, other: Union[int, float, Array], /) -> Array:
714 """
715 Performs the operation __lt__.
716 """
--> 717 other = self._check_allowed_dtypes(other, "real numeric", "__lt__")
718 if other is NotImplemented:
719 return other
File ~/miniforge3/envs/scipy-dev/lib/python3.12/site-packages/array_api_strict/_array_object.py:169, in Array._check_allowed_dtypes(self, other, dtype_category, op)
167 raise TypeError(f"Only {dtype_category} dtypes are allowed in {op}")
168 if isinstance(other, (int, complex, float, bool)):
--> 169 other = self._promote_scalar(other)
170 elif isinstance(other, Array):
171 if other.dtype not in _dtype_categories[dtype_category]:
File ~/miniforge3/envs/scipy-dev/lib/python3.12/site-packages/array_api_strict/_array_object.py:229, in Array._promote_scalar(self, scalar)
227 elif isinstance(scalar, float):
228 if self.dtype not in _floating_dtypes:
--> 229 raise TypeError(
230 "Python float scalars can only be promoted with floating-point arrays."
231 )
232 elif isinstance(scalar, complex):
233 if self.dtype not in _complex_floating_dtypes:
TypeError: Python float scalars can only be promoted with floating-point arrays.
The text was updated successfully, but these errors were encountered:
for comparisons however the limitation to matching dtypes serves no obvious purpose.
FWIW, I agree with you. I brought this up at data-apis/array-api#819, and it was discussed at the consortium meetings, but the consensus there was that this should remain undefined data-apis/array-api#822 (which means the strict library will raise an error on it). Feel free to voice your concerns about this on that issue.
Somewhat similar to #51 (I've still no idea how to open an enhancement request against the standard itself).
The difference to #51 is that one can argue that int/int division is float; for comparisons however the limitation to matching dtypes serves no obvious purpose.
The text was updated successfully, but these errors were encountered: