def test_binding_parameters_does_not_change_parameters_without_free_symbols( self): theta = sympy.Symbol("theta") gate = MatrixFactoryGate("V", example_one_qubit_matrix_factory, (1, 2), 1) new_gate = gate.bind({theta: 5.0}) assert new_gate.params == (1, 2)
def test_binding_parameters_with_symbol_outside_of_free_symbols_does_not_raise( self, ): gamma, theta = sympy.symbols("gamma, theta") params = (theta, 2 * theta) gate = MatrixFactoryGate("U", example_one_qubit_matrix_factory, params, 1) new_gate = gate.bind({gamma: 0.5, theta: 1}) assert new_gate.params == (1, 2)
def test_binding_parameters_creates_new_instance_with_substituted_free_params( self): gamma, theta, x, y = sympy.symbols("gamma, theta, x, y") params = (theta, x + y) gate = MatrixFactoryGate("U", example_one_qubit_matrix_factory, params, 1) new_gate = gate.bind({theta: 0.5, x: gamma, y: 3}) assert new_gate.name == gate.name assert new_gate.matrix_factory == gate.matrix_factory assert new_gate.num_qubits == gate.num_qubits assert new_gate.params == (0.5, gamma + 3)
def test_binding_gates_in_dagger_is_propagated_to_wrapped_gate(self): theta = sympy.Symbol("theta") gate = MatrixFactoryGate("V", example_one_qubit_matrix_factory, (theta, 0), 1) assert gate.dagger.bind({theta: 0.5}) == gate.bind({theta: 0.5}).dagger