Skip to content

Commit 4fc1475

Browse files
committed
ruff linting
1 parent 292a2a4 commit 4fc1475

File tree

18 files changed

+23
-44
lines changed

18 files changed

+23
-44
lines changed

waveform_editor/base_waveform.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from abc import ABC, abstractmethod
2-
from typing import Optional
32

43
import imas
54
import numpy as np
@@ -21,7 +20,7 @@ def __init__(self, yaml_str, name, dd_version):
2120

2221
@abstractmethod
2322
def get_value(
24-
self, time: Optional[np.ndarray] = None
23+
self, time: np.ndarray | None = None
2524
) -> tuple[np.ndarray, np.ndarray]:
2625
raise NotImplementedError
2726

waveform_editor/derived_waveform.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import ast
2-
from typing import Optional
32

43
import numpy as np
54
from asteval import Interpreter
@@ -127,7 +126,7 @@ def _build_eval_context(self, time: np.ndarray) -> dict:
127126
return eval_context
128127

129128
def get_value(
130-
self, time: Optional[np.ndarray] = None
129+
self, time: np.ndarray | None = None
131130
) -> tuple[np.ndarray, np.ndarray]:
132131
"""Evaluate the derived waveform expression at specified times.
133132

waveform_editor/exporter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ def _fill_waveforms(self, ids, waveforms):
193193
# Here, phase/angle should be filled for all 4 beams.
194194
# However, certain niche cases involving multiple slices for different waveforms
195195
# might still not be handled correctly.
196-
for waveform, (path, values) in zip(waveforms, values_per_waveform):
196+
for waveform, (path, values) in zip(
197+
waveforms, values_per_waveform, strict=False
198+
):
197199
logger.debug(f"Filling {waveform.name}...")
198200
self._fill_nodes_recursively(ids, path, values)
199201
self._increment_progress()
@@ -228,7 +230,7 @@ def _fill_nodes_recursively(self, node, path, values, path_index=0, fill=True):
228230
if node.metadata.type.is_dynamic and part != path.parts[-1]:
229231
if len(node) != len(values):
230232
node.resize(len(values), keep=True)
231-
for item, value in zip(node, values):
233+
for item, value in zip(node, values, strict=False):
232234
self._fill_nodes_recursively(item, path, value, next_index)
233235
else:
234236
self._fill_nodes_recursively(node, path, values, next_index)

waveform_editor/gui/editor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import textwrap
2-
from typing import Optional
32

43
import panel as pn
54
import param
@@ -53,7 +52,7 @@ def __init__(self, config):
5352
# Initialize empty
5453
self.set_waveform(None)
5554

56-
def set_waveform(self, waveform: Optional[str]) -> None:
55+
def set_waveform(self, waveform: str | None) -> None:
5756
"""Start editing a waveform.
5857
5958
Args:

waveform_editor/gui/io/filebrowser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def _update_files(
147147
paths.insert(0, "..")
148148
abbreviated.insert(0, "⬆ ..")
149149

150-
options = dict(zip(abbreviated, paths))
150+
options = dict(zip(abbreviated, paths, strict=False))
151151
self._selector.options = options
152152
self._selector.value = [s for s in selected if s in paths]
153153

waveform_editor/gui/selector/selection_group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TYPE_CHECKING, Union
1+
from typing import TYPE_CHECKING
22

33
import panel as pn
44
import param
@@ -20,7 +20,7 @@ class SelectionGroup(Viewer):
2020
def __init__(
2121
self,
2222
selector: "WaveformSelector",
23-
group: Union[WaveformConfiguration, WaveformGroup],
23+
group: WaveformConfiguration | WaveformGroup,
2424
path: list[str],
2525
) -> None:
2626
name = getattr(group, "name", "")

waveform_editor/pcssp_exporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,5 @@ def _add_trajectories(self, segment):
7979
ET.SubElement(trajectory, "EXIT_RULE", {"is": "Last"})
8080
reference = ET.SubElement(trajectory, "REFERENCE")
8181
values = waveform.get_value(self.times)[1]
82-
for t, v in zip(self.times, values):
82+
for t, v in zip(self.times, values, strict=False):
8383
ET.SubElement(reference, "POINT", {"time": str(t), "value": str(v)})

waveform_editor/tendencies/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from abc import abstractmethod
2-
from typing import Optional
32

43
import numpy as np
54
import param
@@ -228,7 +227,7 @@ def _get_value_and_derivative(self, time):
228227

229228
@abstractmethod
230229
def get_value(
231-
self, time: Optional[np.ndarray] = None
230+
self, time: np.ndarray | None = None
232231
) -> tuple[np.ndarray, np.ndarray]:
233232
"""Get the tendency values at the provided time array."""
234233
raise NotImplementedError()

waveform_editor/tendencies/constant.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Optional
2-
31
import numpy as np
42
import param
53
from param import depends
@@ -22,7 +20,7 @@ def __init__(self, **kwargs):
2220
super().__init__(**kwargs)
2321

2422
def get_value(
25-
self, time: Optional[np.ndarray] = None
23+
self, time: np.ndarray | None = None
2624
) -> tuple[np.ndarray, np.ndarray]:
2725
"""Get the tendency values at the provided time array. If no time array is
2826
provided, a constant line containing the start and end points will be generated.

waveform_editor/tendencies/linear.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Optional
2-
31
import numpy as np
42
import param
53
from param import depends
@@ -36,7 +34,7 @@ def __init__(self, **kwargs):
3634
super().__init__(**kwargs)
3735

3836
def get_value(
39-
self, time: Optional[np.ndarray] = None
37+
self, time: np.ndarray | None = None
4038
) -> tuple[np.ndarray, np.ndarray]:
4139
"""Get the tendency values at the provided time array. If no time array is
4240
provided, a line containing the start and end points will be generated.

0 commit comments

Comments
 (0)