From 1f99582d84db84597eb5036b280bc9154807bcf1 Mon Sep 17 00:00:00 2001 From: Michael Clerx Date: Thu, 5 Feb 2026 21:28:16 +0000 Subject: [PATCH] Fixes to toy model docstrings --- pints/toy/_annulus.py | 2 +- pints/toy/_cone.py | 2 +- pints/toy/_constant_model.py | 6 ++++-- pints/toy/_eight_schools.py | 2 +- pints/toy/_fitzhugh_nagumo_model.py | 6 +++--- pints/toy/_german_credit.py | 2 +- pints/toy/_german_credit_hierarchical.py | 2 +- pints/toy/_goodwin_oscillator_model.py | 6 +++--- pints/toy/_hes1_michaelis_menten.py | 8 ++++---- pints/toy/_logistic_model.py | 2 +- pints/toy/_lotka_volterra_model.py | 4 ++-- pints/toy/_sho_model.py | 2 +- pints/toy/_toy_classes.py | 10 ++++++---- pints/toy/stochastic/_degradation_model.py | 2 +- pints/toy/stochastic/_logistic_model.py | 2 +- pints/toy/stochastic/_michaelis_menten_model.py | 2 ++ pints/toy/stochastic/_production_degradation_model.py | 2 +- pints/toy/stochastic/_schlogl_model.py | 10 ++++++---- 18 files changed, 40 insertions(+), 32 deletions(-) diff --git a/pints/toy/_annulus.py b/pints/toy/_annulus.py index 38de7d6e2..ad53c1e3c 100644 --- a/pints/toy/_annulus.py +++ b/pints/toy/_annulus.py @@ -26,7 +26,7 @@ class AnnulusLogPDF(ToyLogPDF): the same radius. In two dimensions, the density looks like a circular annulus. - Extends :class:`pints.LogPDF`. + Extends :class:`pints.toy.ToyLogPDF`. Parameters ---------- diff --git a/pints/toy/_cone.py b/pints/toy/_cone.py index 8361932e9..e7d734c8a 100644 --- a/pints/toy/_cone.py +++ b/pints/toy/_cone.py @@ -23,7 +23,7 @@ class ConeLogPDF(ToyLogPDF): mean and variance that are returned relate to expectations on ``|x|`` not the multidimensional ``x``. - Extends :class:`pints.LogPDF`. + Extends :class:`pints.toy.ToyLogPDF`. Parameters ---------- diff --git a/pints/toy/_constant_model.py b/pints/toy/_constant_model.py index 8854383f8..76647e3a3 100644 --- a/pints/toy/_constant_model.py +++ b/pints/toy/_constant_model.py @@ -8,8 +8,10 @@ import numpy as np import pints +from . import ToyModel -class ConstantModel(pints.ForwardModelS1): + +class ConstantModel(ToyModel, pints.ForwardModelS1): r""" Toy model that's constant over time, linear over the parameters, mostly useful for unit testing. @@ -29,7 +31,7 @@ class ConstantModel(pints.ForwardModelS1): \frac{\partial{f_i(t)}}{dp_j} = \begin{cases} i, i = j\\0, i \neq j \end{cases} - Extends :class:`pints.ForwardModelS1`. + Extends :class:`pints.ForwardModelS1`, :class:`pints.toy.ToyModel`. Parameters ---------- diff --git a/pints/toy/_eight_schools.py b/pints/toy/_eight_schools.py index 8314942be..4d5f02e43 100644 --- a/pints/toy/_eight_schools.py +++ b/pints/toy/_eight_schools.py @@ -15,7 +15,7 @@ class EightSchoolsLogPDF(ToyLogPDF): r""" The classic Eight Schools example that is discussed in [1]_. - The aim of this model (implemented as a :class:`pints.ToyLogPDF`) is to + The aim of this model (implemented as a :class:`pints.toy.ToyLogPDF`) is to determine the effects of coaching on SAT scores in 8 schools (each school being denoted by subscript j in the following equations). It it used by statisticians to illustrate how hierarchical models can quite easily diff --git a/pints/toy/_fitzhugh_nagumo_model.py b/pints/toy/_fitzhugh_nagumo_model.py index e94a26b9f..93273ec4f 100644 --- a/pints/toy/_fitzhugh_nagumo_model.py +++ b/pints/toy/_fitzhugh_nagumo_model.py @@ -77,7 +77,7 @@ def __init__(self, y0=None): raise ValueError('Initial value must have size 2.') def _dfdp(self, y, t, p): - """ See :meth:`pints.ToyODEModel._dfdp()`. """ + """ See :meth:`pints.toy.ToyODEModel._dfdp()`. """ V, R = y a, b, c = [float(param) for param in p] ret = np.empty((2, 3)) @@ -90,7 +90,7 @@ def _dfdp(self, y, t, p): return ret def jacobian(self, y, t, p): - """ See :meth:`pints.ToyODEModel.jacobian()`. """ + """ See :meth:`pints.toy.ToyODEModel.jacobian()`. """ V, R = y a, b, c = [float(param) for param in p] ret = np.empty((2, 2)) @@ -109,7 +109,7 @@ def n_parameters(self): return 3 def _rhs(self, y, t, p): - """ See :meth:`pints.ToyODEModel._rhs()`. """ + """ See :meth:`pints.toy.ToyODEModel._rhs()`. """ V, R = y a, b, c = [float(x) for x in p] dV_dt = (V - V**3 / 3 + R) * c diff --git a/pints/toy/_german_credit.py b/pints/toy/_german_credit.py index 693d95d1e..50b6d9a44 100644 --- a/pints/toy/_german_credit.py +++ b/pints/toy/_german_credit.py @@ -29,7 +29,7 @@ class GermanCreditLogPDF(ToyLogPDF): and :math:`\sigma^2=100`. The dataset here is from [1]_ but the test problem is defined in [2]_. - Extends :class:`pints.LogPDF`. + Extends :class:`pints.toy.ToyLogPDF`. Parameters ---------- diff --git a/pints/toy/_german_credit_hierarchical.py b/pints/toy/_german_credit_hierarchical.py index dd744a9a1..f6bc71b79 100644 --- a/pints/toy/_german_credit_hierarchical.py +++ b/pints/toy/_german_credit_hierarchical.py @@ -31,7 +31,7 @@ class GermanCreditHierarchicalLogPDF(ToyLogPDF): by creating all interactions between individual variables and themselves as defined in [2]_. - Extends :class:`pints.LogPDF`. + Extends :class:`pints.toy.ToyLogPDF`. Parameters ---------- diff --git a/pints/toy/_goodwin_oscillator_model.py b/pints/toy/_goodwin_oscillator_model.py index 71b18d10b..c0d5e294d 100644 --- a/pints/toy/_goodwin_oscillator_model.py +++ b/pints/toy/_goodwin_oscillator_model.py @@ -49,7 +49,7 @@ def __init__(self): self._y0 = [0.0054, 0.053, 1.93] def _dfdp(self, state, time, parameters): - """ See :meth:`pints.ToyODEModel._dfdp()`. """ + """ See :meth:`pints.toy.ToyODEModel._dfdp()`. """ x, y, z = state k2, k3, m1, m2, m3 = parameters ret = np.empty((self.n_outputs(), self.n_parameters())) @@ -71,7 +71,7 @@ def _dfdp(self, state, time, parameters): return ret def jacobian(self, state, time, parameters): - """ See :meth:`pints.ToyODEModel.jacobian()`. """ + """ See :meth:`pints.toy.ToyODEModel.jacobian()`. """ x, y, z = state k2, k3, m1, m2, m3 = parameters ret = np.empty((self.n_outputs(), self.n_outputs())) @@ -95,7 +95,7 @@ def n_parameters(self): return 5 def _rhs(self, state, time, parameters): - """ See :meth:`pints.ToyODEModel._rhs()`. """ + """ See :meth:`pints.toy.ToyODEModel._rhs()`. """ x, y, z = state k2, k3, m1, m2, m3 = parameters dxdt = 1 / (1 + z**10) - m1 * x diff --git a/pints/toy/_hes1_michaelis_menten.py b/pints/toy/_hes1_michaelis_menten.py index bf67ec842..7b64d7bec 100644 --- a/pints/toy/_hes1_michaelis_menten.py +++ b/pints/toy/_hes1_michaelis_menten.py @@ -30,7 +30,7 @@ class Hes1Model(ToyODEModel, pints.ForwardModelS1): the system. The input order of parameters of interest is :math:`\\{ P_0, \\nu, k_1, h \\}`. - Extends :class:`pints.ForwardModel`, :class:`pints.toy.ToyModel`. + Extends :class:`pints.ForwardModelS1`, :class:`pints.toy.ToyODEModel`. Parameters ---------- @@ -58,7 +58,7 @@ def __init__(self, m0=None, fixed_parameters=None): self.set_m0(m0) def _dfdp(self, state, time, parameters): - """ See :meth:`pints.ToyModel.jacobian()`. """ + """ See :meth:`pints.toy.ToyModel.jacobian()`. """ m, p1, p2 = state P0, v, k1, h = parameters p2_over_p0 = p2 / P0 @@ -96,7 +96,7 @@ def fixed_parameters(self): return [self._p0[0], self._p0[1], self._kdeg] def jacobian(self, state, time, parameters): - """ See :meth:`pints.ToyModel.jacobian()`. """ + """ See :meth:`pints.toy.ToyModel.jacobian()`. """ m, p1, p2 = state P0, v, k1, h = parameters k_deg = self._kdeg @@ -116,7 +116,7 @@ def jacobian(self, state, time, parameters): return ret def n_states(self): - """ See :meth:`pints.ToyODEModel.n_states()`. """ + """ See :meth:`pints.toy.ToyODEModel.n_states()`. """ return 3 def n_outputs(self): diff --git a/pints/toy/_logistic_model.py b/pints/toy/_logistic_model.py index 17a91498e..efdafa0b9 100644 --- a/pints/toy/_logistic_model.py +++ b/pints/toy/_logistic_model.py @@ -29,7 +29,7 @@ class LogisticModel(pints.ForwardModelS1, ToyModel): :math:`k`. The initial population size :math:`p_0 = f(0)` is a fixed (known) parameter in the model. - Extends :class:`pints.ForwardModel`, :class:`pints.toy.ToyModel`. + Extends :class:`pints.ForwardModelS1`, :class:`pints.toy.ToyModel`. Parameters ---------- diff --git a/pints/toy/_lotka_volterra_model.py b/pints/toy/_lotka_volterra_model.py index 8aa64282a..3941e9317 100644 --- a/pints/toy/_lotka_volterra_model.py +++ b/pints/toy/_lotka_volterra_model.py @@ -49,7 +49,7 @@ def __init__(self, y0=None): self.set_initial_conditions(y0) def _dfdp(self, z, t, p): - """ See :meth:`pints.ToyModel.jacobian()`. """ + """ See :meth:`pints.toy.ToyModel.jacobian()`. """ x, y = z a, b, c, d = [float(param) for param in p] ret = np.empty((2, 4)) @@ -64,7 +64,7 @@ def _dfdp(self, z, t, p): return ret def jacobian(self, z, t, p): - """ See :meth:`pints.ToyModel.jacobian()`. """ + """ See :meth:`pints.toy.ToyModel.jacobian()`. """ x, y = z a, b, c, d = [float(param) for param in p] ret = np.empty((2, 2)) diff --git a/pints/toy/_sho_model.py b/pints/toy/_sho_model.py index 279672a58..a4730fae4 100644 --- a/pints/toy/_sho_model.py +++ b/pints/toy/_sho_model.py @@ -29,7 +29,7 @@ class SimpleHarmonicOscillatorModel(pints.ForwardModelS1, ToyModel): ``y(0)``, its initial momentum, ``dy/dt(0)`` and the magnitude of the friction force, ``theta``. - Extends :class:`pints.ForwardModel`, :class:`pints.toy.ToyModel`. + Extends :class:`pints.ForwardModelS1`, :class:`pints.toy.ToyModel`. References ---------- diff --git a/pints/toy/_toy_classes.py b/pints/toy/_toy_classes.py index 1c30e365f..bb8431928 100644 --- a/pints/toy/_toy_classes.py +++ b/pints/toy/_toy_classes.py @@ -37,12 +37,12 @@ def suggested_bounds(self): raise NotImplementedError -class ToyModel(object): +class ToyModel(): """ Defines an interface for toy problems. Note that toy models should extend both ``ToyModel`` and one of the forward - model classes, e.g. :class:`pints.ForwardModel`. + model classes, i.e. :class:`pints.ForwardModel` or :class:`ForwardModelS1`. """ def suggested_parameters(self): """ @@ -68,8 +68,8 @@ class ToyODEModel(ToyModel): ordinary differential equation (ODE) that describes some time-series generating model. - Note that toy ODE models should extend both :class:`pints.ToyODEModel` and - one of the forward model classes, e.g. :class:`pints.ForwardModel` or + Note that toy ODE models should extend both :class:`pints.toy.ToyODEModel` + and one of the forward model classes, e.g. :class:`pints.ForwardModel` or :class:`pints.ForwardModelS1`. To use this class as the basis for a :class:`pints.ForwardModel`, the @@ -77,6 +77,8 @@ class ToyODEModel(ToyModel): Models implementing :meth:`_rhs()`, :meth:`jacobian()` and :meth:`_dfdp()` can be used to create a :class:`pints.ForwardModelS1`. + + Extends: :class:`pints.toy.ToyODEModel`. """ def _dfdp(self, y, t, p): """ diff --git a/pints/toy/stochastic/_degradation_model.py b/pints/toy/stochastic/_degradation_model.py index 33095c7d2..37a18bb75 100644 --- a/pints/toy/stochastic/_degradation_model.py +++ b/pints/toy/stochastic/_degradation_model.py @@ -19,7 +19,7 @@ class DegradationModel(MarkovJumpModel): .. math:: A \xrightarrow{k} 0 - Extends :class:`pints.MarkovJumpModel`. + Extends: :class:`pints.toy.stochastic.MarkovJumpModel`. Parameters ---------- diff --git a/pints/toy/stochastic/_logistic_model.py b/pints/toy/stochastic/_logistic_model.py index 10fb098ef..932b52a0a 100644 --- a/pints/toy/stochastic/_logistic_model.py +++ b/pints/toy/stochastic/_logistic_model.py @@ -24,7 +24,7 @@ class LogisticModel(MarkovJumpModel): The model is simulated using the Gillespie stochastic simulation algorithm [2]_, [3]_. - *Extends:* :class:`pints.ForwardModel`, :class:`pints.toy.ToyModel`. + Extends: :class:`pints.toy.stochastic.MarkovJumpModel`. Parameters ---------- diff --git a/pints/toy/stochastic/_michaelis_menten_model.py b/pints/toy/stochastic/_michaelis_menten_model.py index e61d5b9b1..b7a5410d9 100644 --- a/pints/toy/stochastic/_michaelis_menten_model.py +++ b/pints/toy/stochastic/_michaelis_menten_model.py @@ -19,6 +19,8 @@ class MichaelisMentenModel(MarkovJumpModel): - X3 -> X1+X2 with rate k2 - X3 -> X2+X4 with rate k3 + Extends: :class:`pints.toy.stochastic.MarkovJumpModel`. + Parameters ---------- initial_molecule_count : Array of size 3 of integers diff --git a/pints/toy/stochastic/_production_degradation_model.py b/pints/toy/stochastic/_production_degradation_model.py index 996ae866d..028d88839 100644 --- a/pints/toy/stochastic/_production_degradation_model.py +++ b/pints/toy/stochastic/_production_degradation_model.py @@ -20,7 +20,7 @@ class ProductionDegradationModel(MarkovJumpModel): .. math:: A \xrightarrow{k1} 0, 0 \xrightarrow{k2} A - Extends :class:`pints.ForwardModel`, :class:`pints.toy.ToyModel`. + Extends: :class:`pints.toy.stochastic.MarkovJumpModel`. Parameters ---------- diff --git a/pints/toy/stochastic/_schlogl_model.py b/pints/toy/stochastic/_schlogl_model.py index ff2564873..47bfad13a 100644 --- a/pints/toy/stochastic/_schlogl_model.py +++ b/pints/toy/stochastic/_schlogl_model.py @@ -13,9 +13,11 @@ class SchloglModel(MarkovJumpModel): r""" Schlogl's system of chemical reactions has a single type of molecules and - starts with an initial count :math:`A(0)`. The evolution of the molecule - count is defined through the rates :math:`k_1`, :math:`k_2`, :math:`k_3` - and :math:`k_4` and the following equations: + starts with an initial count :math:`A(0)`. + + The evolution of the molecule count is defined through the rates + :math:`k_1`, :math:`k_2`, :math:`k_3` and :math:`k_4` and the following + equations: ..math:: 2A \xrightarrow{k_1} 3A @@ -23,7 +25,7 @@ class SchloglModel(MarkovJumpModel): 0 \xrightarrow{k_3} A A \xrightarrow{k_4} 0 - Extends :class:`pints.ForwardModel`, :class:`pints.toy.ToyModel`. + Extends: :class:`pints.toy.stochastic.MarkovJumpModel`. Parameters ----------