Skip to content

Commit

Permalink
Apply ruff formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ndaelman committed Jan 17, 2025
1 parent 6dec427 commit efe1486
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions electronicparsers/quantumespresso/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2040,7 +2040,11 @@ def str_to_sticks(val_in):
rf'(number of electrons\s*=[^\n]*)',
sub_parser=TextParser(
quantities=[
Quantity('total', rf'number of electrons\s*=\s*({re_float})', dtype=float),
Quantity(
'total',
rf'number of electrons\s*=\s*({re_float})',
dtype=float,
),
Quantity('up', rf'up:\s*({re_float})', dtype=float),
Quantity('down', rf'down:\s*({re_float})', dtype=float),
],
Expand Down Expand Up @@ -2803,7 +2807,9 @@ def get_n_electrons_safe(self) -> float:
if total_n_electrons := n_electrons.get('total'):
return total_n_electrons
elif (up := n_electrons.get('up')) and (down := n_electrons.get('down')):
self.logger.warning('Number of electrons not found. Using spin up + down.')
self.logger.warning(
'Number of electrons not found. Using spin up + down.'
)
return up + down

def parse_scc(self, run, calculation):
Expand Down Expand Up @@ -2925,7 +2931,11 @@ def parse_scc(self, run, calculation):
if np.array(fermi_energy).dtype == float:
sec_energy.fermi = fermi_energy * ureg.eV

if homo is None and fermi_energy is None and len(self.get_n_electrons_safe()) == 0:
if (
homo is None
and fermi_energy is None
and len(self.get_n_electrons_safe()) == 0
):
self.logger.error('Reference energy is not defined')

for key in ['magnetization_total', 'magnetization_absolute']:
Expand Down

0 comments on commit efe1486

Please sign in to comment.