Coverage for typed_stream/__init__.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-02-12 21:24 +0000

1# Licensed under the EUPL-1.2 or later. 

2# You may obtain a copy of the licence in all the official languages of the 

3# European Union at https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 

4 

5"""Typed Stream classes for easier handling of iterables. 

6 

7Examples: 

8>>> import typed_stream 

9>>> # Get sum of 10 squares 

10>>> typed_stream.Stream.range(stop=10).map(lambda x: x * x).sum() 

11285 

12>>> # same as above 

13>>> sum(typed_stream.Stream.counting().limit(10).map(pow, 2)) 

14285 

15>>> # sum first 100 odd numbers 

16>>> typed_stream.Stream.counting(start=1, step=2).limit(100).sum() 

1710000 

18>>> (typed_stream.Stream.counting() 

19... .filter(typed_stream.functions.is_odd).limit(100).sum()) 

2010000 

21>>> (typed_stream.Stream.counting() 

22... .exclude(typed_stream.functions.is_even).limit(100).sum()) 

2310000 

24>>> import typed_stream.functions 

25>>> # Get the longest package name from requirements-dev.txt 

26>>> (typed_stream.FileStream("requirements-dev.txt") 

27... .filter() 

28... .exclude(typed_stream.functions.method_partial(str.startswith, "#")) 

29... .map(str.split, "==") 

30... .starmap(lambda name, version = None: name) 

31... .max(key=len)) 

32'flake8-no-implicit-concat' 

33""" 

34# isort:skip_file 

35 

36from . import _impl, exceptions, streamable, version 

37from . import functions # noqa: F401 

38from ._impl.file_streams import * # noqa: F401, F403s 

39from ._impl.stream import * # noqa: F401, F403 

40from .exceptions import * # noqa: F401, F403 

41from .streamable import * # noqa: F401, F403 

42 

43__all__ = (*_impl.__all__, *streamable.__all__, *exceptions.__all__) 

44__version__ = version.VERSION