Skip to content

Commit

Permalink
fix: non-NEP-50 case
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed Oct 29, 2023
1 parent 2586c8b commit 735c2a8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/awkward/_nplikes/array_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def apply_ufunc(
args: list[Any],
kwargs: dict[str, Any] | None = None,
) -> ArrayLike | tuple[ArrayLike]:
# Does NumPy support value-less ufunc resolution?
if NUMPY_HAS_NEP_50:
# Determine input argument dtypes
input_arg_dtypes = [getattr(obj, "dtype", type(obj)) for obj in args]
Expand All @@ -188,16 +189,15 @@ def apply_ufunc(
for arg, dtype in zip(args, resolved_dtypes)
]
else:
# Otherwise, perform default NumPy coercion (value-dependent)
resolved_args = [
self.asarray(arg, dtype=arg.dtype) if hasattr(arg, "dtype") else arg
for arg in args
]
# Broadcast these resolved arguments
broadcasted_args = self.broadcast_arrays(*resolved_args)
# Allow other nplikes to replace implementation
impl = self.prepare_ufunc(ufunc)
# Compute the result
return impl(*broadcasted_args, **(kwargs or {}))
return impl(*resolved_args, **(kwargs or {}))

def broadcast_arrays(self, *arrays: ArrayLike) -> list[ArrayLike]:
assert not any(isinstance(x, PlaceholderArray) for x in arrays)
Expand Down

0 comments on commit 735c2a8

Please sign in to comment.