Constants#
Constants are a unique type of variable were the value is known.
- class cake.Constant(coefficient: Any = 1, power: Any = 1)[source]#
-
Generic base class for defining constants, behaves similar to
Variable.class MyConstant(Constant): @classmethod def _to_type(cls, coefficient: Any = 1, power: Any = 1) -> MyConstant: return cls(coefficient, power) @property def c_value(self) -> Any: return 5.5 ## Value of the constant ## Lets use our constant mc = MyConstant() x = Variable(x) expr = x + mc(2) print(expr) ### x + 2MyConstant print(expr.solve(x=3)) ### 14
- Parameters:
- static is_similar(x: Variable, y: Variable) bool#
Returns whether 2 Variables can interact with one another,
so
Variable.is_similar(3x, 4x)is True butVariable.is_similar(4y, 3x)is False.