Ticket #14479: trac_14479_cdd_error.patch

File trac_14479_cdd_error.patch, 4.9 KB (added by vbraun, 8 years ago)

Initial patch

  • sage/geometry/polyhedron/backend_cdd.py

    # HG changeset patch
    # User Volker Braun <vbraun.name@gmail.com>
    # Date 1366718950 -3600
    # Node ID 8b94030815e437644bfaae8bb1f825c7b352cfc1
    # Parent  4bc5828edbcbde84ebd8c875c6b1b1e975d74562
    Catch CDD errors
    
    diff --git a/sage/geometry/polyhedron/backend_cdd.py b/sage/geometry/polyhedron/backend_cdd.py
    a b  
    8686        Compute the facet adjacency matrix in case it has not been
    8787        computed during initialization.
    8888
     89        INPUT:
     90
     91        - ``verbose`` -- boolean (default: ``False``). Whether to print
     92          verbose output for debugging purposes.
     93
    8994        EXAMPLES::
    9095
    9196            sage: p = Polyhedron(vertices=[(0,0),(1,0),(0,1)], backend='cdd', base_ring=QQ)
     
    106111        Compute the vertex adjacency matrix in case it has not been
    107112        computed during initialization.
    108113
     114        INPUT:
     115
     116        - ``verbose`` -- boolean (default: ``False``). Whether to print
     117          verbose output for debugging purposes.
     118
    109119        EXAMPLES::
    110120
    111121            sage: p = Polyhedron(vertices=[(0,0),(1,0),(0,1)], backend='cdd', base_ring=QQ)
     
    128138
    129139        TESTS::
    130140
    131             sage: p = Polyhedron(vertices = [[0,0,0],[1,0,0],[0,1,0],[0,0,1]], backend='cdd', base_ring=QQ)
     141            sage: p = Polyhedron(vertices=[[0,0,0],[1,0,0],[0,1,0],[0,0,1]],
     142            ...                  backend='cdd', base_ring=QQ)
    132143            sage: from sage.geometry.polyhedron.cdd_file_format import cdd_Vrepresentation
    133144            sage: s = cdd_Vrepresentation('rational', [[0,0,1],[0,1,0],[1,0,0]], [], [])
    134145            sage: p._init_from_cdd_input(s)
    135146            sage: p.dim()
    136147            2
     148
     149            sage: point_list = [[0.132, -1.028, 0.028],[0.5, 0.5, -1.5],
     150            ...    [-0.5, 1.5, -0.5],[0.5, 0.5, 0.5],[1.5, -0.5, -0.5],
     151            ...    [-0.332, -0.332, -0.668],[-1.332, 0.668, 0.332],
     152            ...    [-0.932, 0.068, 0.932],[-0.38, -0.38, 1.38],
     153            ...    [-0.744, -0.12, 1.12],[-0.7781818182, -0.12, 0.9490909091],
     154            ...    [0.62, -1.38, 0.38],[0.144, -1.04, 0.04],
     155            ...    [0.1309090909, -1.0290909091, 0.04]]
     156            sage: Polyhedron(point_list)
     157            Traceback (most recent call last):
     158            ...
     159            ValueError: *Error: Numerical inconsistency is found.  Use the GMP exact arithmetic.
    137160        """
    138         if verbose: print cdd_input_string
     161        if verbose:
     162            print '---- CDD input -----'
     163            print cdd_input_string
    139164
    140165        cdd_proc = Popen([self._cdd_executable, cmdline_arg],
    141166                         stdin=PIPE, stdout=PIPE, stderr=PIPE)
    142167        ans, err = cdd_proc.communicate(input=cdd_input_string)
    143 
    144         # FIXME: check err
     168       
    145169        if verbose:
     170            print '---- CDD output -----'
    146171            print ans
     172            print err
     173        if 'Error:' in ans + err:
     174            # cdd reports errors on stdout and misc information on stderr
     175            raise ValueError(ans.strip())
    147176        self._init_from_cdd_output(ans)
    148177
    149178
  • sage/geometry/polyhedron/backend_ppl.py

    diff --git a/sage/geometry/polyhedron/backend_ppl.py b/sage/geometry/polyhedron/backend_ppl.py
    a b  
    3333        sage: TestSuite(p).run()
    3434    """
    3535
    36     def _init_from_Vrepresentation(self, vertices, rays, lines, minimize=True):
     36    def _init_from_Vrepresentation(self, vertices, rays, lines, minimize=True, verbose=False):
    3737        """
    3838        Construct polyhedron from V-representation data.
    3939
     
    5151          any iterable container of
    5252          :meth:`~sage.geometry.polyhedron.base.base_ring` elements.
    5353
     54        - ``verbose`` -- boolean (default: ``False``). Whether to print
     55          verbose output for debugging purposes.
     56
    5457        EXAMPLES::
    5558
    5659            sage: p = Polyhedron(backend='ppl')
     
    8992        self._init_Vrepresentation_from_ppl(minimize)
    9093        self._init_Hrepresentation_from_ppl(minimize)
    9194
    92     def _init_from_Hrepresentation(self, ieqs, eqns, minimize=True):
     95    def _init_from_Hrepresentation(self, ieqs, eqns, minimize=True, verbose=False):
    9396        """
    9497        Construct polyhedron from H-representation data.
    9598
     
    103106          as any iterable container of
    104107          :meth:`~sage.geometry.polyhedron.base.base_ring` elements.
    105108
     109        - ``verbose`` -- boolean (default: ``False``). Whether to print
     110          verbose output for debugging purposes.
     111
    106112        EXAMPLES::
    107113
    108114            sage: p = Polyhedron(backend='ppl')
  • sage/geometry/polyhedron/constructor.py

    diff --git a/sage/geometry/polyhedron/constructor.py b/sage/geometry/polyhedron/constructor.py
    a b  
    396396        Vrep = [vertices, rays, lines]
    397397
    398398    # finally, construct the Polyhedron
    399     return parent(Vrep, Hrep, convert=convert)
     399    return parent(Vrep, Hrep, convert=convert, verbose=verbose)