Skip to content

Commit

Permalink
Correct how we call the C code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwg4 committed Feb 10, 2024
1 parent 6c9f301 commit 822dba6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions exact_cover/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .wrapper import get_exact_cover # noqa: F401
from .wrapper import get_all_solutions # noqa: F401
4 changes: 3 additions & 1 deletion exact_cover/wrapper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from exact_cover_impl import get_exact_cover as raw_get_exact_cover
from exact_cover_impl import get_solution_count as raw_get_exact_cover
from exact_cover_impl import get_all_solutions as raw_get_all_solutions

from .error import NoSolution
Expand Down Expand Up @@ -27,7 +28,8 @@ def get_all_solutions(matrix):
assert (
transformed.flags.c_contiguous
), "We depend on the input array being C contiguous for raw goodness."
result = raw_get_all_solutions(transformed)
count = raw_get_solution_count(transformed)
result = raw_get_all_solutions(transformed, count)
if result.size == 0:
raise NoSolution("No solutions found by the C code.")
return result

0 comments on commit 822dba6

Please sign in to comment.