Skip to content

Commit

Permalink
Merge branch 'develop' into ft_2368_partial_equilibration
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored Apr 20, 2024
2 parents 1edc339 + e8493cf commit 137af9d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,16 @@ elseif(AMICI_TRY_ENABLE_HDF5)
endif()

set(VENDORED_SUNDIALS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/sundials)
set(VENDORED_SUNDIALS_BUILD_DIR ${VENDORED_SUNDIALS_DIR}/build)
set(VENDORED_SUNDIALS_INSTALL_DIR ${VENDORED_SUNDIALS_BUILD_DIR})
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
if(AMICI_PYTHON_BUILD_EXT_ONLY)
set(VENDORED_SUNDIALS_BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(VENDORED_SUNDIALS_INSTALL_DIR ${VENDORED_SUNDIALS_BUILD_DIR})
else()
set(VENDORED_SUNDIALS_BUILD_DIR ${VENDORED_SUNDIALS_DIR}/build)
set(VENDORED_SUNDIALS_INSTALL_DIR ${VENDORED_SUNDIALS_BUILD_DIR})
endif()
find_package(
SUNDIALS REQUIRED PATHS
"${VENDORED_SUNDIALS_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/sundials/")
Expand Down
17 changes: 10 additions & 7 deletions python/sdist/amici/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,18 @@ def __getitem__(self, item: str) -> Union[np.ndarray, float]:
if item in self._cache:
return self._cache[item]

if item == "id":
return getattr(self._swigptr, item)
if item in self._field_names:
value = _field_as_numpy(
self._field_dimensions, item, self._swigptr
)
self._cache[item] = value

if item not in self._field_names:
self.__missing__(item)
return value

if not item.startswith("_") and hasattr(self._swigptr, item):
return getattr(self._swigptr, item)

value = _field_as_numpy(self._field_dimensions, item, self._swigptr)
self._cache[item] = value
return value
self.__missing__(item)

def __missing__(self, key: str) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion python/sdist/amici/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def plot_observable_trajectories(
if not ax:
fig, ax = plt.subplots()
if not observable_indices:
observable_indices = range(rdata["y"].shape[1])
observable_indices = range(rdata.ny)

if marker is None:
# Show marker if only one time point is available,
Expand Down
3 changes: 3 additions & 0 deletions python/tests/test_swig_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@ def test_rdataview(sbml_example_presimulation_module):
rdata = amici.runAmiciSimulation(model, model.getSolver())
assert isinstance(rdata, amici.ReturnDataView)

# check that non-array attributes are looked up in the wrapped object
assert rdata.ptr.ny == rdata.ny

# fields are accessible via dot notation and [] operator,
# __contains__ and __getattr__ are implemented correctly
with pytest.raises(AttributeError):
Expand Down

0 comments on commit 137af9d

Please sign in to comment.