Skip to content

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented May 22, 2025

Summary

To fix CI. I tested the changes on a couple of machines 1 with 3.9 the other 3.12 and it seems to pass checks locally.

Fixes #917

Details and comments

  1. There was a unit test failure around shape. See Nightly tests failing around sparse COO #917 so I added shape parameter explicitly to COO. This had been noted in a deprecation warning that shape would become required and did so in the lastest sparse which is where things broke. It still works with the earlier sparse versions where its optional.

  2. There are several mypy failures as below. These do not show up in 3.9 and my first attempt was to add a type: ignore comment for the incompatible type ones which passed under 3.12 but under 3.9 gave error: Unused "type: ignore" comment [unused-ignore] as it does not fail under the older mypy which is still in use by 3.9. Given the code works, though I guess the newer mypy notes the type differences from what it sees to start with being assigned to what is done to the same variable later I simply added an Any type to the variable which passes mypy now under 3.9 and 3.12 since it allows all (any) types.

For the pegagos_svc failure I cast the return of the algorithm_globals.random.integers call to an int type so as to avoid the later use of it in the get being unable to match appropriately.

qiskit_machine_learning/optimizers/aqgd.py:170: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[Any]] | ndarray[tuple[int, ...], dtype[float64]]", variable has type "list[ndarray[tuple[int, ...], dtype[Any]] | ndarray[tuple[int, ...], dtype[float64]]]")  [assignment]
qiskit_machine_learning/optimizers/adam_amsgrad.py:187: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[Any]]", variable has type "ndarray[tuple[int], dtype[float64]]")  [assignment]
qiskit_machine_learning/optimizers/adam_amsgrad.py:189: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[Any]]", variable has type "ndarray[tuple[int], dtype[float64]]")  [assignment]
qiskit_machine_learning/optimizers/adam_amsgrad.py:190: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[Any]]", variable has type "ndarray[tuple[int], dtype[float64]]")  [assignment]
qiskit_machine_learning/optimizers/adam_amsgrad.py:216: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[float64]]", variable has type "ndarray[tuple[int], dtype[float64]]")  [assignment]
qiskit_machine_learning/optimizers/adam_amsgrad.py:217: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[float64]]", variable has type "ndarray[tuple[int], dtype[float64]]")  [assignment]
qiskit_machine_learning/optimizers/adam_amsgrad.py:219: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[float64]]", variable has type "ndarray[tuple[int], dtype[float64]]")  [assignment]
qiskit_machine_learning/optimizers/adam_amsgrad.py:234: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[Any]]", variable has type "ndarray[tuple[int], dtype[float64]]")  [assignment]
qiskit_machine_learning/neural_networks/effective_dimension.py:177: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[float64]]", variable has type "ndarray[tuple[int, int, int], dtype[float64]]")  [assignment]
qiskit_machine_learning/neural_networks/effective_dimension.py:178: error: Incompatible types in assignment (expression has type "ndarray[tuple[int, ...], dtype[float64]]", variable has type "ndarray[tuple[int, int], dtype[float64]]")  [assignment]
qiskit_machine_learning/algorithms/classifiers/pegasos_qsvc.py:198: error: Argument 1 to "_compute_weighted_kernel_sum" of "PegasosQSVC" has incompatible type "signedinteger[_64Bit]"; expected "int"  [arg-type]
qiskit_machine_learning/algorithms/classifiers/pegasos_qsvc.py:202: error: Invalid index type "signedinteger[_64Bit]" for "dict[int, int]"; expected type "int"  [index]
qiskit_machine_learning/algorithms/classifiers/pegasos_qsvc.py:202: error: No overload variant of "get" of "dict" matches argument types "signedinteger[_64Bit]", "int"  [call-overload]
qiskit_machine_learning/algorithms/classifiers/pegasos_qsvc.py:202: note: Possible overload variants:
qiskit_machine_learning/algorithms/classifiers/pegasos_qsvc.py:202: note:     def get(self, int, /) -> int
qiskit_machine_learning/algorithms/classifiers/pegasos_qsvc.py:202: note:     def get(self, int, int, /) -> int
qiskit_machine_learning/algorithms/classifiers/pegasos_qsvc.py:202: note:     def [_T] get(self, int, _T, /) -> int | _T

This is an automatic backport of pull request #919 done by [Mergify](https://mergify.com).

* Fix CI for mypy and add explicit shape for COO

* Fix style

(cherry picked from commit 4b918b0)
@edoaltamura edoaltamura merged commit 50ff3bd into stable/0.8 May 22, 2025
15 checks passed
@edoaltamura edoaltamura deleted the mergify/bp/stable/0.8/pr-919 branch May 22, 2025 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants