Skip to content

Accessing some batches raises an error #184

Open
@agirnow

Description

@agirnow

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions