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 1
1
# This code is part of a Qiskit project.
2
2
#
3
- # (C) Copyright IBM 2022, 2024 .
3
+ # (C) Copyright IBM 2022, 2025 .
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
@@ -233,7 +233,9 @@ def _run_unique(
233
233
gradient .imag = results [partial_sum_n + n // 2 : partial_sum_n + n ]
234
234
235
235
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]
237
239
partial_sum_n += n
238
240
gradients .append (gradient )
239
241
Original file line number Diff line number Diff line change @@ -62,16 +62,20 @@ def __init__(
62
62
"""
63
63
64
64
# 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 )
69
69
self ._model = qnn
70
70
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
75
79
76
80
@property
77
81
def weight_samples (self ) -> np .ndarray :
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 2019, 2024 .
3
+ # (C) Copyright IBM 2019, 2025 .
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
@@ -91,7 +91,7 @@ def optimal_value(self) -> float | None:
91
91
return self ._optimal_value
92
92
93
93
@optimal_value .setter
94
- def optimal_value (self , value : int ) -> None :
94
+ def optimal_value (self , value : float ) -> None :
95
95
"""Sets optimal value"""
96
96
self ._optimal_value = value
97
97
You can’t perform that action at this time.
0 commit comments