mapFolding 0.16.1__py3-none-any.whl → 0.16.4__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 (78) hide show
  1. easyRun/A000682.py +1 -1
  2. easyRun/A005316.py +2 -3
  3. easyRun/NOTcountingFolds.py +6 -5
  4. easyRun/countFolds.py +1 -1
  5. easyRun/generateAllModules.py +14 -0
  6. easyRun/meanders.py +16 -18
  7. mapFolding/__init__.py +1 -0
  8. mapFolding/_theSSOT.py +3 -2
  9. mapFolding/_theTypes.py +3 -0
  10. mapFolding/algorithms/A086345.py +75 -0
  11. mapFolding/algorithms/matrixMeanders.py +15 -28
  12. mapFolding/algorithms/matrixMeandersBeDry.py +34 -116
  13. mapFolding/algorithms/matrixMeandersNumPy.py +117 -70
  14. mapFolding/algorithms/matrixMeandersPandas.py +113 -130
  15. mapFolding/algorithms/oeisIDbyFormula.py +25 -14
  16. mapFolding/algorithms/symmetricFolds.py +36 -0
  17. mapFolding/algorithms/zCuzDocStoopidoeisIDbyFormula.py +26 -12
  18. mapFolding/basecamp.py +152 -323
  19. mapFolding/dataBaskets.py +136 -34
  20. mapFolding/filesystemToolkit.py +4 -32
  21. mapFolding/oeis.py +5 -12
  22. mapFolding/reference/A000682facts.py +785 -1264
  23. mapFolding/reference/A005316facts.py +958 -923
  24. mapFolding/reference/A086345Wu.py +25 -0
  25. mapFolding/reference/matrixMeandersAnalysis/signatures.py +2033 -0
  26. mapFolding/someAssemblyRequired/A007822/A007822rawMaterials.py +9 -44
  27. mapFolding/someAssemblyRequired/A007822/_asynchronousAnnex.py +51 -0
  28. mapFolding/someAssemblyRequired/A007822/makeA007822AsynchronousModules.py +39 -136
  29. mapFolding/someAssemblyRequired/A007822/makeA007822Modules.py +44 -45
  30. mapFolding/someAssemblyRequired/RecipeJob.py +78 -18
  31. mapFolding/someAssemblyRequired/__init__.py +3 -8
  32. mapFolding/someAssemblyRequired/_toolkitContainers.py +32 -3
  33. mapFolding/someAssemblyRequired/infoBooth.py +40 -23
  34. mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +75 -154
  35. mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +56 -88
  36. mapFolding/someAssemblyRequired/makingModules_count.py +91 -85
  37. mapFolding/someAssemblyRequired/makingModules_doTheNeedful.py +7 -65
  38. mapFolding/someAssemblyRequired/{mapFolding → mapFoldingModules}/makeMapFoldingModules.py +25 -31
  39. mapFolding/someAssemblyRequired/meanders/makeMeandersModules.py +14 -13
  40. mapFolding/someAssemblyRequired/toolkitMakeModules.py +10 -10
  41. mapFolding/someAssemblyRequired/toolkitNumba.py +1 -1
  42. mapFolding/someAssemblyRequired/transformationTools.py +17 -19
  43. mapFolding/syntheticModules/A007822/algorithm.py +46 -50
  44. mapFolding/syntheticModules/A007822/asynchronous.py +93 -34
  45. mapFolding/syntheticModules/A007822/initializeState.py +15 -21
  46. mapFolding/syntheticModules/A007822/theorem2.py +21 -21
  47. mapFolding/syntheticModules/A007822/theorem2Numba.py +42 -23
  48. mapFolding/syntheticModules/A007822/theorem2Trimmed.py +21 -21
  49. mapFolding/syntheticModules/countParallelNumba.py +3 -7
  50. mapFolding/syntheticModules/daoOfMapFoldingNumba.py +3 -6
  51. mapFolding/syntheticModules/meanders/bigInt.py +15 -25
  52. mapFolding/syntheticModules/theorem2.py +6 -0
  53. mapFolding/syntheticModules/theorem2Numba.py +26 -2
  54. mapFolding/syntheticModules/theorem2Trimmed.py +6 -0
  55. mapFolding/tests/test_computations.py +1 -1
  56. mapFolding/zCuzDocStoopid/makeDocstrings.py +2 -0
  57. {mapfolding-0.16.1.dist-info → mapfolding-0.16.4.dist-info}/METADATA +4 -1
  58. mapfolding-0.16.4.dist-info/RECORD +106 -0
  59. mapFolding/_dataPacking.py +0 -68
  60. mapFolding/reference/meandersDumpingGround/A005316intOptimized.py +0 -122
  61. mapFolding/reference/meandersDumpingGround/A005316optimized128bit.py +0 -79
  62. mapFolding/reference/meandersDumpingGround/matrixMeandersBaseline.py +0 -65
  63. mapFolding/reference/meandersDumpingGround/matrixMeandersBaselineAnnex.py +0 -84
  64. mapFolding/reference/meandersDumpingGround/matrixMeandersSimpleQueue.py +0 -90
  65. mapFolding/syntheticModules/A007822/algorithmNumba.py +0 -94
  66. mapFolding/syntheticModules/A007822/asynchronousAnnex.py +0 -66
  67. mapFolding/syntheticModules/A007822/asynchronousAnnexNumba.py +0 -85
  68. mapFolding/syntheticModules/A007822/asynchronousNumba.py +0 -52
  69. mapFolding/syntheticModules/A007822/asynchronousTheorem2.py +0 -53
  70. mapFolding/syntheticModules/A007822/asynchronousTrimmed.py +0 -47
  71. mapFolding/syntheticModules/dataPacking.py +0 -28
  72. mapFolding/syntheticModules/dataPackingA007822.py +0 -92
  73. mapfolding-0.16.1.dist-info/RECORD +0 -114
  74. /mapFolding/someAssemblyRequired/{mapFolding → mapFoldingModules}/__init__.py +0 -0
  75. {mapfolding-0.16.1.dist-info → mapfolding-0.16.4.dist-info}/WHEEL +0 -0
  76. {mapfolding-0.16.1.dist-info → mapfolding-0.16.4.dist-info}/entry_points.txt +0 -0
  77. {mapfolding-0.16.1.dist-info → mapfolding-0.16.4.dist-info}/licenses/LICENSE +0 -0
  78. {mapfolding-0.16.1.dist-info → mapfolding-0.16.4.dist-info}/top_level.txt +0 -0
mapFolding/basecamp.py CHANGED
@@ -1,40 +1,42 @@
1
1
  """Unified interface for map folding computation."""
2
2
 
3
3
  from collections.abc import Sequence
4
- from functools import cache
5
4
  from mapFolding import (
6
5
  getPathFilenameFoldsTotal, packageSettings, saveFoldsTotal, saveFoldsTotalFAILearly, validateListDimensions)
7
6
  from os import PathLike
8
- from pathlib import PurePath
7
+ from pathlib import Path, PurePath
9
8
  from typing import Literal
10
9
 
11
10
  # ruff: noqa: PLC0415
12
11
  """TODO new flow paradigm, incomplete
13
12
 
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
-
18
- algorithms directory
19
- manually coded algorithms or formulas
20
- `countFolds` will be a stable interface for multidimensional map folding, including synthetic modules
21
- This has special treatment because people may want to call mapShape not defined in OEIS
22
- `countMeanders` will be a stable interface for meanders
23
- This has special treatment because people may want to call meanders not defined in OEIS
24
- an enhanced version of `oeisIDfor_n` will be a stable interface for calling by ID and n
25
-
26
- General flow structure
27
- doTheNeedful
28
- specific to that version of that algorithm
29
- abstracts the API for that algorithm, so that algorithm (such as multidimensional map folding) has a stable interface
30
- The last place to do defensive programming
31
-
32
- - Incomplete: how to count
33
- - currently in parameters computationDivisions, CPUlimit, and flow
34
-
35
- - Flow in count______
36
- - DEFENSIVE PROGRAMMING
37
- - FAIL EARLY
13
+ - I don't want to FORCE people to use the meaningless OEIS ids without providing the definition of the ID at the same time.
14
+ - On the other hand, I don't have any evidence that anyone is using this package except me.
15
+ - algorithms directory: manually coded algorithms or formulas.
16
+ - 'basecamp' should be able to call any algorithm version.
17
+ - Quickly call the algorithm or the algorithm's dispatcher, i.e., `doTheNeedful`.
18
+ - `countFolds` will be a stable interface for multidimensional map folding, including synthetic modules.
19
+ - `NOTcountingFolds` is sufficient for now. I'll make an analogue to `countFolds` for some algorithms if it would be useful.
20
+
21
+ - state vs ? environment?
22
+ In multidimensional map folding, computationDivisions is part of the state because it is used in the algorithm during a module
23
+ operation. In contrast, CPUlimit is not used in the algorithm, so I feel like it is not part of the state. Storing the state
24
+ in a databasket (i.e., a dataclass) makes things much easier.
25
+
26
+ Environment settings that I sometimes need:
27
+ Concurrency
28
+ CPUlimit.
29
+ Package for concurrency operations.
30
+ Settings for that package, if it were a GPU, for example.
31
+ Memorialization
32
+ Path
33
+ Filename standardization
34
+ Record only a(n), the entire state, or something else?
35
+ Status updates, such as tqdm.
36
+
37
+ - Flow in basecamp
38
+ - Interpret parameters
39
+ - DEFENSIVE PROGRAMMING; FAIL EARLY
38
40
  - Implement "common foundational logic".
39
41
  - IDK what the correct technical term is, but I'm sure other people have researched excellent ways to do this.
40
42
  - Example: in `countFolds`, every possible flow path needs `mapShape`. Therefore, `mapShape` is foundational logic that
@@ -42,37 +44,17 @@ General flow structure
42
44
  - Example: in `countFolds`, some flow paths have more than one "task division" (i.e., the computation is divided into
43
45
  multiple tasks), while other flow paths only have one task division. One reasonable perspective is that computing task
44
46
  divisions is NOT "common foundational logic". My perspective for this example: to compute whether or not there are
45
- task divisions and if so, how many task divisions is identical for all flow paths. Therefore, I handle computing task
46
- divisions as "common foundational logic".
47
- - Incomplete
48
- - Initialize memorialization instructions, if asked
49
- - MORE DEFENSIVE PROGRAMMING
50
- - FAIL EARLIER THAN EARLY
51
- - Incomplete
52
- - DEFENSIVE PROGRAMMING ON BEHALF of downstream modules and functions
53
- - FAIL SO EARLY IT IS BEFORE THE USER INSTALLS THE APP
54
- - Incomplete
55
- - REPEAT MANY OR ALL OF THE DEFENSIVE PROGRAMMING YOU HAVE ALREADY DONE
56
-
57
- - Incomplete
47
+ task divisions is identical for all flow paths. Therefore, it is "common foundational logic".
48
+ - Initialize memorialization instructions, if asked.
58
49
  - Pass control to the correct `doTheNeedful`
59
- - I don't know how to "elegantly" pass control without putting `doTheNeedful` over `count______` in the stack, therefore,
50
+ - I don't know how to "elegantly" pass control without putting `doTheNeedful` on `count______` in the stack, therefore,
60
51
  control will come back here.
61
- - DO NOT, for the love of puppies and cookies, DO NOT use defensive programming here. Defensive programming AFTER a
62
- four-week-long computation is a tacit admission of incompetent programming.
63
- - Follow memorialization instructions: which means pass control to a function will tenaciously follow the instructions.
64
- - return "a(n)" (as OEIS calls it), such as foldsTotal
65
-
52
+ - DO NOT, for the love of puppies and cookies, DO NOT use defensive programming when control returns here. Defensive
53
+ programming AFTER a four-week-long computation is a tacit admission of incompetent programming.
54
+ - Follow memorialization instructions: which means pass control to a function that will tenaciously follow the instructions.
55
+ - return "a(n)" (as OEIS calls it), such as foldsTotal.
66
56
  """
67
57
 
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
-
76
58
  def countFolds(listDimensions: Sequence[int] | None = None
77
59
  , pathLikeWriteFoldsTotal: PathLike[str] | PurePath | None = None
78
60
  , computationDivisions: int | str | None = None
@@ -82,7 +64,7 @@ def countFolds(listDimensions: Sequence[int] | None = None
82
64
  , flow: str | None = None
83
65
  ) -> int:
84
66
  """
85
- Count the total number of distinct ways to fold a map.
67
+ Count the number of distinct ways to fold a map.
86
68
 
87
69
  Mathematicians also describe this as folding a strip of stamps, and they usually call the total "number of distinct ways to
88
70
  fold" a map the map's "foldings."
@@ -129,7 +111,8 @@ def countFolds(listDimensions: Sequence[int] | None = None
129
111
 
130
112
  Returns
131
113
  -------
132
- foldsTotal: Total number of distinct ways to fold a map of the given dimensions.
114
+ foldsTotal : int
115
+ Number of distinct ways to fold a map of the given dimensions.
133
116
 
134
117
  Note well
135
118
  ---------
@@ -145,7 +128,7 @@ def countFolds(listDimensions: Sequence[int] | None = None
145
128
  computation time. If logicalCores >= `leavesTotal`, it will probably be faster. If logicalCores <= 2 * `leavesTotal`, it
146
129
  will almost certainly be slower for all map dimensions.
147
130
  """
148
- # mapShape ---------------------------------------------------------------------
131
+ # ------- mapShape ---------------------------------------------------------------------
149
132
 
150
133
  if mapShape:
151
134
  pass
@@ -159,311 +142,157 @@ def countFolds(listDimensions: Sequence[int] | None = None
159
142
  )
160
143
  raise ValueError(message)
161
144
 
162
- # task division instructions -----------------------------------------------------
145
+ # ------- task division instructions -----------------------------------------------------
163
146
 
164
147
  if computationDivisions:
165
148
  from mapFolding.beDRY import getLeavesTotal, getTaskDivisions, setProcessorLimit
166
149
  concurrencyLimit: int = setProcessorLimit(CPUlimit, packageSettings.concurrencyPackage)
167
150
  leavesTotal: int = getLeavesTotal(mapShape)
168
- taskDivisions = getTaskDivisions(computationDivisions, concurrencyLimit, leavesTotal)
151
+ taskDivisions: int = getTaskDivisions(computationDivisions, concurrencyLimit, leavesTotal)
169
152
  del leavesTotal
170
153
  else:
171
154
  concurrencyLimit = 1
172
155
  taskDivisions = 0
173
156
 
174
- # memorialization instructions ---------------------------------------------
157
+ # ------- memorialization instructions ---------------------------------------------
175
158
 
176
159
  if pathLikeWriteFoldsTotal is not None:
177
- pathFilenameFoldsTotal = getPathFilenameFoldsTotal(mapShape, pathLikeWriteFoldsTotal)
160
+ pathFilenameFoldsTotal: Path | None = getPathFilenameFoldsTotal(mapShape, pathLikeWriteFoldsTotal)
178
161
  saveFoldsTotalFAILearly(pathFilenameFoldsTotal)
179
162
  else:
180
163
  pathFilenameFoldsTotal = None
181
164
 
182
- # Flow control until I can figure out a good way ---------------------------------
183
-
184
- if flow == 'daoOfMapFolding':
185
- from mapFolding.dataBaskets import MapFoldingState
186
- mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
187
-
188
- from mapFolding.algorithms.daoOfMapFolding import doTheNeedful
189
- mapFoldingState = doTheNeedful(mapFoldingState)
190
- foldsTotal = mapFoldingState.foldsTotal
191
-
192
- elif flow == 'numba':
193
- from mapFolding.dataBaskets import MapFoldingState
194
- mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
195
-
196
- from mapFolding.syntheticModules.daoOfMapFoldingNumba import doTheNeedful
197
- mapFoldingState = doTheNeedful(mapFoldingState)
198
- foldsTotal = mapFoldingState.foldsTotal
199
-
200
- elif flow == 'theorem2' and any(dimension > 2 for dimension in mapShape):
201
- from mapFolding.dataBaskets import MapFoldingState
202
- mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
203
-
204
- from mapFolding.syntheticModules.initializeState import transitionOnGroupsOfFolds
205
- mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
206
-
207
- from mapFolding.syntheticModules.theorem2 import count
208
- mapFoldingState = count(mapFoldingState)
209
-
210
- foldsTotal = mapFoldingState.foldsTotal
211
-
212
- elif (flow == 'theorem2Numba' or taskDivisions == 0) and any(dimension > 2 for dimension in mapShape):
213
- from mapFolding.dataBaskets import MapFoldingState
214
- mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
215
-
216
- from mapFolding.syntheticModules.initializeState import transitionOnGroupsOfFolds
217
- mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
218
-
219
- from mapFolding.syntheticModules.dataPacking import sequential
220
- mapFoldingState = sequential(mapFoldingState)
221
-
222
- foldsTotal = mapFoldingState.foldsTotal
223
-
224
- elif flow == 'theorem2Trimmed' and any(dimension > 2 for dimension in mapShape):
225
- from mapFolding.dataBaskets import MapFoldingState
226
- mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
227
-
228
- from mapFolding.syntheticModules.initializeState import transitionOnGroupsOfFolds
229
- mapFoldingState = transitionOnGroupsOfFolds(mapFoldingState)
230
-
231
- from mapFolding.syntheticModules.theorem2Trimmed import count
232
- mapFoldingState = count(mapFoldingState)
233
-
234
- foldsTotal = mapFoldingState.foldsTotal
235
-
236
- elif taskDivisions > 1:
165
+ # ------- Algorithm version -----------------------------------------------------
166
+ if taskDivisions > 1:
237
167
  from mapFolding.dataBaskets import ParallelMapFoldingState
238
- mapFoldingParallelState: ParallelMapFoldingState = ParallelMapFoldingState(mapShape, taskDivisions=taskDivisions)
239
-
240
168
  from mapFolding.syntheticModules.countParallelNumba import doTheNeedful
241
169
 
170
+ mapFoldingParallelState: ParallelMapFoldingState = ParallelMapFoldingState(mapShape, taskDivisions=taskDivisions)
171
+
242
172
  # `listStatesParallel` exists so you can research the parallel computation.
243
- foldsTotal, listStatesParallel = doTheNeedful(mapFoldingParallelState, concurrencyLimit) # pyright: ignore[reportUnusedVariable] # noqa: RUF059
173
+ foldsTotal, _listStatesParallel = doTheNeedful(mapFoldingParallelState, concurrencyLimit)
244
174
 
175
+ # ruff: noqa: E701
245
176
  else:
177
+ match flow:
178
+ case 'daoOfMapFolding': from mapFolding.algorithms.daoOfMapFolding import doTheNeedful
179
+ case 'numba': from mapFolding.syntheticModules.daoOfMapFoldingNumba import doTheNeedful
180
+ case 'theorem2': from mapFolding.syntheticModules.theorem2 import doTheNeedful
181
+ case 'theorem2Numba': from mapFolding.syntheticModules.theorem2Numba import doTheNeedful
182
+ case 'theorem2Trimmed': from mapFolding.syntheticModules.theorem2Trimmed import doTheNeedful
183
+ case _: from mapFolding.algorithms.daoOfMapFolding import doTheNeedful
184
+
246
185
  from mapFolding.dataBaskets import MapFoldingState
247
186
  mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
248
-
249
- from mapFolding.algorithms.daoOfMapFolding import doTheNeedful
250
187
  mapFoldingState = doTheNeedful(mapFoldingState)
251
188
  foldsTotal = mapFoldingState.foldsTotal
252
189
 
253
- # Follow memorialization instructions ---------------------------------------------
190
+ # ------- Follow memorialization instructions ---------------------------------------------
254
191
 
255
192
  if pathFilenameFoldsTotal is not None:
256
193
  saveFoldsTotal(pathFilenameFoldsTotal, foldsTotal)
257
194
 
258
195
  return foldsTotal
259
196
 
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
197
  def NOTcountingFolds(oeisID: str, oeis_n: int, flow: str | None = None
325
- # , pathLikeWriteFoldsTotal: PathLike[str] | PurePath | None = None # noqa: ERA001
198
+ # TODO , pathLikeWriteFoldsTotal: PathLike[str] | PurePath | None = None
326
199
  , CPUlimit: bool | float | int | None = None # noqa: FBT001
327
200
  ) -> int:
328
201
  """Do stuff."""
329
- countTotal: int = -1
202
+ countTotal: int = -31212012 # ERROR
203
+ matched_oeisID: bool = True
330
204
 
331
205
  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
206
+ case 'A000136': from mapFolding.algorithms.oeisIDbyFormula import A000136 as doTheNeedful
207
+ case 'A000560': from mapFolding.algorithms.oeisIDbyFormula import A000560 as doTheNeedful
208
+ case 'A001010': from mapFolding.algorithms.oeisIDbyFormula import A001010 as doTheNeedful
209
+ case 'A001011': from mapFolding.algorithms.oeisIDbyFormula import A001011 as doTheNeedful
210
+ case 'A005315': from mapFolding.algorithms.oeisIDbyFormula import A005315 as doTheNeedful
211
+ case 'A060206': from mapFolding.algorithms.oeisIDbyFormula import A060206 as doTheNeedful
212
+ case 'A077460': from mapFolding.algorithms.oeisIDbyFormula import A077460 as doTheNeedful
213
+ case 'A078591': from mapFolding.algorithms.oeisIDbyFormula import A078591 as doTheNeedful
214
+ case 'A086345': from mapFolding.algorithms.A086345 import A086345 as doTheNeedful
215
+ case 'A178961': from mapFolding.algorithms.oeisIDbyFormula import A178961 as doTheNeedful
216
+ case 'A223094': from mapFolding.algorithms.oeisIDbyFormula import A223094 as doTheNeedful
217
+ case 'A259702': from mapFolding.algorithms.oeisIDbyFormula import A259702 as doTheNeedful
218
+ case 'A301620': from mapFolding.algorithms.oeisIDbyFormula import A301620 as doTheNeedful
219
+ case _: matched_oeisID = False
220
+ if matched_oeisID:
221
+ countTotal = doTheNeedful(oeis_n) # pyright: ignore[reportPossiblyUnboundVariable]
222
+ else:
223
+ matched_oeisID = True
224
+ match oeisID:
225
+ case 'A000682' | 'A005316':
226
+ match flow:
227
+ case 'matrixNumPy':
228
+ from mapFolding.algorithms.matrixMeandersNumPy import doTheNeedful
229
+ from mapFolding.dataBaskets import MatrixMeandersNumPyState as State
230
+ case 'matrixPandas':
231
+ from mapFolding.algorithms.matrixMeandersPandas import doTheNeedful
232
+ from mapFolding.dataBaskets import MatrixMeandersNumPyState as State
233
+ case _:
234
+ from mapFolding.algorithms.matrixMeanders import doTheNeedful
235
+ from mapFolding.dataBaskets import MatrixMeandersState as State
236
+
237
+ boundary: int = oeis_n - 1
238
+
239
+ if oeisID == 'A000682':
240
+ if oeis_n == 1:
241
+ return 1
242
+ elif oeis_n & 0b1:
243
+ arcCode: int = 0b101
244
+ else:
245
+ arcCode = 0b1
246
+ listArcCodes: list[int] = [(arcCode << 1) | arcCode]
247
+ # 0b1010 | 0b0101 is 0b1111, or 0xf
248
+ # 0b10 | 0b01 is 0b11, or 0x3
249
+
250
+ MAXIMUMarcCode: int = 1 << (2 * boundary + 4)
251
+ while listArcCodes[-1] < MAXIMUMarcCode:
252
+ arcCode = (arcCode << 4) | 0b0101 # e.g., 0b 10000 | 0b 0101 = 0b 10101
253
+ listArcCodes.append((arcCode << 1) | arcCode) # e.g., 0b 101010 | 0b 1010101 = 0b 111111 = 0x3f
254
+ # Thereafter, append 0b1111 or 0xf, so, e.g., 0x3f, 0x3ff, 0x3fff, 0x3ffff, ...
255
+ # See "mapFolding/reference/A000682facts.py"
256
+ dictionaryMeanders=dict.fromkeys(listArcCodes, 1)
257
+
258
+ elif oeisID == 'A005316':
259
+ if oeis_n & 0b1:
260
+ dictionaryMeanders: dict[int, int] = {0b1111: 1} # 0xf
261
+ else:
262
+ dictionaryMeanders = {0b10110: 1}
263
+ else:
264
+ message = f"Programming error: I should never have received `{oeisID = }`."
265
+ raise ValueError(message)
266
+
267
+ state = State(oeis_n, oeisID, boundary, dictionaryMeanders)
268
+ countTotal = doTheNeedful(state) # pyright: ignore[reportArgumentType]
269
+ case 'A007822':
270
+ mapShape: tuple[Literal[1], int] = (1, 2 * oeis_n)
271
+ from mapFolding import setProcessorLimit
272
+ concurrencyLimit: int = setProcessorLimit(CPUlimit)
273
+
274
+ from mapFolding.dataBaskets import SymmetricFoldsState
275
+ symmetricState: SymmetricFoldsState = SymmetricFoldsState(mapShape)
276
+
277
+ match flow:
278
+ case 'asynchronous':
279
+ from mapFolding.syntheticModules.A007822.asynchronous import doTheNeedful
280
+ symmetricState = doTheNeedful(symmetricState, concurrencyLimit)
281
+ case 'theorem2':
282
+ from mapFolding.syntheticModules.A007822.theorem2 import doTheNeedful
283
+ symmetricState = doTheNeedful(symmetricState)
284
+ case 'theorem2Numba':
285
+ from mapFolding.syntheticModules.A007822.theorem2Numba import doTheNeedful
286
+ symmetricState = doTheNeedful(symmetricState)
287
+ case 'theorem2Trimmed':
288
+ from mapFolding.syntheticModules.A007822.theorem2Trimmed import doTheNeedful
289
+ symmetricState = doTheNeedful(symmetricState)
290
+ case _:
291
+ from mapFolding.syntheticModules.A007822.algorithm import doTheNeedful
292
+ symmetricState = doTheNeedful(symmetricState)
293
+
294
+ countTotal = symmetricState.groupsOfFolds
295
+ case _:
296
+ matched_oeisID = False
467
297
 
468
298
  return countTotal
469
-