Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
fix doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
vbraun committed Apr 24, 2015
1 parent d8d97c8 commit 4e2e74f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
37 changes: 19 additions & 18 deletions src/doc/en/prep/Programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,14 @@ That's it. This sort of turns the loop around.
- The notation is easiest if you think of it mathematically; "The set of
:math:`n^2`, for (all) :math:`n` in the range between 3 and 13."

This is phenomenally useful. Here is a nice plotting example.

::
This is phenomenally useful. Here is a nice plotting example::

sage: plot([x^n for n in [2..6]],(x,0,1))
Graphics object consisting of 5 graphics primitives

Now we apply it to the example we were doing in the first place. Notice
we now have a nice concise description of all determinants of these
matrices, without the syntax of colon and indentation.

::
matrices, without the syntax of colon and indentation::

sage: [det(A^i) for i in [0..4]]
[1, -2, 4, -8, 16]
Expand All @@ -361,28 +357,33 @@ Tables
Finally, getting away from strictly programming, here is a useful tip.

Some of you may be familiar with a way to take such data and put it in
tabular form from other programs. The ``html.table`` command does this
for us.
tabular form from other programs. The ``table`` command does this
for us::

.. skip
::

sage: html.table( [ (i,det(A^i)) for i in [0..4] ] )
<html>...</html>
sage: table( [ (i,det(A^i)) for i in [0..4] ] )
0 1
1 -2
2 4
3 -8
4 16

Notice that each element of *this* list is two items in parentheses (a
so\-called *tuple*).

Even better, we can put a header line on it to make it really clear what
we are doing, by adding lists. We've seen keywords like ``header=True``
when doing some of our plotting and limits. What do you think will
happen if you put dollar signs around the labels in the header?
happen if you put dollar signs around the labels in the header? ::

::
sage: table( [('i', 'det(A^i)')] + [ (i,det(A^i)) for i in [0..4] ], header_row=True)
i det(A^i)
+---+----------+
0 1
1 -2
2 4
3 -8
4 16

sage: html.table( [('i', 'det(A^i)')] + [ (i,det(A^i)) for i in [0..4] ] , header=True)
<html>...</html>

.. _Defs:

Expand Down
6 changes: 2 additions & 4 deletions src/sage/databases/oeis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1431,9 +1431,7 @@ def links(self, browse=None, format='guess'):
'http://oeis.org/A000024'
sage: s.links(format="html")
<html><font color='black'>0: Wikipedia, <a href="http://en.wikipedia.org/wiki/42_(number)">42 (number)</a>
1: See. also <a href="http://trac.sagemath.org/sage_trac/ticket/42">trac ticket #42</a>
...
'0: Wikipedia, <a href="http://en.wikipedia.org/wiki/42_(number)">42 (number)</a>\n1: See. also <a href="http://trac.sagemath.org/sage_trac/ticket/42">trac ticket #42</a>...'
"""
url_absolute = lambda s: re.sub('\"\/', '\"' + oeis_url, s)
if browse is None:
Expand All @@ -1445,7 +1443,7 @@ def links(self, browse=None, format='guess'):
elif format == 'raw':
return FancyTuple(self._fields['H'])
elif format == 'html':
html(FancyTuple(map(url_absolute, self._fields['H'])))
return html(FancyTuple(map(url_absolute, self._fields['H'])))
elif format == 'url':
url_list = flatten([_urls(url_absolute(string)) for string in self._fields['H']])
return FancyTuple(url_list)
Expand Down

0 comments on commit 4e2e74f

Please sign in to comment.