def test_prepare_authors_and_their_publications_with_one_pub_with_too_big_contrib( ): data = { PUBLICATION_ID: ["0", "1", "2"], IS_MONOGRAPH: [1, 0, 0], PUBLICATION_POINTS_FOR_AUTHOR: [[69, 0, 1]], PUBLICATION_CONTRIB_FOR_AUTHOR: [[96.0, 0, 1.0]], AUTHOR_ID: ["a"], IS_EMPLOYEE: [1], IS_PHD_STUDENT: [0], CONTRIBUTION: [1.0], IS_IN_N: [1], INITIAL_PUBS: [[0 for _ in range(3)] for _ in range(3)], } authors = prepare_authors_and_their_publications(data) data = normalize_data(data) test_authors = prepare_test_authors(data) test_publications = [ Publication("0", True, 69, 96.0), Publication("2", False, 1, 1.0), ] test_authors[0].publications = test_publications test_authors[0].to_considerate = [test_publications[1]] assert authors == test_authors
def test_prepare_authors_and_their_publications_with_multiple_authors(): data = { PUBLICATION_ID: ["0", "1", "2"], IS_MONOGRAPH: [1, 1, 0], PUBLICATION_POINTS_FOR_AUTHOR: [[0, 0, 1], [2, 0, 0], [0, 1, 0]], PUBLICATION_CONTRIB_FOR_AUTHOR: [[0, 0, 1.0], [0.5, 0, 0], [0, 0, 0]], AUTHOR_ID: ["a", "b", "c"], IS_EMPLOYEE: [1, 1, 0], IS_PHD_STUDENT: [0, 1, 1], CONTRIBUTION: [1.0, 0.5, 1.0], IS_IN_N: [1, 1, 1], INITIAL_PUBS: [[0 for _ in range(3)] for _ in range(3)], } authors = prepare_authors_and_their_publications(data) data = normalize_data(data) test_authors = prepare_test_authors(data) test_authors[0].publications = [Publication("2", False, 1, 1.0)] test_authors[0].to_considerate = test_authors[0].publications test_authors[1].publications = [Publication("0", True, 2, 0.5)] test_authors[1].to_considerate = test_authors[1].publications test_authors[2].publications = [] test_authors[2].to_considerate = [] assert authors == test_authors
def create_example_publications_list(): publications = [ Publication("1", False, 100.0, 0.5), Publication("2", False, 50.0, 1.0), Publication("3", False, 10.0, 1.0), ] return publications
def prepare_test_publications(ids: List[str], mons: List[bool], points: List[float], ctbs: List[float]): pubs = [] for p_id, mon, pts, cbs in zip(ids, mons, points, ctbs): if pts > 0 and cbs > 0: pubs.append(Publication(p_id, mon, pts, cbs)) return pubs
def create_complex_publications_list(): pubs = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] mons = [True, True, True, False, True, False, False, False, True, True] points = [100.0, 10.0, 90.0, 20.0, 80.0, 30.0, 70.0, 40.0, 60.0, 50.0] contribs = [1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0, 0.0, 0.5, 1.0] publications = [] for pub_id, is_mono, pts, contrib in zip(pubs, mons, points, contribs): publications.append(Publication(pub_id, is_mono, pts, contrib)) return publications
def create_example_publication( publication_id: str = "id", is_mono: bool = False, points: float = 10.0, contrib: float = 0.1, author: Author = None, accepted: bool = False, ): return Publication(publication_id, is_mono, points, contrib, author, accepted)
def create_publications_list( pubs: List[str], mons: List[int], points: List[float], contribs: List[float], init: List[int] = None, ): """ Creates publications list for single author. Args: pubs: list of publications' ids mons: list that defines which publications are monographs points: lists that contains points from publications for single author contribs: list that contains contributions from publications for single author Returns: List of publications. Publications with 0 points or 0.0 contribution are not contained """ if init is None: init = [0 for _ in range(len(pubs))] assert len(pubs) == len(mons) assert len(points) == len(contribs) assert len(pubs) == len(contribs) assert len(init) == len(pubs) result = [] for pub_id, is_mon, pts, contrib, ini in zip(pubs, mons, points, contribs, init): if pts > 0 and contrib > 0: is_mon = False if is_mon == 0 else True ini = False if ini == 0 else True result.append(Publication(pub_id, is_mon, pts, contrib, None, ini)) return result
def test_publication__init(): publication = Publication(PUBLICATION_ID, IS_MONO, POINTS, CONTRIBUTION) assert publication.id == PUBLICATION_ID assert publication.is_mono == IS_MONO assert publication.points == POINTS assert publication.contribution == CONTRIBUTION