-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert test main script in algorithm_utils to unit test (#3864)
- Loading branch information
1 parent
cfecf36
commit e55ad26
Showing
2 changed files
with
20 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pytest | ||
|
||
from ludwig.utils.algorithms_utils import topological_sort | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"unsorted,sorted", | ||
[ | ||
( | ||
[(2, []), (5, [11]), (11, [2, 9, 10]), (7, [11, 8]), (9, []), (10, []), (8, [9]), (3, [10, 8])], | ||
[(2, []), (9, []), (10, []), (8, [9]), (3, [10, 8]), (11, [2, 9, 10]), (7, [11, 8]), (5, [11])], | ||
), | ||
( | ||
[("macro", ["action", "contact_type"]), ("contact_type", None), ("action", ["contact_type"])], | ||
[("contact_type", []), ("action", ["contact_type"]), ("macro", ["action", "contact_type"])], | ||
), | ||
], | ||
) | ||
def test_topological_sort(unsorted: list, sorted: list) -> None: | ||
assert topological_sort(unsorted) == sorted |