Skip to content

Metric specification

Metric Specification.

This module implements the Specification Pattern to define evaluation rules and criteria. The rules can be combined using logical operators (AND, OR, NOT) to create complex evaluation conditions.

Authors

Surya Mahadi (made.r.s.mahadi@gdplabs.id)

References

[1] https://github.com/u8slvn/sutoppu

MetricSpec(metric, comparator, threshold)

Bases: Specification

Atomic specification such as completeness >= 3.

Attributes:

Name Type Description
metric str

The metric to evaluate.

threshold int

The threshold for the metric.

Initialize the MetricSpec.

Parameters:

Name Type Description Default
metric str

The metric to evaluate.

required
comparator str

The comparator to use.

required
threshold int

The threshold for the metric.

required

__repr__()

Get the representation of the MetricSpec.

Returns:

Name Type Description
str str

The representation of the MetricSpec.

is_satisfied_by(candidate)

Check if the candidate satisfies the metric specification.

Parameters:

Name Type Description Default
candidate Mapping[str, int]

The candidate to check.

required

Returns:

Name Type Description
bool bool

True if the candidate satisfies the metric specification, False otherwise.