pythonic-fp-circulararray 5.3.2__tar.gz → 5.3.3__tar.gz
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_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/CHANGELOG.rst +83 -117
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/PKG-INFO +2 -2
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/pyproject.toml +2 -2
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/src/pythonic_fp/circulararray/__init__.py +1 -2
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/src/pythonic_fp/circulararray/auto.py +55 -94
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/src/pythonic_fp/circulararray/fixed.py +55 -92
- pythonic_fp_circulararray-5.3.3/src/pythonic_fp/circulararray/py.typed +0 -0
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/.gitignore +0 -0
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/LICENSE +0 -0
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/README.rst +0 -0
- /pythonic_fp_circulararray-5.3.2/src/pythonic_fp/circulararray/py.typed → /pythonic_fp_circulararray-5.3.3/src/pythonic_fp/circulararray/__init__.pyi +0 -0
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/src/pythonic_fp/circulararray/auto.pyi +0 -0
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/src/pythonic_fp/circulararray/fixed.pyi +0 -0
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/tests/auto/test_ca.py +0 -0
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/tests/auto/test_ca_capacity.py +0 -0
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/tests/auto/test_repr_str_auto.py +0 -0
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/tests/fixed/test_caf.py +0 -0
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/tests/fixed/test_caf_capacity.py +0 -0
- {pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/tests/fixed/test_repr_str_fixed.py +0 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
CHANGELOG
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
`PyPI pythonic-fp.circulararray project changelog
|
|
6
|
-
<https://github.com/grscheller/pythonic-fp-circulararray/blob/main/README.rst>`_.
|
|
4
|
+
PyPI pythonic-fp-circulararray project.
|
|
7
5
|
|
|
8
6
|
Semantic Versioning
|
|
9
7
|
-------------------
|
|
@@ -19,27 +17,30 @@ See `Semantic Versioning 2.0.0 <https://semver.org>`_.
|
|
|
19
17
|
Releases and Important Milestones
|
|
20
18
|
---------------------------------
|
|
21
19
|
|
|
22
|
-
5.3.
|
|
23
|
-
|
|
20
|
+
PyPI 5.3.3 - 2025-09-21
|
|
21
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
22
|
+
|
|
23
|
+
Polished up docstrings. PyPI documentation link now goes to root, not releases.
|
|
24
|
+
|
|
25
|
+
PyPI 5.3.2 - 2025-09-04
|
|
26
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
24
27
|
|
|
25
28
|
- removed TypeVar declarations
|
|
26
29
|
- removed Never from union return types
|
|
27
|
-
|
|
28
30
|
- seems Never is now interpreted as a bottom
|
|
29
|
-
|
|
30
31
|
- regenerated .pyi files with mypy's stubgen
|
|
31
32
|
- updated docstrings for Sphinx documentation
|
|
32
33
|
|
|
33
|
-
5.3.1 - 2025-08-02
|
|
34
|
-
|
|
34
|
+
PyPI 5.3.1 - 2025-08-02
|
|
35
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
35
36
|
|
|
36
37
|
Added a second version of circulararray which has a fixed capacity.
|
|
37
38
|
|
|
38
39
|
Also, significant docstring changes as the maintainer irons out
|
|
39
40
|
how best to leverage Sphinx.
|
|
40
41
|
|
|
41
|
-
5.2.0 - 2025-07-13
|
|
42
|
-
|
|
42
|
+
PyPI 5.2.0 - 2025-07-13
|
|
43
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
43
44
|
|
|
44
45
|
API addition, removed position only parameters from API `/`
|
|
45
46
|
|
|
@@ -49,72 +50,63 @@ API addition, removed position only parameters from API `/`
|
|
|
49
50
|
- pythonic_fp.circulararray docstrings still a bit rough
|
|
50
51
|
- fixed broken PyPI links
|
|
51
52
|
|
|
52
|
-
5.1.2 - 2025-07-06
|
|
53
|
-
|
|
53
|
+
PyPI 5.1.2 - 2025-07-06
|
|
54
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
54
55
|
|
|
55
56
|
Documentation across pythonic-fp namespace projects brought closer into agreement.
|
|
56
57
|
|
|
57
|
-
5.1.1 - 2025-07-06
|
|
58
|
-
|
|
58
|
+
PyPI 5.1.1 - 2025-07-06
|
|
59
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
59
60
|
|
|
60
61
|
Devel environment and documentation changes only.
|
|
61
62
|
|
|
62
63
|
- documentation improvements
|
|
63
64
|
- forgot to updated changelog.rst before PyPI release
|
|
64
65
|
- Pythonic FP homepage now points to its GitHub README.md
|
|
65
|
-
|
|
66
66
|
- used to point to its GH-Pages
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
~~~~~~~~~~~~~~~~~~
|
|
68
|
+
PyPI 5.1.0 - 2025-07-04
|
|
69
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
71
70
|
|
|
72
71
|
First PyPI Release with Sphinx replacing pdoc.
|
|
73
72
|
|
|
74
73
|
- switched from ``pdoc`` to ``sphinx`` for document generation
|
|
75
|
-
|
|
76
74
|
- no longer source code controlling generated HTML (too wasteful)
|
|
77
75
|
- using ``sphinx.ext.githubpages`` extension to publish from this repo
|
|
78
76
|
- using ``sphinx.ext.autodoc`` to generate detailed API documentation
|
|
79
77
|
- using the ``piccolo-theme at https://pypi.org/project/piccolo-theme/``
|
|
80
|
-
|
|
81
78
|
- beautiful dark mode
|
|
82
79
|
- plays nice with ``autodoc`` and ``DarkReader``
|
|
83
|
-
|
|
84
80
|
- some formatting changes
|
|
85
|
-
|
|
86
81
|
- no actual code changes
|
|
87
82
|
- did remove TypeVar hack used for pdoc
|
|
88
|
-
|
|
89
83
|
- made pyproject.toml improvements
|
|
90
|
-
|
|
91
84
|
- better tooling configurations
|
|
92
85
|
- removed all version caps from pyproject.toml, see this
|
|
93
86
|
`blog post <https://iscinumpy.dev/post/bound-version-constraints>`_.
|
|
94
87
|
|
|
95
|
-
5.0.0 - 2025-05-23
|
|
96
|
-
|
|
88
|
+
PyPI 5.0.0 - 2025-05-23
|
|
89
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
97
90
|
|
|
98
91
|
First PyPI release as ``pythonic-fp.circular-array``.
|
|
99
92
|
|
|
100
93
|
- there was already a PyPI project with the dtools name
|
|
101
94
|
- the name pythonic-fp was not taken
|
|
102
|
-
|
|
103
95
|
- using it as the namespace name for the entire group
|
|
104
96
|
- does exist as an "skeleton" project just to claim the name
|
|
105
97
|
- installing it will break all the namespace packages
|
|
106
98
|
- didn't want any confusion caused by someone else claiming the name
|
|
107
99
|
|
|
108
|
-
3.14.0 - 2025-05-10
|
|
109
|
-
|
|
100
|
+
PyPI 3.14.0 - 2025-05-10
|
|
101
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
110
102
|
|
|
111
103
|
Made package just a single module.
|
|
112
104
|
|
|
113
105
|
- dtools.circular_array.ca -> dtools.circular_array
|
|
114
106
|
- docstring consolidations/updates
|
|
115
107
|
|
|
116
|
-
3.13.0 - 2025-05-06
|
|
117
|
-
|
|
108
|
+
PyPI 3.13.0 - 2025-05-06
|
|
109
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
118
110
|
|
|
119
111
|
Version no longer determined dynamically.
|
|
120
112
|
|
|
@@ -122,31 +114,28 @@ Version no longer determined dynamically.
|
|
|
122
114
|
- version now set in pyproject.toml
|
|
123
115
|
- no longer doing 4 part development versioning
|
|
124
116
|
- version will either denote
|
|
125
|
-
|
|
126
117
|
- the current PyPI release - if no substantive changes made
|
|
127
118
|
- the next PyPI release - what development is working toward
|
|
128
119
|
|
|
129
|
-
3.12.1 - 2025-04-22
|
|
130
|
-
|
|
120
|
+
PyPI 3.12.1 - 2025-04-22
|
|
121
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
131
122
|
|
|
132
|
-
|
|
133
|
-
- pyproject.toml standardization
|
|
123
|
+
Docstring changes and pyproject.toml standardization.
|
|
134
124
|
|
|
135
|
-
3.12.0 - 2025-04-07
|
|
136
|
-
|
|
125
|
+
PyPI 3.12.0 - 2025-04-07
|
|
126
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
137
127
|
|
|
138
128
|
API change.
|
|
139
129
|
|
|
140
130
|
- class CA[D] no longer inherits from Sequence[D]
|
|
141
131
|
- typing improvements
|
|
142
132
|
|
|
143
|
-
3.11.0 - 2025-04-06
|
|
144
|
-
|
|
133
|
+
PyPI 3.11.0 - 2025-04-06
|
|
134
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
145
135
|
|
|
146
136
|
Major API change.
|
|
147
137
|
|
|
148
138
|
- swapped names `ca` and `CA`
|
|
149
|
-
|
|
150
139
|
- class name now `CA`
|
|
151
140
|
- factory function taking variable number of arguments is now `ca`
|
|
152
141
|
|
|
@@ -155,77 +144,65 @@ Major API change.
|
|
|
155
144
|
- still want this class to behave like a builtin
|
|
156
145
|
- but got tired fighting linters
|
|
157
146
|
- maybe being "Pythonic" means
|
|
158
|
-
|
|
159
147
|
- that only builtins should break naming conventions
|
|
160
148
|
- naming conventions being
|
|
161
|
-
|
|
162
149
|
- snake_case for functions and method names
|
|
163
150
|
- CamelCase for class names
|
|
164
|
-
|
|
165
151
|
- perhaps a visual distinction is useful to tell when you
|
|
166
152
|
- are dealing with user/library Python code
|
|
167
153
|
- C code presenting itself as a Python class
|
|
168
|
-
|
|
169
154
|
- typing improvements
|
|
170
155
|
|
|
171
|
-
3.10.1 - 2025-04-03
|
|
172
|
-
|
|
156
|
+
PyPI 3.10.1 - 2025-04-03
|
|
157
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
173
158
|
|
|
174
159
|
Major API changes.
|
|
175
160
|
|
|
176
161
|
- class name still `ca`
|
|
177
|
-
|
|
178
162
|
- initializer takes 1 or 0 iterables
|
|
179
|
-
|
|
180
163
|
- like Python builtin types `list` or `tuple`
|
|
181
|
-
|
|
182
164
|
- factory function `CA` provided to create a `ca` from mult args
|
|
183
|
-
|
|
184
165
|
- like `[]` or `{}`
|
|
185
|
-
|
|
186
166
|
- otherwise, method names are all snake_case compatible
|
|
187
|
-
|
|
188
167
|
- examples
|
|
189
|
-
|
|
190
168
|
- popL -> popl
|
|
191
169
|
- pushR -> pushr
|
|
192
170
|
- fractionFilled -> fraction_filled
|
|
193
|
-
|
|
194
171
|
- updated pyproject.toml
|
|
195
172
|
- to better match other dtools namespace projects
|
|
196
173
|
|
|
197
|
-
3.9.1 - 2025-02-16
|
|
198
|
-
|
|
174
|
+
PyPI 3.9.1 - 2025-02-16
|
|
175
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
199
176
|
|
|
200
177
|
Fixed pdoc issues with new typing notation.
|
|
201
178
|
|
|
202
179
|
- updated docstrings
|
|
203
180
|
- had to add TypeVars
|
|
204
181
|
|
|
205
|
-
3.9.0 - 2025-01-16
|
|
206
|
-
|
|
182
|
+
PyPI 3.9.0 - 2025-01-16
|
|
183
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
207
184
|
|
|
208
185
|
First release as dtools.circular-array,
|
|
209
186
|
was previously grscheller.circular-array.
|
|
210
187
|
|
|
211
|
-
3.8.0 - 2025-01-03
|
|
212
|
-
|
|
188
|
+
PyPI 3.8.0 - 2025-01-03
|
|
189
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
213
190
|
|
|
214
191
|
Now circular-array indexing methods fully support slicing, also added
|
|
215
192
|
the rotL(n) and rotR(n) methods.
|
|
216
193
|
|
|
217
|
-
3.7.1 - 2024-11-18
|
|
218
|
-
|
|
194
|
+
PyPI 3.7.1 - 2024-11-18
|
|
195
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
219
196
|
|
|
220
197
|
For internal changes. Mostly for consistency across PyPI namespace projects
|
|
221
198
|
|
|
222
|
-
3.7.0 - 2024-10-26
|
|
223
|
-
|
|
199
|
+
PyPI 3.7.0 - 2024-10-26
|
|
200
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
224
201
|
|
|
225
202
|
Regenerated docs for PyPI release.
|
|
226
203
|
|
|
227
|
-
3.6.3.2 - 2024-10-20
|
|
228
|
-
|
|
204
|
+
Version 3.6.3.2 - 2024-10-20
|
|
205
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
229
206
|
|
|
230
207
|
Just a commit, preparing for a 3.7.0 PyPI release.
|
|
231
208
|
|
|
@@ -233,20 +210,20 @@ Just a commit, preparing for a 3.7.0 PyPI release.
|
|
|
233
210
|
- created factory function for original constructor use case
|
|
234
211
|
- generated docs in docs repo
|
|
235
212
|
|
|
236
|
-
3.6.2 - 2024-10-20
|
|
237
|
-
|
|
213
|
+
PyPI 3.6.2 - 2024-10-20
|
|
214
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
238
215
|
|
|
239
216
|
Removed docs from repo, now docs for all grscheller namespace projects located
|
|
240
217
|
[here](https://grscheller.github.io/grscheller-pypi-namespace-docs/).
|
|
241
218
|
|
|
242
|
-
3.6.1 - 2024-10-18
|
|
243
|
-
|
|
219
|
+
PyPI 3.6.1 - 2024-10-18
|
|
220
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
244
221
|
|
|
245
222
|
Infrastructure and minor docstring changes. Should be compatible with
|
|
246
223
|
version 3.6.0.
|
|
247
224
|
|
|
248
|
-
3.6.0 - 2024-09-21
|
|
249
|
-
|
|
225
|
+
PyPI 3.6.0 - 2024-09-21
|
|
226
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
250
227
|
|
|
251
228
|
No future changes planned for the foreseeable future
|
|
252
229
|
|
|
@@ -257,8 +234,8 @@ No future changes planned for the foreseeable future
|
|
|
257
234
|
- several more pytest tests added
|
|
258
235
|
- made the `compact` method private, now called `_compact_storage_capacity`
|
|
259
236
|
|
|
260
|
-
3.5.0 - 2024-09-21
|
|
261
|
-
|
|
237
|
+
PyPI 3.5.0 - 2024-09-21
|
|
238
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
262
239
|
|
|
263
240
|
- made the `double` method
|
|
264
241
|
- O(1) amortized pushes and pops either end.
|
|
@@ -268,33 +245,30 @@ No future changes planned for the foreseeable future
|
|
|
268
245
|
- major docstring improvements
|
|
269
246
|
- improved indentation and code alignment, now much more Pythonic
|
|
270
247
|
|
|
271
|
-
3.4.1 - 2024-08-17
|
|
272
|
-
|
|
248
|
+
PyPI 3.4.1 - 2024-08-17
|
|
249
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
273
250
|
|
|
274
251
|
- updated README.md to reflect name changes of CA methods
|
|
275
252
|
- docstring improvements
|
|
276
253
|
|
|
277
|
-
3.4.0 - 2024-08-15
|
|
278
|
-
|
|
254
|
+
PyPI 3.4.0 - 2024-08-15
|
|
255
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
279
256
|
|
|
280
257
|
Updated `__eq__` comparisons.
|
|
281
258
|
|
|
282
259
|
- first compare elements by identity before equality
|
|
283
|
-
|
|
284
260
|
- I noticed that is what Python builtins do
|
|
285
261
|
- makes dealing with grscheller.fp.nada module easier
|
|
286
|
-
|
|
287
262
|
- standardizing docstrings across grscheller PyPI projects
|
|
288
263
|
|
|
289
|
-
3.3.0.1 - 2024-08-05
|
|
290
|
-
|
|
264
|
+
Version 3.3.0.1 - 2024-08-05
|
|
265
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
291
266
|
|
|
292
267
|
Just a commit, made a paradigm "regression".
|
|
293
268
|
|
|
294
269
|
- made a paradigm "regression", preparing for a 3.4.0 release
|
|
295
270
|
- felt CA was becoming way too complicated
|
|
296
271
|
- grscheller.datastructures needed it to fully embrace type annotations
|
|
297
|
-
|
|
298
272
|
- but I was shifting too many features back into grscheller.circular-array
|
|
299
273
|
- want ca to be useful for non-functional applications
|
|
300
274
|
|
|
@@ -308,34 +282,29 @@ The changes made were
|
|
|
308
282
|
- changed nomenclature from "left/right" to "front/rear"
|
|
309
283
|
- unsafe and safe versions of pop & fold functionality
|
|
310
284
|
- left and right folds improvements
|
|
311
|
-
|
|
312
285
|
- consolidated `foldL, foldL1, foldR, foldR1` into `foldL` & `foldR`
|
|
313
|
-
|
|
314
286
|
- tests working
|
|
315
|
-
|
|
316
287
|
- basically I changed pops to unsafe pops and added `try except` blocks
|
|
317
288
|
- safe versions tests needed
|
|
318
|
-
|
|
319
289
|
- safe pops return multiple values in tuples
|
|
320
290
|
- will take a `default` value to return
|
|
321
|
-
|
|
322
291
|
- if only asked to return 1 value and CA is empty
|
|
323
292
|
- seems to work properly from iPython
|
|
324
293
|
|
|
325
|
-
3.2.0 - 2024-07-26
|
|
326
|
-
|
|
294
|
+
PyPI 3.2.0 - 2024-07-26
|
|
295
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
327
296
|
|
|
328
297
|
The class name was changed ``CircularArray -> CA`` Now takes a "sentinel" or "fallback" value in its
|
|
329
298
|
initializer, formally used ``None`` for this.
|
|
330
299
|
|
|
331
|
-
3.1.0 - 2024-07-11
|
|
332
|
-
|
|
300
|
+
PyPI 3.1.0 - 2024-07-11
|
|
301
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
333
302
|
|
|
334
303
|
Generic typing now being used, first PyPI release where multiple values can be
|
|
335
304
|
pushed on CircularArray.
|
|
336
305
|
|
|
337
|
-
3.0.0 - 2024-06-28
|
|
338
|
-
|
|
306
|
+
Version 3.0.0 - 2024-06-28
|
|
307
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
339
308
|
Just a commit, not a PyPI release.
|
|
340
309
|
|
|
341
310
|
CircularArray class now using Generic Type Parameter. new epoch in development,
|
|
@@ -348,8 +317,8 @@ API changes:
|
|
|
348
317
|
- ``foldL1(self, f: Callable[[S, T], S], initial: S) -> S``
|
|
349
318
|
- ``foldR1(self, f: Callable[[T, S], S], initial: S) -> S``
|
|
350
319
|
|
|
351
|
-
2.0.0 - 2024-03-08
|
|
352
|
-
|
|
320
|
+
PyPI 2.0.0 - 2024-03-08
|
|
321
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
353
322
|
|
|
354
323
|
New "epoch" due to resizing bug fixed on previous commit.
|
|
355
324
|
|
|
@@ -358,59 +327,56 @@ New "epoch" due to resizing bug fixed on previous commit.
|
|
|
358
327
|
- method `_double()` made "public" and renamed `double()`
|
|
359
328
|
- method `resize(new_size)` now resizes to at least new_size
|
|
360
329
|
|
|
361
|
-
1.1.0.0 - 2024-03-08
|
|
362
|
-
|
|
330
|
+
Version 1.1.0.0 - 2024-03-08
|
|
331
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
363
332
|
|
|
364
333
|
Just a commit to prepare for PyPI release 2.0.0!!!
|
|
365
334
|
|
|
366
335
|
- BUGFIX: Fixed a subtle resizing bug
|
|
367
|
-
|
|
368
336
|
- bug probably present in all previous versions
|
|
369
337
|
- not previously identified due to inadequate test coverage
|
|
370
338
|
- test coverage improved vastly
|
|
371
|
-
|
|
372
339
|
- made some major code API changes
|
|
373
|
-
|
|
374
340
|
- upon initialization minimizing size of the CircularArray
|
|
375
341
|
- have some ideas on how to improve API for resizing CircularArrays
|
|
376
342
|
- need to test my other 2 PyPI projects, both use circular-array as a dependency
|
|
377
343
|
|
|
378
|
-
1.0.1 - 2024-03-01
|
|
379
|
-
|
|
344
|
+
PyPI 1.0.1 - 2024-03-01
|
|
345
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
380
346
|
|
|
381
347
|
Docstring updates to match other grscheller PyPI repos.
|
|
382
348
|
|
|
383
|
-
1.0.0 - 2024-02-10
|
|
384
|
-
|
|
349
|
+
PyPI 1.0.0 - 2024-02-10
|
|
350
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
385
351
|
|
|
386
352
|
First stable PyPI release, dropped minimum Python requirement to 3.10.
|
|
387
353
|
|
|
388
|
-
0.1.1 - 2024-01-30
|
|
389
|
-
|
|
354
|
+
PyPI 0.1.1 - 2024-01-30
|
|
355
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
390
356
|
|
|
391
357
|
Changed circular-array from a package to just a module, actually a breaking API
|
|
392
358
|
change. Version number should have been 0.2.0 Also, gave CircularArray class
|
|
393
359
|
`foldL` & `foldR` methods.
|
|
394
360
|
|
|
395
|
-
0.1.0 - 2024-01-28
|
|
396
|
-
|
|
361
|
+
PyPI 0.1.0 - 2024-01-28
|
|
362
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
|
397
363
|
|
|
398
364
|
- initial PyPI grscheller.circular-array release
|
|
399
365
|
- migrated Circulararray class from grscheller.datastructures
|
|
400
366
|
- update docstrings to reflect current nomenclature
|
|
401
367
|
|
|
402
|
-
0.0.3 - 2024-01-28
|
|
403
|
-
|
|
368
|
+
Version 0.0.3 - 2024-01-28
|
|
369
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
404
370
|
|
|
405
371
|
Got gh-pages working for the repo.
|
|
406
372
|
|
|
407
|
-
0.0.2 - 2024-01-28
|
|
408
|
-
|
|
373
|
+
Version 0.0.2 - 2024-01-28
|
|
374
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
409
375
|
|
|
410
376
|
Pushed repo up to GitHub, created README.md file for project.
|
|
411
377
|
|
|
412
|
-
0.0.1 - 2024-01-28
|
|
413
|
-
|
|
378
|
+
Version 0.0.1 - 2024-01-28
|
|
379
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
414
380
|
|
|
415
381
|
Decided to split Circulararray class out of grscheller.datastructures, will make it its own PyPI
|
|
416
382
|
project. Got it working with datastructures locally.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pythonic-fp-circulararray
|
|
3
|
-
Version: 5.3.
|
|
3
|
+
Version: 5.3.3
|
|
4
4
|
Summary: Circular Array
|
|
5
5
|
Keywords: auto resizing,circular array,circulararray,dequeue,indexable,pop,push
|
|
6
6
|
Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
|
|
@@ -16,7 +16,7 @@ Classifier: Typing :: Typed
|
|
|
16
16
|
License-File: LICENSE
|
|
17
17
|
Requires-Dist: pytest>=8.4.1 ; extra == "test"
|
|
18
18
|
Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-circulararray/blob/main/CHANGELOG.rst
|
|
19
|
-
Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/circulararray/development/build/html/
|
|
19
|
+
Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/circulararray/development/build/html/index.html
|
|
20
20
|
Project-URL: Homepage, https://github.com/grscheller/pythonic-fp/blob/main/README.md
|
|
21
21
|
Project-URL: Source, https://github.com/grscheller/pythonic-fp-circulararray
|
|
22
22
|
Provides-Extra: test
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "pythonic-fp-circulararray"
|
|
3
|
-
version = "5.3.
|
|
3
|
+
version = "5.3.3"
|
|
4
4
|
readme = "README.rst"
|
|
5
5
|
requires-python = ">=3.13"
|
|
6
6
|
license = { file = "LICENSE" }
|
|
@@ -28,7 +28,7 @@ dynamic = ["description"]
|
|
|
28
28
|
|
|
29
29
|
[project.urls]
|
|
30
30
|
Changelog = "https://github.com/grscheller/pythonic-fp-circulararray/blob/main/CHANGELOG.rst"
|
|
31
|
-
Documentation = "https://grscheller.github.io/pythonic-fp/circulararray/development/build/html/
|
|
31
|
+
Documentation = "https://grscheller.github.io/pythonic-fp/circulararray/development/build/html/index.html"
|
|
32
32
|
Homepage = "https://github.com/grscheller/pythonic-fp/blob/main/README.md"
|
|
33
33
|
Source = "https://github.com/grscheller/pythonic-fp-circulararray"
|
|
34
34
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
"""
|
|
16
16
|
Circular Array
|
|
17
|
-
|
|
17
|
+
--------------
|
|
18
18
|
|
|
19
19
|
Package implementing stateful circular array data structures.
|
|
20
20
|
|
|
@@ -29,7 +29,6 @@ Package implementing stateful circular array data structures.
|
|
|
29
29
|
+-------------------------------------+-------------------------------------------+
|
|
30
30
|
| **pythonic_fp.circulararray.fixed** | Fixed storage capacity circular array. |
|
|
31
31
|
+-------------------------------------+-------------------------------------------+
|
|
32
|
-
|
|
33
32
|
"""
|
|
34
33
|
|
|
35
34
|
__author__ = 'Geoffrey R. Scheller'
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
Variable Storage Capacity
|
|
17
17
|
=========================
|
|
18
18
|
|
|
19
|
-
Circular array with variable storage capacity
|
|
19
|
+
**Circular array with variable storage capacity.**
|
|
20
20
|
|
|
21
21
|
- O(1) pops either end
|
|
22
22
|
- O(1) amortized pushes either end
|
|
@@ -25,7 +25,7 @@ Circular array with variable storage capacity.
|
|
|
25
25
|
- iterable, can safely mutate while iterators continue iterating over previous state
|
|
26
26
|
- comparisons compare identity before equality, like builtins
|
|
27
27
|
- in boolean context, falsy when empty, otherwise truthy
|
|
28
|
-
- factory function ca produces a variable storage capacity circular array from its arguments
|
|
28
|
+
- factory function ``ca`` produces a variable storage capacity circular array from its arguments
|
|
29
29
|
|
|
30
30
|
"""
|
|
31
31
|
from collections.abc import Callable, Iterable, Iterator
|
|
@@ -43,12 +43,8 @@ class CA[I]():
|
|
|
43
43
|
items: Iterable[I] | None = None
|
|
44
44
|
) -> None:
|
|
45
45
|
"""
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
:param items: optional iterable to initial populate circular array
|
|
50
|
-
:raises TypeError: if items is not Iterable
|
|
51
|
-
|
|
46
|
+
:param items: Optional iterable to initial populate circular array.
|
|
47
|
+
:raises TypeError: When ``items`` not Iterable.
|
|
52
48
|
"""
|
|
53
49
|
if items is None:
|
|
54
50
|
self._items: list[I | None] = [None, None]
|
|
@@ -310,11 +306,9 @@ class CA[I]():
|
|
|
310
306
|
return True
|
|
311
307
|
|
|
312
308
|
def pushl(self, *items: I) -> None:
|
|
313
|
-
"""
|
|
314
|
-
Push items onto left side (front) of circular array.
|
|
315
|
-
|
|
316
|
-
:param items: items pushed onto circular array from left
|
|
309
|
+
"""Push ``items`` on from left.
|
|
317
310
|
|
|
311
|
+
:param items: Items pushed onto circular array from left (front).
|
|
318
312
|
"""
|
|
319
313
|
for item in items:
|
|
320
314
|
if self._cnt == self._cap:
|
|
@@ -330,11 +324,9 @@ class CA[I]():
|
|
|
330
324
|
)
|
|
331
325
|
|
|
332
326
|
def pushr(self, *items: I) -> None:
|
|
333
|
-
"""
|
|
334
|
-
Push items onto right side (rear) of circular array.
|
|
335
|
-
|
|
336
|
-
:param items: items pushed onto circular array from right
|
|
327
|
+
"""Push ``items`` on from right.
|
|
337
328
|
|
|
329
|
+
:param items: Items pushed onto circular array from right (rear).
|
|
338
330
|
"""
|
|
339
331
|
for item in items:
|
|
340
332
|
if self._cnt == self._cap:
|
|
@@ -350,12 +342,10 @@ class CA[I]():
|
|
|
350
342
|
)
|
|
351
343
|
|
|
352
344
|
def popl(self) -> I:
|
|
353
|
-
"""
|
|
354
|
-
Pop item off left side (front) of circular array.
|
|
355
|
-
|
|
356
|
-
:returns: item popped from left side of circular array
|
|
357
|
-
:raises ValueError: when called on an empty circular array
|
|
345
|
+
"""Pop single item off from left side.
|
|
358
346
|
|
|
347
|
+
:returns: Item popped from left side (front) of circular array.
|
|
348
|
+
:raises ValueError: When called on an empty circular array.
|
|
359
349
|
"""
|
|
360
350
|
if self._cnt > 1:
|
|
361
351
|
(
|
|
@@ -389,12 +379,10 @@ class CA[I]():
|
|
|
389
379
|
return cast(I, d)
|
|
390
380
|
|
|
391
381
|
def popr(self) -> I:
|
|
392
|
-
"""
|
|
393
|
-
Pop item off right side (rear) of circular array.
|
|
394
|
-
|
|
395
|
-
:return: item popped from right side of circular array
|
|
396
|
-
:raises ValueError: when called on an empty circular array
|
|
382
|
+
"""Pop single item off from right.
|
|
397
383
|
|
|
384
|
+
:returns: Item popped from right side (rear) of circular array.
|
|
385
|
+
:raises ValueError: When called on an empty circular array.
|
|
398
386
|
"""
|
|
399
387
|
if self._cnt > 1:
|
|
400
388
|
(
|
|
@@ -428,13 +416,11 @@ class CA[I]():
|
|
|
428
416
|
return cast(I, d)
|
|
429
417
|
|
|
430
418
|
def popld(self, default: I) -> I:
|
|
431
|
-
"""
|
|
432
|
-
|
|
433
|
-
a mandatory default value. "Safe" version of popl.
|
|
434
|
-
|
|
435
|
-
:param default: item returned if circular array is empty
|
|
436
|
-
:return: item popped from left side or default item if empty
|
|
419
|
+
"""Pop one item from left side of the circular array, provide
|
|
420
|
+
a mandatory default value. "Safe" version of ``popl``.
|
|
437
421
|
|
|
422
|
+
:param default: Item returned if circular array is empty.
|
|
423
|
+
:returns: Item popped from left side or default item if empty.
|
|
438
424
|
"""
|
|
439
425
|
try:
|
|
440
426
|
return self.popl()
|
|
@@ -442,13 +428,11 @@ class CA[I]():
|
|
|
442
428
|
return default
|
|
443
429
|
|
|
444
430
|
def poprd(self, default: I) -> I:
|
|
445
|
-
"""
|
|
446
|
-
|
|
447
|
-
a mandatory default value. "Safe" version of popr.
|
|
448
|
-
|
|
449
|
-
:param default: item returned if circular array is empty
|
|
450
|
-
:return: item popped from right side or default item if empty
|
|
431
|
+
"""Pop one item from right side of the circular array, provide
|
|
432
|
+
a mandatory default value. "Safe" version of ``popr``.
|
|
451
433
|
|
|
434
|
+
:param default: Item returned if circular array is empty.
|
|
435
|
+
:returns: Item popped from right side or default item if empty.
|
|
452
436
|
"""
|
|
453
437
|
try:
|
|
454
438
|
return self.popr()
|
|
@@ -456,12 +440,10 @@ class CA[I]():
|
|
|
456
440
|
return default
|
|
457
441
|
|
|
458
442
|
def poplt(self, maximum: int) -> tuple[I, ...]:
|
|
459
|
-
"""
|
|
460
|
-
Pop multiple items from left side of circular array.
|
|
461
|
-
|
|
462
|
-
:param maximum: maximum number of items to pop, may pop less if not enough items
|
|
463
|
-
:return: items in the order popped, left to right
|
|
443
|
+
"""Pop multiple items from left side of circular array.
|
|
464
444
|
|
|
445
|
+
:param maximum: Maximum number of items to pop, may pop less if not enough items.
|
|
446
|
+
:returns: Tuple of items in the order popped, left to right.
|
|
465
447
|
"""
|
|
466
448
|
item_list: list[I] = []
|
|
467
449
|
|
|
@@ -476,12 +458,10 @@ class CA[I]():
|
|
|
476
458
|
return tuple(item_list)
|
|
477
459
|
|
|
478
460
|
def poprt(self, maximum: int) -> tuple[I, ...]:
|
|
479
|
-
"""
|
|
480
|
-
Pop multiple items from right side of circular array.
|
|
481
|
-
|
|
482
|
-
:param maximum: maximum number of items to pop, may pop less if not enough items
|
|
483
|
-
:return: items in the order popped, right to left
|
|
461
|
+
"""Pop multiple items from right side of circular array.
|
|
484
462
|
|
|
463
|
+
:param maximum: Maximum number of items to pop, may pop less if not enough items.
|
|
464
|
+
:returns: Tuple of items in the order popped, right to left.
|
|
485
465
|
"""
|
|
486
466
|
item_list: list[I] = []
|
|
487
467
|
while maximum > 0:
|
|
@@ -494,11 +474,9 @@ class CA[I]():
|
|
|
494
474
|
return tuple(item_list)
|
|
495
475
|
|
|
496
476
|
def rotl(self, n: int = 1) -> None:
|
|
497
|
-
"""
|
|
498
|
-
Rotate items to the left.
|
|
499
|
-
|
|
500
|
-
:param n: number of times to shift elements to the left
|
|
477
|
+
"""Rotate items to the left.
|
|
501
478
|
|
|
479
|
+
:param n: Number of times to shift elements to the left.
|
|
502
480
|
"""
|
|
503
481
|
if self._cnt < 2:
|
|
504
482
|
return
|
|
@@ -506,11 +484,9 @@ class CA[I]():
|
|
|
506
484
|
self.pushr(self.popl())
|
|
507
485
|
|
|
508
486
|
def rotr(self, n: int = 1) -> None:
|
|
509
|
-
"""
|
|
510
|
-
Rotate items to the right.
|
|
511
|
-
|
|
512
|
-
:param n: number of times to shift elements to the right
|
|
487
|
+
"""Rotate items to the right.
|
|
513
488
|
|
|
489
|
+
:param n: Number of times to shift elements to the right.
|
|
514
490
|
"""
|
|
515
491
|
if self._cnt < 2:
|
|
516
492
|
return
|
|
@@ -518,24 +494,20 @@ class CA[I]():
|
|
|
518
494
|
self.pushl(self.popr())
|
|
519
495
|
|
|
520
496
|
def map[U](self, f: Callable[[I], U]) -> "CA[U]":
|
|
521
|
-
"""
|
|
522
|
-
Apply function f over the circular array's contents,
|
|
523
|
-
|
|
524
|
-
:param f: callable from type I to type U
|
|
525
|
-
:returns: new circular array instance
|
|
497
|
+
"""Apply function ``f`` over the circular array's contents.
|
|
526
498
|
|
|
499
|
+
:param f: Callable from type ``I`` to type ``U``.
|
|
500
|
+
:returns: New auto-resizing circular array instance.
|
|
527
501
|
"""
|
|
528
502
|
return CA(map(f, self))
|
|
529
503
|
|
|
530
504
|
def foldl[L](self, f: Callable[[L, I], L], start: L | None = None) -> L:
|
|
531
|
-
"""
|
|
532
|
-
Fold left with a function and optional starting item.
|
|
533
|
-
|
|
534
|
-
:param f: first argument to f is for the accumulator
|
|
535
|
-
:param start: optional starting item
|
|
536
|
-
:returns: reduced value produced by the left fold
|
|
537
|
-
:raises ValueError: when circular array empty and no starting item given
|
|
505
|
+
"""Fold left with a function and optional starting item.
|
|
538
506
|
|
|
507
|
+
:param f: Folding function, first argument to ``f`` is for the accumulator.
|
|
508
|
+
:param start: Optional starting item.
|
|
509
|
+
:returns: Reduced value produced by the left fold.
|
|
510
|
+
:raises ValueError: When circular array empty and no starting item given.
|
|
539
511
|
"""
|
|
540
512
|
if self._cnt == 0:
|
|
541
513
|
if start is None:
|
|
@@ -555,14 +527,12 @@ class CA[I]():
|
|
|
555
527
|
return acc
|
|
556
528
|
|
|
557
529
|
def foldr[R](self, f: Callable[[I, R], R], start: R | None = None) -> R:
|
|
558
|
-
"""
|
|
559
|
-
Fold right with a function and an optional starting item.
|
|
560
|
-
|
|
561
|
-
:param f: second argument to f is for the accumulator
|
|
562
|
-
:param start: optional starting item
|
|
563
|
-
:returns: reduced value produced by the right fold
|
|
564
|
-
:raises ValueError: when circular array empty and no starting item given
|
|
530
|
+
"""Fold right with a function and an optional starting item.
|
|
565
531
|
|
|
532
|
+
:param f: Folding function, second argument to ``f`` is for the accumulator.
|
|
533
|
+
:param start: Optional starting item.
|
|
534
|
+
:returns: Reduced value produced by the right fold.
|
|
535
|
+
:raises ValueError: When circular array empty and no starting item given.
|
|
566
536
|
"""
|
|
567
537
|
if self._cnt == 0:
|
|
568
538
|
if start is None:
|
|
@@ -582,17 +552,14 @@ class CA[I]():
|
|
|
582
552
|
return acc
|
|
583
553
|
|
|
584
554
|
def capacity(self) -> int:
|
|
585
|
-
"""
|
|
586
|
-
Return current storage capacity of the circular array.
|
|
587
|
-
|
|
588
|
-
:returns: current storage capacity
|
|
555
|
+
"""Return current storage capacity of the circular array.
|
|
589
556
|
|
|
557
|
+
:returns: Current storage capacity.
|
|
590
558
|
"""
|
|
591
559
|
return self._cap
|
|
592
560
|
|
|
593
561
|
def empty(self) -> None:
|
|
594
|
-
"""
|
|
595
|
-
Empty the circular array, keep current storage capacity."""
|
|
562
|
+
"""Empty the circular array, keep current storage capacity."""
|
|
596
563
|
(
|
|
597
564
|
self._items,
|
|
598
565
|
self._front,
|
|
@@ -606,22 +573,18 @@ class CA[I]():
|
|
|
606
573
|
)
|
|
607
574
|
|
|
608
575
|
def fraction_filled(self) -> float:
|
|
609
|
-
"""
|
|
610
|
-
Find fraction of the storage capacity which is filled.
|
|
611
|
-
|
|
612
|
-
:returns: the ratio count/capacity
|
|
576
|
+
"""Find fraction of the storage capacity which is filled.
|
|
613
577
|
|
|
578
|
+
:returns: The ratio count/capacity.
|
|
614
579
|
"""
|
|
615
580
|
return self._cnt / self._cap
|
|
616
581
|
|
|
617
582
|
def resize(self, minimum_capacity: int = 2) -> None:
|
|
618
|
-
"""
|
|
619
|
-
Compact circular array and, if necessary, resize to a minimum
|
|
583
|
+
"""Compact circular array and, if necessary, resize to a minimum
|
|
620
584
|
storage capacity. To just compact the circular array, do not
|
|
621
585
|
provide ``minimum_capacity``.
|
|
622
586
|
|
|
623
|
-
:param minimum_capacity:
|
|
624
|
-
|
|
587
|
+
:param minimum_capacity: Minimum storage capacity to compact the circular array.
|
|
625
588
|
"""
|
|
626
589
|
self._compact_storage_capacity()
|
|
627
590
|
if (min_cap := minimum_capacity) > self._cap:
|
|
@@ -637,11 +600,9 @@ class CA[I]():
|
|
|
637
600
|
|
|
638
601
|
|
|
639
602
|
def ca[T](*items: T) -> CA[T]:
|
|
640
|
-
"""
|
|
641
|
-
Produce circular array from a variable number of arguments.
|
|
642
|
-
|
|
643
|
-
:param items: initial items for a new circular array
|
|
644
|
-
:returns: new variable storage capacity circular array
|
|
603
|
+
"""Produce circular array from a variable number of arguments.
|
|
645
604
|
|
|
605
|
+
:param items: Initial items for a new auto-resizing circular array.
|
|
606
|
+
:returns: New variable storage capacity circular array.
|
|
646
607
|
"""
|
|
647
608
|
return CA(items)
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
Fixed Storage Capacity
|
|
17
17
|
======================
|
|
18
18
|
|
|
19
|
-
Circular array with fixed storage capacity
|
|
19
|
+
**Circular array with fixed storage capacity.**
|
|
20
20
|
|
|
21
21
|
- O(1) pops and pushes either end
|
|
22
22
|
- O(1) indexing, does not support slicing
|
|
@@ -24,7 +24,7 @@ Circular array with fixed storage capacity.
|
|
|
24
24
|
- iterable, can safely mutate while iterators continue iterating over previous state
|
|
25
25
|
- comparisons compare identity before equality, like builtins
|
|
26
26
|
- in boolean context, falsy when either empty or full, otherwise truthy
|
|
27
|
-
- factory function caf produces a fixed storage capacity circular array from its arguments
|
|
27
|
+
- factory function ``caf`` produces a fixed storage capacity circular array from its arguments
|
|
28
28
|
|
|
29
29
|
"""
|
|
30
30
|
from collections.abc import Callable, Iterable, Iterator
|
|
@@ -43,13 +43,9 @@ class CAF[I]():
|
|
|
43
43
|
capacity: int = 2
|
|
44
44
|
) -> None:
|
|
45
45
|
"""
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
:param items: optional iterable to initial populate circular array
|
|
50
|
-
:param capacity: fixed storage capacity of circular array
|
|
51
|
-
:raises TypeError: if items is not Iterable
|
|
52
|
-
|
|
46
|
+
:param items: Optional iterable to initial populate circular array.
|
|
47
|
+
:param capacity: Fixed storage capacity of circular array.
|
|
48
|
+
:raises TypeError: When ``items`` not Iterable,
|
|
53
49
|
"""
|
|
54
50
|
capacity = max(2, capacity)
|
|
55
51
|
if items is None:
|
|
@@ -201,12 +197,10 @@ class CAF[I]():
|
|
|
201
197
|
return True
|
|
202
198
|
|
|
203
199
|
def pushl(self, item: I) -> None:
|
|
204
|
-
"""
|
|
205
|
-
Push single item onto left side (front) of circular array.
|
|
206
|
-
|
|
207
|
-
:param item: single item pushed onto circular array from left
|
|
208
|
-
:raises ValueError: when called on a full CAF
|
|
200
|
+
"""Push ``item`` on from left.
|
|
209
201
|
|
|
202
|
+
:param item: Single item pushed onto circular array from left (front).
|
|
203
|
+
:raises ValueError: When called on a full ``CAF``.
|
|
210
204
|
"""
|
|
211
205
|
if self._cnt == self._cap:
|
|
212
206
|
msg = 'Method pushl called on a full CAF'
|
|
@@ -223,12 +217,10 @@ class CAF[I]():
|
|
|
223
217
|
)
|
|
224
218
|
|
|
225
219
|
def pushr(self, item: I) -> None:
|
|
226
|
-
"""
|
|
227
|
-
Push a single item onto right side (rear) of circular array.
|
|
228
|
-
|
|
229
|
-
:param item: single item pushed onto circular array from right
|
|
230
|
-
:raises ValueError: when called on a full fixed storage capacity circular array
|
|
220
|
+
"""Push ``item`` on from Right.
|
|
231
221
|
|
|
222
|
+
:param item: Single ``item`` pushed onto circular array from right (rear).
|
|
223
|
+
:raises ValueError: When called on a full fixed storage capacity circular array.
|
|
232
224
|
"""
|
|
233
225
|
if self._cnt == self._cap:
|
|
234
226
|
msg = 'Method pushr called on a full CAF'
|
|
@@ -245,12 +237,10 @@ class CAF[I]():
|
|
|
245
237
|
)
|
|
246
238
|
|
|
247
239
|
def popl(self) -> I:
|
|
248
|
-
"""
|
|
249
|
-
Pop item off left side (front) of circular array.
|
|
250
|
-
|
|
251
|
-
:returns: item popped from left side of circular array
|
|
252
|
-
:raises ValueError: when called on an empty circular array
|
|
240
|
+
"""Pop single item off from left side.
|
|
253
241
|
|
|
242
|
+
:returns: Item popped from left side (front) of circular array.
|
|
243
|
+
:raises ValueError: When called on an empty circular array.
|
|
254
244
|
"""
|
|
255
245
|
if self._cnt > 1:
|
|
256
246
|
(
|
|
@@ -284,12 +274,10 @@ class CAF[I]():
|
|
|
284
274
|
return cast(I, d)
|
|
285
275
|
|
|
286
276
|
def popr(self) -> I:
|
|
287
|
-
"""
|
|
288
|
-
Pop item off right side (rear) of circular array.
|
|
289
|
-
|
|
290
|
-
:returns: item popped from right side of circular array
|
|
291
|
-
:raises ValueError: when called on an empty circular array
|
|
277
|
+
"""Pop single item off from right side.
|
|
292
278
|
|
|
279
|
+
:returns: Item popped from right side (rear) of circular array.
|
|
280
|
+
:raises ValueError: When called on an empty circular array.
|
|
293
281
|
"""
|
|
294
282
|
if self._cnt > 1:
|
|
295
283
|
(
|
|
@@ -323,13 +311,11 @@ class CAF[I]():
|
|
|
323
311
|
return cast(I, d)
|
|
324
312
|
|
|
325
313
|
def popld(self, default: I) -> I:
|
|
326
|
-
"""
|
|
327
|
-
Pop one item from left side of the circular array, provide
|
|
314
|
+
"""Pop one item from left side of the circular array, provide
|
|
328
315
|
a mandatory default value. "Safe" version of popl.
|
|
329
316
|
|
|
330
|
-
:param default:
|
|
331
|
-
:returns:
|
|
332
|
-
|
|
317
|
+
:param default: Item returned if circular array is empty.
|
|
318
|
+
:returns: Item popped from left side or default item if empty.
|
|
333
319
|
"""
|
|
334
320
|
try:
|
|
335
321
|
return self.popl()
|
|
@@ -337,13 +323,11 @@ class CAF[I]():
|
|
|
337
323
|
return default
|
|
338
324
|
|
|
339
325
|
def poprd(self, default: I) -> I:
|
|
340
|
-
"""
|
|
341
|
-
Pop one item from right side of the circular array, provide
|
|
326
|
+
"""Pop one item from right side of the circular array, provide
|
|
342
327
|
a mandatory default value. "Safe" version of popr.
|
|
343
328
|
|
|
344
|
-
:param default:
|
|
345
|
-
:returns:
|
|
346
|
-
|
|
329
|
+
:param default: Item returned if circular array is empty.
|
|
330
|
+
:returns: Item popped from right side or default item if empty.
|
|
347
331
|
"""
|
|
348
332
|
try:
|
|
349
333
|
return self.popr()
|
|
@@ -351,12 +335,10 @@ class CAF[I]():
|
|
|
351
335
|
return default
|
|
352
336
|
|
|
353
337
|
def poplt(self, maximum: int) -> tuple[I, ...]:
|
|
354
|
-
"""
|
|
355
|
-
Pop multiple items from left side of circular array.
|
|
356
|
-
|
|
357
|
-
:param maximum: maximum number of items to pop, may pop less if not enough items
|
|
358
|
-
:returns: items in the order popped, left to right
|
|
338
|
+
"""Pop multiple items from left side of circular array.
|
|
359
339
|
|
|
340
|
+
:param maximum: Maximum number of items to pop, may pop less if not enough items.
|
|
341
|
+
:returns: Tuple of items in the order popped, left to right.
|
|
360
342
|
"""
|
|
361
343
|
item_list: list[I] = []
|
|
362
344
|
|
|
@@ -371,12 +353,10 @@ class CAF[I]():
|
|
|
371
353
|
return tuple(item_list)
|
|
372
354
|
|
|
373
355
|
def poprt(self, maximum: int) -> tuple[I, ...]:
|
|
374
|
-
"""
|
|
375
|
-
Pop multiple items from right side of circular array.
|
|
376
|
-
|
|
377
|
-
:param maximum: maximum number of items to pop, may pop less if not enough items
|
|
378
|
-
:returns: items in the order popped, right to left
|
|
356
|
+
"""Pop multiple items from right side of circular array.
|
|
379
357
|
|
|
358
|
+
:param maximum: Maximum number of items to pop, may pop less if not enough items.
|
|
359
|
+
:returns: Tuple of items in the order popped, right to left.
|
|
380
360
|
"""
|
|
381
361
|
item_list: list[I] = []
|
|
382
362
|
while maximum > 0:
|
|
@@ -389,11 +369,9 @@ class CAF[I]():
|
|
|
389
369
|
return tuple(item_list)
|
|
390
370
|
|
|
391
371
|
def rotl(self, n: int = 1) -> None:
|
|
392
|
-
"""
|
|
393
|
-
Rotate items to the left.
|
|
394
|
-
|
|
395
|
-
:param n: number of times to shift elements to the left
|
|
372
|
+
"""Rotate items to the left.
|
|
396
373
|
|
|
374
|
+
:param n: Number of times to shift elements to the left.
|
|
397
375
|
"""
|
|
398
376
|
if self._cnt < 2:
|
|
399
377
|
return
|
|
@@ -401,11 +379,9 @@ class CAF[I]():
|
|
|
401
379
|
self.pushr(self.popl())
|
|
402
380
|
|
|
403
381
|
def rotr(self, n: int = 1) -> None:
|
|
404
|
-
"""
|
|
405
|
-
Rotate items to the right.
|
|
406
|
-
|
|
407
|
-
:param n: number of times to shift elements to the right
|
|
382
|
+
"""Rotate items to the right.
|
|
408
383
|
|
|
384
|
+
:param n: Number of times to shift elements to the right.
|
|
409
385
|
"""
|
|
410
386
|
if self._cnt < 2:
|
|
411
387
|
return
|
|
@@ -413,24 +389,20 @@ class CAF[I]():
|
|
|
413
389
|
self.pushl(self.popr())
|
|
414
390
|
|
|
415
391
|
def map[U](self, f: Callable[[I], U]) -> "CAF[U]":
|
|
416
|
-
"""
|
|
417
|
-
Apply function ``f`` over the circular array's contents,
|
|
418
|
-
|
|
419
|
-
:param f: callable from type I to type U
|
|
420
|
-
:returns: new fixed circular array instance
|
|
392
|
+
"""Apply function ``f`` over the circular array's contents,
|
|
421
393
|
|
|
394
|
+
:param f: Callable from type ``I`` to type ``U``.
|
|
395
|
+
:returns: New fixed capacity circular array instance.
|
|
422
396
|
"""
|
|
423
397
|
return CAF(map(f, self), self._cap)
|
|
424
398
|
|
|
425
399
|
def foldl[L](self, f: Callable[[L, I], L], start: L | None = None) -> L:
|
|
426
|
-
"""
|
|
427
|
-
Fold left with a function and optional stating item.
|
|
428
|
-
|
|
429
|
-
:param f: first argument to f is for the accumulator
|
|
430
|
-
:param start: optional starting item
|
|
431
|
-
:returns: reduced value produced by the left fold
|
|
432
|
-
:raises ValueError: when circular array empty and no starting item given
|
|
400
|
+
"""Fold left with a function and optional stating item.
|
|
433
401
|
|
|
402
|
+
:param f: Folding function, first argument to ``f`` is for the accumulator.
|
|
403
|
+
:param start: Optional starting item.
|
|
404
|
+
:returns: Reduced value produced by the left fold.
|
|
405
|
+
:raises ValueError: When circular array empty and no starting item given.
|
|
434
406
|
"""
|
|
435
407
|
if self._cnt == 0:
|
|
436
408
|
if start is None:
|
|
@@ -450,14 +422,12 @@ class CAF[I]():
|
|
|
450
422
|
return acc
|
|
451
423
|
|
|
452
424
|
def foldr[R](self, f: Callable[[I, R], R], start: R | None = None) -> R:
|
|
453
|
-
"""
|
|
454
|
-
Fold right with a function and an optional starting item.
|
|
455
|
-
|
|
456
|
-
:param f: second argument to f is for the accumulator
|
|
457
|
-
:param start: optional starting item
|
|
458
|
-
:returns: reduced value produced by the right fold
|
|
459
|
-
:raises ValueError: when circular array empty and no starting item given
|
|
425
|
+
"""Fold right with a function and an optional starting item.
|
|
460
426
|
|
|
427
|
+
:param f: Folding function, second argument to ``f`` is for the accumulator.
|
|
428
|
+
:param start: Optional starting item.
|
|
429
|
+
:returns: Reduced value produced by the right fold.
|
|
430
|
+
:raises ValueError: When circular array empty and no starting item given.
|
|
461
431
|
"""
|
|
462
432
|
if self._cnt == 0:
|
|
463
433
|
if start is None:
|
|
@@ -477,17 +447,14 @@ class CAF[I]():
|
|
|
477
447
|
return acc
|
|
478
448
|
|
|
479
449
|
def capacity(self) -> int:
|
|
480
|
-
"""
|
|
481
|
-
Return fixed storage capacity of the circular array.
|
|
482
|
-
|
|
483
|
-
:returns: fixed storage capacity
|
|
450
|
+
"""Return fixed storage capacity of the circular array.
|
|
484
451
|
|
|
452
|
+
:returns: Fixed storage capacity.
|
|
485
453
|
"""
|
|
486
454
|
return self._cap
|
|
487
455
|
|
|
488
456
|
def empty(self) -> None:
|
|
489
|
-
"""
|
|
490
|
-
Empty the circular array."""
|
|
457
|
+
"""Empty the circular array."""
|
|
491
458
|
(
|
|
492
459
|
self._items,
|
|
493
460
|
self._front,
|
|
@@ -501,22 +468,18 @@ class CAF[I]():
|
|
|
501
468
|
)
|
|
502
469
|
|
|
503
470
|
def fraction_filled(self) -> float:
|
|
504
|
-
"""
|
|
505
|
-
Find fraction of the storage capacity which is filled.
|
|
506
|
-
|
|
507
|
-
:returns: the ratio count/capacity
|
|
471
|
+
"""Find fraction of the storage capacity which is filled.
|
|
508
472
|
|
|
473
|
+
:returns: The ratio count/capacity.
|
|
509
474
|
"""
|
|
510
475
|
return self._cnt / self._cap
|
|
511
476
|
|
|
512
477
|
|
|
513
478
|
def caf[T](*items: T, capacity: int = 2) -> CAF[T]:
|
|
514
|
-
"""
|
|
515
|
-
Produce a circular array from a variable number of arguments.
|
|
516
|
-
|
|
517
|
-
:param items: initial items for a new circular array
|
|
518
|
-
:param capacity: the minimum storage capacity to set
|
|
519
|
-
:returns: new fixed storage capacity circular array
|
|
479
|
+
"""Produce a circular array from a variable number of arguments.
|
|
520
480
|
|
|
481
|
+
:param items: Initial items for a new fixed capacity :circular array.
|
|
482
|
+
:param capacity: The minimum storage capacity to set.
|
|
483
|
+
:returns: New fixed storage capacity circular array.
|
|
521
484
|
"""
|
|
522
485
|
return CAF(items, capacity = capacity)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/tests/auto/test_ca_capacity.py
RENAMED
|
File without changes
|
{pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/tests/auto/test_repr_str_auto.py
RENAMED
|
File without changes
|
|
File without changes
|
{pythonic_fp_circulararray-5.3.2 → pythonic_fp_circulararray-5.3.3}/tests/fixed/test_caf_capacity.py
RENAMED
|
File without changes
|
|
File without changes
|