diff options
author | Aaron Meurer <asmeurer@gmail.com> | 2021-07-15 16:40:07 -0600 |
---|---|---|
committer | Aaron Meurer <asmeurer@gmail.com> | 2021-07-15 16:40:07 -0600 |
commit | c5580134c71b68c0bd24104a6393e3cea9cb25ce (patch) | |
tree | 10d5d855670b9a6c0431d4238b4bd7f1ad384c59 /numpy/_array_api/_array_object.py | |
parent | b58fbd24783b29d377427e837d189fa039422c9a (diff) | |
download | numpy-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.py | 6 |
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 |