@@ -157,8 +157,17 @@ def test_render_latency(self, max_latency: t.Optional[float] = None):
157157 axes [0 , 0 ].set_ylabel ("Timing Difference (s)" )
158158
159159 # Perform linear regression between GPU and photodiode timestamps
160- valid_mask = ~ np .isnan (aligned_gpu_photodiode ).any (axis = 1 )
160+ valid_mask = np .isfinite (aligned_gpu_photodiode ).all (axis = 1 )
161161 valid_data = aligned_gpu_photodiode [valid_mask ]
162+
163+ if len (valid_data ) < 2 or np .unique (valid_data [:, 0 ]).size < 2 :
164+ plt .close (fig )
165+ return self .fail_test (
166+ None ,
167+ f"Insufficient aligned GPU/photodiode pairs for regression ({ len (valid_data )} valid rows). "
168+ "The photodiode signal may not be aligned with the rendered frames." ,
169+ )
170+
162171 diff_diff = np .diff (valid_data [:, 0 ]) - np .diff (valid_data [:, 1 ])
163172
164173 axes [1 , 0 ].plot (diff_diff )
@@ -244,9 +253,6 @@ def make_qc_runner(dataset: contract.Dataset) -> qc.Runner:
244253 _runner .add_suite (qc .harp .HarpDeviceTestSuite (stream , commands ), stream .name )
245254
246255 # Also add the HarpOlfactometerExtension if it exists, as it may not be present in all sessions and is not a HarpDevice itself but contains them
247- dataset ["Behavior" ]["HarpOlfactometerExtension" ].load ()
248- dataset ["Behavior" ]["HarpCommands" ]["HarpOlfactometerExtension" ].load ()
249-
250256 for stream in dataset ["Behavior" ]["HarpOlfactometerExtension" ]:
251257 if isinstance (stream , HarpDevice ):
252258 commands = t .cast (HarpDevice , dataset ["Behavior" ]["HarpCommands" ]["HarpOlfactometerExtension" ][stream .name ])
0 commit comments