Skip to content

v3.1.0

Choose a tag to compare

@DiogoRibeiro7 DiogoRibeiro7 released this 28 Aug 10:19
· 75 commits to develop since this release
1830e78

Property-based tests across every generator, and the two tdcm defects they found.

Behaviour changes

Neither affects a call that was producing usable data, and no valid call returns different data — the frozen regression baselines are unchanged, so seeds still reproduce. That is what separates this from 3.0.0.

gen_tdcm raises when exp(beta[0] * z) leaves the range of a float, instead of returning a frame.

dist_par builds each margin as (-log(1 - u) / a) ** (1 / b), so a b below 1 is an exponent above 1 and the covariate reaches the tens of thousands. What came back was not an error:

 id  start  stop  status     covariate  tdcov
1.0    0.0   0.0     1.0 169613.661041    0.0
2.0    0.0   0.0     1.0   5623.501137    0.0

t = log_term / inf is exactly 0.0, and status = (t <= c) then reported an observed event at time zero for every subject, in a zero-length risk interval. With the sign of beta[0] flipped the same expression underflowed to 0.0, making t infinite and every subject censored. Both frames had the right columns, the right dtypes and no NaN — a finiteness check passes either one.

It now raises, naming the largest covariate drawn and what to change.

gen_tdcm rejects corr at the endpoints. The validator allowed (0, 1] for Weibull and [-1, 1] for exponential, and the documentation promised the same. The Gaussian copula underneath needs strict inequalities — its covariance [[1, corr], [corr, 1]] is singular at |corr| = 1. Those values already failed, but deeper in, quoting a different range from a helper the caller never named. They now fail at the model's own boundary.

Property-based testing

tests/test_properties.py drives all twelve generators from Hypothesis rather than from one fixed parameter set each:

  • Output invariants — the column contract, no NaN or infinity, status within its declared set, no zero-length risk intervals, no event at time zero, states within the declared graph.
  • The seed contract — the same seed gives the same frame, and an int agrees with the generator it seeds. Both are promised on the reproducibility page; neither had been tested across all twelve models.
  • Rejection — out-of-domain values raise ValidationError naming the argument, rather than returning a frame or surfacing as a NumPy error about something the caller never passed.

A test fails if a model is registered without a strategy, so a new generator cannot escape any of it.

This was the second of two blockers on returning the maturity classifier to 5 - Production/Stable. R parity fixtures are the last one.

Also

The corr range on the TDCM page and in the docstring now match what is enforced. CI runs on develop rather than only at the release boundary; the runtime dependency check — which used import importlib and then read importlib.util, so it passed only when something else had already imported it — is fixed; and the black pre-commit hook matches the locked dev version, having still been running the version its advisory named.

692 tests pass, up from 613.

Install: pip install gen-surv==3.1.0