Skip to content

Commit d79d4a3

Browse files
committed
Apply ruff formatting fixes from merge
1 parent 0ce15ce commit d79d4a3

File tree

10 files changed

+724086
-80360
lines changed

10 files changed

+724086
-80360
lines changed

src/nomad_simulation_parsers/parsers/ams/file_parser.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,14 @@ def to_band_energy_ranges(val_in):
305305
Quantity(
306306
'points',
307307
rf'No\. +Sym\..+\s+\-+((?:\d+ +\d+ +{RE_FLOAT}.+\s+)+)',
308-
str_operation=lambda x: np.transpose(
309-
np.array(
310-
[v.split() for v in x.strip().splitlines()],
311-
np.float64,
312-
)
313-
)[2:5].T,
308+
str_operation=lambda x: (
309+
np.transpose(
310+
np.array(
311+
[v.split() for v in x.strip().splitlines()],
312+
np.float64,
313+
)
314+
)[2:5].T
315+
),
314316
),
315317
]
316318
),
@@ -823,11 +825,16 @@ def to_band_energy_ranges(val_in):
823825
'dipole_moment',
824826
rf'direction +dipole.+\s+\=+\s+((?:\w+ +{RE_FLOAT}.+\s+)+)',
825827
str_operation=lambda x: (
826-
[float(v.strip().split()[2]) for v in x.strip().splitlines()]
827-
* ureg.debye
828-
)
829-
.to('C * m')
830-
.magnitude,
828+
(
829+
[
830+
float(v.strip().split()[2])
831+
for v in x.strip().splitlines()
832+
]
833+
* ureg.debye
834+
)
835+
.to('C * m')
836+
.magnitude
837+
),
831838
),
832839
Quantity(
833840
'band_energy_ranges',

src/nomad_simulation_parsers/parsers/fhiaims/out_parser.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,17 @@ def init_quantities(self):
395395
'fermi_level', # older version
396396
rf'{RE_N} *\| Chemical potential \(Fermi level\) in '
397397
rf'(\w+)\s*:([\d\.\-\+Ee ]+)',
398-
str_operation=lambda x: float(x.split()[1])
399-
* units_mapping.get(x.split()[0]),
398+
str_operation=lambda x: (
399+
float(x.split()[1]) * units_mapping.get(x.split()[0])
400+
),
400401
),
401402
Quantity(
402403
'fermi_level', # newer version
403404
rf'{RE_N} *\| Chemical potential \(Fermi level\)\:'
404405
rf'\s*([\-\d\.]+)\s*(\w+)',
405-
str_operation=lambda x: float(x.split()[0])
406-
* units_mapping.get(x.split()[1], 1),
406+
str_operation=lambda x: (
407+
float(x.split()[0]) * units_mapping.get(x.split()[1], 1)
408+
),
407409
),
408410
Quantity(
409411
'time_calculation',

src/nomad_simulation_parsers/parsers/lammps/file_parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def __init__(self) -> None:
435435

436436
def init_quantities(self) -> None:
437437
def str_op(val: str) -> str | list[str]:
438-
val = val.split('#', 1)[0]
438+
val = val.split('#', 1)[0]
439439
val = re.sub(f'&{RE_N}+', ' ', val)
440440
val = val.split()
441441
val = val if len(val) > 1 else val[0]

src/nomad_simulation_parsers/parsers/quantumespresso/common.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ def str_to_arrays(val_in: str) -> tuple[list[str], list[float], list[str]]:
758758
},
759759
{
760760
'XC_functional_name': 'LDA_X',
761-
'exx_compute_weight': lambda exx: (1.0 - exx),
761+
'exx_compute_weight': lambda exx: 1.0 - exx,
762762
'XC_functional_weight': 0.75,
763763
},
764764
],
@@ -777,7 +777,7 @@ def str_to_arrays(val_in: str) -> tuple[list[str], list[float], list[str]]:
777777
},
778778
{
779779
'XC_functional_name': 'LDA_X',
780-
'exx_compute_weight': lambda exx: (1.0 - exx),
780+
'exx_compute_weight': lambda exx: 1.0 - exx,
781781
'XC_functional_weight': 0.8,
782782
},
783783
],
@@ -810,7 +810,7 @@ def str_to_arrays(val_in: str) -> tuple[list[str], list[float], list[str]]:
810810
},
811811
{
812812
'XC_functional_name': 'LDA_X',
813-
'exx_compute_weight': lambda exx: (1.0 - exx),
813+
'exx_compute_weight': lambda exx: 1.0 - exx,
814814
'XC_functional_weight': 0.782,
815815
},
816816
],
@@ -1145,14 +1145,14 @@ def str_to_arrays(val_in: str) -> tuple[list[str], list[float], list[str]]:
11451145
{
11461146
'XC_functional_name': 'GGA_X_PBE',
11471147
'XC_functional_weight': 0.75,
1148-
'exx_compute_weight': lambda exx: (1.0 - exx),
1148+
'exx_compute_weight': lambda exx: 1.0 - exx,
11491149
}
11501150
],
11511151
'xc_terms_remove': [
11521152
{
11531153
'XC_functional_name': 'LDA_X',
11541154
'XC_functional_weight': 0.75,
1155-
'exx_compute_weight': lambda exx: (1.0 - exx),
1155+
'exx_compute_weight': lambda exx: 1.0 - exx,
11561156
}
11571157
],
11581158
'xc_section_method': {
@@ -1173,7 +1173,7 @@ def str_to_arrays(val_in: str) -> tuple[list[str], list[float], list[str]]:
11731173
{
11741174
'XC_functional_name': 'LDA_X',
11751175
'XC_functional_weight': 0.8,
1176-
'exx_compute_weight': lambda exx: (1.0 - exx),
1176+
'exx_compute_weight': lambda exx: 1.0 - exx,
11771177
}
11781178
],
11791179
'xc_section_method': {
@@ -1759,7 +1759,7 @@ def str_to_arrays(val_in: str) -> tuple[list[str], list[float], list[str]]:
17591759
{
17601760
'XC_functional_name': 'LDA_X',
17611761
'XC_functional_weight': 0.75,
1762-
'exx_compute_weight': lambda exx: (1.0 - exx),
1762+
'exx_compute_weight': lambda exx: 1.0 - exx,
17631763
}
17641764
],
17651765
'xc_section_method': {
@@ -1780,7 +1780,7 @@ def str_to_arrays(val_in: str) -> tuple[list[str], list[float], list[str]]:
17801780
{
17811781
'XC_functional_name': 'LDA_X',
17821782
'XC_functional_weight': 0.50,
1783-
'exx_compute_weight': lambda exx: (1.0 - exx),
1783+
'exx_compute_weight': lambda exx: 1.0 - exx,
17841784
}
17851785
],
17861786
'xc_section_method': {

src/nomad_simulation_parsers/parsers/quantumespresso/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def get_energy_contributions(self, source: dict[str, Any]):
101101
]
102102

103103
def get_xc_functionals(self, source: str) -> list[dict[str, Any]]:
104-
numbers = source.split('(')[1].split(')')[0]
104+
numbers = source.split('(')[1].split(')', maxsplit=1)[0]
105105
nval = (4, 10)
106106
# handle different formatting
107107
if len(numbers) == nval[0]:

src/nomad_simulation_parsers/parsers/utils/mdanalysisparser.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ def parse(self, quantity_key: str = None, **kwargs):
170170
('names', lambda: ['CGX'] * self.universe.atoms.n_atoms),
171171
(
172172
'moltypes',
173-
lambda: self.get_fragtypes()
174-
if hasattr(self.universe.atoms, 'fragments')
175-
else None,
173+
lambda: (
174+
self.get_fragtypes()
175+
if hasattr(self.universe.atoms, 'fragments')
176+
else None
177+
),
176178
),
177179
('molnums', lambda: getattr(self.universe.atoms, 'fragindices', None)),
178180
('resnames', lambda: self._results['atoms_info'].get('resids')),

0 commit comments

Comments
 (0)