Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RawFeatureVector #654

Merged
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
12 changes: 9 additions & 3 deletions qiskit_machine_learning/circuit/library/raw_feature_vector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2020, 2022.
# (C) Copyright IBM 2020, 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 All @@ -15,7 +15,13 @@
from typing import Optional, List
import numpy as np
from qiskit.exceptions import QiskitError
from qiskit.circuit import QuantumRegister, QuantumCircuit, ParameterVector, Instruction
from qiskit.circuit import (
QuantumRegister,
QuantumCircuit,
ParameterVector,
Instruction,
ParameterExpression,
)
from qiskit.circuit.library import BlueprintCircuit


Expand Down Expand Up @@ -164,7 +170,7 @@ def _define(self):
# cast ParameterExpressions that are fully bound to numbers
cleaned_params = []
for param in self.params:
if len(param.parameters) == 0:
if not isinstance(param, ParameterExpression) or len(param.parameters) == 0:
cleaned_params.append(complex(param))
else:
raise QiskitError("Cannot define a ParameterizedInitialize with unbound parameters")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Updated :class:`~qiskit_machine_learning.circuit.library.RawFeatureVector` to support
`changes <https://github.com/Qiskit/qiskit-terra/pull/10183>`__ in the parameter assignment
introduced in Qiskit.