From 348319522821758e0fb40379743713c1c1e583cf Mon Sep 17 00:00:00 2001 From: Chris Kerr Date: Wed, 11 Dec 2013 11:48:15 +0000 Subject: [PATCH] "control/V" and "control/V/mA" are different No longer forcing them both to "control/V/mA" --- BioLogic.py | 11 ++++++++--- tests/test_BioLogic.py | 17 +++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/BioLogic.py b/BioLogic.py index 4b9935e..ce4bef6 100644 --- a/BioLogic.py +++ b/BioLogic.py @@ -22,14 +22,13 @@ def fieldname_to_dtype(fieldname): elif fieldname in ("ox/red", "error", "control changes", "Ns changes", "counter inc."): return (fieldname, np.bool_) - elif fieldname in ("time/s", "Ewe/V", "P/W", "(Q-Qo)/mA.h", "x"): + elif fieldname in ("time/s", "Ewe/V", "P/W", "(Q-Qo)/mA.h", "x", + "control/V", "control/V/mA"): return (fieldname, np.float_) elif fieldname in ("dq/mA.h", "dQ/mA.h"): return ("dQ/mA.h", np.float_) elif fieldname in ("I/mA", "/mA"): return ("I/mA", np.float_) - elif fieldname in ("control/V", "control/V/mA"): - return ("control/V/mA", np.float_) else: raise ValueError("Invalid column header: %s" % fieldname) @@ -65,6 +64,9 @@ def MPTfile(file_or_path): ["mode", "ox/red", "error", "control changes", "Ns changes", "counter inc.", "time/s", "control/V/mA", "Ewe/V", "dq/mA.h", "P/W", "/mA", "(Q-Qo)/mA.h", "x"], + ['mode', 'ox/red', 'error', 'control changes', 'Ns changes', + 'counter inc.', 'time/s', 'control/V', 'Ewe/V', 'dq/mA.h', + '/mA', '(Q-Qo)/mA.h', 'x'], ["mode", "ox/red", "error", "control changes", "Ns changes", "counter inc.", "time/s", "control/V", "Ewe/V", "I/mA", "dQ/mA.h", "P/W"], @@ -113,6 +115,9 @@ def MPTfileCSV(file_or_path): ["mode", "ox/red", "error", "control changes", "Ns changes", "counter inc.", "time/s", "control/V/mA", "Ewe/V", "dq/mA.h", "P/W", "/mA", "(Q-Qo)/mA.h", "x"], + ['mode', 'ox/red', 'error', 'control changes', 'Ns changes', + 'counter inc.', 'time/s', 'control/V', 'Ewe/V', 'dq/mA.h', + '/mA', '(Q-Qo)/mA.h', 'x'], ["mode", "ox/red", "error", "control changes", "Ns changes", "counter inc.", "time/s", "control/V", "Ewe/V", "I/mA", "dQ/mA.h", "P/W"], diff --git a/tests/test_BioLogic.py b/tests/test_BioLogic.py index d4d0273..0acc9aa 100644 --- a/tests/test_BioLogic.py +++ b/tests/test_BioLogic.py @@ -56,10 +56,10 @@ def test_open_MPR2(): def test_open_MPR3(): - mpr2 = MPRfile(os.path.join(testdata_dir, 'bio-logic3.mpr')) + mpr = MPRfile(os.path.join(testdata_dir, 'bio-logic3.mpr')) ## Check the dates as a basic test that it has been read properly - eq_(mpr2.startdate, date(2013, 3, 27)) - eq_(mpr2.enddate, date(2013, 3, 27)) + eq_(mpr.startdate, date(2013, 3, 27)) + eq_(mpr.enddate, date(2013, 3, 27)) @raises(ValueError) @@ -86,9 +86,14 @@ def assert_MPR_matches_MPT(mpr, mpt): mpt["time/s"], decimal=5) # 5 digits in CSV - assert_array_almost_equal(mpr.data["control/V/mA"], - mpt["control/V/mA"], - decimal=6) # 32 bit float precision + if "control/V/mA" in mpt.dtype.fields: + assert_array_almost_equal(mpr.data["control/V/mA"], + mpt["control/V/mA"], + decimal=6) # 32 bit float precision + if "control/V" in mpt.dtype.fields: + assert_array_almost_equal(mpr.data["control/V"], + mpt["control/V"], + decimal=6) # 32 bit float precision assert_array_almost_equal(mpr.data["Ewe/V"], mpt["Ewe/V"],