amici.numpy

C++ object views

This module provides views on C++ objects for efficient access.

Classes

ExpDataView(edata)

Interface class for C++ Exp Data objects that avoids possibly costly copies of member data.

ReturnDataView(rdata)

Interface class for C++ amici.ReturnData objects that avoids possibly costly copies of member data.

SwigPtrView(swigptr)

Interface class to expose std::vector<double> and scalar members of swig wrapped C++ objects as numpy array attributes and fields.

class amici.numpy.ExpDataView(edata)[source]

Interface class for C++ Exp Data objects that avoids possibly costly copies of member data.

__init__(edata)[source]

Constructor

Parameters

edata (typing.Union[amici.amici.ExpDataPtr, amici.swig_wrappers.ExpData]) – pointer to the ExpData instance

get(k[, d]) D[k] if k in D, else d.  d defaults to None.
items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
values() an object providing a view on D's values
class amici.numpy.ReturnDataView(rdata)[source]

Interface class for C++ amici.ReturnData objects that avoids possibly costly copies of member data.

__init__(rdata)[source]

Constructor

Parameters

rdata (typing.Union[amici.amici.ReturnDataPtr, amici.amici.ReturnData]) – pointer to the ReturnData instance

by_id(entity_id, field=None, model=None)[source]

Get the value of a given field for a named entity.

Parameters
  • entity_id (str) – The ID of the model entity that is to be extracted from field (e.g. a state ID).

  • field (typing.Optional[str]) – The requested field, e.g. ‘x’ for model states. This is optional if field would be one of {'x', 'y', 'w'}

  • model (typing.Optional[amici.amici.Model]) – The model from which this ReturnDataView was generated. This is optional if this ReturnData was generated with solver.getReturnDataReportingMode() == amici.RDataReporting.full.

Return type

numpy.array

get(k[, d]) D[k] if k in D, else d.  d defaults to None.
items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
values() an object providing a view on D's values
class amici.numpy.SwigPtrView(swigptr)[source]

Interface class to expose std::vector<double> and scalar members of swig wrapped C++ objects as numpy array attributes and fields. This class is memory efficient as copies of the underlying C++ objects is only created when respective fields are accessed for the first time. Cached copies are used for all subsequent calls.

Variables
  • _swigptr – pointer to the C++ object

  • _field_names – names of members that will be exposed as numpy arrays

  • _field_dimensions – dimensions of numpy arrays

  • _cache – dictionary with cached values

__init__(swigptr)[source]

Constructor

Parameters

swigptr – pointer to the C++ object

get(k[, d]) D[k] if k in D, else d.  d defaults to None.
items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
values() an object providing a view on D's values