Skip to content

Commit

Permalink
Style correction and removed useless _get_perm() method
Browse files Browse the repository at this point in the history
  • Loading branch information
JosePisco committed Jun 3, 2024
1 parent a44383f commit 1052244
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
19 changes: 5 additions & 14 deletions src/sage/combinat/SJT.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,14 @@ class SJT(CombinatorialElement):
[1, 2, 3, 4]
sage: s = s.next(); s
[1, 2, 4, 3]
sage: p = Permutation(s._get_perm(), algorithm='sjt', sjt=s)
sage: p = Permutation(s._list, algorithm='sjt', sjt=s)
sage: p
[1, 2, 4, 3]
sage: p.next()
[1, 4, 2, 3]
TESTS::
sage: from sage.combinat.SJT import SJT
sage: s = SJT([1, 2, 3, 4]); s
[1, 2, 3, 4]
Expand All @@ -97,7 +98,7 @@ def __init__(self, l, directions=None) -> None:
- ``l`` -- list; a list of ordered ``int``.
- ``directions`` -- list (default: ``None`` ); a list of directions for
- ``directions`` -- list (default: ``None``); a list of directions for
each element in the permuted list. Used when constructing permutations
from a pre-defined internal state.
Expand All @@ -108,7 +109,7 @@ def __init__(self, l, directions=None) -> None:
[1, 2, 3, 4]
sage: s = s.next(); s
[1, 2, 4, 3]
sage: p = Permutation(s._get_perm(), algorithm='sjt', sjt=s)
sage: p = Permutation(s._list, algorithm='sjt', sjt=s)
sage: p
[1, 2, 4, 3]
sage: p.next()
Expand Down Expand Up @@ -162,22 +163,12 @@ def __idx_largest_element_non_zero_direction(self, perm, directions):

return index

def _get_perm(self):
r"""
Return the current permutation of ``self``.
"""
return self._list

def next(self):
r"""
Produce the next permutation of ``self`` following the
Steinhaus-Johnson-Trotter algorithm.
OUTPUT: a tuple of
- the list of the next permutation
- the list of associated directions
OUTPUT: the list of the next permutation
EXAMPLES::
Expand Down
7 changes: 2 additions & 5 deletions src/sage/combinat/permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ class Permutation(CombinatorialElement):
sage: p = Permutation([1, 2, 3], algorithm='sjt')
sage: for _ in range(6):
....: p = p.next()
....:
sage: p
False
Expand Down Expand Up @@ -477,8 +476,7 @@ class Permutation(CombinatorialElement):
"""
@staticmethod
@rename_keyword(deprecation=35233, check_input='check')
def __classcall_private__(cls, l, algorithm='lex', sjt=None,
check=True):
def __classcall_private__(cls, l, algorithm='lex', sjt=None, check=True):
"""
Return a permutation in the general permutations parent.
Expand Down Expand Up @@ -867,7 +865,6 @@ def __next__(self):
sage: for _ in range(factorial(len(l))):
....: s.add(p)
....: p = p.next()
....:
sage: p
False
sage: assert(len(s)) == factorial(len(l))
Expand All @@ -878,7 +875,7 @@ def __next__(self):
sjt = self._sjt.next()
if sjt is False:
return False
return Permutations()(sjt._get_perm(), algorithm='sjt', sjt=sjt)
return Permutations()(sjt._list, algorithm='sjt', sjt=sjt)

p = self[:]
n = len(self)
Expand Down

0 comments on commit 1052244

Please sign in to comment.