pythonic-fp.iterables 5.1.0__py3-none-any.whl → 5.1.2__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.
File without changes
@@ -36,9 +36,9 @@ __all__ = [
36
36
  def drop[D](iterable: Iterable[D], n: int) -> Iterator[D]:
37
37
  """Drop the next n values from iterable.
38
38
 
39
- :param iterable: iterable whose values are to be dropped
40
- :param n: number of values to be dropped
41
- :returns: an iterator of the remaining values
39
+ :param iterable: Iterable whose values are to be dropped.
40
+ :param n: Number of values to be dropped.
41
+ :returns: An iterator of the remaining values.
42
42
 
43
43
  """
44
44
  iterator = iter(iterable)
@@ -53,9 +53,9 @@ def drop[D](iterable: Iterable[D], n: int) -> Iterator[D]:
53
53
  def drop_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[D]:
54
54
  """Drop initial values from iterable while predicate is true.
55
55
 
56
- :param iterable: iterable whose values are to be dropped
57
- :param pred: Boolean valued function, the "predicate"
58
- :return: an iterator beginning where pred returned false
56
+ :param iterable: Iterable whose values are to be dropped.
57
+ :param pred: Single argument Boolean valued function, the "predicate".
58
+ :returns: An iterator beginning where pred returned false.
59
59
 
60
60
  """
61
61
  iterator = iter(iterable)
@@ -73,9 +73,9 @@ def drop_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[
73
73
  def take[D](iterable: Iterable[D], n: int) -> Iterator[D]:
74
74
  """Return an iterator of up to n initial values of an iterable.
75
75
 
76
- :param iterable: iterable providing the values to be taken
77
- :param n: number of values to be dropped
78
- :return: an iterator of up to n initial values from iterable
76
+ :param Iterable: iterable providing the values to be taken.
77
+ :param n: Number of values to be dropped.
78
+ :returns: An iterator of up to n initial values from iterable.
79
79
 
80
80
  """
81
81
  iterator = iter(iterable)
@@ -91,11 +91,12 @@ def take_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[
91
91
  """Yield values from iterable while predicate is true.
92
92
 
93
93
  .. warning::
94
+
94
95
  Risk of value loss if iterable is multiple referenced iterator.
95
96
 
96
- :param iterable: iterable providing the values to be taken
97
- :param pred: Boolean valued function, the "predicate"
98
- :return: an Iterator of of values from iterable until predicate false
97
+ :param iterable: Iterable providing the values to be taken.
98
+ :param pred: Single argument Boolean valued function, the "predicate".
99
+ :returns: An Iterator of of values from iterable until predicate false.
99
100
 
100
101
  """
101
102
  iterator = iter(iterable)
@@ -115,12 +116,12 @@ def take_split[D](iterable: Iterable[D], n: int) -> tuple[Iterator[D], Iterator[
115
116
 
116
117
  .. Warning::
117
118
 
118
- **CONTRACT:** Do not access the second returned iterator until the
119
- first one is exhausted.
119
+ **CONTRACT:** Do not access the second returned iterator until the
120
+ first one is exhausted.
120
121
 
121
- :param iterable: iterable providing the values to be taken
122
- :param n: maximum number of values to be taken
123
- :return: an iterator of values taken and an iterator of remaining values
122
+ :param iterable: Iterable providing the values to be taken.
123
+ :param n: maximum Number of values to be taken.
124
+ :returns: An iterator of values taken and an iterator of remaining values.
124
125
 
125
126
  """
126
127
  iterator = iter(iterable)
@@ -136,12 +137,12 @@ def take_while_split[D](
136
137
 
137
138
  .. Warning::
138
139
 
139
- **CONTRACT:** Do not access the second returned iterator until
140
- the first one is exhausted.
140
+ **CONTRACT:** Do not access the second returned iterator until
141
+ the first one is exhausted.
141
142
 
142
- :param iterable: iterable providing the values to be taken
143
- :param pred: Boolean valued function
144
- :return: tuple containing an iterator of values taken and an iterator of remaining values
143
+ :param iterable: Iterable providing the values to be taken.
144
+ :param pred: Single argument Boolean valued function.
145
+ :returns: Tuple of iterator of values taken and an iterator of remaining values.
145
146
 
146
147
  """
147
148
 
@@ -1,33 +1,10 @@
1
- # Copyright 2023-2025 Geoffrey R. Scheller
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
1
  from collections.abc import Callable, Iterable, Iterator
16
2
 
17
- __all__ = [
18
- 'drop',
19
- 'drop_while',
20
- 'take',
21
- 'take_while',
22
- 'take_split',
23
- 'take_while_split',
24
- ]
3
+ __all__ = ['drop', 'drop_while', 'take', 'take_while', 'take_split', 'take_while_split']
25
4
 
26
5
  def drop[D](iterable: Iterable[D], n: int) -> Iterator[D]: ...
27
6
  def drop_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[D]: ...
28
7
  def take[D](iterable: Iterable[D], n: int) -> Iterator[D]: ...
29
8
  def take_while[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> Iterator[D]: ...
30
9
  def take_split[D](iterable: Iterable[D], n: int) -> tuple[Iterator[D], Iterator[D]]: ...
31
- def take_while_split[D](
32
- iterable: Iterable[D], pred: Callable[[D], bool]
33
- ) -> tuple[Iterator[D], Iterator[D]]: ...
10
+ def take_while_split[D](iterable: Iterable[D], pred: Callable[[D], bool]) -> tuple[Iterator[D], Iterator[D]]: ...
@@ -18,7 +18,7 @@ from collections.abc import Callable, Iterable, Iterator
18
18
  from typing import cast, Never
19
19
  from pythonic_fp.fptools.function import negate, swap
20
20
  from pythonic_fp.fptools.maybe import MayBe
21
- from pythonic_fp.sentinels.novalue import NoValue
21
+ from pythonic_fp.gadgets.sentinels.novalue import NoValue
22
22
  from .drop_take import drop_while, take_while_split
23
23
 
24
24
  __all__ = [
@@ -1,56 +1,13 @@
1
- # Copyright 2023-2025 Geoffrey R. Scheller
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
1
  from collections.abc import Callable, Iterable, Iterator
16
- from typing import cast, Never
17
- from pythonic_fp.fptools.function import negate, swap
18
2
  from pythonic_fp.fptools.maybe import MayBe
19
- from pythonic_fp.sentinels.novalue import NoValue
20
- from .drop_take import drop_while, take_while_split
3
+ from pythonic_fp.gadgets.sentinels.novalue import NoValue
4
+ from typing import Never
21
5
 
22
- __all__ = [
23
- 'accumulate',
24
- 'reduce_left',
25
- 'fold_left',
26
- 'maybe_fold_left',
27
- 'sc_reduce_left',
28
- 'sc_reduce_right',
29
- ]
6
+ __all__ = ['accumulate', 'reduce_left', 'fold_left', 'maybe_fold_left', 'sc_reduce_left', 'sc_reduce_right']
30
7
 
31
- def accumulate[D, L](
32
- iterable: Iterable[D], f: Callable[[L, D], L], initial: L | NoValue = NoValue()
33
- ) -> Iterator[L]: ...
8
+ def accumulate[D, L](iterable: Iterable[D], f: Callable[[L, D], L], initial: L | NoValue = ...) -> Iterator[L]: ...
34
9
  def reduce_left[D](iterable: Iterable[D], f: Callable[[D, D], D]) -> D | Never: ...
35
- def fold_left[D, L](
36
- iterable: Iterable[D], f: Callable[[L, D], L], initial: L
37
- ) -> L | Never: ...
38
- def maybe_fold_left[D, L](
39
- iterable: Iterable[D], f: Callable[[L, D], L], initial: L | NoValue = NoValue()
40
- ) -> MayBe[L] | Never: ...
41
- def sc_reduce_left[D](
42
- iterable: Iterable[D],
43
- f: Callable[[D, D], D],
44
- start: Callable[[D], bool] = (lambda d: True),
45
- stop: Callable[[D], bool] = (lambda d: False),
46
- include_start: bool = True,
47
- include_stop: bool = True,
48
- ) -> tuple[MayBe[D], Iterator[D]]: ...
49
- def sc_reduce_right[D](
50
- iterable: Iterable[D],
51
- f: Callable[[D, D], D],
52
- start: Callable[[D], bool] = (lambda d: False),
53
- stop: Callable[[D], bool] = (lambda d: False),
54
- include_start: bool = True,
55
- include_stop: bool = True,
56
- ) -> tuple[MayBe[D], Iterator[D]]: ...
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]]: ...
@@ -51,8 +51,8 @@ def concat[D](*iterables: Iterable[D]) -> Iterator[D]:
51
51
 
52
52
  Performant to the standard library's ``itertools.chain``.
53
53
 
54
- :param iterables: iterables to concatenate
55
- :return: iterator of concatenated values from the iterables
54
+ :param iterables: Iterables to concatenate.
55
+ :returns: Iterator of concatenated values from the iterables.
56
56
 
57
57
  """
58
58
  for iterator in map(lambda x: iter(x), iterables):
@@ -69,13 +69,13 @@ def merge[D](*iterables: Iterable[D], yield_partials: bool = False) -> Iterator[
69
69
 
70
70
  .. note::
71
71
 
72
- When ``yield_partials`` is true, then any unmatched values from other iterables
73
- already yielded when the first iterable is exhausted are yielded. This prevents
74
- data lose if any of the iterables are iterators with external references.
72
+ When ``yield_partials`` is true, then any unmatched values from other iterables
73
+ already yielded when the first iterable is exhausted are yielded. This prevents
74
+ data lose if any of the iterables are iterators with external references.
75
75
 
76
- :param iterables: iterables to merge until one gets exhausted
77
- :param yield_partials: yield any unpaired yielded values from other iterables
78
- :return: iterator of merged values from the iterables until one is exhausted
76
+ :param iterables: Iterables to merge until one gets exhausted.
77
+ :param yield_partials: Yield any unpaired yielded values from other iterables.
78
+ :returns: Iterator of merged values from the iterables until one is exhausted.
79
79
 
80
80
  """
81
81
  iter_list = list(map(lambda x: iter(x), iterables))
@@ -96,8 +96,8 @@ def merge[D](*iterables: Iterable[D], yield_partials: bool = False) -> Iterator[
96
96
  def exhaust[D](*iterables: Iterable[D]) -> Iterator[D]:
97
97
  """Merge together multiple iterables until all are exhausted.
98
98
 
99
- :param iterables: iterables to exhaustively merge
100
- :return: iterator of merged values from the iterables until all are exhausted
99
+ :param iterables: Iterables to exhaustively merge.
100
+ :returns: Iterator of merged values from the iterables until all are exhausted.
101
101
 
102
102
  """
103
103
  iter_list = list(map(lambda x: iter(x), iterables))
@@ -128,11 +128,11 @@ def blend[D](
128
128
  ) -> Iterator[D]:
129
129
  """Base merge behavior on name only parameters.
130
130
 
131
- :param iterables: iterables to blend together
132
- :param merge_enum: MergeEnum to determine merging behavior
133
- :param yield_partials: yield yielded unpaired values from other iterables
134
- :return: an iterator of type D
135
- :raises ValueError: when an unknown MergeEnum is given
131
+ :param iterables: Iterables to blend together.
132
+ :param merge_enum: ``MergeEnum`` to determine merging behavior.
133
+ :param yield_partials: Yield unpaired values from other iterables.
134
+ :returns: An iterator of type ``D``.
135
+ :raises ValueError: When an unknown ``MergeEnum`` is given.
136
136
 
137
137
  """
138
138
  match merge_enum:
@@ -1,38 +1,14 @@
1
- # Copyright 2023-2025 Geoffrey R. Scheller
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
1
  from collections.abc import Iterable, Iterator
16
- from enum import auto, Enum
2
+ from enum import Enum
17
3
 
18
- __all__ = [
19
- 'MergeEnum',
20
- 'concat',
21
- 'merge',
22
- 'exhaust',
23
- 'blend',
24
- ]
4
+ __all__ = ['MergeEnum', 'concat', 'merge', 'exhaust', 'blend']
25
5
 
26
6
  class MergeEnum(Enum):
27
- Concat = auto()
28
- Merge = auto()
29
- Exhaust = auto()
7
+ Concat = ...
8
+ Merge = ...
9
+ Exhaust = ...
30
10
 
31
11
  def concat[D](*iterables: Iterable[D]) -> Iterator[D]: ...
32
12
  def merge[D](*iterables: Iterable[D], yield_partials: bool = False) -> Iterator[D]: ...
33
13
  def exhaust[D](*iterables: Iterable[D]) -> Iterator[D]: ...
34
- def blend[D](
35
- *iterables: Iterable[D],
36
- merge_enum: MergeEnum = MergeEnum.Concat,
37
- yield_partials: bool = False,
38
- ) -> Iterator[D]: ...
14
+ def blend[D](*iterables: Iterable[D], merge_enum: MergeEnum = ..., yield_partials: bool = False) -> Iterator[D]: ...
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythonic-fp-iterables
3
- Version: 5.1.0
3
+ Version: 5.1.2
4
4
  Summary: Library of functions for iterating iterables
5
5
  Keywords: iterables,iterators
6
6
  Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
@@ -14,13 +14,12 @@ Classifier: Operating System :: OS Independent
14
14
  Classifier: Programming Language :: Python :: 3.13
15
15
  Classifier: Typing :: Typed
16
16
  License-File: LICENSE
17
- Requires-Dist: pythonic-fp-fptools>=5.1.0
18
- Requires-Dist: pythonic-fp-gadgets>=3.0.1
19
- Requires-Dist: pythonic-fp-sentinels>=2.1.1
17
+ Requires-Dist: pythonic-fp-fptools>=5.1.2
18
+ Requires-Dist: pythonic-fp-gadgets>=3.1.0
20
19
  Requires-Dist: pytest>=8.4.1 ; extra == "test"
21
20
  Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-iterables/blob/main/CHANGELOG.rst
22
- Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/iterables/development/build/html/releases.html
23
- Project-URL: Homepage, https://github.com/grscheller/pythonic-fp/blob/main/README.md
21
+ Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/iterables/development/build/html/
22
+ Project-URL: Homepage, https://grscheller.github.io/pythonic-fp/homepage/build/html/
24
23
  Project-URL: Source, https://github.com/grscheller/pythonic-fp-iterables
25
24
  Provides-Extra: test
26
25
 
@@ -43,8 +42,10 @@ Library of functions for iterating iterables.
43
42
  - all iterators are assumed to be iterable
44
43
  - for all iterators ``foo`` we assume ``iter(foo) is foo``
45
44
 
46
- This PyPI project is part of of the
47
- `pythonic-fp namespace projects <https://github.com/grscheller/pythonic-fp/blob/main/README.md>`_
45
+ Part of the
46
+ `pythonic-fp
47
+ <https://grscheller.github.io/pythonic-fp/homepage/build/html/index.html>`_
48
+ PyPI projects.
48
49
 
49
50
  Documentation
50
51
  -------------
@@ -0,0 +1,13 @@
1
+ pythonic_fp/iterables/__init__.py,sha256=UTde8stsDVG_5Z7fo37yiYeTu8fhkkv0QsQcQb_ixTU,1590
2
+ pythonic_fp/iterables/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ pythonic_fp/iterables/drop_take.py,sha256=VpcnQp0Nr4bUGXb-TD2UFl5kHo1fllAFoV_hlYHo8G0,4772
4
+ pythonic_fp/iterables/drop_take.pyi,sha256=vPyByY4PxCGEuL6trI0aTK8fBr4xCuOgqhaKALwJ5Ys,653
5
+ pythonic_fp/iterables/folding.py,sha256=lUvQzRU1wFbolw-b3bI1oU_xk7yIj2V5J8WA-qQxvUc,8612
6
+ pythonic_fp/iterables/folding.pyi,sha256=ZVrpB-D4kWoVwpCsQ2rc3GJ8iTzavAOQ5YK9LteAukU,1175
7
+ pythonic_fp/iterables/merging.py,sha256=CiBYp-iAr-iQrVTWK0wOkFDs9EJ9139p_MRiffIZJ2s,4485
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.2.dist-info/licenses/LICENSE,sha256=IJMkVWQUVy-SonK6SMaMotDQ6Zb-lVi2bUTiGp1GUO8,10774
11
+ pythonic_fp_iterables-5.1.2.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
12
+ pythonic_fp_iterables-5.1.2.dist-info/METADATA,sha256=G2d_xgzY-1WoYRBu-QoJbAO9PbV5O3uzcchy9fOO6ho,2143
13
+ pythonic_fp_iterables-5.1.2.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- pythonic_fp/iterables/__init__.py,sha256=UTde8stsDVG_5Z7fo37yiYeTu8fhkkv0QsQcQb_ixTU,1590
2
- pythonic_fp/iterables/drop_take.py,sha256=bHxVTJAY9vof570cFQNXNZZAUAtnWBDZgRu7df2aV9E,4707
3
- pythonic_fp/iterables/drop_take.pyi,sha256=6BtavkUHIxMJmJfcvDAnds9R29OXrCRkDK12jG575VY,1276
4
- pythonic_fp/iterables/folding.py,sha256=A4VoU7piryt6Fun6Inn1SJSr1IiN-aTqzeSs-mds5oQ,8604
5
- pythonic_fp/iterables/folding.pyi,sha256=BUslV-cn9eOxlYAF_3wz09TcHDbMATUL0uqU7IjJyAM,2035
6
- pythonic_fp/iterables/merging.py,sha256=tPVjw5Fr32gMTd4Uq3SKQPqdV9p5fs3xW-0elt8Yz8U,4462
7
- pythonic_fp/iterables/merging.pyi,sha256=5QBH0NEoqWQwCvWMPBFVoUOWAwmMYqj2W4s2b1rn9J0,1189
8
- pythonic_fp/iterables/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- pythonic_fp_iterables-5.1.0.dist-info/licenses/LICENSE,sha256=IJMkVWQUVy-SonK6SMaMotDQ6Zb-lVi2bUTiGp1GUO8,10774
10
- pythonic_fp_iterables-5.1.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
11
- pythonic_fp_iterables-5.1.0.dist-info/METADATA,sha256=FjgztLEfjG2VBYMtg_XUa0gyZTplavSKb523m746npY,2218
12
- pythonic_fp_iterables-5.1.0.dist-info/RECORD,,