Skip to content

Commit

Permalink
SolverPtr
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Dec 17, 2023
1 parent caeb9f0 commit f907e8c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
18 changes: 12 additions & 6 deletions python/tests/test_swig_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,15 @@ def test_expdata_and_expdataview_are_deepcopyable():

def test_solvers_are_deepcopyable():
for solver_type in (amici.CVodeSolver, amici.IDASolver):
solver1 = solver_type()
solver2 = copy.deepcopy(solver1)
assert solver1.this != solver2.this
assert solver1.getRelativeTolerance() == solver2.getRelativeTolerance()
solver2.setRelativeTolerance(100 * solver2.getRelativeTolerance())
assert solver1.getRelativeTolerance() != solver2.getRelativeTolerance()
for solver1 in (solver_type(), amici.SolverPtr(solver_type())):
solver2 = copy.deepcopy(solver1)
assert solver1.this != solver2.this
assert (
solver1.getRelativeTolerance()
== solver2.getRelativeTolerance()
)
solver2.setRelativeTolerance(100 * solver2.getRelativeTolerance())
assert (
solver1.getRelativeTolerance()
!= solver2.getRelativeTolerance()
)
3 changes: 3 additions & 0 deletions swig/solver.i
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ def __repr__(self):
%pythoncode %{
def __repr__(self):
return _solver_repr(self)

def __deepcopy__(self, memo):
return self.clone()
%}
};

Expand Down
3 changes: 3 additions & 0 deletions swig/std_unique_ptr.i
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ namespace std {
struct unique_ptr {
typedef Type* pointer;

%apply SWIGTYPE *DISOWN { pointer Ptr };
explicit unique_ptr( pointer Ptr );
%clear pointer Ptr;
unique_ptr (unique_ptr&& Right);

template<class Type2, Class Del2> unique_ptr( unique_ptr<Type2, Del2>&& Right );
unique_ptr( const unique_ptr& Right) = delete;

Expand Down

0 comments on commit f907e8c

Please sign in to comment.