Skip to content

Commit d5d2b5b

Browse files
author
Release Manager
committed
Trac #32860: Inaccurate documentation for number field elements_of_norm
For a number field `K` and an integer `n`, the function `K.elements_of_norm(n)` returns a list of integral elements of `K` with norm `n`, up to multiplication by units of positive norm. The docstring says that `n` should be an "integer in this number field", which is wrong (and makes no sense): it must be a rational integer. If you give the function something else (e.g. a non-integral rational or an element of `K` (even `K(0)`), a `PariError` is raised, and it would be better for Sage to check the input, say by trying `n = ZZ(n)` first. URL: https://trac.sagemath.org/32860 Reported by: cremona Ticket author(s): Frédéric Chapoton Reviewer(s): John Cremona
2 parents e0ffa0f + 59e2efa commit d5d2b5b

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

build/pkgs/configure/checksums.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
tarball=configure-VERSION.tar.gz
2-
sha1=ddc95e8bbd9b0a04576bf0040cb6e9a3743a7025
3-
md5=b6062b6b285211a65a7b005eac230ff4
4-
cksum=3715468583
2+
sha1=63a185e63945337d9e35c8befb0842a338f8d485
3+
md5=d1ad922ab9d630f1f3d05ea2cd265a0d
4+
cksum=727308674
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3e2eba8dba557a9626a3c465206b89776f3ebeac
1+
866a2b24b7ffc1f489c181243c6b90659f79e741

src/sage/rings/number_field/number_field.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
# the License, or (at your option) any later version.
105105
# https://www.gnu.org/licenses/
106106
# ****************************************************************************
107-
107+
from __future__ import annotations
108108
from sage.misc.cachefunc import cached_method
109109
from sage.misc.superseded import (deprecation,
110110
deprecated_function_alias)
@@ -5726,13 +5726,13 @@ def trace_dual_basis(self, b):
57265726
raise ValueError('Not a basis of the number field.')
57275727
return [sum([v[i]*b[i] for i in range(len(b))]) for v in M.inverse()]
57285728

5729-
def elements_of_norm(self, n, proof=None):
5729+
def elements_of_norm(self, n, proof=None) -> list:
57305730
"""
5731-
Return a list of elements of norm ``n``.
5731+
Return a list of elements of norm `n`.
57325732
57335733
INPUT:
57345734
5735-
- ``n`` -- integer in this number field
5735+
- `n` -- integer
57365736
57375737
- ``proof`` -- boolean (default: ``True``, unless you called
57385738
:meth:`proof.number_field` and set it otherwise)
@@ -5761,6 +5761,7 @@ def elements_of_norm(self, n, proof=None):
57615761
sage: x in (7/225*a^2 - 7/75*a - 42/25, 28/225*a^2 + 77/75*a - 133/25)
57625762
True
57635763
"""
5764+
n = ZZ(n)
57645765
proof = proof_flag(proof)
57655766
B = self.pari_bnf(proof).bnfisintnorm(n)
57665767
return [self(x, check=False) for x in B]

0 commit comments

Comments
 (0)