def test_elementwise_rdd(self):
     mat1 = RowMatrix(
         self.sc.parallelize([(1, array([1, 2, 3])), (2, array([4, 5, 6]))],
                             2))
     mat2 = RowMatrix(
         self.sc.parallelize([(1, array([7, 8, 9])),
                              (2, array([10, 11, 12]))], 2))
     result = mat1.elementwise(mat2, add).rows().collect()
     truth = array([[8, 10, 12], [14, 16, 18]])
     assert array_equal(result, truth)
示例#2
0
 def test_elementwise_array(self):
     mat = RowMatrix(self.sc.parallelize([(1, array([1, 2, 3]))]))
     assert array_equal(mat.elementwise(2, add).rows().collect()[0], array([3, 4, 5]))
示例#3
0
 def test_elementwise_rdd(self):
     mat1 = RowMatrix(self.sc.parallelize([(1, array([1, 2, 3])), (2, array([4, 5, 6]))], 2))
     mat2 = RowMatrix(self.sc.parallelize([(1, array([7, 8, 9])), (2, array([10, 11, 12]))], 2))
     result = mat1.elementwise(mat2, add).rows().collect()
     truth = array([[8, 10, 12], [14, 16, 18]])
     assert array_equal(result, truth)
 def test_elementwise_array(self):
     mat = RowMatrix(self.sc.parallelize([(1, array([1, 2, 3]))]))
     assert array_equal(
         mat.elementwise(2, add).rows().collect()[0], array([3, 4, 5]))