Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robbibt committed Oct 8, 2024
1 parent b27e3c0 commit 4193f2d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ build-backend = "setuptools.build_meta"
[tool.mypy]
files = ["eo_tides"]
python_version = "3.10"
ignore_missing_imports = "True"
allow_redefinition = "True"
ignore_missing_imports = true
allow_redefinition = true

[tool.pytest.ini_options]
testpaths = ["tests"]
Expand Down Expand Up @@ -119,6 +119,10 @@ DEP002 = [

[tool.coverage.report]
skip_empty = true
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
]

[tool.coverage.run]
branch = true
Expand Down
29 changes: 27 additions & 2 deletions tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_tidal_stats(satellite_ds, modelled_freq):
# Calculate tidal stats
tidal_stats_df = tide_stats(satellite_ds, modelled_freq=modelled_freq)

# Compare outputs to expected results (within 5% or 0.05 m)
# Compare outputs to expected results (within 2% or 0.02 m)
expected_results = pd.Series({
"tidepost_lat": -18.001,
"tidepost_lon": 122.218,
Expand All @@ -36,4 +36,29 @@ def test_tidal_stats(satellite_ds, modelled_freq):
"low_tide_offset": 0.254,
"high_tide_offset": 0.301,
})
assert np.allclose(tidal_stats_df, expected_results, atol=0.05)
assert np.allclose(tidal_stats_df, expected_results, atol=0.02)

# Test linear regression
tidal_stats_linreg_df = tide_stats(satellite_ds, modelled_freq=modelled_freq, linear_reg=True)

# Compare outputs to expected results (within 2% or 0.02 m)
expected_results = pd.Series({
"tidepost_lat": -18.001,
"tidepost_lon": 122.218,
"observed_mean_m": -0.417,
"all_mean_m": -0.005,
"observed_min_m": -2.141,
"all_min_m": -4.321,
"observed_max_m": 1.674,
"all_max_m": 4.259,
"observed_range_m": 3.814,
"all_range_m": 8.580,
"spread": 0.445,
"low_tide_offset": 0.254,
"high_tide_offset": 0.301,
"observed_slope": 6.952,
"all_slope": -1.472,
"observed_pval": 0.573,
"all_pval": 0.000,
})
assert np.allclose(tidal_stats_linreg_df, expected_results, atol=0.02)

0 comments on commit 4193f2d

Please sign in to comment.