google / xarray-beam

Distributed Xarray with Apache Beam
https://xarray-beam.readthedocs.io
Apache License 2.0
126 stars 7 forks source link

[xarray-beam] Fix a bug in zarr._validate_chunk, which failed with KeyError when an offset is not specified for a dimension which has coordinates in both the template and the chunk. #35

Closed copybara-service[bot] closed 2 years ago

copybara-service[bot] commented 2 years ago

[xarray-beam] Fix a bug in zarr._validate_chunk, which failed with KeyError when an offset is not specified for a dimension which has coordinates in both the template and the chunk.

It should instead assume offset 0 for dimensions where an offset isn't specified, and it does already do this for dimensions which don't have coordinates/an index.

This required updating offsets_to_slices to return a slice for all dimensions where the chunk size is known, defaulting to slice(0, size, 1).

test_2d_chunks_to_zarr has been updated to add a case with separate coordinates for the two dimensions, which is sufficient to trigger the issue and fails before the fix.

Renames zarr._validate_chunk to _validate_zarr_chunk to avoid confusion with core.validate_chunk.

google-cla[bot] commented 2 years ago

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

google-cla[bot] commented 2 years ago

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.