Skip to content

Commit

Permalink
Merge branch 'develop' into ExpData_clear_observations
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored Jan 8, 2024
2 parents 04f91e0 + 3d01ebb commit cb65c80
Show file tree
Hide file tree
Showing 36 changed files with 284 additions and 138 deletions.
31 changes: 31 additions & 0 deletions .github/actions/install-macos-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Install AMICI dependencies for MacOS
description: Install AMICI dependencies for MacOS

runs:
using: "composite"
steps:
# use all available cores
- run: echo "AMICI_PARALLEL_COMPILE=" >> $GITHUB_ENV
shell: bash

# AMICI repository root
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV
shell: bash

# BioNetGen path
- run: echo "BNGPATH=${AMICI_DIR}/ThirdParty/BioNetGen-2.7.0" >> $GITHUB_ENV
shell: bash

# CMake hints
# Ensure CMake is using the python version that we will use for the python tests later on
- run: echo "PYTHON_EXECUTABLE=${Python3_ROOT_DIR}/bin/python3" >> $GITHUB_ENV
shell: bash
- run: echo "OpenMP_ROOT=$(brew --prefix)/opt/libomp" >> $GITHUB_ENV
shell: bash
- run: echo "BOOST_ROOT=$(brew --prefix)/opt/boost" >> $GITHUB_ENV
shell: bash

# install amici dependencies
- name: homebrew
run: brew install hdf5 swig gcc libomp boost
shell: bash
60 changes: 47 additions & 13 deletions .github/workflows/test_python_cplusplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ jobs:

# TODO: Include notebooks in coverage report

osx:
name: Tests OSX
macos_cpp_py:
name: Tests MacOS C++/Python
runs-on: macos-latest

steps:
Expand All @@ -231,16 +231,11 @@ jobs:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow

- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV
- run: echo "BNGPATH=${AMICI_DIR}/ThirdParty/BioNetGen-2.7.0" >> $GITHUB_ENV
# Ensure CMake is using the python version that we will use for the python tests later on
- run: echo "PYTHON_EXECUTABLE=${Python3_ROOT_DIR}/bin/python3" >> $GITHUB_ENV
- run: echo "OpenMP_ROOT=$(brew --prefix)/opt/libomp" >> $GITHUB_ENV
- run: echo "BOOST_ROOT=$(brew --prefix)/opt/boost" >> $GITHUB_ENV
- name: Install dependencies
uses: ./.github/actions/install-macos-dependencies

# install amici dependencies
- name: homebrew
run: brew install hdf5 swig gcc cppcheck libomp boost
run: brew install cppcheck

- name: Build AMICI
run: scripts/buildAll.sh
Expand All @@ -254,8 +249,47 @@ jobs:
- name: cppcheck
run: scripts/run-cppcheck.sh

- name: Python tests
run: scripts/run-python-tests.sh

- name: C++ tests
run: scripts/run-cpp-tests.sh

- name: Python tests
run: |
scripts/run-python-tests.sh \
test_pregenerated_models.py \
test_splines_short.py \
test_misc.py
macos_python:
name: Tests MacOS Python
runs-on: macos-latest

steps:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- uses: actions/checkout@v3
- run: git fetch --prune --unshallow

- name: Install dependencies
uses: ./.github/actions/install-macos-dependencies

- name: Install python package
run: |
pip show numpy > /dev/null || python3 -m pip install numpy
scripts/installAmiciSource.sh
- name: Check OpenMP support
run: source build/venv/bin/activate && python -c "import amici; import sys; sys.exit(not amici.compiledWithOpenMP())"

- name: Get BioNetGen
run: scripts/buildBNGL.sh

- name: Python tests
run: |
scripts/run-python-tests.sh \
--ignore=test_pregenerated_models.py \
--ignore=test_splines_short.py \
--ignore=test_misc.py
30 changes: 15 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black", "--filter-files", "--line-length", "79"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
Expand All @@ -16,15 +10,21 @@ repos:
args: [--allow-multiple-documents]
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.7.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.11
hooks:
- id: black-jupyter
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.11
args: ["--line-length", "79"]
# Run the linter.
- id: ruff
args:
- --fix
- --config
- python/sdist/pyproject.toml

# Run the formatter.
- id: ruff-format
args:
- --config
- python/sdist/pyproject.toml

exclude: '^(ThirdParty|models)/'
2 changes: 1 addition & 1 deletion documentation/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/stable/config

import os
import re
import subprocess
Expand All @@ -18,6 +17,7 @@
import exhale_multiproject_monkeypatch
import mock
import pandas as pd
import sphinx
import sympy as sp
from exhale import configs as exhale_configs
from sphinx.transforms.post_transforms import ReferencesResolver
Expand Down
61 changes: 31 additions & 30 deletions include/amici/edata.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ class ReturnData;

/**
* @brief ExpData carries all information about experimental or
* condition-specific data
* condition-specific data.
*/
class ExpData : public SimulationParameters {

public:
/**
* @brief default constructor
* @brief Default constructor.
*/
ExpData() = default;

/**
* @brief Copy constructor, needs to be declared to be generated in
* swig
* @brief Copy constructor.
*/
// needs to be declared to be wrapped by SWIG
ExpData(ExpData const&) = default;

/**
* @brief constructor that only initializes dimensions
* @brief Constructor that only initializes dimensions.
*
* @param nytrue Number of observables
* @param nztrue Number of event outputs
Expand Down Expand Up @@ -154,6 +154,16 @@ class ExpData : public SimulationParameters {
/**
* @brief Set output timepoints.
*
* If the number of timepoint increases, this will grow the
* observation/sigma matrices and fill new entries with NaN.
* If the number of timepoints decreases, this will shrink the
* observation/sigma matrices.
*
* Note that the mapping from timepoints to measurements will not be
* preserved. E.g., say there are measurements at t = 2, and this
* function is called with [1, 2], then the old measurements will belong to
* t = 1.
*
* @param ts timepoints
*/
void setTimepoints(std::vector<realtype> const& ts);
Expand Down Expand Up @@ -225,7 +235,7 @@ class ExpData : public SimulationParameters {
void setObservedDataStdDev(std::vector<realtype> const& observedDataStdDev);

/**
* @brief Set indentical standard deviation for all measurements.
* @brief Set identical standard deviation for all measurements.
*
* @param stdDev standard deviation (dimension: scalar)
*/
Expand Down Expand Up @@ -278,26 +288,23 @@ class ExpData : public SimulationParameters {
realtype const* getObservedDataStdDevPtr(int it) const;

/**
* @brief set function that copies observed event data from input to
* ExpData::observedEvents
* @brief Set observed event data.
*
* @param observedEvents observed data (dimension: nmaxevent x nztrue,
* row-major)
*/
void setObservedEvents(std::vector<realtype> const& observedEvents);

/**
* @brief set function that copies observed event data for specific event
* observable
* @brief Set observed event data for specific event observable.
*
* @param observedEvents observed data (dimension: nmaxevent)
* @param iz observed event data index
*/
void setObservedEvents(std::vector<realtype> const& observedEvents, int iz);

/**
* @brief get function that checks whether event data at specified indices
* has been set
* @brief Check whether event data at specified indices has been set.
*
* @param ie event index
* @param iz event observable index
Expand All @@ -306,42 +313,38 @@ class ExpData : public SimulationParameters {
bool isSetObservedEvents(int ie, int iz) const;

/**
* @brief get function that copies data from ExpData::mz to output
* @brief Get observed event data.
*
* @return observed event data
*/
std::vector<realtype> const& getObservedEvents() const;

/**
* @brief get function that returns a pointer to observed data at ieth
* occurrence
* @brief Get pointer to observed data at ie-th occurrence.
*
* @param ie event occurrence
*
* @return pointer to observed event data at ieth occurrence
* @return pointer to observed event data at ie-th occurrence
*/
realtype const* getObservedEventsPtr(int ie) const;

/**
* @brief set function that copies data from input to
* ExpData::observedEventsStdDev
* @brief Set standard deviation of observed event data.
*
* @param observedEventsStdDev standard deviation of observed event data
*/
void
setObservedEventsStdDev(std::vector<realtype> const& observedEventsStdDev);

/**
* @brief set function that sets all ExpData::observedDataStdDev to the
* input value
* @brief Set standard deviation of observed event data.
*
* @param stdDev standard deviation (dimension: scalar)
*/
void setObservedEventsStdDev(realtype stdDev);

/**
* @brief set function that copies standard deviation of observed data for
* specific observable
* @brief Set standard deviation of observed data for a specific observable.
*
* @param observedEventsStdDev standard deviation of observed data
* (dimension: nmaxevent)
Expand All @@ -352,17 +355,16 @@ class ExpData : public SimulationParameters {
);

/**
* @brief set function that sets all standard deviation of a specific
* observable to the input value
* @brief Set all standard deviations of a specific event-observable.
*
* @param stdDev standard deviation (dimension: scalar)
* @param iz observed data index
*/
void setObservedEventsStdDev(realtype stdDev, int iz);

/**
* @brief get function that checks whether standard deviation of even data
* at specified indices has been set
* @brief Check whether standard deviation of event data
* at specified indices has been set.
*
* @param ie event index
* @param iz event observable index
Expand All @@ -371,16 +373,15 @@ class ExpData : public SimulationParameters {
bool isSetObservedEventsStdDev(int ie, int iz) const;

/**
* @brief get function that copies data from ExpData::observedEventsStdDev
* to output
* @brief Get standard deviation of observed event data.
*
* @return standard deviation of observed event data
*/
std::vector<realtype> const& getObservedEventsStdDev() const;

/**
* @brief get function that returns a pointer to standard deviation of
* observed event data at ie-th occurrence
* @brief Get pointer to standard deviation of
* observed event data at ie-th occurrence.
*
* @param ie event occurrence
*
Expand Down
2 changes: 1 addition & 1 deletion include/amici/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct LogItem {
, message(message){};

/** Severity level */
LogSeverity severity;
LogSeverity severity = LogSeverity::error;

/** Short identifier for the logged event */
std::string identifier;
Expand Down
6 changes: 5 additions & 1 deletion include/amici/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ class Model : public AbstractModel, public ModelDimensions {
std::vector<int> const& getReinitializationStateIdxs() const;

/** Flag indicating Matlab- or Python-based model generation */
bool pythonGenerated;
bool pythonGenerated = false;

/**
* @brief getter for dxdotdp (matlab generated)
Expand Down Expand Up @@ -2020,7 +2020,11 @@ class Model : public AbstractModel, public ModelDimensions {
* Indicates whether the result of every call to `Model::f*` should be
* checked for finiteness
*/
#ifdef NDEBUG
bool always_check_finite_{false};
#else
bool always_check_finite_{true};
#endif

/** indicates whether sigma residuals are to be added for every datapoint */
bool sigma_res_{false};
Expand Down
6 changes: 6 additions & 0 deletions include/amici/simulation_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class SimulationParameters {
this->parameters.size(), ParameterScaling::none
)) {}

#ifndef SWIGPYTHON
/*
* include/amici/simulation_parameters.h:71: Warning 509: Overloaded method amici::SimulationParameters::SimulationParameters(std::vector< amici::realtype,std::allocator< amici::realtype > >,std::vector< amici::realtype,std::allocator< amici::realtype > >,std::vector< amici::realtype,std::allocator< amici::realtype > >) effectively ignored,
* include/amici/simulation_parameters.h:54: Warning 509: as it is shadowed by amici::SimulationParameters::SimulationParameters(std::vector< amici::realtype,std::allocator< amici::realtype > >,std::vector< amici::realtype,std::allocator< amici::realtype > >,std::vector< int,std::allocator< int > >).
*/
/**
* @brief Constructor
* @param fixedParameters Model constants
Expand Down Expand Up @@ -69,6 +74,7 @@ class SimulationParameters {
this->parameters.size(), ParameterScaling::none
))
, ts_(std::move(timepoints)) {}
#endif

/**
* @brief Set reinitialization of all states based on model constants for
Expand Down
Loading

0 comments on commit cb65c80

Please sign in to comment.