Skip to content
Draft
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
20 changes: 20 additions & 0 deletions python/tests/test_scip.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,23 @@ def test_is_solved(model):

def test_bounds(model):
assert model.dual_bound < model.primal_bound


@requires_pyscipopt
def test_pyscipopt_callback(model):
"""GIL is properly reaquired in PySCIPOpt and PySCIPOpt model liftime is managed."""
import pyscipopt.scip

class EventHandler(pyscipopt.scip.Eventhdlr):
def eventinit(self):
self.model.catchEvent(scip.SCIP_EVENTTYPE.LPEVENT, self)

def eventexit(self):
self.model.dropEvent(scip.SCIP_EVENTTYPE.LPEVENT, self)

def eventexec(self, event):
# Use the pyscipopt object to verify its lifetime
self.model.getNTotalNodes()

model.as_pyscipopt().includeEventhdlr(EventHandler(), "Name", "Description")
model.solve()