sppl icon indicating copy to clipboard operation
sppl copied to clipboard

SPPL compiler replaces `==` and `in` with `<<` incorrectly at times

Open fsaad opened this issue 2 years ago • 0 comments

MWE

>>> source = """
i = 0.5
Y ~= bernoulli(p=0 if i == 0.5 else 1)
"""
>>> compiler = SPPL_Compiler(source)
>>> namespace = compiler.execute_module()
TypeError: unsupported operand type(s) for <<: 'float' and 'set'

The reason is that the generated Python is

# MODEL DEFINITION
command = Sequence(
    Sample(Y, bernoulli(p=(0 if (i << {0.5}) else 1))),
)

The offending line is here: https://github.com/probcomp/sppl/blob/8b0fe0c37ed15dd19936d13e0fa652c3b5237cac/src/compilers/sppl_to_python.py#L145

fsaad avatar Sep 07 '22 17:09 fsaad