openclean.util.threshold module

Helper functions that allow to specify different types of thresholds, e.g., lt, le, ge, gt. Instead of specifying thresholds as a single scalar value we specify them as callables. This makes it easier to run the same function with different thresholds like x > threshold, x >= threshold, etc..

class openclean.util.threshold.Threshold(op: Callable, threshold: float)

Bases: object

Generic thrshold class that evaluates a binary operator on a given value and a pre-defined threshold. The operator is called as op(value, threshold).

openclean.util.threshold.ge(threshold: float) openclean.util.threshold.Threshold

Get an instance for a greater or equal than threshold.

Parameters

threshold (float) – Threshold value.

Return type

openclean.util.threshold.Threshold

openclean.util.threshold.gt(threshold: float) openclean.util.threshold.Threshold

Get an instance for a greater than threshold.

Parameters

threshold (float) – Threshold value.

Return type

openclean.util.threshold.Threshold

openclean.util.threshold.le(threshold: float) openclean.util.threshold.Threshold

Get an instance for a lower or equal than threshold.

Parameters

threshold (float) – Threshold value.

Return type

openclean.util.threshold.Threshold

openclean.util.threshold.lt(threshold: float) openclean.util.threshold.Threshold

Get an instance for a lower than threshold.

Parameters

threshold (float) – Threshold value.

Return type

openclean.util.threshold.Threshold

openclean.util.threshold.to_threshold(threshold: Union[Callable, int, float]) Callable

Helper class to ensure that a given argument is a callable. If a scalar value is given the gt threshold will be returned by default if the value is lower than one. The ge threshold will be returned for scalar values that are one or greater.

Parameters
  • threshold (callable, int or float) – Expects a callable or a numeric value that will be wrapped in a comparison operator.

  • Retuns

  • ------

  • callable

Raises

ValueError