Skip to content
Snippets Groups Projects
Commit a1e72a7a authored by David Schäfer's avatar David Schäfer
Browse files

lift the value range restriction from the FloatFlagger

parent de7be768
No related branches found
No related tags found
1 merge request!579Translation cleanups
......@@ -199,22 +199,20 @@ class FloatScheme(TranslationScheme):
DFILTER_DEFAULT: float = FILTER_ALL
def _check(self, val):
return ~((val < 0) | (val > 255) | (val != UNFLAGGED))
def __call__(self, flag: float | int) -> float:
if self._check(flag):
try:
return float(flag)
raise ValueError(
f"invalid flag, expected a numerical value in the interval [0, 255], got: {flag}"
)
except (TypeError, ValueError, OverflowError):
raise ValueError(f"invalid flag, expected a numerical value, got: {flag}")
def forward(self, flags: pd.DataFrame | DictOfSeries) -> Flags:
if self._check(flags):
return Flags(flags)
raise ValueError(
f"invalid flag, expected a collection of numerical value in the interval [0, 255], got: {flags}"
)
try:
return Flags(flags.astype(float))
except (TypeError, ValueError, OverflowError):
raise ValueError(
f"invalid flag(s), expected a collection of numerical values, got: {flags}"
)
def backward(self, flags: Flags, attrs: dict | None = None) -> DictOfSeries:
out = flags.toDios()
......
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