Arctan2 & alternatives to pm.math.switch?

The signature of switch is switch(conditon, if, else), so you can achieve ifelse blocks by putting more switches in the second argument like this:

x = pt.dvector('x')
y = pt.dvector('y')

z = pt.switch(pt.gt(x, 0),
              pt.arctan(y/x),
              pt.switch(pt.gt(y, 0),
                        pt.pi/2 - pt.arctan(x/y),
                        ...))
1 Like