From d48986bc606bcacbbcea0bdb21f9c180ce8d0753 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 15 Nov 2023 10:15:04 +0100 Subject: [PATCH] Easier access to timepoints via ExpDataView ExpDataView provides convenient access to measurements and the like as numpy arrays. However, accessing the associated timepoints is currently only possible via `ExpDataView(...)._swigptr.ts_` which returns an amici.amici.DoubleVector. That's awkward. Now: ```python amici.ExpDataView(amici.ExpData(1, 2, 3, [4, 5, 6])).ts Out[3]: array([4., 5., 6.]) ``` Resolves #2191 --- python/sdist/amici/numpy.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/sdist/amici/numpy.py b/python/sdist/amici/numpy.py index d9b34b6447..7a917d6c98 100644 --- a/python/sdist/amici/numpy.py +++ b/python/sdist/amici/numpy.py @@ -343,6 +343,7 @@ class ExpDataView(SwigPtrView): """ _field_names = [ + "ts", "observedData", "observedDataStdDev", "observedEvents", @@ -363,7 +364,9 @@ def __init__(self, edata: Union[ExpDataPtr, ExpData]): f"Unsupported pointer {type(edata)}, must be" f"amici.ExpDataPtr!" ) - self._field_dimensions = { # observables + self._field_dimensions = { + "ts": [edata.nt()], + # observables "observedData": [edata.nt(), edata.nytrue()], "observedDataStdDev": [edata.nt(), edata.nytrue()], # event observables @@ -378,6 +381,7 @@ def __init__(self, edata: Union[ExpDataPtr, ExpData]): len(edata.fixedParametersPreequilibration) ], } + edata.ts = edata.ts_ edata.observedData = edata.getObservedData() edata.observedDataStdDev = edata.getObservedDataStdDev() edata.observedEvents = edata.getObservedEvents()