fuzzy_and weird code

17 views
Skip to first unread message

Paul Royik

unread,
Mar 25, 2021, 3:51:11 PM3/25/21
to sympy
This is a code for fuzzy_and:
rv = True
for ai in args:
    ai = fuzzy_bool(ai)
    if ai is False:
        return False
    if rv: # this will stop updating if a None is ever trapped
        rv = ai
return rv

Is there any reason why None is not immediately returned?

Chris Smith

unread,
Mar 25, 2021, 3:58:14 PM3/25/21
to sympy
It's waiting for a False which might occur later; False trumps None.

/c

Oscar Benjamin

unread,
Mar 25, 2021, 3:58:17 PM3/25/21
to sympy
To be clear you are talking about this function:
https://github.com/sympy/sympy/blob/aa22709cb7df2d7503803d4b2c0baa7aa21440b6/sympy/core/logic.py#L115

If you call fuzzy_and([True, None, False]) then it needs to run
through to the final False to be able to return False.


Oscar

Paul Royik

unread,
Mar 25, 2021, 3:59:09 PM3/25/21
to sympy
Thank you. Didn't notice that!
Reply all
Reply to author
Forward
0 new messages