def test_tc200_pid(): with expected_protocol( ik.thorlabs.TC200, ["pid?", "pgain=2"], ["pid?", "2 0 220", "> pgain=2", "> "], sep="\r" ) as tc: assert tc.p == 2 tc.p = 2 with expected_protocol( ik.thorlabs.TC200, ["pid?", "igain=0"], ["pid?", "2 0 220", "> igain=0", "> "], sep="\r" ) as tc: assert tc.i == 0 tc.i = 0 with expected_protocol( ik.thorlabs.TC200, ["pid?", "dgain=220"], ["pid?", "2 0 220", "> dgain=220", "> "], sep="\r" ) as tc: assert tc.d == 220 tc.d = 220 with expected_protocol( ik.thorlabs.TC200, ["pid?", "pgain=2", "igain=0", "dgain=220"], ["pid?", "2 0 220", "> pgain=2", "> igain=0", "> dgain=220", "> "], sep="\r", ) as tc: assert tc.pid == [2, 0, 220] tc.pid = (2, 0, 220)
def test_tektds224_data_source_read_waveform(): with expected_protocol( ik.tektronix.TekTDS224, [ "DAT:SOU?", "DAT:SOU CH2", "DAT:ENC RIB", "DATA:WIDTH?", "CURVE?", "WFMP:CH2:YOF?", "WFMP:CH2:YMU?", "WFMP:CH2:YZE?", "WFMP:XZE?", "WFMP:XIN?", "WFMP:CH2:NR_P?", "DAT:SOU CH1" ], [ "CH1", "2", # pylint: disable=no-member "#210" + bytes.fromhex("00000001000200030004").decode("utf-8") + "0", "1", "0", "0", "1", "5" ] ) as tek: data = np.array([0, 1, 2, 3, 4]) (x, y) = tek.channel[1].read_waveform() assert (x == data).all() assert (y == data).all()
def test_relative_set_wrong_type(): with expected_protocol( ik.keithley.Keithley2182, [], [] ) as inst: inst.relative = "derp"
def test_measure_invalid_mode(): with expected_protocol( ik.keithley.Keithley2182, [], [] ) as inst: inst.measure("derp")
def test_lcc25_extern_invalid_type(): with expected_protocol( ik.thorlabs.LCC25, [], [] ) as lcc: lcc.extern = "blo"
def test_lcc25_remote_invalid_type(): with expected_protocol( ik.thorlabs.LCC25, [], [] ) as lcc: lcc.remote = "blo"
def test_tc200_remote_invalid_type(): with expected_protocol( ik.thorlabs.LCC25, [], [] ) as tc: tc.remote = "blo"
def test_tc200_degrees(): with expected_protocol( ik.thorlabs.TC200, [ "stat?", "stat?", "stat?", "unit=c", "unit=f", "unit=k" ], [ "stat?", "44 > stat?", "54 > stat?", "0 > unit=c", "> unit=f", "> unit=k", "> " ], sep="\r" ) as tc: assert str(tc.degrees).split(" ")[1] == "K" assert str(tc.degrees).split(" ")[1] == "degC" assert tc.degrees == pq.degF tc.degrees = pq.degC tc.degrees = pq.degF tc.degrees = pq.degK
def test_read_data_buffer_invalid_mode(): with expected_protocol( ik.srs.SRS830, [], [] ) as inst: _ = inst.read_data_buffer(channel=inst.Mode.x)
def test_set_offset_expand_invalid_offset(): with expected_protocol( ik.srs.SRS830, [], [] ) as inst: inst.set_offset_expand(mode=inst.Mode.x, offset=106, expand=1)
def test_data_snap_invalid_snap_mode2(): with expected_protocol( ik.srs.SRS830, [], [] ) as inst: _ = inst.data_snap(mode1=inst.Mode.x, mode2=inst.Mode.ynoise)
def test_set_offset_expand_invalid_type_expand(): with expected_protocol( ik.srs.SRS830, [], [] ) as inst: inst.set_offset_expand(mode=inst.Mode.x, offset=0, expand="derp")
def test_take_measurement(): with expected_protocol( ik.srs.SRS830, [ "REST", "SRAT 4", "SEND 0", "FAST 2", "STRD", "PAUS", "SPTS?", "SPTS?", "TRCA?1,0,2", "SPTS?", "TRCA?2,0,2" ], [ "2", "2", "1.234,5.678", "2", "0.456,5.321" ] ) as inst: resp = inst.take_measurement(sample_rate=1, num_samples=2) np.testing.assert_array_equal(resp, [[1.234, 5.678], [0.456, 5.321]])
def test_take_measurement_invalid_num_samples(): with expected_protocol( ik.srs.SRS830, [], [] ) as inst: _ = inst.take_measurement(sample_rate=1, num_samples=16384)
def test_laser_correction(): with expected_protocol( ik.toptica.TopMode, [ "(param-ref 'laser1:charm:correction-status)", # 1st "(exec 'laser1:charm:start-correction-initial)", "(param-ref 'laser1:charm:correction-status)", # 2nd "(exec 'laser1:charm:start-correction)", "(param-ref 'laser1:charm:correction-status)", # 3rd "(param-ref 'laser1:charm:correction-status)", # 4th "(exec 'laser1:charm:start-correction)" ], [ "(param-ref 'laser1:charm:correction-status)", # 1st "0", "> (exec 'laser1:charm:start-correction-initial)", "()", "> (param-ref 'laser1:charm:correction-status)", # 3nd "1", "> (exec 'laser1:charm:start-correction)", "()", "> (param-ref 'laser1:charm:correction-status)", # 3rd "3", "> (param-ref 'laser1:charm:correction-status)", # 4th "2", "> (exec 'laser1:charm:start-correction)", "()", "> ", ], sep="\r\n" ) as tm: tm.laser[0].correction() tm.laser[0].correction() _ = tm.laser[0].correction_status tm.laser[0].correction()
def test_sample_rate_invalid(): with expected_protocol( ik.srs.SRS830, [], [] ) as inst: inst.sample_rate = "foobar"
def test_all_current(): with expected_protocol( ik.hp.HP6624a, [ "ISET? 1", "ISET? 2", "ISET? 3", "ISET? 4", "ISET 1,{:.1f}".format(5), "ISET 2,{:.1f}".format(5), "ISET 3,{:.1f}".format(5), "ISET 4,{:.1f}".format(5), "ISET 1,{:.1f}".format(1), "ISET 2,{:.1f}".format(2), "ISET 3,{:.1f}".format(3), "ISET 4,{:.1f}".format(4) ], [ "2", "3", "4", "5" ], sep="\n" ) as hp: assert sorted(hp.current) == sorted((2, 3, 4, 5) * pq.A) hp.current = 5 * pq.A hp.current = (1 * pq.A, 2 * pq.A, 3 * pq.A, 4 * pq.A)
def test_acknowledge(): with expected_protocol( ik.qubitekk.CC1, [ ":ACKN OF", "FIRM?", ":ACKN ON", "CLEA", ":ACKN OF", "CLEA" ], [ "", "Firmware v2.010", "CLEA", ":ACKN OF" ], sep="\n" ) as cc: assert not cc.acknowledge cc.acknowledge = True assert cc.acknowledge cc.clear_counts() cc.acknowledge = False assert not cc.acknowledge cc.clear_counts()
def test_sc10_restore(): with expected_protocol( ik.thorlabs.SC10, "resp\r", "\r1\r" ) as sc: assert sc.restore()
def test_all_voltage(): with expected_protocol( ik.hp.HP6624a, [ "VSET? 1", "VSET? 2", "VSET? 3", "VSET? 4", "VSET 1,{:.1f}".format(5), "VSET 2,{:.1f}".format(5), "VSET 3,{:.1f}".format(5), "VSET 4,{:.1f}".format(5), "VSET 1,{:.1f}".format(1), "VSET 2,{:.1f}".format(2), "VSET 3,{:.1f}".format(3), "VSET 4,{:.1f}".format(4) ], [ "2", "3", "4", "5" ], sep="\n" ) as hp: assert sorted(hp.voltage) == sorted((2, 3, 4, 5) * pq.V) hp.voltage = 5 * pq.V hp.voltage = (1 * pq.V, 2 * pq.V, 3 * pq.V, 4 * pq.V)
def test_sc10_default(): with expected_protocol( ik.thorlabs.SC10, "default\r", "\r1\r" ) as sc: assert sc.default()
def test_sc10_save_mode(): with expected_protocol( ik.thorlabs.SC10, "save\r", "\r1\r" ) as sc: assert sc.save_mode()
def test_sc10_closed(): with expected_protocol( ik.thorlabs.SC10, "closed?\r", "\r1\r" ) as sc: assert sc.closed
def test_sc10_interlock(): with expected_protocol( ik.thorlabs.SC10, "interlock?\r", "\r1\r" ) as sc: assert sc.interlock
def test_lcc25_get_settings(): with expected_protocol( ik.thorlabs.LCC25, "get=2\r", "\r>\r" ) as lcc: lcc.get_settings(2)
def test_lcc25_test_mode(): with expected_protocol( ik.thorlabs.LCC25, "test\r", "\r>\r" ) as lcc: lcc.test_mode()
def test_lcc25_default(): with expected_protocol( ik.thorlabs.LCC25, "default\r", "\r>\r" ) as lcc: lcc.default()
def test_tc200_extern_invalid_type(): with expected_protocol( ik.thorlabs.LCC25, [], [] ) as tc: tc.extern = "blo"
def test_lcc25_save(): with expected_protocol( ik.thorlabs.LCC25, "save\r", "\r>\r" ) as lcc: lcc.save()
def test_data_snap_identical_modes(): with expected_protocol( ik.srs.SRS830, [], [] ) as inst: _ = inst.data_snap(mode1=inst.Mode.x, mode2=inst.Mode.x)
def test_set_offset_expand_invalid_offset(): with expected_protocol(ik.srs.SRS830, [], []) as inst: inst.set_offset_expand(mode=inst.Mode.x, offset=106, expand=1)
def test_set_offset_expand_mode_as_str(): with expected_protocol(ik.srs.SRS830, ["OEXP 1,0,0"], []) as inst: inst.set_offset_expand(mode="x", offset=0, expand=1)
def test_set_offset_expand(): with expected_protocol(ik.srs.SRS830, ["OEXP 1,0,0"], []) as inst: inst.set_offset_expand(mode=inst.Mode.x, offset=0, expand=1)
def test_take_measurement_invalid_num_samples(): with expected_protocol(ik.srs.SRS830, [], []) as inst: _ = inst.take_measurement(sample_rate=1, num_samples=16384)
def test_tec_current(): with expected_protocol(ondax.LM, ["rti?"], ["100"], sep="\r") as lm: assert lm.tec.current == 100 * quantities.mA
def test_apc_enable_not_boolean(): with expected_protocol(ondax.LM, [], [], sep="\r") as lm: lm.apc.enabled = "foobar"
def test_auto_offset_invalid(): with expected_protocol(ik.srs.SRS830, [ "AOFF 1", ], []) as inst: inst.auto_offset(inst.Mode.theta)
def test_data_transfer(): with expected_protocol(ik.srs.SRS830, ["FAST?", "FAST 2"], [ "0", ]) as inst: assert inst.data_transfer is False inst.data_transfer = True
def test_modulation_off_time(): with expected_protocol(ondax.LM, ["stsofft?", "stsofft:20.0"], ["10", "OK"], sep="\r") as lm: assert lm.modulation.off_time == 10 * quantities.ms lm.modulation.off_time = 20 * quantities.ms
def test_apc_stop(): with expected_protocol(ondax.LM, ["cps"], ["OK"], sep="\r") as lm: lm.apc.stop()
def test_apc_enable(): with expected_protocol(ondax.LM, ["len"], ["OK"], sep="\r") as lm: lm.apc.enabled = True assert lm.apc.enabled
def test_apc_disable(): with expected_protocol(ondax.LM, ["ldis"], ["OK"], sep="\r") as lm: lm.apc.enabled = False assert not lm.apc.enabled
def test_acc_off(): with expected_protocol(ondax.LM, ["lcoff"], ["OK"], sep="\r") as lm: lm.acc.off()
def test_apc_target(): with expected_protocol(ondax.LM, ["rslp?"], ["100"], sep="\r") as lm: assert lm.apc.target == 100 * quantities.mW
def test_save(): with expected_protocol(ondax.LM, ["ssc"], ["OK"], sep="\r") as lm: lm.save()
def test_reset(): with expected_protocol(ondax.LM, ["reset"], ["OK"], sep="\r") as lm: lm.reset()
def test_status(): with expected_protocol(ondax.LM, ["rlrs?"], ["1"], sep="\r") as lm: assert lm.status == lm.Status(1)
def test_temperature(): with expected_protocol(ondax.LM, ["rtt?", "stt:40.0"], ["35", "OK"], sep="\r") as lm: assert lm.temperature == 35 * quantities.degC lm.temperature = 40 * quantities.degC
def test_power(): with expected_protocol(ondax.LM, ["rlp?", "slp:100.0"], ["120", "OK"], sep="\r") as lm: assert lm.power == 120 * quantities.mW lm.power = 100 * quantities.mW
def test_serial_number(): with expected_protocol(ondax.LM, ["rsn?"], ["B099999"], sep="\r") as lm: assert lm.serial_number == "B099999"
def test_firmware(): with expected_protocol(ondax.LM, ["rsv?"], ["3.27"], sep="\r") as lm: assert lm.firmware == "3.27"
def test_maximum_current(): with expected_protocol(ondax.LM, ["rlcm?", "smlc:100.0"], ["120", "OK"], sep="\r") as lm: assert lm.maximum_current == 120 * quantities.mA lm.maximum_current = 100 * quantities.mA
def test_tec_enable(): with expected_protocol(ondax.LM, ["tecon"], ["OK"], sep="\r") as lm: lm.tec.enabled = True assert lm.tec.enabled
def test_tec_disable(): with expected_protocol(ondax.LM, ["tecoff"], ["OK"], sep="\r") as lm: lm.tec.enabled = False assert not lm.tec.enabled
def test_auto_phase(): with expected_protocol(ik.srs.SRS830, ["APHS"], []) as inst: inst.auto_phase()
def test_tec_target(): with expected_protocol(ondax.LM, ["rstt?"], ["22"], sep="\r") as lm: assert lm.tec.target == 22 * quantities.degC
def test_init(): with expected_protocol(ik.srs.SRS830, ["REST", "SRAT 5", "SEND 1"], []) as inst: inst.init(sample_rate=2, buffer_mode=inst.BufferMode.loop)
def test_start_data_transfer(): with expected_protocol(ik.srs.SRS830, ["FAST 2", "STRD"], []) as inst: inst.start_data_transfer()
def test_auto_offset(): with expected_protocol(ik.srs.SRS830, ["AOFF 1", "AOFF 1"], []) as inst: inst.auto_offset(inst.Mode.x) inst.auto_offset("x")
def test_modulation_enable_not_boolean(): with expected_protocol(ondax.LM, [], [], sep="\r") as lm: lm.modulation.enabled = "foobar"