Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions python/pyspark/ml/linalg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def _vector_size(v):
return len(v)
elif type(v) in (array.array, list, tuple, xrange):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this change is legitimate, we should change this to isinstance(v, (array.array, list, tuple, xrange))

return len(v)
elif type(v) == np.ndarray:
elif isinstance(v, np.ndarray):
if v.ndim == 1 or (v.ndim == 2 and v.shape[1] == 1):
return len(v)
else:
Expand Down Expand Up @@ -325,7 +325,7 @@ def dot(self, other):
...
AssertionError: dimension mismatch
"""
if type(other) == np.ndarray:
if isinstance(other, np.ndarray):
if other.ndim > 1:
assert len(self) == other.shape[0], "dimension mismatch"
return np.dot(self.array, other)
Expand Down Expand Up @@ -492,7 +492,7 @@ def __init__(self, size, *args):
assert 1 <= len(args) <= 2, "must pass either 2 or 3 arguments"
if len(args) == 1:
pairs = args[0]
if type(pairs) == dict:
if isinstance(pairs, dict):
pairs = pairs.items()
pairs = sorted(pairs)
self.indices = np.array([p[0] for p in pairs], dtype=np.int32)
Expand Down