diff --git a/qumat/qumat.py b/qumat/qumat.py index f926da40b2..f5135ecd3a 100644 --- a/qumat/qumat.py +++ b/qumat/qumat.py @@ -300,7 +300,7 @@ def execute_circuit(self, parameter_values=None): } # Check if there are unbound parameters in the circuit - if self.parameters and not bound_parameters: + if self.parameters and len(bound_parameters) < len(self.parameters): unbound_params = [ p for p in self.parameters.keys() if self.parameters[p] is None ] diff --git a/testing/test_parameter_binding.py b/testing/test_parameter_binding.py index 1187d9d207..66b88cbeb0 100644 --- a/testing/test_parameter_binding.py +++ b/testing/test_parameter_binding.py @@ -204,3 +204,19 @@ def test_unbound_parameter_error(self, backend_name): # Should raise ValueError with clear message with pytest.raises(ValueError, match="unbound parameters"): qumat.execute_circuit() + + @pytest.mark.parametrize("backend_name", TESTING_BACKENDS) + def test_partially_bound_parameters_error(self, backend_name): + """Test that partially bound parameters raise an error across all backends.""" + backend_config = get_backend_config(backend_name) + qumat = QuMat(backend_config) + qumat.create_empty_circuit(num_qubits=2) + + # Apply multiple parameterized gates + qumat.apply_rx_gate(0, "theta0") + qumat.apply_ry_gate(1, "phi1") + + # Bind only one parameter, leaving the other unbound + # This should raise ValueError + with pytest.raises(ValueError, match="unbound parameters"): + qumat.execute_circuit(parameter_values={"theta0": math.pi})