_preprocess_data(func=None, *, replace_names=None, label_namer=None)
When applied:
@_preprocess_data() def func(ax, *args, **kwargs): ...
the signature is modified to decorated(ax, *args, data=None, **kwargs)
with the following behavior:
if called with data=None
, forward the other arguments to func
;
otherwise, data must be a mapping; for any argument passed in as a string name
, replace the argument by data[name]
(if this does not throw an exception), then forward the arguments to func
.
In either case, any argument that is a :None:None:`MappingView`
is also converted to a list.
The list of parameter names for which lookup into data should be attempted. If None, replacement is attempted for all arguments.
If set e.g. to "namer" (which must be a kwarg in the function's signature -- not as **kwargs
), if the namer argument passed in is a (string) key of data and no label kwarg is passed, then use the (string) value of the namer as label. :
@_preprocess_data(label_namer="foo") def func(foo, label=None): ... func("key", data={"key": value}) # is equivalent to func.__wrapped__(value, label="key")
A decorator to add a 'data' kwarg to a function.
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them