def cast_to_const(expr): """Converts a non-Expression to a Constant. """ return expr if isinstance(expr, Expression) else types.constant()(expr)
def __neg__(self): lh_mult = deque([types.constant()(-1)]) terms = AffObjective.mul_terms([lh_mult], self._terms) return AffObjective(self.variables(), terms, self._shape)
def promote(obj, shape): ones = types.constant()(intf.DEFAULT_INTERFACE.ones(*shape.size)) ones_obj,dummy = ones.canonical_form() return ones_obj*obj
def cast_to_const(expr): return expr if isinstance(expr, Expression) else types.constant()(expr)