Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing some batches raises an error #184

Open
agirnow opened this issue Apr 20, 2023 · 1 comment
Open

Accessing some batches raises an error #184

agirnow opened this issue Apr 20, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@agirnow
Copy link

agirnow commented Apr 20, 2023

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

@agirnow agirnow added the bug Something isn't working label Apr 20, 2023
@jpcurbelo
Copy link

jpcurbelo commented Dec 5, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants