pythonic-fp.iterables 5.1.4__py3-none-any.whl → 5.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pythonic_fp/iterables/__init__.py +1 -1
- pythonic_fp/iterables/drop_take.py +4 -4
- pythonic_fp/iterables/folding.py +14 -12
- pythonic_fp/iterables/merging.py +9 -5
- {pythonic_fp_iterables-5.1.4.dist-info → pythonic_fp_iterables-5.2.0.dist-info}/METADATA +21 -31
- pythonic_fp_iterables-5.2.0.dist-info/RECORD +9 -0
- pythonic_fp/iterables/__init__.pyi +0 -0
- pythonic_fp/iterables/drop_take.pyi +0 -10
- pythonic_fp/iterables/folding.pyi +0 -13
- pythonic_fp/iterables/merging.pyi +0 -14
- pythonic_fp_iterables-5.1.4.dist-info/RECORD +0 -13
- {pythonic_fp_iterables-5.1.4.dist-info → pythonic_fp_iterables-5.2.0.dist-info}/WHEEL +0 -0
- {pythonic_fp_iterables-5.1.4.dist-info → pythonic_fp_iterables-5.2.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -74,7 +74,7 @@ def drop_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[
|
|
|
74
74
|
Drop initial items from iterable while predicate is true.
|
|
75
75
|
|
|
76
76
|
:param iterable: Iterable whose items are to be dropped.
|
|
77
|
-
:param pred: Single argument Boolean
|
|
77
|
+
:param pred: Single argument Boolean valued function.
|
|
78
78
|
:yields: items starting when ``pred`` returns ``False``.
|
|
79
79
|
|
|
80
80
|
"""
|
|
@@ -117,7 +117,7 @@ def take_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[
|
|
|
117
117
|
Return an iterator of items until predicate false.
|
|
118
118
|
|
|
119
119
|
:param iterable: Iterable providing the items to be taken.
|
|
120
|
-
:param pred: Single argument Boolean valued function
|
|
120
|
+
:param pred: Single argument Boolean valued function.
|
|
121
121
|
:yields: Items from iterable while predicate is true.
|
|
122
122
|
|
|
123
123
|
.. warning::
|
|
@@ -146,7 +146,7 @@ def take_split[D](iterable: Iterable[D], n: int) -> tuple[Iterator[D], Iterator[
|
|
|
146
146
|
|
|
147
147
|
.. admonition:: CONTRACT
|
|
148
148
|
|
|
149
|
-
**
|
|
149
|
+
**IMPORTANT:** Do not access the second iterator until
|
|
150
150
|
the first one is completely exhausted.
|
|
151
151
|
|
|
152
152
|
:param iterable: Iterable providing the items to be taken.
|
|
@@ -172,7 +172,7 @@ def take_while_split[D](
|
|
|
172
172
|
|
|
173
173
|
.. admonition:: CONTRACT
|
|
174
174
|
|
|
175
|
-
**
|
|
175
|
+
**IMPORTANT:** Do not access the second iterator until
|
|
176
176
|
the first one is completely exhausted.
|
|
177
177
|
|
|
178
178
|
:param iterable: Iterable providing the items to be taken.
|
pythonic_fp/iterables/folding.py
CHANGED
|
@@ -42,11 +42,11 @@ def accumulate[D, L](
|
|
|
42
42
|
"""
|
|
43
43
|
.. admonition:: accumulate
|
|
44
44
|
|
|
45
|
-
Returns an iterator of
|
|
46
|
-
version of
|
|
45
|
+
Returns an iterator of partially folded items.
|
|
47
46
|
|
|
48
47
|
:param iterable: Iterable to be folded.
|
|
49
|
-
:param f: Two parameter function, first parameter for
|
|
48
|
+
:param f: Two parameter function, first parameter is for
|
|
49
|
+
the accumulator.
|
|
50
50
|
:param initial: Optional ``initial`` item to start fold.
|
|
51
51
|
:yields: The intermediate folded items.
|
|
52
52
|
|
|
@@ -90,7 +90,8 @@ def reduce_left[D](iterable: Iterable[D], f: Callable[[D, D], D]) -> D | Never:
|
|
|
90
90
|
Fold an iterable left with a function.
|
|
91
91
|
|
|
92
92
|
:param iterable: Iterable to be reduced (folded).
|
|
93
|
-
:param f: Two parameter function, first parameter for
|
|
93
|
+
:param f: Two parameter function, first parameter is for
|
|
94
|
+
the accumulator.
|
|
94
95
|
:return: Reduced item from the iterable.
|
|
95
96
|
:raises StopIteration: When called on an empty iterable.
|
|
96
97
|
:raises Exception: Does not catch any exceptions from ``f``.
|
|
@@ -98,7 +99,7 @@ def reduce_left[D](iterable: Iterable[D], f: Callable[[D, D], D]) -> D | Never:
|
|
|
98
99
|
.. warning::
|
|
99
100
|
|
|
100
101
|
- never returns if given an infinite iterable
|
|
101
|
-
- does not catch or re-
|
|
102
|
+
- does not catch or re-raise exceptions raised by ``f``
|
|
102
103
|
|
|
103
104
|
"""
|
|
104
105
|
it = iter(iterable)
|
|
@@ -126,10 +127,11 @@ def fold_left[D, L](
|
|
|
126
127
|
- initial item is required, does not default to ``0``
|
|
127
128
|
- handles non-numeric data just find
|
|
128
129
|
|
|
129
|
-
:param iterable:
|
|
130
|
-
:param f:
|
|
131
|
-
|
|
132
|
-
:
|
|
130
|
+
:param iterable: Iterable to be folded.
|
|
131
|
+
:param f: Two parameter function, first parameter is for
|
|
132
|
+
the accumulator.
|
|
133
|
+
:param initial: Mandatory initial item to start fold
|
|
134
|
+
:return: The folded item.
|
|
133
135
|
|
|
134
136
|
.. warning::
|
|
135
137
|
|
|
@@ -155,7 +157,7 @@ def maybe_fold_left[D, L](
|
|
|
155
157
|
- if iterable empty and no ``initial`` item given, return ``MayBe()``
|
|
156
158
|
|
|
157
159
|
:param iterable: The iterable to be folded.
|
|
158
|
-
:param f: First argument is for the
|
|
160
|
+
:param f: First argument is for the accumulator.
|
|
159
161
|
:param initial: Mandatory initial item to start fold.
|
|
160
162
|
:return: ``MayBe`` of a successfully folded item,
|
|
161
163
|
otherwise returns ``MayBe()``.
|
|
@@ -199,7 +201,7 @@ def sc_reduce_left[D](
|
|
|
199
201
|
Short circuit version of a left fold.
|
|
200
202
|
|
|
201
203
|
:param iterable: Iterable to be reduced from the left.
|
|
202
|
-
:param f: Two parameter function, first parameter for
|
|
204
|
+
:param f: Two parameter function, first parameter is for
|
|
203
205
|
the accumulator.
|
|
204
206
|
:param start: Delay starting the fold until it returns true.
|
|
205
207
|
:param stop: Prematurely stop the fold when it returns true.
|
|
@@ -261,7 +263,7 @@ def sc_reduce_right[D](
|
|
|
261
263
|
Short circuit version of a right fold.
|
|
262
264
|
|
|
263
265
|
:param iterable: Iterable to be reduced from the right.
|
|
264
|
-
:param f: Two parameter function, second parameter for
|
|
266
|
+
:param f: Two parameter function, second parameter is for
|
|
265
267
|
the accumulator.
|
|
266
268
|
:param start: Delay starting the fold until it returns true.
|
|
267
269
|
:param stop: Prematurely stop the fold when it returns true.
|
pythonic_fp/iterables/merging.py
CHANGED
|
@@ -35,9 +35,9 @@ class MergeEnum(Enum):
|
|
|
35
35
|
"""
|
|
36
36
|
.. admonition:: Iterable Blending Enums.
|
|
37
37
|
|
|
38
|
-
- **
|
|
39
|
-
- **
|
|
40
|
-
- **
|
|
38
|
+
- **Concat:** Concatenate first to last
|
|
39
|
+
- **Merge:** Merge until one is exhausted
|
|
40
|
+
- **Exhaust:** Merge until all are exhausted
|
|
41
41
|
|
|
42
42
|
"""
|
|
43
43
|
Concat = auto()
|
|
@@ -76,7 +76,7 @@ def merge[D](*iterables: Iterable[D], yield_partials: bool = False) -> Iterator[
|
|
|
76
76
|
"""
|
|
77
77
|
.. admonition:: merge iterables
|
|
78
78
|
|
|
79
|
-
Merge multiple iterables until one is exhausted.
|
|
79
|
+
Merge multiple iterables until one of them is exhausted.
|
|
80
80
|
|
|
81
81
|
:param iterables: Iterables to merge until one gets exhausted.
|
|
82
82
|
:param yield_partials: Yield any unpaired yielded items from other iterables.
|
|
@@ -112,7 +112,7 @@ def exhaust[D](*iterables: Iterable[D]) -> Iterator[D]:
|
|
|
112
112
|
"""
|
|
113
113
|
.. admonition:: exhaustively merge iterables
|
|
114
114
|
|
|
115
|
-
Merge multiple iterables until all are exhausted.
|
|
115
|
+
Merge multiple iterables until all of them are exhausted.
|
|
116
116
|
|
|
117
117
|
:param iterables: Iterables to exhaustively merge.
|
|
118
118
|
:yields: Merged items from the iterables until all of the
|
|
@@ -150,6 +150,10 @@ def blend[D](
|
|
|
150
150
|
|
|
151
151
|
Merge behavior based on value of merge_enum parameter.
|
|
152
152
|
|
|
153
|
+
- Concat: Concatenate first to last
|
|
154
|
+
- Merge: Merge until one is exhausted
|
|
155
|
+
- Exhaust: Merge until all are exhausted
|
|
156
|
+
|
|
153
157
|
:param iterables: Iterables to blend together.
|
|
154
158
|
:param merge_enum: ``MergeEnum`` to determine merging behavior.
|
|
155
159
|
:param yield_partials: Yield unpaired items from other iterables.
|
|
@@ -1,62 +1,52 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pythonic-fp-iterables
|
|
3
|
-
Version: 5.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 5.2.0
|
|
4
|
+
Summary: Composing and iterating iterables.
|
|
5
5
|
Keywords: iterables,iterators
|
|
6
6
|
Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
|
|
7
|
-
Requires-Python: >=3.
|
|
8
|
-
Description-Content-Type: text/
|
|
7
|
+
Requires-Python: >=3.14
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
9
|
Classifier: Development Status :: 5 - Production/Stable
|
|
10
10
|
Classifier: Framework :: Pytest
|
|
11
11
|
Classifier: Intended Audience :: Developers
|
|
12
12
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
13
|
Classifier: Operating System :: OS Independent
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
15
16
|
Classifier: Typing :: Typed
|
|
16
17
|
License-File: LICENSE
|
|
17
|
-
Requires-Dist: pythonic-fp-fptools>=
|
|
18
|
-
Requires-Dist: pythonic-fp-gadgets>=4.
|
|
19
|
-
|
|
20
|
-
Project-URL:
|
|
21
|
-
Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/projects/iterables.html
|
|
18
|
+
Requires-Dist: pythonic-fp-fptools>=6,<6.2
|
|
19
|
+
Requires-Dist: pythonic-fp-gadgets>=4.5,<6
|
|
20
|
+
Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-iterables/blob/main/CHANGELOG.md
|
|
21
|
+
Project-URL: Documentation, https://grscheller.github.io/pythonic-fp-iterables/release/html/
|
|
22
22
|
Project-URL: Homepage, https://grscheller.github.io/pythonic-fp/
|
|
23
23
|
Project-URL: Source, https://github.com/grscheller/pythonic-fp-iterables
|
|
24
|
-
Provides-Extra: test
|
|
25
24
|
|
|
26
|
-
Pythonic FP - Tools for iterables
|
|
27
|
-
|
|
25
|
+
# Pythonic FP - Tools for iterables
|
|
26
|
+
|
|
27
|
+
Library of functions for iterating iterables.
|
|
28
28
|
|
|
29
29
|
PyPI project
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
[pythonic-fp-iterators](https://pypi.org/project/pythonic-fp-iterables).
|
|
31
|
+
Part of the
|
|
32
|
+
[pythonic-fp](https://grscheller.github.io/pythonic-fp/)
|
|
33
|
+
PyPI projects.
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
## Documentation
|
|
36
|
+
|
|
37
|
+
Documentation and other links for this project are hosted on
|
|
38
|
+
[GitHub Pages](https://grscheller.github.io/pythonic-fp/projects/iterables.html).
|
|
34
39
|
|
|
35
40
|
- Concatenating and merging iterables
|
|
36
41
|
- Dropping and taking values from iterables
|
|
37
42
|
- Reducing and accumulating iterables
|
|
38
43
|
- Assumptions
|
|
39
|
-
|
|
40
44
|
- iterables are not necessarily iterators
|
|
41
45
|
- at all times iterator protocol is assumed to be followed
|
|
42
|
-
|
|
43
46
|
- all iterators are assumed to be iterable
|
|
44
47
|
- for all iterators ``foo`` we assume ``iter(foo) is foo``
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
`pythonic-fp
|
|
48
|
-
<https://grscheller.github.io/pythonic-fp/>`_
|
|
49
|
-
PyPI projects.
|
|
50
|
-
|
|
51
|
-
Documentation
|
|
52
|
-
-------------
|
|
53
|
-
|
|
54
|
-
Documentation and other links for this project are hosted on
|
|
55
|
-
`GitHub Pages
|
|
56
|
-
<https://grscheller.github.io/pythonic-fp/projects/iterables.html>`_.
|
|
57
|
-
|
|
58
|
-
Copyright and License
|
|
59
|
-
---------------------
|
|
49
|
+
## Copyright and License
|
|
60
50
|
|
|
61
51
|
Copyright (c) 2023-2026 Geoffrey R. Scheller. Licensed under the Apache
|
|
62
52
|
License, Version 2.0. See the LICENSE file for details.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
pythonic_fp/iterables/__init__.py,sha256=lL6SETAAn9sn2dGRBxvbJlswZwweym4OumCKbJfokQI,1246
|
|
2
|
+
pythonic_fp/iterables/drop_take.py,sha256=kZS8paCc-EOD42BGmCg-89e0W9CGFCXiB88Y4oE_lSg,5527
|
|
3
|
+
pythonic_fp/iterables/folding.py,sha256=IZmoWyuh8D9rS_g9K8DhSu_owM1_IJ_oIMsLJNqH28I,9377
|
|
4
|
+
pythonic_fp/iterables/merging.py,sha256=YYXrCNXHF9xuIMLOySTube6-_YUNB2GGirTa8VbpeLM,5038
|
|
5
|
+
pythonic_fp/iterables/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
pythonic_fp_iterables-5.2.0.dist-info/licenses/LICENSE,sha256=IJMkVWQUVy-SonK6SMaMotDQ6Zb-lVi2bUTiGp1GUO8,10774
|
|
7
|
+
pythonic_fp_iterables-5.2.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
8
|
+
pythonic_fp_iterables-5.2.0.dist-info/METADATA,sha256=yajE7AFhbVcOksI_nW2PdhDdURZjrRkRlpBfBAfiVdw,1997
|
|
9
|
+
pythonic_fp_iterables-5.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
from collections.abc import Callable, Iterable, Iterator
|
|
2
|
-
|
|
3
|
-
__all__ = ['drop', 'drop_while', 'take', 'take_while', 'take_split', 'take_while_split']
|
|
4
|
-
|
|
5
|
-
def drop[D](iterable: Iterable[D], n: int) -> Iterator[D]: ...
|
|
6
|
-
def drop_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[D]: ...
|
|
7
|
-
def take[D](iterable: Iterable[D], n: int) -> Iterator[D]: ...
|
|
8
|
-
def take_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[D]: ...
|
|
9
|
-
def take_split[D](iterable: Iterable[D], n: int) -> tuple[Iterator[D], Iterator[D]]: ...
|
|
10
|
-
def take_while_split[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> tuple[Iterator[D], Iterator[D]]: ...
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
from collections.abc import Callable, Iterable, Iterator
|
|
2
|
-
from pythonic_fp.fptools.maybe import MayBe
|
|
3
|
-
from pythonic_fp.gadgets.sentinels.novalue import NoValue
|
|
4
|
-
from typing import Never
|
|
5
|
-
|
|
6
|
-
__all__ = ['accumulate', 'reduce_left', 'fold_left', 'maybe_fold_left', 'sc_reduce_left', 'sc_reduce_right']
|
|
7
|
-
|
|
8
|
-
def accumulate[D, L](iterable: Iterable[D], f: Callable[[L, D], L], initial: L | NoValue = ...) -> Iterator[L]: ...
|
|
9
|
-
def reduce_left[D](iterable: Iterable[D], f: Callable[[D, D], D]) -> D | Never: ...
|
|
10
|
-
def fold_left[D, L](iterable: Iterable[D], f: Callable[[L, D], L], initial: L) -> L | Never: ...
|
|
11
|
-
def maybe_fold_left[D, L](iterable: Iterable[D], f: Callable[[L, D], L], initial: L | NoValue = ...) -> MayBe[L] | Never: ...
|
|
12
|
-
def sc_reduce_left[D](iterable: Iterable[D], f: Callable[[D, D], D], start: Callable[[D], bool] = ..., stop: Callable[[D], bool] = ..., include_start: bool = True, include_stop: bool = True) -> tuple[MayBe[D], Iterator[D]]: ...
|
|
13
|
-
def sc_reduce_right[D](iterable: Iterable[D], f: Callable[[D, D], D], start: Callable[[D], bool] = ..., stop: Callable[[D], bool] = ..., include_start: bool = True, include_stop: bool = True) -> tuple[MayBe[D], Iterator[D]]: ...
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
from collections.abc import Iterable, Iterator
|
|
2
|
-
from enum import Enum
|
|
3
|
-
|
|
4
|
-
__all__ = ['MergeEnum', 'concat', 'merge', 'exhaust', 'blend']
|
|
5
|
-
|
|
6
|
-
class MergeEnum(Enum):
|
|
7
|
-
Concat = ...
|
|
8
|
-
Merge = ...
|
|
9
|
-
Exhaust = ...
|
|
10
|
-
|
|
11
|
-
def concat[D](*iterables: Iterable[D]) -> Iterator[D]: ...
|
|
12
|
-
def merge[D](*iterables: Iterable[D], yield_partials: bool = False) -> Iterator[D]: ...
|
|
13
|
-
def exhaust[D](*iterables: Iterable[D]) -> Iterator[D]: ...
|
|
14
|
-
def blend[D](*iterables: Iterable[D], merge_enum: MergeEnum = ..., yield_partials: bool = False) -> Iterator[D]: ...
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
pythonic_fp/iterables/__init__.py,sha256=j-Z9XV73LehhLwYvi_Wzhml7hPaEbHiRjRJt-BI6RKs,1255
|
|
2
|
-
pythonic_fp/iterables/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
pythonic_fp/iterables/drop_take.py,sha256=0ydMGx-aj_-aK5PIx7Rowh_9h0niC6bRKMSotHjvy1g,5558
|
|
4
|
-
pythonic_fp/iterables/drop_take.pyi,sha256=vPyByY4PxCGEuL6trI0aTK8fBr4xCuOgqhaKALwJ5Ys,653
|
|
5
|
-
pythonic_fp/iterables/folding.py,sha256=tqFzxzWLpK6qIS9ff8tTwv58q2h4gjBAyuHrNeEWi20,9347
|
|
6
|
-
pythonic_fp/iterables/folding.pyi,sha256=ZVrpB-D4kWoVwpCsQ2rc3GJ8iTzavAOQ5YK9LteAukU,1175
|
|
7
|
-
pythonic_fp/iterables/merging.py,sha256=acQ8_Iw07CVvOnB_D8dbLvmkjv7P48CysareWlfAbRc,4912
|
|
8
|
-
pythonic_fp/iterables/merging.pyi,sha256=KnuSFREXEpnbtTvMWsvn-KfeSjZ3ybP-6n9hCxjNKVs,533
|
|
9
|
-
pythonic_fp/iterables/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
pythonic_fp_iterables-5.1.4.dist-info/licenses/LICENSE,sha256=IJMkVWQUVy-SonK6SMaMotDQ6Zb-lVi2bUTiGp1GUO8,10774
|
|
11
|
-
pythonic_fp_iterables-5.1.4.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
12
|
-
pythonic_fp_iterables-5.1.4.dist-info/METADATA,sha256=zOdoxJujuqsKpXHZqKfI-0wJRmnKEDdy5T_KjMXMJGQ,2096
|
|
13
|
-
pythonic_fp_iterables-5.1.4.dist-info/RECORD,,
|
|
File without changes
|
{pythonic_fp_iterables-5.1.4.dist-info → pythonic_fp_iterables-5.2.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|