Skip to content

Instantly share code, notes, and snippets.

@PaoloLeonard
Created September 8, 2021 18:11
Show Gist options
  • Save PaoloLeonard/8657567ec535ef9814e6a97fadffa114 to your computer and use it in GitHub Desktop.
Save PaoloLeonard/8657567ec535ef9814e6a97fadffa114 to your computer and use it in GitHub Desktop.
Comparator implementation for the GE table expectation tutorial.
from enum import Enum, auto
from statistics import mean
class SupportedComparisonEnum(Enum):
"""Enum class with the currently supported comparison type."""
ABSOLUTE = auto()
MEAN = auto()
def __call__(self, *args, **kwargs):
if self.name == "ABSOLUTE":
return all(args[0] >= i * args[2] / 100 for i in args[1])
elif self.name == "MEAN":
return args[0] >= mean(args[1]) * args[2] / 100
else:
raise NotImplementedError("Comparison key is not supported.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment