Piecewise shift

I want to have a number of piecewise functions, each of which is a shifted copy of the base function, but I don't know how to do this in sympy. Here is an example:

from sympy import Symbol
from sympy import Piecewise
from sympy import And

x = Symbol('x')
s = Symbol('s')
f0 = Piecewise((1, And(x > 0, x < 1)), (0, True))
fs = f0(x - s)

However, the last line gives me an error:

TypeError: 'Piecewise' object is not callable

How to make a piecewise call and indicate that fs is a function of x and s ?

+4
source share

Source: https://habr.com/ru/post/1616255/


All Articles