Skip to content

Commit

Permalink
Easier access to timepoints via ExpDataView
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dweindl committed Nov 15, 2023
1 parent 269910b commit d48986b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python/sdist/amici/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ class ExpDataView(SwigPtrView):
"""

_field_names = [
"ts",
"observedData",
"observedDataStdDev",
"observedEvents",
Expand All @@ -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 = {

Check warning on line 367 in python/sdist/amici/numpy.py

View check run for this annotation

Codecov / codecov/patch

python/sdist/amici/numpy.py#L367

Added line #L367 was not covered by tests
"ts": [edata.nt()],
# observables
"observedData": [edata.nt(), edata.nytrue()],
"observedDataStdDev": [edata.nt(), edata.nytrue()],
# event observables
Expand All @@ -378,6 +381,7 @@ def __init__(self, edata: Union[ExpDataPtr, ExpData]):
len(edata.fixedParametersPreequilibration)
],
}
edata.ts = edata.ts_

Check warning on line 384 in python/sdist/amici/numpy.py

View check run for this annotation

Codecov / codecov/patch

python/sdist/amici/numpy.py#L384

Added line #L384 was not covered by tests
edata.observedData = edata.getObservedData()
edata.observedDataStdDev = edata.getObservedDataStdDev()
edata.observedEvents = edata.getObservedEvents()
Expand Down

0 comments on commit d48986b

Please sign in to comment.