Skip to content
Snippets Groups Projects
Commit 08acb95b authored by Bert Palm's avatar Bert Palm 🎇
Browse files

more checking, docstring formatting

parent 15dbb823
No related branches found
No related tags found
No related merge requests found
Pipeline #177677 failed with stages
in 41 seconds
This commit is part of merge request !710. Comments created here will be created in the context of that merge request.
......@@ -12,6 +12,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
- added checks and unified error message for common inputs.
### Changed
- pin pandas to versions >= 2.0
- parameter `fill_na` of `SaQC.flagUniLOF` and `SaQC.assignUniLOF` is now of type
`bool` instead of one of `[None, "linear"]`
### Removed
- removed deprecated `DictOfSeries.to_df`
### Fixed
......
This diff is collapsed.
......@@ -405,7 +405,7 @@ class ScoresMixin:
algorithm: Literal["ball_tree", "kd_tree", "brute", "auto"] = "ball_tree",
p: int = 1,
density: Literal["auto"] | float | Callable = "auto",
fill_na: str = "linear",
fill_na: bool = True,
**kwargs,
) -> "SaQC":
"""
......@@ -449,7 +449,7 @@ class ScoresMixin:
(passed as Series).
fill_na :
Weather or not to fill NaN values in the data with a linear interpolation.
If True, NaNs in the data are filled with a linear interpolation.
Notes
-----
......@@ -465,8 +465,8 @@ class ScoresMixin:
"""
vals = self._data[field]
if fill_na is not None:
vals = vals.interpolate(fill_na)
if fill_na:
vals = vals.interpolate('linear')
if density == "auto":
density = vals.diff().abs().median()
......
......@@ -31,6 +31,10 @@ def isBoolLike(obj: Any, optional: bool = False) -> bool:
)
def isFloatLike(obj: Any) -> bool:
return isinstance(obj, (float, int))
def isIterable(obj: Any) -> bool:
if isinstance(obj, Iterable) or pd.api.types.is_iterator(obj):
return True
......
......@@ -26,6 +26,7 @@ from typing import (
Union,
get_args,
get_origin,
overload,
)
import numpy as np
......@@ -57,12 +58,18 @@ def assertScalar(name, value, optional=False):
return validateScalar(name=name, value=value, optional=optional)
def toSequence(value: T | Sequence[T]) -> List[T]:
if value is None: # special case
return [None]
if isinstance(value, (str, float, int)):
# fmt: off
@overload
def toSequence(value: T) -> List[T]:
...
@overload
def toSequence(value: Sequence[T]) -> List[T]:
...
def toSequence(value) -> List:
if value is None or isinstance(value, (str, float, int)):
return [value]
return list(value)
# fmt: on
def squeezeSequence(value: Sequence[T]) -> Union[T, Sequence[T]]:
......
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