Skip to content

Commit b122005

Browse files
author
Release Manager
committed
Trac #32791: Human Readable Error-Message for Elliptic curve constructor.
At the moment the error-message when trying to create an elliptic curve from a formula that defines a singular curve is not particularly user- friendly: {{{ sage: EllipticCurve(GF(7), [-2,0,0,0,0]) [...] ArithmeticError: invariants (5, 0, 0, 0, 0) define a singular curve }}} This is trivially improvable by a one-line-fix with the tools that are already implemented (patch at the end) to give the following much more comprehensible error: {{{ ArithmeticError: y^2 + 5*x*y = x^3 defines a singular curve }}} I wanted to create this as a pull-request, but github told me that they don't get accepted there and I couldn't figure out where to create one directly, so please just apply the following patch: {{{ --- a/src/sage/schemes/elliptic_curves/ell_generic.py +++ b/src/sage/schemes/elliptic_curves/ell_generic.py @@ -145,7 +145,7 @@ class EllipticCurve_generic(WithEqualityById, plane_curve.ProjectivePlaneCurve): self.__base_ring = K self.__ainvs = tuple(K(a) for a in ainvs) if self.discriminant() == 0: - raise ArithmeticError("invariants " + str(ainvs) + " define a singular curve") + raise ArithmeticError(self._equation_string() + " defines a singular curve") PP = projective_space.ProjectiveSpace(2, K, names='xyz') x, y, z = PP.coordinate_ring().gens() a1, a2, a3, a4, a6 = ainvs }}} URL: https://trac.sagemath.org/32791 Reported by: gh-Florianjw Ticket author(s): Florian Weber Reviewer(s): Lorenz Panny
2 parents 40b1190 + 9592ab3 commit b122005

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/sage/doctest/forker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ def report_unexpected_exception(self, out, test, example, exc_info):
14751475
sage: old_prompt = sage0._prompt
14761476
sage: sage0._prompt = r"\(Pdb\) "
14771477
sage: sage0.eval("DTR.run(DT, clear_globs=False)") # indirect doctest
1478-
'... ArithmeticError("invariants " + str(ainvs) + " define a singular curve")'
1478+
'... ArithmeticError(self._equation_string() + " defines a singular curve")'
14791479
sage: sage0.eval("l")
14801480
'...if self.discriminant() == 0:...raise ArithmeticError...'
14811481
sage: sage0.eval("u")

src/sage/schemes/elliptic_curves/ell_generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def __init__(self, K, ainvs):
145145
self.__base_ring = K
146146
self.__ainvs = tuple(K(a) for a in ainvs)
147147
if self.discriminant() == 0:
148-
raise ArithmeticError("invariants " + str(ainvs) + " define a singular curve")
148+
raise ArithmeticError(self._equation_string() + " defines a singular curve")
149149
PP = projective_space.ProjectiveSpace(2, K, names='xyz')
150150
x, y, z = PP.coordinate_ring().gens()
151151
a1, a2, a3, a4, a6 = ainvs

0 commit comments

Comments
 (0)