Skip to content

Commit 410d0da

Browse files
author
Robbie Muir
committed
fixed test
1 parent 93bfdfa commit 410d0da

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

linopy/expressions.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,10 @@ def __sub__(
523523
def __sub__(self, other: QuadraticExpression) -> QuadraticExpression: ...
524524

525525
def __sub__(self, other: SideLike) -> LinearExpression | QuadraticExpression:
526-
return self.__add__(-other)
526+
try:
527+
return self.__add__(-other)
528+
except TypeError:
529+
return NotImplemented
527530

528531
def __neg__(self) -> LinearExpression:
529532
"""
@@ -1641,7 +1644,10 @@ def __rsub__(self, other: SideLike) -> QuadraticExpression:
16411644
"""
16421645
Subtract expression from others.
16431646
"""
1644-
return self.__neg__().__add__(other)
1647+
try:
1648+
return self.__neg__() + other
1649+
except TypeError:
1650+
return NotImplemented
16451651

16461652
def __neg__(self) -> QuadraticExpression:
16471653
"""

0 commit comments

Comments
 (0)