pythonic-fp-queues 5.1.2__py3-none-any.whl → 5.1.3__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/queues/de.py CHANGED
@@ -38,18 +38,22 @@ class DEQueue[D]:
38
38
 
39
39
  __slots__ = ('_ca',)
40
40
 
41
- def __init__(self, *dss: Iterable[D]) -> None:
41
+ def __init__(self, *ds: Iterable[D]) -> None:
42
42
  """
43
- :param dss: Takes 0 or 1 iterable parameters. Populates
44
- queue from the iterable left to right.
43
+ .. admonition:: Initializer
44
+
45
+ Initialize ``DEQueue`` with 0 or 1 iterables to populate
46
+ the queue left (front) to right (rear).
47
+
48
+ :param ds: Takes 0 or 1 iterable parameters.
49
+ :raises ValueError: When more than one parameter is provided.
45
50
  :raises TypeError: When passed a non-iterable parameter.
46
- :raises ValueError: When more than one parameter is given.
47
51
 
48
52
  """
49
- if (size := len(dss)) > 1:
53
+ if (size := len(ds)) > 1:
50
54
  msg = f'DEQueue expects at most 1 argument, got {size}'
51
55
  raise ValueError(msg)
52
- self._ca = CA(dss[0]) if size == 1 else CA()
56
+ self._ca = CA(ds[0]) if size == 1 else CA()
53
57
 
54
58
  def __bool__(self) -> bool:
55
59
  """
@@ -61,9 +65,25 @@ class DEQueue[D]:
61
65
  return len(self._ca) > 0
62
66
 
63
67
  def __len__(self) -> int:
68
+ """
69
+ .. admonition:: Get length
70
+
71
+ Return the number of data elements in the ``DEQueue``.
72
+
73
+ """
64
74
  return len(self._ca)
65
75
 
66
76
  def __eq__(self, other: object) -> bool:
77
+ """
78
+ .. admonition:: Equality comparison
79
+
80
+ If ``other`` is a ``DEQueue`` and the corresponding
81
+ elements of ``self`` and ``other`` compare as equal,
82
+ then return ``True``. Otherwise return ``False``.
83
+
84
+ :returns: ``self == other``
85
+
86
+ """
67
87
  if not isinstance(other, DEQueue):
68
88
  return False
69
89
  return self._ca == other._ca
@@ -91,20 +111,40 @@ class DEQueue[D]:
91
111
  return reversed(list(self._ca))
92
112
 
93
113
  def __repr__(self) -> str:
114
+ """
115
+ .. admonition:: String representation
116
+
117
+ Construct string 'DEQueue(d₁, d₂, … dₙ)' where
118
+
119
+ - d₁, d₂, … dₙ are the contents displayed with ``repr()``
120
+
121
+ :returns: A string to reproduce the ``DEQueue``.
122
+
123
+ """
94
124
  if len(self) == 0:
95
125
  return 'DEQueue()'
96
126
  return 'DEQueue(' + ', '.join(map(repr, self._ca)) + ')'
97
127
 
98
128
  def __str__(self) -> str:
129
+ r"""
130
+ .. admonition:: User string
131
+
132
+ Construct string '>< d₁ | d₂ | … | dₙ ><' where
133
+
134
+ - d₁, d₂, ..., dₙ are the contents displayed with ``str()``
135
+
136
+ :returns: A string meaningful to an end user.
137
+
138
+ """
99
139
  return '>< ' + ' | '.join(map(str, self)) + ' ><'
100
140
 
101
141
  def copy(self) -> 'DEQueue[D]':
102
142
  """
103
- .. admonition:: Shallow copy
143
+ .. admonition:: Copy
104
144
 
105
- Make a shallow copy of the queue.
145
+ Shallow copy the ``DEQueue``.
106
146
 
107
- :returns: Shallow copy of the ``DEQueue``.
147
+ :returns: New ``DEQueue`` instance containing the same references.
108
148
 
109
149
  """
110
150
  return DEQueue(self._ca)
@@ -200,7 +240,7 @@ class DEQueue[D]:
200
240
 
201
241
  :param f: Reducing function, first argument is for accumulator.
202
242
  :param start: Optional starting value.
203
- :returns: ``MayBe`` of reduced value with f, empty ``MayBe`` if
243
+ :returns: ``MayBe`` of reduced value with ``f``, empty ``MayBe`` if
204
244
  queue empty and no starting value given.
205
245
 
206
246
  """
@@ -223,8 +263,8 @@ class DEQueue[D]:
223
263
 
224
264
  :param f: Reducing function, second argument is for accumulator.
225
265
  :param start: Optional starting value.
226
- :returns: ``MayBe`` of reduced value with f, empty ``MayBe`` if
227
- queue empty and no starting value given.
266
+ :returns: ``MayBe`` of reduced value with ``f``, empty ``MayBe``
267
+ if queue empty and no starting value given.
228
268
 
229
269
  """
230
270
  if start is None:
@@ -37,18 +37,22 @@ class FIFOQueue[D]:
37
37
 
38
38
  __slots__ = ('_ca',)
39
39
 
40
- def __init__(self, *dss: Iterable[D]) -> None:
40
+ def __init__(self, *ds: Iterable[D]) -> None:
41
41
  """
42
- :param dss: Takes 0 or 1 iterable parameters. Populates
43
- queue from the iterable in FIFO order.
42
+ .. admonition:: Initializer
43
+
44
+ Initialize ``FIFOQueue`` with 0 or 1 iterables to populate
45
+ the queue in natural FIFO order.
46
+
47
+ :param ds: Takes 0 or 1 iterable parameters.
48
+ :raises ValueError: When more than one parameter is provided.
44
49
  :raises TypeError: When passed a non-iterable parameter.
45
- :raises ValueError: When more than one parameter is given.
46
50
 
47
51
  """
48
- if (size := len(dss)) > 1:
52
+ if (size := len(ds)) > 1:
49
53
  msg = f'FIFOQueue expects at most 1 iterable argument, got {size}'
50
54
  raise ValueError(msg)
51
- self._ca = CA(dss[0]) if size == 1 else CA()
55
+ self._ca = CA(ds[0]) if size == 1 else CA()
52
56
 
53
57
  def __bool__(self) -> bool:
54
58
  """
@@ -60,9 +64,25 @@ class FIFOQueue[D]:
60
64
  return len(self._ca) > 0
61
65
 
62
66
  def __len__(self) -> int:
67
+ """
68
+ .. admonition:: Get length
69
+
70
+ Return the number of data elements in the ``FIFOQueue``.
71
+
72
+ """
63
73
  return len(self._ca)
64
74
 
65
75
  def __eq__(self, other: object) -> bool:
76
+ """
77
+ .. admonition:: Equality comparison
78
+
79
+ If ``other`` is a ``FIFOQueue`` and the corresponding
80
+ elements of ``self`` and ``other`` compare as equal,
81
+ then return ``True``. Otherwise return ``False``.
82
+
83
+ :returns: ``self == other``
84
+
85
+ """
66
86
  if not isinstance(other, FIFOQueue):
67
87
  return False
68
88
  return self._ca == other._ca
@@ -79,20 +99,40 @@ class FIFOQueue[D]:
79
99
  return iter(list(self._ca))
80
100
 
81
101
  def __repr__(self) -> str:
102
+ """
103
+ .. admonition:: String representation
104
+
105
+ Construct string 'FIFOQueue(d₁, d₂, … dₙ)' where
106
+
107
+ - d₁, d₂, … dₙ are the contents displayed with ``repr()``
108
+
109
+ :returns: A string to reproduce the ``FIFOQueue``.
110
+
111
+ """
82
112
  if len(self) == 0:
83
113
  return 'FIFOQueue()'
84
114
  return 'FIFOQueue(' + ', '.join(map(repr, self._ca)) + ')'
85
115
 
86
116
  def __str__(self) -> str:
117
+ """
118
+ .. admonition:: User string
119
+
120
+ Construct string '<< d₁ < d₂ < … < dₙ <<' where
121
+
122
+ - d₁, d₂, ..., dₙ are the contents displayed with ``str()``
123
+
124
+ :returns: A string meaningful to an end user.
125
+
126
+ """
87
127
  return '<< ' + ' < '.join(map(str, self)) + ' <<'
88
128
 
89
129
  def copy(self) -> 'FIFOQueue[D]':
90
130
  """
91
- .. admonition:: Shallow copy
131
+ .. admonition:: Copy
92
132
 
93
- Make a shallow copy of the ``FIFOQueue``.
133
+ Shallow copy the ``FIFOQueue``.
94
134
 
95
- :returns: Shallow copy of the ``FIFOQueue``.
135
+ :returns: New ``FIFOQueue`` instance containing the same references.
96
136
 
97
137
  """
98
138
  return FIFOQueue(self._ca)
@@ -163,8 +203,8 @@ class FIFOQueue[D]:
163
203
 
164
204
  :param f: Reducing function, first argument is for accumulator.
165
205
  :param start: Optional starting value.
166
- :returns: ``MayBe`` of reduced value, empty ``MayBe`` if ``FIFOQueue``
167
- empty and no starting value given.
206
+ :returns: ``MayBe`` of reduced value with ``f``, empty ``MayBe``
207
+ if ``FIFOQueue`` empty and no starting value given.
168
208
 
169
209
  """
170
210
  if start is None:
@@ -37,18 +37,22 @@ class LIFOQueue[D]:
37
37
  """
38
38
  __slots__ = ('_ca',)
39
39
 
40
- def __init__(self, *dss: Iterable[D]) -> None:
40
+ def __init__(self, *ds: Iterable[D]) -> None:
41
41
  """
42
- :param dss: Takes 0 or 1 iterable parameters. Populates
43
- queue from the iterable in LIFO order.
42
+ .. admonition:: Initializer
43
+
44
+ Initialize ``LIFOQueue`` with 0 or 1 iterables to populate
45
+ the queue in natural LIFO order.
46
+
47
+ :param ds: Takes 0 or 1 iterable parameters.
48
+ :raises ValueError: When more than one parameter is provided.
44
49
  :raises TypeError: When passed a non-iterable parameter.
45
- :raises ValueError: When more than one parameter is given.
46
50
 
47
51
  """
48
- if (size := len(dss)) > 1:
52
+ if (size := len(ds)) > 1:
49
53
  msg = f'LIFOQueue expects at most 1 iterable argument, got {size}'
50
54
  raise ValueError(msg)
51
- self._ca = CA(dss[0]) if size == 1 else CA()
55
+ self._ca = CA(ds[0]) if size == 1 else CA()
52
56
 
53
57
  def __bool__(self) -> bool:
54
58
  """
@@ -60,9 +64,25 @@ class LIFOQueue[D]:
60
64
  return len(self._ca) > 0
61
65
 
62
66
  def __len__(self) -> int:
67
+ """
68
+ .. admonition:: Get length
69
+
70
+ Return the number of data elements in the ``LIFOQueue``.
71
+
72
+ """
63
73
  return len(self._ca)
64
74
 
65
75
  def __eq__(self, other: object) -> bool:
76
+ """
77
+ .. admonition:: Equality comparison
78
+
79
+ If ``other`` is a ``LIFOQueue`` and the corresponding
80
+ elements of ``self`` and ``other`` compare as equal,
81
+ then return ``True``. Otherwise return ``False``.
82
+
83
+ :returns: ``self == other``
84
+
85
+ """
66
86
  if not isinstance(other, LIFOQueue):
67
87
  return False
68
88
  return self._ca == other._ca
@@ -79,26 +99,49 @@ class LIFOQueue[D]:
79
99
  return reversed(list(self._ca))
80
100
 
81
101
  def __repr__(self) -> str:
102
+ """
103
+ .. admonition:: String representation
104
+
105
+ Construct string 'LIFOQueue(d₁, d₂, … dₙ)' where
106
+
107
+ - d₁, d₂, … dₙ are the contents displayed with ``repr()``
108
+
109
+ :returns: A string to reproduce the ``LIFOQueue``.
110
+
111
+ """
82
112
  if len(self) == 0:
83
113
  return 'LIFOQueue()'
84
114
  return 'LIFOQueue(' + ', '.join(map(repr, self._ca)) + ')'
85
115
 
86
116
  def __str__(self) -> str:
117
+ r"""
118
+ .. admonition:: User string
119
+
120
+ Construct string '|| d₁ > d₂ > … > dₙ ><' where
121
+
122
+ - d₁, d₂, ..., dₙ are the contents displayed with ``str()``
123
+
124
+ :returns: A string meaningful to an end user.
125
+
126
+ """
87
127
  return '|| ' + ' > '.join(map(str, self)) + ' ><'
88
128
 
89
129
  def copy(self) -> 'LIFOQueue[D]':
90
130
  """
91
- .. admonition:: Shallow copy
131
+ .. admonition:: Copy
92
132
 
93
- Make a shallow copy of the ``LIFOQueue``.
133
+ Shallow copy the ``LIFOQueue``.
94
134
 
95
- :returns: Shallow copy of the ``LIFOQueue``.
135
+ :returns: New ``LIFOQueue`` instance containing the same references.
96
136
 
97
137
  """
98
138
  return LIFOQueue(reversed(self._ca))
99
139
 
100
140
  def push(self, *ds: D) -> None:
101
- """Push items onto LIFOQueue.
141
+ """
142
+ .. admonition:: Push
143
+
144
+ Push items onto ``LIFOQueue``.
102
145
 
103
146
  :param ds: Items to be pushed onto ``LIFOQueue``.
104
147
 
@@ -145,8 +188,8 @@ class LIFOQueue[D]:
145
188
 
146
189
  :param f: Reducing function, first argument is for accumulator.
147
190
  :param start: Optional starting value.
148
- :returns: ``MayBe`` of reduced value, empty ``MayBe`` if ``LIFOQueue``
149
- empty and no starting value given.
191
+ :returns: ``MayBe`` of reduced value with ``f``, empty ``MayBe``
192
+ if ``LIFOQueue`` empty and no starting value given.
150
193
 
151
194
  """
152
195
  if start is None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythonic-fp-queues
3
- Version: 5.1.2
3
+ Version: 5.1.3
4
4
  Summary: Queues
5
5
  Keywords: queue,fifo,lifo,dqueue
6
6
  Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
@@ -16,6 +16,7 @@ Classifier: Typing :: Typed
16
16
  License-File: LICENSE
17
17
  Requires-Dist: pythonic-fp-circulararray>=6.0.4
18
18
  Requires-Dist: pythonic-fp-fptools>=5.2.0
19
+ Requires-Dist: pythonic-fp-gadgets>=4.1.0
19
20
  Requires-Dist: pytest>=8.4.1 ; extra == "test"
20
21
  Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-queues/blob/main/CHANGELOG.rst
21
22
  Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/projects/queues.html
@@ -1,13 +1,13 @@
1
1
  pythonic_fp/queues/__init__.py,sha256=NOkkXOQaHmiemvY4Ke5ZdFJCl3_P3bmV87Xz5Y-R9cU,1028
2
2
  pythonic_fp/queues/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- pythonic_fp/queues/de.py,sha256=hRFeogJ4XuXRFV4xOpD3mLoNo1jklP4uT5Ilrw-PiJg,7456
3
+ pythonic_fp/queues/de.py,sha256=ICPHkGz0JKIk8aLk75ZUSPS6T9jSTynkJ-2A5Sy_iig,8532
4
4
  pythonic_fp/queues/de.pyi,sha256=db74UiSLFme25Yhc28Hhw3EKb2GfvU4wNBJtkTlr_e4,1150
5
- pythonic_fp/queues/fifo.py,sha256=EvZub5bRsW3xqCbREKz8dXIt3heBmzsDOzJQuF6Mm30,5728
5
+ pythonic_fp/queues/fifo.py,sha256=qQhv57VuF2QuaRtGJhCtj5qtGPjoGKlQS9RbZIGsvmY,6803
6
6
  pythonic_fp/queues/fifo.pyi,sha256=19TGU3Qg91hCLo5A-5p9vmREcl38EUWhIAvJZtlb1eA,885
7
- pythonic_fp/queues/lifo.py,sha256=_uBM9XnZMm-OYEDhAHPdcHBy_C6h2d0B0dTpoXaJ62A,5348
7
+ pythonic_fp/queues/lifo.py,sha256=lQAzoCOzQrw3gF2A_GgF_4XkYpNivswPyZS-Qp5bxYw,6471
8
8
  pythonic_fp/queues/lifo.pyi,sha256=HdJ-t7R2w3VfCT06raCTXespdUZfpBgMepBlcxDvyuk,832
9
9
  pythonic_fp/queues/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- pythonic_fp_queues-5.1.2.dist-info/licenses/LICENSE,sha256=IJMkVWQUVy-SonK6SMaMotDQ6Zb-lVi2bUTiGp1GUO8,10774
11
- pythonic_fp_queues-5.1.2.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
12
- pythonic_fp_queues-5.1.2.dist-info/METADATA,sha256=fzVKSB2LG3S9c78klIzZ6zvaH1JT4mfRa6NZzZiD7d0,2350
13
- pythonic_fp_queues-5.1.2.dist-info/RECORD,,
10
+ pythonic_fp_queues-5.1.3.dist-info/licenses/LICENSE,sha256=IJMkVWQUVy-SonK6SMaMotDQ6Zb-lVi2bUTiGp1GUO8,10774
11
+ pythonic_fp_queues-5.1.3.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
12
+ pythonic_fp_queues-5.1.3.dist-info/METADATA,sha256=CeQO0Dt1zxfeu94F7ziEET_hegfeZUjlpzzoIzzdQr4,2392
13
+ pythonic_fp_queues-5.1.3.dist-info/RECORD,,