Skip to content

Commit

Permalink
Merge branch 'fix_install_mac' into extend_dataframes
Browse files Browse the repository at this point in the history
  • Loading branch information
FFroehlich committed Mar 5, 2024
2 parents fae874e + 0fea90d commit 9063123
Show file tree
Hide file tree
Showing 24 changed files with 128 additions and 90 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test_petab_test_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,27 @@ jobs:

- name: Install petab
run: |
source ./build/venv/bin/activate \
source ./venv/bin/activate \
&& pip3 install wheel pytest shyaml pytest-cov pysb
# retrieve test models
- name: Download and install PEtab test suite
run: |
git clone --depth 1 --branch main \
https://github.com/PEtab-dev/petab_test_suite \
&& source ./build/venv/bin/activate \
&& source ./venv/bin/activate \
&& cd petab_test_suite && pip3 install -e .
- name: Run PEtab-related unit tests
run: |
source ./build/venv/bin/activate \
source ./venv/bin/activate \
&& pytest --cov-report=xml:coverage.xml \
--cov=./ python/tests/test_*petab*.py python/tests/petab/
# run test models
- name: Run PEtab test suite
run: |
source ./build/venv/bin/activate \
source ./venv/bin/activate \
&& AMICI_PARALLEL_COMPILE="" pytest -v \
--cov-report=xml:coverage.xml \
--cov-append \
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test_python_cplusplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ jobs:
run: scripts/installAmiciSource.sh

- name: Check OpenMP support
run: source build/venv/bin/activate && python -c "import amici; import sys; sys.exit(not amici.compiledWithOpenMP())"
run: source venv/bin/activate && python -c "import amici; import sys; sys.exit(not amici.compiledWithOpenMP())"

- name: Python tests (part 1)
run: |
source build/venv/bin/activate \
source venv/bin/activate \
&& pytest \
--ignore-glob=*petab* \
--ignore-glob=*test_splines.py \
Expand All @@ -64,7 +64,7 @@ jobs:
- name: Python tests splines
if: ${{ github.base_ref == 'master' || github.event.merge_group.base_ref == 'master'}}
run: |
source build/venv/bin/activate \
source venv/bin/activate \
&& pytest \
--cov=amici \
--cov-report=xml:"${AMICI_DIR}/build/coverage_py.xml" \
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:

- name: Python tests
run: |
source build/venv/bin/activate \
source venv/bin/activate \
&& pytest \
--cov=amici \
--cov-report=xml:"${AMICI_DIR}/build/coverage_py.xml" \
Expand Down Expand Up @@ -214,7 +214,7 @@ jobs:

- name: Install notebook dependencies
run: |
source build/venv/bin/activate \
source venv/bin/activate \
&& pip install jax[cpu]
- name: example notebooks
Expand Down Expand Up @@ -251,7 +251,7 @@ jobs:
run: scripts/installAmiciSource.sh

- name: Check OpenMP support
run: source build/venv/bin/activate && python -c "import amici; import sys; sys.exit(not amici.compiledWithOpenMP())"
run: source venv/bin/activate && python -c "import amici; import sys; sys.exit(not amici.compiledWithOpenMP())"

- name: cppcheck
run: scripts/run-cppcheck.sh
Expand Down Expand Up @@ -296,7 +296,7 @@ jobs:
scripts/installAmiciSource.sh
- name: Check OpenMP support
run: source build/venv/bin/activate && python -c "import amici; import sys; sys.exit(not amici.compiledWithOpenMP())"
run: source venv/bin/activate && python -c "import amici; import sys; sys.exit(not amici.compiledWithOpenMP())"

- name: Get BioNetGen
run: scripts/buildBNGL.sh
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_python_ver_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ jobs:
run: scripts/installAmiciSource.sh

# install pysb before sympy to allow for sympy>=1.12 (https://github.com/pysb/pysb/commit/e83937cb8c74afc9b2fa96595b68464946745f33)
- run: source build/venv/bin/activate && pip3 install git+https://github.com/pysb/pysb
- run: source venv/bin/activate && pip3 install git+https://github.com/pysb/pysb

# until sympy>1.12 is released
- run: source build/venv/bin/activate && pip3 install git+https://github.com/sympy/sympy.git@master
- run: source venv/bin/activate && pip3 install git+https://github.com/sympy/sympy.git@master
if: matrix.python-version == '3.12'

- name: Python tests
run: |
source build/venv/bin/activate \
source venv/bin/activate \
&& python3 -m pytest \
--durations=10 \
--ignore-glob=*petab* \
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,4 @@ CS_Signalling_ERBB_RAS_AKT/
cache_fiddy/*
debug/*
tests/benchmark-models/cache_fiddy/*
venv/*
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,12 @@ target_link_libraries(
SUNDIALS::sunnonlinsolfixedpoint_static
SUNDIALS::cvodes_static
SUNDIALS::idas_static
${BLAS_LIBRARIES}
$<$<BOOL:${Boost_CHRONO_FOUND}>:Boost::chrono>
$<$<BOOL:${OpenMP_FOUND}>:OpenMP::OpenMP_CXX>
${CMAKE_DL_LIBS}
PRIVATE
$<$<BOOL:${SUNDIALS_SUPERLUMT_ENABLE}>:SUNDIALS::sundials_sunlinsolsuperlumt>
BLAS::BLAS
)

if(HDF5_FOUND)
Expand Down
2 changes: 2 additions & 0 deletions cmake/AmiciConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ if(@HDF5_FOUND@)
REQUIRED)
endif()

find_package(BLAS)

include("${CMAKE_CURRENT_LIST_DIR}/AmiciTargets.cmake")

check_required_components(Amici)
1 change: 1 addition & 0 deletions include/amici/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ constexpr int AMICI_TOO_MUCH_WORK= -1;
constexpr int AMICI_TOO_MUCH_ACC= -2;
constexpr int AMICI_ERR_FAILURE= -3;
constexpr int AMICI_CONV_FAILURE= -4;
constexpr int AMICI_LSETUP_FAIL= -6;
constexpr int AMICI_RHSFUNC_FAIL= -8;
constexpr int AMICI_FIRST_RHSFUNC_ERR= -9;
constexpr int AMICI_ILL_INPUT= -22;
Expand Down
7 changes: 5 additions & 2 deletions include/amici/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -1334,10 +1334,12 @@ class Model : public AbstractModel, public ModelDimensions {
*
* @param array
* @param model_quantity The model quantity `array` corresponds to
* @param t Current timepoint
* @return
*/
int checkFinite(
gsl::span<realtype const> array, ModelQuantity model_quantity
gsl::span<realtype const> array, ModelQuantity model_quantity,
realtype t
) const;
/**
* @brief Check if the given array has only finite elements.
Expand All @@ -1347,11 +1349,12 @@ class Model : public AbstractModel, public ModelDimensions {
* @param array Flattened matrix
* @param model_quantity The model quantity `array` corresponds to
* @param num_cols Number of columns of the non-flattened matrix
* @param t Current timepoint
* @return
*/
int checkFinite(
gsl::span<realtype const> array, ModelQuantity model_quantity,
size_t num_cols
size_t num_cols, realtype t
) const;

/**
Expand Down
2 changes: 2 additions & 0 deletions python/sdist/amici/MANIFEST.template.in
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
include *.cpp *.h
include CMakeLists.txt
recursive-include swig/ *
2 changes: 1 addition & 1 deletion python/sdist/amici/cxxcodeprinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def csc_matrix(
for col in range(ncols):
symbol_col_ptrs.append(idx)
for row in range(nrows):
if matrix[row, col] == 0:
if matrix[row, col].is_zero:
continue

symbol_row_vals.append(row)
Expand Down
4 changes: 2 additions & 2 deletions python/sdist/amici/de_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2115,7 +2115,7 @@ def state_is_constant(self, ix: int) -> bool:
if isinstance(state, AlgebraicState):
return False

return state.get_dt() == 0.0
return state.get_dt().is_zero

def conservation_law_has_multispecies(self, tcl: ConservationLaw) -> bool:
"""
Expand Down Expand Up @@ -2179,7 +2179,7 @@ def _get_unique_root(
return None

for root in roots:
if sp.simplify(root_found - root.get_val()) == 0:
if sp.simplify(root_found - root.get_val()).is_zero:
return root.get_id()

# create an event for a new root function
Expand Down
5 changes: 4 additions & 1 deletion scripts/buildAmici.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ else
fi

# required for build swig interface
pip show numpy > /dev/null || python3 -m pip install numpy
python3 -m venv "${amici_path}/venv"
source "${amici_path}/venv/bin/activate"
export PYTHON_EXECUTABLE="${amici_path}/venv/bin/python"
pip3 show numpy > /dev/null || python3 -m pip install numpy

${cmake} \
-Wdev -DAMICI_CXX_OPTIONS="-Wall;-Wextra${extra_cxx_flags}" \
Expand Down
10 changes: 5 additions & 5 deletions scripts/installAmiciArchive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ rm -f ${AMICI_PATH}/python/sdist/amici/amici_without_hdf5.py

# test install from archive
set +e
python3 -m venv ${AMICI_PATH}/build/venvArchive --clear
python3 -m venv ${AMICI_PATH}/venvArchive --clear
# in case this fails (usually due to missing ensurepip, try getting pip
# manually
if [[ $? ]]; then
set -e
python3 -m venv ${AMICI_PATH}/build/venvArchive --clear --without-pip
source ${AMICI_PATH}/build/venvArchive/bin/activate
python3 -m venv ${AMICI_PATH}/venvArchive --clear --without-pip
source ${AMICI_PATH}/venvArchive/bin/activate
curl https://bootstrap.pypa.io/get-pip.py -o ${AMICI_PATH}/build/get-pip.py
python ${AMICI_PATH}/build/get-pip.py
python ${AMICI_PATH}/get-pip.py
else
set -e
source ${AMICI_PATH}/build/venvArchive/bin/activate
source ${AMICI_PATH}/venvArchive/bin/activate
fi

pip install $(ls -t ${AMICI_PATH}/build/python/amici-*.tar.gz | head -1)
Expand Down
2 changes: 1 addition & 1 deletion scripts/installAmiciSource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
SCRIPT_PATH=$(dirname $BASH_SOURCE)
AMICI_PATH=$(cd "$SCRIPT_PATH/.." && pwd)

venv_dir="${AMICI_PATH}/build/venv"
venv_dir="${AMICI_PATH}/venv"
# Disabled until cmake package is made compatible with updated setup.py
#make python-wheel
#pip3 install --user --prefix= `ls -t ${AMICI_PATH}/build/python/amici-*.whl | head -1`
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-SBMLTestsuite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if [[ ! -d "tests/sbml-test-suite" ]]; then
mv -f ./sbml-test-suite ./tests/sbml-test-suite
fi

source build/venv/bin/activate
source venv/bin/activate
pip show pytest-xdist > /dev/null 2>&1 || pip install pytest-xdist
pip install coverage pytest-cov

Expand Down
2 changes: 1 addition & 1 deletion scripts/run-codecov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
script_path=$(dirname $BASH_SOURCE)
amici_path=$(cd "$script_path"/.. && pwd)

source "${amici_path}"/build/venv/bin/activate
source "${amici_path}"/venv/bin/activate
pip install coverage pytest pytest-cov

if [[ -z "${BNGPATH}" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-python-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [[ -z "${BNGPATH}" ]]; then
fi

cd "${amici_path}"/python/tests
source "${amici_path}"/build/venv/bin/activate
source "${amici_path}"/venv/bin/activate

# PEtab tests are run separately
pytest \
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-valgrind-py.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [ $# -eq 0 ]
then
# No arguments supplied, run all tests
cd "${amici_path}"/python/tests
source "${amici_path}"/build/venv/bin/activate
source "${amici_path}"/venv/bin/activate
command=(python -m pytest -vv --ignore-glob=*petab* -W 'ignore:Signature ')
# ^ ignores the following warning that occurs only under valgrind,
# e.g. `valgrind python -c "import h5py"`:
Expand Down
5 changes: 3 additions & 2 deletions src/amici.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ std::map<int, std::string> simulation_status_to_str_map = {
{AMICI_MAX_TIME_EXCEEDED, "AMICI_MAX_TIME_EXCEEDED"},
{AMICI_SUCCESS, "AMICI_SUCCESS"},
{AMICI_NOT_RUN, "AMICI_NOT_RUN"},
{AMICI_LSETUP_FAIL, "AMICI_LSETUP_FAIL"},
};

std::unique_ptr<ReturnData> runAmiciSimulation(
Expand Down Expand Up @@ -222,8 +223,8 @@ std::unique_ptr<ReturnData> runAmiciSimulation(

try {
rdata->processSimulationObjects(
preeq.get(), fwd.get(), bwd_success ? bwd.get() : nullptr, posteq.get(),
model, solver, edata
preeq.get(), fwd.get(), bwd_success ? bwd.get() : nullptr,
posteq.get(), model, solver, edata
);
} catch (std::exception const& ex) {
rdata->status = AMICI_ERROR;
Expand Down
Loading

0 comments on commit 9063123

Please sign in to comment.