code: def test_ndcg_perfect():
      recs = pd.DataFrame({"item": [2, 3, 1]})
      truth = pd.DataFrame(
          {"item": [1, 2, 3], "rating": [3.0, 5.0, 4.0]}
      )
      truth = truth.set_index("item")
      assert ndcg(recs, truth) == approx(1.0)
  
imports: import numpy
  import pandas
  from pytest import approx, mark
  from lenskit.metrics.topn import _dcg, dcg, ndcg, _bulk_ndcg
  from lenskit.topn import RecListAnalysis
  from lenskit.util.test import demo_recs
label_desc: Use image node_id 13 for calling a global function with example usage: test_ndcg_perfect() without return types