Skip to content

Commit

Permalink
Storm lookup with correct name match (#94)
Browse files Browse the repository at this point in the history
* Storm lookup with correct name match
* Fix style

IGNORING COVERAGE DUE TO TIMEOUT ISSUE
  • Loading branch information
SorooshMani-NOAA authored Mar 6, 2024
1 parent bf9e36e commit 9d93366
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stormevents/stormevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
"""

storms = nhc_storms(year=year)
storms = storms[storms["name"].str.contains(name.upper())]
storms = storms[storms["name"].str.fullmatch(name.upper())]
if len(storms) > 0:
self.__entry = storms.iloc[0]
else:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_stormevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def test_storm_event_lookup():
paine2016 = StormEvent.from_nhc_code("EP172016")
henri2021 = StormEvent.from_usgs_id(310)
ida2021 = StormEvent("ida", 2021)
eta2020 = StormEvent("eta", 2020)
beta2020 = StormEvent("beta", 2020)

with pytest.raises(ValueError):
StormEvent("nonexistent", 2021)
Expand Down Expand Up @@ -80,6 +82,10 @@ def test_storm_event_lookup():
assert ida2021.start_date == datetime(2021, 8, 27, 18)
assert ida2021.end_date == datetime(2021, 9, 4, 18)

# Similar names are not swapped (like [B]ETA)
assert eta2020.name == "ETA"
assert beta2020.name == "BETA"


def test_storm_event_time_interval():
florence2018 = StormEvent("florence", 2018, start_date=timedelta(days=-2))
Expand Down

0 comments on commit 9d93366

Please sign in to comment.