Skip to content

Commit 2bc61a3

Browse files
authored
Fix RawFeatureVector for failing test case (#838)
* Alter RawFeatureVector normalization * Alter RawFeatureVector normalization
1 parent b5e1c52 commit 2bc61a3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

qiskit_machine_learning/circuit/library/raw_feature_vector.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2020, 2023.
3+
# (C) Copyright IBM 2020, 2024.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -176,7 +176,8 @@ def _define(self):
176176
raise QiskitError("Cannot define a ParameterizedInitialize with unbound parameters")
177177

178178
# normalize
179-
normalized = np.array(cleaned_params) / np.linalg.norm(cleaned_params)
179+
norm = np.linalg.norm(cleaned_params)
180+
normalized = cleaned_params if np.isclose(norm, 1) else cleaned_params / norm
180181

181182
circuit = QuantumCircuit(self.num_qubits)
182183
circuit.initialize(normalized, range(self.num_qubits))

0 commit comments

Comments
 (0)