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