code: def test_dcg_single():
      "a single element should be scored at the right place"
      assert _dcg(np.array([0.5])) == approx(0.5)
      assert _dcg(np.array([0, 0.5])) == approx(0.5)
      assert _dcg(np.array([0, 0, 0.5])) == approx(0.5 / np.log2(3))
      assert _dcg(np.array([0, 0, 0.5, 0])) == approx(0.5 / np.log2(3))
  
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 3 for calling a global function with example usage: test_dcg_single() without return types