mirror of
https://github.com/echemdata/galvani.git
synced 2025-12-14 01:15:34 +00:00
Add loop_from_file and timestamp_from_file functions
to extract loop_index and timestamp from the temporary _LOOP.txt and .mpl files during MPRfile initialization Added unit tests but cannot upload test files due to LFS quota exceeded Edited by Chris Kerr to fix flake8 warnings and resolve my comments from the original PR https://github.com/echemdata/galvani/pull/102
This commit is contained in:
@@ -358,3 +358,25 @@ def test_MPR_matches_MPT_v1150(testdata_dir, basename_v1150):
|
||||
mpr = MPRfile(binpath)
|
||||
mpt, comments = MPTfile(txtpath, encoding="latin1")
|
||||
assert_MPR_matches_MPT_v2(mpr, mpt, comments)
|
||||
|
||||
|
||||
def test_loop_from_file(testdata_dir):
|
||||
"""Check if the loop_index is correctly extracted from the _LOOP.txt file
|
||||
"""
|
||||
mpr = MPRfile(os.path.join(testdata_dir, "running", "running_OCV.mpr"))
|
||||
if mpr.loop_index is None:
|
||||
raise AssertionError("No loop_index found")
|
||||
elif not len(mpr.loop_index) == 4:
|
||||
raise AssertionError("loop_index is not the right size")
|
||||
elif not (mpr.loop_index == [0, 4, 8, 11]).all():
|
||||
raise AssertionError("loop_index values are wrong")
|
||||
|
||||
|
||||
def test_timestamp_from_file(testdata_dir):
|
||||
"""Check if the loop_index is correctly extracted from the _LOOP.txt file
|
||||
"""
|
||||
mpr = MPRfile(os.path.join(testdata_dir, "running", "running_OCV.mpr"))
|
||||
if not hasattr(mpr, "timestamp"):
|
||||
raise AssertionError("No timestamp found")
|
||||
elif not mpr.timestamp.timestamp() == 1707299985.908:
|
||||
raise AssertionError("timestamp value is wrong")
|
||||
|
||||
Reference in New Issue
Block a user