code: def test_partition_may_skip_train():
      """Partitioning when users may not have enough ratings to be in the train set and test set."""
      ratings = lktu.ml_test.ratings
      # make a data set where some users only have 1 rating
      ratings = ratings.sample(frac=0.1)
      users = ratings.groupby("user")["rating"].count()
      assert users.min() == 1.0  # we should have some small users!
      users.name = "ur_count"
  
      splits = xf.partition_users(ratings, 5, xf.SampleN(1))
      splits = list(splits)
      assert len(splits) == 5
  
      # now we go make sure we're missing some users! And don't have any NaN ratings
      for train, test in splits:
          # no null ratings
          assert all(train["rating"].notna())
          # see if test users with 1 rating are missing from train
          test = test.join(users, on="user")
          assert all(
              ~(
                  test.loc[test["ur_count"] == 1, "user"].isin(
                      train["user"].unique()
                  )
              )
          )
          # and users with more than one rating are in train
          assert all(
              test.loc[test["ur_count"] > 1, "user"].isin(
                  train["user"].unique()
              )
          )
  
imports: import itertools
  import functools
  import pytest
  import math
  import numpy
  import lenskit.util.test
  import lenskit.crossfold
label_desc: Use image node_id 11 for calling a global function with example usage: test_partition_may_skip_train() without return types