Skip to content
Snippets Groups Projects

Translation cleanups

Merged David Schäfer requested to merge translation_cleanups into develop
All threads resolved!
1 file
+ 10
12
Compare changes
  • Side-by-side
  • Inline
@@ -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()
Loading