Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Nov 28, 2024
1 parent ddce418 commit aa3bcd1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ert/analysis/_es_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def _load_observations_and_responses(
else:
msg = (
f"WARNING: Could not auto-scale the observations {auto_scale_observations}. "
f"No match with existing observations {obs_keys}"
f"No match with existing active observations {obs_keys}"
)
logger.warning(msg)
print(msg)
Expand Down
4 changes: 3 additions & 1 deletion test-data/ert/poly_example/poly.ert
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ RUNPATH poly_out/realization-<IENS>/iter-<ITER>
OBS_CONFIG observations
REALIZATION_MEMORY 50mb

NUM_REALIZATIONS 100
NUM_REALIZATIONS 10
MIN_REALIZATIONS 1

ANALYSIS_SET_VAR OBSERVATIONS AUTO_SCALE *_OBs

GEN_KW COEFFS coeff_priors
GEN_DATA POLY_RES RESULT_FILE:poly.out

Expand Down
29 changes: 29 additions & 0 deletions tests/ert/unit_tests/analysis/test_es_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,35 @@ def test_that_autoscaling_applies_to_scaled_errors(storage):
assert scaled_errors_without_autoscale.tolist() == [1, 2]


def test_that_autoscaling_ignores_typos_in_observation_names(storage, caplog):
observations_and_responses = polars.DataFrame(
{
"response_key": ["RESPONSE", "RESPONSE", "RESPONSE", "RESPONSE"],
"index": ["rs00", "rs0", "rs0", "rs1"],
"observation_key": ["obs1_1", "obs1_2", "obs2", "obs2"],
"observations": polars.Series([2, 4, 3, 3], dtype=polars.Float32),
"std": polars.Series([1, 2, 1, 1], dtype=polars.Float32),
"1": polars.Series([1, 4, 7, 8], dtype=polars.Float32),
}
)

experiment = storage.create_experiment(name="dummyexp")
ensemble = experiment.create_ensemble(name="dummy", ensemble_size=10)
_mock_load_observations_and_responses(
observations_and_responses,
alpha=1,
std_cutoff=0.05,
global_std_scaling=1,
auto_scale_observations=[["OOOPS1*"]],
progress_callback=lambda _: None,
ensemble=ensemble,
)
logged_messages = str(caplog.messages) # NB: The code also prints to the terminal
assert "Could not auto-scale the observations" in logged_messages
assert "OOPS" in logged_messages
assert "obs1_1" in logged_messages


@pytest.mark.integration_test
def test_gen_data_obs_data_mismatch(storage, uniform_parameter):
resp = GenDataConfig(keys=["RESPONSE"])
Expand Down

0 comments on commit aa3bcd1

Please sign in to comment.