Skip to content

Commit eab43b7

Browse files
author
Ivan Cao-Berg
committed
Refactor function names, remove unnecessary comments, add error handling, update variable names
1 parent 49f2fdf commit eab43b7

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

braininventory/get.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
def today():
88
"""
9-
Get today's snapshot of Brain Image Library.
10-
"""
9+
Get today's snapshot of Brain Image Library.
10+
"""
1111

1212
server = "https://download.brainimagelibrary.org/inventory/daily/reports/"
1313
filename = "today.json"
@@ -54,9 +54,11 @@ def __get_contributor(df):
5454
def __get_affilation(df):
5555
return df["affiliation"].value_counts().to_dict()
5656

57+
5758
def __get_awards(df):
5859
return df["award_number"].unique()
5960

61+
6062
def __get_award_number(df):
6163
return df["award_number"].value_counts().to_dict()
6264

@@ -88,6 +90,7 @@ def __get_technique(df):
8890
def __get_locations(df):
8991
return df["locations"].value_counts().to_dict()
9092

93+
9194
def __get_contributors(df):
9295
"""
9396
This returns an array of contributor names from the contributorname column.
@@ -96,33 +99,36 @@ def __get_contributors(df):
9699

97100

98101
def __get_project_names(df):
99-
'''
100-
Gets the unique list of project names.
102+
"""
103+
Gets the unique list of project names.
101104
102105
Input: dataframe
103-
Output: list
104-
'''
105-
return df['project'].unique()
106+
Output: list
107+
"""
108+
return df["project"].unique()
109+
106110

107111
def __get_list_of_projects(df):
108-
'''
112+
"""
109113
Get the list of names for unique projects
110114
111115
Input parameter: dataframe
112116
Output: list of projects
113-
'''
114-
115-
return df['project'].unique().to_dict()
117+
"""
118+
119+
return df["project"].unique().to_dict()
120+
116121

117122
def __get_number_of_projects(df):
118-
'''
123+
"""
119124
Get the number of unique projects
120125
121126
Input parameter: dataframe
122127
Output: number of projects
123-
'''
124-
125-
return len(df['project'].unique())
128+
"""
129+
130+
return len(df["project"].unique())
131+
126132

127133
def report():
128134
# Get today's date
@@ -136,6 +142,7 @@ def report():
136142
report = {}
137143
report["date"] = tdate
138144
report["number_of_datasets"] = __get_number_of_datasets(df)
145+
report["number_of_project"] = __get_number_of_projects(df)
139146
report["completeness_score"] = __get_completeness_score(df)
140147
report["metadata_version"] = __get_metadata_version(df)
141148
report["contributor"] = __get_contributor(df)
@@ -148,6 +155,5 @@ def report():
148155
report["generalmodality"] = __get_generalmodality(df)
149156
report["technique"] = __get_technique(df)
150157
report["locations"] = __get_locations(df)
151-
report["is_reachable"] = df["URL"].apply(__is_reachable)
152158

153-
return report
159+
return report

0 commit comments

Comments
 (0)