code: def test_df_to_sparse(python_dataset):
      # initialize the splitter
      header = {
          "col_user": DEFAULT_USER_COL,
          "col_item": DEFAULT_ITEM_COL,
          "col_rating": DEFAULT_RATING_COL,
      }
  
      # instantiate the affinity matrix
      am = AffinityMatrix(df=python_dataset, **header)
  
      # obtain the sparse matrix representation of the input dataframe
      X, _, _ = am.gen_affinity_matrix()
  
      # check that the generated matrix has the correct dimensions
      assert (X.shape[0] == python_dataset.userID.unique().shape[0]) & (
          X.shape[1] == python_dataset.itemID.unique().shape[0]
      )
  
file_path: recommenders/tests/unit/recommenders/datasets/test_sparse.py
imports: import pandas
  import numpy
  import pytest
  from recommenders.datasets.sparse import AffinityMatrix
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL, DEFAULT_TIMESTAMP_COL
label_desc: Use image node_id 3 for calling a global function with example usage: test_df_to_sparse(python_dataset) without return types