Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ authors = [
classifiers = [
]
license = {file = "LICENSE.txt"}
requires-python = ">=3.10"
dependencies = [
"numpy",
"pandas",
Expand Down
3 changes: 1 addition & 2 deletions waveform_editor/base_waveform.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from abc import ABC, abstractmethod
from typing import Optional

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

@abstractmethod
def get_value(
self, time: Optional[np.ndarray] = None
self, time: np.ndarray | None = None
) -> tuple[np.ndarray, np.ndarray]:
raise NotImplementedError

Expand Down
3 changes: 1 addition & 2 deletions waveform_editor/derived_waveform.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ast
from typing import Optional

import numpy as np
from asteval import Interpreter
Expand Down Expand Up @@ -127,7 +126,7 @@ def _build_eval_context(self, time: np.ndarray) -> dict:
return eval_context

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

Expand Down
6 changes: 4 additions & 2 deletions waveform_editor/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ def _fill_waveforms(self, ids, waveforms):
# Here, phase/angle should be filled for all 4 beams.
# However, certain niche cases involving multiple slices for different waveforms
# might still not be handled correctly.
for waveform, (path, values) in zip(waveforms, values_per_waveform):
for waveform, (path, values) in zip(
waveforms, values_per_waveform, strict=True
):
logger.debug(f"Filling {waveform.name}...")
self._fill_nodes_recursively(ids, path, values)
self._increment_progress()
Expand Down Expand Up @@ -228,7 +230,7 @@ def _fill_nodes_recursively(self, node, path, values, path_index=0, fill=True):
if node.metadata.type.is_dynamic and part != path.parts[-1]:
if len(node) != len(values):
node.resize(len(values), keep=True)
for item, value in zip(node, values):
for item, value in zip(node, values, strict=True):
self._fill_nodes_recursively(item, path, value, next_index)
else:
self._fill_nodes_recursively(node, path, values, next_index)
Expand Down
3 changes: 1 addition & 2 deletions waveform_editor/gui/editor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import textwrap
from typing import Optional

import panel as pn
import param
Expand Down Expand Up @@ -53,7 +52,7 @@ def __init__(self, config):
# Initialize empty
self.set_waveform(None)

def set_waveform(self, waveform: Optional[str]) -> None:
def set_waveform(self, waveform: str | None) -> None:
"""Start editing a waveform.

Args:
Expand Down
2 changes: 1 addition & 1 deletion waveform_editor/gui/io/filebrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _update_files(
paths.insert(0, "..")
abbreviated.insert(0, "⬆ ..")

options = dict(zip(abbreviated, paths))
options = dict(zip(abbreviated, paths, strict=True))
self._selector.options = options
self._selector.value = [s for s in selected if s in paths]

Expand Down
4 changes: 2 additions & 2 deletions waveform_editor/gui/selector/selection_group.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, Union
from typing import TYPE_CHECKING

import panel as pn
import param
Expand All @@ -20,7 +20,7 @@ class SelectionGroup(Viewer):
def __init__(
self,
selector: "WaveformSelector",
group: Union[WaveformConfiguration, WaveformGroup],
group: WaveformConfiguration | WaveformGroup,
path: list[str],
) -> None:
name = getattr(group, "name", "")
Expand Down
2 changes: 1 addition & 1 deletion waveform_editor/pcssp_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ def _add_trajectories(self, segment):
ET.SubElement(trajectory, "EXIT_RULE", {"is": "Last"})
reference = ET.SubElement(trajectory, "REFERENCE")
values = waveform.get_value(self.times)[1]
for t, v in zip(self.times, values):
for t, v in zip(self.times, values, strict=True):
ET.SubElement(reference, "POINT", {"time": str(t), "value": str(v)})
3 changes: 1 addition & 2 deletions waveform_editor/tendencies/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from abc import abstractmethod
from typing import Optional

import numpy as np
import param
Expand Down Expand Up @@ -228,7 +227,7 @@ def _get_value_and_derivative(self, time):

@abstractmethod
def get_value(
self, time: Optional[np.ndarray] = None
self, time: np.ndarray | None = None
) -> tuple[np.ndarray, np.ndarray]:
"""Get the tendency values at the provided time array."""
raise NotImplementedError()
Expand Down
4 changes: 1 addition & 3 deletions waveform_editor/tendencies/constant.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

import numpy as np
import param
from param import depends
Expand All @@ -22,7 +20,7 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)

def get_value(
self, time: Optional[np.ndarray] = None
self, time: np.ndarray | None = None
) -> tuple[np.ndarray, np.ndarray]:
"""Get the tendency values at the provided time array. If no time array is
provided, a constant line containing the start and end points will be generated.
Expand Down
4 changes: 1 addition & 3 deletions waveform_editor/tendencies/linear.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

import numpy as np
import param
from param import depends
Expand Down Expand Up @@ -36,7 +34,7 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)

def get_value(
self, time: Optional[np.ndarray] = None
self, time: np.ndarray | None = None
) -> tuple[np.ndarray, np.ndarray]:
"""Get the tendency values at the provided time array. If no time array is
provided, a line containing the start and end points will be generated.
Expand Down
4 changes: 1 addition & 3 deletions waveform_editor/tendencies/periodic/sawtooth_wave.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

import numpy as np

from waveform_editor.tendencies.periodic.periodic_base import PeriodicBaseTendency
Expand All @@ -9,7 +7,7 @@ class SawtoothWaveTendency(PeriodicBaseTendency):
"""A tendency representing a sawtooth wave."""

def get_value(
self, time: Optional[np.ndarray] = None
self, time: np.ndarray | None = None
) -> tuple[np.ndarray, np.ndarray]:
"""Get the tendency values at the provided time array. If no time array is
provided, a time array will be created from the start to the end of the
Expand Down
4 changes: 1 addition & 3 deletions waveform_editor/tendencies/periodic/sine_wave.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

import numpy as np

from waveform_editor.tendencies.periodic.periodic_base import PeriodicBaseTendency
Expand All @@ -9,7 +7,7 @@ class SineWaveTendency(PeriodicBaseTendency):
"""A tendency representing a sine wave."""

def get_value(
self, time: Optional[np.ndarray] = None
self, time: np.ndarray | None = None
) -> tuple[np.ndarray, np.ndarray]:
"""Get the tendency values at the provided time array. If no time array is
provided, a linearly spaced time array will be generated from the start to the
Expand Down
4 changes: 1 addition & 3 deletions waveform_editor/tendencies/periodic/square_wave.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

import numpy as np

from waveform_editor.tendencies.periodic.periodic_base import PeriodicBaseTendency
Expand All @@ -9,7 +7,7 @@ class SquareWaveTendency(PeriodicBaseTendency):
"""A tendency representing a square wave."""

def get_value(
self, time: Optional[np.ndarray] = None
self, time: np.ndarray | None = None
) -> tuple[np.ndarray, np.ndarray]:
"""Get the tendency values at the provided time array. If no time array is
provided, a time array will be created from the start to the end of the
Expand Down
4 changes: 1 addition & 3 deletions waveform_editor/tendencies/periodic/triangle_wave.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

import numpy as np

from waveform_editor.tendencies.periodic.periodic_base import PeriodicBaseTendency
Expand All @@ -9,7 +7,7 @@ class TriangleWaveTendency(PeriodicBaseTendency):
"""A tendency representing a triangle wave."""

def get_value(
self, time: Optional[np.ndarray] = None
self, time: np.ndarray | None = None
) -> tuple[np.ndarray, np.ndarray]:
"""Get the tendency values at the provided time array. If no time array is
provided, a time array will be created from the start to the end of the
Expand Down
4 changes: 1 addition & 3 deletions waveform_editor/tendencies/piecewise.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

import numpy as np
import param

Expand Down Expand Up @@ -38,7 +36,7 @@ def __init__(self, user_time=None, user_value=None, **kwargs):
self.param.update(values_changed=True)

def get_value(
self, time: Optional[np.ndarray] = None
self, time: np.ndarray | None = None
) -> tuple[np.ndarray, np.ndarray]:
"""Get the tendency values at the provided time array. If a time array is
provided, the values will be linearly interpolated between the piecewise linear
Expand Down
4 changes: 1 addition & 3 deletions waveform_editor/tendencies/repeat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

import numpy as np
import param

Expand Down Expand Up @@ -84,7 +82,7 @@ def _set_period(self):
self.annotations.add(self.line_number, error_msg, is_warning=True)

def get_value(
self, time: Optional[np.ndarray] = None
self, time: np.ndarray | None = None
) -> tuple[np.ndarray, np.ndarray]:
"""Get the tendency values at the provided time array. If no time array is
provided, the individual tendencies are responsible for creating a time array,
Expand Down
4 changes: 1 addition & 3 deletions waveform_editor/tendencies/smooth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional

import numpy as np
import param
from param import depends
Expand Down Expand Up @@ -28,7 +26,7 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)

def get_value(
self, time: Optional[np.ndarray] = None
self, time: np.ndarray | None = None
) -> tuple[np.ndarray, np.ndarray]:
"""Get the tendency values at the provided time array. If no time array is
provided, a linearly spaced time array will be generated from the start to the
Expand Down
5 changes: 2 additions & 3 deletions waveform_editor/waveform.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import io
from typing import Optional

import numpy as np
from ruamel.yaml import YAML
Expand Down Expand Up @@ -51,7 +50,7 @@ def __init__(
self._process_waveform(waveform)

def get_value(
self, time: Optional[np.ndarray] = None
self, time: np.ndarray | None = None
) -> tuple[np.ndarray, np.ndarray]:
"""Get the tendency values at the provided time array. If no time array is
provided, the individual tendencies are responsible for creating a time array,
Expand All @@ -67,7 +66,7 @@ def get_value(
return np.array([]), np.array([])

if time is None:
time, values = zip(*(t.get_value() for t in self.tendencies))
time, values = zip(*(t.get_value() for t in self.tendencies), strict=True)
time = np.concatenate(time)
values = np.concatenate(values)
else:
Expand Down
Loading