Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvonk committed Mar 13, 2024
1 parent ecddaed commit 59e6667
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/spei/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ def show_versions() -> None:
for dep in deps:
msg += f"{dep}: {metadata.version(dep)}\n"

print(msg)
return msg
6 changes: 3 additions & 3 deletions tests/test_climdex.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from spei import climdex


def text_climdex_rxnday(precmm: Series) -> None:
def test_climdex_rxnday(precmm: Series) -> None:
climdex.rxnday(series=precmm, interval="10D", period="90D")


def text_climdex_rx1day(precmm: Series) -> None:
def test_climdex_rx1day(precmm: Series) -> None:
climdex.rx1day(series=precmm)


def text_climdex_rx5day(precmm: Series) -> None:
def test_climdex_rx5day(precmm: Series) -> None:
climdex.rx5day(series=precmm)


Expand Down
12 changes: 9 additions & 3 deletions tests/test_si.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@


def test_spi(prec: Series) -> None:
spi(prec.rolling("30D", min_periods=30).sum().dropna(), prob_zero=True)
precr = prec.rolling("30D", min_periods=30).sum().dropna()
spi(precr, freq="ME", prob_zero=True)


def test_spei(prec: Series, evap: Series) -> None:
n = (prec - evap).rolling("30D", min_periods=30).sum().dropna()
spei(n)
spei(n, freq="ME")


def test_sgi(head: Series) -> None:
sgi(head)
sgi(head, freq="ME")


def test_sffi(prec: Series) -> None:
sf = prec.rolling("30D", min_periods=30).sum().dropna()
ssfi(sf)


def test_window(prec: Series, evap: Series) -> None:
n = (prec - evap).rolling("30D", min_periods=30).sum().dropna()
spei(n, freq="W", window=3)
3 changes: 2 additions & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ def test_version() -> None:


def test_show_versions():
si.show_versions()
msg = si.show_versions()
assert isinstance(msg, str)

0 comments on commit 59e6667

Please sign in to comment.