Ticket #11880: trac_11880-documentation.patch

File trac_11880-documentation.patch, 4.0 KB (added by ncohen, 8 years ago)
  • sage/graphs/isgci.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1331054972 -3600
    # Node ID ae75360c9f8f12d1dbd9498491847fd3f370928b
    # Parent  9c8a964d2d1b7030ffa68f3870929f4c5e4f437d
    Some documentation and doctests in sage.graphs.isgci
    
    diff --git a/sage/graphs/isgci.py b/sage/graphs/isgci.py
    a b  
    4747        Unknown
    4848
    4949Given a graph class, one can obtain its associated information in the
    50 ISGCI database with the :meth:`~GraphClass.show` method::
     50ISGCI database with the :meth:`~GraphClass.description` method::
    5151
    52     sage: Chordal.show()
     52    sage: Chordal.description()
    5353    Class of graphs : Chordal
    5454    -------------------------
    5555    type                           :  base
     
    358358        True
    359359    """
    360360    def __init__(self, name, gc_id):
     361        r"""
     362        Class constructor
     363
     364        EXAMPLE::
     365
     366            sage: graph_classes.Chordal  # indirect doctest
     367            Chordal graphs
     368        """
    361369        self._name = name
    362370        self._gc_id = gc_id
    363371
     
    375383    def __hash__(self):
    376384        r"""
    377385        Returns the class' ID
     386
     387        EXAMPLE::
     388
     389            sage: hash(graph_classes.Chordal)
     390            -2927255616177890469
    378391        """
    379         return self._gc_id
     392        return hash(self._gc_id)
    380393
    381394    def __le__(self, other):
     395        r"""
     396        <= operator
     397
     398        EXAMPLE::
     399
     400            sage: graph_classes.Chordal <= graph_classes.Tree
     401            Unknown
     402        """
    382403        return other.__ge__(self)
    383404
    384405    def __ge__(self, other):
     406        r"""
     407        >= operator
     408
     409        EXAMPLE::
     410
     411            sage: graph_classes.Chordal >= graph_classes.Tree
     412            True
     413        """
     414
    385415        inclusion_digraph = GraphClasses().inclusion_digraph()
    386416        if inclusion_digraph.shortest_path(self._gc_id,other._gc_id) != []:
    387417            return True
     
    389419            return Unknown
    390420
    391421    def __eq__(self, other):
     422        r"""
     423        == operator
     424
     425        EXAMPLE::
     426
     427            sage: graph_classes.Chordal == graph_classes.Tree
     428            Unknown
     429        """
    392430        return self.__ge__(other) and other.__ge__(self)
    393431
    394432    def __lt__(self, other):
     433        r"""
     434        >, !=, and < operators
     435
     436        EXAMPLE::
     437
     438            sage: graph_classes.Chordal > graph_classes.Tree
     439            Traceback (most recent call last):
     440            ...
     441            Exception: Not Implemented
     442            sage: graph_classes.Chordal < graph_classes.Tree
     443            Traceback (most recent call last):
     444            ...
     445            Exception: Not Implemented
     446            sage: graph_classes.Chordal != graph_classes.Tree
     447            Traceback (most recent call last):
     448            ...
     449            Exception: Not Implemented
     450        """
    395451        raise Exception("Not Implemented")
    396452
    397453    __gt__ = __ne__ = __lt__
    398454
    399     def show(self):
     455    def description(self):
    400456        r"""
    401457        Prints the information of ISGCI about the current class.
    402458
    403459        EXAMPLE::
    404460
    405             sage: graph_classes.Chordal.show()
     461            sage: graph_classes.Chordal.description()
    406462            Class of graphs : Chordal
    407463            -------------------------
    408464            type                           :  base
     
    689745            print "Database saved to .sobj files in "+SAGE_ROOT+'/data/graphs/'
    690746            return
    691747
    692         except IOError:
    693             # TODO: improve!
    694             print "Could not save save database in "+SAGE_ROOT+'/data/graphs/'
     748        except IOError, v:
     749            print "Could not save save database in "+SAGE_ROOT+"/data/graphs/ ("+str(v.strerror)+")"
    695750            print "Now attempting to save the files to "+str(SAGE_DB)
    696751
    697752        # Trying to save to the user's home directory
     
    728783        from sage.all import save, load
    729784        from sage.misc.misc import SAGE_TMP, SAGE_ROOT, SAGE_LOCAL, SAGE_DB
    730785
    731         # TODO: or systematically use the user's version if it exists,
    732         # throwing a warning if it is not the most recent?
    733 
    734786        try:
    735787            open(SAGE_DB+"/isgci_classes.sobj")
    736788