Repository navigation
Commit aaaf66c
authored
Add Hypothesis property-based tests for core tHMM invariants (#1010)
* Add Hypothesis property-based tests for core tHMM invariants
Covers transition-matrix stochasticity, CellVar.divide, the stationary
distribution, weighted Bernoulli/Gamma emission estimators, LineageTree
generation, and Viterbi/log-score consistency. One test is a pinned,
strict xfail documenting a real bug it found: StateDistribution.logpdf
can raise FloatingPointError (NaN from +inf/-inf) when an unobserved
(-1) Bernoulli sentinel coincides with an uncensored, exactly-zero
Gamma observation under a shape parameter < 1.
* Fix FloatingPointError crash in StateDistribution.logpdf
Exclude sentinel/negative Bernoulli and Gamma observations from the
Gamma and Bernoulli log-likelihood terms up front, instead of only
zeroing them out afterwards. Previously an unobserved (-1) Bernoulli
value on a row with an uncensored, exactly-zero Gamma observation and
a shape parameter < 1 (where the Gamma density diverges to +inf at
x=0) could produce a (+inf) + (-inf) = NaN, which crashes under
np.seterr(all="raise").
Un-xfails test_gamma_logpdf_never_produces_nan now that the bug it
documented is fixed.1 parent 9fff0e5 commit aaaf66c
4 files changed
Lines changed: 496 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
65 | 72 | | |
66 | | - | |
| 73 | + | |
| 74 | + | |
67 | 75 | | |
68 | 76 | | |
69 | | - | |
| 77 | + | |
| 78 | + | |
70 | 79 | | |
71 | 80 | | |
72 | 81 | | |
73 | 82 | | |
74 | 83 | | |
75 | | - | |
| 84 | + | |
| 85 | + | |
76 | 86 | | |
77 | 87 | | |
78 | 88 | | |
| |||
0 commit comments