code: def test_stratified_split(self, n_strata=2):
      stra_eval_method = PropensityStratifiedEvaluation(
          data=self.ml_100k,
          n_strata=n_strata,
          rating_threshold=4.0,
          verbose=True,
      )
      strata = [f"Q{idx+1}" for idx in range(n_strata)]
      # total number of ratings in the test set should be split
      # within different strata
      num_ratings = 0
      for stratum in strata:
          if stratum in stra_eval_method.stratified_sets.keys():
              num_ratings += stra_eval_method.stratified_sets[
                  stratum
              ].num_ratings
      self.assertEqual(
          num_ratings, stra_eval_method.test_set.num_ratings
      )
  
      # the number of sampled user/items in each stratum should be lower than
      # the total number of users/items in the test set
      total_users = len(stra_eval_method.test_set.uid_map)
      total_items = len(stra_eval_method.test_set.iid_map)
      for stratum in strata:
          if stratum in stra_eval_method.stratified_sets.keys():
              strata_num_users = len(
                  stra_eval_method.stratified_sets[stratum].uid_map
              )
              self.assertTrue(strata_num_users <= total_users)
              strata_num_items = len(
                  stra_eval_method.stratified_sets[stratum].iid_map
              )
              self.assertTrue(strata_num_items <= total_items)
  
file_path: cornac/tests/cornac/eval_methods/test_propensity_stratified_evaluation.py
imports: import unittest
  import numpy
  import cornac
  from cornac.data import Reader
  from cornac.eval_methods import PropensityStratifiedEvaluation
  from cornac.models import MF
  from cornac.metrics import MAE, AUC
label_desc: Use image node_id 2 for calling the TestPropensityStratifiedEvaluation obj's underlying member method code with example usage: obj.test_stratified_split(n_strata) without return types