code: def test_int_numpy_stratified_splitter(
      test_specs, python_int_dataset
  ):
      # generate a syntetic dataset
      X = python_int_dataset
  
      # the splitter returns (in order): train and test user/affinity matrices, train and test datafarmes and user/items to matrix maps
      Xtr, Xtst = numpy_stratified_split(
          X, ratio=test_specs["ratio"], seed=test_specs["seed"]
      )
  
      # check that the generated matrices have the correct dimensions
      assert (Xtr.shape[0] == X.shape[0]) & (Xtr.shape[1] == X.shape[1])
      assert (Xtst.shape[0] == X.shape[0]) & (
          Xtst.shape[1] == X.shape[1]
      )
  
      X_rated = np.sum(
          X != 0, axis=1
      )  # number of total rated items per user
      Xtr_rated = np.sum(
          Xtr != 0, axis=1
      )  # number of rated items in the train set
      Xtst_rated = np.sum(
          Xtst != 0, axis=1
      )  # number of rated items in the test set
  
      # global split: check that the all dataset is split in the correct ratio
      assert Xtr_rated.sum() / (X_rated.sum()) == pytest.approx(
          test_specs["ratio"], test_specs["tolerance"]
      )
  
      assert Xtst_rated.sum() / (X_rated.sum()) == pytest.approx(
          1 - test_specs["ratio"], test_specs["tolerance"]
      )
  
      # This implementation of the stratified splitter performs a random split at the single user level. Here we check
      # that also this more stringent condition is verified. Note that user to user fluctuations in the split ratio
      # are stronger than for the entire dataset due to the random nature of the per user splitting.
      # For this reason we allow a slightly bigger tolerance, as specified in the test_specs()
  
      assert (
          Xtr_rated / X_rated
          <= test_specs["ratio"] + test_specs["fluctuation"]
      ).all() & (
          Xtr_rated / X_rated
          >= test_specs["ratio"] - test_specs["fluctuation"]
      ).all()
  
      assert (
          Xtst_rated / X_rated
          <= (1 - test_specs["ratio"]) + test_specs["fluctuation"]
      ).all() & (
          Xtst_rated / X_rated
          >= (1 - test_specs["ratio"]) - test_specs["fluctuation"]
      ).all()
  
file_path: recommenders/tests/unit/recommenders/datasets/test_python_splitter.py
imports: import pytest
  import pandas
  import numpy
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL, DEFAULT_TIMESTAMP_COL
  from recommenders.datasets.split_utils import min_rating_filter_pandas, split_pandas_data_with_ratios
  from recommenders.datasets.python_splitters import python_chrono_split, python_random_split, python_stratified_split, numpy_stratified_split
label_desc: Use image node_id 10 for calling a global function with example usage: test_int_numpy_stratified_splitter(test_specs, python_int_dataset) without return types