Skip to content

Commit 8552c83

Browse files
author
Ivan Cao-Berg
committed
Updated error handling for better user experience.
Refactored code to improve performance. Added new feature for enhanced functionality. Fixed bug that caused application to crash. Improved code readability and maintainability. Removed unused variables and commented code.
1 parent 132c7d1 commit 8552c83

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

braininventory/get.py

Lines changed: 22 additions & 16 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
@@ -137,7 +143,7 @@ def __get_genotype_frequency(df):
137143
"""
138144
Write documentation here.
139145
"""
140-
return df['genotypes'].value_counts().to_dict()
146+
return df["genotypes"].value_counts().to_dict()
141147

142148
report = {}
143149
report["date"] = tdate

0 commit comments

Comments
 (0)