Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SwigPtrView fields to dir() #2244

Merged
merged 6 commits into from
Jan 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions python/sdist/amici/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import collections
import copy
import itertools
from typing import Dict, Iterator, List, Literal, Union

import amici
Expand Down Expand Up @@ -164,6 +165,13 @@
return False
return self._swigptr == other._swigptr

def __dir__(self):
return sorted(

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

View check run for this annotation

Codecov / codecov/patch

python/sdist/amici/numpy.py#L169

Added line #L169 was not covered by tests
set(
itertools.chain(dir(super()), self.__dict__, self._field_names)
)
)


class ReturnDataView(SwigPtrView):
"""
Expand Down Expand Up @@ -237,7 +245,7 @@
if not isinstance(rdata, (ReturnDataPtr, ReturnData)):
raise TypeError(
f"Unsupported pointer {type(rdata)}, must be"
f"amici.ExpDataPtr!"
f"amici.ReturnDataPtr or amici.ReturnData!"
)
self._field_dimensions = {
"ts": [rdata.nt],
Expand Down Expand Up @@ -288,7 +296,7 @@
"numerrtestfailsB": [rdata.nt],
"numnonlinsolvconvfailsB": [rdata.nt],
}
super(ReturnDataView, self).__init__(rdata)
super().__init__(rdata)

def __getitem__(
self, item: str
Expand Down Expand Up @@ -406,7 +414,7 @@
edata.observedDataStdDev = edata.getObservedDataStdDev()
edata.observedEvents = edata.getObservedEvents()
edata.observedEventsStdDev = edata.getObservedEventsStdDev()
super(ExpDataView, self).__init__(edata)
super().__init__(edata)


def _field_as_numpy(
Expand Down