euler314 commited on
Commit
26f3e96
·
verified ·
1 Parent(s): 612da33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -1304,16 +1304,18 @@ def create_interface():
1304
  available_years = sorted([year for year in range(1950, 2025) if year in ibtracs.data.keys()])
1305
  return gr.Dropdown.update(choices=available_years, value=available_years[-1] if available_years else None)
1306
 
 
1307
  # Update typhoon dropdown when year changes
1308
  def update_typhoon_dropdown(year):
1309
  if not year or ibtracs is None:
1310
- return gr.Dropdown.update(choices=[], value=None)
1311
-
1312
  typhoons = get_typhoons_for_year(year)
1313
- return gr.Dropdown.update(
1314
- choices=[{"label": name, "value": id} for name, id in typhoons],
1315
- value=typhoons[0][1] if typhoons else None
1316
- )
 
1317
 
1318
  # Update the year dropdown once at the beginning
1319
  demo.load(
 
1304
  available_years = sorted([year for year in range(1950, 2025) if year in ibtracs.data.keys()])
1305
  return gr.Dropdown.update(choices=available_years, value=available_years[-1] if available_years else None)
1306
 
1307
+ # Update typhoon dropdown when year changes
1308
  # Update typhoon dropdown when year changes
1309
  def update_typhoon_dropdown(year):
1310
  if not year or ibtracs is None:
1311
+ return [], None
1312
+
1313
  typhoons = get_typhoons_for_year(year)
1314
+ if not typhoons:
1315
+ return [], None
1316
+
1317
+ # Return the choices and value directly
1318
+ return [{"label": name, "value": id} for name, id in typhoons], typhoons[0][1] if typhoons else None
1319
 
1320
  # Update the year dropdown once at the beginning
1321
  demo.load(