code: def test_popular_excludes_rated():
      algo = basic.Popular()
      algo.fit(lktu.ml_test.ratings)
      counts = lktu.ml_test.ratings.groupby("item").user.count()
      counts = counts.nlargest(100)
  
      recs = algo.recommend(100, 100)
      assert len(recs) == 100
      assert all(np.diff(recs.score) <= 0)
  
      # make sure we didn't recommend anything the user likes
      ratings = lktu.ml_test.ratings
      urates = ratings.set_index(["user", "item"])
      urates = urates.loc[100, :]
      match = recs.join(urates, on="item", how="inner")
      assert len(match) == 0
  
file_path: lkpy/tests/test_popular.py
imports: from lenskit.algorithms import basic
  import pandas
  import numpy
  import pickle
  import lenskit.util.test
label_desc: Use image node_id 2 for calling a global function with example usage: test_popular_excludes_rated() without return types