Skip to content

Commit

Permalink
Fix RawFeatureVector (#654)
Browse files Browse the repository at this point in the history
* fix rawfeaturevector

* fix rawfeaturevector

* Update qiskit_machine_learning/circuit/library/raw_feature_vector.py

Co-authored-by: Julien Gacon <[email protected]>

* fix imports

* add reno

* add reno

---------

Co-authored-by: Julien Gacon <[email protected]>
  • Loading branch information
adekusar-drl and Cryoris authored Jun 8, 2023
1 parent d1a7457 commit a7c5c7b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
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
6 changes: 6 additions & 0 deletions releasenotes/notes/fix-rawfeaturevector-742a68224ddb1b9d.yaml
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.

0 comments on commit a7c5c7b

Please sign in to comment.