Ticket #14469: trac_14469_repr_graphics.patch

File trac_14469_repr_graphics.patch, 24.8 KB (added by Volker Braun, 9 years ago)

Updated patch

  • sage/categories/crystals.py

    # HG changeset patch
    # User Volker Braun <vbraun.name@gmail.com>
    # Date 1370018695 -3600
    # Node ID 3389cb1093c836927f23b23da386cc07f75183d6
    # Parent  e79338e4f8e7470a306959a2c5f1206f31acf4fe
    Sanitize _repr_ of graphics objects.
    
    diff --git a/sage/categories/crystals.py b/sage/categories/crystals.py
    a b  
    817817            EXAMPLES::
    818818
    819819                sage: C = CrystalOfLetters(['A', 5])
    820                 sage: show_default(False) #do not show the plot by default
    821                 sage: C.plot()
     820                sage: print(C.plot())
    822821                Graphics object consisting of 17 graphics primitives
    823822            """
    824823            return self.digraph().plot(edge_labels=True,vertex_size=0,**options)
     
    830829            EXAMPLES::
    831830
    832831                sage: C = KirillovReshetikhinCrystal(['A',3,1],2,1)
    833                 sage: C.plot3d()
     832                sage: print(C.plot3d())
    834833                Graphics3d Object
    835834            """
    836835            G = self.digraph(**options)
  • sage/combinat/rigged_configurations/kleber_tree.py

    diff --git a/sage/combinat/rigged_configurations/kleber_tree.py b/sage/combinat/rigged_configurations/kleber_tree.py
    a b  
    626626        EXAMPLES::
    627627
    628628            sage: KT = KleberTree(['D', 4], [[2, 2]])
    629             sage: show_default(False) #do not show the plot by default
    630             sage: KT.plot()
     629            sage: print(KT.plot())
    631630            Graphics object consisting of 8 graphics primitives
    632631        """
    633632        return self.digraph().plot(edge_labels=True, vertex_size=0, **options)
  • sage/interfaces/sage0.py

    diff --git a/sage/interfaces/sage0.py b/sage/interfaces/sage0.py
    a b  
    423423        """
    424424        return SageElement(self, x)
    425425
     426
    426427class SageElement(ExpectElement):
     428
     429    def _graphics_(self):
     430        """
     431        Disable graphical output.
     432
     433        This is necessary because otherwise our :meth:`__getattr__`
     434        would be called.
     435       
     436        EXAMPLES::
     437
     438            sage: m = sage0(4)
     439            sage: m._graphics_()
     440            False
     441        """
     442        return False
     443
    427444    def __getattr__(self, attrname):
    428445        """
    429446        EXAMPLES::
  • sage/misc/displayhook.py

    diff --git a/sage/misc/displayhook.py b/sage/misc/displayhook.py
    a b  
    251251            [0 0 1], [0 0 1]
    252252            )
    253253        """
     254        if hasattr(obj, '_graphics_') and not isinstance(obj, type):
     255            if obj._graphics_():
     256                return
    254257        s = format_obj(obj)
    255258        if s is not None:
    256259            print s
     
    305308            {u'text/plain':     10      9      8      7      6      5      4      3      2   
    306309                            10*x   + 9*x  + 8*x  + 7*x  + 6*x  + 5*x  + 4*x  + 3*x  + 2*x  + x}
    307310        """
     311        if hasattr(obj, '_graphics_') and not isinstance(obj, type):
     312            if obj._graphics_():
     313                return ''
    308314        s = self._format_obj(obj)
    309315        if s is None:
    310316            s = super(SagePlainTextFormatter, self).__call__(obj)
  • sage/misc/sage_input.py

    diff --git a/sage/misc/sage_input.py b/sage/misc/sage_input.py
    a b  
    12171217        r"""
    12181218        Initialize a \class{SageInputExpression}.
    12191219
    1220         EXAMPLES:
     1220        EXAMPLES::
     1221
    12211222            sage: from sage.misc.sage_input import SageInputBuilder
    1222 
    12231223            sage: sib = SageInputBuilder()
    12241224            sage: sie = sib(3) # indirect doctest
    12251225            sage: sie
     
    12431243        enough that duplicate uses are not worth caching.  Normally
    12441244        this will be true if the expression represents a single token.
    12451245
    1246         EXAMPLES:
     1246        EXAMPLES::
     1247
    12471248            sage: from sage.misc.sage_input import SageInputBuilder
    1248 
    12491249            sage: sib = SageInputBuilder()
    12501250            sage: sib.name('QQ')._sie_is_simple()
    12511251            True
     
    12591259        Returns a list of the immediate subexpressions of this
    12601260        \class{SageInputExpression}.
    12611261
    1262         EXAMPLES:
     1262        EXAMPLES::
     1263
    12631264            sage: from sage.misc.sage_input import SageInputBuilder
    1264 
    12651265            sage: sib = SageInputBuilder()
    12661266            sage: len(sib(GF(2))._sie_referenced())
    12671267            2
     
    12771277        to replace with a variable (rather than generating the value
    12781278        multiple times).
    12791279
    1280         EXAMPLES:
     1280        EXAMPLES::
     1281
    12811282            sage: from sage.misc.sage_input import SageInputBuilder, SageInputFormatter
    1282 
    12831283            sage: sib = SageInputBuilder()
    12841284            sage: sif = SageInputFormatter()
    12851285            sage: pair = sib((GF(2), GF(2)))
     
    13171317        and register it with a \class{SageInputFormatter} (which will
    13181318        allocate a variable name at the end of the preparatory phase).
    13191319
    1320         EXAMPLES:
     1320        EXAMPLES::
     1321
    13211322            sage: from sage.misc.sage_input import SageInputBuilder, SageInputFormatter
    1322 
    13231323            sage: sib = SageInputBuilder()
    13241324            sage: sif = SageInputFormatter()
    13251325            sage: sie = sib(3)
     
    13371337        Get the variable name that the \class{SageInputFormatter} allocated
    13381338        for this \class{SageInputExpression}.
    13391339
    1340         EXAMPLES:
     1340        EXAMPLES::
     1341
    13411342            sage: from sage.misc.sage_input import SageInputBuilder, SageInputFormatter
    1342 
    13431343            sage: sib = SageInputBuilder()
    13441344            sage: sif = SageInputFormatter()
    13451345            sage: sie = sib(3)
     
    13611361        See the documentation for \method{SIE_unary._sie_is_negation}
    13621362        for useful examples.
    13631363
    1364         EXAMPLES:
     1364        EXAMPLES::
     1365
    13651366            sage: from sage.misc.sage_input import SageInputBuilder, SageInputFormatter
    1366 
    13671367            sage: sib = SageInputBuilder()
    13681368            sage: sie = sib.name('foo')
    13691369            sage: sie._sie_is_negation()
     
    13771377        \class{SageInputExpression} representing a function call node
    13781378        (with \code{self} as the function).
    13791379
    1380         EXAMPLES:
     1380        EXAMPLES::
     1381
    13811382            sage: from sage.misc.sage_input import SageInputBuilder
    1382 
    13831383            sage: sib = SageInputBuilder()
    13841384            sage: sie = sib(3)
    13851385            sage: sie(4)
     
    13981398
    13991399        Currently, slices are not supported.
    14001400
    1401         EXAMPLES:
     1401        EXAMPLES::
     1402
    14021403            sage: from sage.misc.sage_input import SageInputBuilder
    1403 
    14041404            sage: sib = SageInputBuilder()
    14051405            sage: sie = sib(3)
    14061406            sage: sie[4]
     
    14161416        Given a \class{SageInputExpression}, build a new
    14171417        \class{SageInputExpression} representing an attribute access.
    14181418
    1419         EXAMPLES:
     1419        EXAMPLES::
     1420
    14201421            sage: from sage.misc.sage_input import SageInputBuilder
    1421 
    14221422            sage: sib = SageInputBuilder()
    14231423            sage: sie = sib.name('x')
    14241424            sage: sie.foo
     
    14281428        """
    14291429        return SIE_getattr(self._sie_builder, self, attr)
    14301430
     1431    def _graphics_(self):
     1432        """
     1433        Disable graphical output.
     1434
     1435        This is necessary because otherwise our :meth:`__getattr__`
     1436        would be called.
     1437       
     1438        EXAMPLES::
     1439
     1440            sage: from sage.misc.sage_input import SageInputBuilder
     1441            sage: sib = SageInputBuilder()
     1442            sage: sie = sib.name('x')
     1443            sage: sie._graphics_()
     1444            False
     1445        """
     1446        return False
     1447
    14311448    def __pow__(self, other):
    14321449        r"""
    14331450        Compute an expression tree for \code{self ** other}.
    14341451
    1435         EXAMPLES:
     1452        EXAMPLES::
     1453
    14361454            sage: from sage.misc.sage_input import SageInputBuilder
    1437 
    14381455            sage: sib = SageInputBuilder()
    14391456            sage: sie = sib(3)
    14401457            sage: sie ^ 4
     
    14461463        r"""
    14471464        Compute an expression tree for \code{self * other}.
    14481465
    1449         EXAMPLES:
     1466        EXAMPLES::
     1467
    14501468            sage: from sage.misc.sage_input import SageInputBuilder
    1451 
    14521469            sage: sib = SageInputBuilder()
    14531470            sage: sie = sib(3)
    14541471            sage: sie * 4
     
    14601477        r"""
    14611478        Compute an expression tree for \code{self / other}.
    14621479
    1463         EXAMPLES:
     1480        EXAMPLES::
     1481
    14641482            sage: from sage.misc.sage_input import SageInputBuilder
    1465 
    14661483            sage: sib = SageInputBuilder()
    14671484            sage: sie = sib(3)
    14681485            sage: sie / 4
     
    14741491        r"""
    14751492        Compute an expression tree for \code{self + other}.
    14761493
    1477         EXAMPLES:
     1494        EXAMPLES::
     1495
    14781496            sage: from sage.misc.sage_input import SageInputBuilder
    1479 
    14801497            sage: sib = SageInputBuilder()
    14811498            sage: sie = sib(3)
    14821499            sage: sie + 4
     
    14881505        r"""
    14891506        Compute an expression tree for \code{self - other}.
    14901507
    1491         EXAMPLES:
     1508        EXAMPLES::
     1509
    14921510            sage: from sage.misc.sage_input import SageInputBuilder
    1493 
    14941511            sage: sib = SageInputBuilder()
    14951512            sage: sie = sib(3)
    14961513            sage: sie - 4
     
    15041521        where OP is a string representing a binary operator (such as
    15051522        '+' or '**').
    15061523
    1507         EXAMPLES:
     1524        EXAMPLES::
     1525
    15081526            sage: from sage.misc.sage_input import SageInputBuilder
    1509 
    15101527            sage: sib = SageInputBuilder()
    15111528            sage: v = sib.name('x')._sie_binop('%', sib.name('y'))
    15121529            sage: type(v)
     
    15221539        r"""
    15231540        Compute an expression tree for \code{-self}.
    15241541
    1525         EXAMPLES:
     1542        EXAMPLES::
     1543
    15261544            sage: from sage.misc.sage_input import SageInputBuilder
    1527 
    15281545            sage: sib = SageInputBuilder()
    15291546            sage: sie = sib(3)
    15301547            sage: -sie
     
    15361553        r"""
    15371554        Compute an expression tree for \code{~self}.
    15381555
    1539         EXAMPLES:
     1556        EXAMPLES::
     1557
    15401558            sage: from sage.misc.sage_input import SageInputBuilder
    1541 
    15421559            sage: sib = SageInputBuilder()
    15431560            sage: sie = sib(3)
    15441561            sage: ~sie
     
    15501567        r"""
    15511568        Compute an expression tree for \code{abs(self)}.
    15521569
    1553         EXAMPLES:
     1570        EXAMPLES::
     1571
    15541572            sage: from sage.misc.sage_input import SageInputBuilder
    1555 
    15561573            sage: sib = SageInputBuilder()
    15571574            sage: sie = sib(3)
    15581575            sage: abs(sie)
     
    15661583        where OP is a string representing a unary operator (such as
    15671584        '-' or '~').
    15681585
    1569         EXAMPLES:
     1586        EXAMPLES::
     1587
    15701588            sage: from sage.misc.sage_input import SageInputBuilder
    1571 
    15721589            sage: sib = SageInputBuilder()
    15731590            sage: sie = sib(3)
    15741591            sage: v = sie._sie_unop('~')
     
    15941611        (that cannot be instantiated).
    15951612       
    15961613            sage: from sage.misc.sage_input import SageInputBuilder, SageInputFormatter
    1597 
    15981614            sage: sib = SageInputBuilder()
    15991615            sage: sif = SageInputFormatter()
    16001616            sage: sie = sib(3)
     
    16271643        an error.  (This is to prevent accidental use of
    16281644        \class{SIE_assign} as a value.)
    16291645
    1630         EXAMPLES:
     1646        EXAMPLES::
     1647
    16311648            sage: from sage.misc.sage_input import SageInputBuilder, SageInputFormatter
    1632 
    16331649            sage: sib = SageInputBuilder()
    16341650            sage: sif = SageInputFormatter()
    16351651            sage: v = sib(3)
  • sage/plot/graphics.py

    diff --git a/sage/plot/graphics.py b/sage/plot/graphics.py
    a b  
    3636ALLOWED_EXTENSIONS = ['.eps', '.pdf', '.png', '.ps', '.sobj', '.svg']
    3737DEFAULT_DPI = 100
    3838DOCTEST_MODE_FILE = os.path.join(sage.misc.misc.SAGE_TMP, 'test.png')
    39 SHOW_DEFAULT = True
    4039
    4140def show_default(default=None):
    4241    r"""
     
    4746    when displayed will be displayed as an actual plot instead of text,
    4847    i.e., the show command is not needed.
    4948   
    50     EXAMPLES: The default starts out as ``True``::
     49    EXAMPLES:
     50
     51    The default starts out as ``True`` in interactive use and
     52    ``False`` in doctests::
    5153   
    5254        sage: show_default()
    53         True
    54    
    55     We set it to ``False``.
    56    
    57     ::
    58    
    59         sage: show_default(False)
    60    
    61     We see that it is ``False``.
    62    
    63     ::
    64    
    65         sage: show_default()
     55        doctest:1: DeprecationWarning: this is done automatically by the doctest framework
     56        See http://trac.sagemath.org/14469 for details.
    6657        False
    67    
    68     Now plot commands will not display their plots by default.
    69    
    70     Turn back on default display.
    71    
    72     ::
    73    
    74         sage: show_default(True)
    7558    """
    76     global SHOW_DEFAULT
     59    from sage.misc.superseded import deprecation
     60    deprecation(14469, 'this is done automatically by the doctest framework')
     61    import sage.doctest
    7762    if default is None:
    78         return SHOW_DEFAULT
    79     SHOW_DEFAULT = bool(default)
     63        return not sage.doctest.DOCTEST_MODE
     64    sage.doctest.DOCTEST_MODE = not bool(default)
    8065
    8166# If do_verify is True, options are checked when drawing a
    8267# GraphicsPrimitive.  See primitive.py
     
    780765
    781766    def _repr_(self):
    782767        r"""
    783         Show this graphics objects.
     768        Return a string representation of the graphics objects.
    784769       
    785         If the ``show_default`` function has been called with
    786         True (the default), then you'll see this graphics object displayed.
    787         Otherwise you'll see a text representation of it.
    788        
    789         EXAMPLES: We create a plot and call ``_repr_`` on it,
    790         which causes it to be displayed as a plot::
     770        OUTPUT:
     771
     772        String.
     773
     774        EXAMPLES:
     775
     776        We create a plot and call :meth:`show` on it, which causes it
     777        to be displayed as a plot::
    791778       
    792779            sage: P = plot(cos, (-1,1))
    793             sage: P._repr_()
    794             ''
     780            sage: P.show()
    795781       
    796782        Just doing this also displays the plot::
    797783       
    798784            sage: P
    799785       
    800         Note that printing P with the ``print`` statement does
    801         not display the plot::
     786        Using the Python `repr` or `str` commands do not display the
     787        plot::
    802788       
    803             sage: print P
     789            sage: repr(P)
     790            'Graphics object consisting of 1 graphics primitive'
     791            sage: str(P)
     792            'Graphics object consisting of 1 graphics primitive'
     793            sage: print(P)
    804794            Graphics object consisting of 1 graphics primitive
    805        
    806         Now we turn off showing plots by default::
    807        
    808             sage: show_default(False)
    809        
    810         Now we just get a string. To show P you would have to do
    811         ``show(P)``.
    812        
    813         ::
    814        
     795
     796        TESTS::
     797           
    815798            sage: P._repr_()
    816799            'Graphics object consisting of 1 graphics primitive'
    817             sage: P
    818             Graphics object consisting of 1 graphics primitive
    819        
    820         Finally, we turn ``show_default`` back on::
    821        
    822             sage: show_default(True)
    823800        """
    824         if SHOW_DEFAULT:
    825             self.show()
    826             return ''
    827         else:
    828             return self.__str__()
     801        return self.__str__()
     802
     803    def _graphics_(self):
     804        """
     805        Show graphics.
     806
     807        The presence of this method is used by the displayhook to
     808        decide that we want to see a graphical output by default.
     809
     810        OUTPUT:
     811
     812        Return ``True`` if graphical output was generated (might not
     813        be shown in doctest mode), otherwise ``False``.
     814
     815        EXAMPLES::
     816
     817            sage: g = Graphics()
     818            sage: g._graphics_()
     819            True
     820            sage: [g, g]
     821            [Graphics object consisting of 0 graphics primitives,
     822             Graphics object consisting of 0 graphics primitives]
     823        """
     824        self.show()
     825        return True
    829826
    830827    def __str__(self):
    831828        r"""
    832829        Return string representation of this plot.
    833830       
     831        OUTPUT:
     832
     833        String.
     834       
    834835        EXAMPLES::
    835836       
    836837            sage: S = circle((0,0), 2); S.__str__()
    837838            'Graphics object consisting of 1 graphics primitive'
     839            sage: str(S)
     840            'Graphics object consisting of 1 graphics primitive'
    838841            sage: print S
    839842            Graphics object consisting of 1 graphics primitive
    840        
    841         .. warning::
    842 
    843            ``__str__`` is not called when printing lists of graphics
    844            objects, which can be confusing, since they will all pop
    845            up. One workaround is to call ``show_default``:
    846        
    847         For example, below when we do ``print v`` two plots are
    848         displayed::
    849        
    850             sage: v = [circle((0,0), 2), circle((2,3), 1)]
    851             sage: print v
    852             [, ]
    853        
    854         However, if we call ``show_default`` then we see the
    855         text representations of the graphics::
    856        
    857             sage: show_default(False)
    858             sage: print v
    859             [Graphics object consisting of 1 graphics primitive, Graphics object consisting of 1 graphics primitive]
    860             sage: v
    861             [Graphics object consisting of 1 graphics primitive,
    862              Graphics object consisting of 1 graphics primitive]
    863        
    864         ::
    865        
    866             sage: show_default(True)
    867843        """
    868844        s = "Graphics object consisting of %s graphics primitives"%(len(self))
    869845        if len(self) == 1:
     
    17081684            sage: plot(1.5/(1+e^(-x)), (x, -10, 10), ticks=[None, 1.5/4]) # It's right at f(x)=0.75!
    17091685
    17101686        But be careful to leave enough room for at least two major ticks, so that
    1711         the user can tell what the scale is.
    1712 
    1713         ::
    1714 
    1715             sage: plot(x^2,(x,1,8),ticks=6)
     1687        the user can tell what the scale is::
     1688
     1689            sage: plot(x^2,(x,1,8),ticks=6).show()
    17161690            Traceback (most recent call last):
    17171691            ...
    1718             ValueError: Expand the range of the independent variable to allow two multiples of your tick locator (option `ticks`).
     1692            ValueError: Expand the range of the independent variable to
     1693            allow two multiples of your tick locator (option `ticks`).
    17191694
    17201695        We can also do custom formatting if you need it.  See above for full
    1721         details.
    1722 
    1723         ::
     1696        details::
    17241697
    17251698            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
    17261699
     
    17551728        If the number of tick labels do not match the number of positions of
    17561729        tick labels, then it results in an error.::
    17571730
    1758             sage: plot(x**2, (x,0,2), ticks=[[2], None], tick_formatter=[["$x_1$","$x_2$"], None])
     1731            sage: plot(x**2, (x,0,2), ticks=[[2], None], tick_formatter=[["$x_1$","$x_2$"], None]).show()
    17591732            Traceback (most recent call last):
    17601733            ...
    17611734            ValueError: If the first component of the list `tick_formatter` is a list then the first component of `ticks` must also be a list of equal length.
     
    17811754            ValueError: 'title_pos' must be a list or tuple of two real numbers.
    17821755
    17831756        """
    1784 
    17851757        # This option should not be passed on to save().
    17861758        linkmode = kwds.pop('linkmode', False)
    17871759
     
    27182690            sage: graphics_array(L)
    27192691            Traceback (most recent call last):
    27202692            ...
    2721             TypeError: array (=[[, ], []]) must be a list of lists of Graphics objects
     2693            TypeError: array (=[[Graphics object consisting of 1 graphics primitive, Graphics object consisting of 1 graphics primitive], [Graphics object consisting of 1 graphics primitive]]) must be a list of lists of Graphics objects
    27222694            sage: G = plot(x,(x,0,1))
    27232695            sage: graphics_array(G)
    27242696            Traceback (most recent call last):
     
    27602732
    27612733            sage: R = rainbow(6)
    27622734            sage: L = [plot(x^n,(x,0,1),color=R[n]) for n in range(6)]
    2763             sage: G = graphics_array(L,2,3)
    2764             sage: G # plot shown is default (indirect doctest)
    2765 
    2766         We can make commands not display their plots by default. ::
    2767 
    2768             sage: show_default(False)
    2769             sage: graphics_array(L) # indirect doctest
    2770             Graphics Array of size 1 x 6
    2771             sage: show_default(True)
     2735            sage: graphics_array(L,2,3)
    27722736        """
    2773         if SHOW_DEFAULT:
    2774             self.show()
    2775             return ''
    2776         else:
    2777             return self.__str__()
     2737        return self.__str__()
     2738
     2739    def _graphics_(self):
     2740        """
     2741        Show graphics.
     2742
     2743        The presence of this method is used by the displayhook to
     2744        decide that we want to see a graphical output by default.
     2745
     2746        OUTPUT:
     2747
     2748        Return ``True`` if graphical output was generated (might not
     2749        be shown in doctest mode), otherwise ``False``.
     2750
     2751        EXAMPLES::
     2752
     2753            sage: from sage.plot.graphics import GraphicsArray
     2754            sage: g = GraphicsArray([])
     2755            sage: g._graphics_()
     2756            True
     2757        """
     2758        self.show()
     2759        return True
    27782760
    27792761    def __str__(self):
    27802762        """
     
    27852767            sage: R = rainbow(6)
    27862768            sage: L = [plot(x^n,(x,0,1),color=R[n]) for n in range(6)]
    27872769            sage: G = graphics_array(L,2,3)
     2770            sage: G.__str__()
     2771            'Graphics Array of size 2 x 3'
    27882772            sage: str(G)
    27892773            'Graphics Array of size 2 x 3'
    2790 
    2791         We can make commands not display their plots by default. ::
    2792 
    2793             sage: show_default(False)
    2794             sage: graphics_array(L)
    2795             Graphics Array of size 1 x 6
    2796             sage: show_default(True)
    27972774        """
    27982775        return "Graphics Array of size %s x %s"%(self._rows, self._cols)
    27992776
     
    29692946        EXAMPLES::
    29702947
    29712948            sage: graphics_array([[plot(sin), plot(cos)], [plot(tan), plot(sec)]])
     2949
     2950        TESTS::
     2951
     2952            sage: graphics_array([])
    29722953        """
    29732954        #glist is a list of Graphics objects:
    29742955        glist = self._glist
    29752956        rows = self._rows
    29762957        cols = self._cols
    29772958        dims = self._dims
     2959        if rows == 0 or cols == 0:
     2960            glist = [Graphics()]
     2961            rows = cols = dims = 1
    29782962        #make a blank matplotlib Figure:
    29792963        from matplotlib.figure import Figure
    29802964        figure = Figure(figsize)
  • sage/plot/plot3d/base.pyx

    diff --git a/sage/plot/plot3d/base.pyx b/sage/plot/plot3d/base.pyx
    a b  
    5050
    5151from sage.interfaces.tachyon import tachyon_rt
    5252
    53 from sage.plot.all import show_default
    54 
    5553# import the double infinity constant
    5654cdef extern from "math.h":
    5755     enum: INFINITY
     
    6462    """
    6563    This is the baseclass for all 3d graphics objects.
    6664    """
    67     def __repr__(self):
     65    def _repr_(self):
    6866        """
    69         When show_default is True, objects are displayed rather than
    70         string representations printed.
     67        Return a string representation.
     68
     69        OUTPUT:
     70       
     71        String.
    7172
    7273        EXAMPLES::
    7374
    7475            sage: S = sphere((0, 0, 0), 1)
    75             sage: show_default(False); S
     76            sage: print S
    7677            Graphics3d Object
    77             sage: show_default(True); S
     78        """
     79        return str(self)
    7880
     81    def _graphics_(self):
    7982        """
    80         if show_default():
    81             self.show()
    82             return ''
    83         else:
    84             return str(self)
     83        Show graphics.
     84
     85        The presence of this method is used by the displayhook to
     86        decide that we want to see a graphical output by default.
     87
     88        OUTPUT:
     89
     90        Return ``True`` if graphical output was generated (might not
     91        be shown in doctest mode), otherwise ``False``.
     92
     93        EXAMPLES::
     94
     95            sage: S = sphere((0, 0, 0), 1)
     96            sage: S._graphics_()
     97            True
     98            sage: S  # also productes graphics
     99            sage: [S, S]
     100            [Graphics3d Object, Graphics3d Object]
     101        """
     102        self.show()
     103        return True
    85104
    86105    def __str__(self):
    87106        """
  • sage/rings/integer.pyx

    diff --git a/sage/rings/integer.pyx b/sage/rings/integer.pyx
    a b  
    461461        mpz_init(self.value)
    462462        self._parent = <SageObject>the_integer_ring
    463463       
    464     def __pyxdoc__init__(self):
    465         """
    466         You can create an integer from an int, long, string literal, or
    467         integer modulo N.
    468        
    469         EXAMPLES::
    470        
    471             sage: Integer(495)
    472             495
    473             sage: Integer('495949209809328523')
    474             495949209809328523
    475             sage: Integer(Mod(3,7))
    476             3
    477             sage: 2^3
    478             8
    479         """
    480        
    481464    def __init__(self, x=None, base=0):
    482465        """
    483466        EXAMPLES::
  • sage/server/support.py

    diff --git a/sage/server/support.py b/sage/server/support.py
    a b  
    4646
    4747    import sage.plot.plot
    4848    sage.plot.plot.EMBEDDED_MODE = True
    49     # Set this to true and plots are shown by default.
    50     #sage.plot.plot.SHOW_DEFAULT = True   
    5149    if object_directory:
    5250        sage.structure.sage_object.base=object_directory
    5351    sage.misc.latex.EMBEDDED_MODE = True