Skip to content

Commit

Permalink
Guard scalar arguments with API_VERSION>=2024.12
Browse files Browse the repository at this point in the history
  • Loading branch information
ev-br committed Nov 22, 2024
1 parent 866cedb commit cfb8e54
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions array_api_strict/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
"""
import numpy as np

from ._flags import get_array_api_strict_flags


_py_scalars = (bool, int, float, complex)


def _maybe_normalize_py_scalars(x1, x2):
from ._array_object import Array

flags = get_array_api_strict_flags()
if flags["array_api"] < "2024.12":
# XXX: string comparison for versions
return x1, x2

if isinstance(x1, _py_scalars):
if isinstance(x2, _py_scalars):
raise TypeError(f"Two scalars not allowed, {type(x1) = } and {type(x2) =}")
Expand Down

0 comments on commit cfb8e54

Please sign in to comment.