|
73 | 73 | _event_channel_dtype, |
74 | 74 | ) |
75 | 75 |
|
| 76 | +from neo.core import NeoReadWriteError |
| 77 | + |
76 | 78 |
|
77 | 79 | class BlackrockRawIO(BaseRawIO): |
78 | 80 | """ |
@@ -330,15 +332,15 @@ def _parse_header(self): |
330 | 332 | else: |
331 | 333 | raise (ValueError("nsx_to_load is wrong")) |
332 | 334 |
|
333 | | - assert all( |
334 | | - nsx_nb in self._avail_nsx for nsx_nb in self.nsx_to_load |
335 | | - ), "nsx_to_load do not match available nsx list" |
| 335 | + if not all(nsx_nb in self._avail_nsx for nsx_nb in self.nsx_to_load): |
| 336 | + raise FileNotFoundError(f"nsx_to_load does not match available nsx list") |
336 | 337 |
|
337 | 338 | # check that all files come from the same specification |
338 | 339 | all_spec = [self.__nsx_spec[nsx_nb] for nsx_nb in self.nsx_to_load] |
339 | 340 | if self._avail_files["nev"]: |
340 | 341 | all_spec.append(self.__nev_spec) |
341 | | - assert all(all_spec[0] == spec for spec in all_spec), "Files don't have the same internal version" |
| 342 | + if not all(all_spec[0] == spec for spec in all_spec): |
| 343 | + raise NeoReadWriteError("Files don't have the same internal version") |
342 | 344 |
|
343 | 345 | if len(self.nsx_to_load) > 0 and self.__nsx_spec[self.nsx_to_load[0]] == "2.1" and not self._avail_files["nev"]: |
344 | 346 | pass |
@@ -401,9 +403,8 @@ def _parse_header(self): |
401 | 403 |
|
402 | 404 | # check nb segment per nsx |
403 | 405 | nb_segments_for_nsx = [len(self.nsx_datas[nsx_nb]) for nsx_nb in self.nsx_to_load] |
404 | | - assert all( |
405 | | - nb == nb_segments_for_nsx[0] for nb in nb_segments_for_nsx |
406 | | - ), "Segment nb not consistent across nsX files" |
| 406 | + if not all(nb == nb_segments_for_nsx[0] for nb in nb_segments_for_nsx): |
| 407 | + raise NeoReadWriteError("Segment nb not consistent across nsX files") |
407 | 408 | self._nb_segment = nb_segments_for_nsx[0] |
408 | 409 |
|
409 | 410 | self.__delete_empty_segments() |
@@ -1263,11 +1264,12 @@ def __match_nsx_and_nev_segment_ids(self, nsx_nb): |
1263 | 1264 | ev_ids[mask_after_seg] += 1 |
1264 | 1265 |
|
1265 | 1266 | # consistency check: same number of segments for nsx and nev data |
1266 | | - assert nb_possible_nev_segments == len(nonempty_nsx_segments), ( |
1267 | | - f"Inconsistent ns{nsx_nb} and nev file. {nb_possible_nev_segments} " |
1268 | | - f"segments present in .nev file, but {len(nonempty_nsx_segments)} in " |
1269 | | - "ns{nsx_nb} file." |
1270 | | - ) |
| 1267 | + if nb_possible_nev_segments != len(nonempty_nsx_segments): |
| 1268 | + raise NeoReadWriteError( |
| 1269 | + f"Inconsistent ns{nsx_nb} and nev file. {nb_possible_nev_segments} " |
| 1270 | + f"segments present in .nev file, but {len(nonempty_nsx_segments)} in " |
| 1271 | + f"ns{nsx_nb} file." |
| 1272 | + ) |
1271 | 1273 |
|
1272 | 1274 | new_nev_segment_id_mapping = dict(zip(range(nb_possible_nev_segments), sorted(list(nonempty_nsx_segments)))) |
1273 | 1275 |
|
|
0 commit comments