bmmltools.utils.basic.ParametersTracker

class bmmltools.utils.basic.ParametersTracker(class_to_track)

Bases: object

Class used to track parameters passed as input to a method of a class.

__init__(class_to_track)

Initialization. Parameters are tracked if they are initialized in a with statement.

Example:

# example class
class Foo:

    def __init__(self,a):

        self.a = a

        # initialize parameter tracking
        self.pt = ParametersTracker(self)

    def method(self,b,c):

        # to track parameters in this method initialize them in a with statement.
        with self.pt:

            self.b = b
            self.c = c

        print(self.b + self.c)

        # increment b of 1
        self.b += 1

foo = Foo(1)
foo.method(3,4)
foo.pt.get_current_tracked_params()
Parameters:

class_to_track – (class) Class whose input parameters (of some method) need to be tracked.

Methods

__init__(class_to_track)

Initialization.

get_current_tracked_params()

Return the current status of the parameters under tracking.

get_current_tracked_params()

Return the current status of the parameters under tracking.

Returns:

(dict) dictionary with the current values of the parameters tracked.