Pass pre-commit checks...
MODIFY
pangeo_forge_recipes/recipes/xarray_zarr.py
pangeo_forge_recipes/recipes/xarray_zarr.py
@@ -402,14 +402,18 @@ def calculate_sequence_lens(
all_lens = np.expand_dims(all_lens, 1)
# check that all lens are the same along the concat dim
- unique_vec, unique_idx, unique_counts = np.unique(all_lens, axis=1, return_index=True, return_counts=True)
+ unique_vec, unique_idx, unique_counts = np.unique(
+ all_lens, axis=1, return_index=True, return_counts=True
+ )
if len(unique_idx) > 1:
correct_col = all_lens[:, unique_idx[np.argmax(unique_counts)]]
err_idx = np.where(np.expand_dims(correct_col, 1) != all_lens)
err_pos = list(zip(*err_idx))
# present a list of problematic files to the user, given the file pattern.
- file_list = '\n'.join([f"- {_get_fname_from_error_pos(epos, file_pattern)!r}" for epos in err_pos])
+ file_list = "\n".join(
+ [f"- {_get_fname_from_error_pos(epos, file_pattern)!r}" for epos in err_pos]
+ )
raise ValueError(
f"Inconsistent sequence lengths between indices {unique_idx} of the concat dim."
f"\nValue(s) {all_lens[err_idx]} at position(s) {err_pos} are different from the rest."

MODIFY
tests/recipe_tests/test_XarrayZarrRecipe.py
tests/recipe_tests/test_XarrayZarrRecipe.py
@@ -510,7 +510,9 @@ def test_calc_sequence_length_errors_multiple_inconsistent_lengths(
"a": {"dims": {"time": [1] * 3, "variables": []}},
"b": {"dims": {"time": [2] * 3, "variables": []}},
"c": {"dims": {"time": [7] + [3] * 2, "variables": []}}, # Inconsistent sequence length
- "d": {"dims": {"time": [4] * 2 + [10], "variables": []}}, # Inconsistent sequence length
+ "d": {
+ "dims": {"time": [4] * 2 + [10], "variables": []}
+ }, # Inconsistent sequence length
}
monkeypatch.setattr(MetadataTarget, "getitems", mock_getitems)

Pass pre-commit checks...