diff --git a/setup.py b/setup.py index c1084f3..3d711c7 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ def run(self): 'name': 'multiset_multicover', 'description': 'MM is a package for running the greedy cover algorithm to perform multiset multicover.', 'license': 'MIT', - 'version': '0.21', + 'version': '0.3', 'author': 'Euxhen Hasanaj', 'author_email': 'ehasanaj@cs.cmu.edu', 'url': 'https://github.com/ferrocactus/multiset_multicover', diff --git a/src/multiset_multicover/GreedyCover.cpp b/src/multiset_multicover/GreedyCover.cpp index 6a13c4e..110733c 100644 --- a/src/multiset_multicover/GreedyCover.cpp +++ b/src/multiset_multicover/GreedyCover.cpp @@ -85,6 +85,7 @@ vector GreedyCoverInstance::__cover() this->__init_leftovers(); this->__init_remaining_msets(); this->__reset_msets(); + this->_coverage_until.clear(); this->_n_elements_remaining.clear(); this->solution.clear(); diff --git a/src/multiset_multicover/python_interface.cpp b/src/multiset_multicover/python_interface.cpp index 8277f2e..84f0ff9 100644 --- a/src/multiset_multicover/python_interface.cpp +++ b/src/multiset_multicover/python_interface.cpp @@ -56,7 +56,7 @@ vector create_size_t_vector_from_list(PyObject* py_list) size_t num = PyLong_AsSize_t(py_item); v[i] = num; } else { - throw Exception("Non numeric value found."); + throw Exception("Non integer value found."); } } return v; @@ -232,7 +232,7 @@ PyObject* _GreedyCoverInstance_delete_multiset(PyObject* self, PyObject* args, P if (PyLong_Check(py_index) && PyIndex_Check(py_index)) gci->delete_multiset(PyLong_AsSize_t(py_index)); else - throw Exception("Non numeric value found."); + throw Exception("Non integer value found."); Py_INCREF(Py_None); return Py_None; @@ -263,7 +263,7 @@ PyObject* _GreedyCoverInstance_cover(PyObject* self, PyObject* args, PyObject* k if (PyLong_Check(py_max_iters)) max_iters = PyLong_AsSize_t(py_max_iters); else - throw Exception("Non integer number found."); + throw Exception("Non integer value found."); } if (PyLong_Check(py_coverage)) { diff --git a/src/multiset_multicover/python_source.py b/src/multiset_multicover/python_source.py index 679530a..c206adc 100644 --- a/src/multiset_multicover/python_source.py +++ b/src/multiset_multicover/python_source.py @@ -50,6 +50,12 @@ def __getitem__(self, index): """ return _c_mm._GreedyCoverInstance_at(self._gci, index) + def __repr__(self): + return f"GreedyCoverInstance({self.n_elements})" + + def __str__(self): + return f"GreedyCoverInstance({self.n_elements}) with {self.size} multisets" + @property def size(self): """ diff --git a/test/test_interface.py b/test/test_interface.py index 64900a9..6ad68ff 100644 --- a/test/test_interface.py +++ b/test/test_interface.py @@ -21,9 +21,12 @@ def test1(self): coverage_until = gci.coverage_until_ self.assertListEqual(coverage_until, [1, 1, 2]) - _ = gci.cover(3) + solution = gci.cover(3) + self.assertListEqual(solution, [2, 1, 4]) multisets_incomplete_cover = gci.multisets_incomplete_cover_ self.assertListEqual(multisets_incomplete_cover, [3]) + coverage_until = gci.coverage_until_ + self.assertListEqual(coverage_until, [0, 1, 2]) def test2(self): gci = mm.GreedyCoverInstance(4)