ConditionalDispatch

class sunpy.util.cond_dispatch.ConditionalDispatch[source] [edit on github]

Bases: object

Methods Summary

__call__(*args, **kwargs)
add(fun[, condition, types, check]) Add fun to ConditionalDispatch under the condition that the arguments must match.
add_dec(condition)
from_existing(cond_dispatch)
generate_docs()
get_signatures([prefix, start]) Return an iterator containing all possible function signatures.
wrapper()

Methods Documentation

__call__(*args, **kwargs)[source] [edit on github]
add(fun, condition=None, types=None, check=True)[source] [edit on github]

Add fun to ConditionalDispatch under the condition that the arguments must match. If condition is left out, the function is executed for every input that matches the signature. Functions are considered in the order they are added, but ones with condition=None are considered as the last: that means, a function with condition None serves as an else branch for that signature. conditions must be mutually exclusive because otherwise which will be executed depends on the order they are added in. Function signatures of fun and condition must match (if fun is bound, the bound parameter needs to be left out in condition).

add_dec(condition)[source] [edit on github]
classmethod from_existing(cond_dispatch)[source] [edit on github]
generate_docs()[source] [edit on github]
get_signatures(prefix='', start=0)[source] [edit on github]

Return an iterator containing all possible function signatures. If prefix is given, use it as function name in signatures, else leave it out. If start is given, leave out first n elements.

If start is -1, leave out first element if the function was created by run_cls.

wrapper()[source] [edit on github]