Skip to content

Commit

Permalink
electrochem: Add 65 to understood I_range values. (#133)
Browse files Browse the repository at this point in the history
* test files

* Fix issue 61 by adding 65 to known I ranges (10 A).

* forgot the test file.

* fix raise -> assert to silence the linter
  • Loading branch information
PeterKraus committed Dec 13, 2023
1 parent 096c8b5 commit 2e02ac7
Show file tree
Hide file tree
Showing 6 changed files with 685 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/yadg/parsers/electrochem/eclabcommon/techniques.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,7 @@ def technique_params(technique: str, settings: list[str]) -> tuple[str, list]:
("100 mA", 38, 1e-1),
("10 mA", 39, 1e-2),
("1 mA", 40, 1e-3),
("10 A", 65, 1e1),
("Auto", None, None),
),
"Is_unit": (
Expand Down
31 changes: 31 additions & 0 deletions tests/test_electrochem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

import numpy as np
import pytest
import xarray
from pathlib import Path

import yadg.extractors
from tests.utils import (
datagram_from_file,
datagram_from_input,
Expand Down Expand Up @@ -599,3 +602,31 @@ def test_electrochem_tomato(infile, ts, datadir):
ret = datagram_from_file(infile, datadir)
standard_datagram_test(ret, ts)
pars_datagram_test(ret, ts)


@pytest.mark.parametrize(
"infile, outfile",
[
("issue_61_Irange_65.mpr", "issue_61.nc"),
("issue_61_Irange_65.mpt", "issue_61.nc"),
],
)
def test_electrochem_bugs(infile, outfile, datadir):
os.chdir(datadir)
if infile.endswith("mpr"):
filetype = "biologic-mpr"
elif infile.endswith("mpt"):
filetype = "biologic-mpt"
else:
assert False, "unknown filetype"
ret = yadg.extractors.extract(filetype=filetype, path=Path(infile))
ref = xarray.open_dataset(outfile, engine="h5netcdf")
# ret.to_netcdf(outfile, engine="h5netcdf")
assert ret["uts"].equals(ref["uts"])
for k in ret.data_vars:
if k.endswith("_std_err"):
continue
elif ret[k].dtype.kind in {"O", "S", "U"}:
assert ret[k].equals(ref[k])
else:
np.testing.assert_allclose(ret[k], ref[k], equal_nan=True)
Binary file added tests/test_electrochem/issue_61.nc
Binary file not shown.
Loading

0 comments on commit 2e02ac7

Please sign in to comment.