Skip to content

Commit c0ca12b

Browse files
committed
Fix up tests
1 parent 3245833 commit c0ca12b

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

bio2zarr/vcf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def scan_vcfs(paths, show_progress, target_num_partitions, worker_processes=1):
281281
)
282282
with core.ParallelWorkManager(worker_processes, progress_config) as pwm:
283283
for path in paths:
284-
pwm.submit(scan_vcf, path, target_num_partitions//len(paths))
284+
pwm.submit(scan_vcf, path, max(1, target_num_partitions//len(paths)))
285285
results = list(pwm.results_as_completed())
286286

287287
# Sort to make the ordering deterministic
@@ -1068,7 +1068,7 @@ def convert_finalise(self):
10681068

10691069
for field in self.metadata.fields:
10701070
# Clear the summary to avoid problems when running in debug
1071-
# syncronous mode
1071+
# synchronous mode
10721072
field.summary = VcfFieldSummary()
10731073
for summary in partition_summaries:
10741074
field.summary.update(summary["field_summaries"][field.full_name])

tests/test_vcf_examples.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -791,14 +791,25 @@ def test_split_explode(tmp_path):
791791
"tests/data/vcf/sample.vcf.gz.3.split/X.vcf.gz",
792792
]
793793
out = tmp_path / "test.explode"
794-
pcvcf = vcf.explode_init(paths, out, num_partitions=15)
795-
with open(out / "num_partitions.txt", "r") as f:
796-
num_partitions = int(f.read())
797-
assert pcvcf.num_partitions == num_partitions
798-
assert num_partitions == 3
799-
vcf.explode_slice(out, 0, num_partitions)
800-
vcf.explode_finalise(out)
794+
pcvcf = vcf.explode_init(paths, out, target_num_partitions=15)
795+
assert pcvcf.num_partitions == 3
796+
assert vcf.explode_partition_count(out) == 3
801797

802-
vcf.encode(out, tmp_path / "test.zarr")
798+
with pytest.raises(ValueError):
799+
vcf.explode_slice(out, -1, 3)
800+
with pytest.raises(ValueError):
801+
vcf.explode_slice(out, 0, 42)
803802

803+
vcf.explode_slice(out, 0, 3)
804+
vcf.explode_finalise(out)
805+
pcvcf = vcf.PickleChunkedVcf.load(out)
806+
assert pcvcf.columns['POS'].vcf_field.summary.asdict() == {
807+
'num_chunks': 3,
808+
'compressed_size': 587,
809+
'uncompressed_size': 1008,
810+
'max_number': 1,
811+
'max_value': 1235237,
812+
'min_value': 10
813+
}
814+
vcf.encode(out, tmp_path / "test.zarr")
804815
vcf.validate("tests/data/vcf/sample.vcf.gz", tmp_path / "test.zarr")

0 commit comments

Comments
 (0)