Ticket #11763: trac_11763_relax_typechecks.patch

File trac_11763_relax_typechecks.patch, 2.2 KB (added by vbraun, 8 years ago)

Updated patch

  • sage/plot/plot3d/shapes2.py

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1333047604 -3600
    # Node ID b761d33b069327daef5c241ff5041606972c4881
    # Parent  fb63d3700b566a500926c2f34be80c16399e2a0d
    Trac #11763: relax typechecks
    
    Some plotting commands needlessly require that the
    input is a Python list. This patch relaxes typechecks
    to allow arbitrary iterables.
    
    diff --git a/sage/plot/plot3d/shapes2.py b/sage/plot/plot3d/shapes2.py
    a b  
    984984   
    985985    INPUT:
    986986   
     987    -  ``v`` -- a point or list of points
    987988   
    988     -  ``v`` - a point or list of points
    989    
    990     -  ``size`` - (default: 5) size of the point (or
     989    -  ``size`` -- (default: 5) size of the point (or
    991990       points)
    992991   
    993     -  ``color`` - a word that describes a color
     992    -  ``color`` -- a word that describes a color
    994993   
    995     -  ``rgbcolor`` - (r,g,b) with r, g, b between 0 and 1
     994    -  ``rgbcolor`` -- (r,g,b) with r, g, b between 0 and 1
    996995       that describes a color
    997996   
    998     -  ``opacity`` - (default: 1) if less than 1 then is
     997    -  ``opacity`` -- (default: 1) if less than 1 then is
    999998       transparent
    1000999   
    1001    
    10021000    EXAMPLES::
    10031001   
    10041002        sage: sum([point3d((i,i^2,i^3), size=5) for i in range(10)])
    10051003
    1006     We check to make sure this works with vectors::
     1004    We check to make sure this works with vectors and other iterables
    10071005
    10081006        sage: pl = point3d([vector(ZZ,(1, 0, 0)), vector(ZZ,(0, 1, 0)), (-1, -1, 0)])
    1009         sage: p = point(vector((2,3,4)))
    1010         sage: print p
     1007        sage: print point(vector((2,3,4)))
    10111008        Graphics3d Object
    1012        
     1009
     1010        sage: c = polytopes.n_cube(3)
     1011        sage: v = c.vertices()[0];  v
     1012        A vertex at (-1, -1, -1)
     1013        sage: print point(v)
     1014        Graphics3d Object
    10131015
    10141016    We check to make sure the options work::
    10151017
    10161018        sage: point3d((4,3,2),size=20,color='red',opacity=.5)
    1017        
    10181019    """
    1019     if (isinstance(v,(list,tuple)) or is_Vector(v)) and len(v) == 3 and not (isinstance(v[0],(list,tuple)) or is_Vector(v[0])):
     1020    if len(v) == 3 and v[0] in RDF:
    10201021        return Point(v, size, **kwds)
    10211022    else:
    10221023        A = sum([Point(z, size, **kwds) for z in v])