Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix current year bug with citation graph #107

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading