Skip to content

Commit a82cf2c

Browse files
committed
src/sage/rings/polynomial/multi_polynomial_ideal.py: no surf plotting
Disable plotting with the experimental (now removed) surf package: * Delete the MPolynomialIdeal_singular_repr.plot() method. This was the plotting implementation that tried to use surf. Most of its doctest methods still work because they were testing the wrong method. * Drop the algorithm keyword from MPolynomialIdeal.plot(). Now that algorithm="surf" is invalid, there are no other algorithms. * Unindent the body of MPolynomialIdeal.plot(). By raising an error immediately if the number of variables wrong, we can unindent the body of the function one level. * Allow only two variables in MPolynomialIdeal.plot(). This matches the documentation, and is all that worked anyway, because the presence of three variables would invoke the surf-based no-op. Closes: #6316 Closes: #22590
1 parent 5132642 commit a82cf2c

File tree

1 file changed

+46
-106
lines changed

1 file changed

+46
-106
lines changed

src/sage/rings/polynomial/multi_polynomial_ideal.py

Lines changed: 46 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -680,58 +680,6 @@ def _groebner_strategy(self):
680680

681681
return GroebnerStrategy(MPolynomialIdeal(self.ring(), self.groebner_basis()))
682682

683-
def plot(self, singular=None):
684-
r"""
685-
If you somehow manage to install surf, perhaps you can use
686-
this function to implicitly plot the real zero locus of this
687-
ideal (if principal).
688-
689-
INPUT:
690-
691-
- ``self`` -- must be a principal ideal in 2 or 3 vars over `\QQ`
692-
693-
EXAMPLES:
694-
695-
Implicit plotting in 2-d::
696-
697-
sage: R.<x,y> = PolynomialRing(QQ,2)
698-
sage: I = R.ideal([y^3 - x^2])
699-
sage: I.plot() # cusp
700-
Graphics object consisting of 1 graphics primitive
701-
sage: I = R.ideal([y^2 - x^2 - 1])
702-
sage: I.plot() # hyperbola
703-
Graphics object consisting of 1 graphics primitive
704-
sage: I = R.ideal([y^2 + x^2*(1/4) - 1])
705-
sage: I.plot() # ellipse
706-
Graphics object consisting of 1 graphics primitive
707-
sage: I = R.ideal([y^2-(x^2-1)*(x-2)])
708-
sage: I.plot() # elliptic curve
709-
Graphics object consisting of 1 graphics primitive
710-
711-
Implicit plotting in 3-d::
712-
713-
sage: R.<x,y,z> = PolynomialRing(QQ,3)
714-
sage: I = R.ideal([y^2 + x^2*(1/4) - z])
715-
sage: I.plot() # a cone; optional - surf
716-
sage: I = R.ideal([y^2 + z^2*(1/4) - x])
717-
sage: I.plot() # same code, from a different angle; optional - surf
718-
sage: I = R.ideal([x^2*y^2+x^2*z^2+y^2*z^2-16*x*y*z])
719-
sage: I.plot() # Steiner surface; optional - surf
720-
721-
AUTHORS:
722-
723-
- David Joyner (2006-02-12)
724-
"""
725-
if self.ring().characteristic() != 0:
726-
raise TypeError("base ring must have characteristic 0")
727-
if not self.is_principal():
728-
raise TypeError("self must be principal")
729-
if singular is None:
730-
singular = singular_default
731-
singular.lib('surf')
732-
I = singular(self)
733-
I.plot()
734-
735683
@require_field
736684
@cached_method
737685
@libsingular_gb_standard_options
@@ -5195,9 +5143,6 @@ def plot(self, *args, **kwds):
51955143
51965144
- ``self`` -- a principal ideal in 2 variables
51975145
5198-
- ``algorithm`` -- set this to 'surf' if you want 'surf' to
5199-
plot the ideal (default: ``None``)
5200-
52015146
- ``*args`` -- (optional) tuples ``(variable, minimum, maximum)``
52025147
for plotting dimensions
52035148
@@ -5210,45 +5155,45 @@ def plot(self, *args, **kwds):
52105155
52115156
sage: R.<x,y> = PolynomialRing(QQ, 2)
52125157
sage: I = R.ideal([y^3 - x^2])
5213-
sage: I.plot() # cusp # needs sage.plot
5158+
sage: I.plot() # cusp, needs sage.plot
52145159
Graphics object consisting of 1 graphics primitive
52155160
52165161
::
52175162
52185163
sage: I = R.ideal([y^2 - x^2 - 1])
5219-
sage: I.plot((x,-3, 3), (y, -2, 2)) # hyperbola # needs sage.plot
5164+
sage: I.plot((x,-3, 3), (y, -2, 2)) # hyperbola, needs sage.plot
52205165
Graphics object consisting of 1 graphics primitive
52215166
52225167
::
52235168
52245169
sage: I = R.ideal([y^2 + x^2*(1/4) - 1])
5225-
sage: I.plot() # ellipse # needs sage.plot
5170+
sage: I.plot() # ellipse, needs sage.plot
52265171
Graphics object consisting of 1 graphics primitive
52275172
52285173
::
52295174
52305175
sage: I = R.ideal([y^2-(x^2-1)*(x-2)])
5231-
sage: I.plot() # elliptic curve # needs sage.plot
5176+
sage: I.plot() # elliptic curve, needs sage.plot
52325177
Graphics object consisting of 1 graphics primitive
52335178
52345179
::
52355180
52365181
sage: f = ((x+3)^3 + 2*(x+3)^2 - y^2)*(x^3 - y^2)*((x-3)^3-2*(x-3)^2-y^2)
52375182
sage: I = R.ideal(f)
5238-
sage: I.plot() # the Singular logo # needs sage.plot
5183+
sage: I.plot() # the Singular logo, needs sage.plot
52395184
Graphics object consisting of 1 graphics primitive
52405185
52415186
::
52425187
52435188
sage: R.<x,y> = PolynomialRing(QQ, 2)
52445189
sage: I = R.ideal([x - 1])
5245-
sage: I.plot((y, -2, 2)) # vertical line # needs sage.plot
5190+
sage: I.plot((y, -2, 2)) # vertical line, needs sage.plot
52465191
Graphics object consisting of 1 graphics primitive
52475192
52485193
::
52495194
52505195
sage: I = R.ideal([-x^2*y + 1])
5251-
sage: I.plot() # blow up # needs sage.plot
5196+
sage: I.plot() # blow up, needs sage.plot
52525197
Graphics object consisting of 1 graphics primitive
52535198
"""
52545199
from sage.plot.all import implicit_plot
@@ -5264,50 +5209,45 @@ def plot(self, *args, **kwds):
52645209
f = self.gens()[0]
52655210

52665211
variables = sorted(f.parent().gens(), reverse=True)
5267-
5268-
if len(variables) == 2 and kwds.get('algorithm','') != 'surf':
5269-
V = [(variables[0], None, None), (variables[1], None, None)]
5270-
5271-
if len(args) > 2:
5272-
raise TypeError("Expected up to 2 optional parameters but got %d." % len(args))
5273-
5274-
# first check whether user supplied boundaries
5275-
for e in args:
5276-
if not isinstance(e, (tuple, list)) or len(e) != 3:
5277-
raise TypeError("Optional parameter must be list or tuple or length 3.")
5278-
v,mi,ma = e
5279-
5280-
if v not in variables:
5281-
raise TypeError("Optional parameter must contain variable of ideal generator.")
5282-
5283-
vi = variables.index(v)
5284-
V[vi] = v,mi,ma
5285-
5286-
# now check whether we should find boundaries
5287-
for var_index in range(2):
5288-
if V[var_index][1] is None:
5289-
v, mi, ma = variables[var_index], -10, 10
5290-
for i in range(mi, ma):
5291-
poly = f.subs({v:i}).univariate_polynomial().change_ring(RR)
5292-
if not poly or len(poly.roots()) > 0:
5293-
mi = i - 1
5294-
break
5295-
5296-
for i in range(ma, mi, -1):
5297-
poly = f.subs({v:i}).univariate_polynomial().change_ring(RR)
5298-
if not poly or len(poly.roots()) > 0:
5299-
ma = i + 1
5300-
break
5301-
V[var_index] = variables[var_index], mi, ma
5302-
5303-
kwds.setdefault("plot_points",200)
5304-
kwds.pop('algorithm', '')
5305-
return implicit_plot(f, V[0], V[1], **kwds)
5306-
5307-
elif len(variables) == 3 or kwds.get('algorithm','') == 'surf':
5308-
MPolynomialIdeal_singular_repr.plot(self, kwds.get("singular",singular_default))
5309-
else:
5310-
raise TypeError("Ideal generator may not have either 2 or 3 variables.")
5212+
if len(variables) != 2:
5213+
raise TypeError("ideal generator does not have two variables")
5214+
5215+
V = [(variables[0], None, None), (variables[1], None, None)]
5216+
5217+
if len(args) > 2:
5218+
raise TypeError("Expected up to 2 optional parameters but got %d." % len(args))
5219+
5220+
# first check whether user supplied boundaries
5221+
for e in args:
5222+
if not isinstance(e, (tuple, list)) or len(e) != 3:
5223+
raise TypeError("Optional parameter must be list or tuple or length 3.")
5224+
v,mi,ma = e
5225+
5226+
if v not in variables:
5227+
raise TypeError("Optional parameter must contain variable of ideal generator.")
5228+
5229+
vi = variables.index(v)
5230+
V[vi] = v,mi,ma
5231+
5232+
# now check whether we should find boundaries
5233+
for var_index in range(2):
5234+
if V[var_index][1] is None:
5235+
v, mi, ma = variables[var_index], -10, 10
5236+
for i in range(mi, ma):
5237+
poly = f.subs({v:i}).univariate_polynomial().change_ring(RR)
5238+
if not poly or len(poly.roots()) > 0:
5239+
mi = i - 1
5240+
break
5241+
5242+
for i in range(ma, mi, -1):
5243+
poly = f.subs({v:i}).univariate_polynomial().change_ring(RR)
5244+
if not poly or len(poly.roots()) > 0:
5245+
ma = i + 1
5246+
break
5247+
V[var_index] = variables[var_index], mi, ma
5248+
5249+
kwds.setdefault("plot_points",200)
5250+
return implicit_plot(f, V[0], V[1], **kwds)
53115251

53125252
def random_element(self, degree, compute_gb=False, *args, **kwds):
53135253
r"""

0 commit comments

Comments
 (0)