Skip to content

Commit

Permalink
Change zip to fail if iterables are different lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite committed Nov 4, 2024
1 parent b815d54 commit 7db7586
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bio2zarr/plink.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ def validate(bed_path, zarr_path):
assert call_genotype.shape[2] == 2

row_id = 0
for bed_row, zarr_row in zip(bed_genotypes, call_genotype, strict=False):
for bed_row, zarr_row in zip(bed_genotypes, call_genotype, strict=True):
# print("ROW", row_id)
# print(bed_row, zarr_row)
row_id += 1
for bed_call, zarr_call in zip(bed_row, zarr_row, strict=False):
for bed_call, zarr_call in zip(bed_row, zarr_row, strict=True):
if bed_call == -127:
assert list(zarr_call) == [-1, -1]
elif bed_call == 0:
Expand Down
4 changes: 2 additions & 2 deletions bio2zarr/vcf2zarr/icf.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def scan_vcf(path, target_num_partitions, *, local_alleles):
samples=[Sample(sample_id) for sample_id in vcf.samples],
contigs=[
Contig(contig_id, length)
for contig_id, length in zip(vcf.seqnames, contig_lengths, strict=False)
for contig_id, length in zip(vcf.seqnames, contig_lengths, strict=True)
],
filters=filters,
fields=fields,
Expand Down Expand Up @@ -766,7 +766,7 @@ def chunks(self, partition_id, start_chunk=0):
for count, cumulative in zip(
chunk_num_records[start_chunk:],
chunk_cumulative_records[start_chunk + 1 :],
strict=False,
strict=True,
):
path = partition_path / f"{cumulative}"
chunk = self.read_chunk(path)
Expand Down
2 changes: 1 addition & 1 deletion bio2zarr/vcf2zarr/vcz.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ def encode_alleles_partition(self, partition_index):
for ref, alt in zip(
ref_field.iter_values(partition.start, partition.stop),
alt_field.iter_values(partition.start, partition.stop),
strict=False,
strict=True,
):
j = alleles.next_buffer_row()
alleles.buff[j, :] = constants.STR_FILL
Expand Down
2 changes: 1 addition & 1 deletion bio2zarr/vcf2zarr/verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def assert_format_val_equal(vcf_val, zarr_val, vcf_type, vcf_number):
assert isinstance(vcf_val, np.ndarray)
if vcf_type in ("String", "Character"):
assert len(vcf_val) == len(zarr_val)
for v, z in zip(vcf_val, zarr_val, strict=False):
for v, z in zip(vcf_val, zarr_val, strict=True):
if vcf_number == "1":
assert v == z
else:
Expand Down
2 changes: 1 addition & 1 deletion bio2zarr/vcf_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
return False

def contig_record_counts(self):
d = dict(zip(self.sequence_names, self.index.record_counts, strict=False))
d = dict(zip(self.sequence_names, self.index.record_counts, strict=True))
if self.file_type == VcfFileType.BCF:
d = {k: v for k, v in d.items() if v > 0}
return d
Expand Down

0 comments on commit 7db7586

Please sign in to comment.