Skip to content

Commit 91b52bd

Browse files
committed
Updated test functions accoding to modified codes
1 parent 6a89729 commit 91b52bd

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

tests/test_calibration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_calibration():
2828
'channel_sd_mon.txt': {
2929
'has_units': True,
3030
'ref_day': 1,
31-
'apply_filter': {'name': ['cha300']}
31+
'apply_filter': {'name': ['cha771']}
3232
}
3333
}
3434

@@ -141,7 +141,7 @@ def test_error_calibration():
141141
'channel_sd_mon.txt': {
142142
'has_units': True,
143143
'ref_day': 1,
144-
'apply_filter': {'name': ['cha561']}
144+
'apply_filter': {'name': ['cha771']}
145145
}
146146
}
147147

@@ -371,12 +371,12 @@ def test_error_calibration():
371371
extract_data={
372372
'channel_sd_day.txt': {
373373
'has_units': True,
374-
'apply_filter': {'name': ['cha561']}
374+
'apply_filter': {'name': ['cha771']}
375375
},
376376
'channel_sd_mon.txt': {
377377
'has_units': True,
378378
'ref_day': 1,
379-
'apply_filter': {'name': ['cha561']}
379+
'apply_filter': {'name': ['cha771']}
380380
}
381381
},
382382
observe_data={

tests/test_data_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_error_hru_stats_from_daily_simulation(
133133
data_manager.hru_stats_from_daily_simulation(
134134
sim_file='channel_sd_mon.txt',
135135
has_units=True,
136-
gis_id=561,
136+
gis_id=771,
137137
sim_col='flo_out'
138138
)
139139
assert exc_info.value.args[0] == 'Statistical summary applies only to daily time series files ending with "_day"; received file name "channel_sd_mon"'

tests/test_sensitivity_analyzer.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_simulation_by_sample_parameters(
5050
'channel_sd_mon.txt': {
5151
'has_units': True,
5252
'ref_day': 1,
53-
'apply_filter': {'name': ['cha300']},
53+
'apply_filter': {'name': ['cha771']},
5454
'usecols': ['gis_id', 'flo_out']
5555
}
5656
}
@@ -209,22 +209,16 @@ def test_simulation_by_sample_parameters(
209209
assert 'Invalid sub-key "begin_datee" for "channel_sd_yr.txt" in extract_data' in exc_info.value.args[0]
210210

211211

212-
def test_error_scenario_indicators(
212+
def test_error_indicator_abbr(
213213
performance_metrics
214214
):
215215

216216
# Error: invalid indicator name
217217
with pytest.raises(Exception) as exc_info:
218-
performance_metrics.scenario_indicators(
219-
sensim_file='sensitivity_simulation.json',
220-
df_name='channel_sd_mon_df',
221-
sim_col='flo_out',
222-
obs_file='a_observe_discharge_monthly.csv',
223-
date_format='%Y-%m-%d',
224-
obs_col='mean',
218+
performance_metrics._validate_indicator_abbr(
225219
indicators=['NSEE']
226220
)
227-
assert 'Invalid name "NSEE" in "indicatiors" list' in exc_info.value.args[0]
221+
assert 'Invalid indicator "NSEE"' in exc_info.value.args[0]
228222

229223

230224
def test_create_sobol_problem(

tests/test_txtinout_reader.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,27 @@ def test_run_swat(
101101
assert list(df.columns) == list(csv_df.columns)
102102
assert all(df.dtypes == csv_df.dtypes)
103103

104+
# Pass: computing indicator from file
105+
output = pySWATPlus.PerformanceMetrics().indicator_from_file(
106+
sim_file=sim2_dir / 'channel_sd_day.txt',
107+
sim_col='flo_out',
108+
extract_sim={
109+
'has_units': True,
110+
'apply_filter': {'name': ['cha771']}
111+
},
112+
obs_file=txtinout_reader.root_dir / 'a_observe_discharge_daily.csv',
113+
date_format='%Y-%m-%d',
114+
obs_col='discharge',
115+
indicators=['NSE', 'KGE', 'RMSE']
116+
)
117+
assert isinstance(output, dict)
118+
assert len(output) == 3
119+
104120
# Pass: monthly and yearly summary statistics from daily time series
105121
stats_dict = pySWATPlus.DataManager().hru_stats_from_daily_simulation(
106122
sim_file=sim2_dir / 'channel_sd_day.txt',
107123
has_units=True,
108-
gis_id=300,
124+
gis_id=771,
109125
sim_col='flo_out',
110126
output_dir=sim2_dir
111127
)

0 commit comments

Comments
 (0)