Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer committed Oct 8, 2024
1 parent a6fffd2 commit b974eed
Show file tree
Hide file tree
Showing 5 changed files with 303 additions and 104 deletions.
8 changes: 4 additions & 4 deletions tests/test_data_retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def test_drop_duplicate_times(df_meas_2010, caplog):

assert len(meas_duplicated) == 105120
assert len(meas_clean) == 52560

# assert logging messages
assert '52530 rows with duplicated time-value-combinations dropped' in caplog.text
assert '30 rows with duplicated times dropped' in caplog.text
assert "52530 rows with duplicated time-value-combinations dropped" in caplog.text
assert "30 rows with duplicated times dropped" in caplog.text


@pytest.mark.unittest
Expand All @@ -45,7 +45,7 @@ def test_drop_duplicate_times_noaction(df_meas_2010, caplog):

assert len(df_meas_2010) == 52560
assert len(meas_clean) == 52560

# assert that there is no logging messages
assert caplog.text == ""

Expand Down
79 changes: 44 additions & 35 deletions tests/test_overschrijding.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ def test_calc_overschrijding(df_ext_12_2010_2014):
expected_values = np.array(
[
1.93,
2.09327434,
2.26311592,
2.44480348,
2.70434509,
2.91627091,
3.14247786,
3.46480369,
3.72735283,
4.00701551,
2.09356726,
2.2637632,
2.44533302,
2.70383299,
2.91416492,
3.13795447,
3.45560027,
3.71330277,
3.98682045,
]
)
assert np.allclose(dist["geinterpoleerd"].values, expected_values)
Expand All @@ -96,11 +96,24 @@ def test_calc_overschrijding_with_hydra(df_ext_12_2010_2014):
1 / 100,
1 / 200,
]
hydra_values = np.array([2.473, 3.18 , 4.043, 4.164, 4.358, 4.696, 5.056, 5.468, 5.865,
6.328, 7.207])
hydra_index = np.array([1.00000000e+00, 1.00000000e-01, 2.00000000e-02, 1.00000000e-02,
3.33333333e-03, 1.00000000e-03, 3.33333333e-04, 1.00000000e-04,
3.33333333e-05, 1.00000000e-05, 1.00000000e-06])
hydra_values = np.array(
[2.473, 3.18, 4.043, 4.164, 4.358, 4.696, 5.056, 5.468, 5.865, 6.328, 7.207]
)
hydra_index = np.array(
[
1.00000000e00,
1.00000000e-01,
2.00000000e-02,
1.00000000e-02,
3.33333333e-03,
1.00000000e-03,
3.33333333e-04,
1.00000000e-04,
3.33333333e-05,
1.00000000e-05,
1.00000000e-06,
]
)
ser_hydra = pd.Series(hydra_values, index=hydra_index)
ser_hydra.attrs = df_ext_12_2010_2014.attrs
dist_hydra = {"Hydra-NL": ser_hydra}
Expand All @@ -121,12 +134,12 @@ def test_calc_overschrijding_with_hydra(df_ext_12_2010_2014):
expected_values = np.array(
[
1.93,
2.09327434,
2.26311587,
2.46299612,
2.79965222,
3.08436295,
3.4987347,
2.09356726,
2.26376316,
2.46348569,
2.79932582,
3.08359924,
3.49814949,
4.043,
4.164,
4.3095,
Expand Down Expand Up @@ -227,20 +240,18 @@ def test_calc_overschrijding_clip_physical_break(df_ext_12_2010_2014):
expected_values_normal = np.array(
[
1.93,
2.09327434,
2.26311592,
2.44480348,
2.70434509,
2.91627091,
3.14247786,
3.46480369,
3.72735283,
4.00701551,
2.09356726,
2.2637632,
2.44533302,
2.70383299,
2.91416492,
3.13795447,
3.45560027,
3.71330277,
3.98682045,
]
)
assert np.allclose(
dist_normal["geinterpoleerd"].values, expected_values_normal
)
assert np.allclose(dist_normal["geinterpoleerd"].values, expected_values_normal)
expected_values_clip = np.array(
[
1.93,
Expand All @@ -255,9 +266,7 @@ def test_calc_overschrijding_clip_physical_break(df_ext_12_2010_2014):
3.90683996,
]
)
assert np.allclose(
dist_clip["geinterpoleerd"].values, expected_values_clip
)
assert np.allclose(dist_clip["geinterpoleerd"].values, expected_values_clip)


@pytest.mark.unittest
Expand Down
46 changes: 27 additions & 19 deletions tests/test_slotgemiddelden.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,18 @@ def test_calc_slotgemiddelden(df_meas_2010_2014, df_ext_12_2010_2014):
assert set(slotgemiddelden_dict_noext.keys()) == set(expected_keys_noext)

# assertion of values
wl_mean_peryear_expected = np.array([0.07960731, 0.08612119, 0.0853051,
0.07010864, 0.10051922])
hw_mean_peryear_expected = np.array([1.13968839, 1.12875177, 1.13988685,
1.1415461, 1.18998584])
lw_mean_peryear_expected = np.array([-0.60561702, -0.59089362, -0.59342291,
-0.61334278, -0.58024113])
range_mean_peryear_expected = np.array([1.74530541, 1.71964539, 1.73330976,
1.75488888, 1.77022697])
wl_mean_peryear_expected = np.array(
[0.07960731, 0.08612119, 0.0853051, 0.07010864, 0.10051922]
)
hw_mean_peryear_expected = np.array(
[1.13968839, 1.12875177, 1.13988685, 1.1415461, 1.18998584]
)
lw_mean_peryear_expected = np.array(
[-0.60561702, -0.59089362, -0.59342291, -0.61334278, -0.58024113]
)
range_mean_peryear_expected = np.array(
[1.74530541, 1.71964539, 1.73330976, 1.75488888, 1.77022697]
)
assert np.allclose(
slotgemiddelden_dict_inclext["wl_mean_peryear"].values, wl_mean_peryear_expected
)
Expand All @@ -88,17 +92,21 @@ def test_calc_slotgemiddelden(df_meas_2010_2014, df_ext_12_2010_2014):
)
assert np.allclose(
slotgemiddelden_dict_inclext["tidalrange_mean_peryear"].values,
range_mean_peryear_expected
range_mean_peryear_expected,
)

wl_model_fit_expected = np.array([0.0141927, 0.08612119, 0.0853051,
0.07010864, 0.10051922, 0.23137634])
hw_model_fit_expected = np.array([1.05295416, 1.12875177, 1.13988685,
1.1415461, 1.18998584, 1.336182])
lw_model_fit_expected = np.array([-0.67420399, -0.59089362, -0.59342291,
-0.61334278, -0.58024113, -0.42969074])
range_model_fit_expected = np.array([1.72715816, 1.71964539, 1.73330976,
1.75488888, 1.77022697, 1.76587273])
wl_model_fit_expected = np.array(
[0.0141927, 0.08612119, 0.0853051, 0.07010864, 0.10051922, 0.23137634]
)
hw_model_fit_expected = np.array(
[1.05295416, 1.12875177, 1.13988685, 1.1415461, 1.18998584, 1.336182]
)
lw_model_fit_expected = np.array(
[-0.67420399, -0.59089362, -0.59342291, -0.61334278, -0.58024113, -0.42969074]
)
range_model_fit_expected = np.array(
[1.72715816, 1.71964539, 1.73330976, 1.75488888, 1.77022697, 1.76587273]
)
assert np.allclose(
slotgemiddelden_dict_inclext["wl_model_fit"].values, wl_model_fit_expected
)
Expand All @@ -109,8 +117,8 @@ def test_calc_slotgemiddelden(df_meas_2010_2014, df_ext_12_2010_2014):
slotgemiddelden_dict_inclext["LW_model_fit"].values, lw_model_fit_expected
)
assert np.allclose(
slotgemiddelden_dict_inclext["tidalrange_model_fit"].values,
range_model_fit_expected
slotgemiddelden_dict_inclext["tidalrange_model_fit"].values,
range_model_fit_expected,
)


Expand Down
Loading

0 comments on commit b974eed

Please sign in to comment.