KITTI-C2L-Dataset / code /tests /test_schema.py
mcocheteux's picture
Release KITTI-C2L v1.0.0: documented self-contained benchmark, loader and baselines
db613b6 verified
Raw History Blame Contribute Delete
1.76 kB
from __future__ import annotations
from pathlib import Path
import pyarrow.parquet as pq
from kitti_c2l.generate import generate_sequence_rows
from kitti_c2l.schema import COLUMN_NAMES, SCHEMA
from kitti_c2l.sequence_mapping import SequenceInfo
from kitti_c2l.stages import STAGES
from kitti_c2l.writer import write_split
def test_parquet_round_trip(fake_kitti_root: Path, tmp_path: Path):
seq_info = SequenceInfo(sequence="04", date="2011_09_30", drive="0016", start=0, end=3, frame_count=4, split="train")
rows = list(generate_sequence_rows(seq_info, fake_kitti_root, stages=STAGES))
output_path = tmp_path / "train.parquet"
count = write_split(rows, output_path)
assert count == len(rows)
table = pq.read_table(output_path)
assert table.schema.equals(SCHEMA)
assert table.num_rows == len(rows)
first = table.to_pylist()[0]
assert set(first.keys()) == set(COLUMN_NAMES)
assert len(first["gt_R_cam_from_velo"]) == 9
assert len(first["camera_intrinsics"]) == 9
def test_row_values_survive_round_trip(fake_kitti_root: Path, tmp_path: Path):
seq_info = SequenceInfo(sequence="04", date="2011_09_30", drive="0016", start=0, end=3, frame_count=4, split="train")
rows = list(generate_sequence_rows(seq_info, fake_kitti_root, stages=STAGES[:1]))
output_path = tmp_path / "train.parquet"
write_split(rows, output_path)
table_rows = pq.read_table(output_path).to_pylist()
for original, read_back in zip(rows, table_rows, strict=True):
assert read_back["sample_id"] == original.sample_id
assert read_back["sample_seed"] == original.sample_seed
for a, b in zip(read_back["gt_R_cam_from_velo"], original.gt_R_cam_from_velo, strict=True):
assert a == b