summaryrefslogtreecommitdiff
path: root/numpy/_array_api/_creation_functions.py
diff options
context:
space:
mode:
authorAaron Meurer <asmeurer@gmail.com>2021-04-15 15:39:14 -0600
committerAaron Meurer <asmeurer@gmail.com>2021-04-15 15:39:14 -0600
commit6c196f540429aa0869e8fb66917a5e76447d2c02 (patch)
tree593b0e4602865f0c07519c061eee6f5681316b8c /numpy/_array_api/_creation_functions.py
parent9af1cc60edd4fdbb7e9c18d124e639a44ce420c7 (diff)
downloadnumpy-6c196f540429aa0869e8fb66917a5e76447d2c02.tar.gz
Fix type promotion consistency for the array API elementwise functions and operators
NumPy's type promotion behavior deviates from the spec, which says that type promotion should work independently of shapes or values, in cases where one array is 0-d and the other is not. A helper function is added that works around this issue by adding a dimension to the 0-d array before passing it to the NumPy function. This function is used in elementwise functions and operators. It may still need to be applied to other functions in the namespace. Additionally, this fixes: - The shift operators (<< and >>) should always return the same dtype as the first argument. - NumPy's __pow__ does not type promote the two arguments, so we use the array API pow() in ndarray.__pow__, which does. - The internal _promote_scalar helper function was changed to return an array API ndarray object, as this is simpler with the inclusion of the new _normalize_two_args helper in the operators.
Diffstat (limited to 'numpy/_array_api/_creation_functions.py')
0 files changed, 0 insertions, 0 deletions