turboflow.config_validation module
- turboflow.config_validation.convert_configuration_options(config)[source]
Processes configuration data by evaluating string expressions as numerical values and converting lists to numpy arrays.
This function iteratively goes through the configuration dictionary and converts string representations of numbers (e.g., “1+2”, “2*np.pi”) into actual numerical values using Python’s eval function. It also ensures that all numerical values are represented as Numpy types for consistency across the application.
- Parameters:
- configdict
The configuration data loaded from a YAML file, typically containing a mix of strings, numbers, and lists.
- Returns:
- dict
The postprocessed configuration data where string expressions are evaluated as numbers, and all numerical values are cast to corresponding NumPy types.
- Raises:
- ConfigurationError
If a list contains elements of different types after conversion, indicating an inconsistency in the expected data types.
- turboflow.config_validation.load_config(config_file_path: str, print_summary=False)[source]
Load and process a configuration file.
This function reads a YAML configuration file, validates its contents, and converts it into a configuration object for turbomachinery analysis. The configuration can be printed as a summary if specified.
- Parameters:
- config_file_pathstr
Path to the YAML configuration file.
- print_summarybool, optional
Whether to print a summary of the loaded configuration (default is True).
- Returns:
- dict
A dictionary representation of the configuration object, with all nested attributes recursively converted.
- Raises:
- FileNotFoundError
If the configuration file is not found.
- ValueError
If required fields are missing or contain invalid values.
- yaml.YAMLError
If there is an error parsing the YAML file.
- turboflow.config_validation.object_to_dict(obj)[source]
Recursively convert an object’s attributes to a dictionary.
This function takes an object and converts its attributes to a dictionary format. It handles nested dictionaries, lists, and objects with a __dict__ attribute, recursively converting all attributes to dictionaries or arrays as appropriate.
- Parameters:
- objany
The object to convert. This can be a dictionary, list, or an object with a __dict__ attribute.
- Returns:
- dict
A dictionary representation of the object, where all nested attributes are recursively converted.
- turboflow.config_validation.read_configuration_file(filename)[source]
Reads a YAML configuration file and converts options to NumPy types when possible.
- Parameters:
- filenamestr
The path to the YAML configuration file.
- Returns:
- dict
A dictionary containing the configuration options, with values converted to NumPy types where applicable.
- Raises:
- Exception
If there is an error reading or parsing the configuration file.