Skip to content

Commit

Permalink
fix(metadata): interpret 0 fill value as "0" for Zarr V2 arrays
Browse files Browse the repository at this point in the history
This was the default in zarr-python 2.x.x.
  • Loading branch information
LDeakin committed Feb 7, 2025
1 parent d24d316 commit 4464d2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions zarrs_metadata/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Interpret a `0` fill value as `"0"` for Zarr V2 string arrays (for `zarr-python` 2.x.x compatibility)

## [0.3.3] - 2025-02-06

### Fixed
Expand Down
5 changes: 3 additions & 2 deletions zarrs_metadata/src/v2_to_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ pub fn array_metadata_v2_to_v3(
}
}
} else if data_type.name() == "string" {
// Add a special case for `zarr-python` string data with a 0 fill value -> empty string
// Add a special case for string data with a 0 fill value -> "0"
// This was the default in zarr-python 2.x.x.
if let Some(0) = fill_value.try_as_uint::<u64>() {
fill_value = FillValueMetadataV3::String(String::new());
fill_value = FillValueMetadataV3::String("0".to_string());
}
}

Expand Down

0 comments on commit 4464d2a

Please sign in to comment.