Skip to content

Commit

Permalink
ruff linting fixes for magres parser
Browse files Browse the repository at this point in the history
  • Loading branch information
jkshenton authored and oerc0122 committed Feb 12, 2025
1 parent e0a838f commit aa020de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions castep_outputs/parsers/magres_file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from ..utilities.datatypes import AtomIndex, ThreeByThreeMatrix, ThreeVector
from ..utilities.filewrapper import Block
from ..utilities.utility import add_aliases, determine_type, to_type, atreg_to_index
from ..utilities.utility import add_aliases, atreg_to_index, determine_type, to_type

MAGRES_ALIASES = {
"ms": "magnetic_shielding",
Expand Down Expand Up @@ -70,6 +70,7 @@ class UnitsInfo(TypedDict):

class MagresInfo(TypedDict):
"""NMR Magnetic response information."""

#: Ion (atom) coordinates.
ions: dict[AtomIndex, ThreeVector]
calc_code: Literal["CASTEP"]
Expand Down Expand Up @@ -266,7 +267,7 @@ def _process_magres_old_block(block: Block) -> dict[str, str | ThreeByThreeMatri
for match in coords_matches:
index = atreg_to_index(match)
if index not in found_atoms:
data["atoms"]["coords"][index] = to_type(match['val'].split(), float)
data["atoms"]["coords"][index] = to_type(match["val"].split(), float)
found_atoms.add(index)

perturbing_index = None
Expand Down
4 changes: 2 additions & 2 deletions castep_outputs/utilities/castep_res.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,12 @@ def get_atom_parts(spec: str) -> dict[str, str]:
),
# Magnetic shielding tensor
"ms_tensor": re.compile(
rf"\s*(.*?) Shielding Tensor[\r\n]+{TENSOR_RE}"
rf"\s*(.*?) Shielding Tensor[\r\n]+{TENSOR_RE}",
),
# Spin-Spin coupling tensor
"isc_tensor": re.compile(
r"\s{0,}J-coupling (.*?)[\r\n]+"
rf"{TENSOR_RE}"
rf"{TENSOR_RE}",
),
# Electric field gradient tensor
"efg_tensor": re.compile(
Expand Down

0 comments on commit aa020de

Please sign in to comment.