Skip to content

Commit

Permalink
Merge branch 'develop' into optimize_transpose
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored Jul 30, 2021
2 parents f3ac586 + e981d74 commit 56480a9
Show file tree
Hide file tree
Showing 61 changed files with 1,634 additions and 1,629 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/test_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ jobs:
run: |
scripts/buildSundials.sh
- name: Build cpputest
run: |
scripts/buildCpputest.sh
- name: Build AMICI
run: |
scripts/buildAmici.sh
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test_python_cplusplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:

- name: C++ tests
run: |
scripts/run-cpputest.sh
scripts/run-cpp-tests.sh
- name: Install python package
run: |
Expand All @@ -85,7 +85,7 @@ jobs:
--cov-report=xml:"${AMICI_DIR}/build/coverage_py.xml" \
--cov-append \
${AMICI_DIR}/python/tests
- name: example notebooks
run: |
scripts/runNotebook.sh python/examples/example_*/
Expand All @@ -96,7 +96,7 @@ jobs:
- name: Codecov Python
uses: codecov/codecov-action@v1
with:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./build/coverage_py.xml
flags: python
Expand Down Expand Up @@ -163,4 +163,4 @@ jobs:
- name: C++ tests
run: |
scripts/run-cpputest.sh
scripts/run-cpp-tests.sh
11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ build/*
build-debug/*
build_xcode/*
swig/python/build/*
tests/cpputest/build/*
tests/cpputest/build_xcode/*
tests/cpputest/Testing/*
tests/cpp/build/*
tests/cpp/build_xcode/*
tests/cpp/Testing/*

doc-venv/*
doc/*
Expand Down Expand Up @@ -136,8 +136,8 @@ tests/test/*
*/tests/fricker_2010_apoptosis_amici/*
*/tests/explicit_amici/*
*/tests/fixed_initial_amici/*
tests/cpputest/writeResults.h5
tests/cpputest/writeResults.h5.bak
tests/cpp/writeResults.h5
tests/cpp/writeResults.h5.bak
tests/sbml-test-suite/*
tests/sbml-test-suite/
tests/sedml-test-suite/
Expand Down Expand Up @@ -171,7 +171,6 @@ AMICI_guide.pdf

ThirdParty/bionetgen.tar.gz
ThirdParty/BioNetGen-*
ThirdParty/cpputest-master*
ThirdParty/doxygen/*
ThirdParty/mtocpp-master*
ThirdParty/sundials/build/*
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ if(BUILD_TESTS)
if(ENABLE_HDF5)
enable_testing()

add_subdirectory(tests/cpputest)
add_subdirectory(tests/cpp)
else()
message(WARNING "Cannot build tests with ENABLE_HDF5=OFF.")
endif()
Expand Down
12 changes: 6 additions & 6 deletions documentation/CI.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tests are integrated with CMake, see `make help` in the build directory.
## C++ unit and integration tests

To run C++ tests, build AMICI with `make` or `scripts/buildAll.sh`,
then run `scripts/run-cpputest.sh`.
then run `scripts/run-cpp-tests.sh`.


## Python unit and integration tests
Expand Down Expand Up @@ -58,7 +58,7 @@ To execute the Matlab test suite, run `tests/testModels.m`.

Many of our integration tests are model simulations. The simulation results
obtained from the Python and C++ are compared to results saved in an HDF5 file
(`tests/cpputest/expectedResults.h5`).
(`tests/cpp/expectedResults.h5`).
Settings and data for the test simulations are also specified in this file.

**Note:** The C++ code for the models is included in the repository under
Expand All @@ -73,7 +73,7 @@ the Matlab model import routines change.

This is done with

tests/cpputest/wrapTestModels.m
tests/cpp/wrapTestModels.m

**Note:** This is currently only possible from Matlab < R2018a. This should
change as soon as 1) all second-order sensitivity code is ported to C++/Python,
Expand All @@ -84,13 +84,13 @@ for Python.
### Regenerating expected results

To update test results, run `make test` in the build directory,
replace `tests/cpputest/expectedResults.h5` by
`tests/cpputest/writeResults.h5.bak`
replace `tests/cpp/expectedResults.h5` by
`tests/cpp/writeResults.h5.bak`
[ONLY DO THIS AFTER TRIPLE CHECKING CORRECTNESS OF RESULTS]
Before replacing the test results, confirm that only expected datasets have
changed, e.g. using

h5diff -v --relative 1e-8 tests/cpputest/expectedResults.h5 tests/cpputest/writeResults.h5.bak | less
h5diff -v --relative 1e-8 tests/cpp/expectedResults.h5 tests/cpp/writeResults.h5.bak | less


## Adding/Updating tests
Expand Down
2 changes: 1 addition & 1 deletion documentation/cpp_installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ To use AMICI from C++, run the

.. code-block:: bash
./scripts/buildSuiteSparse.sh
./scripts/buildSundials.sh
./scripts/buildSuitesparse.sh
./scripts/buildAmici.sh
script to build the AMICI library.
Expand Down
6 changes: 3 additions & 3 deletions documentation/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ process described below:
(our CI pipeline will do this for you)

- When adding new functionality, please also provide test cases (see
``tests/cpputest/`` and
``tests/cpp/`` and
`documentation/CI.md <documentation/CI.md>`__)

- Write meaningful commit messages

- Run all tests to ensure nothing was broken (`more
details <documentation/CI.md>`__)

- Run ``scripts/buildAll.sh && scripts/run-cpputest.sh``.
- Run ``scripts/buildAll.sh && scripts/run-cpp-tests.sh``.

- If you made changes to the Matlab or C++ code and have a Matlab
license, please also run ``tests/cpputest/wrapTestModels.m`` and
license, please also run ``tests/cpp/wrapTestModels.m`` and
``tests/testModels.m``

- If you made changes to the Python or C++ code, run
Expand Down
14 changes: 7 additions & 7 deletions matlab/tests/testModels.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ function testModels()

model_dir = [fileparts(mfilename('fullpath')) '/../../models/'];
cd(fileparts(mfilename('fullpath')))
addpath(genpath('../../tests/cpputest'));
addpath(genpath('../../tests/cpp'));
addpath(genpath('../examples'));
% wrapTestModels()

cd(fileparts(mfilename('fullpath')))
hdf5file = fullfile(fileparts(mfilename('fullpath')), ...
'../../tests/cpputest', 'expectedResults.h5');
'../../tests/cpp', 'expectedResults.h5');

info = h5info(hdf5file);
for imodel = 1:length(info.Groups)
modelname = info.Groups(imodel).Name(2:end);

if(~isempty(regexp(modelname,'^model_neuron')))
model_atol = 1e-9;
model_rtol = 1e-4;
Expand All @@ -42,18 +42,18 @@ function testModels()
if(ismember(testname, ignoredTests))
continue
end

display(testname);

[results,options,data,t,theta,kappa] = readDataFromHDF5(info.Groups(imodel).Groups(itest),hdf5file);

% rebuild model
old_path = addpath([model_dir modelname]);
old_pwd = cd([model_dir modelname]);
rebuild = str2func(['rebuild_' modelname]);
rebuild();
cd(old_pwd);

sol = getResults(modelname,options,data,t,theta,kappa);
compareResults(sol,results);
path(old_path);
Expand Down
26 changes: 12 additions & 14 deletions python/tests/test_pregenerated_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
"""Run simulations with Matlab-AMICI pre-generated models and verify using
saved expectations."""

import h5py
import amici
import os
from amici.gradient_check import check_derivatives, check_results
import pytest
from pathlib import Path

import amici
import h5py
import numpy as np
import pytest
from amici.gradient_check import check_derivatives, check_results


options_file = os.path.join(os.path.dirname(__file__), '..', '..',
'tests', 'cpputest', 'testOptions.h5')
expected_results_file = os.path.join(os.path.dirname(__file__), '..', '..',
'tests', 'cpputest', 'expectedResults.h5')
cpp_test_dir = Path(__file__).parents[2] / 'tests' / 'cpp'
options_file = str(cpp_test_dir / 'testOptions.h5')
expected_results_file = str(cpp_test_dir / 'expectedResults.h5')
expected_results = h5py.File(expected_results_file, 'r')

model_cases = [(sub_test, case)
Expand Down Expand Up @@ -43,10 +42,9 @@ def test_pregenerated_model(sub_test, case):
else:
model_name = sub_test

model_swig_folder = \
os.path.join(os.path.dirname(__file__), '..', '..', 'build', 'tests',
'cpputest', f'external_{model_name}-prefix',
'src', f'external_{model_name}-build', 'swig')
model_swig_folder = str(Path(__file__).parents[2] / 'build' / 'tests'
/ 'cpp' / f'external_{model_name}-prefix' / 'src'
/ f'external_{model_name}-build' / 'swig')

test_model_module = amici.import_model_module(
module_name=model_name, module_path=model_swig_folder)
Expand All @@ -64,7 +62,7 @@ def test_pregenerated_model(sub_test, case):
edata = None
if 'data' in expected_results[sub_test][case].keys():
edata = amici.readSimulationExpData(
expected_results_file,
str(expected_results_file),
f'/{sub_test}/{case}/data', model.get()
)
rdata = amici.runAmiciSimulation(model, solver,
Expand Down
9 changes: 2 additions & 7 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ This directory contains a number of build, installation, and CI scripts.

Download and build
[BioNetGen](https://www.csb.pitt.edu/Faculty/Faeder/?page_id=409) (required for some tests)

* `buildCpputest.sh`

Download and build [CppUTest](https://cpputest.github.io/)
(required for C++ test suite)


* `buildSuiteSparse.sh`

Build [SuiteSparse](http://faculty.cse.tamu.edu/davis/suitesparse.html)
Expand Down Expand Up @@ -64,7 +59,7 @@ This directory contains a number of build, installation, and CI scripts.

Run static code analysis

* `run-cpputest.sh`
* `run-cpp-tests.sh`

Run C++ unit and integration tests

Expand Down
23 changes: 11 additions & 12 deletions scripts/buildAmici.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# Build libamici
#
set -e
set -eou pipefail

cmake=${CMAKE:-cmake}
make=${MAKE:-make}

Expand All @@ -12,28 +13,26 @@ amici_build_dir="${amici_path}/build"
mkdir -p "${amici_build_dir}"
cd "${amici_build_dir}"

cpputest_build_dir="${amici_path}/ThirdParty/cpputest-master/build/"

if [[ $TRAVIS = true ]] || [[ $GITHUB_ACTIONS = true ]] || [[ $ENABLE_AMICI_DEBUGGING = TRUE ]];
then
if [ "${TRAVIS:-}" = true ] ||
[ "${GITHUB_ACTIONS:-}" = true ] ||
[ "${ENABLE_AMICI_DEBUGGING:-}" = TRUE ]; then
# Running on CI server
build_type="Debug"
else
build_type="RelWithDebInfo"
fi

CppUTest_DIR=${cpputest_build_dir} \
${cmake} \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror" \
-DCMAKE_BUILD_TYPE=$build_type \
-DPython3_EXECUTABLE="$(command -v python3)" ..
${cmake} \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror" \
-DCMAKE_BUILD_TYPE=$build_type \
-DPython3_EXECUTABLE="$(command -v python3)" ..

# build, with or without sonarcloud wrapper
if [[ "$CI_SONARCLOUD" == "TRUE" ]]; then
if [ "${CI_SONARCLOUD:-}" = "TRUE" ]; then
build-wrapper-linux-x86-64 \
--out-dir "${amici_path}/bw-output" \
cmake --build . --parallel
elif [[ "$TRAVIS" == "true" ]]; then
elif [ "${TRAVIS:-}" = "true" ]; then
cmake --build .
${make} python-sdist
else
Expand Down
32 changes: 0 additions & 32 deletions scripts/buildCpputest.sh

This file was deleted.

1 change: 0 additions & 1 deletion scripts/buildDependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ script_path=$(cd "$script_path" && pwd)

"${script_path}/buildSuiteSparse.sh"
"${script_path}/buildSundials.sh"
"${script_path}/buildCpputest.sh"
"${script_path}/buildBNGL.sh"
10 changes: 4 additions & 6 deletions scripts/buildXcode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@ CMAKE=${CMAKE:-cmake}
${AMICI_PATH}/scripts/buildSuiteSparse.sh
${AMICI_PATH}/scripts/buildSundials.sh
${AMICI_PATH}/scripts/buildAmici.sh
${AMICI_PATH}/scripts/buildCpputest.sh


cp ${AMICI_PATH}/tests/cpputest/expectedResults.h5 ./expectedResults.h5
cp ${AMICI_PATH}/tests/cpp/expectedResults.h5 ./expectedResults.h5

mkdir -p ${AMICI_PATH}/build_xcode
cd ${AMICI_PATH}/build_xcode
CPPUTEST_BUILD_DIR=${AMICI_PATH}/ThirdParty/cpputest-master/build/
CppUTest_DIR=${CPPUTEST_BUILD_DIR} ${CMAKE} -G"Xcode" -DCMAKE_BUILD_TYPE=Debug ..
${CMAKE} -G"Xcode" -DCMAKE_BUILD_TYPE=Debug ..

for model in steadystate robertson neuron neuron_o2 jakstat_adjoint jakstat_adjoint_o2 dirac events nested_events
do
cp ${AMICI_PATH}/build/tests/cpputest/external_model_${model}-prefix/src/external_model_${model}-build/libmodel_${model}.a \
${AMICI_PATH}/build_xcode/tests/cpputest/external_model_${model}-prefix/src/external_model_${model}-build/libmodel_${model}.a
cp ${AMICI_PATH}/build/tests/cpp/external_model_${model}-prefix/src/external_model_${model}-build/libmodel_${model}.a \
${AMICI_PATH}/build_xcode/tests/cpp/external_model_${model}-prefix/src/external_model_${model}-build/libmodel_${model}.a
done
Loading

0 comments on commit 56480a9

Please sign in to comment.