Skip to content

Commit ea0a9da

Browse files
author
Matthias Koeppe
committed
Matrix.str: Add documentation and tests for top_border, ...
1 parent 9ced71d commit ea0a9da

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/sage/matrix/matrix0.pyx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,6 +1847,16 @@ cdef class Matrix(sage.structure.element.Matrix):
18471847
:class:`~sage.typeset.unicode_art.UnicodeArt` which support line
18481848
breaking of wide matrices that exceed the window width
18491849
1850+
- ``left_border``, ``right_border`` -- sequence (default: ``None``);
1851+
if not ``None``, call :func:`str` on the elements and use the
1852+
results as labels for the rows of the matrix. The labels appear
1853+
outside of the parentheses.
1854+
1855+
- ``top_border``, ``bottom_border`` -- sequence (default: ``None``);
1856+
if not ``None``, call :func:`str` on the elements and use the
1857+
results as labels for the columns of the matrix. The labels appear
1858+
outside of the parentheses.
1859+
18501860
EXAMPLES::
18511861
18521862
sage: R = PolynomialRing(QQ,6,'z')
@@ -1974,6 +1984,32 @@ cdef class Matrix(sage.structure.element.Matrix):
19741984
sage: matrix(R, [[2/3 - 10^6 * x^3 + 3 * y + O(x, y)^4]])
19751985
[2/3 + 3*y - 1000000*x^3 + O(x, y)^4]
19761986
sage: matrix.options._reset()
1987+
1988+
Edge cases of matrices with borders::
1989+
1990+
sage: print(matrix(ZZ, 0, 0).str(
1991+
....: top_border=[], bottom_border=[], left_border=[], right_border=[]))
1992+
[]
1993+
sage: print(matrix(ZZ, 0, 4).str(
1994+
....: unicode=True,
1995+
....: top_border='abcd', bottom_border=range(4)))
1996+
()
1997+
sage: print(matrix(ZZ, 1, 4).str(
1998+
....: unicode=True,
1999+
....: top_border='abcd', bottom_border=range(4)))
2000+
a b c d
2001+
(0 0 0 0)
2002+
0 1 2 3
2003+
sage: print(matrix(ZZ, 2, 4).str(
2004+
....: unicode=True,
2005+
....: top_border='abcd', bottom_border=range(4), left_border='uv'))
2006+
a b c d
2007+
u⎛0 0 0 0⎞
2008+
v⎝0 0 0 0⎠
2009+
0 1 2 3
2010+
sage: print(matrix(ZZ, 2, 0).str(
2011+
....: top_border='', left_border='uv', right_border=['*', '']))
2012+
[]
19772013
"""
19782014
cdef Py_ssize_t nr, nc, r, c
19792015
nr = self._nrows

0 commit comments

Comments
 (0)