Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"Implements ArrayConstraint"
2from .single_equation import SingleEquationConstraint
5class ArrayConstraint(SingleEquationConstraint, list):
6 """A ConstraintSet for prettier array-constraint printing.
8 When created by NomialArray `left` and `right` are likely to be
9 be either NomialArrays or Varkeys of VectorVariables.
10 """
11 def __init__(self, constraints, left, oper, right):
12 self.constraints = constraints
13 list.__init__(self, constraints)
14 SingleEquationConstraint.__init__(self, left, oper, right)
16 def __iter__(self):
17 yield from self.constraints.flat
19 def lines_without(self, excluded):
20 "Returns lines for indentation in hierarchical printing."
21 return self.str_without(excluded).split("\n")
23 def __bool__(self):
24 "Allows the use of '=' NomialArrays as truth elements."
25 return False if self.oper != "=" else bool(self.constraints.all())