om_warnings.py

A module for OpenMDAO-specific warnings and associated functions.

exception openmdao.utils.om_warnings.CacheWarning[source]

Bases: openmdao.utils.om_warnings.OpenMDAOWarning

Warning which is issued when the a cache is invalid and needs to be rebuilt.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'always'
name = 'warn_cache'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception openmdao.utils.om_warnings.CaseRecorderWarning[source]

Bases: openmdao.utils.om_warnings.OpenMDAOWarning

Warning pertaining to case recording and reading.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'always'
name = 'warn_case_recorder'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception openmdao.utils.om_warnings.DerivativesWarning[source]

Bases: openmdao.utils.om_warnings.OpenMDAOWarning

Warning issued when the approximated partials or coloring cannot be evaluated as expected.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'always'
name = 'warn_derivatives'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception openmdao.utils.om_warnings.DistributedComponentWarning[source]

Bases: openmdao.utils.om_warnings.SetupWarning

Warning specific to a distributed component.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'always'
name = 'warn_distributed_component'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception openmdao.utils.om_warnings.DriverWarning[source]

Bases: openmdao.utils.om_warnings.OpenMDAOWarning

Warning which is issued during the execution of a driver.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'always'
name = 'warn_driver'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception openmdao.utils.om_warnings.MPIWarning[source]

Bases: openmdao.utils.om_warnings.SetupWarning

Warning dealing with the availability of MPI.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'always'
name = 'warn_mpi'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception openmdao.utils.om_warnings.OMDeprecationWarning[source]

Bases: openmdao.utils.om_warnings.OpenMDAOWarning

An OpenMDAO-specific deprecation warning that is noisy by default, unlike the Python one.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'once'
name = 'warn_deprecation'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception openmdao.utils.om_warnings.OMInvalidCheckDerivativesOptionsWarning[source]

Bases: openmdao.utils.om_warnings.OpenMDAOWarning

An OpenMDAO-specific warning that defaults to raising an exception.

It tells the user that they are checking derivatives with the exact same method used to computer the derivatives, including all the settings.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'error'
name = 'warn_invalid_check_derivatives'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception openmdao.utils.om_warnings.OpenMDAOWarning[source]

Bases: UserWarning

Base class for all OpenMDAO warnings.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'always'
name = 'warn_openmdao'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception openmdao.utils.om_warnings.PromotionWarning[source]

Bases: openmdao.utils.om_warnings.SetupWarning

Warning dealing with the promotion of an input or output.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'always'
name = 'warn_promotion'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception openmdao.utils.om_warnings.SetupWarning[source]

Bases: openmdao.utils.om_warnings.OpenMDAOWarning

Warning class for warnings that occur during setup.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'always'
name = 'warn_setup'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception openmdao.utils.om_warnings.SolverWarning[source]

Bases: openmdao.utils.om_warnings.OpenMDAOWarning

Warning base class for solver-related warnings.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'always'
name = 'warn_solver'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception openmdao.utils.om_warnings.UnitsWarning[source]

Bases: openmdao.utils.om_warnings.SetupWarning

Warning which is issued when unitless variable is connected to a variable with units.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'always'
name = 'warn_units'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception openmdao.utils.om_warnings.UnusedOptionWarning[source]

Bases: openmdao.utils.om_warnings.OpenMDAOWarning

Warning dealing with an unnecessary option or argument being provided.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

args
filter = 'always'
name = 'warn_unused_option'
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

openmdao.utils.om_warnings.issue_warning(msg, prefix='', stacklevel=2, category=<class 'openmdao.utils.om_warnings.OpenMDAOWarning'>)[source]

Display a warning with the desired stack level and optional prefix.

Ex.

>>> om.issue_warning('some warning message', prefix=self.pathname, category=om.SetupWarning)
Parameters
msgstr

The warning message.

prefixstr

An optional prefix to be prepended to the warning message (usually the system path).

stacklevelint

Number of levels up the stack to identify as the warning location.

categoryclass

The class of warning to be issued.

class openmdao.utils.om_warnings.reset_warning_registry(pattern=None)[source]

Bases: object

Context manager which archives & clears warning registry for duration of context.

From https://bugs.python.org/file40031/reset_warning_registry.py

Parameters
patternregex pattern

Causes manager to only reset modules whose names match pattern. defaults to ".*".

Attributes
_patternregex pattern

Causes manager to only reset modules whose names match this pattern. defaults to ".*".

__init__(pattern=None)[source]

Initialize all attributes.

openmdao.utils.om_warnings.reset_warnings()[source]

Apply the default warning filter actions for the OpenMDAO-specific warnings.

This is necessary when testing the filters, because Python resets the default filters before running each test.