Ticket #11763: trac_11763_remove_trailing_whitespace.patch

File trac_11763_remove_trailing_whitespace.patch, 54.7 KB (added by vbraun, 7 years ago)

Updated patch

  • sage/geometry/polyhedron/backend_cdd.py

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1350906371 -3600
    # Node ID 47a1e13855a20fa53cfb5951003f23851dfea3b8
    # Parent  9004cbac42c61ff1c6954267b0e6ad0196546715
    Trac #11763: remove trailing whitespace
    
    diff --git a/sage/geometry/polyhedron/backend_cdd.py b/sage/geometry/polyhedron/backend_cdd.py
    a b  
    2828        - ``vertices`` -- list of point. Each point can be specified
    2929           as any iterable container of
    3030           :meth:`~sage.geometry.polyhedron.base.base_ring` elements.
    31        
     31
    3232        - ``rays`` -- list of rays. Each ray can be specified as any
    3333          iterable container of
    3434          :meth:`~sage.geometry.polyhedron.base.base_ring` elements.
    35        
     35
    3636        - ``lines`` -- list of lines. Each line can be specified as
    3737          any iterable container of
    3838          :meth:`~sage.geometry.polyhedron.base.base_ring` elements.
     
    8787        computed during initialization.
    8888
    8989        EXAMPLES::
    90        
     90
    9191            sage: p = Polyhedron(vertices=[(0,0),(1,0),(0,1)], backend='cdd', base_ring=QQ)
    9292            sage: '_H_adjacency_matrix' in p.__dict__
    9393            False
     
    107107        computed during initialization.
    108108
    109109        EXAMPLES::
    110        
     110
    111111            sage: p = Polyhedron(vertices=[(0,0),(1,0),(0,1)], backend='cdd', base_ring=QQ)
    112112            sage: '_V_adjacency_matrix' in p.__dict__
    113113            False
     
    127127        and initialize ourselves with the output.
    128128
    129129        TESTS::
    130        
     130
    131131            sage: p = Polyhedron(vertices = [[0,0,0],[1,0,0],[0,1,0],[0,0,1]], backend='cdd', base_ring=QQ)
    132132            sage: from sage.geometry.polyhedron.cdd_file_format import cdd_Vrepresentation
    133133            sage: s = cdd_Vrepresentation('rational', [[0,0,1],[0,1,0],[1,0,0]], [], [])
     
    152152        Initialize ourselves with the output from cdd.
    153153
    154154        TESTS::
    155  
     155
    156156            sage: from sage.geometry.polyhedron.cdd_file_format import cdd_Vrepresentation
    157157            sage: s = cdd_Vrepresentation('rational',[[0,0],[1,0],[0,1],[1,1]], [], [])
    158158            sage: from subprocess import Popen, PIPE
     
    228228                parent._make_Vertex(self, [0] * self.ambient_dim())
    229229            self._Vrepresentation = tuple(self._Vrepresentation)
    230230            expect_in_cddout('end')
    231        
     231
    232232        if find_in_cddout('H-representation'):
    233233            self._Hrepresentation = []
    234234            equations = cdd_linearities()
     
    249249            l = cddout.pop(0).split()
    250250            assert l[2] == ':', "Not a line of the adjacency data?"
    251251            return [int(i)-1 for i in l[3:]]
    252        
     252
    253253        if find_in_cddout('Vertex graph'):
    254254            n = len(self._Vrepresentation);
    255255            if suppressed_vertex:
     
    276276                    self._V_adjacency_matrix[n-1,i] = 1
    277277            self._V_adjacency_matrix.set_immutable()
    278278            expect_in_cddout('end')
    279    
     279
    280280        if find_in_cddout('Facet graph'):
    281281            n = len(self._Hrepresentation);
    282282            self._H_adjacency_matrix = matrix(ZZ, n, n, 0)
     
    301301      :class:`~sage.geometry.polyhedron.parent.Polyhedra`.
    302302
    303303    - ``Vrep`` -- a list ``[vertices, rays, lines]`` or ``None``.
    304        
     304
    305305    - ``Hrep`` -- a list ``[ieqs, eqns]`` or ``None``.
    306306
    307307    EXAMPLES::
     
    325325        data.
    326326
    327327        TESTS::
    328        
     328
    329329            sage: p = Polyhedron(backend='cdd', base_ring=QQ)
    330330            sage: type(p)
    331331            <class 'sage.geometry.polyhedron.backend_cdd.Polyhedra_QQ_cdd_with_category.element_class'>
    332332            sage: TestSuite(p).run()
    333333        """
    334334        Polyhedron_cdd.__init__(self, parent, Vrep, Hrep, **kwds)
    335    
     335
    336336
    337337#########################################################################
    338338class Polyhedron_RDF_cdd(Polyhedron_cdd, Polyhedron_RDF):
     
    344344    - ``ambient_dim`` -- integer. The dimension of the ambient space.
    345345
    346346    - ``Vrep`` -- a list ``[vertices, rays, lines]`` or ``None``.
    347        
     347
    348348    - ``Hrep`` -- a list ``[ieqs, eqns]`` or ``None``.
    349349
    350350    EXAMPLES::
     
    356356        A 2-dimensional polyhedron in RDF^2 defined as the convex hull of 3 vertices
    357357    """
    358358    _cdd_type = 'real'
    359    
     359
    360360    _cdd_executable = 'cdd_both_reps'
    361361
    362362    def __init__(self, parent, Vrep, Hrep, **kwds):
     
    367367        data.
    368368
    369369        TESTS::
    370        
     370
    371371            sage: p = Polyhedron(backend='cdd', base_ring=RDF)
    372372            sage: type(p)
    373373            <class 'sage.geometry.polyhedron.backend_cdd.Polyhedra_RDF_cdd_with_category.element_class'>
    374374            sage: TestSuite(p).run()
    375375        """
    376376        Polyhedron_cdd.__init__(self, parent, Vrep, Hrep, **kwds)
    377    
     377
  • sage/geometry/polyhedron/backend_ppl.py

    diff --git a/sage/geometry/polyhedron/backend_ppl.py b/sage/geometry/polyhedron/backend_ppl.py
    a b  
    2424    INPUT:
    2525
    2626    - ``Vrep`` -- a list ``[vertices, rays, lines]`` or ``None``.
    27        
     27
    2828    - ``Hrep`` -- a list ``[ieqs, eqns]`` or ``None``.
    2929
    3030    EXAMPLES::
     
    4242        - ``vertices`` -- list of point. Each point can be specified
    4343           as any iterable container of
    4444           :meth:`~sage.geometry.polyhedron.base.base_ring` elements.
    45        
     45
    4646        - ``rays`` -- list of rays. Each ray can be specified as any
    4747          iterable container of
    4848          :meth:`~sage.geometry.polyhedron.base.base_ring` elements.
    49        
     49
    5050        - ``lines`` -- list of lines. Each line can be specified as
    5151          any iterable container of
    5252          :meth:`~sage.geometry.polyhedron.base.base_ring` elements.
     
    9494        Construct polyhedron from H-representation data.
    9595
    9696        INPUT:
    97        
     97
    9898        - ``ieqs`` -- list of inequalities. Each line can be specified
    9999          as any iterable container of
    100100          :meth:`~sage.geometry.polyhedron.base.base_ring` elements.
     
    134134    def _init_Vrepresentation_from_ppl(self, minimize):
    135135        """
    136136        Create the Vrepresentation objects from the ppl polyhedron.
    137        
     137
    138138        EXAMPLES::
    139139
    140140            sage: p = Polyhedron(vertices=[(0,1/2),(2,0),(4,5/6)],
  • sage/geometry/polyhedron/base.py

    diff --git a/sage/geometry/polyhedron/base.py b/sage/geometry/polyhedron/base.py
    a b  
    9090    - ``Vrep`` -- a list `[vertices, rays, lines]`` or ``None``. The
    9191      V-representation of the polyhedron. If ``None``, the polyhedron
    9292      is determined by the H-representation.
    93        
     93
    9494    - ``Hrep`` -- a list `[ieqs, eqns]`` or ``None``. The
    9595      H-representation of the polyhedron. If ``None``, the polyhedron
    9696      is determined by the V-representation.
     
    134134        - ``vertices`` -- list of point. Each point can be specified
    135135           as any iterable container of
    136136           :meth:`~sage.geometry.polyhedron.base.base_ring` elements.
    137        
     137
    138138        - ``rays`` -- list of rays. Each ray can be specified as any
    139139          iterable container of
    140140          :meth:`~sage.geometry.polyhedron.base.base_ring` elements.
    141        
     141
    142142        - ``lines`` -- list of lines. Each line can be specified as
    143143          any iterable container of
    144144          :meth:`~sage.geometry.polyhedron.base.base_ring` elements.
     
    219219        computed during initialization.
    220220
    221221        EXAMPLES::
    222        
     222
    223223            sage: p = Polyhedron(vertices=[(0,0),(1,0),(0,1)])
    224224            sage: p._facet_adjacency_matrix()
    225225            [0 1 1]
     
    250250        computed during initialization.
    251251
    252252        EXAMPLES::
    253        
     253
    254254            sage: p = Polyhedron(vertices=[(0,0),(1,0),(0,1)])
    255255            sage: p._vertex_adjacency_matrix()
    256256            [0 1 1]
     
    431431        Return a graphical representation.
    432432
    433433        INPUT:
    434        
     434
    435435        - ``**kwds`` -- optional keyword parameters.
    436436
    437437        See :func:`render_2d`, :func:`render_3d`, :func:`render_4d`
     
    487487            desc += repr(self.n_vertices())
    488488            if self.n_vertices()==1: desc += ' vertex'
    489489            else:                    desc += ' vertices'
    490            
     490
    491491            if self.n_rays()>0:
    492492                if self.n_lines()>0: desc += ", "
    493493                else:                desc += " and "
    494494                desc += repr(self.n_rays())
    495495                if self.n_rays()==1: desc += ' ray'
    496496                else:                desc += ' rays'
    497                
     497
    498498            if self.n_lines()>0:
    499499                if self.n_rays()>0: desc += ", "
    500500                else:               desc += " and "
     
    545545        """
    546546        Write the vertices/rays/lines data of the polyhedron in cdd's
    547547        V-representation format.
    548        
     548
    549549        OUTPUT:
    550550
    551551        A string. If you save the output to filename.ext then you can
     
    663663        either an inequality or a equation.
    664664
    665665        INPUT:
    666        
     666
    667667        - ``index`` -- either an integer or ``None``.
    668668
    669669        OUTPUT:
    670        
     670
    671671        The optional argument is an index in
    672672        `0...n_Hrepresentations()`. If present, the H-representation
    673673        object at the given index will be returned. Without an
    674674        argument, returns the list of all H-representation objects.
    675675
    676676        EXAMPLES::
    677        
     677
    678678            sage: p = polytopes.n_cube(3)
    679679            sage: p.Hrepresentation(0)
    680680            An inequality (0, 0, -1) x + 1 >= 0
     
    685685            return self._Hrepresentation
    686686        else:
    687687            return self._Hrepresentation[index]
    688            
     688
    689689
    690690    def Hrep_generator(self):
    691691        """
     
    693693        (inequalities or equations).
    694694
    695695        EXAMPLES::
    696        
     696
    697697            sage: p = polytopes.n_cube(3)
    698698            sage: p.Hrep_generator().next()
    699699            An inequality (0, 0, -1) x + 1 >= 0
     
    727727        either a vertex, a ray, or a line.
    728728
    729729        INPUT:
    730        
     730
    731731        - ``index`` -- either an integer or ``None``.
    732732
    733733        OUTPUT:
    734        
     734
    735735        The optional argument is an index in
    736736        `0...n_Vrepresentation()`. If present, the V-representation
    737737        object at the given index will be returned. Without an
     
    829829    def facial_incidences(self):
    830830        """
    831831        Return the face-vertex incidences in the form `[f_i, [v_{i_0}, v_{i_1},\dots ,v_{i_2}]]`.
    832        
     832
    833833        .. NOTE::
    834834
    835835            Instead of working with face/vertex indices, it is
     
    936936    def vertex_incidences(self):
    937937        """
    938938        Return the vertex-face incidences in the form `[v_i, [f_{i_0}, f_{i_1},\dots ,f_{i_2}]]`.
    939        
     939
    940940        .. NOTE::
    941941
    942942            Instead of working with face/vertex indices, you can use
     
    974974        polyhedron.
    975975
    976976        OUTPUT:
    977        
     977
    978978        A generator of the inequality Hrepresentation objects.
    979979
    980980        EXAMPLES::
     
    10251025        Return a list of inequalities as coefficient lists.
    10261026
    10271027        .. NOTE::
    1028        
     1028
    10291029            It is recommended to use :meth:`inequalities` or
    10301030            :meth:`inequality_generator` instead to iterate over the
    10311031            list of :class:`Inequality` objects.
     
    10511051        Deprecated. Alias for inequalities()
    10521052
    10531053        EXAMPLES::
    1054          
     1054
    10551055            sage: p3 = Polyhedron(vertices = permutations([1,2,3,4]))
    10561056            sage: p3.ieqs() == p3.inequalities()
    10571057            doctest:...: DeprecationWarning:
     
    11041104        the equation b = a1*x1 + a2*x2 + ... + an*xn.
    11051105
    11061106        .. NOTE::
    1107        
     1107
    11081108            It is recommended to use :meth:`equations` or
    11091109            :meth:`equation_generator()` instead to iterate over the
    11101110            list of
     
    11471147        Return a list of vertices of the polyhedron.
    11481148
    11491149        .. NOTE::
    1150        
     1150
    11511151            It is recommended to use :meth:`vertex_generator` instead to
    11521152            iterate over the list of :class:`Vertex` objects.
    11531153
     
    11651165            True
    11661166        """
    11671167        return [list(x) for x in self.vertex_generator()]
    1168        
     1168
    11691169    def vertex_generator(self):
    11701170        """
    11711171        Return a generator for the vertices of the polyhedron.
     
    12251225        Return the coordinates of the vertices as the columns of a matrix.
    12261226
    12271227        INPUT:
    1228        
     1228
    12291229        - ``base_ring`` -- A ring or ``None`` (default). The base ring
    12301230          of the returned matrix. If not specified, the base ring of
    12311231          the polyhedron is used.
     
    12971297        Return a list of rays as coefficient lists.
    12981298
    12991299        .. NOTE::
    1300        
     1300
    13011301            It is recommended to use :meth:`rays` or
    13021302            :meth:`ray_generator` instead to iterate over the list of
    13031303            :class:`Ray` objects.
     
    13531353        as a list of coordinates rather than as a Hrepresentation object.
    13541354
    13551355        .. NOTE::
    1356        
     1356
    13571357            It is recommended to use :meth:`line_generator` instead to
    13581358            iterate over the list of :class:`Line` objects.
    13591359
     
    13661366            True
    13671367        """
    13681368        return [list(x) for x in self.line_generator()]
    1369                
     1369
    13701370    def bounded_edges(self):
    13711371        """
    13721372        Return the bounded edges (excluding rays and lines).
    1373        
     1373
    13741374        OUTPUT:
    13751375
    13761376        A generator for pairs of vertices, one pair per edge.
     
    13951395    def Vrepresentation_space(self):
    13961396        r"""
    13971397        Return the ambient vector space.
    1398        
     1398
    13991399        OUTPUT:
    1400        
     1400
    14011401        A free module over the base ring of dimension :meth:`ambient_dim`.
    1402        
     1402
    14031403        EXAMPLES::
    14041404
    14051405            sage: poly_test = Polyhedron(vertices = [[1,0,0,0],[0,1,0,0]])
     
    14171417        Return the linear space containing the H-representation vectors.
    14181418
    14191419        OUTPUT:
    1420        
     1420
    14211421        A free module over the base ring of dimension :meth:`ambient_dim` + 1.
    1422        
     1422
    14231423        EXAMPLES::
    1424        
     1424
    14251425            sage: poly_test = Polyhedron(vertices = [[1,0,0,0],[0,1,0,0]])
    14261426            sage: poly_test.Hrepresentation_space()
    14271427            Ambient free module of rank 5 over the principal ideal domain Integer Ring
     
    14391439            4
    14401440        """
    14411441        return self.parent().ambient_dim()
    1442            
     1442
    14431443    def dim(self):
    14441444        """
    14451445        Return the dimension of the polyhedron.
     
    15011501            :meth:`Vrepresentation`
    15021502
    15031503        EXAMPLES::
    1504        
     1504
    15051505            sage: p = polytopes.cuboctahedron()
    15061506            sage: p.incidence_matrix()
    15071507            [0 0 1 1 0 1 0 0 0 0 1 0 0 0]
     
    16161616        distance measure.
    16171617
    16181618        EXAMPLES::
    1619        
     1619
    16201620            sage: p = polytopes.n_cube(4)
    16211621            sage: p.radius()
    16221622            2
     
    16831683            sage: p2 = p.prism()
    16841684            sage: p2.gale_transform()
    16851685            [(1, 0), (0, 1), (-1, -1), (-1, 0), (0, -1), (1, 1)]
    1686        
     1686
    16871687        REFERENCES:
    16881688
    16891689            Lectures in Geometric Combinatorics, R.R.Thomas, 2006, AMS Press.
     
    17201720        - ``fine`` -- boolean (default: ``False``). Whether the
    17211721          triangulations must be fine, that is, make use of all points
    17221722          of the configuration.
    1723    
     1723
    17241724        - ``regular`` -- boolean or ``None`` (default:
    17251725          ``None``). Whether the triangulations must be regular. A
    17261726          regular triangulation is one that is induced by a
    17271727          piecewise-linear convex support function. In other words,
    17281728          the shadows of the faces of a polyhedron in one higher
    17291729          dimension.
    1730      
     1730
    17311731          * ``True``: Only regular triangulations.
    17321732
    17331733          * ``False``: Only non-regular triangulations.
     
    17461746        :class:`~sage.geometry.triangulation.point_configuration.Triangulation`. The
    17471747        indices in the triangulation correspond to the
    17481748        :meth:`Vrepresentation` objects.
    1749        
     1749
    17501750        EXAMPLES::
    17511751
    17521752            sage: cube = polytopes.n_cube(3)
     
    17971797            This method is deprecated. Use self.Hrepresentation(i).incident() instead.
    17981798            See http://trac.sagemath.org/11763 for details.
    17991799            [[0, [0, 1, 2]], [1, [0, 1, 3]], [2, [0, 2, 3]], [3, [1, 2, 3]]]
    1800                              
     1800
    18011801        Otherwise some faces get split up to triangles::
    18021802
    18031803            sage: Polyhedron(vertices = [[2,0,0],[4,1,0],[0,5,0],[5,5,0],
     
    21742174        r"""
    21752175        Return a new polyhedron formed from two points on each edge
    21762176        between two vertices.
    2177        
     2177
    21782178        INPUT:
    2179        
     2179
    21802180        - ``cut_frac`` -- integer. how deeply to cut into the edge.
    21812181            Default is `\frac{1}{3}`.
    2182            
     2182
    21832183        OUTPUT:
    21842184
    21852185        A Polyhedron object, truncated as described above.
    2186            
     2186
    21872187        EXAMPLES::
    21882188
    21892189            sage: cube = polytopes.n_cube(3)
     
    22212221          face.
    22222222
    22232223        OUTPUT:
    2224        
     2224
    22252225        A new :class:`PolyhedronFace_base` instance. It is not checked
    22262226        whether the input data actually defines a face.
    22272227
     
    22392239        Return the face-lattice poset.
    22402240
    22412241        OUTPUT:
    2242        
     2242
    22432243        A :class:`~sage.combinat.posets.posets.FinitePoset`. Elements
    22442244        are given as
    22452245        :class:`~sage.geometry.polyhedron.PolyhedronFace_base`.
     
    22772277        * Lines are removed before calling
    22782278          :func:`Hasse_diagram_from_incidences`, and then added back
    22792279          to each face V-representation except for the "empty face".
    2280        
     2280
    22812281        * Equations are removed before calling
    22822282          :func:`Hasse_diagram_from_incidences`, and then added back
    22832283          to each face H-representation.
     
    23132313            (A vertex at (-1, -1), A vertex at (1, -1))
    23142314            sage: a_face.ambient_Hrepresentation()
    23152315            (An inequality (0, 1) x + 1 >= 0,)
    2316            
     2316
    23172317        A more complicated example::
    23182318
    23192319            sage: c5_10 = Polyhedron(vertices = [[i,i^2,i^3,i^4,i^5] for i in range(1,11)])
    23202320            sage: c5_10_fl = c5_10.face_lattice()
    23212321            sage: [len(x) for x in c5_10_fl.level_sets()]
    23222322            [1, 10, 45, 100, 105, 42, 1]
    2323            
     2323
    23242324        Note that if the polyhedron contains lines then there is a
    23252325        dimension gap between the empty face and the first non-empty
    23262326        face in the face lattice::
     
    23702370        REFERENCES:
    23712371
    23722372        ..  [KP2002]
    2373        
     2373
    23742374            Volker Kaibel and Marc E. Pfetsch, "Computing the Face
    23752375            Lattice of a Polytope from its Vertex-Facet Incidences",
    23762376            Computational Geometry: Theory and Applications, Volume
     
    23822382        Hindex_to_coatom = [None] * self.n_Hrepresentation()
    23832383        for i in range(0,len(coatom_to_Hindex)):
    23842384            Hindex_to_coatom[ coatom_to_Hindex[i] ] = i
    2385            
     2385
    23862386        atom_to_Vindex = [ v.index() for v in self.Vrep_generator() if not v.is_line() ]
    23872387        Vindex_to_atom = [None] * self.n_Vrepresentation()
    23882388        for i in range(0,len(atom_to_Vindex)):
    23892389                        Vindex_to_atom[ atom_to_Vindex[i] ] = i
    2390            
     2390
    23912391        atoms_incidences   = [ tuple([ Hindex_to_coatom[h.index()]
    23922392                                       for h in v.incident() if h.is_inequality() ])
    23932393                               for v in self.Vrepresentation() if not v.is_line() ]
    2394        
     2394
    23952395        coatoms_incidences = [ tuple([ Vindex_to_atom[v.index()]
    23962396                                       for v in h.incident() if not v.is_line() ])
    23972397                               for h in self.Hrepresentation() if h.is_inequality() ]
    2398        
     2398
    23992399        atoms_vertices = [ Vindex_to_atom[v.index()] for v in self.vertex_generator() ]
    24002400        equations = [ e.index() for e in self.equation_generator() ]
    24012401        lines     = [ l.index() for l in self.line_generator() ]
     
    24202420        Return the f-vector.
    24212421
    24222422        OUTPUT:
    2423        
     2423
    24242424        Returns a vector whose ``i``-th entry is the number of
    24252425        ``i``-dimensional faces of the polytope.
    24262426
     
    25182518             [0, 0, 1, 0],
    25192519             [0, 1, 0, 0],
    25202520             [1, 0, 0, 0]]
    2521        
     2521
    25222522        Now check that bipyramids of cross-polytopes are cross-polytopes::
    25232523
    25242524            sage: q2 = [list(v) for v in polytopes.cross_polytope(4).vertex_generator()]
     
    26292629            projection_dir = [sum([vertices[f0[i]][j]/len(f0) for i in range(len(f0))])
    26302630                              for j in range(self.ambient_dim())]
    26312631        return proj.schlegel(projection_direction = projection_dir, height = height)
    2632        
     2632
    26332633    def lrs_volume(self, verbose = False):
    26342634        """
    26352635        Computes the volume of a polytope.
     
    26492649            2.0
    26502650
    26512651        REFERENCES:
    2652        
     2652
    26532653             David Avis's lrs program.
    26542654        """
    26552655        if is_package_installed('lrs') != True:
     
    26962696        Boolean.
    26972697
    26982698        EXAMPLES::
    2699        
     2699
    27002700            sage: P = Polyhedron(vertices=[[1,1],[1,-1],[0,0]])
    27012701            sage: P.contains( [1,0] )
    27022702            True
     
    27172717            True
    27182718            sage: ray.contains(['hello', 'kitty'])   # no common ring for coordinates
    27192719            False
    2720            
     2720
    27212721        The empty polyhedron needs extra care, see trac #10238::
    27222722
    27232723            sage: empty = Polyhedron(); empty
     
    27432743
    27442744        if len(p)!=self.ambient_dim():
    27452745            return False
    2746        
     2746
    27472747        for H in self.Hrep_generator():
    27482748            if not H.contains(p):
    27492749                return False
     
    27582758        :meth:`relative_interior_contains`.
    27592759
    27602760        INPUT:
    2761        
     2761
    27622762        - ``point`` -- coordinates of a point.
    27632763
    27642764        OUTPUT:
    2765        
     2765
    27662766        ``True`` or ``False``.
    27672767
    27682768        EXAMPLES::
    2769        
     2769
    27702770            sage: P = Polyhedron(vertices=[[0,0],[1,1],[1,-1]])
    27712771            sage: P.contains( [1,0] )
    27722772            True
     
    27992799
    28002800        if len(p)!=self.ambient_dim():
    28012801            return False
    2802        
     2802
    28032803        for H in self.Hrep_generator():
    28042804            if not H.interior_contains(p):
    28052805                return False
     
    28132813        See also :meth:`contains` and :meth:`interior_contains`.
    28142814
    28152815        INPUT:
    2816        
     2816
    28172817        - ``point`` -- coordinates of a point.
    28182818
    28192819        OUTPUT:
    2820        
     2820
    28212821        ``True`` or ``False``.
    28222822
    28232823        EXAMPLES::
    2824        
     2824
    28252825            sage: P = Polyhedron(vertices=[(1,0), (-1,0)])
    28262826            sage: P.contains( (0,0) )
    28272827            True
     
    28492849
    28502850        if len(p)!=self.ambient_dim():
    28512851            return False
    2852          
     2852
    28532853        for eq in self.equation_generator():
    28542854            if not eq.contains(p):
    28552855                return False
     
    28632863    def is_simplex(self):
    28642864        r"""
    28652865        Return whether the polyhedron is a simplex.
    2866        
     2866
    28672867        EXAMPLES::
    28682868
    28692869            sage: Polyhedron([(0,0,0), (1,0,0), (0,1,0)]).is_simplex()
     
    28792879    def is_lattice_polytope(self):
    28802880        r"""
    28812881        Return whether the polyhedron is a lattice polytope.
    2882        
     2882
    28832883        OUTPUT:
    28842884
    28852885        ``True`` if the polyhedron is compact and has only integral
    28862886        vertices, ``False`` otherwise.
    2887        
     2887
    28882888        EXAMPLES::
    2889        
     2889
    28902890            sage: polytopes.cross_polytope(3).is_lattice_polytope()
    28912891            True
    28922892            sage: polytopes.regular_polygon(5).is_lattice_polytope()
     
    28972897        if self.base_ring() is ZZ:
    28982898            return True
    28992899        return all(v.is_integral() for v in self.vertex_generator())
    2900        
     2900
    29012901    @cached_method
    29022902    def lattice_polytope(self, envelope=False):
    29032903        r"""
    29042904        Return an encompassing lattice polytope.
    2905        
     2905
    29062906        INPUT:
    29072907
    29082908        - ``envelope`` -- boolean (default: ``False``). If the
     
    29332933        is returned.
    29342934
    29352935        EXAMPLES:
    2936        
     2936
    29372937        First, a polyhedron with integral vertices::
    29382938
    29392939            sage: P = Polyhedron( vertices = [(1, 0), (0, 1), (-1, 0), (0, -1)])
     
    29852985        This method is for testing purposes and will eventually be removed.
    29862986
    29872987        OUTPUT:
    2988        
     2988
    29892989        The list of integral points in the polyhedron. If the
    29902990        polyhedron is not compact, a ``ValueError`` is raised.
    29912991
    29922992        EXAMPLES::
    2993        
     2993
    29942994            sage: Polyhedron(vertices=[(-1,-1),(1,0),(1,1),(0,1)])._integral_points_PALP()
    29952995            [(-1, -1), (0, 1), (1, 0), (1, 1), (0, 0)]
    29962996            sage: Polyhedron(vertices=[(-1/2,-1/2),(1,0),(1,1),(0,1)]).lattice_polytope(True).points()
     
    30233023
    30243024        - ``integral`` -- Boolean (default: ``False``). Whether to
    30253025          only allow integral coordinates in the bounding box.
    3026        
     3026
    30273027        OUTPUT:
    30283028
    30293029        A pair of tuples ``(box_min, box_max)`` where ``box_min`` are
     
    30573057                box_max.append(max_coord)
    30583058                box_min.append(min_coord)
    30593059        return (tuple(box_min), tuple(box_max))
    3060        
     3060
    30613061    def integral_points(self, threshold=100000):
    30623062        r"""
    30633063        Return the integral points in the polyhedron.
     
    30713071          algorith as long as the bounding box is smaller than this.
    30723072
    30733073        OUTPUT:
    3074        
     3074
    30753075        The list of integral points in the polyhedron. If the
    30763076        polyhedron is not compact, a ``ValueError`` is raised.
    30773077
    30783078        EXAMPLES::
    3079        
     3079
    30803080            sage: Polyhedron(vertices=[(-1,-1),(1,0),(1,1),(0,1)]).integral_points()
    30813081            ((-1, -1), (0, 0), (0, 1), (1, 0), (1, 1))
    30823082
     
    31533153            points.update(new_points)
    31543154        # assert all(self.contains(p) for p in points)   # slow
    31553155        return tuple(points)
    3156    
     3156
    31573157    @cached_method
    31583158    def combinatorial_automorphism_group(self):
    31593159        """
     
    31733173        chosen to be shifted by ``+1``. That is, ``i`` in the
    31743174        permutation group corresponds to the V-representation object
    31753175        ``self.Vrepresentation(i-1)``.
    3176        
     3176
    31773177        EXAMPLES::
    3178        
     3178
    31793179            sage: quadrangle = Polyhedron(vertices=[(0,0),(1,0),(0,1),(2,3)])
    31803180            sage: quadrangle.combinatorial_automorphism_group()
    31813181            Permutation Group with generators [(2,3), (1,2)(3,4)]
     
    32103210    def _affine_coordinates(self, Vrep_object):
    32113211        r"""
    32123212        Return affine coordinates for a V-representation object.
    3213        
     3213
    32143214        INPUT:
    32153215
    32163216        - ``v`` -- a V-representation object or any iterable
     
    32243224        A ``self.dim()``-dimensional coordinate vector. It contains
    32253225        the coordinates of ``v`` in an arbitrary but fixed basis for
    32263226        the affine span of the polyhedron.
    3227        
     3227
    32283228        EXAMPLES::
    3229        
     3229
    32303230            sage: P = Polyhedron(rays=[(1,0,0),(0,1,0)])
    32313231            sage: P._affine_coordinates( (-1,-2,-3) )
    32323232            (-1, -2)
     
    32403240                v_list = [ v - origin for v in v_list ]
    32413241            coordinates = matrix(v_list)
    32423242            self._affine_coordinates_pivots = coordinates.pivots()
    3243    
     3243
    32443244        v = list(Vrep_object)
    32453245        if len(v) != self.ambient_dim():
    32463246            raise ValueError('Incorrect dimension: '+str(v))
    32473247
    32483248        return vector(self.base_ring(), [ v[i] for i in self._affine_coordinates_pivots ])
    3249        
     3249
    32503250    @cached_method
    32513251    def restricted_automorphism_group(self):
    32523252        r"""
     
    32653265        generators with line generators.
    32663266
    32673267        For example, take the first quadrant
    3268        
     3268
    32693269        .. MATH::
    3270        
     3270
    32713271            Q = \Big\{ (x,y) \Big| x\geq 0,\; y\geq0 \Big\}
    32723272            \subset \QQ^2
    3273            
     3273
    32743274        Then the linear automorphism group is
    3275        
     3275
    32763276        .. MATH::
    32773277
    32783278            \mathrm{Aut}(Q) =
     
    33163316        A :class:`PermutationGroup<sage.groups.perm_gps.permgroup.PermutationGroup_generic>`
    33173317        that is isomorphic to the restricted automorphism group is
    33183318        returned.
    3319        
     3319
    33203320        Note that in Sage, permutation groups always act on positive
    33213321        integers while ``self.Vrepresentation()`` is indexed by
    33223322        nonnegative integers. The indexing of the permutation group is
     
    33843384
    33853385        Floating-point computations are supported with a simple fuzzy
    33863386        zero implementation::
    3387        
     3387
    33883388            sage: P = Polyhedron(vertices=[(1.0/3.0,0,0),(0,1.0/3.0,0),(0,0,1.0/3.0)], base_ring=RDF)
    33893389            sage: P.restricted_automorphism_group()
    33903390            Permutation Group with generators [(2,3), (1,2)]
     
    34743474class PolyhedronFace_base(Polyhedron_base):
    34753475    r"""
    34763476    A face of a polyhedron.
    3477    
     3477
    34783478    This class is for use in
    34793479    :meth:`~sage.geometry.polyhedron.base.Polyhedron_base.face_lattice`.
    34803480
     
    35273527        - ``H_indices`` -- list of integers. The indices of the
    35283528          H-representation objects of the ambient polyhedron that are
    35293529          saturated on the face.
    3530        
     3530
    35313531        TESTS::
    35323532
    35333533            sage: from sage.geometry.polyhedron.base import PolyhedronFace_base
     
    35783578        r"""
    35793579        Return the H-representation objects of the ambient polytope
    35803580        defining the face.
    3581        
     3581
    35823582        INPUT:
    3583        
     3583
    35843584        - ``index`` -- optional. Either an integer or ``None``
    35853585          (default).
    35863586
    35873587        OUTPUT:
    3588        
     3588
    35893589        If the optional argument is not present, a tuple of
    35903590        H-representation objects. Each entry is either an inequality
    35913591        or an equation.
     
    35943594        ``index``-th element of the tuple is returned.
    35953595
    35963596        EXAMPLES::
    3597          
     3597
    35983598            sage: square = polytopes.n_cube(2)
    35993599            sage: for fl in square.face_lattice():
    36003600            ...       print fl.element.ambient_Hrepresentation()
     
    36153615            return self._ambient_Hrepresentation
    36163616        else:
    36173617            return self._ambient_Hrepresentation[index]
    3618        
     3618
    36193619    def ambient_Vrepresentation(self, index=None):
    36203620        r"""
    36213621        Return the V-representation objects of the ambient polytope
    36223622        defining the face.
    36233623
    36243624        INPUT:
    3625        
     3625
    36263626        - ``index`` -- optional. Either an integer or ``None``
    36273627          (default).
    36283628
    36293629        OUTPUT:
    3630        
     3630
    36313631        If the optional argument is not present, a tuple of
    36323632        V-representation objects. Each entry is either a vertex, a
    36333633        ray, or a line.
    36343634
    36353635        If the optional integer ``index`` is specified, the
    36363636        ``index``-th element of the tuple is returned.
    3637        
     3637
    36383638        EXAMPLES::
    3639          
     3639
    36403640            sage: square = polytopes.n_cube(2)
    36413641            sage: for fl in square.face_lattice():
    36423642            ...       print fl.element.ambient_Vrepresentation()
     
    37153715    def dim(self):
    37163716        """
    37173717        Return the dimension of the face.
    3718        
     3718
    37193719        OUTPUT:
    3720        
     3720
    37213721        Integer.
    3722        
     3722
    37233723        EXAMPLES::
    37243724
    37253725            sage: fl = polytopes.dodecahedron().face_lattice()
  • sage/geometry/polyhedron/base_QQ.py

    diff --git a/sage/geometry/polyhedron/base_QQ.py b/sage/geometry/polyhedron/base_QQ.py
    a b  
    1111    Base class for Polyhedra over `\QQ`
    1212
    1313    TESTS::
    14      
     14
    1515        sage: p = Polyhedron([(0,0)], base_ring=QQ);  p
    1616        A 0-dimensional polyhedron in QQ^2 defined as the convex hull of 1 vertex
    1717        sage: TestSuite(p).run()
     
    1919    def _is_zero(self, x):
    2020        """
    2121        Test whether ``x`` is zero.
    22        
     22
    2323        INPUT:
    2424
    2525        - ``x`` -- a number in the base ring.
     
    2929        Boolean.
    3030
    3131        EXAMPLES::
    32          
     32
    3333            sage: p = Polyhedron([(0,0)], base_ring=QQ)
    3434            sage: p._is_zero(0)
    3535            True
     
    4141    def _is_nonneg(self, x):
    4242        """
    4343        Test whether ``x`` is nonnegative.
    44        
     44
    4545        INPUT:
    4646
    4747        - ``x`` -- a number in the base ring.
     
    5151        Boolean.
    5252
    5353        EXAMPLES::
    54          
     54
    5555            sage: p = Polyhedron([(0,0)], base_ring=QQ)
    5656            sage: p._is_nonneg(1)
    5757            True
     
    6363    def _is_positive(self, x):
    6464        """
    6565        Test whether ``x`` is positive.
    66        
     66
    6767        INPUT:
    6868
    6969        - ``x`` -- a number in the base ring.
     
    7373        Boolean.
    7474
    7575        EXAMPLES::
    76          
     76
    7777            sage: p = Polyhedron([(0,0)], base_ring=QQ)
    7878            sage: p._is_positive(1)
    7979            True
  • sage/geometry/polyhedron/base_RDF.py

    diff --git a/sage/geometry/polyhedron/base_RDF.py b/sage/geometry/polyhedron/base_RDF.py
    a b  
    1212    Base class for polyhedra over ``RDF``.
    1313
    1414    TESTS::
    15      
     15
    1616        sage: p = Polyhedron([(0,0)], base_ring=RDF);  p
    1717        A 0-dimensional polyhedron in RDF^2 defined as the convex hull of 1 vertex
    1818        sage: TestSuite(p).run()
     
    2222    def _is_zero(self, x):
    2323        """
    2424        Test whether ``x`` is zero.
    25        
     25
    2626        INPUT:
    2727
    2828        - ``x`` -- a number in the base ring.
     
    3232        Boolean.
    3333
    3434        EXAMPLES::
    35          
     35
    3636            sage: p = Polyhedron([(0,0)], base_ring=RDF)
    3737            sage: p._is_zero(0)
    3838            True
     
    4949    def _is_nonneg(self, x):
    5050        """
    5151        Test whether ``x`` is nonnegative.
    52        
     52
    5353        INPUT:
    5454
    5555        - ``x`` -- a number in the base ring.
     
    5959        Boolean.
    6060
    6161        EXAMPLES::
    62          
     62
    6363            sage: p = Polyhedron([(0,0)], base_ring=RDF)
    6464            sage: p._is_nonneg(1)
    6565            True
     
    7676    def _is_positive(self, x):
    7777        """
    7878        Test whether ``x`` is positive.
    79        
     79
    8080        INPUT:
    8181
    8282        - ``x`` -- a number in the base ring.
     
    8686        Boolean.
    8787
    8888        EXAMPLES::
    89          
     89
    9090            sage: p = Polyhedron([(0,0)], base_ring=RDF)
    9191            sage: p._is_positive(1)
    9292            True
     
    9999            True
    100100        """
    101101        return x>=-1e-6
    102      
     102
    103103    _base_ring = RDF
    104104
  • sage/geometry/polyhedron/cdd_file_format.py

    diff --git a/sage/geometry/polyhedron/cdd_file_format.py b/sage/geometry/polyhedron/cdd_file_format.py
    a b  
    2222    Return a string containing the V-representation in cddlib's ext format.
    2323
    2424    NOTE:
    25        
     25
    2626    If there is no vertex given, then the origin will be implicitly
    2727    added. You cannot write the empty V-representation (which cdd
    2828    would refuse to process).
  • sage/geometry/polyhedron/constructor.py

    diff --git a/sage/geometry/polyhedron/constructor.py b/sage/geometry/polyhedron/constructor.py
    a b  
    2121    polyhedron is then the Minkowski sum
    2222
    2323    .. MATH::
    24    
     24
    2525        P = \text{conv}\{v_1,\dots,v_k\} +
    2626        \sum_{i=1}^m \RR_+ r_i +
    2727        \sum_{j=1}^n \RR \ell_j
    2828
    2929    where
    30        
     30
    3131        * `v_1`, `\dots`, `v_k` are a finite number of vertices,
    3232        * `r_1`, `\dots`, `r_m` are generators of rays,
    3333        * and `\ell_1`, `\dots`, `\ell_n` are generators of full lines.
     
    109109
    110110
    111111
    112        
     112
    113113
    114114
    115115#########################################################################
     
    132132      any iterable container of ``base_ring`` elements. If ``rays`` or
    133133      ``lines`` are specified but no ``vertices``, the origin is
    134134      taken to be the single vertex.
    135        
     135
    136136    - ``rays`` -- list of rays. Each ray can be specified as any
    137137      iterable container of ``base_ring`` elements.
    138        
     138
    139139    - ``lines`` -- list of lines. Each line can be specified as any
    140140      iterable container of ``base_ring`` elements.
    141141
     
    219219      * The inequality `e+b \geq c+d`
    220220      * The inequality `e+c \geq b+d`
    221221      * The equation `a+b+c+d+e+f = 31`
    222      
     222
    223223    ::
    224224
    225225        sage: positive_coords = Polyhedron(ieqs=[
     
    238238         A vertex at (0, 0, 0, 31/2, 31/2, 0))
    239239
    240240    .. NOTE::
    241    
     241
    242242      * Once constructed, a ``Polyhedron`` object is immutable.
    243243      * Although the option ``field=RDF`` allows numerical data to
    244244        be used, it might not give the right answer for degenerate
     
    254254
    255255    got_Vrep = (len(vertices+rays+lines) > 0)
    256256    got_Hrep = (len(ieqs+eqns) > 0)
    257    
     257
    258258    if got_Vrep and got_Hrep:
    259259        raise ValueError('You cannot specify both H- and V-representation.')
    260260    elif got_Vrep:
  • sage/geometry/polyhedron/library.py

    diff --git a/sage/geometry/polyhedron/library.py b/sage/geometry/polyhedron/library.py
    a b  
    4242        """
    4343        A matrix of rational approximations to orthonormal vectors to
    4444        ``(1,...,1)``.
    45    
     45
    4646        INPUT:
    4747
    4848        - ``dim_n`` - the dimension of the vectors
     
    100100        An internal utility function for constructing the Birkhoff polytopes.
    101101
    102102        EXAMPLES::
    103        
     103
    104104            sage: from sage.geometry.polyhedron.library import Polytopes
    105105            sage: Polytopes._pfunc(1,2,permutations(3)[0])
    106106            0
     
    195195        Return an icosahedron with edge length 1.
    196196
    197197        INPUT:
    198        
     198
    199199        - ``base_ring`` -- Either ``QQ`` or ``RDF``.
    200200
    201201        OUTPUT:
     
    233233    def dodecahedron(self, base_ring=QQ):
    234234        """
    235235        Return a dodecahedron.
    236        
     236
    237237        INPUT:
    238        
     238
    239239        - ``base_ring`` -- Either ``QQ`` (in which case a rational
    240240          approximation to the golden ratio is used) or ``RDF``.
    241241
     
    537537        - ``n`` -- the numbers ``(1,...,n)`` are permuted
    538538
    539539        - ``project`` -- If ``False`` the polyhedron is left in dimension ``n``.
    540  
     540
    541541        OUTPUT:
    542542
    543543        A Polyhedron object representing the permutahedron.
     
    562562        Return a cube in the given dimension
    563563
    564564        INPUT:
    565  
     565
    566566        - ``dim_n`` -- integer. The dimension of the cube.
    567567
    568568        OUTPUT:
     
    613613        verts = verts + permutations([0 for i in range(dim_n-1)] + [-1])
    614614        return Polyhedron(vertices=verts)
    615615
    616    
     616
    617617    def parallelotope(self, generators):
    618618        r"""
    619619        Return the parallelotope spanned by the generators.
    620620
    621621        INPUT:
    622        
     622
    623623        - ``generators`` -- an iterable of anything convertible to vector
    624624          (for example, a list of vectors) such that the vectors all
    625625          have the same dimension.
     
    631631        parallelepiped (3 generators).
    632632
    633633        EXAMPLES::
    634        
     634
    635635            sage: polytopes.parallelotope([ (1,0), (0,1) ])
    636636            A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 4 vertices
    637637            sage: polytopes.parallelotope([[1,2,3,4],[0,1,0,7],[3,1,0,2],[0,0,1,0]])
     
    643643        except TypeError:
    644644            generators = [ vector(RDF,v) for v in generators ]
    645645            base_ring = RDF
    646            
     646
    647647        from sage.combinat.combination import Combinations
    648648        par =  [ 0*generators[0] ]
    649649        par += [ sum(c) for c in Combinations(generators) if c!=[] ]
    650650        return Polyhedron(vertices=par, base_ring=base_ring)
    651                            
     651
    652652
    653653
    654654polytopes = Polytopes()
  • sage/geometry/polyhedron/misc.py

    diff --git a/sage/geometry/polyhedron/misc.py b/sage/geometry/polyhedron/misc.py
    a b  
    2525    INPUT:
    2626
    2727    - ``l`` -- anything iterable.
    28    
     28
    2929    OUTPUT:
    3030
    3131    String.
     
    9898    length differs, ``ValueError`` is raised. Used to check arguments.
    9999
    100100    OUTPUT:
    101    
     101
    102102    A tuple (number of entries, common length of the entries)
    103103
    104104    EXAMPLES::
  • sage/geometry/polyhedron/plot.py

    diff --git a/sage/geometry/polyhedron/plot.py b/sage/geometry/polyhedron/plot.py
    a b  
    3333    """
    3434    Return 2d rendering of the projection of a polyhedron into
    3535    2-dimensional ambient space.
    36    
     36
    3737    EXAMPLES::
    38    
     38
    3939        sage: p1 = Polyhedron(vertices=[[1,1]], rays=[[1,1]])
    4040        sage: q1 = p1.projection()
    4141        sage: p2 = Polyhedron(vertices=[[1,0], [0,1], [0,0]])
     
    6464    """
    6565    Return 3d rendering of a polyhedron projected into
    6666    3-dimensional ambient space.
    67    
     67
    6868    NOTE:
    69    
     69
    7070    This method, ``render_3d``, is used in the ``show()``
    7171    method of a polyhedron if it is in 3 dimensions.
    72    
     72
    7373    EXAMPLES::
    7474
    7575        sage: p1 = Polyhedron(vertices=[[1,1,1]], rays=[[1,1,1]])
    7676        sage: p2 = Polyhedron(vertices=[[2,0,0], [0,2,0], [0,0,2]])
    7777        sage: p3 = Polyhedron(vertices=[[1,0,0], [0,1,0], [0,0,1]], rays=[[-1,-1,-1]])
    7878        sage: p1.projection().show() + p2.projection().show() + p3.projection().show()
    79        
     79
    8080    It correctly handles various degenerate cases::
    81            
     81
    8282        sage: Polyhedron(lines=[[1,0,0],[0,1,0],[0,0,1]]).show()                              # whole space
    8383        sage: Polyhedron(vertices=[[1,1,1]], rays=[[1,0,0]], lines=[[0,1,0],[0,0,1]]).show()  # half space
    8484        sage: Polyhedron(vertices=[[1,1,1]], lines=[[0,1,0],[0,0,1]]).show()                  # R^2 in R^3
     
    102102    polyhedron projected into 3-dimensional space.
    103103
    104104    NOTES:
    105    
     105
    106106    The ``show()`` method of ``Polyhedron()`` uses this to draw itself
    107107    if the ambient dimension is 4.
    108108
    109109    INPUT:
    110    
     110
    111111    - ``polyhedron`` -- A
    112112      :mod:`~sage.geometry.polyhedron.constructor.Polyhedron` object.
    113113
     
    115115      ``projection_direction=<list>`` sets the projetion direction of
    116116      the Schlegel projection. If it is not given, the center of a
    117117      facet is used.
    118    
     118
    119119    EXAMPLES::
    120    
     120
    121121        sage: poly = polytopes.twenty_four_cell()
    122122        sage: poly
    123123        A 4-dimensional polyhedron in QQ^4 defined as the convex hull of 24 vertices
     
    125125        sage: poly.show(projection_direction=[2,5,11,17])
    126126        sage: type( poly.show() )
    127127        <class 'sage.plot.plot3d.base.Graphics3dGroup'>
    128    
     128
    129129    TESTS::
    130    
     130
    131131        sage: from sage.geometry.polyhedron.plot import render_4d
    132132        sage: p = polytopes.n_cube(4)
    133133        sage: q = render_4d(p)
     
    154154def cyclic_sort_vertices_2d(Vlist):
    155155    """
    156156    Return the vertices/rays in cyclic order if possible.
    157    
     157
    158158    NOTES:
    159159
    160160    This works if and only if each vertex/ray is adjacent to exactly
     
    242242            chain = [ Vlist.pop() ]
    243243    result += chain
    244244    return result
    245        
    246        
    247    
     245
     246
     247
    248248
    249249#########################################################################
    250250def projection_func_identity(x):
     
    295295        """
    296296        self.projection_point = vector(projection_point)
    297297        self.dim = self.projection_point.degree()
    298        
     298
    299299        pproj = vector(RDF,self.projection_point)
    300300        self.psize = norm(pproj)
    301301        if (self.psize).is_zero():
     
    314314        Action of the stereographic projection.
    315315
    316316        INPUT:
    317        
     317
    318318        - ``x`` -- a vector or anything convertible to a vector.
    319319
    320320        OUTPUT:
     
    362362    def __init__(self, projection_direction, height = 1.1):
    363363        """
    364364        Initializes the projection.
    365        
     365
    366366        EXAMPLES::
    367367
    368368            sage: from sage.geometry.polyhedron.plot import ProjectionFuncSchlegel
     
    433433          - ``proj`` -- a projection function for the points
    434434
    435435        NOTES:
    436        
     436
    437437        Once initialized, the polyhedral data is fixed. However, the
    438438        projection can be changed later on.
    439439
     
    514514            Sequence([proj(p) for p in self.coords])
    515515        self._init_dimension()
    516516        return self
    517        
     517
    518518
    519519    def identity(self):
    520520        """
    521521        Return the identity projection of the polyhedron.
    522522
    523523        EXAMPLES::
    524        
     524
    525525            sage: p = polytopes.icosahedron()
    526526            sage: from sage.geometry.polyhedron.plot import Projection
    527527            sage: pproj = Projection(p)
     
    537537        Rteurn the stereographic projection.
    538538
    539539        INPUT:
    540        
     540
    541541        - ``projection_point`` - The projection point. This must be
    542542          distinct from the polyhedron's vertices. Default is `(1,0,\dots,0)`
    543543
    544544        EXAMPLES::
    545        
     545
    546546            sage: from sage.geometry.polyhedron.plot import Projection
    547547            sage: proj = Projection(polytopes.buckyball())  #long time
    548548            sage: proj                                      #long time
     
    554554        if projection_point == None:
    555555            projection_point = [1] + [0]*(self.polyhedron_ambient_dim-1)
    556556        return self.__call__(ProjectionFuncStereographic(projection_point))
    557        
     557
    558558
    559559    def schlegel(self, projection_direction=None, height = 1.1):
    560560        """
     
    565565        the sphere.
    566566
    567567        INPUT:
    568        
     568
    569569          - ``projection_direction`` - The direction of the Schlegel
    570570            projection. By default, the vector consisting of the first
    571571            n primes is chosen.
     
    588588        if projection_direction == None:
    589589            projection_direction = primes_first_n(self.polyhedron_ambient_dim)
    590590        return self.__call__(ProjectionFuncSchlegel(projection_direction, height = height))
    591        
     591
    592592
    593593    def coord_index_of(self, v):
    594594        """
     
    621621            [7, 5]
    622622        """
    623623        return [self.coord_index_of(v) for v in v_list]
    624        
     624
    625625
    626626    def coordinates_of(self, coord_index_list):
    627627        """
     
    663663            except AttributeError:
    664664                pass
    665665
    666    
     666
    667667    def _init_from_2d(self, polyhedron):
    668668        """
    669669        Internal function: Initialize from 2d polyhedron.
     
    762762                                          self.coord_index_of(l1[1]) ] )
    763763                    self.arrows.append( [ self.coord_index_of(l2[0]),
    764764                                          self.coord_index_of(l2[1]) ] )
    765    
     765
    766766
    767767    def _init_area_2d(self, polyhedron):
    768768        """
     
    781781        vertices = [v for v in polyhedron.Vrep_generator()]
    782782        vertices = cyclic_sort_vertices_2d(vertices)
    783783        coords = []
    784        
     784
    785785        def adjacent_vertices(i):
    786786            n = len(vertices)
    787787            if vertices[(i-1) % n].is_vertex(): yield vertices[(i-1) % n]
    788788            if vertices[(i+1) % n].is_vertex(): yield vertices[(i+1) % n]
    789        
     789
    790790        for i in range(len(vertices)):
    791791            v = vertices[i]
    792792            if v.is_vertex():
     
    794794            if v.is_ray():
    795795                for a in adjacent_vertices(i):
    796796                    coords.append(a() + v())
    797                
     797
    798798        if polyhedron.n_lines() == 0:
    799799            self.polygons.append( self.coord_indices_of(coords) )
    800800            return
    801    
     801
    802802        polygons = []
    803803
    804804        if polyhedron.n_lines() == 1:
     
    815815            l1 = line1()
    816816            l2 = line2()
    817817            polygons = [ [v-l1-l2, v+l1-l2, v+l1+l2, v-l1+l2] ]
    818        
     818
    819819        polygons = [ self.coord_indices_of(p) for p in polygons ]
    820820        self.polygons.extend(polygons)
    821        
     821
    822822
    823823
    824824    def _init_solid_3d(self, polyhedron):
     
    851851            vertices = [v for v in facet_equation.incident()]
    852852            vertices = cyclic_sort_vertices_2d(vertices)
    853853            coords = []
    854        
     854
    855855            def adjacent_vertices(i):
    856856                n = len(vertices)
    857857                if vertices[(i-1) % n].is_vertex(): yield vertices[(i-1) % n]
    858858                if vertices[(i+1) % n].is_vertex(): yield vertices[(i+1) % n]
    859        
     859
    860860            for i in range(len(vertices)):
    861861                v = vertices[i]
    862862                if v.is_vertex():
     
    883883                    assert len(coords)==2, "There must be two points."
    884884                    polygons.append( [ coords[0],coords[1],
    885885                                       coords[1]+shift, coords[0]+shift ] )
    886                
     886
    887887        if polyhedron.n_lines()==2:
    888888            [line1, line2] = [l for l in polyhedron.line_generator()]
    889889            l1 = line1()
    890890            l2 = line2()
    891891            for v in polyhedron.vertex_generator():
    892892                polygons.append( [v()-l1-l2, v()+l1-l2, v()+l1+l2, v()-l1+l2] )
    893            
     893
    894894        self.polygons.extend( [self.coord_indices_of(p) for p in polygons] )
    895895
    896896
     
    946946        poly = [polygon2d(self.coordinates_of(p), **kwds)
    947947                 for p in self.polygons]
    948948        return sum(poly)
    949    
    950  
     949
     950
    951951    def render_vertices_3d(self, **kwds):
    952952        """
    953953        Return the 3d rendering of the vertices.
     
    988988    def render_solid_3d(self, **kwds):
    989989        """
    990990        Return solid 3d rendering of a 3d polytope.
    991        
     991
    992992        EXAMPLES::
    993        
     993
    994994            sage: p = polytopes.n_cube(3).projection()
    995995            sage: p_solid = p.render_solid_3d(opacity = .7)
    996996            sage: type(p_solid)
  • sage/geometry/polyhedron/representation.py

    diff --git a/sage/geometry/polyhedron/representation.py b/sage/geometry/polyhedron/representation.py
    a b  
    3232    """
    3333    The internal base class for all representation objects of
    3434    ``Polyhedron`` (vertices/rays/lines and inequalites/equations)
    35    
     35
    3636    .. note::
    37    
     37
    3838        You should not (and cannot) instantiate it yourself. You can
    3939        only obtain them from a Polyhedron() class.
    4040
     
    4444            sage: P.PolyhedronRepresentation()
    4545            <class 'sage.geometry.polyhedron.representation.PolyhedronRepresentation'>
    4646    """
    47    
     47
    4848    # Numeric values for the output of the type() method
    4949    INEQUALITY = 0
    5050    EQUATION = 1
    5151    VERTEX = 2
    5252    RAY = 3
    5353    LINE = 4
    54    
     54
    5555    def __len__(self):
    5656        """
    5757        Returns the length of the representation data.
    58        
     58
    5959        TESTS::
    60        
     60
    6161            sage: p = Polyhedron(vertices=[[1,2,3]])
    6262            sage: v = p.Vrepresentation(0)
    6363            sage: v.__len__()
     
    6868    def __getitem__(self, i):
    6969        """
    7070        Supports indexing.
    71        
     71
    7272        TESTS::
    73        
     73
    7474            sage: p = Polyhedron(vertices=[[1,2,3]])
    7575            sage: v = p.Vrepresentation(0)
    7676            sage: v.__getitem__(1)
     
    169169    def polyhedron(self):
    170170        """
    171171        Returns the underlying polyhedron.
    172        
     172
    173173        TESTS::
    174        
     174
    175175            sage: p = Polyhedron(vertices=[[1,2,3]])
    176176            sage: v = p.Vrepresentation(0)
    177177            sage: v.polyhedron()
     
    185185        object. Shorthand for the vector() method.
    186186
    187187        TESTS::
    188        
     188
    189189            sage: p = Polyhedron(vertices=[[1,2,3]])
    190190            sage: v = p.Vrepresentation(0)
    191191            sage: v.__call__()
     
    199199        storage order.
    200200
    201201        NOTES:
    202        
     202
    203203        H-representation and V-representation objects are enumerated
    204204        independently. That is, amongst all vertices/rays/lines there
    205205        will be one with ``index()==0``, and amongs all
     
    207207        unless the polyhedron is empty or spans the whole space.
    208208
    209209        EXAMPLES::
    210        
     210
    211211            sage: s = Polyhedron(vertices=[[1],[-1]])
    212212            sage: first_vertex = s.vertex_generator().next()
    213213            sage: first_vertex.index()
     
    388388            True
    389389        """
    390390        return False
    391    
     391
    392392    def A(self):
    393393        r"""
    394394        Returns the coefficient vector `A` in `A\vec{x}+b`.
     
    485485        r"""
    486486        Evaluates the left hand side `A\vec{x}+b` on the given
    487487        vertex/ray/line.
    488        
     488
    489489        NOTES:
    490          
     490
    491491          * Evaluating on a vertex returns `A\vec{x}+b`
    492492          * Evaluating on a ray returns `A\vec{r}`. Only the sign or
    493493            whether it is zero is meaningful.
     
    495495            is zero or not is meaningful.
    496496
    497497        EXAMPLES::
    498        
     498
    499499            sage: triangle = Polyhedron(vertices=[[1,0],[0,1],[-1,-1]])
    500500            sage: ineq = triangle.inequality_generator().next()
    501501            sage: ineq
     
    506506            [0, 0, 3]
    507507
    508508        If you pass a vector, it is assumed to be the coordinate vector of a point::
    509            
     509
    510510            sage: ineq.eval( vector(ZZ, [3,2]) )
    511511            5
    512512        """
     
    642642                return self.polyhedron()._is_nonneg( self.eval(Vobj) )
    643643        except AttributeError:
    644644            pass
    645                
     645
    646646        if Vobj.is_line():
    647647            return self.polyhedron()._is_zero( self.eval(Vobj) )
    648648        else:
     
    665665            [True, False, False, False, True, True, True, False]
    666666
    667667        If you pass a vector, it is assumed to be the coordinate vector of a point::
    668        
     668
    669669            sage: P = Polyhedron(vertices=[[1,1],[1,-1],[-1,1],[-1,-1]])
    670670            sage: p = vector(ZZ, [1,0] )
    671671            sage: [ ieq.interior_contains(p) for ieq in P.inequality_generator() ]
     
    676676                return self.polyhedron()._is_positive( self.eval(Vobj) )
    677677        except AttributeError:
    678678            pass
    679                
     679
    680680        if Vobj.is_line():
    681681            return self.polyhedron()._is_zero( self.eval(Vobj) )
    682682        elif Vobj.is_vertex():
     
    738738    def _repr_(self):
    739739        """
    740740        A string representation of this object.
    741        
     741
    742742        TESTS::
    743743
    744744            sage: p = Polyhedron(vertices = [[0,0,0],[1,1,0],[1,2,0]])
     
    768768        the given vertex/ray/line.
    769769
    770770        EXAMPLES::
    771        
     771
    772772            sage: p = Polyhedron(vertices = [[0,0,0],[1,1,0],[1,2,0]])
    773773            sage: v = p.vertex_generator().next()
    774774            sage: v
     
    817817        Initializes the PolyhedronRepresentation object.
    818818
    819819        TESTS::
    820        
     820
    821821            sage: p = Polyhedron(vertices = [[0,0,0],[1,1,0],[1,2,0]])
    822822            sage: a = p.inequality_generator().next()
    823823            sage: a
     
    954954        Alias for neighbors().
    955955
    956956        TESTS::
    957        
     957
    958958            sage: p = Polyhedron(vertices = [[0,0],[1,0],[0,3],[1,4]])
    959959            sage: v = p.vertex_generator().next()
    960960            sage: a = v.neighbors().next()
     
    11161116        Boolean.
    11171117
    11181118        EXAMPLES::
    1119        
     1119
    11201120            sage: p = Polyhedron([(1/2,3,5), (0,0,0), (2,3,7)])
    11211121            sage: [ v.is_integral() for v in p.vertex_generator() ]
    11221122            [True, False, True]
     
    11901190        Returns `A\vec{r}`
    11911191
    11921192        EXAMPLES::
    1193        
     1193
    11941194            sage: p = Polyhedron(ieqs = [[0,0,1],[0,1,0],[1,-1,0]])
    11951195            sage: a = p.ray_generator().next()
    11961196            sage: h = p.inequality_generator().next()
     
    12401240        Tests if the object is a line.  By construction it must be.
    12411241
    12421242        TESTS::
    1243        
     1243
    12441244            sage: p = Polyhedron(ieqs = [[1, 0, 0, 1],[1,1,0,0]])
    12451245            sage: a = p.line_generator().next()
    12461246            sage: a.is_line()
     
    12531253        A string representation of the line.
    12541254
    12551255        TESTS::
    1256        
     1256
    12571257            sage: p = Polyhedron(ieqs = [[1, 0, 0, 1],[1,1,0,0]])
    12581258            sage: a = p.line_generator().next()
    12591259            sage: a.__repr__()
     
    12641264    def evaluated_on(self, Hobj):
    12651265        r"""
    12661266        Returns `A\vec{\ell}`
    1267        
     1267
    12681268        EXAMPLES::
    1269        
     1269
    12701270            sage: p = Polyhedron(ieqs = [[1, 0, 0, 1],[1,1,0,0]])
    12711271            sage: a = p.line_generator().next()
    12721272            sage: h = p.inequality_generator().next()