symforce-org / symforce

Fast symbolic computation, code generation, and nonlinear optimization for robotics

Home Page:https://symforce.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sf.logical_or

BenedictChannn opened this issue · comments

>>> sf.logical_or(1 > 4, 3 > 2, 8 < 10, unsafe = True)
max(False, True)

As long as I have more than 2 arguments, the output is as such. Shouldn't it just output True?

sf.logical_or() operates on sf.Scalars (floats) and not bools. This version of your example works:

>>> sf.logical_or(sf.greater(1, 4), sf.greater(3, 2), sf.greater(8, 10), unsafe=True)
1

The example I gave above wasn't appropriate... If I am dealing with symbolic variables then even with sf.greater(x, 5) for example would result in the same issue. Is there something else I have to do?

Can you give some more context on what you're doing with the symbolic expression? In particular, what is the eventual type of x? Throwing a symbolic variable in my earlier example seems to give the right result:

>>> phi = sf.Symbol('phi')

>>> sf.logical_or(sf.greater(1, 4), sf.greater(3, 2), sf.greater(phi, 10), unsafe=True)
max(1, sign(-10 + phi))