-
I'm not sure I fully understand import xarray as xr
import numpy as np
def test(x, y, z):
print(f"x: {x} | y: {y} | z: {z}")
return x + y
x = xr.DataArray(np.linspace(0, 2, 3), dims="x")
y = xr.DataArray(np.linspace(2, 4, 3), dims="y")
# this works
z = [1, 2, 3]
# using either one of the below crashes
# z = {1, 2, 3}
# z = {"a": 1, "b": 2, "c": 3}
print(xr.apply_ufunc(test, x, y, z, input_core_dims=((), (), ("z")), vectorize=True))
# prints if using a list
# x: 0.0 | y: 2.0 | z: [1 2 3]
# x: 0.0 | y: 3.0 | z: [1 2 3]
# ... How can I use What would happen if I then pass e.g. I guess what I'm asking for is for |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
To pass arbitrary things, pass them as The variables in
Instead try
|
Beta Was this translation helpful? Give feedback.
To pass arbitrary things, pass them as
kwargs
.The variables in
*args
(herex
,y
,z
) are interpreted as array-like. So dicts won't really work or sets, which are unordered, won't work well.Instead try