Example #1
0
 def test_get_indicators(self):
     '''Test getting indicators'''
     from metrics import get_indicators
     indic, indic_ref = get_indicators(testset)
     # Start comparing the results with computed values
     # Get the year range for comparison of 'm'
     yrange = datetime.now().year - min([int(p[:4]) for p in testset]) + 1
     # Test the indicators for all publications
     indicators = ['h', 'g', 'i10', 'i100']
     for indicator in indicators:
         self.assertEqual(indic[indicator],
                          expected_results['indicators'][indicator])
     self.assertEqual(indic['m'], float(indic['h']) / float(yrange))
     # By contruction of the reads data, Read10 follows thusly:
     # there are only two papers published in previous 10 years
     # and their current reads are all 1; one has 3 authors, the other 2
     self.assertEqual(indic['read10'], 1.0 / float(3) + 1.0 / float(2))
     # Now do the comparison for the refereed values
     # The year range is the same, because the oldest paper is refereed
     for indicator in indicators:
         self.assertEqual(
             indic_ref[indicator],
             expected_results['indicators refereed'][indicator])
     self.assertEqual(indic_ref['m'], float(indic_ref['h']) / float(yrange))
     # There are no refereed papers in previous 10 years, so Read10 is zero
     self.assertEqual(indic_ref['read10'], 0.0)
 def test_get_h_nocits(self):
     '''Test h index for only records where Ncits > Nrecs:
        h should equal Nrecs'''
     from metrics import get_indicators
     indic, indic_ref = get_indicators(testset)
     self.assertEqual(indic['h'], 0)
     self.assertEqual(indic['g'], 0)
 def test_get_h_nocits(self):
     '''Test h index for only records where Ncits > Nrecs:
        h should equal Nrecs'''
     from metrics import get_indicators
     indic, indic_ref = get_indicators(testset)
     self.assertEqual(indic['h'], 0)
     self.assertEqual(indic['g'], 0)
 def test_get_indicators(self):
     '''Test getting indicators'''
     from metrics import get_indicators
     indic, indic_ref = get_indicators(testset)
     # Start comparing the results with computed values
     # Get the year range for comparison of 'm'
     yrange = datetime.now().year - min([int(p[:4]) for p in testset]) + 1
     # Test the indicators for all publications
     indicators = ['h', 'g', 'i10', 'i100']
     for indicator in indicators:
         self.assertEqual(
             indic[indicator], expected_results['indicators'][indicator])
     self.assertEqual(indic['m'], float(indic['h']) / float(yrange))
     # By contruction of the reads data, Read10 follows thusly:
     # there are only two papers published in previous 10 years
     # and their current reads are all 1; one has 3 authors, the other 2
     self.assertEqual(indic['read10'], 1.0 / float(3) + 1.0 / float(2))
     # Now do the comparison for the refereed values
     # The year range is the same, because the oldest paper is refereed
     for indicator in indicators:
         self.assertEqual(
             indic_ref[indicator],
             expected_results['indicators refereed'][indicator])
     self.assertEqual(indic_ref['m'], float(indic_ref['h']) / float(yrange))
     # There are no refereed papers in previous 10 years, so Read10 is zero
     self.assertEqual(indic_ref['read10'], 0.0)