Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gh-36986: Fixed a bug in
AbelianGroup.Subgroup.gens_orders()
, which…
… returns the reduced order of the subgroup The `gens_orders()` method will returns the correct order after these changes. <!-- ^^^^^ 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" --> Created a new variable `gens_orders`: ```python gens_orders = [order_sage for g in H.GeneratorsOfGroup() if (order_sage := g.Order().sage()) is not infinity] ``` Modified the `AbelianGroup_class` class to include an additional argument, from which gens_orders is passed and assigned to `self.gens_orders`: ```python def __init__(self, generator_orders, names, gens_orders=None, category=None): self._gens_orders = generator_orders if gens_orders is None else gens_orders ``` Also, tests have been written for the `gens_orders` method: ```sage sage: G, (g0, g1) = AbelianGroup(2, [48, 0]).objgens() sage: G0 = G.subgroup([g0]) sage: len(G0.gens()) == len(G0.gens_orders()) True ``` Additionally, performed code cleanup. <!-- Why is this change required? What problem does it solve? --> Fixes #36974 Changing the `invs` variable directly to `[order_sage for g in H.GeneratorsOfGroup() if (order_sage := g.Order().sage()) is not infinity]` [here](https://github.com/sagemath/sage/blob/e249befd47ad8610 f74372533a2943ff7b2dde94/src/sage/groups/abelian_gps/abelian_group.py#L1 710) causes series of errors, as other variables depend on it. ### 📝 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. <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #36986 Reported by: Aman Moon Reviewer(s): Travis Scrimshaw
- Loading branch information