compileml.compile

normalize_constraints

def normalize_constraints(constraints, n_features: int, feature_names=None) -> list[int] | None

from compileml.compile import normalize_constraints

Normalize to a list of -1/0/+1 per feature, or None if unconstrained.

Accepts a positional sequence, a dict keyed by feature index, or — when feature_names is given — a dict keyed by feature name.

Parameters#

NameTypeDefaultKind
constraints—requiredpositional
n_featuresintrequiredpositional
feature_names—Nonepositional

Returns#

list[int] | None

Raises#

  • ValueError

Read from the function body and the private helpers it calls, not inferred. A function that raises nothing has no section here.