case.py

A Case class.

class openmdao.recorders.case.Case(source, data, prom2abs, abs2prom, abs2meta, voi_meta, data_format=None)[source]

Bases: object

Case wraps the data from a single iteration of a recording to make it more easily accessible.

Attributes

source (str) The unique id of the system/solver/driver/problem that did the recording.
iteration_coordinate (str) The full unique identifier for this iteration.
parent (str) The iteration coordinate of the parent case for this iteration if any, else None.
counter (int) The unique sequential index of this case in the recording.
timestamp (float) Time of execution of the case.
success (str) Success flag for the case.
msg (str) Message associated with the case.
outputs (PromotedToAbsoluteMap) Map of outputs to values recorded.
inputs (PromotedToAbsoluteMap or None) Map of inputs to values recorded, None if not recorded.
residuals (PromotedToAbsoluteMap or None) Map of outputs to residuals recorded, None if not recorded.
jacobian (PromotedToAbsoluteMap or None) Map of (output, input) to derivatives recorded, None if not recorded.
parent (str) The full unique identifier for the parent this iteration.
abs_err (float or None) Absolute tolerance (None if not recorded).
rel_err (float or None) Relative tolerance (None if not recorded).
__init__(source, data, prom2abs, abs2prom, abs2meta, voi_meta, data_format=None)[source]

Initialize.

Parameters:
source : str

The unique id of the system/solver/driver/problem that did the recording.

data : dict-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.

abs2meta : dict

Dictionary mapping absolute names of all variables to variable metadata.

voi_meta : dict

Dictionary mapping absolute names of variables of interest to variable metadata.

data_format : int

A version number specifying the format of array data, if not numpy arrays.

get_constraints(scaled=True, use_indices=True)[source]

Get the values of the constraints, as seen by the driver, for this case.

Parameters:
scaled : bool

The unique id of the system/solver/driver/problem that did the recording.

use_indices : bool

The full unique identifier for this iteration.

Returns:
PromotedToAbsoluteMap

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:
scaled : bool

The unique id of the system/solver/driver/problem that did the recording.

use_indices : bool

The full unique identifier for this iteration.

Returns:
PromotedToAbsoluteMap

Map of variables to their values.

get_objectives(scaled=True, use_indices=True)[source]

Get the values of the objectives, as seen by the driver, for this case.

Parameters:
scaled : bool

The unique id of the system/solver/driver/problem that did the recording.

use_indices : bool

The full unique identifier for this iteration.

Returns:
PromotedToAbsoluteMap

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:
scaled : bool

The unique id of the system/solver/driver/problem that did the recording.

use_indices : bool

The full unique identifier for this iteration.

Returns:
PromotedToAbsoluteMap

Map of variables to their values.

list_inputs(values=True, units=False, hierarchical=True, print_arrays=False, out_stream=<object object>)[source]

Return and optionally log a list of input names and other optional information.

Also optionally logs the information to a user defined output stream.

Parameters:
values : bool, optional

When True, display/return input values. Default is True.

units : bool, optional

When True, display/return units. Default is False.

hierarchical : bool, optional

When True, human readable output shows variables in hierarchical format.

print_arrays : bool, 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.

out_stream : file-like object

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
list

list of input names and other optional information about those inputs

list_outputs(explicit=True, implicit=True, values=True, prom_name=False, residuals=False, residuals_tol=None, units=False, shape=False, bounds=False, scaling=False, hierarchical=True, print_arrays=False, out_stream=<object object>)[source]

Return and optionally log a list of output names and other optional information.

Also optionally logs the information to a user defined output stream.

Parameters:
explicit : bool, optional

include outputs from explicit components. Default is True.

implicit : bool, optional

include outputs from implicit components. Default is True.

values : bool, optional

When True, display/return output values. Default is True.

prom_name : bool, optional

When True, display/return the promoted name of the variable. Default is False.

residuals : bool, optional

When True, display/return residual values. Default is False.

residuals_tol : float, 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.

units : bool, optional

When True, display/return units. Default is False.

shape : bool, optional

When True, display/return the shape of the value. Default is False.

bounds : bool, optional

When True, display/return bounds (lower and upper). Default is False.

scaling : bool, optional

When True, display/return scaling (ref, ref0, and res_ref). Default is False.

hierarchical : bool, optional

When True, human readable output shows variables in hierarchical format.

print_arrays : bool, 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.

out_stream : file-like

Where to send human readable output. Default is sys.stdout. Set to None to suppress.

Returns:
list

list of output names and other optional information about those outputs

class openmdao.recorders.case.PromotedToAbsoluteMap(values, prom2abs, abs2prom, output=True)[source]

Bases: dict

A dictionary that enables accessing values via absolute or promoted variable names.

__contains__($self, key, /)

True if D has a key k, else False.

__getitem__(key)[source]

Use the variable name to get the corresponding value.

Parameters:
key : string

Absolute or promoted variable name.

Returns:
array :

An array entry value that corresponds to the given variable name.

__init__(values, prom2abs, abs2prom, output=True)[source]

Initialize.

Parameters:
values : array or dict

Numpy structured array or dictionary of values.

prom2abs : {‘input’: dict, ‘output’: dict}

Dictionary mapping promoted names to absolute names.

abs2prom : {‘input’: dict, ‘output’: dict}

Dictionary mapping absolute names to promoted names.

output : bool

True if this should map using output variable names, False for input variable names.

__iter__($self, /)

Implement iter(self).

__setitem__(key, value)[source]

Set the value for the given key, which may use absolute or promoted names.

Parameters:
key : string

Absolute or promoted variable name.

value : any

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.

clear() → None. Remove all items from D.
copy() → a shallow copy of D
fromkeys($type, iterable, value=None, /)

Returns a new dict with keys from iterable and values equal to value.

get(k[, d]) → D[k] if k in D, else d. d defaults to None.
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(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
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