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
4 changes: 2 additions & 2 deletions .github/workflows/copyright-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Set up Python 3.8
- name: Set up Python 3.13
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.13
architecture: x64

- name: install chi
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/coverage-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: set up Python 3.8
- name: set up Python 3.13
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.13
architecture: x64

- name: install sundials
run: |
sudo apt-get update
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Set up Python 3.8
- name: Set up Python 3.13
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.13
architecture: x64

- name: install sundials (ubuntu)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/style-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Set up Python 3.8
- name: Set up Python 3.13
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.13
architecture: x64

- name: install chi
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/unit-test-os-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Set up Python 3.11
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.13

- name: install sundials (ubuntu)
if: ${{ matrix.os == 'ubuntu-latest' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test-python-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2024, David Augustin
Copyright (c) 2025, David Augustin
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
8 changes: 4 additions & 4 deletions chi/_log_pdfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ def __call__(self, parameters):
'An error occured while solving the mechanistic model: \n'
+ str(e) + '.\n A score of -infinity is returned.',
RuntimeWarning)
return -np.infty
return -np.inf

# Remember only error parameters
parameters = parameters[self._n_mechanistic_params:]
Expand Down Expand Up @@ -993,7 +993,7 @@ def evaluateS1(self, parameters):
+ str(e) + '.\n A score of -infinity is returned.',
RuntimeWarning)
n_parameters = len(parameters)
return -np.infty, np.full(shape=n_parameters, fill_value=np.infty)
return -np.inf, np.full(shape=n_parameters, fill_value=np.inf)

# Remember only error parameters
parameters = parameters[self._n_mechanistic_params:]
Expand Down Expand Up @@ -1606,7 +1606,7 @@ def __call__(self, parameters):
'An error occured while solving the mechanistic model: \n'
+ str(e) + '.\n A score of -infinity is returned.',
RuntimeWarning)
return -np.infty
return -np.inf

# Add noise to simulate measurements
if self._error_on_log_scale:
Expand Down Expand Up @@ -1832,7 +1832,7 @@ def evaluateS1(self, parameters):
'An error occured while solving the mechanistic model: \n'
+ str(e) + '.\n A score of -infinity is returned.',
RuntimeWarning)
return -np.infty, sensitivities[:self._n_parameters]
return -np.inf, sensitivities[:self._n_parameters]

# Add noise to simulate measurements
if self._error_on_log_scale:
Expand Down
40 changes: 0 additions & 40 deletions chi/tests/test_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,46 +810,6 @@ def test_run(self):
self.assertEqual(runs[1], 2)
self.assertEqual(runs[2], 3)

def test_run_catch_exception(self):
# Check failure of optimisation doesn't interrupt all runs
# (CMAES returns NAN for 1-dim problems)

# Get test data and model
problem = copy.deepcopy(self.problem)
problem.fix_parameters({
'global.drug_concentration': 1,
'global.kappa': 1,
'global.lambda_0': 1,
'global.lambda_1': 1,
'Sigma base': 1,
'Sigma rel.': 1})
problem.set_log_prior(pints.ComposedLogPrior(*[
pints.UniformLogPrior(1E-3, 1E1)]))
log_posterior = problem.get_log_posterior()

# Set up optmisation controller
optimiser = chi.OptimisationController(log_posterior)
optimiser.set_n_runs(3)
result = optimiser.run(n_max_iterations=10)

keys = result.keys()
self.assertEqual(len(keys), 5)
self.assertEqual(keys[0], 'ID')
self.assertEqual(keys[1], 'Parameter')
self.assertEqual(keys[2], 'Estimate')
self.assertEqual(keys[3], 'Score')
self.assertEqual(keys[4], 'Run')

parameters = result['Parameter'].unique()
self.assertEqual(len(parameters), 1)
self.assertEqual(parameters[0], 'global.tumour_volume')

runs = result['Run'].unique()
self.assertEqual(len(runs), 3)
self.assertEqual(runs[0], 1)
self.assertEqual(runs[1], 2)
self.assertEqual(runs[2], 3)

def test_set_optmiser(self):
optimiser = chi.OptimisationController(self.log_posterior_id_40)
optimiser.set_optimiser(pints.PSO)
Expand Down
2 changes: 1 addition & 1 deletion chi/tests/test_log_pdfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,7 @@ def test_call_and_compute_pointwise_ll(self):
self.assertAlmostEqual(score, ref_score)
n_obs = 7
self.assertEqual(pw_score.shape, (n_obs,))
self.assertEqual(np.sum(pw_score), score)
self.assertAlmostEqual(np.sum(pw_score), score)

# Reset number of outputs
self.model.set_outputs(['central.drug_amount', 'dose.drug_amount'])
Expand Down
86 changes: 43 additions & 43 deletions docs/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,46 @@ Summary of all functions and classes in chi

.. autosummary::

chi.AveragedPredictiveModel
chi.compute_pointwise_loglikelihood
chi.ConstantAndMultiplicativeGaussianErrorModel
chi.CovariateModel
chi.ErrorModel
chi.library.DataLibrary
chi.library.ModelLibrary
chi.LinearCovariateModel
chi.LogLikelihood
chi.LogNormalErrorModel
chi.LogNormalModel
chi.LogPosterior
chi.HeterogeneousModel
chi.HierarchicalLogLikelihood
chi.HierarchicalLogPosterior
chi.GaussianErrorModel
chi.GaussianModel
chi.InferenceController
chi.MechanisticModel
chi.MultiplicativeGaussianErrorModel
chi.OptimisationController
chi.PAMPredictiveModel
chi.PKPDModel
chi.plots.MarginalPosteriorPlot
chi.plots.ParameterEstimatePlot
chi.plots.PDTimeSeriesPlot
chi.plots.PKTimeSeriesPlot
chi.plots.PDPredictivePlot
chi.plots.PKPredictivePlot
chi.plots.ResidualPlot
chi.PooledModel
chi.PopulationModel
chi.PopulationPredictiveModel
chi.ReducedErrorModel
chi.PosteriorPredictiveModel
chi.PredictiveModel
chi.PriorPredictiveModel
chi.ProblemModellingController
chi.ReducedMechanisticModel
chi.ReducedPopulationModel
chi.SamplingController
chi.SBMLModel
chi.TruncatedGaussianModel
AveragedPredictiveModel
compute_pointwise_loglikelihood
ConstantAndMultiplicativeGaussianErrorModel
CovariateModel
ErrorModel
library.DataLibrary
library.ModelLibrary
LinearCovariateModel
LogLikelihood
LogNormalErrorModel
LogNormalModel
LogPosterior
HeterogeneousModel
HierarchicalLogLikelihood
HierarchicalLogPosterior
GaussianErrorModel
GaussianModel
InferenceController
MechanisticModel
MultiplicativeGaussianErrorModel
OptimisationController
PAMPredictiveModel
PKPDModel
plots.MarginalPosteriorPlot
plots.ParameterEstimatePlot
plots.PDTimeSeriesPlot
plots.PKTimeSeriesPlot
plots.PDPredictivePlot
plots.PKPredictivePlot
plots.ResidualPlot
PooledModel
PopulationModel
PopulationPredictiveModel
ReducedErrorModel
PosteriorPredictiveModel
PredictiveModel
PriorPredictiveModel
ProblemModellingController
ReducedMechanisticModel
ReducedPopulationModel
SamplingController
SBMLModel
TruncatedGaussianModel
6 changes: 3 additions & 3 deletions docs/source/api/mechanistic_models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Mechanistic Models
Mechanistic models in chi refer to any deterministic model that describes the
evolution of quantities of interest in time. In systems biology
such models are often inspired by biological mechanisms, which is why we go
with the name :class:`chi.MechanisticModel`. :class:`chi.MechanisticModel` by
with the name :class:`MechanisticModel`. :class:`MechanisticModel` by
no means have to be mechanism-based though, but may be any function of time
that you may deem interesting.

Chi provides two ways to specify mechanistic models: 1. you can use the
:class:`chi.MechanisticModel` base class an implement its methods yourself;
:class:`MechanisticModel` base class an implement its methods yourself;
2. you can specify the mechanistic model using the System Biology Markup
Language (SBML_) and instantiate the model using :class:`chi.SBMLModel`.
Language (SBML_) and instantiate the model using :class:`SBMLModel`.
For detailed examples how either of those can be done, we refer to the Getting
started.

Expand Down
24 changes: 12 additions & 12 deletions docs/source/getting_started/fitting_models_to_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -712,15 +712,15 @@ Reference to ErrorModel, LogPDF and PredictiveModel API

.. autosummary::

chi.ErrorModel
chi.GaussianErrorModel
chi.LogNormalErrorModel
chi.MultiplicativeGaussianErrorModel
chi.ConstantAndMultiplicativeGaussianErrorModel
chi.ReducedErrorModel
chi.LogLikelihood
chi.LogPosterior
chi.ProblemModellingController
chi.SamplingController
chi.PredictiveModel
chi.PosteriorPredictiveModel
ErrorModel
GaussianErrorModel
LogNormalErrorModel
MultiplicativeGaussianErrorModel
ConstantAndMultiplicativeGaussianErrorModel
ReducedErrorModel
LogLikelihood
LogPosterior
ProblemModellingController
SamplingController
PredictiveModel
PosteriorPredictiveModel
8 changes: 4 additions & 4 deletions docs/source/getting_started/mechanistic_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ Reference to MechanisticModel API

.. autosummary::

chi.MechanisticModel
chi.SBMLModel
chi.PKPDModel
chi.ReducedMechanisticModel
MechanisticModel
SBMLModel
PKPDModel
ReducedMechanisticModel
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
setup(
# Module name
name='chi-drm',
version='1.0.1',
version='1.0.2',
description='Package to model dose response dynamics',
long_description=readme,
long_description_content_type="text/markdown",
Expand All @@ -30,13 +30,13 @@

# List of dependencies
install_requires=[
'arviz>=0.11',
'arviz>=0.17',
'myokit>=1.34',
'numpy>=1.17',
'pandas>=0.24',
'pints>=0.4',
'plotly>=4.8.1',
'scipy<=1.12', # 07/2024 - ArviZ seems to not yet keep up with SciPy
'scipy>=1.11', # 07/2024 - ArviZ seems to not yet keep up with SciPy
'tqdm>=4.46.1',
'xarray>=0.19',
],
Expand Down
Loading