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

Add sublayout functionality #53

Open
MarcSerraPeralta opened this issue Sep 17, 2024 · 0 comments
Open

Add sublayout functionality #53

MarcSerraPeralta opened this issue Sep 17, 2024 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@MarcSerraPeralta
Copy link
Owner

An existing implementation that has been removed from surface-sim is

    def sublayout(
        self,
        qubits: List[str],
        name: Optional[str] = None,
        distance: Optional[int] = None,
        description: Optional[str] = None,
    ) -> Layout:
        setup = {}

        setup["name"] = name
        setup["distance"] = distance
        setup["description"] = description
        setup["interaction_order"] = self.interaction_order

        layout = []
        for node, attrs in self.graph.nodes(data=True):
            if node in qubits:
                node_dict = deepcopy(attrs)
                node_dict["qubit"] = node

                nbr_dict = dict()
                adj_view = self.graph.adj[node]

                for nbr_node, edge_attrs in adj_view.items():
                    if nbr_node in qubits:
                        edge_dir = edge_attrs["direction"]
                        nbr_dict[edge_dir] = nbr_node

                for ver_dir in ("north", "south"):
                    for hor_dir in ("east", "west"):
                        edge_dir = f"{ver_dir}_{hor_dir}"
                        if edge_dir not in nbr_dict:
                            nbr_dict[edge_dir] = None

                node_dict["neighbors"] = nbr_dict

                layout.append(node_dict)
        setup["layout"] = layout
        return Layout(setup)

I believe this functionality should not be a method from Layout as this class is already big and it can be separated into a new function.

@MarcSerraPeralta MarcSerraPeralta added the enhancement New feature or request label Sep 17, 2024
@MarcSerraPeralta MarcSerraPeralta added this to the v0.3.0 milestone Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant