diff options
author | Reynold Xin <rxin@apache.org> | 2014-05-25 17:15:01 -0700 |
---|---|---|
committer | Reynold Xin <rxin@apache.org> | 2014-05-25 17:15:01 -0700 |
commit | d33d3c61ae9e4551aed0217e525a109e678298f2 (patch) | |
tree | 109ffeeaf31ae267bbe791051fd39f490af04aa4 /python/pyspark/mllib/linalg.py | |
parent | 14f0358b2a0a9b92526bdad6d501ab753459eaa0 (diff) | |
download | spark-d33d3c61ae9e4551aed0217e525a109e678298f2.tar.gz spark-d33d3c61ae9e4551aed0217e525a109e678298f2.tar.bz2 spark-d33d3c61ae9e4551aed0217e525a109e678298f2.zip |
Fix PEP8 violations in Python mllib.
Author: Reynold Xin <rxin@apache.org>
Closes #871 from rxin/mllib-pep8 and squashes the following commits:
848416f [Reynold Xin] Fixed a typo in the previous cleanup (c -> sc).
a8db4cd [Reynold Xin] Fix PEP8 violations in Python mllib.
Diffstat (limited to 'python/pyspark/mllib/linalg.py')
-rw-r--r-- | python/pyspark/mllib/linalg.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/python/pyspark/mllib/linalg.py b/python/pyspark/mllib/linalg.py index 7511ca7573..2766842720 100644 --- a/python/pyspark/mllib/linalg.py +++ b/python/pyspark/mllib/linalg.py @@ -54,7 +54,7 @@ class SparseVector(object): if len(args) == 1: pairs = args[0] if type(pairs) == dict: - pairs = pairs.items() + 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) @@ -88,7 +88,7 @@ class SparseVector(object): result += self.values[i] * other[self.indices[i]] return result elif other.ndim == 2: - results = [self.dot(other[:,i]) for i in xrange(other.shape[1])] + results = [self.dot(other[:, i]) for i in xrange(other.shape[1])] return array(results) else: raise Exception("Cannot call dot with %d-dimensional array" % other.ndim) @@ -135,7 +135,7 @@ class SparseVector(object): return result else: raise Exception("Cannot call squared_distance with %d-dimensional array" % - other.ndim) + other.ndim) else: result = 0.0 i, j = 0, 0 @@ -184,15 +184,14 @@ class SparseVector(object): """ return (isinstance(other, self.__class__) - and other.size == self.size - and array_equal(other.indices, self.indices) - and array_equal(other.values, self.values)) + and other.size == self.size + and array_equal(other.indices, self.indices) + and array_equal(other.values, self.values)) def __ne__(self, other): return not self.__eq__(other) - class Vectors(object): """ Factory methods for working with vectors. Note that dense vectors |