-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/dei 35 multiply rule time dependent table (#32)
* Feat [DEI-96]: working date range table * feat[DEI-35]: fix date_range not passed along to rule * feat [DEI-35]: update tests * feat [DEI-35]: test validation utils * feat [DEI-35]: update tests multiply rule * feat [DEI-35]: update parser multiply rule tests * feat [EIT-35]: add validation for start_date before end_date * feat [DEI-35]: fix flake8 * feat [DEI-35]: fix flake8 again * feat [DEI-35]: and again flake8 * feat [DEI-35]: update from review feedback * feat [DEI-35]: update mkdocs * fix feedback comments * Added functionality for REACT to calculate Q and depth from WFLOW Added functionality for REACT to calculate Q and depth from WFLOW (this is a test application of the functionality but as the WFLOW file seems to contain lakes I don't think this approach will give a correct result -> approach needs to be refactured). --------- Co-authored-by: Marc Weeber <41464989+MPWeeber@users.noreply.github.com>
- Loading branch information
1 parent
679c6eb
commit 56b9337
Showing
15 changed files
with
585 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
@echo "Run the tests" | ||
python examples/python_test_of_functions.py | ||
python main.py examples/test_DHYDRO_DELWAQ_Online.yaml | ||
python main.py examples/test_DHYDRO_Maas.yaml | ||
python main.py examples/test_DHYDRO_Maas_Potamogeton_testcase_fuzzylogic.yaml | ||
python main.py examples/test_IMOD_Dommel.yaml | ||
@echo next one is to be considered requested functionality (different time axes) | ||
@echo 2023-05-31 10:51:46,661: ValueError: The arrays must have the same dimensions. | ||
@echo python main.py examples/test_SFINCS_beira_flood.yaml | ||
@echo | ||
python main.py examples/test_VKZM_Potamogeton_testcase_boundaries.yaml | ||
python main.py examples/test_VKZM_Potamogeton_testcase_fuzzylogic.yaml | ||
python main.py examples/test_VKZM_simple_testcase.yaml | ||
python main.py examples/test_IRM_Doesburg_IJssel_rasters.yaml | ||
python main.py examples/test_Westerschelde.yaml | ||
python main.py examples/test1_default_independent_rules.yaml | ||
python main.py examples/test2_variable_mapping.yaml | ||
@echo next one is to be considered requested functionality (error in yaml implementation, always variable mapping expected) | ||
@echo AttributeError: 'str' object has no attribute 'keys' | ||
@echo python main.py examples/test2b_variable_no_mapping.yaml | ||
@echo | ||
@echo next one is to be considered requested functionality (error in yaml implementation, always variable mapping expected) | ||
@echo 2023-05-31 10:53:25,352: ERROR Mapping towards the following variables 'mesh2d_sa1, mesh2d_s1', will create duplicates with variables in the input datasets. | ||
@echo 2023-05-31 10:53:25,352: ERROR Model "Model 1" transition from ModelStatus.VALIDATING to ModelStatus.VALIDATED has failed. | ||
@echo python main.py examples/test2c_variable_no_mapping.yaml | ||
@echo | ||
python main.py examples/test3_layer_filter_layer22.yaml | ||
python main.py examples/test3b_layer_filter_layer0.yaml | ||
python main.py examples/test3c_layer_filter_layer1.yaml | ||
@echo | ||
@echo next one is correct (expected error in model config, not existing layer) WARNING could be clearer | ||
@echo 2023-05-31 13:34:14,487: WARNING Some rules can not be resolved: test name | ||
@echo 2023-05-31 13:34:14,487: ERROR Initialization failed. | ||
@echo python main.py examples/test3d_layer_filter_not_existing_layer.yaml | ||
@echo | ||
python main.py examples/test4_depending_rules_multiply.yaml | ||
python main.py examples/test4b_depending_rules_multiply.yaml | ||
python main.py examples/test5_depending_rules_multiply_layerfilter.yaml | ||
python main.py examples/test6_combine_results_add.yaml | ||
python main.py examples/test6b_combine_results_subtract.yaml | ||
python main.py examples/test6c_combine_results_min.yaml | ||
python main.py examples/test6d_combine_results_max.yaml | ||
python main.py examples/test6e_combine_results_multiply.yaml | ||
python main.py examples/test6f_combine_results_with_nans.yaml | ||
python main.py examples/test7_time_aggregation_year.yaml | ||
python main.py examples/test7b_time_aggregation_month.yaml | ||
@echo next one is correct (expected error in model config, day is not implemented) | ||
@echo 2023-05-31 10:54:04,909: ERROR The provided time scale 'day' of rule 'test name' is not supported. | ||
@echo Please select one of the following types: month,year | ||
@echo python main.py examples/test7c_time_aggregation_day_not_existing_opp.yaml | ||
@echo | ||
@echo next one is correct (expected error in model config, popcorn is not implemented) | ||
@echo The provided time scale 'popcorn' of rule 'test name' is not supported. | ||
@echo Please select one of the following types: month,year | ||
@echo python main.py examples/test7d_time_aggregation_popcorn_not_existing_opp.yaml | ||
@echo | ||
@echo next one is correct (expected error in model config, time scale missing) | ||
@echo AttributeError: Missing element time_scale | ||
@echo python main.py examples/test7e_time_aggregation_default.yaml | ||
@echo | ||
python main.py examples/test8_stepwise_classification_waterlevel.yaml | ||
python main.py examples/test8b_stepwise_classification_salinity_limits.yaml | ||
python main.py examples/test8c_stepwise_classification_salinity_categories.yaml | ||
python main.py examples/test8d_stepwise_classification_waterlevel_lower_range.yaml | ||
python main.py examples/test9_response_curve_waterlevel.yaml | ||
@echo next one is correct (expected error in model config, data provided in wrong order) | ||
@echo 2023-05-31 10:57:54,424: ERROR The input values should be given in a sorted order. | ||
@echo 2023-05-31 10:57:54,424: ERROR Model "Model 1" transition from ModelStatus.VALIDATING to ModelStatus.VALIDATED has failed. | ||
@echo python main.py examples/test9b_response_curve_waterlevel_wrong_order.yaml | ||
@echo | ||
python main.py examples/test9c_response_curve_waterlevel_on_year.yaml | ||
python main.py examples/test10_formula_based_comparison.yaml | ||
python main.py examples/test10b_formula_based_arithmatic.yaml | ||
python main.py examples/test10c_formula_based_ifelse.yaml | ||
@echo next one is to be considered requested functionality (variable computations with missing/different time axes) | ||
@echo IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed | ||
@echo python main.py examples/test10d_formula_based_timeaxes_calculation.yaml | ||
@echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
""" | ||
Module for Validation functions | ||
""" | ||
|
||
from typing import List | ||
from datetime import datetime | ||
|
||
|
||
def validate_all_instances_number(data: List, name: str): | ||
"""Check if all instances in a list are of type int or float | ||
Args: | ||
data (List): List to check | ||
name (str): Name to give in the error message | ||
Raises: | ||
ValueError: Raise an error to define which value is incorrect | ||
""" | ||
if not all(isinstance(m, (int, float)) for m in data): | ||
message = ( | ||
f"{name} should be a list of int or floats, " | ||
f"received: {data}" | ||
) | ||
position_error = "".join( | ||
[ | ||
f"ERROR in position {index} is type {type(m)}. " | ||
for (index, m) in enumerate(data) | ||
if not isinstance(m, (int, float)) | ||
] | ||
) | ||
raise ValueError(f"{position_error}{message}") | ||
|
||
|
||
def validate_type_date(data: List[str], name: str): | ||
""" | ||
Check if all dates in list are a datestring of format: DD-MM | ||
Args: | ||
data (str): List of date strings | ||
name (str): Name of data to address in error message | ||
Raises: | ||
ValueError: Raise this error to indicate which value is not | ||
a date in the proper format. | ||
""" | ||
|
||
for (index, m) in enumerate(data): | ||
try: | ||
datetime.strptime(m, r"%d-%m") | ||
except TypeError: | ||
message = ( | ||
f"{name} should be a list of strings, " | ||
f"received: {data}. ERROR in position {index} is type {type(m)}." | ||
) | ||
raise TypeError(message) | ||
except ValueError: | ||
message = ( | ||
f"{name} should be a list of date strings with Format DD-MM, " | ||
f"received: {data}. ERROR in position {index}, string: {m}." | ||
) | ||
raise ValueError(message) | ||
|
||
|
||
def validate_start_before_end(start_list: List[str], end_list: List[str]): | ||
"""Validate if for each row in the table the start date is before the end date. | ||
Args: | ||
start_list (List[str]): list of dates | ||
end_list (List[str]): list of dates | ||
""" | ||
|
||
for (index, (start, end)) in enumerate(zip(start_list, end_list)): | ||
start_str = datetime.strptime(start, r"%d-%m") | ||
end_str = datetime.strptime(end, r"%d-%m").replace() | ||
|
||
if not start_str < end_str: | ||
message = ( | ||
f"All start dates should be before the end dates. " | ||
f"ERROR in position {index} where start: " | ||
f"{start} and end: {end}." | ||
) | ||
raise ValueError(message) |
Oops, something went wrong.