Skip to content

Commit

Permalink
Merge pull request #107 from RemDelaporteMathurin/fix-current-year-bug
Browse files Browse the repository at this point in the history
Fix current year bug with citation graph
  • Loading branch information
RemDelaporteMathurin authored Nov 9, 2024
2 parents 0d1fb60 + b7e2ea4 commit ea85ae6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion htm_dashboard/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def make_citations_graph(group: htm.PropertiesGroup, per_year: bool = True):
references.append(label)
if per_year:
current_year = datetime.now().year
nb_citations.append(nb_citations_prop / (current_year - year))
nb_citations.append(nb_citations_prop / (current_year - year + 1))
else:
nb_citations.append(nb_citations_prop)

Expand Down
13 changes: 12 additions & 1 deletion tests/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
from contextvars import copy_context
from dash._callback_context import context_value
from dash._utils import AttributeDict
from datetime import datetime

from htm_dashboard.callbacks import create_make_download_data_function
from htm_dashboard.callbacks import (
create_make_download_data_function,
make_citations_graph,
)


def test_export_groups():
Expand Down Expand Up @@ -33,3 +37,10 @@ def run_callback():
ctx = copy_context()
output = ctx.run(run_callback)
assert type(output["content"]) == str


def test_citation_graphs_per_year_same_year():
current_year = datetime.now().year

group = htm.PropertiesGroup([htm.Property(year=current_year)])
make_citations_graph(group, per_year=True)

0 comments on commit ea85ae6

Please sign in to comment.