diff --git a/src/ert/libres_facade.py b/src/ert/libres_facade.py index 56555a57aa4..7c3a1e24bce 100644 --- a/src/ert/libres_facade.py +++ b/src/ert/libres_facade.py @@ -128,12 +128,6 @@ def load_from_forward_model( realisations: npt.NDArray[np.bool_], iteration: Optional[int] = None, ) -> int: - if iteration is not None: - warnings.warn( - "The iteration argument has no effect, iteration is read from ensemble", - DeprecationWarning, - stacklevel=1, - ) t = time.perf_counter() run_args = create_run_arguments( Runpaths( diff --git a/tests/unit_tests/test_load_forward_model.py b/tests/unit_tests/test_load_forward_model.py index 706ec11a0fb..dc0c78ec9d7 100644 --- a/tests/unit_tests/test_load_forward_model.py +++ b/tests/unit_tests/test_load_forward_model.py @@ -10,6 +10,7 @@ from ert.config import ErtConfig from ert.enkf_main import create_run_path from ert.libres_facade import LibresFacade +from ert.run_arg import create_run_arguments from ert.storage import open_storage @@ -281,3 +282,54 @@ def test_that_the_states_are_set_correctly(): facade.load_from_forward_model(new_ensemble, realizations, 0) assert not new_ensemble.is_initalized() assert new_ensemble.has_data() + + +@pytest.mark.parametrize("iter", [None, 0, 1, 2, 3]) +@pytest.mark.usefixtures("use_tmpdir") +def test_loading_from_any_available_iter(storage, run_paths, run_args, iter): + config_text = dedent( + """ + NUM_REALIZATIONS 1 + GEN_DATA RESPONSE RESULT_FILE:response.out INPUT_FORMAT:ASCII + """ + ) + Path("config.ert").write_text(config_text, encoding="utf-8") + + ert_config = ErtConfig.from_file("config.ert") + prior_ensemble = storage.create_ensemble( + storage.create_experiment( + responses=ert_config.ensemble_config.response_configuration + ), + name="prior", + ensemble_size=ert_config.model_config.num_realizations, + iteration=iter if iter is not None else 0, + ) + + run_args = create_run_arguments( + run_paths(ert_config), + [True] * ert_config.model_config.num_realizations, + prior_ensemble, + iter, + ) + create_run_path( + run_args, + prior_ensemble, + ert_config, + run_paths(ert_config), + ) + run_path = Path( + f"simulations/realization-0/iter-{iter if iter is not None else 0}/" + ) + with open(run_path / "response.out", "w", encoding="utf-8") as fout: + fout.write("\n".join(["1", "2", "3"])) + with open(run_path / "response.out_active", "w", encoding="utf-8") as fout: + fout.write("\n".join(["1", "0", "1"])) + + facade = LibresFacade.from_config_file("config.ert") + facade.load_from_forward_model(prior_ensemble, [True], iter) + assert list( + prior_ensemble.load_responses("RESPONSE", (0,)) + .to_dataframe() + .dropna() + .values.flatten() + ) == [1.0, 3.0]