class_docstr: Test both vector operations and MLlib algorithms with SciPy sparse matrices,
  if SciPy is available.
class_docstr_tok: ["Test","both","vector","operations","and","MLlib","algorithms","with","SciPy","sparse","matrices",",","if","SciPy","is","available","."]
code: def test_serialize(self):
      from scipy.sparse import lil_matrix
  
      ser = CPickleSerializer()
      lil = lil_matrix((4, 1))
      lil[1, 0] = 1
      lil[3, 0] = 2
      sv = SparseVector(4, {1: 1, 3: 2})
      self.assertEqual(sv, _convert_to_vector(lil))
      self.assertEqual(sv, _convert_to_vector(lil.tocsc()))
      self.assertEqual(sv, _convert_to_vector(lil.tocoo()))
      self.assertEqual(sv, _convert_to_vector(lil.tocsr()))
      self.assertEqual(sv, _convert_to_vector(lil.todok()))
  
      def serialize(d):
          return ser.loads(ser.dumps(_convert_to_vector(d)))
  
      self.assertEqual(sv, serialize(lil))
      self.assertEqual(sv, serialize(lil.tocsc()))
      self.assertEqual(sv, serialize(lil.tocsr()))
      self.assertEqual(sv, serialize(lil.todok()))
  
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 1 for calling the SciPyTests obj's underlying member method code with example usage: obj.test_serialize() and returns: ser