From 0e8c91154b6ddb709706802c0d60624398d82956 Mon Sep 17 00:00:00 2001 From: Nicolas Vetsch Date: Fri, 7 Oct 2022 09:53:01 +0200 Subject: [PATCH] WAIT technique bugfix (#88) * Bugfix * Properly defaulting E_range * Testing Co-authored-by: Nicolas Vetsch --- src/yadg/parsers/electrochem/eclabmpr.py | 4 +++- src/yadg/parsers/electrochem/eclabmpt.py | 4 +++- tests/test_electrochem.py | 26 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/yadg/parsers/electrochem/eclabmpr.py b/src/yadg/parsers/electrochem/eclabmpr.py index 251e27a8..fd33e616 100644 --- a/src/yadg/parsers/electrochem/eclabmpr.py +++ b/src/yadg/parsers/electrochem/eclabmpr.py @@ -768,7 +768,9 @@ def _process_modules(contents: bytes) -> tuple[dict, list, list, dict, dict]: Eranges = [] Iranges = [] for el in params: - Eranges.append(el["E_range_max"] - el["E_range_min"]) + E_range_max = el.get("E_range_max", float("inf")) + E_range_min = el.get("E_range_min", float("-inf")) + Eranges.append(E_range_max - E_range_min) Iranges.append(el.get("I_range", "Auto")) elif name == "VMP data": data = _process_data(module_data, header["version"], Eranges, Iranges) diff --git a/src/yadg/parsers/electrochem/eclabmpt.py b/src/yadg/parsers/electrochem/eclabmpt.py index 14ff7188..d84b386c 100644 --- a/src/yadg/parsers/electrochem/eclabmpt.py +++ b/src/yadg/parsers/electrochem/eclabmpt.py @@ -312,7 +312,9 @@ def process( Eranges = [] Iranges = [] for el in params: - Eranges.append(el["E_range_max"] - el["E_range_min"]) + E_range_max = el.get("E_range_max", float("inf")) + E_range_min = el.get("E_range_min", float("-inf")) + Eranges.append(E_range_max - E_range_min) Iranges.append(el.get("I_range", "Auto")) data = _process_data(data_lines, Eranges, Iranges) # Arrange all the data into the correct format. diff --git a/tests/test_electrochem.py b/tests/test_electrochem.py index 7038b074..d9ff6590 100644 --- a/tests/test_electrochem.py +++ b/tests/test_electrochem.py @@ -378,6 +378,32 @@ def test_datagram_from_eclab(input, ts, datadir): pars_datagram_test(ret, ts) +@pytest.mark.parametrize( + "input, ts", + [ + ( + { # ts0 - wait.mpr + "case": "wait.mpr", + "encoding": "windows-1252", + "parameters": {"filetype": "eclab.mpr"}, + }, + "ca_data.json", + ), + ( + { # ts1 - wait.mpt + "case": "wait.mpt", + "encoding": "windows-1252", + "parameters": {"filetype": "eclab.mpt"}, + }, + "ca_data.json", + ), + ], +) +def test_datagram_wait_technique(input, ts, datadir): + ret = datagram_from_input(input, "electrochem", datadir) + assert not ret["steps"][0]["data"], "No data should be present." + + @pytest.mark.parametrize( "input, refpath", [