Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6342#discussion_r33807648
  
    --- Diff: python/pyspark/mllib/linalg.py ---
    @@ -952,6 +1001,84 @@ def __init__(self, numRows, numCols, colPtrs, 
rowIndices, values,
                 raise ValueError("Expected rowIndices of length %d, got %d."
                                  % (self.rowIndices.size, self.values.size))
     
    +    def __str__(self):
    +        """
    +        Pretty printing of a SparseMatrix
    +
    +        >>> sm1 = SparseMatrix(2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4])
    +        >>> print(sm1)
    +        2 X 2 CSCMatrix
    +        (0,0) 2.0
    +        (1,0) 3.0
    +        (1,1) 4.0
    +        >>> sm1 = SparseMatrix(2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4], True)
    +        >>> print(sm1)
    +        2 X 2 CSRMatrix
    +        (0,0) 2.0
    +        (0,1) 3.0
    +        (1,1) 4.0
    +        """
    +        spstr = "{0} X {1} ".format(self.numRows, self.numCols)
    +        if self.isTransposed:
    +            spstr += "CSRMatrix\n"
    +        else:
    +            spstr += "CSCMatrix\n"
    +
    +        cur_col = 0
    +        smlist = []
    +
    +        # Display first 5 values.
    --- End diff --
    
    Why 5 here but 6 in dense matrix? I think it should be okay to increate 
this value to 16 or 32.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to