summaryrefslogtreecommitdiff
path: root/numpy/array_api/_array_object.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2022-04-04 17:23:40 -0600
committerGitHub <noreply@github.com>2022-04-04 17:23:40 -0600
commitbebf21809dccd6d5f37df525ace83e1ed2d4b8c3 (patch)
tree068beb4dc95471d7f967155f000caac99a7cd165 /numpy/array_api/_array_object.py
parentbcc570c864492530f7603fc5150b558b8fde5c84 (diff)
parent3b3843895150ea1cf15b6fb306b0d0306ca7d999 (diff)
downloadnumpy-bebf21809dccd6d5f37df525ace83e1ed2d4b8c3.tar.gz
Merge pull request #21260 from asmeurer/array-api-docs
Add a document that enumerates the differences between numpy and numpy.array_api
Diffstat (limited to 'numpy/array_api/_array_object.py')
-rw-r--r--numpy/array_api/_array_object.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/numpy/array_api/_array_object.py b/numpy/array_api/_array_object.py
index c86cfb3a6..6cf9ec6f3 100644
--- a/numpy/array_api/_array_object.py
+++ b/numpy/array_api/_array_object.py
@@ -177,6 +177,8 @@ class Array:
integer that is too large to fit in a NumPy integer dtype, or
TypeError when the scalar type is incompatible with the dtype of self.
"""
+ # Note: Only Python scalar types that match the array dtype are
+ # allowed.
if isinstance(scalar, bool):
if self.dtype not in _boolean_dtypes:
raise TypeError(
@@ -195,6 +197,9 @@ class Array:
else:
raise TypeError("'scalar' must be a Python scalar")
+ # Note: scalars are unconditionally cast to the same dtype as the
+ # array.
+
# Note: the spec only specifies integer-dtype/int promotion
# behavior for integers within the bounds of the integer dtype.
# Outside of those bounds we use the default NumPy behavior (either