mapFolding 0.15.4__py3-none-any.whl → 0.16.1__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.
Files changed (83) hide show
  1. easyRun/A000682.py +25 -0
  2. easyRun/A005316.py +21 -0
  3. easyRun/NOTcountingFolds.py +36 -0
  4. easyRun/__init__.py +0 -0
  5. easyRun/countFolds.py +41 -0
  6. easyRun/meanders.py +71 -0
  7. mapFolding/__init__.py +10 -55
  8. mapFolding/_dataPacking.py +68 -0
  9. mapFolding/_theSSOT.py +33 -36
  10. mapFolding/_theTypes.py +21 -4
  11. mapFolding/algorithms/daoOfMapFolding.py +1 -2
  12. mapFolding/algorithms/matrixMeanders.py +101 -348
  13. mapFolding/algorithms/matrixMeandersBeDry.py +264 -0
  14. mapFolding/algorithms/matrixMeandersNumPy.py +286 -0
  15. mapFolding/algorithms/matrixMeandersPandas.py +351 -0
  16. mapFolding/algorithms/oeisIDbyFormula.py +320 -76
  17. mapFolding/algorithms/zCuzDocStoopidoeisIDbyFormula.py +92 -0
  18. mapFolding/basecamp.py +261 -113
  19. mapFolding/beDRY.py +2 -30
  20. mapFolding/dataBaskets.py +120 -4
  21. mapFolding/oeis.py +13 -33
  22. mapFolding/reference/A000682facts.py +1276 -0
  23. mapFolding/reference/A005316facts.py +985 -0
  24. mapFolding/reference/matrixMeandersAnalysis/__init__.py +1 -0
  25. mapFolding/reference/matrixMeandersAnalysis/prefixNotationNotes.py +15 -0
  26. mapFolding/reference/meandersDumpingGround/A005316JavaPort.py +1 -1
  27. mapFolding/reference/meandersDumpingGround/A005316imperative.py +1 -1
  28. mapFolding/reference/meandersDumpingGround/matrixMeandersNumPyV1finalForm.py +424 -0
  29. mapFolding/someAssemblyRequired/A007822/A007822rawMaterials.py +54 -0
  30. mapFolding/someAssemblyRequired/A007822/__init__.py +0 -0
  31. mapFolding/someAssemblyRequired/A007822/makeA007822AsynchronousModules.py +197 -0
  32. mapFolding/someAssemblyRequired/A007822/makeA007822Modules.py +74 -0
  33. mapFolding/someAssemblyRequired/RecipeJob.py +4 -4
  34. mapFolding/someAssemblyRequired/__init__.py +9 -2
  35. mapFolding/someAssemblyRequired/_toolIfThis.py +4 -3
  36. mapFolding/someAssemblyRequired/_toolkitContainers.py +8 -8
  37. mapFolding/someAssemblyRequired/infoBooth.py +27 -30
  38. mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +6 -5
  39. mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +6 -4
  40. mapFolding/someAssemblyRequired/makingModules_count.py +294 -0
  41. mapFolding/someAssemblyRequired/makingModules_doTheNeedful.py +117 -0
  42. mapFolding/someAssemblyRequired/mapFolding/__init__.py +0 -0
  43. mapFolding/someAssemblyRequired/mapFolding/makeMapFoldingModules.py +220 -0
  44. mapFolding/someAssemblyRequired/meanders/__init__.py +0 -0
  45. mapFolding/someAssemblyRequired/meanders/makeMeandersModules.py +64 -0
  46. mapFolding/someAssemblyRequired/toolkitMakeModules.py +152 -0
  47. mapFolding/someAssemblyRequired/toolkitNumba.py +1 -1
  48. mapFolding/someAssemblyRequired/transformationTools.py +1 -0
  49. mapFolding/syntheticModules/A007822/__init__.py +1 -0
  50. mapFolding/syntheticModules/{algorithmA007822.py → A007822/algorithm.py} +2 -3
  51. mapFolding/syntheticModules/{algorithmA007822Numba.py → A007822/algorithmNumba.py} +3 -6
  52. mapFolding/syntheticModules/A007822/asynchronous.py +148 -0
  53. mapFolding/syntheticModules/A007822/asynchronousAnnex.py +66 -0
  54. mapFolding/syntheticModules/A007822/asynchronousAnnexNumba.py +85 -0
  55. mapFolding/syntheticModules/A007822/asynchronousNumba.py +52 -0
  56. mapFolding/syntheticModules/A007822/asynchronousTheorem2.py +53 -0
  57. mapFolding/syntheticModules/A007822/asynchronousTrimmed.py +47 -0
  58. mapFolding/syntheticModules/{initializeStateA007822.py → A007822/initializeState.py} +1 -2
  59. mapFolding/syntheticModules/{theorem2A007822.py → A007822/theorem2.py} +1 -2
  60. mapFolding/syntheticModules/{theorem2A007822Numba.py → A007822/theorem2Numba.py} +6 -4
  61. mapFolding/syntheticModules/{theorem2A007822Trimmed.py → A007822/theorem2Trimmed.py} +1 -2
  62. mapFolding/syntheticModules/countParallelNumba.py +5 -2
  63. mapFolding/syntheticModules/daoOfMapFoldingNumba.py +4 -2
  64. mapFolding/syntheticModules/dataPacking.py +4 -2
  65. mapFolding/syntheticModules/dataPackingA007822.py +92 -26
  66. mapFolding/syntheticModules/meanders/__init__.py +1 -0
  67. mapFolding/syntheticModules/meanders/bigInt.py +62 -0
  68. mapFolding/syntheticModules/theorem2Numba.py +3 -2
  69. mapFolding/tests/conftest.py +28 -13
  70. mapFolding/tests/test_computations.py +69 -62
  71. mapFolding/tests/test_oeis.py +6 -6
  72. mapFolding/zCuzDocStoopid/__init__.py +4 -0
  73. mapFolding/zCuzDocStoopid/makeDocstrings.py +68 -0
  74. mapfolding-0.16.1.dist-info/METADATA +99 -0
  75. mapfolding-0.16.1.dist-info/RECORD +114 -0
  76. {mapfolding-0.15.4.dist-info → mapfolding-0.16.1.dist-info}/top_level.txt +1 -0
  77. mapFolding/someAssemblyRequired/A007822rawMaterials.py +0 -46
  78. mapFolding/someAssemblyRequired/makeAllModules.py +0 -764
  79. mapfolding-0.15.4.dist-info/METADATA +0 -78
  80. mapfolding-0.15.4.dist-info/RECORD +0 -78
  81. {mapfolding-0.15.4.dist-info → mapfolding-0.16.1.dist-info}/WHEEL +0 -0
  82. {mapfolding-0.15.4.dist-info → mapfolding-0.16.1.dist-info}/entry_points.txt +0 -0
  83. {mapfolding-0.15.4.dist-info → mapfolding-0.16.1.dist-info}/licenses/LICENSE +0 -0
mapFolding/basecamp.py CHANGED
@@ -1,22 +1,27 @@
1
1
  """Unified interface for map folding computation."""
2
2
 
3
3
  from collections.abc import Sequence
4
+ from functools import cache
4
5
  from mapFolding import (
5
- getPathFilenameFoldsTotal, packageSettings, saveFoldsTotal, saveFoldsTotalFAILearly, setProcessorLimit,
6
- validateListDimensions)
6
+ getPathFilenameFoldsTotal, packageSettings, saveFoldsTotal, saveFoldsTotalFAILearly, validateListDimensions)
7
7
  from os import PathLike
8
8
  from pathlib import PurePath
9
- import contextlib
9
+ from typing import Literal
10
10
 
11
+ # ruff: noqa: PLC0415
11
12
  """TODO new flow paradigm, incomplete
12
13
 
14
+ I don't want to FORCE people to use the meaningless OEIS ids without providing the definition of the ID at the same time.
15
+
16
+ On the other hand, I don't have any evidence that anyone is using this package except me.
17
+
13
18
  algorithms directory
14
19
  manually coded algorithms or formulas
15
- countFolds will be a stable interface for multidimensional map folding, including synthetic modules
20
+ `countFolds` will be a stable interface for multidimensional map folding, including synthetic modules
16
21
  This has special treatment because people may want to call mapShape not defined in OEIS
17
- countMeanders will be a stable interface for meanders
22
+ `countMeanders` will be a stable interface for meanders
18
23
  This has special treatment because people may want to call meanders not defined in OEIS
19
- an enhanced version of oeisIDfor_n will be a stable interface for calling by ID and n
24
+ an enhanced version of `oeisIDfor_n` will be a stable interface for calling by ID and n
20
25
 
21
26
  General flow structure
22
27
  doTheNeedful
@@ -60,14 +65,20 @@ General flow structure
60
65
 
61
66
  """
62
67
 
68
+ # Parameters
69
+ # What you want to compute
70
+ # Memorialization
71
+ # Concurrency
72
+ # How you want to compute it
73
+ # Interpretation of parameters
74
+ # Input data
75
+
63
76
  def countFolds(listDimensions: Sequence[int] | None = None
64
77
  , pathLikeWriteFoldsTotal: PathLike[str] | PurePath | None = None
65
78
  , computationDivisions: int | str | None = None
66
79
  # , * # TODO improve `standardizedEqualToCallableReturn` so it will work with keyword arguments
67
80
  , CPUlimit: bool | float | int | None = None # noqa: FBT001
68
81
  , mapShape: tuple[int, ...] | None = None
69
- , oeisID: str | None = None
70
- , oeis_n: int | None = None
71
82
  , flow: str | None = None
72
83
  ) -> int:
73
84
  """
@@ -92,8 +103,7 @@ def countFolds(listDimensions: Sequence[int] | None = None
92
103
  - 'maximum': divides the computation into `leavesTotal`-many tasks.
93
104
  - 'cpu': divides the computation into the number of available CPUs.
94
105
  CPUlimit : bool | float | int | None = None
95
- If relevant, whether and how to limit the number of processors `countFolds` will use. `CPUlimit` is an irrelevant setting
96
- unless the computation is divided into more than one task with the `computationDivisions` parameter.
106
+ If relevant, whether and how to limit the number of processors `countFolds` will use.
97
107
  - `False`, `None`, or `0`: No limits on processor usage; uses all available processors. All other values will
98
108
  potentially limit processor usage.
99
109
  - `True`: Yes, limit the processor usage; limits to 1 processor.
@@ -108,10 +118,6 @@ def countFolds(listDimensions: Sequence[int] | None = None
108
118
  "dimensions", such as in the seminal paper, "Multi-dimensional map-folding". Nevertheless, in contemporary Python
109
119
  programming, in the context of these algorithms, the term "shape" makes it much easier to align the mathematics with the
110
120
  syntax of the programming language.
111
- oeisID : str | None = None
112
- The On-Line Encyclopedia of Integer Sequences (OEIS) ID for which to compute a(n) for value of 'n' set in `oeis_n`.
113
- oeis_n : int | None = None
114
- The 'n' value for the `oeisID`.
115
121
  flow : str | None = None
116
122
  My stupid way of selecting the version of the algorithm to use in the computation. There are certainly better ways to do
117
123
  this, but I have not yet solved this issue. As of 2025 Aug 14, these values will work:
@@ -143,20 +149,12 @@ def countFolds(listDimensions: Sequence[int] | None = None
143
149
 
144
150
  if mapShape:
145
151
  pass
146
- else:
147
- if oeisID and oeis_n:
148
- from mapFolding.oeis import dictionaryOEISMapFolding # noqa: PLC0415
149
- with contextlib.suppress(KeyError):
150
- mapShape = dictionaryOEISMapFolding[oeisID]['getMapShape'](oeis_n)
151
- if not mapShape and listDimensions:
152
- mapShape = validateListDimensions(listDimensions)
152
+ elif listDimensions:
153
+ mapShape = validateListDimensions(listDimensions)
153
154
 
154
155
  if mapShape is None:
155
- message = (
156
- f"""I received these values:
157
- `{listDimensions = }`,
158
- `{mapShape = }`,
159
- `{oeisID = }` and `{oeis_n = }`,
156
+ message = (f"""I received these values:
157
+ `{listDimensions = }` and `{mapShape = }`,
160
158
  but I was unable to select a map for which to count the folds."""
161
159
  )
162
160
  raise ValueError(message)
@@ -164,8 +162,8 @@ def countFolds(listDimensions: Sequence[int] | None = None
164
162
  # task division instructions -----------------------------------------------------
165
163
 
166
164
  if computationDivisions:
165
+ from mapFolding.beDRY import getLeavesTotal, getTaskDivisions, setProcessorLimit
167
166
  concurrencyLimit: int = setProcessorLimit(CPUlimit, packageSettings.concurrencyPackage)
168
- from mapFolding.beDRY import getLeavesTotal, getTaskDivisions # noqa: PLC0415
169
167
  leavesTotal: int = getLeavesTotal(mapShape)
170
168
  taskDivisions = getTaskDivisions(computationDivisions, concurrencyLimit, leavesTotal)
171
169
  del leavesTotal
@@ -183,133 +181,72 @@ def countFolds(listDimensions: Sequence[int] | None = None
183
181
 
184
182
  # Flow control until I can figure out a good way ---------------------------------
185
183
 
186
- # A007822 flow control until I can figure out a good way ---------------------------------
187
- if oeisID == 'A007822':
188
- """To use A007822, oeisID is mandatory.
189
-
190
- `if oeisID == 'A007822'` precedes the `elif flow ==` cascade because A007822 is fundamentally incompatible with those flow
191
- paths and it will cause `Exception` or incorrect computations.
192
-
193
- Parallel version:
194
- idk. The computation division logic will try to execute. As of 2025 Aug 13 at 11 PM, I haven't tried or thought about
195
- a parallel version. And I don't really care. Potential parallelism is certainly present in `filterAsymmetricFolds`.
196
- But, if I want to implement that, I should almost certainly replace `filterAsymmetricFolds` with a non-blocking
197
- function to which `count` can pass the necessary values to. TODO Watch out for errors.
198
-
199
- """
200
- match flow:
201
- case 'numba':
202
- from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
203
- mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
204
-
205
- from mapFolding.syntheticModules.algorithmA007822Numba import doTheNeedful # noqa: PLC0415
206
- mapFoldingState = doTheNeedful(mapFoldingState)
207
-
208
- case 'theorem2':
209
- from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
210
- mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
211
-
212
- from mapFolding.syntheticModules.initializeStateA007822 import transitionOnGroupsOfFolds # noqa: PLC0415
213
- mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
214
-
215
- from mapFolding.syntheticModules.theorem2A007822 import count # noqa: PLC0415
216
- mapFoldingState = count(mapFoldingState)
217
-
218
- case 'theorem2Numba':
219
- from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
220
- mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
221
-
222
- from mapFolding.syntheticModules.initializeStateA007822 import transitionOnGroupsOfFolds # noqa: PLC0415
223
- mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
224
-
225
- from mapFolding.syntheticModules.dataPackingA007822 import sequential # noqa: PLC0415
226
- mapFoldingState = sequential(mapFoldingState)
227
-
228
- case 'theorem2Trimmed':
229
- from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
230
- mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
231
-
232
- from mapFolding.syntheticModules.initializeStateA007822 import transitionOnGroupsOfFolds # noqa: PLC0415
233
- mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
234
-
235
- from mapFolding.syntheticModules.theorem2A007822Trimmed import count # noqa: PLC0415
236
- mapFoldingState = count(mapFoldingState)
237
-
238
- case _:
239
- from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
240
- mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
241
-
242
- from mapFolding.syntheticModules.algorithmA007822 import doTheNeedful # noqa: PLC0415
243
- mapFoldingState = doTheNeedful(mapFoldingState)
244
-
245
- foldsTotal = mapFoldingState.groupsOfFolds
246
-
247
- elif flow == 'daoOfMapFolding':
248
- from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
184
+ if flow == 'daoOfMapFolding':
185
+ from mapFolding.dataBaskets import MapFoldingState
249
186
  mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
250
187
 
251
- from mapFolding.algorithms.daoOfMapFolding import doTheNeedful # noqa: PLC0415
188
+ from mapFolding.algorithms.daoOfMapFolding import doTheNeedful
252
189
  mapFoldingState = doTheNeedful(mapFoldingState)
253
190
  foldsTotal = mapFoldingState.foldsTotal
254
191
 
255
192
  elif flow == 'numba':
256
- from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
193
+ from mapFolding.dataBaskets import MapFoldingState
257
194
  mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
258
195
 
259
- from mapFolding.syntheticModules.daoOfMapFoldingNumba import doTheNeedful # noqa: PLC0415
196
+ from mapFolding.syntheticModules.daoOfMapFoldingNumba import doTheNeedful
260
197
  mapFoldingState = doTheNeedful(mapFoldingState)
261
198
  foldsTotal = mapFoldingState.foldsTotal
262
199
 
263
200
  elif flow == 'theorem2' and any(dimension > 2 for dimension in mapShape):
264
- from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
201
+ from mapFolding.dataBaskets import MapFoldingState
265
202
  mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
266
203
 
267
- from mapFolding.syntheticModules.initializeState import transitionOnGroupsOfFolds # noqa: PLC0415
204
+ from mapFolding.syntheticModules.initializeState import transitionOnGroupsOfFolds
268
205
  mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
269
206
 
270
- from mapFolding.syntheticModules.theorem2 import count # noqa: PLC0415
207
+ from mapFolding.syntheticModules.theorem2 import count
271
208
  mapFoldingState = count(mapFoldingState)
272
209
 
273
210
  foldsTotal = mapFoldingState.foldsTotal
274
211
 
275
- elif flow == 'theorem2Trimmed' and any(dimension > 2 for dimension in mapShape):
276
- from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
212
+ elif (flow == 'theorem2Numba' or taskDivisions == 0) and any(dimension > 2 for dimension in mapShape):
213
+ from mapFolding.dataBaskets import MapFoldingState
277
214
  mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
278
215
 
279
- from mapFolding.syntheticModules.initializeState import transitionOnGroupsOfFolds # noqa: PLC0415
216
+ from mapFolding.syntheticModules.initializeState import transitionOnGroupsOfFolds
280
217
  mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
281
218
 
282
- from mapFolding.syntheticModules.theorem2Trimmed import count # noqa: PLC0415
283
- mapFoldingState = count(mapFoldingState)
219
+ from mapFolding.syntheticModules.dataPacking import sequential
220
+ mapFoldingState = sequential(mapFoldingState)
284
221
 
285
222
  foldsTotal = mapFoldingState.foldsTotal
286
223
 
287
- elif (flow == 'theorem2Numba' or taskDivisions == 0) and any(dimension > 2 for dimension in mapShape):
288
- from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
224
+ elif flow == 'theorem2Trimmed' and any(dimension > 2 for dimension in mapShape):
225
+ from mapFolding.dataBaskets import MapFoldingState
289
226
  mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
290
227
 
291
- from mapFolding.syntheticModules.initializeState import transitionOnGroupsOfFolds # noqa: PLC0415
228
+ from mapFolding.syntheticModules.initializeState import transitionOnGroupsOfFolds
292
229
  mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
293
230
 
294
- from mapFolding.syntheticModules.dataPacking import sequential # noqa: PLC0415
295
- mapFoldingState = sequential(mapFoldingState)
231
+ from mapFolding.syntheticModules.theorem2Trimmed import count
232
+ mapFoldingState = count(mapFoldingState)
296
233
 
297
234
  foldsTotal = mapFoldingState.foldsTotal
298
235
 
299
236
  elif taskDivisions > 1:
300
- from mapFolding.dataBaskets import ParallelMapFoldingState # noqa: PLC0415
301
- parallelMapFoldingState: ParallelMapFoldingState = ParallelMapFoldingState(mapShape, taskDivisions=taskDivisions)
237
+ from mapFolding.dataBaskets import ParallelMapFoldingState
238
+ mapFoldingParallelState: ParallelMapFoldingState = ParallelMapFoldingState(mapShape, taskDivisions=taskDivisions)
302
239
 
303
- from mapFolding.syntheticModules.countParallelNumba import doTheNeedful # noqa: PLC0415
240
+ from mapFolding.syntheticModules.countParallelNumba import doTheNeedful
304
241
 
305
- # `listStatesParallel` exists in case you want to research the parallel computation.
306
- foldsTotal, listStatesParallel = doTheNeedful(parallelMapFoldingState, concurrencyLimit) # pyright: ignore[reportUnusedVariable]
242
+ # `listStatesParallel` exists so you can research the parallel computation.
243
+ foldsTotal, listStatesParallel = doTheNeedful(mapFoldingParallelState, concurrencyLimit) # pyright: ignore[reportUnusedVariable] # noqa: RUF059
307
244
 
308
245
  else:
309
- from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
246
+ from mapFolding.dataBaskets import MapFoldingState
310
247
  mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
311
248
 
312
- from mapFolding.syntheticModules.daoOfMapFoldingNumba import doTheNeedful # noqa: PLC0415
249
+ from mapFolding.algorithms.daoOfMapFolding import doTheNeedful
313
250
  mapFoldingState = doTheNeedful(mapFoldingState)
314
251
  foldsTotal = mapFoldingState.foldsTotal
315
252
 
@@ -319,3 +256,214 @@ def countFolds(listDimensions: Sequence[int] | None = None
319
256
  saveFoldsTotal(pathFilenameFoldsTotal, foldsTotal)
320
257
 
321
258
  return foldsTotal
259
+
260
+ @cache
261
+ def A000682(n: int, flow: str | None = None) -> int:
262
+ """Compute A000682(n)."""
263
+ match flow:
264
+ case 'matrixNumPy':
265
+ from mapFolding.algorithms.matrixMeandersNumPy import doTheNeedful
266
+ from mapFolding.dataBaskets import MatrixMeandersNumPyState as State
267
+ case 'matrixPandas':
268
+ from mapFolding.algorithms.matrixMeandersPandas import doTheNeedful
269
+ from mapFolding.dataBaskets import MatrixMeandersNumPyState as State
270
+ case _:
271
+ from mapFolding.algorithms.matrixMeanders import doTheNeedful
272
+ from mapFolding.dataBaskets import MatrixMeandersState as State
273
+
274
+ oeisID = 'A000682'
275
+
276
+ kOfMatrix: int = n - 1
277
+
278
+ if n == 1:
279
+ return 1
280
+ elif n & 0b1:
281
+ arcCode: int = 5
282
+ else:
283
+ arcCode = 1
284
+ listCurveLocations: list[int] = [(arcCode << 1) | arcCode]
285
+
286
+ MAXIMUMarcCode: int = 1 << (2 * kOfMatrix + 4)
287
+ while listCurveLocations[-1] < MAXIMUMarcCode:
288
+ arcCode = (arcCode << 4) | 0b101 # == arcCode * 2**4 + 5
289
+ listCurveLocations.append((arcCode << 1) | arcCode)
290
+
291
+ dictionaryMeanders=dict.fromkeys(listCurveLocations, 1)
292
+
293
+ state = State(n, oeisID, kOfMatrix, dictionaryMeanders)
294
+
295
+ return doTheNeedful(state) # pyright: ignore[reportArgumentType]
296
+
297
+ @cache
298
+ def A005316(n: int, flow: str | None = None) -> int:
299
+ """Compute A005316(n)."""
300
+ match flow:
301
+ case 'matrixNumPy':
302
+ from mapFolding.algorithms.matrixMeandersNumPy import doTheNeedful
303
+ from mapFolding.dataBaskets import MatrixMeandersNumPyState as State
304
+ case 'matrixPandas':
305
+ from mapFolding.algorithms.matrixMeandersPandas import doTheNeedful
306
+ from mapFolding.dataBaskets import MatrixMeandersNumPyState as State
307
+ case _:
308
+ from mapFolding.algorithms.matrixMeanders import doTheNeedful
309
+ from mapFolding.dataBaskets import MatrixMeandersState as State
310
+
311
+ oeisID = 'A005316'
312
+
313
+ kOfMatrix: int = n - 1
314
+
315
+ if n & 0b1:
316
+ dictionaryMeanders: dict[int, int] = {15: 1}
317
+ else:
318
+ dictionaryMeanders = {22: 1}
319
+
320
+ state = State(n, oeisID, kOfMatrix, dictionaryMeanders)
321
+
322
+ return doTheNeedful(state) # pyright: ignore[reportArgumentType]
323
+
324
+ def NOTcountingFolds(oeisID: str, oeis_n: int, flow: str | None = None
325
+ # , pathLikeWriteFoldsTotal: PathLike[str] | PurePath | None = None # noqa: ERA001
326
+ , CPUlimit: bool | float | int | None = None # noqa: FBT001
327
+ ) -> int:
328
+ """Do stuff."""
329
+ countTotal: int = -1
330
+
331
+ match oeisID:
332
+ case 'A000136':
333
+ from mapFolding.algorithms.oeisIDbyFormula import A000136
334
+ countTotal = A000136(oeis_n)
335
+ case 'A000560':
336
+ from mapFolding.algorithms.oeisIDbyFormula import A000560
337
+ countTotal = A000560(oeis_n)
338
+ case 'A000682':
339
+ countTotal = A000682(oeis_n, flow)
340
+ case 'A001010':
341
+ from mapFolding.algorithms.oeisIDbyFormula import A001010
342
+ countTotal = A001010(oeis_n)
343
+ case 'A001011':
344
+ from mapFolding.algorithms.oeisIDbyFormula import A001011
345
+ countTotal = A001011(oeis_n)
346
+ case 'A005315':
347
+ from mapFolding.algorithms.oeisIDbyFormula import A005315
348
+ countTotal = A005315(oeis_n)
349
+ case 'A005316':
350
+ countTotal = A005316(oeis_n, flow)
351
+ case 'A007822':
352
+ mapShape: tuple[Literal[1], int] = (1, 2 * oeis_n)
353
+ match flow:
354
+ case 'asynchronous':
355
+ from mapFolding.dataBaskets import MapFoldingState
356
+ mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
357
+
358
+ from mapFolding import setProcessorLimit
359
+ concurrencyLimit = setProcessorLimit(CPUlimit)
360
+
361
+ from mapFolding.syntheticModules.A007822.asynchronous import doTheNeedful
362
+ mapFoldingState = doTheNeedful(mapFoldingState)
363
+
364
+ case 'asynchronousNumba':
365
+ from mapFolding.dataBaskets import MapFoldingState
366
+ mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
367
+
368
+ from mapFolding.syntheticModules.A007822.initializeState import transitionOnGroupsOfFolds
369
+ mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
370
+
371
+ from mapFolding import setProcessorLimit
372
+ concurrencyLimit = setProcessorLimit(CPUlimit)
373
+
374
+ from mapFolding.syntheticModules.A007822.asynchronousAnnex import initializeConcurrencyManager
375
+ initializeConcurrencyManager(maxWorkers=concurrencyLimit, groupsOfFolds=mapFoldingState.groupsOfFolds)
376
+ mapFoldingState.groupsOfFolds = 0
377
+
378
+ from mapFolding.syntheticModules.A007822.asynchronousNumba import count
379
+ mapFoldingState = count(mapFoldingState)
380
+
381
+ case 'asynchronousTrimmed':
382
+ from mapFolding.dataBaskets import MapFoldingState
383
+ mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
384
+
385
+ from mapFolding.syntheticModules.A007822.initializeState import transitionOnGroupsOfFolds
386
+ mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
387
+
388
+ from mapFolding import setProcessorLimit
389
+ concurrencyLimit = setProcessorLimit(CPUlimit)
390
+
391
+ from mapFolding.syntheticModules.A007822.asynchronousAnnex import initializeConcurrencyManager
392
+ initializeConcurrencyManager(maxWorkers=concurrencyLimit, groupsOfFolds=mapFoldingState.groupsOfFolds)
393
+ mapFoldingState.groupsOfFolds = 0
394
+
395
+ from mapFolding.syntheticModules.A007822.asynchronousTrimmed import count
396
+ mapFoldingState = count(mapFoldingState)
397
+
398
+ case 'numba':
399
+ from mapFolding.dataBaskets import MapFoldingState
400
+ mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
401
+
402
+ from mapFolding.syntheticModules.A007822.algorithmNumba import doTheNeedful
403
+ mapFoldingState = doTheNeedful(mapFoldingState)
404
+
405
+ case 'theorem2':
406
+ from mapFolding.dataBaskets import MapFoldingState
407
+ mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
408
+
409
+ from mapFolding.syntheticModules.A007822.initializeState import transitionOnGroupsOfFolds
410
+ mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
411
+
412
+ from mapFolding.syntheticModules.A007822.theorem2 import count
413
+ mapFoldingState = count(mapFoldingState)
414
+
415
+ case 'theorem2Numba':
416
+ from mapFolding.dataBaskets import MapFoldingState
417
+ mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
418
+
419
+ from mapFolding.syntheticModules.A007822.initializeState import transitionOnGroupsOfFolds
420
+ mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
421
+
422
+ from mapFolding.syntheticModules.A007822.theorem2Numba import count
423
+ mapFoldingState = count(mapFoldingState)
424
+
425
+ case 'theorem2Trimmed':
426
+ from mapFolding.dataBaskets import MapFoldingState
427
+ mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
428
+
429
+ from mapFolding.syntheticModules.A007822.initializeState import transitionOnGroupsOfFolds
430
+ mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
431
+
432
+ from mapFolding.syntheticModules.A007822.theorem2Trimmed import count
433
+ mapFoldingState = count(mapFoldingState)
434
+
435
+ case _:
436
+ from mapFolding.dataBaskets import MapFoldingState
437
+ mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
438
+
439
+ from mapFolding.syntheticModules.A007822.algorithm import doTheNeedful
440
+ mapFoldingState = doTheNeedful(mapFoldingState)
441
+
442
+ countTotal = mapFoldingState.groupsOfFolds
443
+ case 'A060206':
444
+ from mapFolding.algorithms.oeisIDbyFormula import A060206
445
+ countTotal = A060206(oeis_n)
446
+ case 'A077460':
447
+ from mapFolding.algorithms.oeisIDbyFormula import A077460
448
+ countTotal = A077460(oeis_n)
449
+ case 'A078591':
450
+ from mapFolding.algorithms.oeisIDbyFormula import A078591
451
+ countTotal = A078591(oeis_n)
452
+ case 'A178961':
453
+ from mapFolding.algorithms.oeisIDbyFormula import A178961
454
+ countTotal = A178961(oeis_n)
455
+ case 'A223094':
456
+ from mapFolding.algorithms.oeisIDbyFormula import A223094
457
+ countTotal = A223094(oeis_n)
458
+ case 'A259702':
459
+ from mapFolding.algorithms.oeisIDbyFormula import A259702
460
+ countTotal = A259702(oeis_n)
461
+ case 'A301620':
462
+ from mapFolding.algorithms.oeisIDbyFormula import A301620
463
+ countTotal = A301620(oeis_n)
464
+
465
+ case _:
466
+ pass
467
+
468
+ return countTotal
469
+
mapFolding/beDRY.py CHANGED
@@ -1,26 +1,4 @@
1
- """
2
- Core computational utilities implementing Lunnon's map folding algorithm.
3
-
4
- (AI generated docstring)
5
-
6
- With the configuration foundation established and the type system defined, this
7
- module provides the essential building blocks that transform mathematical theory
8
- into executable computation. These utilities implement the fundamental operations
9
- required by Lunnon's 1971 algorithm, handling dimension validation, connection
10
- graph generation, and computational resource management.
11
-
12
- The connection graph generation represents the mathematical heart of the algorithm,
13
- calculating how leaves connect across dimensions using coordinate systems, parity
14
- rules, and boundary conditions. This graph becomes the foundation upon which the
15
- recursive folding analysis operates. Validation functions ensure computational
16
- of large-scale problems. Validation functions ensure computational
17
- integrity, while task division management enables experimental task division strategies.
18
-
19
- These utilities follow DRY and SSOT principles, providing reusable functions that
20
- serve as the computational assembly-line components. They prepare the essential
21
- data structures and computational parameters that the state management system
22
- requires to orchestrate the complex recursive algorithms.
23
- """
1
+ """Oft-needed computations or actions, especially for multi-dimensional map folding."""
24
2
 
25
3
  from collections.abc import Sequence
26
4
  from hunterMakesPy import defineConcurrencyLimit, intInnit, oopsieKwargsie
@@ -33,8 +11,6 @@ import numpy
33
11
  def getLeavesTotal(mapShape: tuple[int, ...]) -> int:
34
12
  """Calculate the total number of leaves in a map with the given dimensions.
35
13
 
36
- (AI generated docstring)
37
-
38
14
  The total number of leaves is the product of all dimensions in the map shape.
39
15
 
40
16
  Parameters
@@ -66,8 +42,6 @@ def getLeavesTotal(mapShape: tuple[int, ...]) -> int:
66
42
  def getTaskDivisions(computationDivisions: int | str | None, concurrencyLimit: int, leavesTotal: int) -> int:
67
43
  """Determine whether to divide the computation into tasks and how many divisions.
68
44
 
69
- (AI generated docstring)
70
-
71
45
  Parameters
72
46
  ----------
73
47
  computationDivisions : int | str | None
@@ -214,12 +188,10 @@ def makeDataContainer(shape: int | tuple[int, ...], datatype: type[NumPyIntegerT
214
188
  def setProcessorLimit(CPUlimit: Any | None, concurrencyPackage: str | None = None) -> int:
215
189
  """Set the CPU usage limit for concurrent operations.
216
190
 
217
- (AI generated docstring)
218
-
219
191
  Parameters
220
192
  ----------
221
193
  CPUlimit : Any | None
222
- Please see the documentation for in `countFolds` for details. I know it is annoying, but I want to be sure you
194
+ Please see the documentation in `countFolds` for details. I know it is annoying, but I want to be sure you
223
195
  have the most accurate information.
224
196
  concurrencyPackage : str | None = None
225
197
  Specifies which concurrency package to use.