From 735c2a8df9fea0479c7e7d6269056ef329f385e0 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Sun, 29 Oct 2023 22:34:23 +0000 Subject: [PATCH] fix: non-NEP-50 case --- src/awkward/_nplikes/array_module.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/awkward/_nplikes/array_module.py b/src/awkward/_nplikes/array_module.py index d9b9b8a1a3..cb4d18b86b 100644 --- a/src/awkward/_nplikes/array_module.py +++ b/src/awkward/_nplikes/array_module.py @@ -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] @@ -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)