code: def test_hit_ratio(self):
      hr = HitRatio()
  
      self.assertEqual(hr.type, "ranking")
      self.assertEqual(hr.name, "HitRatio@-1")
  
      self.assertEqual(1, hr.compute(np.asarray([0]), np.asarray([0])))
      self.assertEqual(
          1, hr.compute(np.asarray([0, 1]), np.asarray([0, 2]))
      )
  
      gt_pos = np.asarray([0, 2])  # [1, 0, 1]
      pd_rank = np.asarray([0, 2, 1])  # [1, 1, 1]
      self.assertEqual(1, hr.compute(gt_pos, pd_rank))
  
      gt_pos = np.asarray([2])  # [0, 0, 1]
      pd_rank = np.asarray([1, 2, 0])  # [1, 1, 1]
      self.assertEqual(1, hr.compute(gt_pos, pd_rank))
  
      hr_2 = HitRatio(k=2)
      self.assertEqual(hr_2.k, 2)
  
      gt_pos = np.asarray([0])  # [0, 0, 1]
      pd_rank = np.asarray([1, 2, 0])  # [1, 1, 1]
      self.assertEqual(0, hr_2.compute(gt_pos, pd_rank))
  
      gt_pos = np.asarray([2])  # [0, 0, 1]
      pd_rank = np.asarray([1, 2, 0])  # [1, 1, 1]
      self.assertEqual(1, hr_2.compute(gt_pos, pd_rank))
  
imports: import unittest
  import numpy
  from cornac.metrics.ranking import RankingMetric
  from cornac.metrics.ranking import MeasureAtK
  from cornac.metrics import NDCG
  from cornac.metrics import NCRR
  from cornac.metrics import MRR
  from cornac.metrics import HitRatio
  from cornac.metrics import Precision
  from cornac.metrics import Recall
  from cornac.metrics import FMeasure
  from cornac.metrics import AUC
  from cornac.metrics import MAP
label_desc: Use image node_id 6 for calling the TestRanking obj's underlying member method code with example usage: obj.test_hit_ratio() without return types