Skip to content
Snippets Groups Projects
Commit d7ee03d8 authored by Wolfgang Kastaun's avatar Wolfgang Kastaun
Browse files

fix faulty type annotations and improve others

parent 25815707
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ Use make_dynamic_shift_lagrange_dask to create a Lagrange interpolator for dask ...@@ -5,7 +5,7 @@ Use make_dynamic_shift_lagrange_dask to create a Lagrange interpolator for dask
from __future__ import annotations from __future__ import annotations
from typing import Callable from typing import Callable, Final
import dask import dask
import dask.array as da import dask.array as da
...@@ -18,11 +18,7 @@ from lisainstrument.dynamic_delay_numpy import ( ...@@ -18,11 +18,7 @@ from lisainstrument.dynamic_delay_numpy import (
RegularInterpMethod, RegularInterpMethod,
) )
from lisainstrument.fir_filters_dask import DaskArray1D, make_dask_array_1d from lisainstrument.fir_filters_dask import DaskArray1D, make_dask_array_1d
from lisainstrument.fir_filters_numpy import ( from lisainstrument.fir_filters_numpy import NumpyArray1D, make_numpy_array_1d
EdgeHandling,
NumpyArray1D,
make_numpy_array_1d,
)
class DynamicShiftDask: class DynamicShiftDask:
...@@ -48,8 +44,8 @@ class DynamicShiftDask: ...@@ -48,8 +44,8 @@ class DynamicShiftDask:
self, self,
min_delay: float, min_delay: float,
max_delay: float, max_delay: float,
left_bound: EdgeHandling, left_bound: DynShiftBC,
right_bound: EdgeHandling, right_bound: DynShiftBC,
interp: RegularInterpMethod, interp: RegularInterpMethod,
): ):
"""Set up interpolation parameters """Set up interpolation parameters
...@@ -66,12 +62,12 @@ class DynamicShiftDask: ...@@ -66,12 +62,12 @@ class DynamicShiftDask:
msg = f"dynamic_shift_dask: invalid delay range {min_delay=}, {max_delay=}" msg = f"dynamic_shift_dask: invalid delay range {min_delay=}, {max_delay=}"
raise ValueError(msg) raise ValueError(msg)
self._min_delay = int(np.floor(min_delay)) self._min_delay: Final[int] = int(np.floor(min_delay))
self._max_delay = int(np.ceil(max_delay)) self._max_delay: Final[int] = int(np.ceil(max_delay))
self._left_bound = left_bound self._left_bound: Final = left_bound
self._right_bound = right_bound self._right_bound: Final = right_bound
self._interp_np = interp self._interp_np: Final = interp
def _op_interp( def _op_interp(
self, samp: np.ndarray, loc: np.ndarray, ofs: np.ndarray self, samp: np.ndarray, loc: np.ndarray, ofs: np.ndarray
...@@ -171,8 +167,8 @@ class DynamicShiftDask: ...@@ -171,8 +167,8 @@ class DynamicShiftDask:
def make_dynamic_shift_linear_dask( def make_dynamic_shift_linear_dask(
min_delay: float, min_delay: float,
max_delay: float, max_delay: float,
left_bound: EdgeHandling, left_bound: DynShiftBC,
right_bound: EdgeHandling, right_bound: DynShiftBC,
) -> DynamicShiftDask: ) -> DynamicShiftDask:
"""Set up DynamicShiftDask instance with linear interpolation method. """Set up DynamicShiftDask instance with linear interpolation method.
...@@ -193,8 +189,8 @@ def make_dynamic_shift_lagrange_dask( ...@@ -193,8 +189,8 @@ def make_dynamic_shift_lagrange_dask(
length: int, length: int,
min_delay: float, min_delay: float,
max_delay: float, max_delay: float,
left_bound: EdgeHandling, left_bound: DynShiftBC,
right_bound: EdgeHandling, right_bound: DynShiftBC,
) -> DynamicShiftDask: ) -> DynamicShiftDask:
"""Set up DynamicShiftDask instance with Lagrange interpolation method. """Set up DynamicShiftDask instance with Lagrange interpolation method.
......
...@@ -8,7 +8,7 @@ from __future__ import annotations ...@@ -8,7 +8,7 @@ from __future__ import annotations
import functools import functools
import operator import operator
from enum import Enum from enum import Enum
from typing import Callable, Protocol from typing import Final, Protocol
import numpy as np import numpy as np
from numpy.polynomial import Polynomial from numpy.polynomial import Polynomial
...@@ -181,9 +181,11 @@ class RegularInterpLagrange(RegularInterpMethod): ...@@ -181,9 +181,11 @@ class RegularInterpLagrange(RegularInterpMethod):
raise ValueError(msg) raise ValueError(msg)
offset = -((length - 1) // 2) offset = -((length - 1) // 2)
self._length: int = length self._length: Final[int] = length
self._offset: int = offset self._offset: Final[int] = offset
self._fir_filt = self._make_firs(length, offset) self._fir_filt: Final[list[FilterFirNumpyType]] = self._make_firs(
length, offset
)
@property @property
def margin_left(self) -> int: def margin_left(self) -> int:
...@@ -328,8 +330,8 @@ class DynamicShiftNumpy: ...@@ -328,8 +330,8 @@ class DynamicShiftNumpy:
self, self,
min_delay: float, min_delay: float,
max_delay: float, max_delay: float,
left_bound: EdgeHandling, left_bound: DynShiftBC,
right_bound: EdgeHandling, right_bound: DynShiftBC,
interp: RegularInterpMethod, interp: RegularInterpMethod,
): ):
...@@ -337,12 +339,12 @@ class DynamicShiftNumpy: ...@@ -337,12 +339,12 @@ class DynamicShiftNumpy:
msg = f"dynamic_shift_dask: invalid delay range {min_delay=}, {max_delay=}" msg = f"dynamic_shift_dask: invalid delay range {min_delay=}, {max_delay=}"
raise ValueError(msg) raise ValueError(msg)
self._min_delay = int(np.floor(min_delay)) self._min_delay: Final[int] = int(np.floor(min_delay))
self._max_delay = int(np.ceil(max_delay)) self._max_delay: Final[int] = int(np.ceil(max_delay))
self._left_bound = left_bound self._left_bound: Final = left_bound
self._right_bound = right_bound self._right_bound: Final = right_bound
self._interp_np = interp self._interp_np: Final = interp
def _op_interp( def _op_interp(
self, samp: np.ndarray, loc: np.ndarray, ofs: np.ndarray self, samp: np.ndarray, loc: np.ndarray, ofs: np.ndarray
...@@ -436,8 +438,8 @@ def make_dynamic_shift_lagrange_numpy( ...@@ -436,8 +438,8 @@ def make_dynamic_shift_lagrange_numpy(
length: int, length: int,
min_delay: float, min_delay: float,
max_delay: float, max_delay: float,
left_bound: EdgeHandling, left_bound: DynShiftBC,
right_bound: EdgeHandling, right_bound: DynShiftBC,
) -> DynamicShiftNumpy: ) -> DynamicShiftNumpy:
"""Set up DynamicShiftNumpy instance with Lagrange interpolation method. """Set up DynamicShiftNumpy instance with Lagrange interpolation method.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment