From 97e5291e3e258e98c644774c75678e500414fddc Mon Sep 17 00:00:00 2001 From: Hsien-Cheng Huang Date: Mon, 5 Jan 2026 02:36:33 +0000 Subject: [PATCH 1/2] fix: parameter validation to detect partially bound parameters --- qumat/qumat.py | 2 +- testing/test_parameter_binding.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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..cc13d00bca 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}) \ No newline at end of file From d044d53ca081192e232e707ccefd2f2a83a01ce8 Mon Sep 17 00:00:00 2001 From: Hsien-Cheng Huang Date: Mon, 5 Jan 2026 02:39:55 +0000 Subject: [PATCH 2/2] pre-commit --- testing/test_parameter_binding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/test_parameter_binding.py b/testing/test_parameter_binding.py index cc13d00bca..66b88cbeb0 100644 --- a/testing/test_parameter_binding.py +++ b/testing/test_parameter_binding.py @@ -219,4 +219,4 @@ def test_partially_bound_parameters_error(self, backend_name): # 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}) \ No newline at end of file + qumat.execute_circuit(parameter_values={"theta0": math.pi})