From 36f56c15b03cded7d866d4912c8d4c94525f28bf Mon Sep 17 00:00:00 2001 From: "Kevin J. Sung" Date: Wed, 11 Jan 2023 09:12:43 -0500 Subject: [PATCH 1/6] use allow_unknown_parameters in SparseLabelOp.assign_parameters --- qiskit_nature/second_q/operators/sparse_label_op.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/qiskit_nature/second_q/operators/sparse_label_op.py b/qiskit_nature/second_q/operators/sparse_label_op.py index 88fbfb9fad..619f943275 100644 --- a/qiskit_nature/second_q/operators/sparse_label_op.py +++ b/qiskit_nature/second_q/operators/sparse_label_op.py @@ -1,6 +1,6 @@ # This code is part of Qiskit. # -# (C) Copyright IBM 2022. +# (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory @@ -511,11 +511,7 @@ def assign_parameters(self, parameters: Mapping[ParameterExpression, _TCoeff]) - A new operator with the parameters assigned. """ data = { - # TODO use this line once - # https://github.com/Qiskit/qiskit-terra/pull/9304 - # is merged: - # key: value.bind(parameters, allow_unknown_parameters=True) - key: value.bind({k: v for k, v in parameters.items() if k in value.parameters}) + key: value.bind(parameters, allow_unknown_parameters=True) if isinstance(value, ParameterExpression) else value for key, value in self._data.items() From d8cdce27d73bbaadba24a45d20449c94394473dd Mon Sep 17 00:00:00 2001 From: "Kevin J. Sung" Date: Mon, 16 Jan 2023 10:18:17 -0500 Subject: [PATCH 2/6] add test --- test/second_q/operators/test_sparse_label_op.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/second_q/operators/test_sparse_label_op.py b/test/second_q/operators/test_sparse_label_op.py index 6ddf8c15b7..5303fc3262 100644 --- a/test/second_q/operators/test_sparse_label_op.py +++ b/test/second_q/operators/test_sparse_label_op.py @@ -426,6 +426,10 @@ def test_assign_parameters(self): assigned_op = op.assign_parameters({a: 1}) self.assertEqual(assigned_op, DummySparseLabelOp({"+_0 -_1": 2, "+_1 -_0": b})) + op = DummySparseLabelOp({"+_0 -_1": a + 1}) + assigned_op = op.assign_parameters({b: 1}) + self.assertEqual(assigned_op, op) + def test_round(self): """test round function""" with self.subTest("round just real part"): From fa09fed6efd215137a8245acca8bcddd1921845a Mon Sep 17 00:00:00 2001 From: "Kevin J. Sung" Date: Mon, 16 Jan 2023 10:31:52 -0500 Subject: [PATCH 3/6] make the copyright checker happy --- test/second_q/operators/test_sparse_label_op.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/second_q/operators/test_sparse_label_op.py b/test/second_q/operators/test_sparse_label_op.py index 5303fc3262..3d810be6ee 100644 --- a/test/second_q/operators/test_sparse_label_op.py +++ b/test/second_q/operators/test_sparse_label_op.py @@ -1,6 +1,6 @@ # This code is part of Qiskit. # -# (C) Copyright IBM 2022. +# (C) Copyright IBM 2022, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory From 618a4bdbbc90343fa177565379afbd23bd840efa Mon Sep 17 00:00:00 2001 From: "Kevin J. Sung" Date: Tue, 17 Jan 2023 11:05:27 -0500 Subject: [PATCH 4/6] update requirements.txt to qiskit-terra 0.23 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ac3563ac74..54b2f1dc51 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -qiskit-terra>=0.22.* +qiskit-terra>=0.23.* scipy>=1.4 numpy>=1.17 psutil>=5 From 9e86fe6aa5bf4ba1fdfdd64430b3f5e454b39e3a Mon Sep 17 00:00:00 2001 From: "Kevin J. Sung" Date: Tue, 17 Jan 2023 11:18:46 -0500 Subject: [PATCH 5/6] update requirements.txt to github qiskit-terra --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 54b2f1dc51..e1377b8bd2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -qiskit-terra>=0.23.* +git+https://github.com/Qiskit/qiskit-terra@main#egg=qiskit-terra scipy>=1.4 numpy>=1.17 psutil>=5 From 5da14986fd7e35c75118337e2e174ce14e84ff3d Mon Sep 17 00:00:00 2001 From: "Kevin J. Sung" Date: Wed, 18 Jan 2023 09:01:11 -0500 Subject: [PATCH 6/6] change requirements.txt to qiskit-terra 0.23 again Co-authored-by: Max Rossmannek --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e1377b8bd2..54b2f1dc51 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -git+https://github.com/Qiskit/qiskit-terra@main#egg=qiskit-terra +qiskit-terra>=0.23.* scipy>=1.4 numpy>=1.17 psutil>=5