1
1
from pathlib import Path
2
+
2
3
import numpy as np
3
4
import pytest
4
5
from pydantic .v1 .error_wrappers import ValidationError
15
16
QHTable ,
16
17
QuantityUnitPair ,
17
18
TimeInterpolation ,
18
- TimeSeries
19
+ TimeSeries ,
19
20
)
20
21
from tests .utils import assert_files_equal
21
22
@@ -27,6 +28,7 @@ def quantityunitpair(quantity, unit, verticalpositionindex=None):
27
28
quantity = quantity , unit = unit , vertpositionindex = verticalpositionindex
28
29
)
29
30
31
+
30
32
def harmonic_values (iscorrection : bool ):
31
33
function = "harmonic-correction" if iscorrection else "harmonic"
32
34
return dict (
@@ -43,6 +45,7 @@ def harmonic_values(iscorrection: bool):
43
45
],
44
46
)
45
47
48
+
46
49
def qhtable_values ():
47
50
return dict (
48
51
name = "boundary_qhtable" ,
@@ -73,6 +76,7 @@ def constant_values():
73
76
],
74
77
)
75
78
79
+
76
80
def astronomic_values (iscorrection : bool , quantityunitpair ):
77
81
function = "astronomic-correction" if iscorrection else "astronomic"
78
82
return dict (
@@ -120,7 +124,7 @@ def test_parses_function_case_insensitive(self, input, expected):
120
124
],
121
125
)
122
126
def test_create_forcingbase_missing_field_raises_correct_error (
123
- self , missing_field : str
127
+ self , missing_field : str
124
128
):
125
129
values = dict (
126
130
name = "Boundary2" ,
@@ -143,13 +147,13 @@ def test_create_forcingbase_missing_field_raises_correct_error(
143
147
[
144
148
(["time" , "dischargebnd" ], "m³/s" ),
145
149
(
146
- ["time" , "dischargebnd" , "extra" ],
147
- ["minutes since 2021-01-01 00:00:00" , "m³/s" ],
150
+ ["time" , "dischargebnd" , "extra" ],
151
+ ["minutes since 2021-01-01 00:00:00" , "m³/s" ],
148
152
),
149
153
],
150
154
)
151
155
def test_create_forcingbase_mismatch_number_of_quantities_units_raises_correct_error (
152
- self , quantities , units
156
+ self , quantities , units
153
157
):
154
158
values = dict (
155
159
name = "Boundary2" ,
@@ -172,7 +176,10 @@ class TestForcingModel:
172
176
"""
173
177
174
178
def test_forcing_model (self , input_files_dir ):
175
- filepath = input_files_dir / "e02/f101_1D-boundaries/c01_steady-state-flow/BoundaryConditions.bc"
179
+ filepath = (
180
+ input_files_dir
181
+ / "e02/f101_1D-boundaries/c01_steady-state-flow/BoundaryConditions.bc"
182
+ )
176
183
177
184
m = ForcingModel (filepath )
178
185
assert len (m .forcing ) == 13
@@ -192,7 +199,9 @@ def test_read_bc_missing_field_raises_correct_error(self, invalid_data_dir):
192
199
assert expected_message1 in str (error .value )
193
200
assert expected_message2 in str (error .value )
194
201
195
- def test_save_forcing_model (self , time_series_values , t3d_values , output_files_dir , reference_files_dir ):
202
+ def test_save_forcing_model (
203
+ self , time_series_values , t3d_values , output_files_dir , reference_files_dir
204
+ ):
196
205
bc_file = output_files_dir / TEST_BC_FILE
197
206
reference_file = reference_files_dir / "bc" / TEST_BC_FILE
198
207
forcingmodel = ForcingModel ()
@@ -221,7 +230,7 @@ def test_save_forcing_model(self, time_series_values, t3d_values, output_files_d
221
230
222
231
@pytest .mark .parametrize ("cls" , [Astronomic , AstronomicCorrection ])
223
232
def test_astronomic_values_with_strings_in_datablock_are_parsed_correctly (
224
- self , cls
233
+ self , cls
225
234
):
226
235
try :
227
236
is_correction = cls == AstronomicCorrection
@@ -280,4 +289,4 @@ def test_forcing_model_with_datablock_that_has_nan_values_should_raise_error(sel
280
289
)
281
290
282
291
expected_message = "NaN is not supported in datablocks."
283
- assert expected_message in str (error .value )
292
+ assert expected_message in str (error .value )
0 commit comments