Skip to content

Commit aa773c1

Browse files
author
Ivan Cao-Berg
committed
Refactor square function. Use math.pow instead of multiplication.
1 parent 60c0375 commit aa773c1

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

braininventory/get.py

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@
2121

2222

2323
def __create_general_modality_plot(df):
24+
"""
25+
Create a bar plot to visualize the frequency of general modalities.
26+
27+
This function takes a pandas DataFrame as input and generates a bar plot to display the frequency
28+
of different general modalities in the 'generalmodality' column of the DataFrame.
29+
30+
Parameters:
31+
df (pandas.DataFrame): The input DataFrame containing the 'generalmodality' column.
32+
33+
Returns:
34+
None: The function generates a bar plot but does not return any value. The plot is saved as an
35+
image file with a filename in the format 'general-modality-YYYYMMDD.png', where 'YYYYMMDD'
36+
represents the current date in year-month-day format.
37+
"""
38+
2439
modality_counts = df["generalmodality"].value_counts()
2540

2641
plt.figure(figsize=(10, 6))
@@ -123,11 +138,22 @@ def __create_general_modality_treemap(df):
123138

124139
def __get_pretty_size_statistics(df):
125140
"""
126-
Pretty version of __get_size_statistics
141+
Get human-readable size statistics from the DataFrame.
127142
128-
Input: dataframe
129-
Output: list of strings
143+
This method takes a pandas DataFrame as input and calculates size statistics using the '__get_size_statistics()'
144+
method. The statistics include the minimum, maximum, mean, and total size of the data in the DataFrame.
145+
146+
Parameters:
147+
df (pandas.DataFrame): The input DataFrame.
148+
149+
Returns:
150+
list: A list containing human-readable size statistics in the following order:
151+
- Human-readable minimum size.
152+
- Human-readable maximum size.
153+
- Human-readable mean size.
154+
- Human-readable total size.
130155
"""
156+
131157
size_stats = __get_size_statistics(df)
132158

133159
return [
@@ -140,10 +166,20 @@ def __get_pretty_size_statistics(df):
140166

141167
def __get_size_statistics(df):
142168
"""
143-
Helper method that returns size statistics from size column.
169+
Calculate basic size statistics from the DataFrame.
144170
145-
Input: dataframe
146-
Output: list of numbers
171+
This method takes a pandas DataFrame as input and calculates basic size statistics, including the minimum,
172+
maximum, mean, and standard deviation of the 'size' column in the DataFrame.
173+
174+
Parameters:
175+
df (pandas.DataFrame): The input DataFrame containing the 'size' column.
176+
177+
Returns:
178+
list: A list containing the size statistics in the following order:
179+
- Minimum size.
180+
- Maximum size.
181+
- Mean size.
182+
- Standard deviation of sizes.
147183
"""
148184

149185
min = df["size"].min()

0 commit comments

Comments
 (0)