︠3c9fb3dd-6623-4180-8df5-6ff3d9f00878︠
table?
︡565ab439-0775-4f31-8689-bffa4d5ec706︡{"code":{"source":"File: /usr/local/sage/sage-6.4/local/lib/python2.7/site-packages/sage/misc/table.py\nUnable to read docstring (source code not available)","mode":"text/x-rst","lineno":-1,"filename":null}}︡
︠aab539ea-c072-4807-acd2-ac5da3289cc4︠
table(columns=[(x,n(sin(x), digits=2)) for x in [0..3]], header_column=['$x$', '$\sin(x)$'], frame=True)
︡28fd7b9e-b397-4ca8-86f5-b230d8f0c707︡{"stdout":"+-----------++------+------+------+------+\n| $x$ || 0 | 1 | 2 | 3 |\n+-----------++------+------+------+------+\n| $\\sin(x)$ || 0.00 | 0.84 | 0.91 | 0.14 |\n+-----------++------+------+------+------+\n"}︡
︠7c0b238a-766f-4788-b16b-7c2c6a4f6cb2︠
help(table)
︡35a0f2ba-022c-42b7-b9f2-81c341281909︡{"stdout":"Help on class table in module sage.misc.table:\n\nclass table(sage.structure.sage_object.SageObject)\n | Display a rectangular array as a table, either in plain text, LaTeX,\n | or html.\n | \n | INPUTS:\n | \n | - ``rows`` (default ``None``) - a list of lists (or list of tuples,\n | etc.), containing the data to be displayed.\n | - ``columns`` (default ``None``) - a list of lists (etc.), containing\n | the data to be displayed, but stored as columns. Set either ``rows``\n | or ``columns``, but not both.\n | - ``header_row`` (default ``False``) - if ``True``, first row is\n | highlighted.\n | - ``header_column`` (default ``False``) - if ``True``, first column is\n | highlighted.\n | - ``frame`` (default ``False``) - if ``True``, put a box around each\n | cell.\n | - ``align`` (default 'left') - the alignment of each entry: either\n | 'left', 'center', or 'right'\n | \n | EXAMPLES::\n | \n | sage: rows = [['a', 'b', 'c'], [100,2,3], [4,5,60]]\n | sage: table(rows)\n | a b c\n | 100 2 3\n | 4 5 60\n | sage: latex(table(rows))\n | \\begin{tabular}{lll}\n | a & b & c \\\\\n | $100$ & $2$ & $3$ \\\\\n | $4$ & $5$ & $60$ \\\\\n | \\end{tabular}\n | \n | If ``header_row`` is ``True``, then the first row is highlighted. If\n | ``header_column`` is ``True``, then the first column is\n | highlighted. If ``frame`` is ``True``, then print a box around every\n | \"cell\". ::\n | \n | sage: table(rows, header_row=True)\n | a b c\n | +-----+---+----+\n | 100 2 3\n | 4 5 60\n | sage: latex(table(rows, header_row=True))\n | \\begin{tabular}{lll}\n | a & b & c \\\\ \\hline\n | $100$ & $2$ & $3$ \\\\\n | $4$ & $5$ & $60$ \\\\\n | \\end{tabular}\n | sage: table(rows=rows, frame=True)\n | +-----+---+----+\n | | a | b | c |\n | +-----+---+----+\n | | 100 | 2 | 3 |\n | +-----+---+----+\n | | 4 | 5 | 60 |\n | +-----+---+----+\n | sage: latex(table(rows=rows, frame=True))\n | \\begin{tabular}{|l|l|l|} \\hline\n | a & b & c \\\\ \\hline\n | $100$ & $2$ & $3$ \\\\ \\hline\n | $4$ & $5$ & $60$ \\\\ \\hline\n | \\end{tabular}\n | sage: table(rows, header_column=True, frame=True)\n | +-----++---+----+\n | | a || b | c |\n | +-----++---+----+\n | | 100 || 2 | 3 |\n | +-----++---+----+\n | | 4 || 5 | 60 |\n | +-----++---+----+\n | sage: latex(table(rows, header_row=True, frame=True))\n | \\begin{tabular}{|l|l|l|} \\hline\n | a & b & c \\\\ \\hline \\hline\n | $100$ & $2$ & $3$ \\\\ \\hline\n | $4$ & $5$ & $60$ \\\\ \\hline\n | \\end{tabular}\n | sage: table(rows, header_column=True)\n | a | b c\n | 100 | 2 3\n | 4 | 5 60\n | \n | The argument ``header_row`` can, instead of being ``True`` or\n | ``False``, be the contents of the header row, so that ``rows``\n | consists of the data, while ``header_row`` is the header\n | information. The same goes for ``header_column``. Passing lists\n | for both arguments simultaneously is not supported. ::\n | \n | sage: table([(x,n(sin(x), digits=2)) for x in [0..3]], header_row=[\"$x$\", \"$\\sin(x)$\"], frame=True)\n | +-----+-----------+\n | | $x$ | $\\sin(x)$ |\n | +=====+===========+\n | | 0 | 0.00 |\n | +-----+-----------+\n | | 1 | 0.84 |\n | +-----+-----------+\n | | 2 | 0.91 |\n | +-----+-----------+\n | | 3 | 0.14 |\n | +-----+-----------+\n | \n | You can create the transpose of this table in several ways, for\n | example, \"by hand,\" that is, changing the data defining the table::\n | \n | sage: table(rows=[[x for x in [0..3]], [n(sin(x), digits=2) for x in [0..3]]], header_column=['$x$', '$\\sin(x)$'], frame=True)\n | +-----------++------+------+------+------+\n | | $x$ || 0 | 1 | 2 | 3 |\n | +-----------++------+------+------+------+\n | | $\\sin(x)$ || 0.00 | 0.84 | 0.91 | 0.14 |\n | +-----------++------+------+------+------+\n | \n | or by passing the original data as the ``columns`` of the table\n | and using ``header_column`` instead of ``header_row``::\n | \n | sage: table(columns=[(x,n(sin(x), digits=2)) for x in [0..3]], header_column=['$x$', '$\\sin(x)$'], frame=True)\n | +-----------++------+------+------+------+\n | | $x$ || 0 | 1 | 2 | 3 |\n | +-----------++------+------+------+------+\n | | $\\sin(x)$ || 0.00 | 0.84 | 0.91 | 0.14 |\n | +-----------++------+------+------+------+\n | \n | or by taking the :meth:`transpose` of the original table::\n | \n | sage: table(rows=[(x,n(sin(x), digits=2)) for x in [0..3]], header_row=['$x$', '$\\sin(x)$'], frame=True).transpose()\n | +-----------++------+------+------+------+\n | | $x$ || 0 | 1 | 2 | 3 |\n | +-----------++------+------+------+------+\n | | $\\sin(x)$ || 0.00 | 0.84 | 0.91 | 0.14 |\n | +-----------++------+------+------+------+\n | \n | In either plain text or LaTeX, entries in tables can be aligned to the\n | left (default), center, or right::\n | \n | sage: table(rows, align='left')\n | a b c\n | 100 2 3\n | 4 5 60\n | sage: table(rows, align='center')\n | a b c\n | 100 2 3\n | 4 5 60\n | sage: table(rows, align='right', frame=True)\n | +-----+---+----+\n | | a | b | c |\n | +-----+---+----+\n | | 100 | 2 | 3 |\n | +-----+---+----+\n | | 4 | 5 | 60 |\n | +-----+---+----+\n | \n | To print HTML, use either ``table(...)._html_()`` or ``html(table(...))``::\n | \n | sage: html(table([[\"$x$\", \"$\\sin(x)$\"]] + [(x,n(sin(x), digits=2)) for x in [0..3]], header_row=True, frame=True))\n | \n |
\n | \n | \n | It is an error to specify both ``rows`` and ``columns``::\n | \n | sage: table(rows=[[1,2,3], [4,5,6]], columns=[[0,0,0], [0,0,1024]])\n | Traceback (most recent call last):\n | ...\n | ValueError: Don't set both 'rows' and 'columns' when defining a table.\n | \n | sage: table(columns=[[0,0,0], [0,0,1024]])\n | 0 0\n | 0 0\n | 0 1024\n | \n | Note that if ``rows`` is just a list or tuple, not nested, then\n | it is treated as a single row::\n | \n | sage: table([1,2,3])\n | 1 2 3\n | \n | Also, if you pass a non-rectangular array, the longer rows or\n | columns get truncated::\n | \n | sage: table([[1,2,3,7,12], [4,5]])\n | 1 2\n | 4 5\n | sage: table(columns=[[1,2,3], [4,5,6,7]])\n | 1 4\n | 2 5\n | 3 6\n | \n | TESTS::\n | \n | sage: TestSuite(table([[\"$x$\", \"$\\sin(x)$\"]] + [(x,n(sin(x), digits=2)) for x in [0..3]], header_row=True, frame=True)).run()\n | \n | Method resolution order:\n | table\n | sage.structure.sage_object.SageObject\n | __builtin__.object\n | \n | Methods defined here:\n | \n | __eq__(self, other)\n | Two tables are equal if and only if their data rowss and\n | their options are the same.\n | \n | EXAMPLES::\n | \n | sage: rows = [['a', 'b', 'c'], [1,plot(sin(x)),3], [4,5,identity_matrix(2)]]\n | sage: T = table(rows, header_row=True)\n | sage: T2 = table(rows, header_row=True)\n | sage: T is T2\n | False\n | sage: T == T2\n | True\n | sage: T2.options(frame=True)\n | sage: T == T2\n | False\n | \n | __init__(self, rows=None, columns=None, header_row=False, header_column=False, frame=False, align='left')\n | EXAMPLES::\n | \n | sage: table([1,2,3], frame=True)\n | +---+---+---+\n | | 1 | 2 | 3 |\n | +---+---+---+\n | \n | options(self, **kwds)\n | With no arguments, return the dictionary of options for this\n | table. With arguments, modify options.\n | \n | INPUTS:\n | \n | - ``header_row`` - if True, first row is highlighted.\n | - ``header_column`` - if True, first column is highlighted.\n | - ``frame`` - if True, put a box around each cell.\n | - ``align`` - the alignment of each entry: either 'left',\n | 'center', or 'right'\n | \n | EXAMPLES::\n | \n | sage: T = table([['a', 'b', 'c'], [1,2,3]])\n | sage: T.options()['align'], T.options()['frame']\n | ('left', False)\n | sage: T.options(align='right', frame=True)\n | sage: T.options()['align'], T.options()['frame']\n | ('right', True)\n | \n | Note that when first initializing a table, ``header_row`` or\n | ``header_column`` can be a list. In this case, during the\n | initialization process, the header is merged with the rest of\n | the data, so changing the header option later using\n | ``table.options(...)`` doesn't affect the contents of the\n | table, just whether the row or column is highlighed. When\n | using this :meth:`options` method, no merging of data occurs,\n | so here ``header_row`` and ``header_column`` should just be\n | ``True`` or ``False``, not a list. ::\n | \n | sage: T = table([[1,2,3], [4,5,6]], header_row=['a', 'b', 'c'], frame=True)\n | sage: T\n | +---+---+---+\n | | a | b | c |\n | +===+===+===+\n | | 1 | 2 | 3 |\n | +---+---+---+\n | | 4 | 5 | 6 |\n | +---+---+---+\n | sage: T.options(header_row=False)\n | sage: T\n | +---+---+---+\n | | a | b | c |\n | +---+---+---+\n | | 1 | 2 | 3 |\n | +---+---+---+\n | | 4 | 5 | 6 |\n | +---+---+---+\n | \n | If you do specify a list for ``header_row``, an error is raised::\n | \n | sage: T.options(header_row=['x', 'y', 'z'])\n | Traceback (most recent call last):\n | ...\n | TypeError: header_row should be either True or False.\n | \n | transpose(self)\n | Return a table which is the transpose of this one:\n | rows and columns have been interchanged. Several of the\n | properties of the original table are preserved: whether a\n | frame is present and any alignment setting. On the other hand,\n | header rows are converted to header columns, and vice versa.\n | \n | EXAMPLES::\n | \n | sage: T = table([[1,2,3], [4,5,6]])\n | sage: T.transpose()\n | 1 4\n | 2 5\n | 3 6\n | sage: T = table([[1,2,3], [4,5,6]], header_row=['x', 'y', 'z'], frame=True)\n | sage: T.transpose()\n | +---++---+---+\n | | x || 1 | 4 |\n | +---++---+---+\n | | y || 2 | 5 |\n | +---++---+---+\n | | z || 3 | 6 |\n | +---++---+---+\n | \n | ----------------------------------------------------------------------\n | Data descriptors defined here:\n | \n | __dict__\n | dictionary for instance variables (if defined)\n | \n | __weakref__\n | list of weak references to the object (if defined)\n | \n | ----------------------------------------------------------------------\n | Methods inherited from sage.structure.sage_object.SageObject:\n | \n | __hash__(...)\n | File: sage/structure/sage_object.pyx (starting at line 227)\n | \n | __repr__(...)\n | File: sage/structure/sage_object.pyx (starting at line 121)\n | \n | Default method for string representation.\n | \n | .. NOTE::\n | \n | Do not overwrite this method. Instead, implement\n | a ``_repr_`` (single underscore) method.\n | \n | EXAMPLES:\n | \n | By default, the string representation coincides with\n | the output of the single underscore ``_repr_``::\n | \n | sage: P. = QQ[]\n | sage: repr(P) == P._repr_() #indirect doctest\n | True\n | \n | Using :meth:`rename`, the string representation can\n | be customized::\n | \n | sage: P.rename('A polynomial ring')\n | sage: repr(P) == P._repr_()\n | False\n | \n | The original behaviour is restored with :meth:`reset_name`.::\n | \n | sage: P.reset_name()\n | sage: repr(P) == P._repr_()\n | True\n | \n | category(...)\n | File: sage/structure/sage_object.pyx (starting at line 397)\n | \n | db(...)\n | File: sage/structure/sage_object.pyx (starting at line 368)\n | \n | Dumps self into the Sage database. Use db(name) by itself to\n | reload.\n | \n | The database directory is ``$HOME/.sage/db``\n | \n | dump(...)\n | File: sage/structure/sage_object.pyx (starting at line 340)\n | \n | Same as self.save(filename, compress)\n | \n | dumps(...)\n | File: sage/structure/sage_object.pyx (starting at line 346)\n | \n | Dump ``self`` to a string ``s``, which can later be reconstituted\n | as ``self`` using ``loads(s)``.\n | \n | There is an optional boolean argument ``compress`` which defaults to ``True``.\n | \n | EXAMPLES::\n | \n | sage: O=SageObject(); O.dumps()\n | 'x\\x9ck`J.NLO\\xd5+.)*M.)-\\x02\\xb2\\x80\\xdc\\xf8\\xfc\\xa4\\xac\\xd4\\xe4\\x12\\xae` \\xdb\\x1f\\xc2,d\\xd4l,d\\xd2\\x03\\x00\\xb7X\\x10\\xf1'\n | sage: O.dumps(compress=False)\n | '\\x80\\x02csage.structure.sage_object\\nSageObject\\nq\\x01)\\x81q\\x02.'\n | \n | rename(...)\n | File: sage/structure/sage_object.pyx (starting at line 44)\n | \n | Change self so it prints as x, where x is a string.\n | \n | .. NOTE::\n | \n | This is *only* supported for Python classes that derive\n | from SageObject.\n | \n | EXAMPLES::\n | \n | sage: x = PolynomialRing(QQ, 'x', sparse=True).gen()\n | sage: g = x^3 + x - 5\n | sage: g\n | x^3 + x - 5\n | sage: g.rename('a polynomial')\n | sage: g\n | a polynomial\n | sage: g + x\n | x^3 + 2*x - 5\n | sage: h = g^100\n | sage: str(h)[:20]\n | 'x^300 + 100*x^298 - '\n | sage: h.rename('x^300 + ...')\n | sage: h\n | x^300 + ...\n | \n | Real numbers are not Python classes, so rename is not supported::\n | \n | sage: a = 3.14\n | sage: type(a)\n | \n | sage: a.rename('pi')\n | Traceback (most recent call last):\n | ...\n | NotImplementedError: object does not support renaming: 3.14000000000000\n | \n | .. NOTE::\n | \n | The reason C-extension types are not supported by default\n | is if they were then every single one would have to carry\n | around an extra attribute, which would be slower and waste\n | a lot of memory.\n | \n | To support them for a specific class, add a\n | ``cdef public __custom_name`` attribute.\n | \n | reset_name(...)\n | File: sage/structure/sage_object.pyx (starting at line 101)\n | \n | Remove the custrom name of an object.\n | \n | EXAMPLES::\n | \n | sage: P. = QQ[]\n | sage: P\n | Univariate Polynomial Ring in x over Rational Field\n | sage: P.rename('A polynomial ring')\n | sage: P\n | A polynomial ring\n | sage: P.reset_name()\n | sage: P\n | Univariate Polynomial Ring in x over Rational Field\n | \n | save(...)\n | File: sage/structure/sage_object.pyx (starting at line 317)\n | \n | Save self to the given filename.\n | \n | EXAMPLES::\n | \n | sage: f = x^3 + 5\n | sage: f.save(os.path.join(SAGE_TMP, 'file'))\n | sage: load(os.path.join(SAGE_TMP, 'file.sobj'))\n | x^3 + 5\n | \n | version(...)\n | File: sage/structure/sage_object.pyx (starting at line 300)\n | \n | The version of Sage.\n | \n | Call this to save the version of Sage in this object.\n | If you then save and load this object it will know in what\n | version of Sage it was created.\n | \n | This only works on Python classes that derive from SageObject.\n | \n | ----------------------------------------------------------------------\n | Data and other attributes inherited from sage.structure.sage_object.SageObject:\n | \n | __new__ = \n | T.__new__(S, ...) -> a new object with type S, a subtype of T\n"}︡{"stdout":"\n"}︡
︠a91091f4-481e-4253-8781-da8066201646︠