|
16 | 16 | from __future__ import annotations |
17 | 17 |
|
18 | 18 | from collections import ChainMap, defaultdict |
19 | | -from collections.abc import Iterable, Mapping |
| 19 | +from collections.abc import Iterable |
20 | 20 | from functools import cached_property |
21 | 21 | from pathlib import Path |
| 22 | +from typing import TYPE_CHECKING |
22 | 23 |
|
23 | 24 | import h5py |
24 | 25 | import numpy as np |
|
41 | 42 | NO_CELL, |
42 | 43 | UnitCell, |
43 | 44 | ) |
| 45 | +from MDANSE.Trajectory.FileTrajBase import TrajectoryFile |
44 | 46 |
|
45 | | -from .FileTrajBase import TrajectoryFile |
| 47 | +if TYPE_CHECKING: |
| 48 | + from collections.abc import Mapping |
46 | 49 |
|
47 | 50 | SLICE_ALL = np.s_[:] |
48 | 51 |
|
@@ -268,25 +271,24 @@ def configuration( |
268 | 271 |
|
269 | 272 | def _load_unit_cells(self): |
270 | 273 | """Load all the unit cells.""" |
271 | | - if "unit_cell" in self._h5_file: |
272 | | - self._unit_cells = [UnitCell(uc) for uc in self._h5_file["unit_cell"][:]] |
273 | | - else: |
| 274 | + if "unit_cell" not in self._h5_file: |
274 | 275 | self._unit_cells = None |
275 | 276 | self.unit_cell_warning = NO_CELL |
| 277 | + return |
| 278 | + |
| 279 | + self._unit_cells = [UnitCell(uc) for uc in self._h5_file["unit_cell"][:]] |
276 | 280 |
|
277 | | - if not self.unit_cell_warning: |
278 | | - if self._unit_cells[0].volume < CELL_SIZE_LIMIT: |
279 | | - self.unit_cell_warning = BAD_CELL |
280 | | - return |
| 281 | + if self._unit_cells[0].volume < CELL_SIZE_LIMIT: |
| 282 | + self.unit_cell_warning = BAD_CELL |
| 283 | + return |
281 | 284 |
|
282 | | - reference_array = self._unit_cells[0].direct |
| 285 | + reference_array = self._unit_cells[0].direct |
283 | 286 |
|
284 | | - if any( |
285 | | - not np.allclose(reference_array, uc.direct) |
286 | | - for uc in self._unit_cells[1:] |
287 | | - ): |
288 | | - self.unit_cell_warning = CHANGING_CELL |
289 | | - return |
| 287 | + if any( |
| 288 | + not np.allclose(reference_array, uc.direct) for uc in self._unit_cells[1:] |
| 289 | + ): |
| 290 | + self.unit_cell_warning = CHANGING_CELL |
| 291 | + return |
290 | 292 |
|
291 | 293 | def time(self): |
292 | 294 | """Return the time array for all the frames.""" |
|
0 commit comments