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

improve error reporting for Python bindings #45

Merged
merged 1 commit into from
Dec 21, 2023
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
7 changes: 3 additions & 4 deletions python/src/pyapproxmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static int parse_clause(Counter *self, PyObject *clause, std::vector<CMSat::Lit>
if (allow_more_vars)
self->arjun->new_vars(max_var-(long int)self->arjun->nVars()+1);
else {
PyErr_SetString(PyExc_SystemError,
PyErr_SetString(PyExc_ValueError,
"ERROR: Sampling vars contain variables that are not in the original clauses!");
return 0;
}
Expand Down Expand Up @@ -413,8 +413,7 @@ Approximately count the number of solutions to the formula. It can only be calle
static PyObject* count(Counter *self, PyObject *args, PyObject *kwds)
{
if (self->count_called) {
PyErr_SetString(PyExc_SystemError,
"ERROR: Sampling vars contain variables that are not in the original clauses!");
PyErr_SetString(PyExc_ValueError, "ERROR: Counter.count() may only be called once!");
return NULL;
} else {
self->count_called = true;
Expand All @@ -436,7 +435,7 @@ static PyObject* count(Counter *self, PyObject *args, PyObject *kwds)
}
for(const auto& l: sampling_lits) {
if (l.var() > self->arjun->nVars()) {
PyErr_SetString(PyExc_SystemError,
PyErr_SetString(PyExc_ValueError,
"ERROR: Sampling vars contain variables that are not in the original clauses!");
return NULL;
}
Expand Down
Loading