case.py#
A Case class.
- class openmdao.recorders.case.Case(source, data, prom2abs, abs2prom, abs2meta, conns, auto_ivc_map, var_info, data_format=- 1)[source]
Bases:
object
Case wraps the data from a single iteration of a recording to make it more easily accessible.
- Parameters:
- sourcestr
The unique id of the system/solver/driver/problem that did the recording.
- datadict-like
Dictionary of data for a case.
- prom2abs{‘input’: dict, ‘output’: dict}
Dictionary mapping promoted names of all variables to absolute names.
- abs2prom{‘input’: dict, ‘output’: dict}
Dictionary mapping absolute names of all variables to promoted names.
- abs2metadict
Dictionary mapping absolute names of all variables to variable metadata.
- connsdict
Dictionary of all model connections.
- auto_ivc_mapdict
Dictionary that maps all auto_ivc sources to either an absolute input name for single connections or a promoted input name for multiple connections. This is for output display.
- var_infodict
Dictionary with information about variables (scaling, indices, execution order).
- data_formatint
A version number specifying the format of array data, if not numpy arrays.
- Attributes:
- sourcestr
The unique id of the system/solver/driver/problem that did the recording.
- namestr
The unique identifier for this case.
- parentstr
The iteration coordinate of the parent case for this iteration if any, else None.
- counterint
The unique sequential index of this case in the recording.
- timestampfloat
Time of execution of the case.
- successstr
Success flag for the case.
- msgstr
Message associated with the case.
- outputsPromAbsDict
Map of outputs to values recorded.
- inputsPromAbsDict or None
Map of inputs to values recorded, None if not recorded.
- residualsPromAbsDict or None
Map of outputs to residuals recorded, None if not recorded.
- derivativesPromAbsDict or None
Map of (output, input) to derivatives recorded, None if not recorded.
- parentstr
The full unique identifier for the parent this iteration.
- abs_errfloat or None
Absolute tolerance (None if not recorded).
- rel_errfloat or None
Relative tolerance (None if not recorded).
- _prom2abs{‘input’: dict, ‘output’: dict}
Dictionary mapping promoted names of all variables to absolute names.
- _abs2prom{‘input’: dict, ‘output’: dict}
Dictionary mapping absolute names of all variables to promoted names.
- _abs2metadict
Dictionary mapping absolute names of all variables to variable metadata.
- _connsdict
Dictionary of all model connections.
- _auto_ivc_mapdict
Dictionary that maps all auto_ivc sources to either an absolute input name for single connections or a promoted input name for multiple connections. This is for output display.
- _var_infodict
Dictionary with information about variables (scaling, indices, execution order).
- _format_versionint
A version number specifying the format of array data, if not numpy arrays.
- __getitem__(name)[source]
Get an output/input variable.
- Parameters:
- namestr
Promoted or relative variable name in the root system’s namespace.
- Returns:
- float or ndarray or any python object
the requested output/input variable.
- __init__(source, data, prom2abs, abs2prom, abs2meta, conns, auto_ivc_map, var_info, data_format=- 1)[source]
Initialize.
- get_constraints(scaled=True, use_indices=True)[source]
Get the values of the constraints, as seen by the driver, for this case.
- Parameters:
- scaledbool
If True, then return scaled values.
- use_indicesbool
If True, apply indices.
- Returns:
- PromAbsDict
Map of variables to their values.
- get_design_vars(scaled=True, use_indices=True)[source]
Get the values of the design variables, as seen by the driver, for this case.
- Parameters:
- scaledbool
If True, then return scaled values.
- use_indicesbool
If True, apply indices.
- Returns:
- PromAbsDict
Map of variables to their values.
- get_io_metadata(iotypes=('input', 'output'), metadata_keys=None, includes=None, excludes=None, is_indep_var=None, is_design_var=None, tags=None)[source]
Retrieve metadata for a filtered list of variables.
- Parameters:
- iotypesstr or iter of str
Will contain either ‘input’, ‘output’, or both. Defaults to both.
- metadata_keysiter of str or None
Names of metadata entries to be retrieved or None, meaning retrieve all available ‘allprocs’ metadata. If ‘val’ or ‘src_indices’ are required, their keys must be provided explicitly since they are not found in the ‘allprocs’ metadata and must be retrieved from local metadata located in each process.
- includesstr, iter of str or None
Collection of glob patterns for pathnames of variables to include. Default is None, which includes all variables.
- excludesstr, iter of str or None
Collection of glob patterns for pathnames of variables to exclude. Default is None.
- is_indep_varbool or None
If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.
- is_design_varbool or None
If None (the default), do no additional filtering of the inputs. If True, list only outputs and connected inputs that are driver design variables. If False, list only outputs and connected inputs that are _not_ driver design variables.
- tagsstr or iter of strs
User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.
- Returns:
- dict
A dict of metadata keyed on name, where the metadata is a dict containing entries based on the value of the metadata_keys arg. Every metadata dict will always contain two entries, ‘prom_name’ and ‘discrete’, to indicate a given variable’s promoted name and whether or not it is discrete.
- get_objectives(scaled=True, use_indices=True)[source]
Get the values of the objectives, as seen by the driver, for this case.
- Parameters:
- scaledbool
If True, then return scaled values.
- use_indicesbool
If True, apply indices.
- Returns:
- PromAbsDict
Map of variables to their values.
- get_responses(scaled=True, use_indices=True)[source]
Get the values of the responses, as seen by the driver, for this case.
- Parameters:
- scaledbool
If True, then return scaled values.
- use_indicesbool
If True, apply indices.
- Returns:
- PromAbsDict
Map of variables to their values.
- get_val(name, units=None, indices=None)[source]
Get an output/input variable.
Function is used if you want to specify display units.
- Parameters:
- namestr
Promoted or relative variable name in the root system’s namespace.
- unitsstr, optional
Units to convert to before upon return.
- indicesint or list of ints or tuple of ints or int ndarray or Iterable or None, optional
Indices or slice to return.
- Returns:
- float or ndarray
The requested output/input variable.
- list_inputs(val=True, prom_name=True, units=False, shape=False, global_shape=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')[source]
Return and optionally log a list of input names and other optional information.
- Parameters:
- valbool, optional
When True, display/return input values. Default is True.
- prom_namebool, optional
When True, display/return the promoted name of the variable. Default is True.
- unitsbool, optional
When True, display/return units. Default is False.
- shapebool, optional
When True, display/return the shape of the value. Default is False.
- global_shapebool, optional
When True, display/return the global shape of the value. Default is False.
- descbool, optional
When True, display/return description. Default is False.
- hierarchicalbool, optional
When True, human readable output shows variables in hierarchical format.
- print_arraysbool, optional
When False, in the columnar display, just display norm of any ndarrays with size > 1. The norm is surrounded by vertical bars to indicate that it is a norm. When True, also display full values of the ndarray below the row. Format is affected by the values set with numpy.set_printoptions Default is False.
- tagsstr or list of strs
User defined tags that can be used to filter what gets listed. Only inputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.
- print_tagsbool
When true, display tags in the columnar display.
- includesstr, iter of str, or None
Glob patterns for pathnames to include in the check. Default is None, which includes all.
- excludesstr, iter of str, or None
Glob patterns for pathnames to exclude from the check. Default is None, which excludes nothing.
- is_indep_varbool or None
If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.
- is_design_varbool or None
If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.
- out_streamfile-like object
Where to send human readable output. Default is sys.stdout. Set to None to suppress.
- print_minbool, optional
When true, if the input value is an array, print its smallest value.
- print_maxbool, optional
When true, if the input value is an array, print its largest value.
- return_formatstr
Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.
- Returns:
- list of (name, metadata) or dict of {name: metadata}
List or dict of input names and other optional information about those inputs.
- list_outputs(explicit=True, implicit=True, val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, global_shape=False, bounds=False, scaling=False, desc=False, hierarchical=True, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')[source]
Return and optionally log a list of output names and other optional information.
- Parameters:
- explicitbool, optional
Include outputs from explicit components. Default is True.
- implicitbool, optional
Include outputs from implicit components. Default is True.
- valbool, optional
When True, display/return output values. Default is True.
- prom_namebool, optional
When True, display/return the promoted name of the variable. Default is False.
- residualsbool, optional
When True, display/return residual values. Default is False.
- residuals_tolfloat, optional
If set, limits the output of list_outputs to only variables where the norm of the resids array is greater than the given ‘residuals_tol’. Default is None.
- unitsbool, optional
When True, display/return units. Default is False.
- shapebool, optional
When True, display/return the shape of the value. Default is False.
- global_shapebool, optional
When True, display/return the global shape of the value. Default is False.
- boundsbool, optional
When True, display/return bounds (lower and upper). Default is False.
- scalingbool, optional
When True, display/return scaling (ref, ref0, and res_ref). Default is False.
- descbool, optional
When True, display/return description. Default is False.
- hierarchicalbool, optional
When True, human readable output shows variables in hierarchical format.
- print_arraysbool, optional
When False, in the columnar display, just display norm of any ndarrays with size > 1. The norm is surrounded by vertical bars to indicate that it is a norm. When True, also display full values of the ndarray below the row. Format is affected by the values set with numpy.set_printoptions Default is False.
- tagsstr or list of strs
User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.
- print_tagsbool
When true, display tags in the columnar display.
- includesstr, iter of str, or None
Glob patterns for pathnames to include in the check. Default is None, which includes all.
- excludesstr, iter of str, or None
Glob patterns for pathnames to exclude from the check. Default is None, which excludes nothing.
- is_indep_varbool or None
If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to an output tagged openmdao:indep_var. If False, list only inputs _not_ connected to outputs tagged openmdao:indep_var.
- is_design_varbool or None
If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.
- list_autoivcsbool
If True, include auto_ivc outputs in the listing. Defaults to False.
- out_streamfile-like
Where to send human readable output. Default is sys.stdout. Set to None to suppress.
- print_minbool, optional
When true, if the output value is an array, print its smallest value.
- print_maxbool, optional
When true, if the output value is an array, print its largest value.
- return_formatstr
Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.
- Returns:
- list of (name, metadata) or dict of {name: metadata}
List or dict of output names and other optional information about those outputs.
- list_vars(val=True, prom_name=True, residuals=False, residuals_tol=None, units=False, shape=False, bounds=False, scaling=False, desc=False, print_arrays=False, tags=None, print_tags=False, includes=None, excludes=None, is_indep_var=None, is_design_var=None, list_autoivcs=False, out_stream=DEFAULT_OUT_STREAM, print_min=False, print_max=False, return_format='list')[source]
Write a list of inputs and outputs sorted by component in execution order.
- Parameters:
- valbool, optional
When True, display output values. Default is True.
- prom_namebool, optional
When True, display the promoted name of the variable. Default is True.
- residualsbool, optional
When True, display residual values. Default is False.
- residuals_tolfloat, optional
If set, limits the output of list_outputs to only variables where the norm of the resids array is greater than the given ‘residuals_tol’. Default is None.
- unitsbool, optional
When True, display units. Default is False.
- shapebool, optional
When True, display/return the shape of the value. Default is False.
- boundsbool, optional
When True, display/return bounds (lower and upper). Default is False.
- scalingbool, optional
When True, display/return scaling (ref, ref0, and res_ref). Default is False.
- descbool, optional
When True, display/return description. Default is False.
- print_arraysbool, optional
When False, in the columnar display, just display norm of any ndarrays with size > 1. The norm is surrounded by vertical bars to indicate that it is a norm. When True, also display full values of the ndarray below the row. Format is affected by the values set with numpy.set_printoptions Default is False.
- tagsstr or list of strs
User defined tags that can be used to filter what gets listed. Only outputs with the given tags will be listed. Default is None, which means there will be no filtering based on tags.
- print_tagsbool
When true, display tags in the columnar display.
- includesNone, str, or iter of str
Collection of glob patterns for pathnames of variables to include. Default is None, which includes all output variables.
- excludesNone, str, or iter of str
Collection of glob patterns for pathnames of variables to exclude. Default is None.
- is_indep_varbool or None
If None (the default), do no additional filtering of the inputs. If True, list only outputs tagged openmdao:indep_var. If False, list only outputs that are _not_ tagged openmdao:indep_var.
- is_design_varbool or None
If None (the default), do no additional filtering of the inputs. If True, list only inputs connected to outputs that are driver design variables. If False, list only inputs _not_ connected to outputs that are driver design variables.
- list_autoivcsbool
If True, include auto_ivc outputs in the listing. Defaults to False.
- out_streamfile-like
Where to send human readable output. Default is sys.stdout. Set to None to suppress.
- print_minbool
When true, if the output value is an array, print its smallest value.
- print_maxbool
When true, if the output value is an array, print its largest value.
- return_formatstr
Indicates the desired format of the return value. Can have value of ‘list’ or ‘dict’. If ‘list’, the return value is a list of (name, metadata) tuples. if ‘dict’, the return value is a dictionary mapping {name: metadata}.
- Returns:
- list of (name, metadata) or dict of {name: metadata}
List or dict of output names and other optional information about those outputs.
- class openmdao.recorders.case.PromAbsDict(values, prom2abs, abs2prom, data_format=14, in_prom2abs=None, auto_ivc_map=None, var_info=None)[source]
Bases:
dict
A dictionary that enables accessing values via absolute or promoted variable names.
- Parameters:
- valuesarray or dict
Numpy structured array or dictionary of values.
- prom2absdict
Dictionary mapping promoted names to absolute names.
- abs2promdict
Dictionary mapping absolute names in the output vector to promoted names.
- data_formatint
A version number specifying the OpenMDAO SQL case database version.
- in_prom2absdict
Dictionary mapping promoted names in the input vector to absolute names.
- auto_ivc_mapdict
Dictionary that maps all auto_ivc sources to either an absolute input name for single connections or a promoted input name for multiple connections. This is for output display.
- var_infodict
Dictionary of variable metadata. Needed when there are constraint aliases.
- Attributes:
- _valuesarray or dict
Array or dict of values accessible via absolute variable name.
- _keysarray
Absolute variable names that map to the values in the _values array.
- _prom2absdict
Dictionary mapping promoted names in the output vector to absolute names.
- _abs2promdict
Dictionary mapping absolute names to promoted names.
- _auto_ivc_mapdict
Dictionary that maps all auto_ivc sources to either an absolute input name for single connections or a promoted input name for multiple connections. This is for output display.
- _var_infodict
Dictionary of variable metadata. Needed when there are constraint aliases.
- _DERIV_KEY_SEPstr
Separator character for derivative keys.
- __contains__(key, /)
True if the dictionary has the specified key, else False.
- __getitem__(key)[source]
Use the variable name to get the corresponding value.
- Parameters:
- keystr
Absolute or promoted variable name.
- Returns:
- array
An array entry value that corresponds to the given variable name.
- __init__(values, prom2abs, abs2prom, data_format=14, in_prom2abs=None, auto_ivc_map=None, var_info=None)[source]
Initialize.
- __iter__(/)
Implement iter(self).
- __setitem__(key, value)[source]
Set the value for the given key, which may use absolute or promoted names.
- Parameters:
- keystr
Absolute or promoted variable name.
- valueany
value for variable
- absolute_names()[source]
Yield absolute names for variables contained in this dictionary.
Similar to keys() but with absolute variable names instead of promoted names.
- Yields:
- str
absolute names for variables contained in this dictionary.
- clear() None. Remove all items from D.
- copy() a shallow copy of D
- fromkeys(iterable, value=None, /)
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items
- keys() a set-like object providing a view on D's keys
- pop(key, default=<unrepresentable>, /)
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem(/)
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from dict/iterable E and F.
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values