Skip to content

Commit 8e23f93

Browse files
committed
Assorted fixes after rebase
1 parent a4d9feb commit 8e23f93

12 files changed

Lines changed: 65 additions & 59 deletions

File tree

MDANSE/Src/MDANSE/Framework/Jobs/SolventAccessibleSurface.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import collections
1919
import copy
20-
from collections.abc import Sequence
20+
from typing import TYPE_CHECKING
2121

2222
import numpy as np
2323
import numpy.typing as npt
@@ -39,7 +39,11 @@
3939
)
4040
from MDANSE.Mathematics.Geometry import generate_sphere_points
4141
from MDANSE.MolecularDynamics.Configuration import padded_coordinates
42-
from MDANSE.MolecularDynamics.Trajectory import Trajectory
42+
43+
if TYPE_CHECKING:
44+
from collections.abc import Sequence
45+
46+
from MDANSE.MolecularDynamics.Trajectory import Trajectory
4347

4448

4549
def compare_trees(
@@ -433,7 +437,8 @@ def initialize(self):
433437
)
434438

435439
atoms_in_molecule, loose_atoms = identify_loose_atoms(
436-
self.trajectory, self.grouping_level,
440+
self.trajectory,
441+
self.grouping_level,
437442
)
438443

439444
# Generate the sphere points that will be used to evaluate the sas per atom.

MDANSE/Src/MDANSE/Framework/Parsers/MDAnalysis.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
from more_itertools import first
2424

2525
from MDANSE.Framework.AtomMapping import AtomLabel
26+
from MDANSE.Framework.Parsers.Parser import Parser
2627
from MDANSE.Framework.Units import measure
2728
from MDANSE.MolecularDynamics.UnitCell import UnitCell
2829

29-
from .Parser import Parser
30-
3130
if TYPE_CHECKING:
3231
from collections.abc import Iterable, Sequence
3332

@@ -43,7 +42,6 @@ class MDAnalysisTopology(Parser):
4342

4443
def __init__(self, _desc, filename: Sequence[Path | str], deps: Depends):
4544
self.filename = tuple(Path(pth).expanduser() for pth in filename)
46-
print(_desc, filename, deps)
4745
self.trajectory = self.load(deps)
4846

4947
def load(self, deps):

MDANSE/Src/MDANSE/MLogging/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import logging
44
from enum import Enum
5+
from typing import Any
56

67

78
class LogLevels(Enum):
@@ -15,7 +16,7 @@ class LogLevels(Enum):
1516
NO_LOGS = NONE
1617

1718
@classmethod
18-
def _missing_(cls, value: str):
19+
def _missing_(cls, value: str) -> Any:
1920
if not isinstance(value, str):
2021
return
2122
value = "_".join(value.split()).upper()

MDANSE/Src/MDANSE/Trajectory/H5MDTrajectory.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
from __future__ import annotations
1717

1818
from collections import ChainMap
19-
from collections.abc import Mapping
2019
from pathlib import Path
20+
from typing import TYPE_CHECKING
2121

2222
import h5py
2323
import numpy as np
@@ -40,8 +40,10 @@
4040
NO_CELL,
4141
UnitCell,
4242
)
43+
from MDANSE.Trajectory.FileTrajBase import TrajectoryFile
4344

44-
from .FileTrajBase import TrajectoryFile
45+
if TYPE_CHECKING:
46+
from collections.abc import Mapping
4547

4648
SLICE_ALL = np.s_[:]
4749

MDANSE/Src/MDANSE/Trajectory/MdanseTrajectory.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
from __future__ import annotations
1717

1818
from collections import ChainMap, defaultdict
19-
from collections.abc import Iterable, Mapping
19+
from collections.abc import Iterable
2020
from functools import cached_property
2121
from pathlib import Path
22+
from typing import TYPE_CHECKING
2223

2324
import h5py
2425
import numpy as np
@@ -41,8 +42,10 @@
4142
NO_CELL,
4243
UnitCell,
4344
)
45+
from MDANSE.Trajectory.FileTrajBase import TrajectoryFile
4446

45-
from .FileTrajBase import TrajectoryFile
47+
if TYPE_CHECKING:
48+
from collections.abc import Mapping
4649

4750
SLICE_ALL = np.s_[:]
4851

@@ -268,25 +271,24 @@ def configuration(
268271

269272
def _load_unit_cells(self):
270273
"""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:
274275
self._unit_cells = None
275276
self.unit_cell_warning = NO_CELL
277+
return
278+
279+
self._unit_cells = [UnitCell(uc) for uc in self._h5_file["unit_cell"][:]]
276280

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
281284

282-
reference_array = self._unit_cells[0].direct
285+
reference_array = self._unit_cells[0].direct
283286

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
290292

291293
def time(self):
292294
"""Return the time array for all the frames."""

MDANSE_GUI/Src/MDANSE_GUI/InputWidgets/OutputFilesWidget.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,11 @@
2222
from qtpy.QtCore import Qt, Slot
2323
from qtpy.QtWidgets import QComboBox, QFileDialog, QLabel, QLineEdit, QPushButton
2424

25-
from MDANSE.Framework.Configurators.OutputFilesConfigurator import (
26-
OutputFilesConfigurator,
27-
)
2825
from MDANSE.IO.IOUtils import unused_standard_output_filename
29-
from MDANSE.MLogging import LOG
3026
from MDANSE.MLogging import LOG, LogLevels
27+
from MDANSE_GUI.InputWidgets.CheckableComboBox import CheckableComboBox
3128
from MDANSE_GUI.InputWidgets.WidgetBase import WidgetBase
3229

33-
from .CheckableComboBox import CheckableComboBox
34-
3530
if TYPE_CHECKING:
3631
from MDANSE.Framework.Parameters import OutputFile
3732

@@ -57,10 +52,10 @@ def __init__(self, *args, parameter: OutputFile, **kwargs):
5752
try:
5853
jobname = str(self._parent._job_instance.label).replace(" ", "")
5954
except Exception:
60-
jobname = "MDANSE_analysis"
55+
jobname = default_value
6156
LOG.error("It was not possible to get the job name from the parent")
6257

63-
self.default_path = self.default_path / "output"
58+
self.default_path /= "output"
6459
guess_name = unused_standard_output_filename(self.default_path, jobname)
6560
self.file_association = "Output file name (*)"
6661

MDANSE_GUI/Src/MDANSE_GUI/InputWidgets/OutputTrajectoryWidget.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,8 @@
2929
QSpinBox,
3030
)
3131

32-
from MDANSE.Framework.Configurators.OutputTrajectoryConfigurator import (
33-
OutputTrajectoryConfigurator,
34-
)
35-
from MDANSE.IO.IOUtils import unused_standard_output_filename
36-
from MDANSE.MLogging import LOG
3732
from MDANSE.Framework.Parameters import OutputTrajectory
33+
from MDANSE.IO.IOUtils import unused_standard_output_filename
3834
from MDANSE.MLogging import LOG, LogLevels
3935
from MDANSE_GUI.InputWidgets.WidgetBase import WidgetBase
4036

@@ -48,8 +44,6 @@ def __init__(self, *args, parameter: OutputTrajectory, **kwargs):
4844
*args, parameter=parameter, layout_type="QGridLayout", **kwargs
4945
)
5046

51-
default_value = self.parameter.descriptors["path"].default
52-
5347
try:
5448
self.default_path = Path(self._parent._default_path)
5549
except (KeyError, AttributeError) as err:
@@ -64,9 +58,11 @@ def __init__(self, *args, parameter: OutputTrajectory, **kwargs):
6458

6559
try:
6660
jobname = str(self._parent._job_instance.label).replace(" ", "")
61+
6762
except Exception:
68-
jobname = "converted_trajectory"
63+
jobname = self.parameter.descriptors["path"].default
6964
LOG.error("It was not possible to get the job name from the parent")
65+
7066
self.default_path = self.default_path / "trajectory"
7167
guess_name = unused_standard_output_filename(
7268
self.default_path, jobname, extra_text="_trajectory", extension=".mdt"

MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/PropertyWidget.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
from __future__ import annotations
22

33
from collections import ChainMap
4-
from collections.abc import Callable, Sequence
54
from enum import Enum, auto
65
from functools import partial
7-
from typing import Any
6+
from typing import TYPE_CHECKING, Any
87

98
from qtpy.QtCore import Qt, Slot
109
from qtpy.QtGui import QStandardItem, QStandardItemModel
1110
from qtpy.QtWidgets import QComboBox, QTableView, QVBoxLayout, QWidget
1211

1312
from MDANSE.Chemistry import ATOMS_DATABASE
14-
from MDANSE.MolecularDynamics.Trajectory import Trajectory
13+
14+
if TYPE_CHECKING:
15+
from collections.abc import Callable, Sequence
16+
17+
from MDANSE.MolecularDynamics.Trajectory import Trajectory
1518

1619

1720
class Const:

MDANSE_GUI/Src/MDANSE_GUI/Tabs/Models/JobTree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
from qtpy.QtGui import QStandardItem, QStandardItemModel
2424

2525
from MDANSE.Framework.Jobs.IJob import IJob
26-
from MDANSE.Framework.Parameters.Parameters import Configurable
2726

2827
if TYPE_CHECKING:
2928
from MDANSE.Core.SubclassFactory import SubclassFactory
3029
from MDANSE.Framework.Converters.Converter import Converter
30+
from MDANSE.Framework.Parameters.Parameters import Configurable
3131

3232

3333
class JobTree(QStandardItemModel):

MDANSE_GUI/Src/MDANSE_GUI/Tabs/Plotters/Heatmap.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@
1717

1818
import csv
1919
import math
20-
from collections.abc import Iterator
2120
from typing import TYPE_CHECKING, Any, TextIO
2221

2322
import numpy as np
24-
from matplotlib.axes import Axes
25-
from matplotlib.image import AxesImage
2623
from matplotlib.pyplot import colorbar as mpl_colorbar
2724
from scipy.interpolate import interp1d
2825

2926
from MDANSE.MLogging import LOG
3027
from MDANSE_GUI.Tabs.Plotters.Plotter import Plotter
3128

3229
if TYPE_CHECKING:
30+
from collections.abc import Iterator
31+
32+
from matplotlib.axes import Axes
3333
from matplotlib.figure import Figure
34+
from matplotlib.image import AxesImage
3435

3536
from MDANSE_GUI.Tabs.Models.PlottingContext import PlottingContext
3637

0 commit comments

Comments
 (0)