-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add isnan(::PhasePoint)
#381
Conversation
Not sure we want this? I guess there are two things here:
Though I understand (2) is maybe a bit counter-intuitive, the reality is that with these random programs, you might encounter NaNs even though the code is all correct (just because we encounter particularly badly behaved parts of the space). In these cases, we want to reject the points, as they are just 0-probability choices, rather than error and break stop the |
I agree with Tor here, we probably don't want to error directly. Introducing some kind of guard with number of attempts should be good. If we do decide not to error, would |
There's already a guard that warns the user, buuuuut I think in practice this isn't as useful as I was hoping when I first introduced it because IO isn't given priority and the user never ends up seeing the warning until they interrupt the computation manually 😬 |
I suppose the question is whether seeing ±Inf means something different from seeing NaN. My assumption is that NaN indicates that something is wrong and the user should look at it. But if that's not true and you can get NaN's even when doing everything right, then there's no difference (and we shouldn't include it in an error message either). |
This is unfortunately not the case 😕 For example julia> Inf / Inf
NaN (got it from here: https://docs.julialang.org/en/v1/manual/integers-and-floating-point-numbers/#Special-floating-point-values) |
Closing in favour of TuringLang/Turing.jl#2392 |
See TuringLang/Turing.jl#2389 for full context, but TLDR: if any of the values inside the PhasePoint are NaN's, we want Turing's sampling to error immediately instead of the current behaviour which is to enter an infinite loop.
This function provides a way for upstream packages such as Turing to detect this error condition.