diff --git a/src/forest.cpp b/src/forest.cpp index b25622318..0bb0fbf15 100644 --- a/src/forest.cpp +++ b/src/forest.cpp @@ -74,28 +74,7 @@ Constructs a forest with *n* nodes, that is initialised so that the parents, std::vector> const& labels) { - using node_type = Forest::node_type; - std::vector parents_as_ints; - std::vector labels_as_ints; - for (auto const& val : parents) { - if (std::holds_alternative(val)) { - parents_as_ints.push_back(std::get<0>(val)); - } else { - parents_as_ints.push_back( - static_cast(std::get<1>(val))); - } - } - // TODO there's something like this in transf.cpp too, we should - // avoid code dupl - for (auto const& val : labels) { - if (std::holds_alternative(val)) { - labels_as_ints.push_back(std::get<0>(val)); - } else { - labels_as_ints.push_back( - static_cast(std::get<1>(val))); - } - } - return make(parents_as_ints, labels_as_ints); + return make(to_ints(parents), to_ints(labels)); }), py::arg("parents"), py::arg("labels"), diff --git a/src/main.hpp b/src/main.hpp index 1035d8558..06c3cce50 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -19,8 +19,12 @@ #ifndef SRC_MAIN_HPP_ #define SRC_MAIN_HPP_ +#include + #include +#include + namespace libsemigroups { namespace py = pybind11; @@ -70,6 +74,30 @@ namespace libsemigroups { void init_word_graph(py::module&); void init_words(py::module&); + template + std::vector + to_ints(std::vector> const& vec) { + std::vector vec_as_ints; + for (auto const& val : vec) { + if (std::holds_alternative(val)) { + vec_as_ints.push_back(std::get<0>(val)); + } else { + vec_as_ints.push_back(static_cast(std::get<1>(val))); + } + } + return vec_as_ints; + } + + template + std::vector> + to_ints(std::vector>> const& vec) { + std::vector> vec_as_ints; + for (auto const& val : vec) { + vec_as_ints.push_back(to_ints(val)); + } + return vec_as_ints; + } + } // namespace libsemigroups #endif // SRC_MAIN_HPP_ diff --git a/src/transf.cpp b/src/transf.cpp index b6437034a..325cc17df 100644 --- a/src/transf.cpp +++ b/src/transf.cpp @@ -524,16 +524,7 @@ among the points where :math:`f` is defined). thing.def( py::init( [](std::vector> const& imgs) { - std::vector imgs_as_ints; - for (auto const& val : imgs) { - if (std::holds_alternative(val)) { - imgs_as_ints.push_back(std::get<0>(val)); - } else { - imgs_as_ints.push_back( - static_cast(std::get<1>(val))); - } - } - return make(std::move(imgs_as_ints)); + return make(to_ints(imgs)); }), py::arg("imgs"), R"pbdoc( diff --git a/src/word-graph.cpp b/src/word-graph.cpp index 60c84288e..bf9802115 100644 --- a/src/word-graph.cpp +++ b/src/word-graph.cpp @@ -111,13 +111,15 @@ out-degree of any node is *n*. There are no edges in the defined word graph. :math:`O(mn)` where *m* is the number of nodes, and *n* is the out-degree of the word graph.)pbdoc"); - thing.def(py::init([](size_t num_nodes, - std::vector> const& targets) { - return make(num_nodes, targets); - }), - py::arg("num_nodes"), - py::arg("targets"), - R"pbdoc( + thing.def( + py::init([](size_t num_nodes, + std::vector>> const& targets) { + return make(num_nodes, to_ints(targets)); + }), + py::arg("num_nodes"), + py::arg("targets"), + R"pbdoc( Construct a word graph from a number of nodes and an list of targets. This function constructs a word graph from its arguments whose diff --git a/tests/test_stephen.py b/tests/test_stephen.py index 47ff04adc..c7ced383e 100644 --- a/tests/test_stephen.py +++ b/tests/test_stephen.py @@ -21,21 +21,22 @@ import pytest from libsemigroups_pybind11 import ( - ReportGuard, - stephen, - Stephen, - presentation, - Presentation, InversePresentation, + LibsemigroupsError, POSITIVE_INFINITY, - WordGraph, - word_graph, + Presentation, + ReportGuard, + Stephen, ToWord, - lexicographical_compare, - LibsemigroupsError, - todd_coxeter, ToddCoxeter, + UNDEFINED, + WordGraph, congruence_kind, + lexicographical_compare, + presentation, + stephen, + todd_coxeter, + word_graph, ) from libsemigroups_pybind11.presentation import examples @@ -45,7 +46,7 @@ def check_000(s): s.set_word([0]).run() assert s.word_graph().number_of_nodes() == 2 # TODO(1): use UNDEFINED once that works - assert s.word_graph() == WordGraph(2, [[1, 2**32 - 1], [2**32 - 1, 1]]) + assert s.word_graph() == WordGraph(2, [[1, UNDEFINED], [UNDEFINED, 1]]) assert stephen.number_of_words_accepted(s) == POSITIVE_INFINITY assert list(islice(stephen.words_accepted(s), 10)) == [ [0], @@ -144,8 +145,8 @@ def test_stephen_001(): assert s.word_graph() == WordGraph( 7, [ - [2**32 - 1, 1], - [2**32 - 1, 2], + [UNDEFINED, 1], + [UNDEFINED, 2], [3, 1], [4, 5], [3, 6], @@ -199,7 +200,7 @@ def test_stephen_001(): s.set_word([0, 0]).run() assert s.word_graph().number_of_nodes() == 5 assert s.word_graph() == WordGraph( - 5, [[1, 2**32 - 1], [2, 3], [1, 4], [4, 1], [3, 2]] + 5, [[1, UNDEFINED], [2, 3], [1, 4], [4, 1], [3, 2]] ) p.rules = [] @@ -208,7 +209,7 @@ def test_stephen_001(): s.init(p).set_word([0, 0]).run() assert s.word() == [0, 0] assert s.word_graph() == WordGraph( - 3, [[1, 2**32 - 1], [2, 2**32 - 1], [1, 2**32 - 1]] + 3, [[1, UNDEFINED], [2, UNDEFINED], [1, UNDEFINED]] ) @@ -225,126 +226,126 @@ def test_stephen_002(): assert s.word_graph() == WordGraph( 120, [ - [1, 2, 3, 4, 2**32 - 1], - [0, 5, 6, 7, 2**32 - 1], - [8, 0, 9, 10, 2**32 - 1], - [11, 12, 0, 13, 2**32 - 1], - [14, 15, 16, 0, 2**32 - 1], - [17, 1, 18, 19, 2**32 - 1], - [20, 21, 1, 22, 2**32 - 1], - [23, 24, 25, 1, 2**32 - 1], - [2, 17, 26, 27, 2**32 - 1], - [28, 29, 2, 30, 2**32 - 1], - [31, 32, 33, 2, 2**32 - 1], - [3, 34, 20, 35, 2**32 - 1], - [36, 3, 29, 37, 2**32 - 1], - [38, 39, 40, 3, 2**32 - 1], - [4, 41, 42, 23, 2**32 - 1], - [43, 4, 44, 32, 2**32 - 1], - [45, 46, 4, 40, 2**32 - 1], - [5, 8, 47, 48, 2**32 - 1], - [49, 50, 5, 51, 2**32 - 1], - [52, 53, 54, 5, 2**32 - 1], - [6, 55, 11, 56, 2**32 - 1], - [57, 6, 50, 58, 2**32 - 1], - [59, 60, 61, 6, 2**32 - 1], - [7, 62, 63, 14, 2**32 - 1], - [64, 7, 65, 53, 2**32 - 1], - [66, 67, 7, 61, 2**32 - 1], - [55, 57, 8, 68, 2**32 - 1], - [62, 64, 69, 8, 2**32 - 1], - [9, 49, 55, 70, 2**32 - 1], - [50, 9, 12, 71, 2**32 - 1], - [72, 73, 74, 9, 2**32 - 1], - [10, 52, 75, 62, 2**32 - 1], - [53, 10, 76, 15, 2**32 - 1], - [77, 78, 10, 74, 2**32 - 1], - [47, 11, 49, 79, 2**32 - 1], - [63, 80, 66, 11, 2**32 - 1], - [12, 47, 57, 81, 2**32 - 1], - [82, 76, 78, 12, 2**32 - 1], - [13, 83, 59, 63, 2**32 - 1], - [84, 13, 73, 76, 2**32 - 1], - [61, 74, 13, 16, 2**32 - 1], - [48, 14, 85, 52, 2**32 - 1], - [56, 86, 14, 59, 2**32 - 1], - [15, 48, 87, 64, 2**32 - 1], - [88, 71, 15, 73, 2**32 - 1], - [16, 89, 56, 66, 2**32 - 1], - [90, 16, 71, 78, 2**32 - 1], - [34, 36, 17, 91, 2**32 - 1], - [41, 43, 92, 17, 2**32 - 1], - [18, 28, 34, 93, 2**32 - 1], - [29, 18, 21, 94, 2**32 - 1], - [95, 96, 97, 18, 2**32 - 1], - [19, 31, 98, 41, 2**32 - 1], - [32, 19, 99, 24, 2**32 - 1], - [100, 101, 19, 97, 2**32 - 1], - [26, 20, 28, 102, 2**32 - 1], - [42, 103, 45, 20, 2**32 - 1], - [21, 26, 36, 104, 2**32 - 1], - [105, 99, 101, 21, 2**32 - 1], - [22, 106, 38, 42, 2**32 - 1], - [107, 22, 96, 99, 2**32 - 1], - [40, 97, 22, 25, 2**32 - 1], - [27, 23, 108, 31, 2**32 - 1], - [35, 109, 23, 38, 2**32 - 1], - [24, 27, 110, 43, 2**32 - 1], - [111, 94, 24, 96, 2**32 - 1], - [25, 112, 35, 45, 2**32 - 1], - [113, 25, 94, 101, 2**32 - 1], - [106, 107, 114, 26, 2**32 - 1], - [112, 113, 27, 114, 2**32 - 1], - [108, 111, 112, 28, 2**32 - 1], - [115, 44, 46, 29, 2**32 - 1], - [30, 95, 106, 108, 2**32 - 1], - [96, 30, 39, 44, 2**32 - 1], - [114, 40, 30, 33, 2**32 - 1], - [102, 105, 31, 106, 2**32 - 1], - [116, 37, 32, 39, 2**32 - 1], - [33, 100, 102, 112, 2**32 - 1], - [101, 33, 37, 46, 2**32 - 1], - [98, 116, 100, 34, 2**32 - 1], - [110, 35, 111, 116, 2**32 - 1], - [109, 110, 113, 36, 2**32 - 1], - [37, 98, 105, 109, 2**32 - 1], - [91, 38, 95, 98, 2**32 - 1], - [39, 91, 107, 110, 2**32 - 1], - [93, 115, 41, 95, 2**32 - 1], - [104, 42, 115, 105, 2**32 - 1], - [103, 104, 43, 107, 2**32 - 1], - [44, 93, 103, 111, 2**32 - 1], - [92, 45, 93, 100, 2**32 - 1], - [46, 92, 104, 113, 2**32 - 1], - [83, 84, 117, 47, 2**32 - 1], - [89, 90, 48, 117, 2**32 - 1], - [85, 88, 89, 49, 2**32 - 1], - [118, 65, 67, 50, 2**32 - 1], - [51, 72, 83, 85, 2**32 - 1], - [73, 51, 60, 65, 2**32 - 1], - [117, 61, 51, 54, 2**32 - 1], - [79, 82, 52, 83, 2**32 - 1], - [119, 58, 53, 60, 2**32 - 1], - [54, 77, 79, 89, 2**32 - 1], - [78, 54, 58, 67, 2**32 - 1], - [75, 119, 77, 55, 2**32 - 1], - [87, 56, 88, 119, 2**32 - 1], - [86, 87, 90, 57, 2**32 - 1], - [58, 75, 82, 86, 2**32 - 1], - [68, 59, 72, 75, 2**32 - 1], - [60, 68, 84, 87, 2**32 - 1], - [70, 118, 62, 72, 2**32 - 1], - [81, 63, 118, 82, 2**32 - 1], - [80, 81, 64, 84, 2**32 - 1], - [65, 70, 80, 88, 2**32 - 1], - [69, 66, 70, 77, 2**32 - 1], - [67, 69, 81, 90, 2**32 - 1], - [74, 117, 68, 69, 2**32 - 1], - [71, 85, 86, 118, 2**32 - 1], - [76, 79, 119, 80, 2**32 - 1], - [97, 114, 91, 92, 2**32 - 1], - [94, 108, 109, 115, 2**32 - 1], - [99, 102, 116, 103, 2**32 - 1], + [1, 2, 3, 4, UNDEFINED], + [0, 5, 6, 7, UNDEFINED], + [8, 0, 9, 10, UNDEFINED], + [11, 12, 0, 13, UNDEFINED], + [14, 15, 16, 0, UNDEFINED], + [17, 1, 18, 19, UNDEFINED], + [20, 21, 1, 22, UNDEFINED], + [23, 24, 25, 1, UNDEFINED], + [2, 17, 26, 27, UNDEFINED], + [28, 29, 2, 30, UNDEFINED], + [31, 32, 33, 2, UNDEFINED], + [3, 34, 20, 35, UNDEFINED], + [36, 3, 29, 37, UNDEFINED], + [38, 39, 40, 3, UNDEFINED], + [4, 41, 42, 23, UNDEFINED], + [43, 4, 44, 32, UNDEFINED], + [45, 46, 4, 40, UNDEFINED], + [5, 8, 47, 48, UNDEFINED], + [49, 50, 5, 51, UNDEFINED], + [52, 53, 54, 5, UNDEFINED], + [6, 55, 11, 56, UNDEFINED], + [57, 6, 50, 58, UNDEFINED], + [59, 60, 61, 6, UNDEFINED], + [7, 62, 63, 14, UNDEFINED], + [64, 7, 65, 53, UNDEFINED], + [66, 67, 7, 61, UNDEFINED], + [55, 57, 8, 68, UNDEFINED], + [62, 64, 69, 8, UNDEFINED], + [9, 49, 55, 70, UNDEFINED], + [50, 9, 12, 71, UNDEFINED], + [72, 73, 74, 9, UNDEFINED], + [10, 52, 75, 62, UNDEFINED], + [53, 10, 76, 15, UNDEFINED], + [77, 78, 10, 74, UNDEFINED], + [47, 11, 49, 79, UNDEFINED], + [63, 80, 66, 11, UNDEFINED], + [12, 47, 57, 81, UNDEFINED], + [82, 76, 78, 12, UNDEFINED], + [13, 83, 59, 63, UNDEFINED], + [84, 13, 73, 76, UNDEFINED], + [61, 74, 13, 16, UNDEFINED], + [48, 14, 85, 52, UNDEFINED], + [56, 86, 14, 59, UNDEFINED], + [15, 48, 87, 64, UNDEFINED], + [88, 71, 15, 73, UNDEFINED], + [16, 89, 56, 66, UNDEFINED], + [90, 16, 71, 78, UNDEFINED], + [34, 36, 17, 91, UNDEFINED], + [41, 43, 92, 17, UNDEFINED], + [18, 28, 34, 93, UNDEFINED], + [29, 18, 21, 94, UNDEFINED], + [95, 96, 97, 18, UNDEFINED], + [19, 31, 98, 41, UNDEFINED], + [32, 19, 99, 24, UNDEFINED], + [100, 101, 19, 97, UNDEFINED], + [26, 20, 28, 102, UNDEFINED], + [42, 103, 45, 20, UNDEFINED], + [21, 26, 36, 104, UNDEFINED], + [105, 99, 101, 21, UNDEFINED], + [22, 106, 38, 42, UNDEFINED], + [107, 22, 96, 99, UNDEFINED], + [40, 97, 22, 25, UNDEFINED], + [27, 23, 108, 31, UNDEFINED], + [35, 109, 23, 38, UNDEFINED], + [24, 27, 110, 43, UNDEFINED], + [111, 94, 24, 96, UNDEFINED], + [25, 112, 35, 45, UNDEFINED], + [113, 25, 94, 101, UNDEFINED], + [106, 107, 114, 26, UNDEFINED], + [112, 113, 27, 114, UNDEFINED], + [108, 111, 112, 28, UNDEFINED], + [115, 44, 46, 29, UNDEFINED], + [30, 95, 106, 108, UNDEFINED], + [96, 30, 39, 44, UNDEFINED], + [114, 40, 30, 33, UNDEFINED], + [102, 105, 31, 106, UNDEFINED], + [116, 37, 32, 39, UNDEFINED], + [33, 100, 102, 112, UNDEFINED], + [101, 33, 37, 46, UNDEFINED], + [98, 116, 100, 34, UNDEFINED], + [110, 35, 111, 116, UNDEFINED], + [109, 110, 113, 36, UNDEFINED], + [37, 98, 105, 109, UNDEFINED], + [91, 38, 95, 98, UNDEFINED], + [39, 91, 107, 110, UNDEFINED], + [93, 115, 41, 95, UNDEFINED], + [104, 42, 115, 105, UNDEFINED], + [103, 104, 43, 107, UNDEFINED], + [44, 93, 103, 111, UNDEFINED], + [92, 45, 93, 100, UNDEFINED], + [46, 92, 104, 113, UNDEFINED], + [83, 84, 117, 47, UNDEFINED], + [89, 90, 48, 117, UNDEFINED], + [85, 88, 89, 49, UNDEFINED], + [118, 65, 67, 50, UNDEFINED], + [51, 72, 83, 85, UNDEFINED], + [73, 51, 60, 65, UNDEFINED], + [117, 61, 51, 54, UNDEFINED], + [79, 82, 52, 83, UNDEFINED], + [119, 58, 53, 60, UNDEFINED], + [54, 77, 79, 89, UNDEFINED], + [78, 54, 58, 67, UNDEFINED], + [75, 119, 77, 55, UNDEFINED], + [87, 56, 88, 119, UNDEFINED], + [86, 87, 90, 57, UNDEFINED], + [58, 75, 82, 86, UNDEFINED], + [68, 59, 72, 75, UNDEFINED], + [60, 68, 84, 87, UNDEFINED], + [70, 118, 62, 72, UNDEFINED], + [81, 63, 118, 82, UNDEFINED], + [80, 81, 64, 84, UNDEFINED], + [65, 70, 80, 88, UNDEFINED], + [69, 66, 70, 77, UNDEFINED], + [67, 69, 81, 90, UNDEFINED], + [74, 117, 68, 69, UNDEFINED], + [71, 85, 86, 118, UNDEFINED], + [76, 79, 119, 80, UNDEFINED], + [97, 114, 91, 92, UNDEFINED], + [94, 108, 109, 115, UNDEFINED], + [99, 102, 116, 103, UNDEFINED], ], ) @@ -398,29 +399,29 @@ def test_stephen_004(): [ [ 1, - 2**32 - 1, - 2**32 - 1, - 2**32 - 1, - 2**32 - 1, - 2**32 - 1, - 2**32 - 1, + UNDEFINED, + UNDEFINED, + UNDEFINED, + UNDEFINED, + UNDEFINED, + UNDEFINED, ], [2, 3], [4], - [2**32 - 1, 2**32 - 1, 5], - [2**32 - 1, 2**32 - 1, 2**32 - 1, 2**32 - 1, 6], - [2**32 - 1, 2**32 - 1, 2**32 - 1, 7, 8], + [UNDEFINED, UNDEFINED, 5], + [UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, 6], + [UNDEFINED, UNDEFINED, UNDEFINED, 7, 8], [9], [ - 2**32 - 1, - 2**32 - 1, - 2**32 - 1, - 2**32 - 1, - 2**32 - 1, - 2**32 - 1, + UNDEFINED, + UNDEFINED, + UNDEFINED, + UNDEFINED, + UNDEFINED, + UNDEFINED, 10, ], - [2**32 - 1, 2**32 - 1, 2**32 - 1, 2**32 - 1, 2**32 - 1, 10], + [UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, 10], [7], ], ) @@ -428,8 +429,8 @@ def test_stephen_004(): m = word_graph.last_node_on_path(S.word_graph(), 0, rule)[0] rule = p.rules[1] n = word_graph.last_node_on_path(S.word_graph(), 0, rule)[0] - assert m != 2**32 - 1 - assert n != 2**32 - 1 + assert m != UNDEFINED + assert n != UNDEFINED assert m == n assert S.word_graph().number_of_nodes() == 11 assert stephen.accepts(S, to_word("aaaeaag")) @@ -1149,10 +1150,10 @@ def test_Stephen_038(): assert S.word_graph() == WordGraph( 4, [ - [1, 2, 2**32 - 1, 2**32 - 1], - [2**32 - 1, 1, 0, 1], - [2**32 - 1, 3, 2**32 - 1, 0], - [2**32 - 1, 2**32 - 1, 2**32 - 1, 2], + [1, 2, UNDEFINED, UNDEFINED], + [UNDEFINED, 1, 0, 1], + [UNDEFINED, 3, UNDEFINED, 0], + [UNDEFINED, UNDEFINED, UNDEFINED, 2], ], ) @@ -1193,13 +1194,13 @@ def test_Stephen_040(): assert S.word_graph() == WordGraph( 7, [ - [1, 2**32 - 1, 2, 2**32 - 1, 3, 2**32 - 1], - [2**32 - 1, 2**32 - 1, 2**32 - 1, 0, 4, 2**32 - 1], - [2**32 - 1, 2**32 - 1, 2**32 - 1, 2**32 - 1, 5, 0], - [4, 0, 5, 2**32 - 1, 2**32 - 1, 2**32 - 1], - [2**32 - 1, 1, 6, 3, 2**32 - 1, 2**32 - 1], - [6, 2, 2**32 - 1, 2**32 - 1, 2**32 - 1, 3], - [2**32 - 1, 2**32 - 1, 2**32 - 1, 5, 2**32 - 1, 4], + [1, UNDEFINED, 2, UNDEFINED, 3, UNDEFINED], + [UNDEFINED, UNDEFINED, UNDEFINED, 0, 4, UNDEFINED], + [UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, 5, 0], + [4, 0, 5, UNDEFINED, UNDEFINED, UNDEFINED], + [UNDEFINED, 1, 6, 3, UNDEFINED, UNDEFINED], + [6, 2, UNDEFINED, UNDEFINED, UNDEFINED, 3], + [UNDEFINED, UNDEFINED, UNDEFINED, 5, UNDEFINED, 4], ], ) @@ -1263,13 +1264,13 @@ def test_stephen_043(): assert S.word_graph() == WordGraph( 7, [ - [1, 2**32 - 1, 2, 2**32 - 1, 3, 2**32 - 1], - [2**32 - 1, 2**32 - 1, 2**32 - 1, 0, 4, 2**32 - 1], - [2**32 - 1, 2**32 - 1, 2**32 - 1, 2**32 - 1, 5, 0], - [4, 0, 5, 2**32 - 1, 2**32 - 1, 2**32 - 1], - [2**32 - 1, 1, 6, 3, 2**32 - 1, 2**32 - 1], - [6, 2, 2**32 - 1, 2**32 - 1, 2**32 - 1, 3], - [2**32 - 1, 2**32 - 1, 2**32 - 1, 5, 2**32 - 1, 4], + [1, UNDEFINED, 2, UNDEFINED, 3, UNDEFINED], + [UNDEFINED, UNDEFINED, UNDEFINED, 0, 4, UNDEFINED], + [UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, 5, 0], + [4, 0, 5, UNDEFINED, UNDEFINED, UNDEFINED], + [UNDEFINED, 1, 6, 3, UNDEFINED, UNDEFINED], + [6, 2, UNDEFINED, UNDEFINED, UNDEFINED, 3], + [UNDEFINED, UNDEFINED, UNDEFINED, 5, UNDEFINED, 4], ], ) diff --git a/tests/test_word_graph.py b/tests/test_word_graph.py index 524b8c153..8377efd83 100644 --- a/tests/test_word_graph.py +++ b/tests/test_word_graph.py @@ -270,7 +270,7 @@ def test_meeter(word_graph_fixture): wg1.remove_target(4, 0) meet = Meeter() - assert wg1 == WordGraph(5, [[1], [2], [3], [4], [2**32 - 1]]) + assert wg1 == WordGraph(5, [[1], [2], [3], [4], [UNDEFINED]]) assert meet(wg1, wg1) == wg1 wg2 = WordGraph(2, [[1, 0], [1, 0]]) @@ -286,11 +286,10 @@ def test_meeter(word_graph_fixture): def test_joiner(word_graph_fixture): wg1, _ = word_graph_fixture wg1.remove_target(0, 0) - assert wg1 == WordGraph(5, [[2**32 - 1], [2], [3], [4], [0]]) + assert wg1 == WordGraph(5, [[UNDEFINED], [2], [3], [4], [0]]) join = Joiner() - # TODO(later) use UNDEFINED here instead of 2**32 -1 - assert join(wg1, wg1) == WordGraph(1, [[2**32 - 1]]) + assert join(wg1, wg1) == WordGraph(1, [[UNDEFINED]]) wg3 = WordGraph(2, [[1, 1], [1, 1]]) wg2 = WordGraph(2, [[1, 0], [1, 0]]) @@ -305,7 +304,10 @@ def test_joiner(word_graph_fixture): def test_str(word_graph_fixture): wg1, wg2 = word_graph_fixture assert str(wg1) == "WordGraph(5, [[1], [2], [3], [4], [0]])" - assert str(wg2) == "WordGraph(10, [[1], [2], [3], [4], [0], [6], [7], [8], [9], [5]])" + assert ( + str(wg2) + == "WordGraph(10, [[1], [2], [3], [4], [0], [6], [7], [8], [9], [5]])" + ) def test_copy(word_graph_fixture):