Skip to content

Commit

Permalink
gh-37288: Directly convert PermutationGroup element into sized Permut…
Browse files Browse the repository at this point in the history
…ation

    
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
  • Loading branch information
Release Manager committed Mar 21, 2024
2 parents bab9e4c + 54747b6 commit 31a08e0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/sage/combinat/permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7092,7 +7092,19 @@ def _element_constructor_(self, x, check=True):
[1, 4, 5, 2, 3, 6]
sage: Permutations(6)(x) # known bug
[1, 4, 5, 2, 3, 6]
Ensure that :issue:`37284` is fixed::
sage: PG = PermutationGroup([[(1,2,3),(5,6)],[(7,8)]])
sage: P8 = Permutations(8)
sage: p = PG.an_element()
sage: q = P8(p); q
[2, 3, 1, 4, 6, 5, 8, 7]
sage: q.parent()
Standard permutations of 8
"""
if isinstance(x, PermutationGroupElement):
return self. _from_permutation_group_element(x)
if len(x) < self.n:
x = list(x) + list(range(len(x) + 1, self.n + 1))
return self.element_class(self, x, check=check)
Expand Down

0 comments on commit 31a08e0

Please sign in to comment.