pypeit.par.util module
Utility functions for PypeIt parameter sets
- pypeit.par.util._eval_iter(inp, left, right, otype)[source]
Convenience function used to abstract the core functionality of
eval_tuple()andeval_list().
- pypeit.par.util.ast_literal_eval(inp)[source]
A wrapper for
ast.literal_eval()that returns the input if it raises a ValueError.
- pypeit.par.util.eval_list(inp)[source]
Evaluate the input to one or more lists.
This allows conversion of one or more lists provided to a configuration parameters.
Warning
Currently can only handle lists with integers, floats, or strings!
- pypeit.par.util.eval_tuple(inp)[source]
Evaluate the input to one or more tuples.
This allows conversion of one or more tuples provided to a configuration parameters.
Warning
Currently can only handle tuples with integers, floats, or strings!
- pypeit.par.util.recursive_dict_evaluate(d)[source]
Recursively run
eval()on each element of the provided dictionary.A raw read of a configuration file with configobj results in a dictionary that contains strings or lists of strings. However, when assigning the values for the various ParSets, the from_dict methods expect the dictionary values to have the appropriate type. E.g., the configobj will have something like d[‘foo’] = ‘1’, when the from_dict method expects the value to be an integer (d[‘foo’] = 1).
This function tries to evaluate all dictionary values, except for those listed above in the
_eval_ignore()function. Any value in this list or where:ast_literal_eval(d[k]) for k in d.keys()
raises an exception is returned as the original string.
This is currently only used in
from_cfg_file(); see further comments there.