one_hotΒΆ
- one_hot(poly: Poly, label: str = '') ConstraintΒΆ
- one_hot(array: PolyArray[_Dim], label: str = '', *, axis: None = None) Constraint
- one_hot(array: PolyArray[Dim], label: str = '', *, axis: int | tuple[int, ...]) Constraint | ConstraintList
Create a one-hot constraint.
Equivalent to
equal_to()with right-hand side1. For a single polynomialpoly, constrainpoly == 1. For an array withaxis=None(default), constrain the sum of all elements ofarrayto be equal to 1, returning a singleConstraint. For an array withaxisspecified, reduce along the given axis or axes. Return aConstraintif all axes are reduced, or aConstraintListwith one constraint per remaining slice otherwise.Overload 1.
- Args:
poly (amplify.Poly): Left-hand side polynomial.
label (str): Constraint label. Defaults to
''.
- Returns:
amplify.Constraint: Constraint object.
Overload 2.
- Args:
array (amplify.PolyArray[_Dim]): Array of polynomials to reduce.
label (str): Constraint label. Defaults to
''.axis (None): Axis or axes to reduce. Defaults to
None.
- Returns:
amplify.Constraint: Single constraint when all axes are reduced; otherwise one constraint per remaining slice.
Overload 3.
- Args:
array (amplify.PolyArray[Dim]): Array of polynomials to reduce.
label (str): Constraint label. Defaults to
''.axis (int | tuple[int, β¦]): Axis or axes to reduce.
- Returns:
amplify.Constraint | amplify.ConstraintList: Single constraint when all axes are reduced; otherwise one constraint per remaining slice.