@@ -36,22 +36,28 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
3636 if ufunc .signature is not None :
3737 raise NotImplementedError (
3838 '{} not supported: xarray objects do not directly implement '
39- 'generalized ufuncs. Instead, use xarray.apply_ufunc.'
39+ 'generalized ufuncs. Instead, use xarray.apply_ufunc or '
40+ 'explicitly convert to xarray objects to NumPy arrays '
41+ '(e.g., with `.values`).'
4042 .format (ufunc ))
4143
4244 if method != '__call__' :
4345 # TODO: support other methods, e.g., reduce and accumulate.
4446 raise NotImplementedError (
4547 '{} method for ufunc {} is not implemented on xarray objects, '
46- 'which currently only support the __call__ method.'
48+ 'which currently only support the __call__ method. As an '
49+ 'alternative, consider explicitly converting xarray objects '
50+ 'to NumPy arrays (e.g., with `.values`).'
4751 .format (method , ufunc ))
4852
4953 if any (isinstance (o , SupportsArithmetic ) for o in out ):
5054 # TODO: implement this with logic like _inplace_binary_op. This
5155 # will be necessary to use NDArrayOperatorsMixin.
5256 raise NotImplementedError (
5357 'xarray objects are not yet supported in the `out` argument '
54- 'for ufuncs.' )
58+ 'for ufuncs. As an alternative, consider explicitly '
59+ 'converting xarray objects to NumPy arrays (e.g., with '
60+ '`.values`).' )
5561
5662 join = dataset_join = OPTIONS ['arithmetic_join' ]
5763
0 commit comments