sppl
sppl copied to clipboard
Fix Reciprocal.ffwd in case that argument is not an integer (sympy chokes)
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])
Note that sympy hangs only if x<0; positive is fine.
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.