Skip to content

Commit cb95e67

Browse files
Joseph-Edwardsjames-d-mitchell
authored andcommitted
Test kb + word type -> pres
1 parent 0f1526a commit cb95e67

1 file changed

Lines changed: 22 additions & 14 deletions

File tree

tests/test_to.py

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
FroidurePinKEString,
2121
FroidurePinKEWord,
2222
FroidurePinTCE,
23+
PresentationStrings,
24+
PresentationWords,
2325
)
2426

2527
from libsemigroups_pybind11 import (
@@ -101,26 +103,32 @@ def check_cong_to_froidure_pin(Type, Word, **kwargs):
101103

102104
def check_cong_to_todd_coxeter(Type, Word, **kwargs):
103105
thing = cong_from_sample_pres(Type, Word, **kwargs)
104-
tc = to(congruence_kind.twosided, thing, Return=ToddCoxeter)
106+
tc = to(congruence_kind.twosided, thing, Return=(ToddCoxeter,))
105107
tc.run()
106108
assert tc.number_of_classes() == 3
107109
return tc
108110

109111

110-
def check_knuth_bendix_to_pres(Word, Rewriter):
111-
p = sample_pres(Word)
112+
def check_knuth_bendix_to_pres(WordIn, WordOut, Rewriter):
113+
p = sample_pres(WordIn)
112114
kb = KnuthBendix(congruence_kind.twosided, p, Rewriter=Rewriter)
113-
q = to(kb, Return=Presentation)
114-
115-
assert isinstance(q, type(p))
116-
117-
presentation.sort_each_rule(p)
118-
presentation.sort_each_rule(q)
119-
presentation.sort_rules(p)
120-
presentation.sort_rules(q)
121-
122-
# This is because sample_pres is already confluent
123-
assert p == q
115+
q = to(kb, Return=(Presentation, WordOut))
116+
117+
if WordOut is str:
118+
assert isinstance(to_cxx(q), PresentationStrings)
119+
else:
120+
assert isinstance(to_cxx(q), PresentationWords)
121+
122+
assert len(q.rules) == kb.number_of_active_rules() * 2
123+
124+
if WordIn is WordOut:
125+
assert q == to(kb, Return=(Presentation,))
126+
presentation.sort_each_rule(p)
127+
presentation.sort_each_rule(q)
128+
presentation.sort_rules(p)
129+
presentation.sort_rules(q)
130+
# This is because sample_pres is already confluent
131+
assert p == q
124132

125133

126134
def check_froidure_pin_to_pres(Word):

0 commit comments

Comments
 (0)