Skip to content

Commit

Permalink
Merge branch 'protos' into chi/documentation-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiCheng45 committed Feb 24, 2025
2 parents f0c7303 + 128b78b commit ffa8955
Show file tree
Hide file tree
Showing 96 changed files with 35 additions and 152 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
- uses: astral-sh/ruff-action@v3
with:
options: "--check --verbose"
src: "MDANSE/Src"
src: "./MDANSE/Src"
args: "format --check"

lint_check_ruff:
runs-on: ubuntu-latest
Expand All @@ -25,14 +25,14 @@ jobs:
src: "./MDANSE/Src"
args: "check"

lint-mdanse-gui:
lint_format_ruff_gui:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
- uses: astral-sh/ruff-action@v3
with:
options: "--check --verbose"
src: "MDANSE_GUI/Src"
src: "./MDANSE_GUI/Src"
args: "format --check"

lint_check_ruff_gui:
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion MDANSE/Src/MDANSE/Chemistry/ChemicalSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@


class ChemicalSystem:

def __init__(self, name: str = "", trajectory=None):
"""
Expand Down
1 change: 0 additions & 1 deletion MDANSE/Src/MDANSE/Framework/AtomMapping/atom_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


class AtomLabel:

def __init__(self, atm_label: str, **kwargs):
"""Creates an atom label object which is used for atom mapping
and atom type guessing.
Expand Down
3 changes: 0 additions & 3 deletions MDANSE/Src/MDANSE/Framework/AtomSelector/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ def get_idxs(self) -> set[int]:
idxs = set([])

for k, v in self.settings.items():

if isinstance(v, dict):
args = [{self._kwarg_keys[k]: i} for i in v.keys()]
switches = v.values()
Expand Down Expand Up @@ -234,7 +233,6 @@ def update_with_idxs(self, idxs: set[int]) -> None:

added = set([])
for k, v in self.settings.items():

if k == "index":
continue

Expand Down Expand Up @@ -338,7 +336,6 @@ def check_valid_setting(self, settings: dict[str, Union[bool, dict]]) -> bool:
setting_keys = self._default.keys()
dict_setting_keys = self._kwarg_keys.keys()
for k0, v0 in settings.items():

if k0 not in setting_keys:
return False

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class ASEFileConfigurator(FileWithAtomDataConfigurator):
"""

def parse(self):

try:
self._input = ASETrajectory(self["filename"])
except Exception:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ def configure(self, value: str):

self._nTransmutedAtoms = 0
for idx, element in value.items():

try:
idx = int(idx)
except ValueError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class LAMMPSConfigFileError(Error):


def parse_unit_cell(inputs):

unit_cell = np.zeros(9)

xlo, xhi, xy = inputs[0], inputs[1], inputs[2]
Expand All @@ -53,7 +52,6 @@ def parse_unit_cell(inputs):


class ConfigFileConfigurator(FileWithAtomDataConfigurator):

def parse(self):
self._filename = self["filename"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class CorrelationFramesConfigurator(FramesConfigurator):

def configure(self, value: tuple[int, int, int, int]):
"""Configure the correlation and set the number of correlation
frames to use.
Expand Down Expand Up @@ -50,8 +49,7 @@ def configure(self, value: tuple[int, int, int, int]):

if c_frames < 2:
self.error_status = (
"Number of frames used for the correlation "
"should be greater then zero."
"Number of frames used for the correlation should be greater then zero."
)
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class DistHistCutoffConfigurator(RangeConfigurator):

def __init__(self, name, **kwargs):
super().__init__(name, **kwargs)
self._max_value = kwargs.get("max_value", True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


class FileWithAtomDataConfigurator(InputFileConfigurator):

def configure(self, filepath: str) -> None:
"""
Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def configure(self, value):
):
indices.append(cluster)
elements.append([chemical_system.atom_list[x] for x in cluster])
names.append(f"{mol_name}_mol{mol_number+1}")
names.append(f"{mol_name}_mol{mol_number + 1}")
masses.append([mass_lookup[x] for x in cluster])
elif value == "group":
for group_name, group_indices in chemical_system._labels.items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


class MDAnalysisCoordinateFileConfigurator(MultiInputFileConfigurator):

_default = ("", "AUTO")

def __init__(self, name, wildcard="All files (*)", **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class MDAnalysisTimeStepConfigurator(FloatConfigurator):

_default = 0.0

def configure(self, value):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


class MDAnalysisTopologyFileConfigurator(FileWithAtomDataConfigurator):

_default = ("", "AUTO")

def configure(self, setting: str) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class MDTrajTimeStepConfigurator(FloatConfigurator):

_default = 0.0

def configure(self, value):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


class MDTrajTopologyFileConfigurator(FileWithAtomDataConfigurator):

def configure(self, value: Optional[str]):
"""
Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


class MDTrajTrajectoryFileConfigurator(MultiInputFileConfigurator):

def configure(self, value):
super().configure(value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


class MultiInputFileConfigurator(IConfigurator):

_default = ""

def __init__(self, name, wildcard="All files (*)", **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ def get_information(self):
"""

if self._valid:

info = f"{self['number']:d} values from {self['first']} to {self['last']}"

if self._includeLast:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def check_trajectory(filename: str):


class XDATCARFileConfigurator(FileWithAtomDataConfigurator):

def parse(self):
filename = self["filename"]
with open(filename, "r") as source:
Expand Down Expand Up @@ -107,7 +106,6 @@ def parse(self):
self._coordinates = np.empty((self["n_atoms"], 3))

def read_step(self, step):

if step > 0 and not self._has_fixed_cell:
unit_cell, atoms, atom_numbers, system_name = read_modern_header(
self["instance"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@


class XTDFileConfigurator(FileWithAtomDataConfigurator):

def __init__(self, name, **kwargs):
super().__init__(name, **kwargs)
self._atoms = None
Expand Down
2 changes: 1 addition & 1 deletion MDANSE/Src/MDANSE/Framework/Converters/CP2K.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def initialize(self):
self._cellFile = CellFile(self.configuration["cell_file"]["filename"])

if abs(self._cellFile["time_step"] - self._xyzFile["time_step"]) > 1.0e-09:
LOG.error(f'{self._cellFile["time_step"]}, {self._xyzFile["time_step"]}')
LOG.error(f"{self._cellFile['time_step']}, {self._xyzFile['time_step']}")
raise CP2KConverterError(
"Inconsistent time step between pos and cell files"
)
Expand Down
1 change: 0 additions & 1 deletion MDANSE/Src/MDANSE/Framework/Converters/DL_POLY.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class DL_POLYConverterError(Error):


class HistoryFile(dict):

def __init__(self, filename):
super().__init__()
self._dist_conversion = measure(1.0, "ang").toval("nm")
Expand Down
4 changes: 2 additions & 2 deletions MDANSE/Src/MDANSE/Framework/Converters/Forcite.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def parse_header(self):
rec = "!i"
recSize = struct.calcsize(rec)
(NTRJTI,) = struct.unpack(rec, trjfile.read(recSize))
rec = f"!{80*NTRJTI}s8x"
rec = f"!{80 * NTRJTI}s8x"
recSize = struct.calcsize(rec)
self["title"] = struct.unpack(rec, trjfile.read(recSize))
self["title"] = "\n".join([t.decode("utf-8") for t in self["title"]])
Expand All @@ -82,7 +82,7 @@ def parse_header(self):
recSize = struct.calcsize(rec)
NFLUSD = struct.unpack(rec, trjfile.read(recSize))[0]

rec = f"!{NFLUSD}i{NFLUSD}i{8*NFLUSD}s8x"
rec = f"!{NFLUSD}i{NFLUSD}i{8 * NFLUSD}s8x"
recSize = struct.calcsize(rec)
trjfile.read(recSize)

Expand Down
7 changes: 4 additions & 3 deletions MDANSE/Src/MDANSE/Framework/Converters/Gromacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ def initialize(self):
)

# The TRRTrajectoryFile object returns ints for these values, so turn them into bools
self._read_velocities, self._read_forces = bool(
self._read_velocities
), bool(self._read_forces)
self._read_velocities, self._read_forces = (
bool(self._read_velocities),
bool(self._read_forces),
)

if self._read_velocities:
data_to_be_written.append("velocities")
Expand Down
9 changes: 0 additions & 9 deletions MDANSE/Src/MDANSE/Framework/Converters/LAMMPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class LAMMPSTrajectoryFileError(Error):


class LAMMPSReader:

def __init__(self, *args, **kwargs):
self._units = kwargs.get("lammps_units", "real")
self._timestep = kwargs.get("timestep", 1.0)
Expand Down Expand Up @@ -116,7 +115,6 @@ def set_units(self, lammps_units):


class LAMMPScustom(LAMMPSReader):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

Expand All @@ -135,7 +133,6 @@ def open_file(self, filename: str):
self._start = 0

def parse_first_step(self, aliases, config):

self._itemsPosition = collections.OrderedDict()

comp = -1
Expand Down Expand Up @@ -387,7 +384,6 @@ def run_step(self, index):


class LAMMPSxyz(LAMMPSReader):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._full_cell = None
Expand All @@ -406,7 +402,6 @@ def open_file(self, filename: str):
self._file = open(filename, "r")

def read_any_step(self):

line = self._file.readline()
number_of_atoms = int(line)
line = self._file.readline()
Expand All @@ -416,7 +411,6 @@ def read_any_step(self):
atom_types = np.empty(number_of_atoms, dtype=int)

for at_num in range(number_of_atoms):

line = self._file.readline()

if not line:
Expand All @@ -433,7 +427,6 @@ def read_any_step(self):
return timestep, atom_types, positions

def parse_first_step(self, aliases, config):

_, atom_types, positions = self.read_any_step()

self._nAtoms = len(atom_types)
Expand Down Expand Up @@ -527,7 +520,6 @@ def run_step(self, index):


class LAMMPSh5md(LAMMPSReader):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._charges_fixed = None
Expand All @@ -544,7 +536,6 @@ def open_file(self, filename: str):
self._file = h5py.File(filename, "r")

def parse_first_step(self, aliases, config):

try:
atom_types = self._file["/particles/all/species/value"][0]
except KeyError:
Expand Down
4 changes: 2 additions & 2 deletions MDANSE/Src/MDANSE/Framework/Converters/MDAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def initialize(self):
*coord_files,
continuous=self.configuration["continuous"]["value"],
format=coord_format,
topology_format=self.configuration["topology_file"]["format"]
topology_format=self.configuration["topology_file"]["format"],
)
else:
coord_files = [(i, coord_format) for i in coord_files]
Expand Down Expand Up @@ -176,7 +176,7 @@ def initialize(self):
self.configuration["output_files"]["file"],
self._chemical_system,
self.numberOfSteps,
**kwargs
**kwargs,
)
super().initialize()

Expand Down
2 changes: 1 addition & 1 deletion MDANSE/Src/MDANSE/Framework/Converters/MDTraj.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def initialize(self):
self.configuration["output_files"]["file"],
self._chemical_system,
self.numberOfSteps,
**kwargs
**kwargs,
)
super().initialize()

Expand Down
3 changes: 1 addition & 2 deletions MDANSE/Src/MDANSE/Framework/Jobs/AreaPerMolecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ def initialize(self):
)
if self._nMolecules == 0:
raise AreaPerMoleculeError(
"No molecule matches "
f"{self.configuration['molecule_name']['value']!r} name."
f"No molecule matches {self.configuration['molecule_name']['value']!r} name."
)

self._outputData.add(
Expand Down
Loading

0 comments on commit ffa8955

Please sign in to comment.