Created
September 8, 2021 18:11
-
-
Save PaoloLeonard/8657567ec535ef9814e6a97fadffa114 to your computer and use it in GitHub Desktop.
Comparator implementation for the GE table expectation tutorial.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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