Skip to content

Commit b2e3ecc

Browse files
committed
Require numeric types in diff
1 parent 729175f commit b2e3ecc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

array_api_strict/_utility_functions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from ._array_object import Array
44
from ._flags import requires_api_version
5+
from ._dtypes import _numeric_dtypes
56

67
from typing import TYPE_CHECKING
78
if TYPE_CHECKING:
@@ -49,6 +50,12 @@ def diff(
4950
prepend: Optional[Array] = None,
5051
append: Optional[Array] = None,
5152
) -> Array:
53+
if x.dtype not in _numeric_dtypes:
54+
raise TypeError("Only numeric dtypes are allowed in diff")
55+
56+
# TODO: The type promotion behavior for prepend and append is not
57+
# currently specified.
58+
5259
# NumPy does not support prepend=None or append=None
5360
kwargs = dict(axis=axis, n=n)
5461
if prepend is not None:

0 commit comments

Comments
 (0)