Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correct MitTask type #197

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

daniel-mills-cqc
Copy link
Collaborator

@daniel-mills-cqc daniel-mills-cqc commented Dec 9, 2024

Very minor change. As this change touches everything I though I would double check incase I have misunderstood something.
Is this typing the way we have used MitTask in practice?

This was all done in an effort to get

mypy tests/leakage_gadget_test.py

working.

@daniel-mills-cqc daniel-mills-cqc marked this pull request as draft December 9, 2024 12:16
]

qermit_result_list = postselection_task(
(
result_list,
postselect_mgr_list,
postselect_mgr_list, # type: ignore
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required since PostselectMgr, is not a recognised wire type. Simply adding it to the list of recognised wire types induces cyclic imports.

I don't really know what the right solution to this is...

I assume there must be a way to define a type annotation for PostselectMgr within mittask.py although I have tried and failed to do that. User defined generic types might also help -> https://docs.python.org/3/library/typing.html#user-defined-generic-types but I think that only works for python 3.12. If you happen to know how to do something like that then I would be very interested to know about that.

Another solution is to move serialised versions of PostselectMgr along wires. As far as I can tell that is the best solution, but would be some significant work.

Another solution would be to allow Any as a wire type, which I don't want to do...

Comment on lines +58 to +73
WireList = Union[
List[CircuitShots],
List[Circuit],
List[BackendResult],
List[ResultHandle],
List[AnsatzCircuit],
List[ObservableExperiment],
List[int],
List[float],
List[bool],
List[str],
List[QubitPauliOperator],
List[Dict[Qubit, Bit]],
List[Dict],
]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if there is a more succinct way of doing this. I would like Tuple[List[Wire], ...] to work but that assumes every List[Wire] in Tuple uses the same Wire.

@daniel-mills-cqc daniel-mills-cqc marked this pull request as ready for review December 9, 2024 13:32
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.

1 participant