holdenk commented on a change in pull request #17968: [SPARK-9792] Make
DenseMatrix equality semantical
URL: https://github.com/apache/spark/pull/17968#discussion_r263978351
##########
File path: python/pyspark/ml/linalg/__init__.py
##########
@@ -980,14 +980,14 @@ def __getitem__(self, indices):
return self.values[i + j * self.numRows]
def __eq__(self, other):
- if (not isinstance(other, DenseMatrix) or
- self.numRows != other.numRows or
- self.numCols != other.numCols):
+ if isinstance(other, SparseMatrix):
+ return np.all(self.toArray() == other.toArray())
+ if (self.numRows != other.numRows or self.numCols != other.numCols):
Review comment:
I think it would make sense to move this check above L983? We canm check the
number of rows and columns faster than converting a `SparseMatrix` to an array.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]