summaryrefslogtreecommitdiff
path: root/numpy/_array_api/_array_object.py
diff options
context:
space:
mode:
authorAaron Meurer <asmeurer@gmail.com>2021-07-15 16:40:07 -0600
committerAaron Meurer <asmeurer@gmail.com>2021-07-15 16:40:07 -0600
commitc5580134c71b68c0bd24104a6393e3cea9cb25ce (patch)
tree10d5d855670b9a6c0431d4238b4bd7f1ad384c59 /numpy/_array_api/_array_object.py
parentb58fbd24783b29d377427e837d189fa039422c9a (diff)
downloadnumpy-c5580134c71b68c0bd24104a6393e3cea9cb25ce.tar.gz
Add a comment about the _normalize_two_args trick
Diffstat (limited to 'numpy/_array_api/_array_object.py')
-rw-r--r--numpy/_array_api/_array_object.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/numpy/_array_api/_array_object.py b/numpy/_array_api/_array_object.py
index 6e451ab7a..e523acd2d 100644
--- a/numpy/_array_api/_array_object.py
+++ b/numpy/_array_api/_array_object.py
@@ -130,6 +130,12 @@ class Array:
broadcasting, so the resulting shape is the same, but this prevents NumPy
from not promoting the dtype.
"""
+ # Another option would be to use signature=(x1.dtype, x2.dtype, None),
+ # but that only works for ufuncs, so we would have to call the ufuncs
+ # directly in the operator methods. One should also note that this
+ # sort of trick wouldn't work for functions like searchsorted, which
+ # don't do normal broadcasting, but there aren't any functions like
+ # that in the array API namespace.
if x1.ndim == 0 and x2.ndim != 0:
# The _array[None] workaround was chosen because it is relatively
# performant. broadcast_to(x1._array, x2.shape) is much slower. We