Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add early check for training set definition #95

Merged
merged 8 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/flownet/ahm/_run_ahm.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ def _find_training_set_fraction(
training_set_fraction = 1.0

if config.flownet.training_set_end_date is not None:
if config.flownet.training_set_fraction is not None:
print(
"\nTraining set fraction and training set end date are both defined in config file.\n"
"The input given for training set fraction will be ignored.\n"
"The training set end date will be used to calculate the training set fraction.\n"
)
if (
not schedule.get_first_date()
<= config.flownet.training_set_end_date
Expand Down
8 changes: 7 additions & 1 deletion src/flownet/config_parser/_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def create_schema(_to_abs_path) -> Dict:
MK.Type: types.NamedDict,
MK.Content: {
"scheme": {MK.Type: types.String, MK.Default: "global"},
"datum_depth": {MK.Type: types.Number},
"datum_depth": {MK.Type: types.Number, MK.AllowNone: True},
"datum_pressure": {
MK.Type: types.NamedDict,
MK.Content: {
Expand Down Expand Up @@ -518,4 +518,10 @@ def _to_abs_path(path: Optional[str]) -> str:
):
raise ValueError(f"The input case {suffix} file does not exist")

if config.flownet.training_set_end_date and config.flownet.training_set_fraction:
raise ValueError(
"Ambiguous configuration input: 'training_set_fraction' and 'training_set_end_date' are "
"both defined in the configuration file."
)

return config
1 change: 0 additions & 1 deletion tests/configs/norne_parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ flownet:
random_seed: 999
perforation_handling_strategy: bottom_point
fast_pyscal: True
training_set_fraction: 0.7 # Fraction of observations (from 0 to 1) to use as training data
training_set_end_date: 2005-01-31 #YYYY-MM-DD. If defined training set fraction is calculated from this date
fault_tolerance: 0.1

Expand Down