config.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:QGL 作者: BBN-Q 项目源码 文件源码
def load_config(filename=None):
    global meas_file, AWGDir, plotBackground, gridColor, pulse_primitives_lib, cnot_implementation

    if filename:
        meas_file = filename
    else:
        meas_file = find_meas_file()

    with open(meas_file, 'r') as FID:
        # cfg = yaml.load(f)
        loader = Loader(FID)
        try:
            cfg = loader.get_single_data()
        finally:
            loader.dispose()

    # pull out the variables
    # abspath allows the use of relative file names in the config file
    if 'AWGDir' in cfg['config'].keys():
        AWGDir = os.path.abspath(cfg['config']['AWGDir'])
    else:
        raise KeyError("Could not find AWGDir in the YAML config section")

    plotBackground       = cfg['config'].get('PlotBackground', '#EAEAF2')
    gridColor            = cfg['config'].get('GridColor', None)
    pulse_primitives_lib = cfg['config'].get('PulsePrimitivesLibrary', 'standard')
    cnot_implementation  = cfg['config'].get('cnot_implementation', 'CNOT_simple')

    return meas_file
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号