Skip to content

Commit 0a72058

Browse files
Merge pull request #10 from benjeffery/check-size
Check size before min/max
2 parents 1282e3b + 4079638 commit 0a72058

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bio2zarr/vcf.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,9 @@ def update_bounds_float(summary, value, number_dim):
545545
value = np.array(value, dtype=np.float32, copy=False)
546546
# Map back to python types to avoid JSON issues later. Could
547547
# be done more efficiently at the end.
548-
summary.max_value = float(max(summary.max_value, np.max(value)))
549-
summary.min_value = float(min(summary.min_value, np.min(value)))
548+
if value.size > 0:
549+
summary.min_value = float(min(summary.min_value, np.min(value)))
550+
summary.max_value = float(max(summary.max_value, np.max(value)))
550551
number = 0
551552
assert len(value.shape) <= number_dim + 1
552553
if len(value.shape) == number_dim + 1:
@@ -564,8 +565,9 @@ def update_bounds_integer(summary, value, number_dim):
564565
value = np.array(value, dtype=np.int32, copy=False)
565566
# Mask out missing and fill values
566567
a = value[value >= MIN_INT_VALUE]
567-
summary.max_value = int(max(summary.max_value, np.max(a)))
568-
summary.min_value = int(min(summary.min_value, np.min(a)))
568+
if a.size > 0:
569+
summary.max_value = int(max(summary.max_value, np.max(a)))
570+
summary.min_value = int(min(summary.min_value, np.min(a)))
569571
number = 0
570572
assert len(value.shape) <= number_dim + 1
571573
if len(value.shape) == number_dim + 1:

0 commit comments

Comments
 (0)