xbatcher
xbatcher copied to clipboard
Accessing some batches raises an error
What happened?
Hi everyone !
I'm jumping into xbatcher for my work on climate data, thanks for the work, I think this library is going to be very useful for me !
Trying to understand the impact of each argument of the BatchGenerator, I tried to run the following code which raised me an error. BatchGenerator instance has len 16, however I cannot access index 3.
Does anyone know how to fix that ?
Thanks a lot.
What did you expect to happen?
No response
Minimal Complete Verifiable Example
import xarray as xr
import xbatcher as xb
import numpy as np
ds = xr.DataArray(np.random.rand(30,30), name = 'var', dims = ['lat', 'lon'])
xbatcher = xb.BatchGenerator(
ds=ds,
input_dims={"lat": 6, 'lon': 6},
batch_dims={"lat": 7, 'lon': 7},
concat_input_dims=True,
)
print("Len :",len(xbatcher))
print(xbatcher[3])
Relevant log output
ValueError: min() arg is an empty sequence
Anything else we need to know?
No response
Environment
No response
Hi, @agirnow. I found your comment because I'm having a similar issue. Have you found a solution? In my case, the len(xbatcher) it's supposed to be ok but, from a given batch index I got the same error as you did. I've noticed that setting concat_input_dims=False runs well and generates sequences, although, the batches are not created as I expected in the first place. I hope you have more info on this. Thanks!