You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stairs instances have a "closed" property which can be "left" or "right" indicates if they are left-closed, right-open or right-closed left-open.
When performing binary operations with two Stairs objects, like addition, &, >= etc it is important that both operands have the same value of closed, and an error should be raised if not.
It would be great to have this functionality implemented as a function decorator, which knows to compare self and other parameters which appear in these binary operator methods.
The text was updated successfully, but these errors were encountered:
There is a function _sanitise_binary_operands which could come in handy. It is called each time a binary operation is applied, to convert any numerical operands to Stairs.
At the moment when it converts from numerical to Stairs, the default value for "closed" is used ("left"). We may need to set the closed parameter accordingly in this function, and/or make sure the checks pass if Stairs.number_of_steps == 0.
I've suggested it would be nice to have the functionality as a decorator, (and to be honest _sanitise_binary_operands would be nice to have as a decorator), but first step is probably to iron out any wrinkles in the logic, and have it pass tests before we worry about transforming it into a decorator.
Describe the solution you'd like
Stairs instances have a "closed" property which can be "left" or "right" indicates if they are left-closed, right-open or right-closed left-open.
When performing binary operations with two Stairs objects, like addition, &, >= etc it is important that both operands have the same value of closed, and an error should be raised if not.
It would be great to have this functionality implemented as a function decorator, which knows to compare self and other parameters which appear in these binary operator methods.
The text was updated successfully, but these errors were encountered: