# IMPORTS #################################################################### from __future__ import absolute_import from builtins import bytes import numpy as np import instruments as ik from instruments.tests import expected_protocol, make_name_test # TESTS ###################################################################### # pylint: disable=protected-access test_tektds224_name = make_name_test(ik.tektronix.TekTDS224) def test_tektds224_data_width(): with expected_protocol(ik.tektronix.TekTDS224, ["DATA:WIDTH?", "DATA:WIDTH 1"], ["2"]) as tek: assert tek.data_width == 2 tek.data_width = 1 def test_tektds224_data_source(): with expected_protocol(ik.tektronix.TekTDS224, ["DAT:SOU?", "DAT:SOU MATH"], ["CH1"]) as tek: assert tek.data_source == ik.tektronix.tektds224._TekTDS224Channel( tek, 0) tek.data_source = tek.math
""" Module containing tests for generic SCPI function generator instruments """ # IMPORTS #################################################################### from __future__ import absolute_import import quantities as pq import instruments as ik from instruments.tests import expected_protocol, make_name_test # TESTS ###################################################################### test_scpi_func_gen_name = make_name_test(ik.generic_scpi.SCPIFunctionGenerator) def test_scpi_func_gen_amplitude(): with expected_protocol(ik.generic_scpi.SCPIFunctionGenerator, [ "VOLT:UNIT?", "VOLT?", "VOLT:UNIT VPP", "VOLT 2.0", "VOLT:UNIT DBM", "VOLT 1.5" ], ["VPP", "+1.000000E+00"], repeat=2) as fg: assert fg.amplitude == (1 * pq.V, fg.VoltageMode.peak_to_peak) fg.amplitude = 2 * pq.V fg.amplitude = (1.5 * pq.V, fg.VoltageMode.dBm) assert fg.channel[0].amplitude == (1 * pq.V, fg.VoltageMode.peak_to_peak) fg.channel[0].amplitude = 2 * pq.V
""" # IMPORTS #################################################################### import pytest import instruments as ik from instruments.abstract_instruments.comm import GPIBCommunicator from instruments.units import ureg as u from instruments.tests import expected_protocol, make_name_test, unit_eq # TESTS ###################################################################### # pylint: disable=no-member,protected-access test_srsdg645_name = make_name_test(ik.srs.SRSDG645) # CHANNELS # def test_srsdg645_channel_init(): """ _SRSDG645Channel: Ensure correct errors are raised during initialization if not coming from a DG class. """ with pytest.raises(TypeError): ik.srs.srsdg645._SRSDG645Channel(42, 0) def test_srsdg645_channel_init_channel_value(): """
# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ## ## IMPORTS #################################################################### import instruments as ik from instruments.tests import expected_protocol, make_name_test, unit_eq import cStringIO as StringIO import quantities as pq import numpy as np ## TESTS ###################################################################### test_scpi_multimeter_name = make_name_test(ik.generic_scpi.SCPIMultimeter) def test_scpi_multimeter_mode(): with expected_protocol( ik.generic_scpi.SCPIMultimeter, [ "CONF?", "CONF:CURR:AC" ] , [ "FRES +1.000000E+01,+3.000000E-06" ] ) as dmm: assert dmm.mode == dmm.Mode.fourpt_resistance dmm.mode = dmm.Mode.current_ac def test_scpi_multimeter_trigger_mode():
from hypothesis import ( given, strategies as st, ) import numpy as np import pytest import instruments as ik from instruments.tests import expected_protocol, make_name_test # TESTS ####################################################################### # pylint: disable=protected-access test_tekdpo4104_name = make_name_test(ik.tektronix.TekDPO4104) # INSTRUMENT # def test_data_source(): """Get / set data source for waveform transfer.""" with expected_protocol( ik.tektronix.TekDPO4104, [ "DAT:SOU CH1", # set a string "DAT:SOU?", "DAT:SOU REF2", # set value of an enum "DAT:SOU?", "DAT:SOU MATH", # set a math channel "DAT:SOU?"
""" Module containing tests for generic SCPI function generator instruments """ # IMPORTS #################################################################### from __future__ import absolute_import import quantities as pq import instruments as ik from instruments.tests import expected_protocol, make_name_test # TESTS ###################################################################### test_scpi_func_gen_name = make_name_test(ik.agilent.Agilent33220a) def test_agilent33220a_amplitude(): with expected_protocol(ik.agilent.Agilent33220a, [ "VOLT:UNIT?", "VOLT?", "VOLT:UNIT VPP", "VOLT 2.0", "VOLT:UNIT DBM", "VOLT 1.5" ], ["VPP", "+1.000000E+00"]) as fg: assert fg.amplitude == (1 * pq.V, fg.VoltageMode.peak_to_peak) fg.amplitude = 2 * pq.V fg.amplitude = (1.5 * pq.V, fg.VoltageMode.dBm) def test_agilent33220a_frequency(): with expected_protocol(ik.agilent.Agilent33220a, ["FREQ?", "FREQ 1.005000e+02"],
""" Module containing tests for generic SCPI function generator instruments """ # IMPORTS #################################################################### from __future__ import absolute_import import quantities as pq import instruments as ik from instruments.tests import expected_protocol, make_name_test # TESTS ###################################################################### test_scpi_func_gen_name = make_name_test(ik.agilent.Agilent33220a) def test_agilent33220a_amplitude(): with expected_protocol( ik.agilent.Agilent33220a, [ "VOLT:UNIT?", "VOLT?", "VOLT:UNIT VPP", "VOLT 2.0", "VOLT:UNIT DBM", "VOLT 1.5" ], [ "VPP", "+1.000000E+00"
""" Module containing tests for generic SCPI function generator instruments """ # IMPORTS #################################################################### from __future__ import absolute_import import quantities as pq import instruments as ik from instruments.tests import expected_protocol, make_name_test # TESTS ###################################################################### test_scpi_func_gen_name = make_name_test(ik.generic_scpi.SCPIFunctionGenerator) def test_scpi_func_gen_amplitude(): with expected_protocol( ik.generic_scpi.SCPIFunctionGenerator, [ "VOLT:UNIT?", "VOLT?", "VOLT:UNIT VPP", "VOLT 2.0", "VOLT:UNIT DBM", "VOLT 1.5" ], [ "VPP", "+1.000000E+00"
# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ## ## IMPORTS #################################################################### import instruments as ik from instruments.tests import expected_protocol, make_name_test, unit_eq import cStringIO as StringIO import quantities as pq import numpy as np ## TESTS ###################################################################### test_scpi_multimeter_name = make_name_test(ik.hp.HP6632b) def test_hp6632b_display_textmode(): with expected_protocol( ik.hp.HP6632b, [ "DISP:MODE?", "DISP:MODE TEXT" ] , [ "NORM" ] ) as psu: assert psu.display_textmode == False psu.display_textmode = True def test_hp6632b_display_text():
Module containing tests for the Rigol DS1000 """ # IMPORTS #################################################################### import numpy as np import pytest import instruments as ik from instruments.tests import expected_protocol, make_name_test # TESTS ###################################################################### # pylint: disable=protected-access test_rigolds1000_name = make_name_test(ik.rigol.RigolDS1000Series) # TEST CHANNEL # def test_channel_initialization(): """Ensure correct initialization of channel object.""" with expected_protocol(ik.rigol.RigolDS1000Series, [], []) as osc: channel = osc.channel[0] assert channel._parent is osc assert channel._idx == 1 def test_channel_coupling(): """Get / set channel coupling.""" with expected_protocol(ik.rigol.RigolDS1000Series,
# IMPORTS #################################################################### from __future__ import absolute_import from builtins import bytes import numpy as np import instruments as ik from instruments.tests import expected_protocol, make_name_test # TESTS ###################################################################### # pylint: disable=protected-access test_tektds224_name = make_name_test(ik.tektronix.TekTDS224) def test_tektds224_data_width(): with expected_protocol( ik.tektronix.TekTDS224, [ "DATA:WIDTH?", "DATA:WIDTH 1" ], [ "2" ] ) as tek: assert tek.data_width == 2 tek.data_width = 1
import instruments as ik from instruments.optional_dep_finder import numpy from instruments.tests import ( expected_protocol, iterable_eq, make_name_test, ) # TESTS ####################################################################### # pylint: disable=protected-access test_tektds5xx_name = make_name_test(ik.tektronix.TekTDS5xx) # MEASUREMENT # @pytest.mark.parametrize("msr", [it for it in range(3)]) def test_measurement_init(msr): """Initialize a new measurement.""" meas_categories = ['enabled', 'type', 'units', 'src1', 'src2', 'edge1', 'edge2', 'dir'] meas_return = "0;UNDEFINED;\"V\",CH1,CH2,RISE,RISE,FORWARDS" data_expected = dict(zip(meas_categories, meas_return.split(';'))) with expected_protocol( ik.tektronix.TekTDS5xx, [
Module containing tests for generic SCPI instruments """ # IMPORTS #################################################################### from hypothesis import given, strategies as st import pytest from instruments.units import ureg as u import instruments as ik from instruments.tests import expected_protocol, make_name_test, unit_eq # TESTS ###################################################################### test_scpi_multimeter_name = make_name_test(ik.generic_scpi.SCPIInstrument) def test_scpi_instrument_scpi_version(): """Get name of instrument.""" retval = "12345" with expected_protocol(ik.generic_scpi.SCPIInstrument, ["SYST:VERS?"], [f"{retval}"]) as inst: assert inst.scpi_version == retval @pytest.mark.parametrize("retval", ("0", "1")) def test_scpi_instrument_op_complete(retval): """Check if operation is completed.""" with expected_protocol(ik.generic_scpi.SCPIInstrument, ["*OPC?"], [f"{retval}"]) as inst:
# # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ## ## IMPORTS #################################################################### import instruments as ik from instruments.tests import expected_protocol, make_name_test, unit_eq from cStringIO import StringIO import quantities as pq ## TESTS ###################################################################### test_srsdg645_name = make_name_test(ik.srs.SRSDG645) def test_srsdg645_output_level(): """ SRSDG645: Checks getting/setting unitful ouput level. """ with expected_protocol(ik.srs.SRSDG645, [ "LAMP? 1", "LAMP 1,4.0", ], [ "3.2" ] ) as ddg: unit_eq(ddg.output['AB'].level_amplitude, pq.Quantity(3.2, "V")) ddg.output['AB'].level_amplitude = 4.0
Module containing tests for Agilent 34410a """ # IMPORTS #################################################################### import pytest import instruments as ik from instruments.optional_dep_finder import numpy from instruments.tests import (expected_protocol, iterable_eq, make_name_test, unit_eq) from instruments.units import ureg as u # TESTS ###################################################################### test_agilent_34410a_name = make_name_test(ik.agilent.Agilent34410a) def test_agilent34410a_read(): with expected_protocol( ik.agilent.Agilent34410a, ["CONF?", "READ?"], ["VOLT +1.000000E+01,+3.000000E-06", "+1.86850000E-03"]) as dmm: unit_eq(dmm.read_meter(), +1.86850000E-03 * u.volt) def test_agilent34410a_data_point_count(): with expected_protocol(ik.agilent.Agilent34410a, [ "DATA:POIN?", ], [ "+215", ]) as dmm:
""" Module containing tests for generic SCPI multimeter instruments """ # IMPORTS #################################################################### from __future__ import absolute_import import quantities as pq import instruments as ik from instruments.tests import expected_protocol, make_name_test, unit_eq # TESTS ###################################################################### test_scpi_multimeter_name = make_name_test(ik.generic_scpi.SCPIMultimeter) def test_scpi_multimeter_mode(): with expected_protocol(ik.generic_scpi.SCPIMultimeter, ["CONF?", "CONF:CURR:AC"], ["FRES +1.000000E+01,+3.000000E-06"]) as dmm: assert dmm.mode == dmm.Mode.fourpt_resistance dmm.mode = dmm.Mode.current_ac def test_scpi_multimeter_trigger_mode(): with expected_protocol(ik.generic_scpi.SCPIMultimeter, ["TRIG:SOUR?", "TRIG:SOUR EXT"], ["BUS"]) as dmm: assert dmm.trigger_mode == dmm.TriggerMode.bus dmm.trigger_mode = dmm.TriggerMode.external
# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ## ## IMPORTS #################################################################### import instruments as ik from instruments.tests import expected_protocol, make_name_test, unit_eq import cStringIO as StringIO import quantities as pq import numpy as np ## TESTS ###################################################################### test_agilent_34410a_name = make_name_test(ik.agilent.Agilent34410a) def test_agilent34410a_read(): with expected_protocol( ik.agilent.Agilent34410a, [ "CONF?", "READ?" ] , [ "VOLT +1.000000E+01,+3.000000E-06", "+1.86850000E-03" ] ) as dmm: unit_eq(dmm.read(), +1.86850000E-03 * pq.volt) def test_agilent34410a_data_point_count():
# along with this program. If not, see <http://www.gnu.org/licenses/>. ## ## IMPORTS #################################################################### import instruments as ik from instruments.tests import expected_protocol, make_name_test, unit_eq from cStringIO import StringIO import quantities as pq from nose.tools import raises ## TESTS ###################################################################### test_cc1_name = make_name_test(ik.qubitekk.CC1) @raises(IOError) def test_cc1_unknown_command(): """ CC1: Checks that invalid commands are properly turned into exceptions. """ with expected_protocol(ik.qubitekk.CC1, [ "FTN" ], [ "Unknown command" ] ) as cc1: cc1.sendcmd("FTN")
from hypothesis import ( given, strategies as st, ) import pytest import instruments as ik from instruments.optional_dep_finder import numpy from instruments.tests import expected_protocol, make_name_test from instruments.units import ureg as u # TESTS ####################################################################### # pylint: disable=protected-access test_tekawg2000_name = make_name_test(ik.tektronix.TekAWG2000) # CHANNEL # channels_to_try = range(2) channels_to_try_id = [f"CH{it}" for it in channels_to_try] @pytest.mark.parametrize("channel", channels_to_try, ids=channels_to_try_id) def test_channel_init(channel): """Channel initialization.""" with expected_protocol(ik.tektronix.TekAWG2000, [], []) as inst: assert inst.channel[channel]._tek is inst assert inst.channel[channel]._name == f"CH{channel + 1}" assert inst.channel[channel]._old_dsrc is None
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. ## ## IMPORTS #################################################################### import instruments as ik from instruments.tests import expected_protocol, make_name_test, unit_eq from cStringIO import StringIO import quantities as pq from nose.tools import raises ## TESTS ###################################################################### test_cc1_name = make_name_test(ik.qubitekk.CC1) @raises(IOError) def test_cc1_unknown_command(): """ CC1: Checks that invalid commands are properly turned into exceptions. """ with expected_protocol(ik.qubitekk.CC1, ["FTN"], ["Unknown command"]) as cc1: cc1.sendcmd("FTN")