How do I combine step functions?

Step functions can be added, subtracted, divided and multiplied together. The staircase.Stairs class provides these binary operator methods *:

To promote readability, these methods are ideally invoked using their operator symbols. Note that we can use them in conjunction with floats and a number, x, is equivalent to sc.Stairs(initial_value=x) when used as an operand. Instead of walking through each of these methods, let’s roll the example into one:

In [1]: fig, axes = plt.subplots(ncols=2, figsize=(7,3), tight_layout=True)

In [2]: sf.plot(ax=axes[0], arrows=True);

In [3]: ((sf*sf + 2)/(4 - sf)).plot(ax=axes[1], arrows=True);



and their “reverse” operator counterparts