import json


def load_coupling(name):
    """
    Loads the coupling map that is given as a json file from a subfolder named layouts

    Args:
        name (string): name of the coupling map that was used when saving
                        (corresponds to the filename without the extension .json)
    Returns:
        dict
        {
            "qubits" : the number of qubits in the coupling map
            "name": coupling map name
            "coupling_map" : actual coupling map as used by QISKit
            "position" : arrangement of the qubits in 2D if available
            "description": additional information on the coupling map
        }

    """
    with open("./layouts/"+name+".json", 'r') as infile:
        temp = json.load(infile)
        temp["coupling_map"] = {int(ii): kk for ii, kk in temp["coupling_map"].items()}
        return temp