Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions qiskit_nature/second_q/operators/sparse_label_op.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
qiskit-terra>=0.22.*
qiskit-terra>=0.23.*
scipy>=1.4
numpy>=1.17
psutil>=5
Expand Down
6 changes: 5 additions & 1 deletion test/second_q/operators/test_sparse_label_op.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"):
Expand Down