Skip to content

Commit 127e372

Browse files
authored
Merge pull request #4 from thisiscam/examples-and-docs
docs: TOC nesting fix + clarify compile_model backends (ils_*)
2 parents e47e64a + 8f97062 commit 127e372

3 files changed

Lines changed: 32 additions & 21 deletions

File tree

‎acopula/compile.py‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -366,21 +366,31 @@ def compile_model(
366366
``model_fn`` expects. Values are used only to drive oryx's
367367
tracer; pass any sensible defaults (e.g.
368368
``{"theta": 1.0}``).
369-
method: Density evaluation backend. ``"bell"`` uses the
370-
polynomial-powering scan (recommended for nested >= 2
371-
levels), ``"single_layer"`` is the closed-form unnested
372-
formula, ``"nested"`` falls back to numerical integration
373-
via the implicit-LST solver. ``"auto"`` picks ``"bell"``
374-
for depth > 1 else ``"single_layer"``.
369+
method: Density-evaluation backend:
370+
371+
- ``"auto"`` (default): ``"bell"`` for depth > 1, else
372+
``"single_layer"``.
373+
- ``"bell"``: polynomial-powering scan (recommended for
374+
nested copulas; the only backend that supports
375+
``with_censored_mask``).
376+
- ``"single_layer"``: closed-form unnested formula (flat
377+
copulas only).
378+
- ``"integral"``: numerical inverse-Laplace integration —
379+
the only backend that uses ``ils_method`` / ``ils_params``.
375380
survival: Treat marginals as survival functions
376381
``S(t) = 1 - F(t)`` rather than CDFs. Required for the
377382
HACSurv-style joint survival likelihood.
378383
with_censored_mask: If True, the returned ``ll_fn`` takes a
379384
third ``censored_mask`` argument so callers can ``vmap``
380385
per-observation masks. Forces ``method="bell"`` since the
381386
other backends do not support dynamic censoring.
382-
ils_method: Implicit-LST solver for ``method="nested"``.
383-
ils_params: Extra params for the implicit solver.
387+
ils_method: Inverse-Laplace solver used **only** by
388+
``method="integral"`` — e.g. ``"cohen"`` (default),
389+
``"euler"``, ``"post_widder"``. **Ignored by ``"bell"`` and
390+
``"single_layer"``**, which assemble the density analytically
391+
and never invert a Laplace transform.
392+
ils_params: Extra params for that solver; likewise **only used by
393+
``method="integral"``** and ignored by the other backends.
384394
385395
Returns:
386396
A :class:`CompiledModel` holding the frozen graph, flattener,

‎acopula/core.py‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,25 +151,26 @@ def __call__(self, children: Iterable[Union["Node", "Leaf", jax.Array]]) -> "Nod
151151

152152

153153
def copula(cls):
154-
"""Decorator to create a copula class with dataclass-like syntax.
154+
"""Class decorator for defining a copula family with dataclass-style
155+
parameters.
155156
156-
Usage:
157+
Generates an ``__init__`` from the type-annotated class attributes,
158+
makes the class inherit from `Copula`, and registers the parameters —
159+
while preserving every user-defined method. Instances accept positional
160+
or keyword arguments.
161+
162+
Examples:
163+
```python
157164
@copula
158165
class Clayton:
159166
theta: float
160167
161-
def generator(self, u: jax.Array) -> jax.Array:
168+
def generator(self, u):
162169
return (1.0 + u) ** (-1.0 / self.theta)
163170
164-
# Can instantiate with positional or keyword arguments
165-
c1 = Clayton(2.0)
166-
c2 = Clayton(theta=2.0)
167-
168-
This automatically:
169-
- Makes the class inherit from Copula
170-
- Generates an __init__ method from type annotations
171-
- Preserves all user-defined methods
172-
- Handles parameter registration
171+
c1 = Clayton(2.0) # positional
172+
c2 = Clayton(theta=2.0) # keyword
173+
```
173174
"""
174175
# Get type annotations in definition order
175176
annotations = getattr(cls, "__annotations__", {})

‎mkdocs.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ plugins:
5757
filters: ["!^_"] # hide private / dunder members
5858
show_source: false
5959
summary: true
60-
heading_level: 2
60+
heading_level: 3 # section headers are ## (h2); symbols nest as h3
6161
# Emits /llms.txt (an index for LLMs/agents, per llmstxt.org) plus a single
6262
# concatenated llms-full.txt of the whole site.
6363
- llmstxt:

0 commit comments

Comments
 (0)