MCPcopy Create free account
hub / github.com/cvxpy/cvxpy / constants

Method constants

cvxpy/problems/problem.py:484–499  ·  view source on GitHub ↗

Accessor method for constants. Returns ------- list of :class:`~cvxpy.expressions.constants.constant.Constant` A list of the constants in the problem.

(self)

Source from the content-addressed store, hash-verified

482
483 @perf.compute_once
484 def constants(self) -> list[Constant]:
485 """Accessor method for constants.
486
487 Returns
488 -------
489 list of :class:`~cvxpy.expressions.constants.constant.Constant`
490 A list of the constants in the problem.
491 """
492 const_dict = {}
493 constants_ = self.objective.constants()
494 for constr in self.constraints:
495 constants_ += constr.constants()
496 # Note that numpy matrices are not hashable, so we use the built-in
497 # function "id"
498 const_dict = {id(constant): constant for constant in constants_}
499 return list(const_dict.values())
500
501 def atoms(self) -> list[Atom]:
502 """Accessor method for atoms.

Callers 2

test_constantsMethod · 0.95
__init__Method · 0.45

Calls 1

valuesMethod · 0.80

Tested by 1

test_constantsMethod · 0.76