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

Specify key type of EdgeSettings.qn_domains and NodeSettings.qn_domains #281

Closed
redeboer opened this issue Aug 9, 2024 · 3 comments · Fixed by #292
Closed

Specify key type of EdgeSettings.qn_domains and NodeSettings.qn_domains #281

redeboer opened this issue Aug 9, 2024 · 3 comments · Fixed by #292
Assignees
Labels
⚙️ Enhancement Improvements and optimizations of existing features ❔ Question Discuss this matter in the team
Milestone

Comments

@redeboer
Copy link
Member

redeboer commented Aug 9, 2024

The key of qn_domains in NodeSettings and EdgeSettings can be typed with an alias like EdgeQuantumNumber instead of Any, see #278 (comment)). So the type would be something like:

EdgeQuantumNumberType = Union[
    type[EdgeQuantumNumbers.pid],
    type[EdgeQuantumNumbers.mass],
    type[EdgeQuantumNumbers.width],
    ...
    type[EdgeQuantumNumbers.g_parity],
]
NodeQuantumNumberType = Union[
    type[NodeQuantumNumbers.l_magnitude],
    ...
]
@redeboer redeboer added ❔ Question Discuss this matter in the team ⚙️ Enhancement Improvements and optimizations of existing features labels Aug 9, 2024
@redeboer redeboer added this to the 0.10.3 milestone Aug 9, 2024
@redeboer
Copy link
Member Author

redeboer commented Aug 9, 2024

As an aside: all of this indicates that the decision to type everything with complicated NewType classes etc was a bad one. Issues like #280 suggest typing everything with TypedDict instead (so based on the name of the key rather than the key type itself).

@redeboer redeboer removed their assignment Aug 14, 2024
@grayson-helmholz
Copy link
Contributor

Has been implemented in the remove_spin-projections_in_cons-rules-branch. Issue should be closeable after merging.

@redeboer
Copy link
Member Author

We'll have to do a bit more probably ;) There are a lot of places where Any should be replaced with EdgeQuantumNumberType/NodeQuantumNumberType.

Btw, for lower Python <3.9, use from typing import Type instead of type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙️ Enhancement Improvements and optimizations of existing features ❔ Question Discuss this matter in the team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants