zenna / Omega.jl

Causal, Higher-Order, Probabilistic Programming
MIT License
160 stars 17 forks source link

Errors in tutorial code & documentation about ~ and @ operators #205

Open elliottower opened 2 years ago

elliottower commented 2 years ago

I have been running through the tutorial examples and a lot of them work, with some minor adjustments needed, but some do not seem to work at all. For example, the callbacks tutorial I am not able to run any of the cells, when I try to run any of the cells with the ~ operator, such as this: x = ~ ω -> (sleep(0.001); normal(ω, 0, 1)) I get the following error

MethodError: no method matching ~(::getfield(Main, Symbol("##26#27")))
Closest candidates are:
  ~(::BigInt) at gmp.jl:470
  ~(::Missing) at missing.jl:79
  ~(::Bool) at bool.jl:39

The basic tutorial also has a similar issue with the ~ operator, I am assuming this is because the functionality was changed and the documentation hasn't been updated yet, but it throws this error. weight = @~ Beta(2.0, 2.0) UndefVarError: @~ not defined

Copying from another notebook I got the tutorial to work by instead using weight = β(2.0, 2.0), and replacing the later line coinflips_ = [Bernoulli.(weight, Bool) for i = 1:nflips] (which gives the error MethodError: no method matching length(::Omega.Prim.Beta{Float64,Float64}))

with coinflips_ = [bernoulli(weight, Bool) for i = 1:nflips]

I am running julia 1.0.5 and omega 0.1.1, as those were the only versions I could get to work (see my other issue), so maybe these errors are fixed in 0.2? I was considering submitting a pull request to update the documentation but I wasn't sure if this was just a problem on my end or an actual bug.

In order to help people troubleshoot issues like these, and make it more clear what each operator does, I think it would be helpful to have documentation about all of the different types of symbols.

There are a few helpful notes about how to type the subscript s for soft execution and explaining it what it does, but a centralized document with all of this would be very helpful, especially for beginners. It could be useful to explain how to type other mathematical symbols such as ω or μ as well, as these are used in many of the examples but I for example had no idea how to type them at first.

Edit: Stumbled upon this cheat sheet but it seems to be missing some stuff, would be awesome if it could be updated to clarify some of these confusions https://github.com/zenna/Omega.jl/blob/master/docs/src/cheatsheet.md

MichielStock commented 1 year ago

The documentation indeed does not seem to match the package anymore. I could make the basic examples work (noting that you only need to use rand instead of randsample). I did not find how to use any other samplers than rejection sampling, limiting the use of the package...