Commit abd23540 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update PluginPublicationInfo to store DataFrame in df_info instead of publication_info

parent 096b1277
......@@ -26,7 +26,7 @@ class PluginPublicationInfo(object):
+------------+--------------------------------+
The DataFrame has to be build in the parent
It is retrieved via self["publication_info"]
It is retrieved via self["df_info"]
"""
......@@ -46,7 +46,7 @@ class PluginPublicationInfo(object):
# * the row contains empty string when the record is not published.
# * iloc[0] returns a serie where the index are the column's name
#
columns = (self["publication_info"].iloc[0]
columns = (self["df_info"].iloc[0]
.replace("", np.nan)
.dropna()
.index)
......@@ -60,7 +60,7 @@ class PluginPublicationInfo(object):
bool
"""
df = self["publication_info"]
df = self["df_info"]
return len(df) > 1
def paper_editor(self):
......@@ -71,7 +71,7 @@ class PluginPublicationInfo(object):
empty string when not defined.
"""
df = self["publication_info"]
df = self["df_info"]
editor = (df.title.iloc[0] if "title" in df else "")
# add space after the dot Phys.Rev -> Phys. Rev
......@@ -88,7 +88,7 @@ class PluginPublicationInfo(object):
* Empty string when not defined.
"""
df = self["publication_info"]
df = self["df_info"]
return (df.pagination.iloc[0] if "pagination" in df else "")
def paper_reference(self):
......@@ -101,7 +101,7 @@ class PluginPublicationInfo(object):
published in a review.
"""
df = self["publication_info"]
df = self["df_info"]
its = df.columns.intersection({"title",
"volume",
......@@ -128,7 +128,7 @@ class PluginPublicationInfo(object):
empty string when nothing is found.
"""
df = self["publication_info"]
df = self["df_info"]
return (df.volume.iloc[0] if "volume" in df else "")
def paper_year(self):
......@@ -139,5 +139,5 @@ class PluginPublicationInfo(object):
- Empty string if the year is not defined.
"""
df = self["publication_info"]
df = self["df_info"]
return (df.year.iloc[0] if "year" in df else "")
......@@ -236,8 +236,7 @@ class RecordPubli(Record, PluginAuthors, PluginPublicationInfo):
"year",
"pagination"]
self["publication_info"] = \
DataFrame([[""] * len(cols)], columns=cols)
self["df_info"] = DataFrame([[""] * len(cols)], columns=cols)
return
......@@ -262,7 +261,7 @@ class RecordPubli(Record, PluginAuthors, PluginPublicationInfo):
df = df.sort_values("year")
# replace
self["publication_info"] = df
self["df_info"] = df
def collaboration(self):
"""The collaboration(s) signing the publication.
......
......@@ -52,7 +52,7 @@ def test_constructor_cds_04002(record):
assert len(authors) == record["number_of_authors"]
assert authors.affiliation.iloc[12] == "INFN, Rome|CERN"
papers = record["publication_info"]
papers = record["df_info"]
assert isinstance(papers, pd.DataFrame)
assert len(papers) == 1
......
......@@ -52,7 +52,7 @@ def test_constructor_ins_05002(record):
assert len(authors) == 704
assert authors.affiliation.iloc[12] == "INFN, Rome|CERN"
papers = record["publication_info"]
papers = record["df_info"]
assert isinstance(papers, pd.DataFrame)
assert len(papers) == 1
......
......@@ -66,7 +66,7 @@ def test_paper_reference_cds_13004(svc, reccds):
# remove the publisher and volume information
paper_ref = reccds.paper_reference()
reccds["publication_info"].loc[0, ["title", "volume"]] = ["", ""]
reccds["df_info"].loc[0, ["title", "volume"]] = ["", ""]
svc.paper_reference(reccds)
assert reccds.paper_reference() == paper_ref
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment