Skip to content

Commit 31a08e0

Browse files
author
Release Manager
committed
gh-37288: Directly convert PermutationGroup element into sized Permutation This patch fixes #37284 by converting the input into a Permutation class object if it is the object of another class. <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #37288 Reported by: Ruchit Jagodara Reviewer(s): grhkm21, Travis Scrimshaw
2 parents bab9e4c + 54747b6 commit 31a08e0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/sage/combinat/permutation.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7092,7 +7092,19 @@ def _element_constructor_(self, x, check=True):
70927092
[1, 4, 5, 2, 3, 6]
70937093
sage: Permutations(6)(x) # known bug
70947094
[1, 4, 5, 2, 3, 6]
7095+
7096+
Ensure that :issue:`37284` is fixed::
7097+
7098+
sage: PG = PermutationGroup([[(1,2,3),(5,6)],[(7,8)]])
7099+
sage: P8 = Permutations(8)
7100+
sage: p = PG.an_element()
7101+
sage: q = P8(p); q
7102+
[2, 3, 1, 4, 6, 5, 8, 7]
7103+
sage: q.parent()
7104+
Standard permutations of 8
70957105
"""
7106+
if isinstance(x, PermutationGroupElement):
7107+
return self. _from_permutation_group_element(x)
70967108
if len(x) < self.n:
70977109
x = list(x) + list(range(len(x) + 1, self.n + 1))
70987110
return self.element_class(self, x, check=check)

0 commit comments

Comments
 (0)