scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersBackRef
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.

Notes

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.

Parameters

dispatchables: Sequence[Union[uarray.Dispatchable, Any]] :

The dispatchables that must be supported

domain: string :

The domain to query for backends and set.

coerce: bool :

Whether or not to allow coercion to the backend's types. Implies only .

only: bool :

Whether or not this should be the last backend to try.

dispatch_type: Optional[Any] :

The default dispatch type associated with dispatchables , aka " marking <MarkingGlossary> ".

Set a backend supporting all dispatchables

See Also

determine_backend

For a single dispatch value

set_backend

For when you know which backend to set

Examples

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 .

This example is valid syntax, but we were not able to check execution
>>> 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.

This example is valid syntax, but we were not able to check execution
>>> with ua.set_backend(ex.BackendAB), ua.set_backend(ex.BackendBC):
...  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
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy._lib._uarray._backend.determine_backend_multi

Local connectivity graph

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


GitHub : /scipy/_lib/_uarray/_backend.py#617
type: <class 'function'>
Commit: