qiskit-algorithms
qiskit-algorithms copied to clipboard
Improve typing
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.
- [ ] Typing around
np.ndarray
vsSequence[float]
. It is a known issue that tomypy
the numpy arrays do not satisfy theSequence
type. This leads to many type ignore statements right now which can hopefully be improved upon.- [ ] For example, typing around parameter values being passed on to the primitives: sometimes its
Sequence[float]
, sometimes itsSequence[Sequence[float]]
, and oftentimes internally it ends up asnp.ndarray
causing many type ignore comments
- [ ] For example, typing around parameter values being passed on to the primitives: sometimes its
- [ ] The typing of the
initial_point
attributes is very inconsistent across its various occurrences. - [ ] The
Minimizer
interface does not appear to be supported properly byVQD
andPVQD
(for example) since they do not provide the requiredjac
argument - [ ] The
ListOrDict
type is causing quite some oddities. This has multiple cases:- [ ] for the
metadata
(e.g.variance
) types and implementations are inconsistent with the variance sometimes wrapped in dictionaries and sometimes provided as a single number - [ ] for
aux_operators
and/orobservables
we had to add many type ignores which would need to be re-evaluated (possibly linked to the previous point)
- [ ] for the
- [ ] All classes that use the
EsimationProblem
have very poor typing around the following points:- [ ] the
post_processing
function - [ ] the confidence intervals
- [ ] the
circuit_results
- [ ] the
- [ ] Add py.typed file back again - removed by #121