Skip to content

Commit 0e18357

Browse files
committed
Change zip to fail if iteratables are different lengths
1 parent 528eea0 commit 0e18357

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

tests/test_vcf_writer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_write_vcf__filtering(tmp_path, include, exclude, expected_chrom_pos):
8585
assert len(variants) == len(expected_chrom_pos)
8686
assert v.samples == ["NA00001", "NA00002", "NA00003"]
8787

88-
for variant, chrom_pos in zip(variants, expected_chrom_pos, strict=False):
88+
for variant, chrom_pos in zip(variants, expected_chrom_pos, strict=True):
8989
chrom, pos = chrom_pos
9090
assert variant.CHROM == chrom
9191
assert variant.POS == pos
@@ -141,7 +141,7 @@ def test_write_vcf__regions(tmp_path, regions, targets,
141141

142142
assert v.samples == ["NA00001", "NA00002", "NA00003"]
143143

144-
for variant, chrom_pos in zip(variants, expected_chrom_pos, strict=False):
144+
for variant, chrom_pos in zip(variants, expected_chrom_pos, strict=True):
145145
chrom, pos = chrom_pos
146146
assert variant.CHROM == chrom
147147
assert variant.POS == pos
@@ -230,7 +230,7 @@ def test_write_vcf__regions_samples_filtering(
230230
assert len(variants) == len(expected_chrom_pos)
231231
assert v.samples == ["NA00001"]
232232

233-
for variant, chrom_pos in zip(variants, expected_chrom_pos, strict=False):
233+
for variant, chrom_pos in zip(variants, expected_chrom_pos, strict=True):
234234
chrom, pos = chrom_pos
235235
assert variant.CHROM == chrom
236236
assert variant.POS == pos

vcztools/query.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def generate(root):
9999
end = start + v_chunk_size
100100

101101
for gt_row, phase in zip(
102-
gt_zarray[start:end], phase_zarray[start:end], strict=False
102+
gt_zarray[start:end], phase_zarray[start:end], strict=True
103103
):
104104

105105
def stringify(gt_and_phase: tuple):
@@ -113,7 +113,7 @@ def stringify(gt_and_phase: tuple):
113113
return separator.join(gt)
114114

115115
gt_row = gt_row.tolist()
116-
yield map(stringify, zip(gt_row, phase, strict=False))
116+
yield map(stringify, zip(gt_row, phase, strict=True))
117117
else:
118118
# TODO: Support datasets without the phasing data
119119
raise NotImplementedError
@@ -219,8 +219,8 @@ def _compose_sample_loop_generator(
219219

220220
def generate(root):
221221
iterables = (generator(root) for generator in generators)
222-
zipped = zip(*iterables, strict=False)
223-
zipped_zipped = (zip(*element, strict=False) for element in zipped)
222+
zipped = zip(*iterables, strict=True)
223+
zipped_zipped = (zip(*element, strict=True) for element in zipped)
224224
flattened_zipped_zipped = (
225225
(
226226
subsubelement
@@ -309,7 +309,7 @@ def generate(root) -> str:
309309
filter_iterable = filter_generator(root)
310310

311311
for results, filter_indicator in zip(
312-
zip(*iterables, strict=False), filter_iterable, strict=False
312+
zip(*iterables, strict=True), filter_iterable, strict=True
313313
):
314314
if filter_indicator:
315315
results = map(str, results)

vcztools/stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def stats(vcz, output):
3838
).astype(np.int64)
3939

4040
for contig, contig_length, nr in zip(
41-
contigs, contig_lengths, num_records_per_contig, strict=False
41+
contigs, contig_lengths, num_records_per_contig, strict=True
4242
):
4343
if nr > 0:
4444
print(f"{contig}\t{contig_length}\t{nr}", file=output)

0 commit comments

Comments
 (0)