qiskit-community / qiskit-algorithms

A library of quantum algorithms for Qiskit.
https://qiskit-community.github.io/qiskit-algorithms/
Apache License 2.0
116 stars 59 forks source link

Improve typing #74

Open mrossinek opened 1 year ago

mrossinek commented 1 year ago

What should we add?

While working on #73, @ElePT and I have identified the following inconsistencies and/or problems around the type hints which should be investigated further. Rather than holding up that PR unnecessarily, we decided to gather these here. That way, they can be investigated one-by-one.

Note: some of these may very likely require code changes to resolve inconsistencies in the interfaces.

woodsp-ibm commented 1 year ago

The Estimation logic - and possible elsewhere - has code that is no longer used. While deprecated code for QI/opflow was removed there are some util like functions taking types that would have been an outcome - this code is now untested.

Also Grover has some issue around using the circuit passed a as grover operator - it allows QuatumCircuit but then treats it as GroverOperator where it unconditionally accesses an attribute that has which is not present on a QuantumCircuit. Update: I raised #76 for this.

This was just from starting to look at mypy in AA and AE folders.

mrossinek commented 1 year ago

I suppose a good strategy at finding which of the code is unused would be to look at the coverage reports. Obviously not all uncovered lines can be removed but it might be a good starting point :+1:

woodsp-ibm commented 1 year ago

Yes, particularly around the algos AE, Grover and Phase Estimation that were modified to add Sampler logic paths to the existing code and whether more could/should have been removed when QI paths were removed that was part of common utilities.