Recipes for everything else!

Iterables

flatten[source]

flatten(iterable:Iterable)

From: https://stackoverflow.com/a/2158532

Convenience functions

class DotDict[source]

DotDict(dct) :: dict

Enable dot access to a dictionary. e.g. dict.key1.key2.key3

suppress_stdout[source]

suppress_stdout()

Suppress any stdout in this with block

class Show[source]

Show(things:dict)

Show multiple HTML reprs in the same cell

coalesce[source]

coalesce(*args, default=None)

Provide same function as C# and JS ?? operator

nbdev helpers

show_plotly[source]

show_plotly(fig)

Render plotly figs with nbdev

fastai helpers

class Hook[source]

Hook(m, hook_func, is_forward=True, detach=True, cpu=False, gather=False)

Create a hook on m with hook_func.

class HookBwd[source]

HookBwd(m)

Learner.show_activations[source]

Learner.show_activations(img)

Decorators

decorate_all_methods_with[source]

decorate_all_methods_with(decorators)

Decorate all methods of a class with a list of decorators

decorate_function_with[source]

decorate_function_with(decorators)

Apply a list of decorators to a function

JSON

dict_generator[source]

dict_generator(indict, pre=None)

Recursively traverse a dictionary of unknown depth and return flat lists.

Useful for generating API endpoint strings from JSON-like