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
@@ -0,0 +1,351 @@
1
+ from gc import collect as goByeBye
2
+ from mapFolding.algorithms.matrixMeandersBeDry import areIntegersWide, flipTheExtra_0b1AsUfunc, getBucketsTotal
3
+ from mapFolding.dataBaskets import MatrixMeandersNumPyState
4
+ from mapFolding.syntheticModules.meanders.bigInt import countBigInt
5
+ from warnings import warn
6
+ import pandas
7
+
8
+ # TODO investigate adding another condition to `areIntegersWide`: while dict is faster than pandas, stay in bigInt.
9
+
10
+ # ruff: noqa: B023
11
+
12
+ def countPandas(state: MatrixMeandersNumPyState) -> MatrixMeandersNumPyState:
13
+ """Count meanders with matrix transfer algorithm using pandas DataFrame.
14
+
15
+ Parameters
16
+ ----------
17
+ state : MatrixMeandersState
18
+ The algorithm state containing current `kOfMatrix`, `dictionaryMeanders`, and thresholds.
19
+
20
+ Returns
21
+ -------
22
+ state : MatrixMeandersState
23
+ Updated state with new `kOfMatrix` and `dictionaryMeanders`.
24
+ """
25
+ dataframeAnalyzed = pandas.DataFrame({
26
+ 'analyzed': pandas.Series(name='analyzed', data=state.dictionaryMeanders.keys(), copy=False, dtype=state.datatypeArcCode)
27
+ , 'crossings': pandas.Series(name='crossings', data=state.dictionaryMeanders.values(), copy=False, dtype=state.datatypeCrossings)
28
+ }, dtype=state.datatypeArcCode
29
+ )
30
+ state.dictionaryMeanders.clear()
31
+
32
+ while (state.kOfMatrix > 0 and not areIntegersWide(state, dataframe=dataframeAnalyzed)):
33
+
34
+ def aggregateArcCodes() -> None:
35
+ nonlocal dataframeAnalyzed
36
+ dataframeAnalyzed = dataframeAnalyzed.iloc[0:state.indexTarget].groupby('analyzed', sort=False)['crossings'].aggregate('sum').reset_index()
37
+
38
+ def analyzeArcCodesAligned() -> None:
39
+ """Compute `arcCode` from `bitsAlpha` and `bitsZulu` if at least one is an even number.
40
+
41
+ Before computing `arcCode`, some values of `bitsAlpha` and `bitsZulu` are modified.
42
+
43
+ Warning
44
+ -------
45
+ This function deletes rows from `dataframeMeanders`. Always run this analysis last.
46
+
47
+ Formula
48
+ -------
49
+ ```python
50
+ if bitsAlpha > 1 and bitsZulu > 1 and (bitsAlphaIsEven or bitsZuluIsEven):
51
+ arcCode = (bitsAlpha >> 2) | ((bitsZulu >> 2) << 1)
52
+ ```
53
+ """
54
+ nonlocal dataframeMeanders
55
+
56
+ # NOTE Step 1 drop unqualified rows
57
+
58
+ bitsTarget: pandas.Series = dataframeMeanders['arcCode'].copy() # `bitsAlpha`
59
+ bitsTarget &= state.locatorBits # `bitsAlpha`
60
+
61
+ dataframeMeanders = dataframeMeanders.loc[(bitsTarget > 1)] # if bitsAlphaHasCurves
62
+
63
+ del bitsTarget
64
+
65
+ bitsTarget = dataframeMeanders['arcCode'].copy() # `bitsZulu`
66
+ bitsTarget //= 2**1 # `bitsZulu` (bitsZulu >> 1)
67
+ bitsTarget &= state.locatorBits # `bitsZulu`
68
+
69
+ dataframeMeanders = dataframeMeanders.loc[(bitsTarget > 1)] # if bitsZuluHasCurves
70
+
71
+ del bitsTarget
72
+
73
+ bitsTarget = dataframeMeanders['arcCode'].copy() # `bitsZulu`
74
+ bitsTarget &= 0b10 # `bitsZulu`
75
+ bitsTarget //= 2**1 # `bitsZulu` (bitsZulu >> 1)
76
+ bitsTarget &= 1 # (bitsZulu & 1)
77
+ bitsTarget ^= 1 # (1 - (bitsZulu ...))
78
+ dataframeMeanders.loc[:, 'analyzed'] = bitsTarget # selectorBitsZuluAtEven
79
+
80
+ del bitsTarget
81
+
82
+ bitsTarget = dataframeMeanders['arcCode'].copy() # `bitsAlpha`
83
+ bitsTarget &= 1 # (bitsAlpha & 1)
84
+ bitsTarget ^= 1 # (1 - (bitsAlpha ...))
85
+ bitsTarget = bitsTarget.astype(bool) # selectorBitsAlphaAtODD
86
+
87
+ dataframeMeanders = dataframeMeanders.loc[(bitsTarget) | (dataframeMeanders.loc[:, 'analyzed'])] # if (bitsAlphaIsEven or bitsZuluIsEven)
88
+
89
+ del bitsTarget
90
+
91
+ # NOTE Step 2 modify rows
92
+
93
+ # Make a selector for bitsZuluAtEven, so you can modify bitsAlpha
94
+ bitsTarget = dataframeMeanders['arcCode'].copy() # `bitsZulu`
95
+ bitsTarget &= 0b10 # `bitsZulu`
96
+ bitsTarget //= 2**1 # `bitsZulu` (bitsZulu >> 1)
97
+ bitsTarget &= 1 # (bitsZulu & 1)
98
+ bitsTarget ^= 1 # (1 - (bitsZulu ...))
99
+ bitsTarget = bitsTarget.astype(bool) # selectorBitsZuluAtEven
100
+
101
+ dataframeMeanders.loc[:, 'analyzed'] = dataframeMeanders['arcCode'] # `bitsAlpha`
102
+ dataframeMeanders.loc[:, 'analyzed'] &= state.locatorBits # `bitsAlpha`
103
+
104
+ # if bitsAlphaIsEven and not bitsZuluIsEven, modify bitsAlphaPairedToOdd
105
+ dataframeMeanders.loc[(~bitsTarget), 'analyzed'] = state.datatypeArcCode( # pyright: ignore[reportCallIssue, reportArgumentType]
106
+ flipTheExtra_0b1AsUfunc(dataframeMeanders.loc[(~bitsTarget), 'analyzed']))
107
+
108
+ del bitsTarget
109
+
110
+ # if bitsZuluIsEven and not bitsAlphaIsEven, modify bitsZuluPairedToOdd
111
+ bitsTarget = dataframeMeanders['arcCode'].copy() # `bitsZulu`
112
+ bitsTarget //= 2**1 # `bitsZulu` (bitsZulu >> 1)
113
+ bitsTarget &= state.locatorBits # `bitsZulu`
114
+
115
+ bitsTarget.loc[(dataframeMeanders.loc[:, 'arcCode'] & 1).astype(bool)] = state.datatypeArcCode( # pyright: ignore[reportArgumentType, reportCallIssue]
116
+ flipTheExtra_0b1AsUfunc(bitsTarget.loc[(dataframeMeanders.loc[:, 'arcCode'] & 1).astype(bool)])) # pyright: ignore[reportCallIssue, reportUnknownArgumentType, reportArgumentType]
117
+
118
+ # NOTE Step 3 compute arcCode
119
+
120
+ dataframeMeanders.loc[:, 'analyzed'] //= 2**2 # (bitsAlpha >> 2)
121
+
122
+ bitsTarget //= 2**2 # (bitsZulu >> 2)
123
+ bitsTarget *= 2**1 # ((bitsZulu ...) << 1)
124
+
125
+ dataframeMeanders.loc[:, 'analyzed'] |= bitsTarget # ... | (bitsZulu ...)
126
+
127
+ del bitsTarget
128
+
129
+ dataframeMeanders.loc[dataframeMeanders['analyzed'] >= state.MAXIMUMarcCode, 'analyzed'] = 0
130
+
131
+ def analyzeBitsAlpha() -> None:
132
+ """Compute `arcCode` from `bitsAlpha`.
133
+
134
+ Formula
135
+ -------
136
+ ```python
137
+ if bitsAlpha > 1:
138
+ arcCode = ((1 - (bitsAlpha & 1)) << 1) | (bitsZulu << 3) | (bitsAlpha >> 2)
139
+ # `(1 - (bitsAlpha & 1)` is an evenness test.
140
+ ```
141
+ """
142
+ nonlocal dataframeMeanders
143
+ dataframeMeanders['analyzed'] = dataframeMeanders['arcCode']
144
+ dataframeMeanders.loc[:, 'analyzed'] &= 1 # (bitsAlpha & 1)
145
+ dataframeMeanders.loc[:, 'analyzed'] ^= 1 # (1 - (bitsAlpha ...))
146
+
147
+ dataframeMeanders.loc[:, 'analyzed'] *= 2**1 # ((bitsAlpha ...) << 1)
148
+
149
+ bitsTarget: pandas.Series = dataframeMeanders['arcCode'].copy() # `bitsZulu`
150
+ bitsTarget //= 2**1 # `bitsZulu` (bitsZulu >> 1)
151
+ bitsTarget &= state.locatorBits # `bitsZulu`
152
+
153
+ bitsTarget *= 2**3 # (bitsZulu << 3)
154
+ dataframeMeanders.loc[:, 'analyzed'] |= bitsTarget # ... | (bitsZulu ...)
155
+
156
+ del bitsTarget
157
+
158
+ """NOTE In this code block, I rearranged the "formula" to use `bitsTarget` for two goals. 1. `(bitsAlpha >> 2)`.
159
+ 2. `if bitsAlpha > 1`. The trick is in the equivalence of v1 and v2.
160
+ v1: BITScow | (BITSwalk >> 2)
161
+ v2: ((BITScow << 2) | BITSwalk) >> 2
162
+
163
+ The "formula" calls for v1, but by using v2, `bitsTarget` is not changed. Therefore, because `bitsTarget` is
164
+ `bitsAlpha`, I can use `bitsTarget` for goal 2, `if bitsAlpha > 1`.
165
+ """
166
+ dataframeMeanders.loc[:, 'analyzed'] *= 2**2 # ... | (bitsAlpha >> 2)
167
+
168
+ bitsTarget = dataframeMeanders['arcCode'].copy() # `bitsAlpha`
169
+ bitsTarget &= state.locatorBits # `bitsAlpha`
170
+
171
+ dataframeMeanders.loc[:, 'analyzed'] |= bitsTarget # ... | (bitsAlpha)
172
+ dataframeMeanders.loc[:, 'analyzed'] //= 2**2 # (... >> 2)
173
+
174
+ dataframeMeanders.loc[(bitsTarget <= 1), 'analyzed'] = 0 # if bitsAlpha > 1
175
+
176
+ del bitsTarget
177
+
178
+ dataframeMeanders.loc[dataframeMeanders['analyzed'] >= state.MAXIMUMarcCode, 'analyzed'] = 0
179
+
180
+ def analyzeArcCodesSimple() -> None:
181
+ """Compute arcCode with the 'simple' formula.
182
+
183
+ Formula
184
+ -------
185
+ ```python
186
+ arcCode = ((bitsAlpha | (bitsZulu << 1)) << 2) | 3
187
+ ```
188
+
189
+ Notes
190
+ -----
191
+ Using `+= 3` instead of `|= 3` is valid in this specific case. Left shift by two means the last bits are '0b00'. '0 + 3'
192
+ is '0b11', and '0b00 | 0b11' is also '0b11'.
193
+
194
+ """
195
+ nonlocal dataframeMeanders
196
+ dataframeMeanders['analyzed'] = dataframeMeanders['arcCode']
197
+ dataframeMeanders.loc[:, 'analyzed'] &= state.locatorBits
198
+
199
+ bitsZulu: pandas.Series = dataframeMeanders['arcCode'].copy()
200
+ bitsZulu //= 2**1 # (bitsZulu >> 1)
201
+ bitsZulu &= state.locatorBits # `bitsZulu`
202
+ bitsZulu *= 2**1 # (bitsZulu << 1)
203
+
204
+ dataframeMeanders.loc[:, 'analyzed'] |= bitsZulu # ((bitsAlpha | (bitsZulu ...))
205
+
206
+ del bitsZulu
207
+
208
+ dataframeMeanders.loc[:, 'analyzed'] *= 2**2 # (... << 2)
209
+ dataframeMeanders.loc[:, 'analyzed'] += 3 # (...) | 3
210
+ dataframeMeanders.loc[dataframeMeanders['analyzed'] >= state.MAXIMUMarcCode, 'analyzed'] = 0
211
+
212
+ def analyzeBitsZulu() -> None:
213
+ """Compute `arcCode` from `bitsZulu`.
214
+
215
+ Formula
216
+ -------
217
+ ```python
218
+ if bitsZulu > 1:
219
+ arcCode = (1 - (bitsZulu & 1)) | (bitsAlpha << 2) | (bitsZulu >> 1)
220
+ ```
221
+ """
222
+ nonlocal dataframeMeanders
223
+ dataframeMeanders.loc[:, 'analyzed'] = dataframeMeanders['arcCode'] # `bitsZulu`
224
+ dataframeMeanders.loc[:, 'analyzed'] &= 0b10 # `bitsZulu`
225
+ dataframeMeanders.loc[:, 'analyzed'] //= 2**1 # `bitsZulu` (bitsZulu >> 1)
226
+ dataframeMeanders.loc[:, 'analyzed'] &= 1 # (bitsZulu & 1)
227
+ dataframeMeanders.loc[:, 'analyzed'] ^= 1 # (1 - (bitsZulu ...))
228
+
229
+ bitsTarget: pandas.Series = dataframeMeanders['arcCode'].copy() # `bitsAlpha`
230
+ bitsTarget &= state.locatorBits # `bitsAlpha`
231
+
232
+ bitsTarget *= 2**2 # (bitsAlpha << 2)
233
+ dataframeMeanders.loc[:, 'analyzed'] |= bitsTarget # ... | (bitsAlpha ...)
234
+
235
+ del bitsTarget
236
+
237
+ # NOTE No, IDK why I didn't use the same trick as in `analyzeBitsAlpha`. I _think_ I wrote this code before I figured out that trick.
238
+ bitsTarget = dataframeMeanders['arcCode'].copy() # `bitsZulu`
239
+ bitsTarget //= 2**1 # `bitsZulu` (bitsZulu >> 1)
240
+ bitsTarget &= state.locatorBits # `bitsZulu`
241
+
242
+ bitsTarget //= 2**1 # (bitsZulu >> 1)
243
+
244
+ dataframeMeanders.loc[:, 'analyzed'] |= bitsTarget # ... | (bitsZulu ...)
245
+
246
+ del bitsTarget
247
+
248
+ bitsTarget = dataframeMeanders['arcCode'].copy() # `bitsZulu`
249
+ bitsTarget //= 2**1 # `bitsZulu` (bitsZulu >> 1)
250
+ bitsTarget &= state.locatorBits # `bitsZulu`
251
+
252
+ dataframeMeanders.loc[bitsTarget <= 1, 'analyzed'] = 0 # if bitsZulu > 1
253
+
254
+ del bitsTarget
255
+
256
+ dataframeMeanders.loc[dataframeMeanders['analyzed'] >= state.MAXIMUMarcCode, 'analyzed'] = 0
257
+
258
+ def recordArcCodes() -> None:
259
+ nonlocal dataframeAnalyzed
260
+
261
+ indexStopAnalyzed: int = state.indexTarget + int((dataframeMeanders['analyzed'] > 0).sum()) # pyright: ignore[reportUnknownArgumentType, reportUnknownMemberType]
262
+
263
+ if indexStopAnalyzed > state.indexTarget:
264
+ if len(dataframeAnalyzed.index) < indexStopAnalyzed:
265
+ warn(f"Lengthened `dataframeAnalyzed` from {len(dataframeAnalyzed.index)} to {indexStopAnalyzed=}; n={state.n}, {state.kOfMatrix=}.", stacklevel=2)
266
+ dataframeAnalyzed = dataframeAnalyzed.reindex(index=pandas.RangeIndex(indexStopAnalyzed), fill_value=0)
267
+
268
+ dataframeAnalyzed.loc[state.indexTarget:indexStopAnalyzed - 1, ['analyzed', 'crossings']] = (
269
+ dataframeMeanders.loc[(dataframeMeanders['analyzed'] > 0), ['analyzed', 'crossings']
270
+ ].to_numpy(dtype=state.datatypeArcCode, copy=False)
271
+ )
272
+
273
+ state.indexTarget = indexStopAnalyzed
274
+
275
+ del indexStopAnalyzed
276
+
277
+ dataframeMeanders = pandas.DataFrame({
278
+ 'arcCode': pandas.Series(name='arcCode', data=dataframeAnalyzed['analyzed'], copy=False, dtype=state.datatypeArcCode)
279
+ , 'analyzed': pandas.Series(name='analyzed', data=0, dtype=state.datatypeArcCode)
280
+ , 'crossings': pandas.Series(name='crossings', data=dataframeAnalyzed['crossings'], copy=False, dtype=state.datatypeCrossings)
281
+ } # pyright: ignore[reportUnknownArgumentType]
282
+ )
283
+
284
+ del dataframeAnalyzed
285
+ goByeBye()
286
+
287
+ state.bitWidth = int(dataframeMeanders['arcCode'].max()).bit_length()
288
+ length: int = getBucketsTotal(state)
289
+ dataframeAnalyzed = pandas.DataFrame({
290
+ 'analyzed': pandas.Series(0, pandas.RangeIndex(length), dtype=state.datatypeArcCode, name='analyzed')
291
+ , 'crossings': pandas.Series(0, pandas.RangeIndex(length), dtype=state.datatypeCrossings, name='crossings')
292
+ }, index=pandas.RangeIndex(length), columns=['analyzed', 'crossings'], dtype=state.datatypeArcCode # pyright: ignore[reportUnknownArgumentType]
293
+ )
294
+
295
+ state.kOfMatrix -= 1
296
+
297
+ state.indexTarget = 0
298
+
299
+ analyzeArcCodesSimple()
300
+ recordArcCodes()
301
+
302
+ analyzeBitsAlpha()
303
+ recordArcCodes()
304
+
305
+ analyzeBitsZulu()
306
+ recordArcCodes()
307
+
308
+ analyzeArcCodesAligned()
309
+ recordArcCodes()
310
+ del dataframeMeanders
311
+ goByeBye()
312
+
313
+ aggregateArcCodes()
314
+
315
+ if state.n >= 45: # for data collection
316
+ print(state.n, state.kOfMatrix+1, state.indexTarget, sep=',') # noqa: T201
317
+
318
+ state.dictionaryMeanders = dataframeAnalyzed.set_index('analyzed')['crossings'].to_dict()
319
+ return state
320
+
321
+ def doTheNeedful(state: MatrixMeandersNumPyState) -> int:
322
+ """Compute `crossings` with a transfer matrix algorithm implemented in pandas.
323
+
324
+ Parameters
325
+ ----------
326
+ state : MatrixMeandersState
327
+ The algorithm state.
328
+
329
+ Returns
330
+ -------
331
+ crossings : int
332
+ The computed value of `crossings`.
333
+
334
+ Notes
335
+ -----
336
+ Citation: https://github.com/hunterhogan/mapFolding/blob/main/citations/Jensen.bibtex
337
+
338
+ See Also
339
+ --------
340
+ https://oeis.org/A000682
341
+ https://oeis.org/A005316
342
+ """
343
+ while state.kOfMatrix > 0:
344
+ if areIntegersWide(state):
345
+ state = countBigInt(state)
346
+ else:
347
+ state = countPandas(state)
348
+
349
+ goByeBye()
350
+
351
+ return sum(state.dictionaryMeanders.values())