Skip to content

Commit 1d78f9a

Browse files
committed
add tests and docs
1 parent 5f01449 commit 1d78f9a

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

streamz/core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,10 @@ class filter(Stream):
622622
predicate : function
623623
The predicate. Should return True or False, where
624624
True means that the predicate is satisfied.
625+
*args :
626+
The arguments to pass to the predicate.
627+
**kwargs:
628+
Keyword arguments to pass to predicate
625629
626630
Examples
627631
--------
@@ -649,7 +653,6 @@ def update(self, x, who=None):
649653
return self._emit(x)
650654

651655

652-
653656
@Stream.register_api()
654657
class accumulate(Stream):
655658
""" Accumulate results with previous state

streamz/tests/test_core.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,26 @@ def test_filter():
8383
assert L == [0, 2, 4, 6, 8]
8484

8585

86+
def test_filter_args():
87+
source = Stream()
88+
L = source.filter(lambda x, n: x % n == 0, 2).sink_to_list()
89+
90+
for i in range(10):
91+
source.emit(i)
92+
93+
assert L == [0, 2, 4, 6, 8]
94+
95+
96+
def test_filter_kwargs():
97+
source = Stream()
98+
L = source.filter(lambda x, n=1: x % n == 0, n=2).sink_to_list()
99+
100+
for i in range(10):
101+
source.emit(i)
102+
103+
assert L == [0, 2, 4, 6, 8]
104+
105+
86106
def test_filter_none():
87107
source = Stream()
88108
L = source.filter(None).sink_to_list()

0 commit comments

Comments
 (0)