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 for failing test case #838

Merged
merged 2 commits into from
Oct 9, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2020, 2023.
# (C) Copyright IBM 2020, 2024.
#
# 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 @@ -176,7 +176,8 @@ def _define(self):
raise QiskitError("Cannot define a ParameterizedInitialize with unbound parameters")

# normalize
normalized = np.array(cleaned_params) / np.linalg.norm(cleaned_params)
norm = np.linalg.norm(cleaned_params)
normalized = cleaned_params if np.isclose(norm, 1) else cleaned_params / norm

circuit = QuantumCircuit(self.num_qubits)
circuit.initialize(normalized, range(self.num_qubits))
Expand Down