determine_backend_multi(dispatchables, *, domain, only=True, coerce=False, **kwargs)
This is useful for functions that call multimethods without any dispatchable arguments. You can use determine_backend_multi
to ensure the same backend is used everywhere in a block of multimethod calls involving multiple arrays.
Support is determined by the __ua_convert__
protocol. Backends not supporting the type must return NotImplemented
from their __ua_convert__
if they don't support input of that type.
The dispatchables that must be supported
The domain to query for backends and set.
Whether or not to allow coercion to the backend's types. Implies only
.
Whether or not this should be the last backend to try.
The default dispatch type associated with dispatchables
, aka " marking <MarkingGlossary>
".
Set a backend supporting all dispatchables
determine_backend
For a single dispatch value
set_backend
For when you know which backend to set
determine_backend
allows the backend to be set from a single object. determine_backend_multi
allows multiple objects to be checked simultaneously for support in the backend. Suppose we have a BackendAB
which supports TypeA
and TypeB
in the same call, and a BackendBC
that doesn't support TypeA
.
>>> with ua.set_backend(ex.BackendAB), ua.set_backend(ex.BackendBC):
... a, b = ex.TypeA(), ex.TypeB()
... with ua.determine_backend_multi(
... [ua.Dispatchable(a, "mark"), ua.Dispatchable(b, "mark")],
... domain="ua_examples"
... ):
... res = ex.creation_multimethod()
... ex.call_multimethod(res, a, b) TypeA
This won't call BackendBC
because it doesn't support TypeA
.
We can also use leave out the ua.Dispatchable
if we specify the default dispatch_type
for the dispatchables
argument.
>>> with ua.set_backend(ex.BackendAB), ua.set_backend(ex.BackendBC):See :
... a, b = ex.TypeA(), ex.TypeB()
... with ua.determine_backend_multi(
... [a, b], dispatch_type="mark", domain="ua_examples"
... ):
... res = ex.creation_multimethod()
... ex.call_multimethod(res, a, b) TypeA
The following pages refer to to this document either explicitly or contain code examples using this.
scipy._lib._uarray._backend.determine_backend_multi
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