2626import json
2727import os
2828from pathlib import Path
29- from typing import Any
3029
3130import pytest
3231
@@ -141,13 +140,11 @@ def test_document_type_counts(self, jess_haley_dataset):
141140 actual_count = actual .get (dtype , 0 )
142141 if dtype == "session" :
143142 # Dataset init adds 1 extra session doc
144- assert actual_count >= expected , (
145- f" { dtype } : expected >= { expected } , got { actual_count } "
146- )
143+ assert (
144+ actual_count >= expected
145+ ), f" { dtype } : expected >= { expected } , got { actual_count } "
147146 else :
148- assert actual_count == expected , (
149- f"{ dtype } : expected { expected } , got { actual_count } "
150- )
147+ assert actual_count == expected , f"{ dtype } : expected { expected } , got { actual_count } "
151148
152149 def test_all_documents_have_base_id (self , all_docs_raw ):
153150 """Every document has a base.id field."""
@@ -227,9 +224,9 @@ def test_groups_by_variable_names(self, otr_tables):
227224 def test_group_row_counts (self , otr_tables ):
228225 data_tables , _ = otr_tables
229226 actual_sizes = sorted ([len (dt ) for dt in data_tables ], reverse = True )
230- assert actual_sizes == EXPECTED_OTR_GROUP_SIZES_SORTED , (
231- f"Group sizes mismatch: { actual_sizes } != { EXPECTED_OTR_GROUP_SIZES_SORTED } "
232- )
227+ assert (
228+ actual_sizes == EXPECTED_OTR_GROUP_SIZES_SORTED
229+ ), f"Group sizes mismatch: { actual_sizes } != { EXPECTED_OTR_GROUP_SIZES_SORTED } "
233230
234231 def test_data_dict_extraction (self , otr_tables ):
235232 """At least one group has bacterial plate columns."""
@@ -261,9 +258,9 @@ def test_encounter_table_has_numeric_data(self, otr_tables):
261258 # Find the encounter table (largest group, ~20411 rows)
262259 encounter_table = max (data_tables , key = len )
263260 decel_col = "CElegansBehavioralAssay_DecelerationUponEncounter"
264- assert decel_col in encounter_table . columns , (
265- f"' { decel_col } ' not in largest group columns: { list ( encounter_table .columns ) } "
266- )
261+ assert (
262+ decel_col in encounter_table .columns
263+ ), f"' { decel_col } ' not in largest group columns: { list ( encounter_table . columns ) } "
267264 assert pd .api .types .is_numeric_dtype (encounter_table [decel_col ])
268265
269266 def test_bacterial_plate_table_has_expected_columns (self , otr_tables ):
@@ -633,7 +630,9 @@ def test_session_id_consistency(self, jess_haley_dataset):
633630 # Note: session_id is the session object's ID, NOT the session
634631 # document's base.id. The Jess Haley dataset has 3 unique session_ids.
635632 assert len (session_ids ) >= 2 , f"Expected >= 2 unique session_ids, got { session_ids } "
636- assert len (session_ids ) <= 10 , f"Too many session_ids ({ len (session_ids )} ), data may be corrupt"
633+ assert (
634+ len (session_ids ) <= 10
635+ ), f"Too many session_ids ({ len (session_ids )} ), data may be corrupt"
637636
638637
639638# ===========================================================================
@@ -668,7 +667,7 @@ def test_plot_document_type_distribution(self, jess_haley_dataset):
668667 ax .barh (doc_types , doc_counts , color = "steelblue" )
669668 ax .set_xlabel ("Count" )
670669 ax .set_title ("Jess Haley Dataset: Document Type Distribution" )
671- for i , (t , c ) in enumerate (zip (doc_types , doc_counts )):
670+ for i , (_t , c ) in enumerate (zip (doc_types , doc_counts )):
672671 ax .text (c + 100 , i , str (c ), va = "center" , fontsize = 8 )
673672 plt .tight_layout ()
674673 plt .savefig (out / "doc_type_distribution.png" , dpi = 150 )
@@ -681,7 +680,6 @@ def test_plot_subject_experiment_types(self, jess_haley_dataset):
681680 import matplotlib
682681
683682 matplotlib .use ("Agg" )
684- import re
685683 from collections import Counter
686684
687685 import matplotlib .pyplot as plt
@@ -870,7 +868,7 @@ def test_render_video_frame_sequence(self, all_docs_raw):
870868 time_per_frame = time_scale [2 ] if len (time_scale ) > 2 else 1.0
871869
872870 fig , axes = plt .subplots (2 , 4 , figsize = (16 , 8 ))
873- for idx , (ax , fi ) in enumerate (zip (axes .flat , frame_indices )):
871+ for _idx , (ax , fi ) in enumerate (zip (axes .flat , frame_indices )):
874872 cap .set (cv2 .CAP_PROP_POS_FRAMES , fi )
875873 ret , frame = cap .read ()
876874 if ret :
0 commit comments