Ticket #1877: trac_1877.patch

File trac_1877.patch, 2.5 kB (added by jwmerrill, 4 months ago)
  • a/sage/plot/plot3d/parametric_plot3d.py

    old new  
    336336        sage: fz = -u + (2*0.84*cosh(0.4*u)*sinh(0.4*u))/(0.4*((sqrt(0.84)*cosh(0.4*u))^2 + (0.4*sin(sqrt(0.84)*v))^2)) 
    337337        sage: parametric_plot3d([fx, fy, fz], (u, -13.2, 13.2), (v, -37.4, 37.4), plot_points = [90,90], frame=False, color="green") 
    338338 
     339    TESTS: 
     340     
     341        sage: u, v = var('u,v') 
     342        sage: plot3d(u^2-v^2, (u, -1, 1), (u, -1, 1)) 
     343        Traceback (most recent call last): 
     344        ... 
     345        ValueError: Plot variables should be distinct, but both are u. 
    339346    """ 
    340347    # TODO: 
    341348    #   * Surface -- behavior of functions not defined everywhere -- see note above 
     
    366373            plot_points = 75 
    367374        G = parametric_plot3d_curve(f, urange, plot_points, **kwds) 
    368375    else: 
     376        if urange[0] is vrange[0]: 
     377            raise ValueError, "Plot variables should be distinct, but both are %s."%urange[0]         
     378 
    369379        if plot_points == "automatic": 
    370380            plot_points = [40,40] 
    371381        G = parametric_plot3d_surface(f, urange, vrange, plot_points, **kwds) 
  • a/sage/plot/plot3d/plot3d.py

    old new  
    128128    Hill and valley (flat surface with a bump and a dent): 
    129129        sage: x, y = var('x y') 
    130130        sage: plot3d( 4*x*exp(-x^2-y^2), (x,-2,2), (y,-2,2)) 
     131 
     132    TESTS: 
     133    Listing the same plot variable twice gives an error. 
     134        sage: x, y = var('x y') 
     135        sage: plot3d( 4*x*exp(-x^2-y^2), (x,-2,2), (x,-2,2)) 
     136        Traceback (most recent call last): 
     137        ... 
     138        ValueError: Plot variables should be distinct, but both are x. 
    131139    """ 
    132140    if len(urange) == 2: 
    133141        try: 
     
    140148    else: 
    141149        u = urange[0] 
    142150        v = vrange[0] 
     151        if u is v: 
     152            raise ValueError, "Plot variables should be distinct, but both are %s."%u    
     153         
    143154        w = (u, v, f) 
    144155 
    145156    if adaptive: