Skip to content

Commit

Permalink
merge changes from remote
Browse files Browse the repository at this point in the history
  • Loading branch information
MAfarrag committed Jan 14, 2025
2 parents 1b372cd + 7ec7450 commit c231f1b
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions tests/dflowfm/bc/test_forcing_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path

import numpy as np
import pytest
from pydantic.v1.error_wrappers import ValidationError
Expand All @@ -15,7 +16,7 @@
QHTable,
QuantityUnitPair,
TimeInterpolation,
TimeSeries
TimeSeries,
)
from tests.utils import assert_files_equal

Expand All @@ -27,6 +28,7 @@ def quantityunitpair(quantity, unit, verticalpositionindex=None):
quantity=quantity, unit=unit, vertpositionindex=verticalpositionindex
)


def harmonic_values(iscorrection: bool):
function = "harmonic-correction" if iscorrection else "harmonic"
return dict(
Expand All @@ -43,6 +45,7 @@ def harmonic_values(iscorrection: bool):
],
)


def qhtable_values():
return dict(
name="boundary_qhtable",
Expand Down Expand Up @@ -73,6 +76,7 @@ def constant_values():
],
)


def astronomic_values(iscorrection: bool, quantityunitpair):
function = "astronomic-correction" if iscorrection else "astronomic"
return dict(
Expand Down Expand Up @@ -120,7 +124,7 @@ def test_parses_function_case_insensitive(self, input, expected):
],
)
def test_create_forcingbase_missing_field_raises_correct_error(
self, missing_field: str
self, missing_field: str
):
values = dict(
name="Boundary2",
Expand All @@ -143,13 +147,13 @@ def test_create_forcingbase_missing_field_raises_correct_error(
[
(["time", "dischargebnd"], "m³/s"),
(
["time", "dischargebnd", "extra"],
["minutes since 2021-01-01 00:00:00", "m³/s"],
["time", "dischargebnd", "extra"],
["minutes since 2021-01-01 00:00:00", "m³/s"],
),
],
)
def test_create_forcingbase_mismatch_number_of_quantities_units_raises_correct_error(
self, quantities, units
self, quantities, units
):
values = dict(
name="Boundary2",
Expand All @@ -172,7 +176,10 @@ class TestForcingModel:
"""

def test_forcing_model(self, input_files_dir):
filepath = input_files_dir / "e02/f101_1D-boundaries/c01_steady-state-flow/BoundaryConditions.bc"
filepath = (
input_files_dir
/ "e02/f101_1D-boundaries/c01_steady-state-flow/BoundaryConditions.bc"
)

m = ForcingModel(filepath)
assert len(m.forcing) == 13
Expand All @@ -192,7 +199,9 @@ def test_read_bc_missing_field_raises_correct_error(self, invalid_data_dir):
assert expected_message1 in str(error.value)
assert expected_message2 in str(error.value)

def test_save_forcing_model(self, time_series_values, t3d_values, output_files_dir, reference_files_dir):
def test_save_forcing_model(
self, time_series_values, t3d_values, output_files_dir, reference_files_dir
):
bc_file = output_files_dir / TEST_BC_FILE
reference_file = reference_files_dir / "bc" / TEST_BC_FILE
forcingmodel = ForcingModel()
Expand Down Expand Up @@ -221,7 +230,7 @@ def test_save_forcing_model(self, time_series_values, t3d_values, output_files_d

@pytest.mark.parametrize("cls", [Astronomic, AstronomicCorrection])
def test_astronomic_values_with_strings_in_datablock_are_parsed_correctly(
self, cls
self, cls
):
try:
is_correction = cls == AstronomicCorrection
Expand Down Expand Up @@ -280,4 +289,4 @@ def test_forcing_model_with_datablock_that_has_nan_values_should_raise_error(sel
)

expected_message = "NaN is not supported in datablocks."
assert expected_message in str(error.value)
assert expected_message in str(error.value)

0 comments on commit c231f1b

Please sign in to comment.