code: def test_ml_mllib_matrix_conversion(self):
      # to ml
      # dense
      mllibDM = Matrices.dense(2, 2, [0, 1, 2, 3])
      mlDM1 = newlinalg.Matrices.dense(2, 2, [0, 1, 2, 3])
      mlDM2 = mllibDM.asML()
      self.assertEqual(mlDM2, mlDM1)
      # transposed
      mllibDMt = DenseMatrix(2, 2, [0, 1, 2, 3], True)
      mlDMt1 = newlinalg.DenseMatrix(2, 2, [0, 1, 2, 3], True)
      mlDMt2 = mllibDMt.asML()
      self.assertEqual(mlDMt2, mlDMt1)
      # sparse
      mllibSM = Matrices.sparse(2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4])
      mlSM1 = newlinalg.Matrices.sparse(
          2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4]
      )
      mlSM2 = mllibSM.asML()
      self.assertEqual(mlSM2, mlSM1)
      # transposed
      mllibSMt = SparseMatrix(
          2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4], True
      )
      mlSMt1 = newlinalg.SparseMatrix(
          2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4], True
      )
      mlSMt2 = mllibSMt.asML()
      self.assertEqual(mlSMt2, mlSMt1)
      # from ml
      # dense
      mllibDM1 = Matrices.dense(2, 2, [1, 2, 3, 4])
      mlDM = newlinalg.Matrices.dense(2, 2, [1, 2, 3, 4])
      mllibDM2 = Matrices.fromML(mlDM)
      self.assertEqual(mllibDM1, mllibDM2)
      # transposed
      mllibDMt1 = DenseMatrix(2, 2, [1, 2, 3, 4], True)
      mlDMt = newlinalg.DenseMatrix(2, 2, [1, 2, 3, 4], True)
      mllibDMt2 = Matrices.fromML(mlDMt)
      self.assertEqual(mllibDMt1, mllibDMt2)
      # sparse
      mllibSM1 = Matrices.sparse(2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4])
      mlSM = newlinalg.Matrices.sparse(
          2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4]
      )
      mllibSM2 = Matrices.fromML(mlSM)
      self.assertEqual(mllibSM1, mllibSM2)
      # transposed
      mllibSMt1 = SparseMatrix(
          2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4], True
      )
      mlSMt = newlinalg.SparseMatrix(
          2, 2, [0, 2, 3], [0, 1, 1], [2, 3, 4], True
      )
      mllibSMt2 = Matrices.fromML(mlSMt)
      self.assertEqual(mllibSMt1, mllibSMt2)
  
imports: import array
  import unittest
  from numpy import array, array_equal, zeros, arange, tile, ones, inf
  import pyspark.ml.linalg
  from pyspark.serializers import CPickleSerializer
  from pyspark.mllib.linalg import Vector, SparseVector, DenseVector, VectorUDT, _convert_to_vector, DenseMatrix, SparseMatrix, Vectors, Matrices, MatrixUDT
  from pyspark.mllib.linalg.distributed import RowMatrix, IndexedRowMatrix, IndexedRow
  from pyspark.mllib.regression import LabeledPoint
  from pyspark.sql import Row
  from pyspark.testing.mllibutils import MLlibTestCase
  from pyspark.testing.utils import have_scipy
label_desc: Use image node_id 19 for calling the VectorTests obj's underlying member method code with example usage: obj.test_ml_mllib_matrix_conversion() without return types