@@ -124,17 +124,20 @@ def test_check_timestamps_match_first_dimension_special_skip(tmp_path):
124124 image_height = 15
125125 num_channels = 3
126126 dtype = "uint8"
127- image_series = pynwb .image .ImageSeries (
127+
128+ # Use __new__ and in_construct_mode=True to bypass the check in pynwb for data.shape[0] == len(timestamps)
129+ image_series = pynwb .image .ImageSeries .__new__ (pynwb .image .ImageSeries , in_construct_mode = True )
130+ image_series .__init__ (
128131 name = "ImageSeries" ,
129- unit = "n.a. " ,
132+ unit = "N/A " ,
130133 data = np .empty (shape = (num_images , image_width , image_height , num_channels ), dtype = dtype ),
131134 timestamps = [],
132135 )
133136 nwbfile .add_acquisition (image_series )
134137 nwbfile .add_acquisition (
135138 pynwb .image .IndexSeries (
136139 name = "IndexSeries" ,
137- unit = "n.a. " ,
140+ unit = "N/A " ,
138141 data = [0 , 1 ],
139142 indexed_timeseries = image_series ,
140143 timestamps = [0.5 , 0.6 ],
@@ -152,14 +155,15 @@ def test_check_timestamps_match_first_dimension_special_skip(tmp_path):
152155
153156
154157def test_check_timestamps_match_first_dimension_bad ():
155- assert check_timestamps_match_first_dimension (
156- time_series = pynwb .TimeSeries (
157- name = "test_time_series" ,
158- unit = "test_units" ,
159- data = np .empty (shape = 4 ),
160- timestamps = [1.0 , 2.0 , 3.0 ],
161- )
162- ) == InspectorMessage (
158+ # Use __new__ and in_construct_mode=True to bypass the check in pynwb for data.shape[0] == len(timestamps)
159+ time_series = pynwb .TimeSeries .__new__ (pynwb .TimeSeries , in_construct_mode = True )
160+ time_series .__init__ (
161+ name = "test_time_series" ,
162+ unit = "test_units" ,
163+ data = np .empty (shape = 4 ),
164+ timestamps = [1.0 , 2.0 , 3.0 ],
165+ )
166+ assert check_timestamps_match_first_dimension (time_series = time_series ) == InspectorMessage (
163167 message = "The length of the first dimension of data (4) does not match the length of timestamps (3)." ,
164168 importance = Importance .CRITICAL ,
165169 check_function_name = "check_timestamps_match_first_dimension" ,
@@ -170,9 +174,15 @@ def test_check_timestamps_match_first_dimension_bad():
170174
171175
172176def test_check_timestamps_empty_data ():
173- assert check_timestamps_match_first_dimension (
174- time_series = pynwb .TimeSeries (name = "test_time_series" , unit = "test_units" , data = [], timestamps = [1.0 , 2.0 , 3.0 ])
175- ) == InspectorMessage (
177+ # Use __new__ and in_construct_mode=True to bypass the check in pynwb for data.shape[0] == len(timestamps)
178+ time_series = pynwb .TimeSeries .__new__ (pynwb .TimeSeries , in_construct_mode = True )
179+ time_series .__init__ (
180+ name = "test_time_series" ,
181+ unit = "test_units" ,
182+ data = [],
183+ timestamps = [1.0 , 2.0 , 3.0 ],
184+ )
185+ assert check_timestamps_match_first_dimension (time_series = time_series ) == InspectorMessage (
176186 message = "The length of the first dimension of data (0) does not match the length of timestamps (3)." ,
177187 importance = Importance .CRITICAL ,
178188 check_function_name = "check_timestamps_match_first_dimension" ,
@@ -183,9 +193,15 @@ def test_check_timestamps_empty_data():
183193
184194
185195def test_check_timestamps_empty_timestamps ():
186- assert check_timestamps_match_first_dimension (
187- time_series = pynwb .TimeSeries (name = "test_time_series" , unit = "test_units" , data = np .empty (shape = 4 ), timestamps = [])
188- ) == InspectorMessage (
196+ # Use __new__ and in_construct_mode=True to bypass the check in pynwb for data.shape[0] == len(timestamps)
197+ time_series = pynwb .TimeSeries .__new__ (pynwb .TimeSeries , in_construct_mode = True )
198+ time_series .__init__ (
199+ name = "test_time_series" ,
200+ unit = "test_units" ,
201+ data = np .empty (shape = 4 ),
202+ timestamps = [],
203+ )
204+ assert check_timestamps_match_first_dimension (time_series = time_series ) == InspectorMessage (
189205 message = "The length of the first dimension of data (4) does not match the length of timestamps (0)." ,
190206 importance = Importance .CRITICAL ,
191207 check_function_name = "check_timestamps_match_first_dimension" ,
0 commit comments