metric#

class Metric(goal='minimize')[source]#

Bases: StrDictMixIn, object

Parent Metric class: inherit all other metrics from this class.

Initialize the metric.

calc(results, best_known_energies, **kwargs)[source]#

Placeholder: calculate the metric value.

static fill_in_value(value: float, failure_fill_in_value: float) float[source]#

If value is nan/inf, replace it with failure_fill_in_value.

Parameters:
  • value (float) – The value to be checked.

  • failure_fill_in_value (float) – The replacement value on failure.

Returns:

Filled in value.

Return type:

float

static num_solutions_per_result(results: list[list]) int[source]#

Return the number of solutions per result.

All results must have the same number of solutions.

Parameters:

results (list[list]) – List of result list.

Raises:

ValueError – Raises an error if number of result for each problem is different.

Returns:

Return the only number of results for every result in the given list.

Return type:

int

static overall_mean(results, key)[source]#

Calculate the overall average of the quantity that corresponds to key.

static overall_variance(results, key)[source]#

Calculate the variance of the quantity that corresponds to key.