Skip to content

Commit 3570b48

Browse files
stephen: fix for upstream changes
1 parent 5b2d0fb commit 3570b48

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

src/stephen.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,14 @@ it labels a path in :any:`Stephen.word_graph` with source ``0``.
379379
this function may never terminate.
380380
)pbdoc");
381381

382-
m.def("stephen_left_factors",
383-
&stephen::left_factors<PresentationType>,
384-
py::arg("s"),
385-
R"pbdoc(
382+
m.def(
383+
"stephen_left_factors",
384+
[](Stephen_& s) {
385+
auto range = stephen::left_factors(s);
386+
return py::make_iterator(rx::begin(range), rx::end(range));
387+
},
388+
py::arg("s"),
389+
R"pbdoc(
386390
:sig=(s: Stephen) -> Paths:
387391
:only-document-once:
388392
Returns a :any:`Paths` object containing all the words (in short-lex order)
@@ -504,10 +508,14 @@ equivalent to :math:`u` in the semigroup defined by
504508
this function may never terminate.
505509
)pbdoc");
506510

507-
m.def("stephen_words_accepted",
508-
&stephen::words_accepted<PresentationType>,
509-
py::arg("s"),
510-
R"pbdoc(
511+
m.def(
512+
"stephen_words_accepted",
513+
[](Stephen_& s) {
514+
auto range = stephen::words_accepted(s);
515+
return py::make_iterator(rx::begin(range), rx::end(range));
516+
},
517+
py::arg("s"),
518+
R"pbdoc(
511519
:sig=(s: Stephen) -> Paths:
512520
:only-document-once:
513521

tests/test_stephen.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def verify_c4_normal_form(p, word, nf):
8989
assert sorted(list(stephen.words_accepted(S)), key=lexicographic_compare_key_func)[0] == nf
9090

9191
assert all(stephen.accepts(S, w) for w in stephen.words_accepted(S))
92-
assert stephen.number_of_words_accepted(S) == len(stephen.words_accepted(S))
92+
assert stephen.number_of_words_accepted(S) == sum(1 for _ in stephen.words_accepted(S))
9393

9494

9595
def verify_c4_equal_to(p, word1, word2):
@@ -521,7 +521,7 @@ def test_stephen_008():
521521
] == to_word("dfabcdf")
522522

523523
assert all(stephen.accepts(S, w) for w in stephen.words_accepted(S))
524-
assert stephen.number_of_words_accepted(S) == len(stephen.words_accepted(S))
524+
assert stephen.number_of_words_accepted(S) == sum(1 for _ in stephen.words_accepted(S))
525525

526526
S.set_word(to_word("abcdfceg")).run()
527527
assert stephen.number_of_words_accepted(S) == 16
@@ -572,7 +572,7 @@ def test_Stephen_009():
572572

573573
S.set_word(to_word("acba")).run()
574574

575-
assert list(stephen.words_accepted(S)) == [to_word("aabc"), to_word("acba")]
575+
assert list(stephen.words_accepted(S)) == [to_word("acba"), to_word("aabc")]
576576

577577
verify_c4_normal_form(p, to_word("acba"), to_word("aabc"))
578578

@@ -1434,7 +1434,7 @@ def test_stephen_045():
14341434
T.set_word(T.word() * 2)
14351435
T.run()
14361436
assert S == T
1437-
assert stephen.words_accepted(S).get() == [0, 2, 0, 2]
1437+
assert next(stephen.words_accepted(S)) == [0, 2, 0, 2]
14381438
assert stephen.number_of_left_factors(S) == POSITIVE_INFINITY
14391439
S.set_word(to_word("aBbcaABAabCc"))
14401440
T.set_word(to_word("CcBAabaACBbA"))

0 commit comments

Comments
 (0)