Skip to content

Commit

Permalink
🐛 fix: ditch lambdas as criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
YounesOMK committed Dec 21, 2023
1 parent 9a1f106 commit 7e83ff5
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions metricheq/evaluation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@
class Metric(BaseModel):
value: Optional[Union[int, float, bool]]

def satisfies(self, criterion) -> bool:
def satisfies(self, criterion: "Criterion") -> bool:
if self.value is None:
return False

if callable(criterion):
return criterion(self.value)
elif isinstance(criterion, Criterion):
return criterion.is_satisfied_by(self)
else:
raise ValueError("Criterion must be a callable or an instance of Criterion")
return criterion.is_satisfied_by(self)

def satisfies_all(self, criteria: List["Criterion"]) -> bool:
if self.value is None:
Expand Down

0 comments on commit 7e83ff5

Please sign in to comment.