streams icon indicating copy to clipboard operation
streams copied to clipboard

Stream.exclude behaves the same as Stream.filter

Open chriswatrous opened this issue 9 years ago • 0 comments

Stream.exclude should exclude items for which the predicate returns True. It seems to actually exclude items for which the predicate returns False, same as Stream.filter.

Versions

pystreams 0.6 Python 2.7.12

Expected

> list(Stream('qewr').exclude(lambda x: True))
[]

>list(Stream('qewr').exclude(lambda x: False))
['q', 'e', 'w', 'r']

Actual

> list(Stream('qewr').exclude(lambda x: True))
['q', 'e', 'w', 'r']

> list(Stream('qewr').exclude(lambda x: False))
[]

The docs say it should behave the same as itertools.ifilterfalse, which behaves like this:

> list(itertools.ifilterfalse(lambda x: True, 'qewr'))
[]

> list(itertools.ifilterfalse(lambda x: False, 'qewr'))
['q', 'e', 'w', 'r']

chriswatrous avatar Jan 25 '17 17:01 chriswatrous