Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pints/toy/_annulus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down
2 changes: 1 addition & 1 deletion pints/toy/_cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down
6 changes: 4 additions & 2 deletions pints/toy/_constant_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
----------
Expand Down
2 changes: 1 addition & 1 deletion pints/toy/_eight_schools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pints/toy/_fitzhugh_nagumo_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pints/toy/_german_credit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down
2 changes: 1 addition & 1 deletion pints/toy/_german_credit_hierarchical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down
6 changes: 3 additions & 3 deletions pints/toy/_goodwin_oscillator_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand All @@ -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()))
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pints/toy/_hes1_michaelis_menten.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pints/toy/_logistic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down
4 changes: 2 additions & 2 deletions pints/toy/_lotka_volterra_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion pints/toy/_sho_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down
10 changes: 6 additions & 4 deletions pints/toy/_toy_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -68,15 +68,17 @@ 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
method :meth:`_rhs()` should be reimplemented.

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):
"""
Expand Down
2 changes: 1 addition & 1 deletion pints/toy/stochastic/_degradation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DegradationModel(MarkovJumpModel):
.. math::
A \xrightarrow{k} 0

Extends :class:`pints.MarkovJumpModel`.
Extends: :class:`pints.toy.stochastic.MarkovJumpModel`.

Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion pints/toy/stochastic/_logistic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down
2 changes: 2 additions & 0 deletions pints/toy/stochastic/_michaelis_menten_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pints/toy/stochastic/_production_degradation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down
10 changes: 6 additions & 4 deletions pints/toy/stochastic/_schlogl_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@
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
3A \xrightarrow{k_2} 2A
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
----------
Expand Down