Skip to content

Commit

Permalink
Merge branch 'develop' into deepcopy_edata
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored Nov 15, 2023
2 parents 0506d09 + 187362a commit f82b1b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion python/sdist/amici/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ def __getitem__(

return super().__getitem__(item)

def __repr__(self):
status = amici.simulation_status_to_str(self._swigptr.status)
return f"<{self.__class__.__name__}(id={self._swigptr.id!r}, status={status})>"

def by_id(
self, entity_id: str, field: str = None, model: Model = None
) -> np.array:
Expand Down Expand Up @@ -359,6 +363,7 @@ class ExpDataView(SwigPtrView):
"""

_field_names = [
"ts",
"observedData",
"observedDataStdDev",
"observedEvents",
Expand All @@ -379,7 +384,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
Expand All @@ -394,6 +401,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()
Expand Down
3 changes: 2 additions & 1 deletion swig/edata.i
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ def __repr__(self):
return _edata_repr(self)

def __eq__(self, other):
return isinstance(other, self.__class__) and __eq__(self, other)
return other.__class__ == self.__class__ and __eq__(self, other)

def __deepcopy__(self, memo):
# invoke copy constructor
return type(self)(self)

%}
};
%extend std::unique_ptr<amici::ExpData> {
Expand Down

0 comments on commit f82b1b5

Please sign in to comment.