Repository navigation
Allow nonnumeric observations in model checks - #1546
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1546 +/- ##
=======================================
Coverage 85.34% 85.34%
=======================================
Files 52 52
Lines 4714 4714
=======================================
Hits 4023 4023
Misses 691 691 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
DynamicPPL.jl documentation for PR #1546 is available at: |
BenchmarksPerformance Ratio: gradient time divided by log-density time. For very small models these ratios are noisy across runs and machines; raw primal and gradient timings are more reliable. The benchmarks are aimed at DynamicPPL developers and mainly catch obvious allocation or type-stability regressions. See benchmark notes for details. Primal times: EnvironmentJulia Version 1.13.4 Commit c1ac32ab733 (2026-11-13 17:30 UTC) Build Info: Official https://julialang.org release Platform Info: OS: Linux (x86_64-linux-gnu) CPU: 4 × AMD EPYC 9V74 80-Core Processor WORD_SIZE: 64 LLVM: libLLVM-20.1.8 (ORCJIT, znver4) GC: Built with stock GC Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores) |
yebai
left a comment
There was a problem hiding this comment.
Thanks for picking this up so quickly. A local run confirms that the reproducer in #1545 now passes check_model.
One side effect: applicable(isnan, x) is false for a tuple, so a NaN inside a tuple observation now passes the check silently; on main it threw a MethodError:
struct D <: DiscreteUnivariateDistribution end
Distributions.loglikelihood(::D, ::Tuple) = 0.0
@model m(y) = (x ~ Normal(); y ~ D())
check_model(m((:a, NaN))) # true on this branchThe suggestions below use dispatch instead, as the issue proposes, with recursion into tuples added: isnan for numbers and false for anything else, so Missing no longer needs its own method. The only behaviour this drops is isnan defined on a type that is not a Number. The tests then go through the public check_model; a local run shows that each fails on main, and that the tuple test also fails with the applicable form.
The PR also needs a rebase for a conflict in HISTORY.md.
Valid observations need not be numeric.
Closes #1545