diff --git a/python/ommx/ommx/v1/__init__.py b/python/ommx/ommx/v1/__init__.py index d32c0894..1d9c1c4d 100644 --- a/python/ommx/ommx/v1/__init__.py +++ b/python/ommx/ommx/v1/__init__.py @@ -1233,22 +1233,6 @@ def __neg__(self) -> Linear: return -1 * self def __eq__(self, other) -> Constraint: # type: ignore[reportIncompatibleMethodOverride] - """ - Create a constraint that this linear function is equal to the right-hand side. - - Examples - ======== - - >>> x = DecisionVariable.integer(1) - >>> y = DecisionVariable.integer(2) - >>> x + y == 1 - Constraint(...) - - To compare two objects, use :py:meth:`almost_equal` method. - - >>> assert (x + y).almost_equal(Linear(terms={1: 1, 2: 1})) - - """ return Constraint( function=self - other, equality=Equality.EQUALITY_EQUAL_TO_ZERO ) @@ -1448,6 +1432,11 @@ def __rmul__(self, other): def __neg__(self) -> Linear: return -1 * self + def __eq__(self, other) -> Constraint: # type: ignore[reportIncompatibleMethodOverride] + return Constraint( + function=self - other, equality=Equality.EQUALITY_EQUAL_TO_ZERO + ) + @dataclass class Polynomial(AsConstraint): @@ -1633,6 +1622,11 @@ def __rmul__(self, other): def __neg__(self) -> Linear: return -1 * self + def __eq__(self, other) -> Constraint: # type: ignore[reportIncompatibleMethodOverride] + return Constraint( + function=self - other, equality=Equality.EQUALITY_EQUAL_TO_ZERO + ) + def as_function( f: int @@ -1867,6 +1861,11 @@ def __rmul__(self, other): def __neg__(self) -> Function: return -1 * self + def __eq__(self, other) -> Constraint: # type: ignore[reportIncompatibleMethodOverride] + return Constraint( + function=self - other, equality=Equality.EQUALITY_EQUAL_TO_ZERO + ) + @dataclass class Constraint: