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

Fix ExpData equality operator for Python #2194

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions python/tests/test_swig_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,12 @@ def test_edata_repr():
assert expected_str in repr(e)
# avoid double delete!!
edata_ptr.release()


def test_edata_equality_operator():
e1 = amici.ExpData(1, 2, 3, [3])
e2 = amici.ExpData(1, 2, 3, [3])
assert e1 == e2
# check that comparison with other types works
# this is not implemented by swig by default
assert e1 != 1
3 changes: 3 additions & 0 deletions swig/edata.i
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def _edata_repr(self: "ExpData"):
%pythoncode %{
def __repr__(self):
return _edata_repr(self)

def __eq__(self, other):
return other.__class__ == self.__class__ and __eq__(self, other)
%}
};
%extend std::unique_ptr<amici::ExpData> {
Expand Down