Replies: 1 comment
-
Your function needs to return a array of constant length for If I understand your example correctly, you can simply create a constant-length array and fill that as needed: def func(a):
assert a.ndim == 1, a.ndim
random_ = np.random.randint(low=4, high=7)
out = np.full((7,), fill_value=np.nan)
out[:random_] = a + np.arange(random_)
return out |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there,
Suppose I have input data as
space
xtime,
and for each spatial point, I'd like to compute a decomposition of any kind. This means that the input to the function is 1D array(time)
, and my function returns decomposition as(mode, time)
. Now, the tricky part is that the number of modes depends on the input time series, which can be between 4-6. No matter how I setxr.apply_ufunc
I am gettingValueError: could not broadcast input array from the shape (5,500) into shape (6,500)
.Here is the dummy code:
Is there any way to make this work? The ideal solution would be to use the highest number of modes in the
frequency
dimension and fill non-existent values with nan or something else.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions