This is an automated email from the ASF dual-hosted git repository.
guanmingchiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/mahout.git
The following commit(s) were added to refs/heads/main by this push:
new ac5e58017 fix: parameter validation to detect partially bound
parameters (#792)
ac5e58017 is described below
commit ac5e58017b64cc2f3c1254cb0a6e3d1e455835d5
Author: Ryan Huang <[email protected]>
AuthorDate: Mon Jan 5 12:53:54 2026 +0800
fix: parameter validation to detect partially bound parameters (#792)
* fix: parameter validation to detect partially bound parameters
* pre-commit
---
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 f926da40b..f5135ecd3 100644
--- a/qumat/qumat.py
+++ b/qumat/qumat.py
@@ -300,7 +300,7 @@ class QuMat:
}
# 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 1187d9d20..66b88cbeb 100644
--- a/testing/test_parameter_binding.py
+++ b/testing/test_parameter_binding.py
@@ -204,3 +204,19 @@ class TestParameterBinding:
# 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})