sppl icon indicating copy to clipboard operation
sppl copied to clipboard

Fix Reciprocal.ffwd in case that argument is not an integer (sympy chokes)

Open fsaad opened this issue 5 years ago • 2 comments

https://github.com/probcomp/sum-product-dsl/blob/95c0daf08af9eea974e0053a45ec9d462e18dbfc/src/transforms.py#L593

Test case

>>> spn = X >> norm(0,1)
>>> spn.transform(Z, 2**(1/X))
>>> samples = spn.sample(10)

The final call will cause sympy to hang, which cannot evaluate two raised to a large Rational, specifically:

2**sympy.Rational(1, samples[0][x])

fsaad avatar Apr 22 '20 01:04 fsaad

Note that sympy hangs only if x<0; positive is fine.

fsaad avatar Apr 28 '20 03:04 fsaad

Generally it seems we need to migrate the solver in transforms.py to use python floats, since sympy has unreliable performance for edge cases which will be too complicated to try and track.

fsaad avatar Apr 28 '20 03:04 fsaad