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

fix random doctest failure in generic has_order() function #37102

Merged
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
15 changes: 14 additions & 1 deletion src/sage/groups/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,18 @@ def has_order(P, n, operation='+'):
True
sage: has_order(el, o.factor())
True
sage: has_order(el, ZZ(randrange(100)*o + randrange(o)))
sage: not_o = ZZ(randrange(100*o))
sage: not_o += (not_o == o)
sage: has_order(el, not_o)
False

Check for :issue:`37102`::

sage: from sage.groups.generic import has_order
sage: x = Mod(9, 24)
sage: has_order(x, 0)
False
sage: has_order(x, -8)
False

.. NOTE::
Expand All @@ -1471,6 +1482,8 @@ def has_order(P, n, operation='+'):
*computing* the order using :func:`order_from_multiple`.
"""
if isinstance(n, sage.rings.integer.Integer):
if n <= 0:
return False
n = n.factor()

G = P.parent()
Expand Down
Loading