rethinkpriorities / squigglepy

Squiggle programming language for intuitive probabilistic estimation features in Python
MIT License
65 stars 8 forks source link

at least one instance of hyperparameters does not work #6

Open joel-becker opened 1 year ago

joel-becker commented 1 year ago

this would work in squiggle

a = normal(0, 1)
b = normal(a, 1)

but doesn't work in squigglepy

>>> c = sq.norm(mean=sq.norm(mean=0,sd=1), sd=1)
>>> c
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/joel/Library/Python/3.9/lib/python/site-packages/squigglepy/distributions.py", line 40, in __repr__
    return str(self)
  File "/Users/joel/Library/Python/3.9/lib/python/site-packages/squigglepy/distributions.py", line 588, in __str__
    round(self.mean, 2),
TypeError: type NormalDistribution doesn't define __round__ method
>>> c.mean
<Distribution> norm(mean=0, sd=1)

i guess because sampling is determined by the user, after computing everything else, in order to keep squigglepy very fast. i definitely appreciate the speed, but there have been a couple of times when "something like the above example, implemented fast enough for a web app" would be dreamy.

peterhurford commented 1 year ago

Hmm I hadn't thought about this but I can make it happen!