#14266: Pretty Console Output --> ascii art
---------------------------------------+------------------------------------
       Reporter:  elixyre              |         Owner:  was         
           Type:  task                 |        Status:  needs_review
       Priority:  major                |     Milestone:  sage-5.9    
      Component:  user interface       |    Resolution:              
       Keywords:  ascii-art            |   Work issues:              
Report Upstream:  N/A                  |     Reviewers:              
        Authors:  Jean-Baptiste Priez  |     Merged in:              
   Dependencies:                       |      Stopgaps:              
---------------------------------------+------------------------------------

Comment (by vbraun):

 Looks pretty nice! I'm fine with the functionality, but the documentation
 needs to be improved. Especially since you want to provide other
 developers a framework to enable ascii art output.

 Some of the names are awkward in English. Pretty console representation
 means that the console is pretty, not the repr(esentation). It would be
 nice (and it would make writing doctests easier) if we install a global
 function analogous to `repr()` to get the ascii art representation. I
 would suggest we call it `display()` and the magic `%display` (instead of
 `%pcp`, unless you want to use it as a pun on the hallucinogenic drug).

 Similarly, I don't like `__pretty_repr__`. Its not a variant of `__repr__`
 with pretty output since it returns a specialized object instead of a
 string. Its also not a Python builtin, so Sage coding style would use only
 single underscores. How about we call it `_ascii_art_()`? Similarly,
 `set_display` instead of `set_pretty_repr`.

 Also, since this should be a general framework we should add a default
 `_ascii_art_` method (with suitable documentation to benefit developers)
 to `SageObject`. For example (in `sage_object.pyx`):
 {{{
     def _ascii_art_(self):
         '''
         Return an ASCII art representation.

         To implement multi-line ASCII art output in a derived class
         you must override this method. Unlike :meth:`_repr_`, which is
         sometimes used for the hash key, the output of
         :meth:`_ascii_art_` may depend on settings and is allowed to
         change during runtime. For example,
         :meth:`~sage.combinat.tableau.Tableaux.set_display` can be
         used to switch the ASCII art of tableaux between different
         mathematical conventions.

         OUTPUT:

         An :class:`~sage.misc.ascii_art.AsciiArt` object, see
         :mod:`sage.misc.ascii_art` for details.

         EXAMPLES:

         You can use the :func:`~sage.misc.ascii_art.display` function
         to get the ASCII art representation of any object in Sage::

             sage: display(integral(exp(x^2)/(x+1), x))
             ⌠
             ⎮  ⎛ 2⎞
             ⎮  ⎝x ⎠
             ⎮ ℯ
             ⎮ ───── dx
             ⎮ x + 1
             ⌡

         Alternatively, you can use the `%display on/off` magic to
         switch all output to ASCII art and back::

             sage: tab = StandardTableaux(3)[2];  tab
             [[1, 2], [3]]
             sage: %display on
             sage: tab
             1  2
             3
             sage: Tableau.set_display("normal")
             sage: tab
             +---+
             | 3 |
             +---+---+
             | 1 | 2 |
             +---+---+
             sage: %display off

         TESTS::

             sage: 1._ascii_art_()
             1
             sage: type(_)
             sage.misc.ascii_art.AsciiArt
         '''
         from sage.misc.ascii_art import AsciiArt
         return AsciiArt(repr(self))
 }}}

 Finally, __every__ function must be documented and doctested. Please
 follow http://www.sagemath.org/doc/developer/conventions.html#docstring-
 markup-with-rest-and-sphinx for the markup. For example, we use an
 `OUTPUT:` block instead of `@postcondition`.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14266#comment:15>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to