-
Notifications
You must be signed in to change notification settings - Fork 150
Adding messages #111
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
Adding messages #111
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -931,3 +931,28 @@ def slow_write(x): | |
|
|
||
| if sys.version_info >= (3, 5): | ||
| from streamz.tests.py3_test_core import * # noqa | ||
|
|
||
|
|
||
| def test_clear(): | ||
| s = Stream() | ||
| # increment | ||
| def acc1(x1, x2): | ||
| return x1 + x2 | ||
| from streamz.core import ClearMSG, IgnoreMSG | ||
|
|
||
| clear_msg = ClearMSG() | ||
| ignore_msg = IgnoreMSG() | ||
|
|
||
| sout = s.accumulate(acc1) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would happen if you had a map before the accumulate? Does map (or all other stream operations) also need to know what to do with ClearMSGs?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would imagine that all |
||
| Lout = sout.sink_to_list() | ||
| sout2 = sout.map(lambda x : x + 1) | ||
| Lout2 = sout2.sink_to_list() | ||
|
|
||
| s.emit(1) | ||
| s.emit(2) | ||
| s.emit(ignore_msg) | ||
| s.emit(3) | ||
| s.emit(clear_msg) | ||
| s.emit(3) | ||
| assert Lout == [1, 3, 6, 3] | ||
| assert Lout2 == [2, 4, 7, 4] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want a MSG base class so you can just check if an item is an instance if that class