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

CouplingMap should be iterable #8863

Closed
nonhermitian opened this issue Oct 9, 2022 · 3 comments · Fixed by #9051
Closed

CouplingMap should be iterable #8863

nonhermitian opened this issue Oct 9, 2022 · 3 comments · Fixed by #9051
Labels
type: feature request New feature or request

Comments

@nonhermitian
Copy link
Contributor

What should we add?

BackendV2 objects return a CouplingMap object as the coupling_map. The old list-based coupling_map allowed for simple iteration, such as:

for edge in backend.coupling_map:
    do stuff here

It would be nice if this same behavior could be done using CouplingMap objects. Currently one gets:

TypeError: 'CouplingMap' object is not iterable

@jakelishman
Copy link
Member

There's .get_edges (or edge_list or something) on it.

@nonhermitian
Copy link
Contributor Author

It also does not present any difficulty to give easier access to the primary data for CouplingMap in an easy manner, and solve issues like #8865 at the same time.

@jakelishman
Copy link
Member

That's fair - I'm not saying we can't add the magic method, just that in the interim, the iterable form does exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants