Skip to content

Commit

Permalink
Fix division-by-zero when computing statistics for a single-time data…
Browse files Browse the repository at this point in the history
…set (#142)

When calculating sample indices, make sure that at least one sample
is included.
  • Loading branch information
mpartio authored Nov 29, 2024
1 parent 26a32a1 commit 7f7b181
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/anemoi/datasets/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def _compute_constant_fields_from_a_few_samples(self):
sample_count = min(4, len(indices))
count = len(indices)

p = slice(0, count, count // (sample_count - 1))
p = slice(0, count, count // max(1, sample_count - 1))
samples = list(range(*p.indices(count)))

samples.append(count - 1) # Add last
Expand Down

0 comments on commit 7f7b181

Please sign in to comment.