Skip to content

Commit

Permalink
Update test_metric_utilities.py
Browse files Browse the repository at this point in the history
fix tests so that all metric functions use all correct args
  • Loading branch information
barneydobson committed Apr 1, 2024
1 parent 4d3adb5 commit 3ce1a4e
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions tests/test_metric_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,24 @@ def test_outlet_nse_flow():

# Calculate NSE (perfect results)
val = mu.metrics.outlet_nse_flow(synthetic_G = G,
synthetic_subs = None,
synthetic_results = results,
real_G = G,
real_results = results,
real_subs = subs)
real_subs = subs,
metric_evaluation = None)
assert val == 1.0

# Calculate NSE (mean results)
results_ = results.copy()
results_.loc[[0,2],'value'] = 7.5
val = mu.metrics.outlet_nse_flow(synthetic_G = G,
synthetic_subs = None,
synthetic_results = results_,
real_G = G,
real_results = results,
real_subs = subs)
real_subs = subs,
metric_evaluation = None)
assert val == 0.0

# Change the graph
Expand All @@ -190,20 +194,24 @@ def test_outlet_nse_flow():

# Calculate NSE (mean results)
val = mu.metrics.outlet_nse_flow(synthetic_G = G_,
synthetic_subs = None,
synthetic_results = results_,
real_G = G,
real_results = results,
real_subs = subs)
real_subs = subs,
metric_evaluation = None)
assert val == 0.0

# Test time interpolation
results_.loc[2,'date'] = pd.to_datetime('2021-01-01 00:00:10')
results_.loc[[0,2], 'value'] = [0,30]
val = mu.metrics.outlet_nse_flow(synthetic_G = G_,
synthetic_subs = None,
synthetic_results = results_,
real_G = G,
real_results = results,
real_subs = subs)
real_subs = subs,
metric_evaluation = None)
assert val == -15.0

def test_outlet_nse_flooding():
Expand Down Expand Up @@ -248,20 +256,24 @@ def test_outlet_nse_flooding():

# Calculate NSE (perfect results)
val = mu.metrics.outlet_nse_flooding(synthetic_G = G,
synthetic_subs = None,
synthetic_results = results,
real_G = G,
real_results = results,
real_subs = subs)
real_subs = subs,
metric_evaluation = None)
assert val == 1.0

# Calculate NSE (mean results)
results_ = results.copy()
results_.loc[results_.id.isin([770549936, 25472468]),'value'] = [14.5 / 4] * 4
val = mu.metrics.outlet_nse_flooding(synthetic_G = G,
synthetic_subs = None,
synthetic_results = results_,
real_G = G,
real_results = results,
real_subs = subs)
real_subs = subs,
metric_evaluation = None)
assert val == 0.0

# Change the graph
Expand All @@ -275,10 +287,12 @@ def test_outlet_nse_flooding():

# Calculate NSE (mean results)
val = mu.metrics.outlet_nse_flooding(synthetic_G = G_,
synthetic_subs = None,
synthetic_results = results_,
real_G = G,
real_results = results,
real_subs = subs)
real_subs = subs,
metric_evaluation = None)
assert val == 0.0

# Test time interpolation
Expand All @@ -287,9 +301,11 @@ def test_outlet_nse_flooding():

val = mu.metrics.outlet_nse_flooding(synthetic_G = G_,
synthetic_results = results_,
synthetic_subs = None,
real_G = G,
real_results = results,
real_subs = subs)
real_subs = subs,
metric_evaluation = None)
assert val == 0.0

def test_design_params():
Expand Down Expand Up @@ -440,10 +456,12 @@ def test_subcatchment_nse_flooding():

# Calculate NSE (perfect results)
val = mu.metrics.subcatchment_nse_flooding(synthetic_G = G,
synthetic_subs = None,
real_G = G,
synthetic_results = results,
real_results = results,
real_subs = subs)
real_subs = subs,
metric_evaluation = None)
assert val == 1.0

# Calculate NSE (remapped node)
Expand All @@ -460,14 +478,17 @@ def test_subcatchment_nse_flooding():
results_.id = results_.id.replace(mapping)

val = mu.metrics.subcatchment_nse_flooding(synthetic_G = G_,
synthetic_subs = None,
synthetic_results = results_,
real_G = G,
real_results = results,
real_subs = subs)
real_subs = subs,
metric_evaluation = None)
assert val == 1.0

# Test gridded
val = mu.metrics.grid_nse_flooding(synthetic_G = G_,
synthetic_subs = None,
synthetic_results = results_,
real_G = G,
real_results = results,
Expand Down

0 comments on commit 3ce1a4e

Please sign in to comment.