Skip to content
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

Dynamic collation #1243

Merged
merged 13 commits into from Apr 5, 2017

Small fix for dynamic collation closure

  • Loading branch information...
Philipp Rudiger Philipp Rudiger
Philipp Rudiger authored and Philipp Rudiger committed Apr 4, 2017
commit 002ded45fdb133ac6afa06291c6d4ed4e63a3901
@@ -847,9 +847,10 @@ def collation_cb(*args, **kwargs):
vstreams = streams.get(i, [])
elif isinstance(streams, list):
vstreams = streams[i] if i < len(streams) else []
def collation_cb(collation_key=k, *args, **kwargs):
return self[args][collation_key]
callback = Callable(collation_cb, inputs=[self])
def collation_cb(*args, **kwargs):
return self[args][kwargs['collation_key']]
callback = Callable(partial(collation_cb, collation_key=k),
inputs=[self])

This comment has been minimized.

Copy link
@jlstevens

jlstevens Apr 5, 2017

Contributor

A couple of question:

Why use a partial? Can't collation_cb use k directly, forming a closure? Or is the issue that k is changing in a loop?

To make sure I understand, collation_key is really about selecting a portion of the structure returned by the callback? In which case selection_key might be a more intuitive name...

This comment has been minimized.

Copy link
@philippjfr

philippjfr Apr 5, 2017

Author Contributor

Why use a partial? Can't collation_cb use k directly, forming a closure? Or is the issue that k is changing in a loop?

Yes.

To make sure I understand, collation_key is really about selecting a portion of the structure returned by the callback? In which case selection_key might be a more intuitive name...

Sure.

vdmap = self.clone(callback=callback, shared_data=False,
streams=vstreams)
for stream in vstreams:
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.