name_maps.py#

Maps between promoted/relative/absolute names and name pairs.

openmdao.utils.name_maps.abs_key2rel_key(system, abs_key)[source]

Map relative variable name pair to absolute variable name pair.

Parameters:
system<System>

System to which the given key is relative.

abs_key(str, str)

Given absolute variable name pair.

Returns:
(str, str)

Relative variable name pair.

openmdao.utils.name_maps.abs_key_iter(system, rel_ofs, rel_wrts)[source]

Return absolute jacobian keys given relative ‘of’ and ‘wrt’ names.

Parameters:
systemSystem

The scoping system.

rel_ofsiter of str

Names of the relative ‘of’ variables.

rel_wrtsiter of str

Names of the relative ‘wrt’ variables.

Yields:
abs_of

Absolute ‘of’ name.

abs_wrt

Absolute ‘wrt’ name.

openmdao.utils.name_maps.abs_name2rel_name(system, abs_name)[source]

Map relative variable name to absolute variable name.

Parameters:
system<System>

System to which the given name is relative.

abs_namestr

Given absolute variable name.

Returns:
str

Relative variable name.

openmdao.utils.name_maps.key2abs_key(system, key)[source]

Map the given absolute, promoted or relative name pair to the absolute name pair.

The first name is an output, and the second name can be an output or an input. If the second name is non-unique, a KeyError is thrown.

Parameters:
system<System>

System to which prom_key is relative.

key(str, str)

Promoted or relative name pair of sub-Jacobian.

Returns:
(str, str) or None

Absolute name pair of sub-Jacobian if unique abs_key found or None otherwise.

openmdao.utils.name_maps.name2abs_name(system, name)[source]

Map the given promoted or relative name to the absolute name.

This is only valid when the name is unique; otherwise, a KeyError is thrown.

Parameters:
system<System>

System to which name is relative.

namestr

Promoted or relative variable name in the owning system’s namespace.

Returns:
str or None

Absolute variable name if unique abs_name found or None otherwise.

str or None

The type (‘input’ or ‘output’) of the corresponding variable.

openmdao.utils.name_maps.name2abs_names(system, name)[source]

Map the given promoted, relative, or absolute name to any matching absolute names.

This will also match any buried promotes.

Parameters:
system<System>

System to which name is relative.

namestr

Promoted or relative variable name in the owning system’s namespace.

Returns:
tuple or list of str

Tuple or list of absolute variable names found.

openmdao.utils.name_maps.prom_key2abs_key(system, prom_key)[source]

Map the given promoted name pair to the absolute name pair.

The first name is a continuous output, and the second name can be an output or an input. If the second name is non-unique, a KeyError is thrown.

Parameters:
system<System>

System to which prom_key is relative.

prom_key(str, str)

Promoted name pair of sub-Jacobian.

Returns:
(str, str) or None

Absolute name pair of sub-Jacobian or None is prom_key is invalid.

openmdao.utils.name_maps.prom_name2abs_name(system, prom_name, iotype)[source]

Map the given promoted name to the absolute name.

This is only valid when the name is unique; otherwise, a KeyError is thrown.

Parameters:
system<System>

System to which prom_name is relative.

prom_namestr

Promoted variable name in the owning system’s namespace.

iotypestr

Either ‘input’ or ‘output’.

Returns:
str or None

Absolute variable name or None if prom_name is invalid.

openmdao.utils.name_maps.rel_key2abs_key(system, rel_key)[source]

Map relative variable name pair to absolute variable name pair.

Parameters:
system<System>

System to which the given key is relative.

rel_key(str, str)

Given relative variable name pair.

Returns:
(str, str)

Absolute variable name pair.

openmdao.utils.name_maps.rel_name2abs_name(system, rel_name)[source]

Map relative variable name to absolute variable name.

Parameters:
system<System>

System to which the given name is relative.

rel_namestr

Given relative variable name.

Returns:
str

Absolute variable name.