code: def test_idcg_at_k(self):
      ordered = np.array([3, 3, 3, 2, 2, 2, 1, 0])
      wiki_idcg = np.array([3, 3, 3, 2, 2, 2, 1, 0])
  
      # note different than on page calculation, they use linear
      shuffle(wiki_idcg)
      exponential_calc = _idcg(wiki_idcg)
      self.assertAlmostEqual(exponential_calc, 18.77105, 3)
  
      ordered_calc = _idcg(ordered)
      self.assertEqual(ordered_calc, exponential_calc)
  
      binary = np.array([1, 1, 1, 1, 0, 0])
      # By hand
      terms = [
          (2**e - 1) / (np.log2(i + 2))
          for i, e in enumerate(list(binary))
      ]
      est_idcg = np.sum(terms)
      hits = binary
      self.assertEqual(_idcg(hits), est_idcg)
  
file_path: tensorrec/test/test_eval.py
imports: from unittest import TestCase
  from numpy.random import shuffle
  import numpy
  import scipy.sparse
  from tensorrec import TensorRec
  from tensorrec.eval import recall_at_k, precision_at_k, f1_score_at_k, ndcg_at_k
  from tensorrec.eval import _setup_ndcg, _idcg, _dcg
  from tensorrec.util import generate_dummy_data_with_indicator
label_desc: Use image node_id 6 for calling the EvalTestCase obj's underlying member method code with example usage: obj.test_idcg_at_k() without return types