DOC: Updated example usage in the docstring for make_decorator
.
#1864
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The docstring to the utility function
make_decorator
provides the example ofcustomized_count = some_decorator(count)
. However, the correct usage should becustomized_count = some_decorator()(count)
otherwise we actually getdec(gen_func)
as the decorated function, rather thandec_inner(...)
as intended.Description
The equivalent syntactic-sugar version of
customized_count = some_decorator(count)
would beThis is a common python pattern for decorators that do not require arguments.
However, the wrappers that are turned into decorators may accept additional arguments and so what comes back from
make_decorator
needs to be a decorator factory. The syntactic-sugar version would then be something like:This is the version that
make_decorator()
produces, and is also how the usage is described in the curated documentation for plans:@relative_set_decorator([motor])
.The equivalent without the sugar is
customized_count = some_decorator()(count)
.Motivation and Context
This PR will update the docstring for
make_decorator
to match the curated documentation, and provide the correct usage for the resulting decorators.If the instructions are followed as previously written, there is no mechanism to provide arguments to the original wrapper, and any attempt to call the decorated plan results in the following error:
(the original plan accepts a keyword argument num).
How Has This Been Tested?
I added wrappers to some common functions. If I use
count = baseline_decorator(count)
I get the error described above. If I change this tocount = baseline_decorator(devices=[...])(count, ...)
. I do not get the error.I have not tested whether the messages for the baseline are actually applied.