Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
src/sage/schemes/elliptic_curves/constructor.py: Remove use of SR, is…
Browse files Browse the repository at this point in the history
…_SymbolicEquation; add test for symbolic input
  • Loading branch information
Matthias Koeppe committed Oct 17, 2021
1 parent 80a8f9e commit a287531
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/sage/schemes/elliptic_curves/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
_Fields = Fields()

from sage.structure.sequence import Sequence
from sage.structure.element import parent
from sage.structure.element import parent, Expression
from sage.structure.factory import UniqueFactory
from sage.symbolic.ring import SR
from sage.symbolic.expression import is_SymbolicEquation


class EllipticCurveFactory(UniqueFactory):
Expand Down Expand Up @@ -385,6 +383,20 @@ def create_key_and_extra_args(self, x=None, y=None, j=None, minimal_twist=True,
incorrect data may lead to wrong results of computations
instead of errors or warnings.
TESTS::
sage: var('x', 'y', 'v', 'w')
(x, y, v, w)
sage: EllipticCurve(y^2 + y > x^3 + x - 9)
Traceback (most recent call last):
...
ValueError: no symbolic relations other than equalities are allowed
sage: E = EllipticCurve(y^2 + y == x^3 + x - 9)
sage: E is EllipticCurve(y^2 + y - ( x^3 + x - 9 ))
True
sage: R.<x,y> = QQ[]
sage: E is EllipticCurve(y^2 + y - ( x^3 + x - 9 ))
True
"""
R = None
if is_Ring(x):
Expand All @@ -400,10 +412,13 @@ def create_key_and_extra_args(self, x=None, y=None, j=None, minimal_twist=True,
raise ValueError("First parameter (if present) must be a ring when j is specified")
x = coefficients_from_j(j, minimal_twist)

if is_SymbolicEquation(x):
if isinstance(x, Expression) and x.is_relational():
import operator
if x.operator() != operator.eq:
raise ValueError("no symbolic relations other than equalities are allowed")
x = x.lhs() - x.rhs()

if parent(x) is SR:
if isinstance(parent(x), sage.rings.abc.SymbolicRing):
x = x._polynomial_(rings.QQ['x', 'y'])

if is_MPolynomial(x):
Expand Down

0 comments on commit a287531

Please sign in to comment.