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

throw ValueError instead of TypeError when logarithm doesn't exist in AdditiveAbelianGroupWrapper #37142

Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions src/sage/groups/additive_abelian/additive_abelian_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
sage: G.discrete_log(V([6, 4]))
Traceback (most recent call last):
...
TypeError: Not in group
ValueError: not in group

::

Expand Down Expand Up @@ -617,7 +617,7 @@
if key in tab:
return tab[key] + vector(y)

raise TypeError('Not in group')
raise ValueError('not in group')

def _rec(j, k, c):

Expand Down Expand Up @@ -744,7 +744,7 @@
beta_q *= p
try:
e = _discrete_log_pgroup(p, vals, alphas, -beta_q)
except TypeError:
except ValueError:

Check warning on line 747 in src/sage/groups/additive_abelian/additive_abelian_wrapper.py

View check run for this annotation

Codecov / codecov/patch

src/sage/groups/additive_abelian/additive_abelian_wrapper.py#L747

Added line #L747 was not covered by tests
continue
# step 6
_expand_basis_pgroup(p, alphas, vals, beta, h, list(e) + [p**v])
Expand Down Expand Up @@ -815,7 +815,7 @@
beta, ord_beta = pgens.pop()
try:
dlog = _discrete_log_pgroup(p, vals, alphas, beta)
except TypeError:
except ValueError:
pass
else:
continue
Expand All @@ -828,7 +828,7 @@
# assert beta_q == beta * p**v
try:
e = _discrete_log_pgroup(p, vals, alphas, -beta_q)
except TypeError:
except ValueError:
continue
_expand_basis_pgroup(p, alphas, vals, beta, val_beta, list(e) + [p**v])
# assert all(a.order() == p**v for a,v in zip(alphas, vals))
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/fg_pid/fgp_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ def __contains__(self, x):
try:
self(x)
return True
except TypeError:
except (TypeError, ValueError):
return False

def submodule(self, x):
Expand Down
Loading