Skip to content

Commit 0459cd6

Browse files
Merge pull request #482 from scholarly-python-package/develop
Release v1.7.10
2 parents 84f9e26 + bf13b8f commit 0459cd6

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

scholarly/author_parser.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,12 @@ def _fill_indices(self, soup, author):
123123
def _fill_counts(self, soup, author):
124124
years = [int(y.text)
125125
for y in soup.find_all('span', class_='gsc_g_t')]
126-
cites = [int(c.text)
127-
for c in soup.find_all('span', class_='gsc_g_al')]
126+
127+
cites = [0]*len(years)
128+
for c in soup.find_all('a', class_='gsc_g_a'):
129+
i = int(c['style'].split(':')[-1])
130+
cites[-i] = int(c.find('span', class_='gsc_g_al').text)
131+
128132
author['cites_per_year'] = dict(zip(years, cites))
129133

130134
def _fill_public_access(self, soup, author):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name='scholarly',
8-
version='1.7.10-alpha',
8+
version='1.7.10',
99
author='Steven A. Cholewiak, Panos Ipeirotis, Victor Silva, Arun Kannawadi',
1010
author_email='steven@cholewiak.com, panos@stern.nyu.edu, vsilva@ualberta.ca, arunkannawadi@astro.princeton.edu',
1111
description='Simple access to Google Scholar authors and citations',

test_module.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,15 @@ def test_bin_citations_by_year(self):
560560
self.assertLessEqual(y_lo, y_hi)
561561
self.assertLessEqual(sum(cpy[y] for y in range(y_lo, y_hi+1)), 1000)
562562

563+
def test_cites_per_year(self):
564+
"""Test that the cites_per_year is correctly filled in,
565+
including any gap years.
566+
"""
567+
author = scholarly.search_author_id('DW_bVcEAAAAJ')
568+
scholarly.fill(author, sections=['counts'])
569+
cpy = {2014: 1, 2015: 2, 2016: 2, 2017: 0, 2018: 2, 2019: 1, 2020: 12, 2021: 21, 2022: 35}
570+
for year, count in cpy.items():
571+
self.assertEqual(author['cites_per_year'][year], count)
563572

564573
class TestScholarlyWithProxy(unittest.TestCase):
565574
@classmethod

0 commit comments

Comments
 (0)