@@ -36,22 +36,28 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
36
36
if ufunc .signature is not None :
37
37
raise NotImplementedError (
38
38
'{} 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`).'
40
42
.format (ufunc ))
41
43
42
44
if method != '__call__' :
43
45
# TODO: support other methods, e.g., reduce and accumulate.
44
46
raise NotImplementedError (
45
47
'{} 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`).'
47
51
.format (method , ufunc ))
48
52
49
53
if any (isinstance (o , SupportsArithmetic ) for o in out ):
50
54
# TODO: implement this with logic like _inplace_binary_op. This
51
55
# will be necessary to use NDArrayOperatorsMixin.
52
56
raise NotImplementedError (
53
57
'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`).' )
55
61
56
62
join = dataset_join = OPTIONS ['arithmetic_join' ]
57
63
0 commit comments