def test_offset_methods(): """Test methods for finding the voltage+current offsets.""" param = params.copy() # param['debug'] = True dciv_data = np.genfromtxt('tests/exp-data/dciv-data.csv', **csv_param) # Automatic for voltage and current offset param['voffset_range'] = 1e-3 _, _, dc0 = iv.dciv_curve(dciv_data, **param) param['voffset_range'] = (-0.8e-3, 1e-3) _, _, dc1 = iv.dciv_curve(dciv_data, **param) # Set voltage offset param['voffset'] = dc1.offset[0] _, _, dc2 = iv.dciv_curve(dciv_data, **param) # Set both param['ioffset'] = dc1.offset[1] _, _, dc3 = iv.dciv_curve(dciv_data, **param) # Check values assert abs(dc0.offset[0] - dc1.offset[0]) < 0.01e-3 assert abs(dc0.offset[0] - dc2.offset[0]) < 0.01e-3 assert abs(dc0.offset[0] - dc3.offset[0]) < 0.01e-3 assert abs(dc1.offset[1] - dc2.offset[1]) < 1e-6 assert abs(dc1.offset[1] - dc3.offset[1]) < 1e-6 # Load pumped I-V curve with both voffset and ioffset defined pump_data = np.genfromtxt('tests/exp-data/f230_0_iv.csv', **csv_param) pump = iv.iv_curve(pump_data, dc3, **param)
def test_try_importing_reflected_iv_data(): dciv_data = np.genfromtxt('tests/exp-data/dciv-data.csv', **csv_param) dciv_data.flags.writeable = False v1, i1, dc1 = iv.dciv_curve(dciv_data, **params) v2, i2, dc2 = iv.dciv_curve(dciv_data[::-1, :], **params) assert abs(dc1.vgap - dc2.vgap) < 0.05e-3
def test_vgap_methods(): """Test methods for finding Vgap.""" # Method 1: Vgap is where the current passes _, _, dc1 = iv.dciv_curve('tests/exp-data/dciv-data.csv', **params) # Method 2: Vgap is where the derivative is the highest tmp = params.copy() tmp['vgap_threshold'] = None _, _, dc2 = iv.dciv_curve('tests/exp-data/dciv-data.csv', **tmp) # Both methods should be within 0.05 mV assert abs(dc1.vgap - dc2.vgap) < 0.05e-3
def test_dciv_importing_bad_units(): tmp = params.copy() tmp['i_fmt'] = 'A' _, _, dc = iv.dciv_curve('tests/exp-data/dciv-data.csv', **tmp) assert dc.rn < 1
def test_dciv_importing_bad_units(): tmp = params.copy() tmp['i_fmt'] = 'A' dciv_data = np.genfromtxt('tests/exp-data/dciv-data.csv', **csv_param) _, _, dc = iv.dciv_curve(dciv_data, **tmp) assert dc.rn < 1
def test_vgap(): """Test method for finding Vgap.""" param = params.copy() # param['debug'] = True # Method 1: Vgap is where the current passes dciv_data = np.genfromtxt('tests/exp-data/dciv-data.csv', **csv_param) _, _, dc1 = iv.dciv_curve(dciv_data, **param) # Both methods should be within 0.05 mV assert abs(dc1.vgap - 2.715e-3) < 0.05e-3
def test_try_loading_list(): """Try loading a list (not an accepted input type).""" with pytest.raises(AssertionError): _, _, _ = iv.dciv_curve([1, 2, 3])