Skip to content

Commit

Permalink
Fix pre-commit issues (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
yakutovicha authored Feb 4, 2025
1 parent 19f85d1 commit 27c8b53
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions nanoribbon/viewers/igor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def __init__(self):
super().__init__("Missing 'BEGIN' statement of data block")


class UnknownParameterError(KeyError):
def __init__(self, key):
super().__init__(f"Unknown parameter {key}")


class Axis:
"""Represents an axis of an IGOR wave"""

Expand Down Expand Up @@ -174,7 +179,7 @@ def __init__(self, data=None, axes=None, name="1d", **kwargs):
if key in self.parameters:
self.parameters[key] = value
else:
raise KeyError(f"Unknown parameter {key}")
raise UnknownParameterError(key)

if axes is None:
p = self.parameters
Expand Down Expand Up @@ -225,7 +230,7 @@ def __init__(self, data=None, axes=None, name=None, **kwargs):
if key in self.parameters:
self.parameters[key] = value
else:
raise KeyError(f"Unknown parameter {key}")
raise UnknownParameterError(key)

if axes is None:
p = self.parameters
Expand Down
11 changes: 8 additions & 3 deletions nanoribbon/viewers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ def __init__(self, label, state):
super().__init__(f"Calculation {label} in state {state}.")


class WorkchainExceptedError(RuntimeError):
def __init__(self, workchain):
super().__init__(
f"Workchain {workchain.pk} excepted ({workchain.exit_status})."
)


class NanoribbonSearchWidget(ipw.VBox):
STYLE = {"description_width": "120px"}
LAYOUT = ipw.Layout(width="80%")
Expand Down Expand Up @@ -186,9 +193,7 @@ def get_calc_by_label(workcalc, label):
return calc

if workcalc.exit_status or workcalc.is_excepted:
raise RuntimeError(
f"Workchain {workcalc.pk} in state {workcalc.exit_status}."
)
raise WorkchainExceptedError(workcalc)
# Formula and description.
structure = workcalc.inputs.structure
ase_struct = structure.get_ase()
Expand Down

0 comments on commit 27c8b53

Please sign in to comment.