File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
qiskit_machine_learning/circuit/library Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 1
1
# This code is part of a Qiskit project.
2
2
#
3
- # (C) Copyright IBM 2020, 2023 .
3
+ # (C) Copyright IBM 2020, 2024 .
4
4
#
5
5
# This code is licensed under the Apache License, Version 2.0. You may
6
6
# obtain a copy of this license in the LICENSE.txt file in the root directory
@@ -176,7 +176,8 @@ def _define(self):
176
176
raise QiskitError ("Cannot define a ParameterizedInitialize with unbound parameters" )
177
177
178
178
# 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
180
181
181
182
circuit = QuantumCircuit (self .num_qubits )
182
183
circuit .initialize (normalized , range (self .num_qubits ))
You can’t perform that action at this time.
0 commit comments