ConstraintListΒΆ

class ConstraintListΒΆ

List-like container of Constraint objects.

Methods

__init__

__init__

append

Append a constraint to the end of the list.

clear

Remove all constraints from the list.

copy

Return a shallow copy of the constraint list.

count

Return the number of occurrences of a constraint in the list.

extend

Extend the list with constraints from a sequence.

index

Return the index of the first occurrence of a constraint.

insert

Insert a constraint at a given position.

pop

Remove and return a constraint.

remove

Remove the first matching constraint from the list.

reverse

Reverse the constraint list in place.

class IteratorΒΆ
__init__(*args, **kwargs)ΒΆ
__iter__(self) → IteratorΒΆ
Return type:

Iterator

__next__(self) → ConstraintΒΆ
Return type:

Constraint

__add__(self, arg: ConstraintList, /) → ConstraintListΒΆ
__add__(self, arg: Constraint, /) → ConstraintList

Give a new constraint list that holds the constraints of both sides.

Overload 1.

Args:
  • arg (amplify.ConstraintList)

Returns:

amplify.ConstraintList:

Overload 2.

Args:
  • arg (amplify.Constraint)

Returns:

amplify.ConstraintList:

__copy__(self) → ConstraintListΒΆ

Return a shallow copy of the constraint list.

Return type:

ConstraintList

__deepcopy__(self, memo: object | None = None) → ConstraintListΒΆ

Give a copy of the list that holds a copy of every constraint.

Parameters:

memo (object | None) – Dictionary that copy.deepcopy() uses. Defaults to None.

Return type:

ConstraintList

__eq__(self, arg: object, /) → boolΒΆ

Tell whether the two lists hold the same constraints in the same order.

Parameters:

arg (object)

Return type:

bool

__getitem__(self, key: int) → ConstraintΒΆ

Give the constraint at the index. A negative index counts from the end.

Parameters:

key (int) – Index of the constraint.

Return type:

Constraint

Raises:

IndexError – The index is outside the list.

__iadd__(self, arg: ConstraintList, /) → ConstraintListΒΆ
__iadd__(self, arg: Constraint, /) → ConstraintList

Add the constraints of the right side to the constraint list.

Overload 1.

Args:
  • arg (amplify.ConstraintList)

Returns:

amplify.ConstraintList:

Overload 2.

Args:
  • arg (amplify.Constraint)

Returns:

amplify.ConstraintList:

__imul__(self, arg: float, /) → ConstraintListΒΆ

Multiply the weight of every constraint in the list by the coefficient.

Parameters:

arg (float)

Return type:

ConstraintList

__init__(self) → NoneΒΆ
__init__(self, arg: Sequence[Constraint]) → None
__init__(self, arg: Iterable[Constraint]) → None

__init__

Overload 2.

Args:
  • arg (collections.abc.Sequence[amplify.Constraint])

Overload 3.

Args:
  • arg (collections.abc.Iterable[amplify.Constraint])

__iter__(self) → IteratorΒΆ
Return type:

Iterator

__itruediv__(self, arg: float, /) → ConstraintListΒΆ

Divide the weight of every constraint in the list by the coefficient.

Parameters:

arg (float)

Return type:

ConstraintList

__len__(self) → intΒΆ

Number of constraints in the list.

Return type:

int

__mul__(self, arg: float, /) → ConstraintListΒΆ

Give a new list in which the weight of every constraint is multiplied by the coefficient.

Parameters:

arg (float)

Return type:

ConstraintList

__ne__(self, arg: object, /) → boolΒΆ

Tell whether the two lists differ. This is the negation of ==.

Parameters:

arg (object)

Return type:

bool

__radd__(self, arg: Constraint, /) → ConstraintListΒΆ
__radd__(self, arg: int, /) → ConstraintList

Give a new constraint list that holds the constraints of both sides.

Overload 1.

Args:
  • arg (amplify.Constraint)

Returns:

amplify.ConstraintList:

Overload 2.

Args:
  • arg (int)

Returns:

amplify.ConstraintList:

__repr__(self) → strΒΆ
Return type:

str

__rmul__(self, arg: float, /) → ConstraintListΒΆ

Give a new list in which the weight of every constraint is multiplied by the coefficient.

Parameters:

arg (float)

Return type:

ConstraintList

__setitem__(self, key: int, value: Constraint) → NoneΒΆ

Replace the constraint at the index. A negative index counts from the end.

Parameters:
  • key (int) – Index of the constraint.

  • value (Constraint) – Constraint that takes its place.

Raises:

IndexError – The index is outside the list.

__str__(self) → strΒΆ
Return type:

str

__truediv__(self, arg: float, /) → ConstraintListΒΆ

Give a new list in which the weight of every constraint is divided by the coefficient.

Parameters:

arg (float)

Return type:

ConstraintList

append(self, value: Constraint) → NoneΒΆ

Append a constraint to the end of the list.

Parameters:

value (Constraint)

clear(self) → NoneΒΆ

Remove all constraints from the list.

copy(self) → ConstraintListΒΆ

Return a shallow copy of the constraint list.

Return type:

ConstraintList

count(self, value: Constraint) → intΒΆ

Return the number of occurrences of a constraint in the list.

Parameters:

value (Constraint) – Constraint to count.

Returns:

Number of occurrences.

Return type:

int

extend(self, sequence: Sequence[Constraint]) → NoneΒΆ

Extend the list with constraints from a sequence.

Parameters:

sequence (Sequence[Constraint])

index(self, value: Constraint) → intΒΆ
index(self, value: Constraint, start: int) → int
index(self, value: Constraint, start: int, end: int) → int

Return the index of the first occurrence of a constraint.

Overload 1.

Args:
  • value (amplify.Constraint): Constraint to find.

Returns:

int: Index of the first match.

Overload 2.

Args:
  • value (amplify.Constraint): Constraint to find.

  • start (int): Start index.

Returns:

int: Index of the first match.

Overload 3.

Args:
  • value (amplify.Constraint): Constraint to find.

  • start (int): Start index.

  • end (int): End index.

Returns:

int: Index of the first match.

insert(self, index: int, value: Constraint) → NoneΒΆ

Insert a constraint at a given position.

Parameters:
pop(self, index: int | None = None) → ConstraintΒΆ

Remove and return a constraint.

Parameters:

index (int | None) – Index to pop. If omitted, pop the last item. Defaults to None.

Returns:

Popped constraint.

Return type:

Constraint

remove(self, value: Constraint) → NoneΒΆ

Remove the first matching constraint from the list.

Parameters:

value (Constraint)

reverse(self) → NoneΒΆ

Reverse the constraint list in place.