class_util.py

Various utils dealing with classes.

class openmdao.utils.class_util.WeakMethodWrapper(obj, fname)[source]

Bases: object

A class to contain a weak ref to a method.

weakerf.ref(obj.method) doesn’t work, so this class will wrap a weak ref to the method’s parent object, look the method up in that instance by name, and call it.

Parameters
objobject

The instance object.

fnamestr

The name of the method.

Attributes
_refweakerf

The weakref to the method’s owning instance.

__name__str

The name of the method.

__init__(obj, fname)[source]

Initialize the wrapper.

openmdao.utils.class_util.overrides_method(method_name, obj, base)[source]

Return True if the named base class method is overridden by obj.

Parameters
method_namestr

Name of the method to search for.

objobject

An object that is assumed to inherit from base.

baseclass

The base class that contains the base version of the named method.

Returns
bool

True if the named base clas is overridden by the given obj, otherwise False.