hrntsm/Tunny

View on GitHub
Optuna/Sampler/Python/constraints.py

Summary

Maintainability
A
0 mins
Test Coverage
import numpy as np

_CONSTRAINTS_KEY = "Constraint"


def constraints(trial):
    con = trial.user_attrs[_CONSTRAINTS_KEY]
    if np.any(np.isnan(con)) or not isinstance(con, (tuple, list)):
        con = [-1]
    return con