class_util.py

Various utils dealing with classes.

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.

class openmdao.utils.class_util.weak_method_wrapper(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.

__init__(obj, fname)[source]

Initialize the wrapper.

Parameters
objobject

The instance object.

fnamestr

The name of the method.