code: def test_topn_recommend():
      pred = basic.Memorized(simple_df)
      rec = basic.TopN(pred)
      rec.fit(simple_df)
  
      rec10 = rec.recommend(10, candidates=[1, 2])
      assert all(rec10.item == [2, 1])
      assert all(rec10.score == [5, 4])
  
      rec2 = rec.recommend(12, candidates=[1, 2])
      assert len(rec2) == 1
      assert all(rec2.item == [1])
      assert all(rec2.score == [3])
  
      rec10 = rec.recommend(10, n=1, candidates=[1, 2])
      assert len(rec10) == 1
      assert all(rec10.item == [2])
      assert all(rec10.score == [5])
  
file_path: lkpy/tests/test_topn_recs.py
imports: from lenskit.algorithms import basic
  from lenskit.algorithms import bias
  import pandas
  import numpy
  import lenskit.util.test
  from pytest import approx
label_desc: Use image node_id 1 for calling a global function with example usage: test_topn_recommend() without return types