Skip to content

Commit 88f0f4b

Browse files
Bug fix and add doc string
1 parent 246ad95 commit 88f0f4b

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

src/components/dropdown.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
PROCESSED_DATA_PATH = "data/processed/tsunami-events.csv"
77

88
def preprocess(year_start, year_end):
9-
"""The function to return the processed dataframe with a new index column
10-
and combination column of the country and year. Also filters the df
11-
based on the callback year slider for tsunamis occurring between
12-
specific dates, then reorders by tsunami intensity.
9+
"""The function to return the processed dataframe with a new index column
10+
and combination column of the country and year. Also filters the df
11+
based on the callback year slider for tsunamis occurring between
12+
specific dates, then reorders by tsunami intensity.
1313
Parameters
1414
----------
1515
year_start : int
@@ -33,8 +33,8 @@ def preprocess(year_start, year_end):
3333
return df
3434

3535
def create_bar_plot(year_start, year_end):
36-
"""The function to create a bar graph of the highest intensity
37-
tsunamis between the year_start and year_end.
36+
"""The function to create a bar graph of the highest intensity
37+
tsunamis between the year_start and year_end.
3838
Parameters
3939
----------
4040
year_start : int

src/components/map_plot.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66
COUNTRY_IDS_FILE_PATH = "data/processed/world-110m-country-names.tsv"
77

88
def create_map_plot(year_start, year_end, countries):
9+
"""Create a world map plot with countries colored by no. of tsunami
10+
hits and with origin points.
11+
12+
Parameters
13+
----------
14+
year_start : int
15+
the lower bound of the range of years selected by user
16+
year_end : int
17+
the upper bound of the range of years selected by user
18+
countries : list
19+
the list of countries to filter as selected by the user
20+
21+
Returns
22+
-------
23+
LayerChart:
24+
a world map plot with countries colored by no. of tsunami
25+
hits and with origin points
26+
"""
927

1028
world_map = alt.topo_feature(data.world_110m.url, 'countries')
1129
counts, tsunami_events = preprocess_data(year_start, year_end, countries)
@@ -53,6 +71,24 @@ def create_map_plot(year_start, year_end, countries):
5371
return (map + tsunami_spots).to_html()
5472

5573
def preprocess_data(year_start, year_end, countries):
74+
"""Reads and preprocesses the data for the map plot.
75+
76+
Parameters
77+
----------
78+
year_start : int
79+
the lower bound of the range of years selected by user
80+
year_end : int
81+
the upper bound of the range of years selected by user
82+
countries : list
83+
the list of countries to filter as selected by the user
84+
85+
Returns
86+
-------
87+
counts:
88+
a dataframe which has the number of tsunami hits by countries
89+
tsunami_events:
90+
a dataframe of filtered tsunami events
91+
"""
5692

5793
tsunami_events = pd.read_csv(PROCESSED_DATA_PATH)
5894
country_ids = pd.read_csv(COUNTRY_IDS_FILE_PATH, sep="\t")

0 commit comments

Comments
 (0)