Skip to content

Commit 27a79ec

Browse files
committed
Use auto dtype for positions
1 parent 727e47d commit 27a79ec

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

bio2zarr/tskit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,17 @@ def generate_schema(
153153
)
154154

155155
# Check if positions will fit in i4 (max ~2.1 billion)
156+
min_position = 0
156157
max_position = 0
157158
if self.ts.num_sites > 0:
159+
min_position = np.min(self.ts.sites_position)
158160
max_position = np.max(self.ts.sites_position)
159-
position_dtype = "i4" if max_position <= np.iinfo(np.int32).max else "i8"
160161

161162
array_specs = [
162163
vcz.ZarrArraySpec(
163164
source="position",
164165
name="variant_position",
165-
dtype=position_dtype,
166+
dtype=core.min_int_dtype(min_position, max_position),
166167
dimensions=["variants"],
167168
description="Position of each variant",
168169
),

0 commit comments

Comments
 (0)