File tree Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Original file line number Diff line number Diff line change 11# This code is part of a Qiskit project.
22#
3- # (C) Copyright IBM 2022, 2024 .
3+ # (C) Copyright IBM 2022, 2025 .
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
@@ -233,7 +233,9 @@ def _run_unique(
233233 gradient .imag = results [partial_sum_n + n // 2 : partial_sum_n + n ]
234234
235235 else :
236- gradient = np .real (results [partial_sum_n : partial_sum_n + n ])
236+ gradient = np .real (
237+ results [partial_sum_n : partial_sum_n + n ]
238+ ) # type: ignore[assignment, unused-ignore]
237239 partial_sum_n += n
238240 gradients .append (gradient )
239241
Original file line number Diff line number Diff line change @@ -62,16 +62,20 @@ def __init__(
6262 """
6363
6464 # Store arguments
65- self ._weight_samples = None
66- self ._input_samples = None
67- self ._num_weight_samples = 1
68- self ._num_input_samples = 1
65+ self ._weight_samples = np . asarray ([ 0.25 ])
66+ self ._input_samples = np . asarray ([ 0.5 ])
67+ self ._num_weight_samples = len ( self . _weight_samples )
68+ self ._num_input_samples = len ( self . _input_samples )
6969 self ._model = qnn
7070
71- # Define weight samples and input samples
72- self .weight_samples = weight_samples # type: ignore
73- # input setter uses self._model
74- self .input_samples = input_samples # type: ignore
71+ # Setup things for weight and input samples via setters that deal
72+ # with the union of types that can be passed so that the private
73+ # vars above that have just been set with temp values of right types
74+ # to establish typing, get the right values per what was passed.
75+ # Note, the samples ones above had been set to None but this results
76+ # in errors when checking using mypy 1.16.0
77+ self .weight_samples = weight_samples
78+ self .input_samples = input_samples
7579
7680 @property
7781 def weight_samples (self ) -> np .ndarray :
Original file line number Diff line number Diff line change 11# This code is part of a Qiskit project.
22#
3- # (C) Copyright IBM 2019, 2024 .
3+ # (C) Copyright IBM 2019, 2025 .
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
@@ -91,7 +91,7 @@ def optimal_value(self) -> float | None:
9191 return self ._optimal_value
9292
9393 @optimal_value .setter
94- def optimal_value (self , value : int ) -> None :
94+ def optimal_value (self , value : float ) -> None :
9595 """Sets optimal value"""
9696 self ._optimal_value = value
9797
You can’t perform that action at this time.
0 commit comments