modelrunner.utils module
Miscellaneous utility methods.
Decorator to use a method both as a classmethod and an instance method. |
|
Import a class or module given an identifier. |
- class hybridmethod(fclass, finstance=None, doc=None)[source]
Bases:
objectDecorator to use a method both as a classmethod and an instance method.
Note
The decorator can be used like so:
@hybridmethod def method(cls, ...): ... @method.instancemethod def method(self, ...): ...
Adapted from https://stackoverflow.com/a/28238047
- import_class(identifier)[source]
Import a class or module given an identifier.
- Parameters:
identifier (str) – The identifier can be a module or a class. For instance, calling the function with the string identifier == ‘numpy.linalg.norm’ is roughly equivalent to running from numpy.linalg import norm and would return a reference to norm.