Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not allow order of AbelianGroup generator to be negative #38970

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/sage/groups/abelian_gps/abelian_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,13 @@ def _normalize(n, gens_orders=None, names='f'):
Traceback (most recent call last):
...
TypeError: unable to convert 's' to an integer

Verify that :issue:`38967` is fixed::

sage: AbelianGroup([-4])
Traceback (most recent call last):
...
ValueError: orders of generators cannot be negative but they are (-4,)
"""
if gens_orders is None:
if isinstance(n, (list, tuple)):
Expand All @@ -376,6 +383,8 @@ def _normalize(n, gens_orders=None, names='f'):
if len(gens_orders) < n:
gens_orders = [0] * (n - len(gens_orders)) + list(gens_orders)
gens_orders = tuple(ZZ(i) for i in gens_orders)
if any(i < 0 for i in gens_orders):
raise ValueError(f'orders of generators cannot be negative but they are {gens_orders}')
if len(gens_orders) > n:
raise ValueError('gens_orders (='+str(gens_orders)+') must have length n (='+str(n)+')')
if isinstance(names, list):
Expand Down
Loading