Skip to content

Commit

Permalink
Merge branch 'develop' into test_numpy2
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored May 31, 2024
2 parents 38edece + 2b8c6a2 commit 6cf22a7
Show file tree
Hide file tree
Showing 29 changed files with 470 additions and 110 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ updates:
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-patch", "version-update:semver-minor"]
target-branch: "develop"
4 changes: 2 additions & 2 deletions .github/workflows/test_matlab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV

- name: Install MATLAB
uses: matlab-actions/setup-matlab@v1
uses: matlab-actions/setup-matlab@v2
- name: Run script
uses: matlab-actions/run-command@v1
uses: matlab-actions/run-command@v2
with:
command: cd matlab; installAMICI; addpath tests; testModels
4 changes: 2 additions & 2 deletions .github/workflows/test_python_cplusplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cache/pooch
Expand Down Expand Up @@ -273,7 +273,7 @@ jobs:

steps:
- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/Library/Caches/pooch
Expand Down
52 changes: 50 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,58 @@

## v0.X Series

### v0.25.1 (2024-05-16)

**Fixes**
* Avoid clashes with sympy-entities in `plot_expressions`
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2440
* PEtab: fix KeyErrors for missing parameters in `fill_in_parameters`
(default values are now used if only a subset of parameters is provided)
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2449
* CMake: Fix Intel MKL detection when not using environment modules
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2443
* CMake: Fix some issues with multi-config generators
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2445

**Full Changelog**: https://github.com/AMICI-dev/AMICI/compare/v0.25.0...v0.25.1


### v0.25.0 (2024-05-08)

This release requires Python >= 3.10.

**Fixes**
* Fixed a bug in event handling that could lead to incorrect simulation
results for models with events that assign to compartments *and* have
additional event assignments
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2428
* SBML import: handle `useValuesFromTriggerTime` attribute on events.
This attribute was previously ignored. It is possible that now AMICI fails
to import models that it previously imported successfully. For cases where
`useValuesFromTriggerTime=True` made a difference, AMICI might have produced
incorrect results before.
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2429
* Faster code generation for models with events if they don't have
state-dependent triggers
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2417
* Most warnings now come with a more informative code location
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2421
* `amici.ExpData` was changed so that `isinstance(edata, amici.ExpData)` works
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2396

**Features**
* Event-assignments to compartments are now supported. Previously, this only
worked for compartments that were rate rule targets.
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2425
* Releases are now deployed to Docker Hub
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2413

**Full Changelog**: https://github.com/AMICI-dev/AMICI/compare/v0.24.0...v0.25.0

### v0.24.0 (2024-04-22)

This will be the last release supporting Python 3.9.
Future releases will require Python 3.10.
Future releases will require Python>=3.10.

**Fixes**

Expand All @@ -27,7 +75,7 @@ Future releases will require Python 3.10.
the correct SUNDIALS installation
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2397

* **Features**
**Features**

* Optionally include measurements in `plot_observable_trajectories`
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2381
Expand Down
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ if("$ENV{ENABLE_AMICI_DEBUGGING}" OR "$ENV{ENABLE_GCOV_COVERAGE}")
else()
add_compile_options(-O0 -g)
endif()
set(CMAKE_BUILD_TYPE "Debug")
endif()

# coverage options
Expand Down Expand Up @@ -135,7 +134,7 @@ endif()
set(VENDORED_SUNDIALS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/sundials)
set(SUNDIALS_PRIVATE_INCLUDE_DIRS "${VENDORED_SUNDIALS_DIR}/src")
# Handle different sundials build/install dirs, depending on whether we are
# building the Python extension only or the full C++ interface
# building the Python extension only or the full C++ interface
if(AMICI_PYTHON_BUILD_EXT_ONLY)
set(VENDORED_SUNDIALS_BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(VENDORED_SUNDIALS_INSTALL_DIR ${VENDORED_SUNDIALS_BUILD_DIR})
Expand Down
51 changes: 34 additions & 17 deletions cmake/AmiciFindBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,33 @@ set_property(CACHE BLAS PROPERTY STRINGS "CBLAS" "MKL" "ACCELERATE")

if(${BLAS} STREQUAL "MKL" OR DEFINED ENV{MKLROOT})
if(DEFINED ENV{MKLROOT})
# This is set by Environment Modules
message(STATUS "Using MKL_INCDIR and MKL_LIB from environment module")
set(BLAS
"MKL"
CACHE STRING "BLAS library to use" FORCE)
set(BLAS_INCLUDE_DIRS
"$ENV{MKL_INCDIR}"
CACHE STRING "" FORCE)
set(BLAS_LIBRARIES
"$ENV{MKL_LIB}"
CACHE STRING "" FORCE)

# Was MKLROOT set by /opt/intel/oneapi/setvars.sh? then cmake will find it
message(STATUS "Trying to find BLAS based on MKLROOT=$ENV{MKLROOT}")
# give the user the option to override the BLA_VENDOR
if(NOT DEFINED BLA_VENDOR)
set(BLA_VENDOR Intel10_64lp)
endif()
message(STATUS "Trying FindBLAS with BLA_VENDOR=${BLA_VENDOR}")
find_package(BLAS)
if(BLAS_FOUND)
message(STATUS "Found BLAS via FindBLAS and MKLROOT")
else()
# This is set by Environment Modules and might not be compatible with
# FindBLAS
message(STATUS "Using MKL_INCDIR and MKL_LIB from environment module")
set(BLAS_INCLUDE_DIRS
"$ENV{MKL_INCDIR}"
CACHE STRING "" FORCE)
set(BLAS_LIBRARIES
"$ENV{MKL_LIB}"
CACHE STRING "" FORCE)
endif()
else()
message(STATUS "BLAS is set to MKL, but MKLROOT is not set.")
set(BLAS_INCLUDE_DIRS
""
CACHE STRING "")
Expand All @@ -42,6 +57,7 @@ elseif(

if(APPLE AND (NOT DEFINED BLA_VENDOR OR BLA_VENDOR STREQUAL "All"))
set(BLA_VENDOR Apple)
message(STATUS "Trying FindBLAS with BLA_VENDOR=${BLA_VENDOR}")
find_package(BLAS)
if(BLAS_FOUND)
message(STATUS "Found Apple Accelerate BLAS")
Expand All @@ -59,6 +75,7 @@ elseif(

endif()
if(NOT BLAS_FOUND)
message(STATUS "Trying FindBLAS with BLA_VENDOR=${BLA_VENDOR}")
find_package(BLAS)
if(BLAS_FOUND)
message(STATUS "Found BLAS via FindBLAS")
Expand All @@ -79,17 +96,17 @@ endif()
# Create an imported target
if(NOT TARGET BLAS::BLAS)
add_library(BLAS INTERFACE)
set_target_properties(BLAS PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${BLAS_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}")
set_target_properties(
BLAS PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${BLAS_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}")
add_library(BLAS::BLAS ALIAS BLAS)
if("${PROJECT_NAME}" STREQUAL "amici")
install(TARGETS BLAS EXPORT BLAS)
export(EXPORT BLAS NAMESPACE BLAS::)
install(
EXPORT BLAS
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Amici"
NAMESPACE BLAS::)
install(TARGETS BLAS EXPORT BLAS)
export(EXPORT BLAS NAMESPACE BLAS::)
install(
EXPORT BLAS
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Amici"
NAMESPACE BLAS::)
endif()

# legacy python package environment variables:
Expand Down
2 changes: 2 additions & 0 deletions cmake/cmakelang-tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ set(ALL_CMAKE_FILES
tests/cpp/unittests/CMakeLists.txt
${CMAKE_MODULE_PATH}/cmakelang-tools.cmake
${CMAKE_MODULE_PATH}/clang-tools.cmake
${CMAKE_MODULE_PATH}/AmiciFindBLAS.cmake
${CMAKE_MODULE_PATH}/version.cmake)

list(JOIN ALL_CMAKE_FILES " " ALL_CMAKE_FILES)

# --- cmake-format ---
Expand Down
10 changes: 6 additions & 4 deletions documentation/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,19 @@ def install_mtocpp():

def install_doxygen():
"""Get a more recent doxygen"""
version = "1.9.7"
version = "1.11.0"
release = f"Release_{version.replace('.', '_')}"
filename = f"doxygen-{version}.linux.bin.tar.gz"
doxygen_exe = os.path.join(
amici_dir, "ThirdParty", f"doxygen-{version}", "bin", "doxygen"
)
# to create a symlink to doxygen in a location that is already on PATH
some_dir_on_path = os.environ["PATH"].split(os.pathsep)[0]
cmd = (
f"cd '{os.path.join(amici_dir, 'ThirdParty')}' "
f"&& wget 'https://www.doxygen.nl/files/"
f"doxygen-{version}.linux.bin.tar.gz' "
f"&& tar -xzf doxygen-{version}.linux.bin.tar.gz "
f"&& wget 'https://github.com/doxygen/doxygen/releases/download/"
f"{release}/{filename}' "
f"&& tar -xzf '{filename}' "
f"&& ln -sf '{doxygen_exe}' '{some_dir_on_path}'"
)
subprocess.run(cmd, shell=True, check=True)
Expand Down
2 changes: 1 addition & 1 deletion documentation/python_interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ AMICI can import :term:`SBML` models via the
Status of SBML support in Python-AMICI
++++++++++++++++++++++++++++++++++++++

Python-AMICI currently **passes 1247 out of the 1821 (~68%) test cases** from
Python-AMICI currently **passes 1252 out of the 1821 (~68%) test cases** from
the semantic
`SBML Test Suite <https://github.com/sbmlteam/sbml-test-suite/>`_
(`current status <https://github.com/AMICI-dev/AMICI/actions>`_).
Expand Down
2 changes: 1 addition & 1 deletion documentation/rtd_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exhale>=0.3.7
sphinxcontrib-matlabdomain>=0.20.0
sphinxcontrib-napoleon>=0.7
pygments>=2.15.1
Jinja2==3.1.2
Jinja2==3.1.4
git+https://github.com/readthedocs/readthedocs-sphinx-ext
ipykernel
-e git+https://github.com/Benchmarking-Initiative/Benchmark-Models-PEtab.git@master#subdirectory=src/python&egg=benchmark_models_petab
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ filterwarnings =
ignore:The --rsyncdir command line argument and rsyncdirs config variable are deprecated.:DeprecationWarning
ignore:.*:ImportWarning:tellurium
ignore:.*PyDevIPCompleter6.*:DeprecationWarning
# ignore numpy log(0) warnings (np.log(0) = -inf)
ignore:divide by zero encountered in log:RuntimeWarning

norecursedirs = .git amici_models build doc documentation matlab models ThirdParty amici sdist examples
4 changes: 2 additions & 2 deletions python/sdist/amici/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import amici
import numpy as np
import sympy as sp

from sympy.abc import _clash
from . import ExpData, ExpDataPtr, Model, ReturnData, ReturnDataPtr

StrOrExpr = Union[str, sp.Expr]
Expand Down Expand Up @@ -497,7 +497,7 @@ def evaluate(expr: StrOrExpr, rdata: ReturnDataView) -> np.array:
from sympy.utilities.lambdify import lambdify

if isinstance(expr, str):
expr = sp.sympify(expr)
expr = sp.sympify(expr, locals=_clash)

arg_names = list(sorted(expr.free_symbols, key=lambda x: x.name))
func = lambdify(arg_names, expr, "numpy")
Expand Down
45 changes: 24 additions & 21 deletions python/sdist/amici/petab/simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,30 +166,33 @@ def simulate_petab(
amici_model=amici_model,
)

if problem_parameters is not None and not scaled_parameters:
problem_parameters = petab_problem.scale_parameters(problem_parameters)
scaled_parameters = True

if problem_parameters is None:
# scaled PEtab nominal values
problem_parameters = dict(
zip(
petab_problem.x_ids,
petab_problem.x_nominal_scaled,
strict=True,
)
problem_parameters = {}

# scaled PEtab nominal values
default_problem_parameters = dict(
zip(
petab_problem.x_ids,
petab_problem.get_x_nominal(scaled=scaled_parameters),
strict=True,
)
# depending on `fill_fixed_parameters` for parameter mapping, the
# parameter mapping may contain values instead of symbols for fixed
# parameters. In this case, we need to filter them here to avoid
# warnings in `fill_in_parameters`.
free_parameters = parameter_mapping.free_symbols
problem_parameters = {
par_id: par_value
for par_id, par_value in problem_parameters.items()
if par_id in free_parameters
}

elif not scaled_parameters:
problem_parameters = petab_problem.scale_parameters(problem_parameters)
)
# depending on `fill_fixed_parameters` for parameter mapping, the
# parameter mapping may contain values instead of symbols for fixed
# parameters. In this case, we need to filter them here to avoid
# warnings in `fill_in_parameters`.
free_parameters = parameter_mapping.free_symbols
default_problem_parameters = {
par_id: par_value
for par_id, par_value in default_problem_parameters.items()
if par_id in free_parameters
}

scaled_parameters = True
problem_parameters = default_problem_parameters | problem_parameters

# Get edatas
if edatas is None:
Expand Down
Loading

0 comments on commit 6cf22a7

Please sign in to comment.