tslumen.misc module

Miscellaneous utils available to all modules.

tslumen.misc.import_error_class(module: str)Type[source]

Proxy class to raise import error

tslumen.misc.import_error_function(module: str)Callable[source]

Proxy function to raise import error

tslumen.misc.import_error_module(module: str)Type[source]

Proxy “module” to raise import error

tslumen.misc.lazyproperty(func: Callable)property[source]

Decorator to create lazy-loading properties. Creates a class attribute with the same name prefixed with an underscore and sets it to None. When accessing the property, if the underscored attribute is None, executes the decorated function and stores the result. Returns the underscored attribute.

Parameters

func (Callable) – Function to decorate.

Returns

Decorated fn turned into a property.

Return type

property

tslumen.misc.repr_html(klass: type)type[source]

Decorator to inject a _repr_html_ method in a given class. Will attempt to load the jinja template and render to html, else returns html. Passes self onto the jinja variable obj on the template. Template should be under /ipython (see tslumen.misc.JINJA_FILE_SEARCHPATHS for the full list of search paths).