@@ -110,8 +110,8 @@ def _sample_xcp_metrics() -> XCPQCMetrics:
110110class TestXCPQCMetrics :
111111 """Tests for XCPQCMetrics NamedTuple structure."""
112112
113- def test_field_names_match_tsv_columns (self ) -> None :
114- """NamedTuple field names exactly match expected TSV columns."""
113+ def test_field_names_match_pq_columns (self ) -> None :
114+ """NamedTuple field names exactly match expected Parquet columns."""
115115 assert list (XCPQCMetrics ._fields ) == EXPECTED_COLUMNS
116116
117117 def test_field_count (self ) -> None :
@@ -224,55 +224,51 @@ class TestWriteXcpQc:
224224
225225 def test_writes_file (self , tmp_path : Path ) -> None :
226226 """Output file is created."""
227- out = tmp_path / "qc.tsv "
227+ out = tmp_path / "qc.parquet "
228228 result = write_xcp_qc (_sample_xcp_metrics (), out )
229229 assert result == out
230230 assert out .exists ()
231231
232232 def test_correct_headers (self , tmp_path : Path ) -> None :
233- """TSV header row matches expected column names."""
234- out = tmp_path / "qc.tsv "
233+ """Parquet column names match expected column names."""
234+ out = tmp_path / "qc.parquet "
235235 write_xcp_qc (_sample_xcp_metrics (), out )
236- header = out . read_text (). splitlines ()[ 0 ]. split ( " \t " )
237- assert header == EXPECTED_COLUMNS
236+ df = pl . read_parquet ( out )
237+ assert df . columns == EXPECTED_COLUMNS
238238
239239 def test_correct_values (self , tmp_path : Path ) -> None :
240240 """Values in TSV match the input metrics."""
241241 m = _sample_xcp_metrics ()
242- out = tmp_path / "qc.tsv "
242+ out = tmp_path / "qc.parquet "
243243 write_xcp_qc (m , out )
244- values = out . read_text (). splitlines ()[ 1 ]. split ( " \t " )
245- assert values [0 ] == "01" # sub
246- assert values [ 3 ] == "1" # run
247- assert float ( values [ 7 ]) == m .meanFD
244+ df = pl . read_parquet ( out )
245+ assert df [ "sub" ] [0 ] == "01" # sub
246+ assert df [ "run" ][ 0 ] == 1 # run
247+ assert df [ "meanFD" ][ 0 ] == m .meanFD
248248
249249 def test_round_trip_polars (self , tmp_path : Path ) -> None :
250250 """Polars can read back the TSV and recover the values."""
251251 m = _sample_xcp_metrics ()
252- out = tmp_path / "qc.tsv "
252+ out = tmp_path / "qc.parquet "
253253 write_xcp_qc (m , out )
254- df = pl .read_csv (
255- out ,
256- separator = "\t " ,
257- schema_overrides = {"sub" : pl .Utf8 , "ses" : pl .Utf8 },
258- )
254+ df = pl .read_parquet (out )
259255 assert df .shape == (1 , 24 )
260256 assert df ["sub" ][0 ] == "01"
261257 assert df ["meanFD" ][0 ] == m .meanFD
262258 assert df ["normCoverage" ][0 ] == m .normCoverage
263259
264260 def test_creates_parent_dirs (self , tmp_path : Path ) -> None :
265261 """Parent directories are created if they don't exist."""
266- out = tmp_path / "a" / "b" / "c" / "qc.tsv "
262+ out = tmp_path / "a" / "b" / "c" / "qc.parquet "
267263 write_xcp_qc (_sample_xcp_metrics (), out )
268264 assert out .exists ()
269265
270266 def test_single_data_row (self , tmp_path : Path ) -> None :
271- """TSV has exactly one header row and one data row."""
272- out = tmp_path / "qc.tsv "
267+ """Parquet has exactly one data row."""
268+ out = tmp_path / "qc.parquet "
273269 write_xcp_qc (_sample_xcp_metrics (), out )
274- lines = out . read_text (). strip (). splitlines ( )
275- assert len ( lines ) == 2
270+ df = pl . read_parquet ( out )
271+ assert df . shape [ 0 ] == 1
276272
277273
278274# ===================================================================
0 commit comments