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

    https://github.com/apache/spark/pull/2378#discussion_r17701626
  
    --- Diff: python/pyspark/mllib/linalg.py ---
    @@ -61,16 +195,19 @@ def __init__(self, size, *args):
                 if type(pairs) == dict:
                     pairs = pairs.items()
                 pairs = sorted(pairs)
    -            self.indices = array([p[0] for p in pairs], dtype=int32)
    -            self.values = array([p[1] for p in pairs], dtype=float64)
    +            self.indices = array.array('i', [p[0] for p in pairs])
    +            self.values = array.array('d', [p[1] for p in pairs])
             else:
                 assert len(args[0]) == len(args[1]), "index and value arrays 
not same length"
    -            self.indices = array(args[0], dtype=int32)
    -            self.values = array(args[1], dtype=float64)
    +            self.indices = array.array('i', args[0])
    +            self.values = array.array('d', args[1])
                 for i in xrange(len(self.indices) - 1):
                     if self.indices[i] >= self.indices[i + 1]:
                         raise TypeError("indices array must be sorted")
     
    +    def __reduce__(self):
    +        return (SparseVector, (self.size, self.indices, self.values))
    +
         def dot(self, other):
             """
             Dot product with a SparseVector or 1- or 2-dimensional Numpy array.
    --- End diff --
    
    Update doc to say dot product with each column if given a 2-d array?


---
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