Ticket #10974: trac_10974_stack-augment.reviewer-v2.patch

File trac_10974_stack-augment.reviewer-v2.patch, 7.1 KB (added by rbeezer, 8 years ago)
  • sage/matrix/matrix1.pyx

    # HG changeset patch
    # Parent e6342acc32daf541a4670ee1f4539c3e2a28a21a
    # User Keshav Kini <kini@member.ams.org>
    # Date 1300759270 25200
    10974: minor formatting for matrix augment and stack
    
    diff --git a/sage/matrix/matrix1.pyx b/sage/matrix/matrix1.pyx
    a b  
    981981        return V(tmp, coerce=False, copy=False, check=False)
    982982
    983983
    984     ############################################################################################
     984    ###########################################################################
    985985    # Building matrices out of other matrices, rows, or columns
    986     ############################################################################################
     986    ###########################################################################
    987987    def stack(self, bottom, subdivide=False):
    988988        r"""
    989989        Returns a new matrix formed by appending the matrix
     
    11851185        if hasattr(bottom, '_vector_'):
    11861186            bottom = bottom.row()
    11871187        if not isinstance(bottom, sage.matrix.matrix1.Matrix):
    1188             raise TypeError('a matrix must be stacked with another matrix, or a vector')
     1188            raise TypeError('a matrix must be stacked with another matrix, or '
     1189                'a vector')
    11891190
    11901191        cdef Matrix other
    11911192        other = bottom
    11921193
    11931194        if self._ncols != other._ncols:
    1194             raise TypeError('number of columns must be the same, {0} != {1}'.format(self._ncols, other._ncols))
     1195            raise TypeError('number of columns must be the same, '
     1196                '{0} != {1}'.format(self._ncols, other._ncols))
    11951197        if not (self._base_ring is other.base_ring()):
    11961198            other = other.change_ring(self._base_ring)
    11971199
     
    12151217
    12161218    def augment(self, right, subdivide=False):
    12171219        r"""
    1218         Returns a new matrix formed by appending the matrix
    1219         (or vector) ``right`` on the right side of ``self``.
     1220        Returns a new matrix formed by appending the matrix (or vector)
     1221        ``right`` on the right side of ``self``.
    12201222
    12211223        INPUT:
    12221224
     
    12241226          dimensions are compatible with ``self``.
    12251227
    12261228        - ``subdivide`` - default: ``False`` - request the resulting
    1227           matrix to have a new subdivision, separating ``self`` from ``right``.
     1229          matrix to have a new subdivision, separating ``self`` from
     1230          ``right``.
    12281231
    12291232        OUTPUT:
    12301233
    1231         A new matrix formed by appending ``right`` onto the right side of ``self``.
    1232         If ``right`` is a vector (or free module element) then in this context
    1233         it is appropriate to consider it as a column vector.  (The code first
    1234         converts a vector to a 1-column matrix.)
     1234        A new matrix formed by appending ``right`` onto the right side
     1235        of ``self``.  If ``right`` is a vector (or free module element)
     1236        then in this context it is appropriate to consider it as a
     1237        column vector.  (The code first converts a vector to a 1-column
     1238        matrix.)
    12351239
    12361240        If ``subdivide`` is ``True`` then any column subdivisions for
    12371241        the two matrices are preserved, and a new subdivision is added
    12381242        between ``self`` and ``right``.  If the row divisions are
    1239         identical, then they are preserved, otherwise they are discarded.
    1240         When ``subdivide`` is ``False`` there is no subdivision information
    1241         in the result.
     1243        identical, then they are preserved, otherwise they are
     1244        discarded.  When ``subdivide`` is ``False`` there is no
     1245        subdivision information in the result.
    12421246
    12431247        .. warning::
    12441248            If ``subdivide`` is ``True`` then unequal row subdivisions
    1245             will be discarded, since it would be ambiguous how to interpret
    1246             them.  If the subdivision behavior is not what you need,
    1247             you can manage subdivisions yourself with methods like
    1248             :meth:`~sage.matrix.matrix2.Matrix.get_subdivisions`
    1249             and
    1250             :meth:`~sage.matrix.matrix2.Matrix.subdivide`.
    1251             You might also find :func:`~sage.matrix.constructor.block_matrix`
    1252             or
     1249            will be discarded, since it would be ambiguous how to
     1250            interpret them.  If the subdivision behavior is not what you
     1251            need, you can manage subdivisions yourself with methods like
     1252            :meth:`~sage.matrix.matrix2.Matrix.get_subdivisions` and
     1253            :meth:`~sage.matrix.matrix2.Matrix.subdivide`.  You might
     1254            also find :func:`~sage.matrix.constructor.block_matrix` or
    12531255            :func:`~sage.matrix.constructor.block_diagonal_matrix`
    12541256            useful and simpler in some instances.
    12551257
     
    13111313            [2|3|3 4|5]
    13121314            [4|5|6 7|8]
    13131315
    1314         Row subdivisions can be preserved, but only if they are identical.
    1315         Otherwise, this information is discarded and must be managed
    1316         separately. ::
     1316        Row subdivisions can be preserved, but only if they are
     1317        identical.  Otherwise, this information is discarded and must be
     1318        managed separately. ::
    13171319
    13181320            sage: A = matrix(QQ, 3, range(6))
    13191321            sage: A.subdivide([1,3], None)
     
    13321334            [2 3|3 4 5]
    13331335            [4 5|6 7 8]
    13341336
    1335         The result retains the base ring of ``self`` by coercing
    1336         the elements of ``right`` into the base ring of ``self``. ::
     1337        The result retains the base ring of ``self`` by coercing the
     1338        elements of ``right`` into the base ring of ``self``. ::
    13371339
    13381340            sage: A = matrix(QQ, 2, [1,2])
    13391341            sage: B = matrix(RR, 2, [sin(1.1), sin(2.2)])
     
    13491351            sage: D.parent()
    13501352            Full MatrixSpace of 2 by 2 dense matrices over Real Field with 53 bits of precision
    13511353
    1352         Sometimes it is not possible to coerce into the base ring
    1353         of ``self``.  A solution is to change the base ring of ``self``
    1354         to a more expansive ring.  Here we mix the rationals with
    1355         a ring of polynomials with rational coefficients.  ::
     1354        Sometimes it is not possible to coerce into the base ring of
     1355        ``self``.  A solution is to change the base ring of ``self`` to
     1356        a more expansive ring.  Here we mix the rationals with a ring of
     1357        polynomials with rational coefficients.  ::
    13561358
    13571359            sage: R = PolynomialRing(QQ, 'y')
    13581360            sage: A = matrix(QQ, 1, [1,2])
     
    13841386        if hasattr(right, '_vector_'):
    13851387            right = right.column()
    13861388        if not isinstance(right, sage.matrix.matrix1.Matrix):
    1387             raise TypeError("a matrix must be augmented with another matrix, or a vector")
     1389            raise TypeError("a matrix must be augmented with another matrix, "
     1390                "or a vector")
    13881391
    13891392        cdef Matrix other
    13901393        other = right
    13911394
    13921395        if self._nrows != other._nrows:
    1393             raise TypeError('number of rows must be the same, {0} != {1}'.format(self._nrows, other._nrows))
     1396            raise TypeError('number of rows must be the same, '
     1397                '{0} != {1}'.format(self._nrows, other._nrows))
    13941398        if not (self._base_ring is other.base_ring()):
    13951399            other = other.change_ring(self._base_ring)
    13961400