-
-
Notifications
You must be signed in to change notification settings - Fork 167
support for coroutine #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What syntax do you suggest?
|
A "Receives" heading and parameter listing perhaps?? |
Does it make sense to bundle this under the yield description? |
In the sense that the signature should describe one or a tuple of arguments to be passed to a function, it does not belong in yield. It is another parameter listing, with type specs and descriptions. |
I guess I'd need a concrete code snippet example to wrap my head around this. |
A bit artificial, but perhaps: def optimize(n_params):
"""Supplies candidates to search in response to error signal
Parameters
----------
n_params : int
Yields
------
candidate : array of shape (n_params,)
Given
-----
error : float
"""
candidate = np.random.rand(n_params)
error = yield candidate
while not_converged():
candidate = generate_new_candidate(candidate, error)
results = yield candidate
optimizer = optimize(10)
candidate = next(optimizer)
while True:
try:
candidate = optimizer.send(evaluate(candidate))
except StopIteration:
break |
I can't find any language around this in the documentation, so |
Yes, receives makes some sense. @Dreem-Devices, any opinion? |
@tacaswell, you +1ed the issue. Do you have an opinion on the section naming? "Receives" okay? |
I like co-routines also need to support |
fixes numpy#47 TODO: tests
I have a lot of coroutine to comment but i have not seen any suppport for this python feature.
The yield allows to comment what goes out of the coroutine but it would be nice to be able to specify what goes in in a specific manner.
The text was updated successfully, but these errors were encountered: