Skip to content

Commit 44a9616

Browse files
committed
Remove redundant validation
These properties are already validated in validate_general_input
1 parent 809028a commit 44a9616

2 files changed

Lines changed: 1 addition & 59 deletions

File tree

src/semeio/fmudesign/config_validation.py

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44

55
import copy
6-
import numbers
76
from enum import StrEnum
87
from typing import Any
98

@@ -37,15 +36,6 @@ def validate_configuration(
3736
"""
3837
config = copy.deepcopy(config)
3938

40-
if config["designtype"] != "onebyone":
41-
raise ValueError(
42-
"Generation of DesignMatrix only implemented for type 'onebyone', "
43-
f"not {config['designtype']}"
44-
)
45-
46-
if "repeats" not in config:
47-
raise LookupError('"repeats" must be specified in general input sheet')
48-
4939
key = "correlation_iterations"
5040
if key not in config:
5141
if verbosity > 0:
@@ -60,29 +50,6 @@ def validate_configuration(
6050
f" If desired correlation does not match observed, try setting {key!r}=999 or higher." # ruff: ignore[line-too-long]
6151
)
6252
config[key] = 0
63-
else:
64-
try:
65-
config[key] = int(config[key])
66-
except (ValueError, TypeError) as err:
67-
raise ValueError(
68-
f"{key!r} must be a non-negative integer, got: {config[key]}"
69-
) from err
70-
71-
key = "distribution_seed"
72-
if key not in config:
73-
raise ValueError(
74-
"You did not specify a value for 'distribution_seed', which is used to "
75-
"seed the random number generator that draws from distributions in Monte "
76-
"Carlo sensitivities.\n"
77-
"- Specify a number (e.g. a 6 digit integer) to seed the random number "
78-
"generator and obtain reproducible results.\n"
79-
"- Specify None if you do not want to seed the random number generator. "
80-
"Your analysis will not be reproducible."
81-
)
82-
if not (isinstance(config[key], numbers.Integral) or (config[key] is None)):
83-
raise ValueError(
84-
f"{key!r} must be a non-negative integer or None, got: {config[key]}"
85-
)
8653

8754
# 'seed_strategy' controls how Monte Carlo samples are seeded.
8855
# See the SeedStrategy docstring for what each strategy means.
@@ -92,13 +59,7 @@ def validate_configuration(
9259
value = value.strip().lower()
9360
if value is None or value == "none":
9461
value = SeedStrategy.JOINT
95-
try:
96-
config[key] = SeedStrategy(value)
97-
except (ValueError, TypeError) as err:
98-
raise ValueError(
99-
f"{key!r} must be one of {[s.value for s in SeedStrategy]}, "
100-
f"got: {config[key]}"
101-
) from err
62+
config[key] = SeedStrategy(value)
10263

10364
# 'seeds' here is 'rms_seeds' in the input. It can be either:
10465
# - 'default' => gives seed numbers 1000, 1001, 1002, ...

tests/fmudesign/test_config_validation.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,6 @@ def test_seed_strategy_is_normalized_to_enum_member():
2626
assert cfg["seed_strategy"] == "independent"
2727

2828

29-
def test_seed_strategy_invalid_raises():
30-
with pytest.raises(ValueError, match="seed_strategy"):
31-
validate_configuration(_minimal_config(seed_strategy="bogus"))
32-
33-
34-
@pytest.mark.parametrize("value", [["independent"], {"joint": 1}, 5, 1.5])
35-
def test_seed_strategy_non_string_raises_value_error(value):
36-
"""Unsupported types must be rejected as validation errors, not TypeErrors."""
37-
with pytest.raises(ValueError, match="seed_strategy"):
38-
validate_configuration(_minimal_config(seed_strategy=value))
39-
40-
41-
@pytest.mark.parametrize("value", ["Independent", "INDEPENDENT", " independent "])
42-
def test_seed_strategy_is_case_and_whitespace_insensitive(value):
43-
"""Excel auto-capitalizes cell text, so 'Independent' must be accepted."""
44-
cfg = validate_configuration(_minimal_config(seed_strategy=value))
45-
assert cfg["seed_strategy"] is SeedStrategy.INDEPENDENT
46-
47-
4829
@pytest.mark.parametrize("value", [None, "None"])
4930
def test_seed_strategy_none_falls_back_to_joint(value):
5031
cfg = validate_configuration(_minimal_config(seed_strategy=value))

0 commit comments

Comments
 (0)