def loadFromFile(self, fileName): """ loads from fileName, a plain text .paramnames file or a "full" yaml file """ self.filenameLoadedFrom = os.path.split(fileName)[1] extension = os.path.splitext(fileName)[-1] if extension == '.paramnames': with open(fileName) as f: self.names = [ ParamInfo(line) for line in [s.strip() for s in f] if line != '' ] elif extension.lower() in ('.yaml', '.yml'): from getdist.yaml_format_tools import yaml_load_file, get_info_params from getdist.yaml_format_tools import is_sampled_param, is_derived_param from getdist.yaml_format_tools import _p_label, _p_renames info_params = get_info_params(yaml_load_file(fileName)) # first sampled, then derived self.names = [ ParamInfo(name=param, label=(info or {}).get(_p_label, param), renames=(info or {}).get(_p_renames)) for param, info in info_params.items() if is_sampled_param(info) ] self.names += [ ParamInfo(name=param, label=(info or {}).get(_p_label, param), renames=(info or {}).get(_p_renames), derived=True) for param, info in info_params.items() if is_derived_param(info) ]
def loadFromFile(self, fileName): self.filenameLoadedFrom = os.path.split(fileName)[1] extension = os.path.splitext(fileName)[-1] if extension in ('.ranges', '.bounds'): with open(fileName) as f: for line in f: strings = [text.strip() for text in line.split()] if len(strings) == 3: self.setRange(strings[0], strings[1:]) elif extension in ('.yaml', '.yml'): from getdist.yaml_format_tools import yaml_load_file, get_info_params, get_range info_params = get_info_params(yaml_load_file(fileName)) for p, info in info_params.items(): self.setRange(p, get_range(info))
def loadFromFile(self, fileName): self.filenameLoadedFrom = os.path.split(fileName)[1] extension = os.path.splitext(fileName)[-1] if extension in ('.ranges', '.bounds'): with open(fileName) as f: for line in f: strings = [text.strip() for text in line.split()] if len(strings) == 3: self.setRange(strings[0], strings[1:]) elif extension in ('.yaml', '.yml'): from getdist.yaml_format_tools import yaml_load_file, get_info_params from getdist.yaml_format_tools import get_range, is_fixed_param info_params = get_info_params(yaml_load_file(fileName)) for p, info in info_params.items(): if not is_fixed_param(info): self.setRange(p, get_range(info))
def loadFromFile(self, fileName): """ loads from fileName, a plain text .paramnames file or a "full" yaml file """ self.filenameLoadedFrom = os.path.split(fileName)[1] extension = os.path.splitext(fileName)[-1] if extension == '.paramnames': with open(fileName) as f: self.names = [ParamInfo(line) for line in [s.strip() for s in f] if line != ''] elif extension.lower() in ('.yaml', '.yml'): from getdist.yaml_format_tools import yaml_load_file, get_info_params from getdist.yaml_format_tools import is_sampled_param, is_derived_param from getdist.yaml_format_tools import _p_label, _p_renames info_params = get_info_params(yaml_load_file(fileName)) # first sampled, then derived self.names = [ParamInfo(name=param, label=(info or {}).get(_p_label, param), renames=(info or {}).get(_p_renames)) for param, info in info_params.items() if is_sampled_param(info)] self.names += [ParamInfo(name=param, label=(info or {}).get(_p_label, param), renames=(info or {}).get(_p_renames), derived=True) for param, info in info_params.items() if is_derived_param(info)]