Skip to content

Commit

Permalink
Quickly fix a broken doctest
Browse files Browse the repository at this point in the history
test_semi_infinite should now handle words which are above the basis
provided.
  • Loading branch information
DMRobertson committed Dec 8, 2014
1 parent 88cd2ec commit 3024857
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 10 additions & 5 deletions thompson/automorphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ def orbit_type(self, y, basis):
x1 a2 a2: Periodic component of order 2
with respect to the basis [x1 a1 a1 a1, x1 a1 a1 a2, x1 a1 a2, x1 a2 a1, x1 a2 a2]
>>> print_component_types(example_4_5, basis=example_4_5.domain, words=['x', 'x a1', 'x a2'])
x: Incomplete component
x a1: Incomplete component
x a2: Incomplete component
x1: Incomplete component
x1 a1: Incomplete component
x1 a2: Incomplete component
with respect to the basis [x1 a1 a1 a1, x1 a1 a1 a2, x1 a1 a2, x1 a2 a1, x1 a2 a2]
>>> #Example 4.11
Expand Down Expand Up @@ -388,7 +388,7 @@ def orbit_type(self, y, basis):
def test_semi_infinite(self, y, basis, backward=False):
r"""Computes the orbit type of *y* under the current automorphism :math:`\psi` with respect to *basis* in the given direction. Let :math:`y\psi^m` be the most recently computed image. The process stops when either:
1. :math:`y\psi^m` is not below the *basis*.
1. :math:`y\psi^m` is not below the *basis*, for some :math:`m\geq 0`.
- infinite: ``False``
- start: ``0``
Expand All @@ -410,7 +410,12 @@ def test_semi_infinite(self, y, basis, backward=False):
images = [y]
m = 0
heads = set()
prefix, _ = basis.test_above(y)

result = basis.test_above(y)
if result is None:
return False, 0, m-1, images

prefix, _ = result
while True:
heads.add(prefix)
m += 1
Expand Down
3 changes: 3 additions & 0 deletions thompson/orbits.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from numbers import Number

from .word import format
from .generators import Generators

__all__ = ["ComponentType", "print_component_types", "SolutionSet"]

Expand Down Expand Up @@ -116,6 +117,8 @@ def print_component_types(aut, basis=None, words=None):
basis = aut._seminormal_form_start_point()
if words is None:
words = basis
elif not isinstance(words, Generators):
words = Generators(aut.domain.signature, words)
for w in words:
print("{}: {}".format(
w, aut.orbit_type(w, basis)[0]))
Expand Down

0 comments on commit 3024857

Please sign in to comment.