def test_pulse_mode(self): processor = Processor(2) processor.add_control(sigmax(), targets=0, label="sx") processor.set_coeffs({"sx": np.array([1., 2., 3.])}) processor.set_tlist({"sx": np.array([0., 1., 2., 3.])}) processor.pulse_mode = "continuous" assert (processor.pulse_mode == "continuous") assert (processor.pulses[0].spline_kind == "cubic") processor.pulse_mode = "discrete" assert (processor.pulse_mode == "discrete") assert (processor.pulses[0].spline_kind == "step_func")
def test_control_and_coeffs(self): processor = Processor(2) processor.add_control(sigmax()) processor.add_control(sigmaz()) # Set coeffs and tlist without a label coeffs = np.array([[1., 2., 3.], [3., 2., 1.]]) processor.set_coeffs(coeffs) assert_allclose(coeffs, processor.coeffs) tlist = np.array([0., 1., 2., 3.]) processor.set_tlist(tlist) assert_allclose(tlist, processor.get_full_tlist()) processor.set_tlist({0: tlist, 1: tlist}) assert_allclose(tlist, processor.get_full_tlist()) # Pulses assert (len(processor.pulses) == 2) assert (processor.find_pulse(0) == processor.pulses[0]) assert (processor.find_pulse(1) == processor.pulses[1]) with pytest.raises(KeyError): processor.find_pulse("non_exist_pulse")