-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Particles{Bool,N} in a conditional #85
Comments
Hey! If all of them are true I guess it's safe to let the comparison evaluate to true. I already do that for the I can draw you attention to the relevant part of the docs that describe the different comparison modes |
Ah, if it appears as the type Particles in a conditional, I can't make it behave like a boolean without making use of a compiler pass, using Cassette.jl or Irtools. Something has to turn it into a boolean before it appears in the boolean context. Even more context available in this discussion |
Oh haha, Chad already ran into this exact issue. I see. I'm not expert enough to mess around with Cassette.jl, but I appreciate how it's not possible without that, or modifying Distributions.jl. I'll have to read #22 more slowly until the rest sinks in. Thanks! |
Hi @millerjoey , not sure if we've talked about this before, but lots of julia> b = Bernoulli(Particles(Uniform()); check_args=false)
Bernoulli{Particles{Float64,2000}}(
p: 0.5 ± 0.29
) Note that this works fine: julia> logpdf(b, true)
Particles{Float64,2000}
-0.999827 ± 0.999 but julia> rand.(b)
Particles{Bool,2000}
0.136 ± 0.343 The method that's being called here is rand(rng::AbstractRNG, d::Bernoulli) = rand(rng) <= succprob(d) so a single random value is tested against each of the |
Yeah, I ended up using |
Thanks for the great package that Chad Scherrer introduced me to!
Currently,
is an error due to the
check_args
call. You can get around this withBernoulli(Particles(10, Uniform()), check_args=false)
, but it would be nice if that weren't needed. Would it be dangerous/too special-cased if aParticles{Bool}
with all 1s behaved like atrue
in a conditional?The text was updated successfully, but these errors were encountered: