mapFolding 0.16.0__py3-none-any.whl → 0.16.2__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.
- easyRun/A000682.py +25 -0
- easyRun/A005316.py +20 -0
- easyRun/NOTcountingFolds.py +36 -0
- easyRun/__init__.py +0 -0
- easyRun/countFolds.py +41 -0
- easyRun/meanders.py +69 -0
- mapFolding/__init__.py +8 -51
- mapFolding/_dataPacking.py +68 -0
- mapFolding/_theSSOT.py +33 -37
- mapFolding/_theTypes.py +21 -4
- mapFolding/algorithms/matrixMeanders.py +86 -517
- mapFolding/algorithms/matrixMeandersBeDry.py +182 -0
- mapFolding/algorithms/matrixMeandersNumPy.py +333 -0
- mapFolding/algorithms/matrixMeandersPandas.py +334 -0
- mapFolding/algorithms/oeisIDbyFormula.py +50 -29
- mapFolding/algorithms/zCuzDocStoopidoeisIDbyFormula.py +51 -29
- mapFolding/basecamp.py +167 -206
- mapFolding/beDRY.py +2 -30
- mapFolding/dataBaskets.py +75 -49
- mapFolding/oeis.py +11 -32
- mapFolding/reference/A000682facts.py +787 -652
- mapFolding/reference/A005316facts.py +961 -3
- mapFolding/reference/matrixMeandersAnalysis/prefixNotationNotes.py +15 -0
- mapFolding/reference/matrixMeandersAnalysis/signatures.py +2030 -0
- mapFolding/reference/meandersDumpingGround/A005316JavaPort.py +1 -1
- mapFolding/reference/meandersDumpingGround/A005316imperative.py +1 -1
- mapFolding/reference/meandersDumpingGround/matrixMeandersNumPyV1finalForm.py +424 -0
- mapFolding/someAssemblyRequired/A007822/A007822rawMaterials.py +3 -4
- mapFolding/someAssemblyRequired/A007822/makeA007822AsynchronousModules.py +103 -29
- mapFolding/someAssemblyRequired/A007822/makeA007822Modules.py +18 -14
- mapFolding/someAssemblyRequired/RecipeJob.py +2 -2
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +7 -6
- mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +3 -4
- mapFolding/someAssemblyRequired/makingModules_count.py +88 -87
- mapFolding/someAssemblyRequired/makingModules_doTheNeedful.py +10 -9
- mapFolding/someAssemblyRequired/mapFolding/makeMapFoldingModules.py +3 -3
- mapFolding/someAssemblyRequired/meanders/__init__.py +0 -0
- mapFolding/someAssemblyRequired/meanders/makeMeandersModules.py +63 -0
- mapFolding/someAssemblyRequired/toolkitMakeModules.py +37 -37
- mapFolding/someAssemblyRequired/transformationTools.py +8 -8
- mapFolding/syntheticModules/A007822/algorithm.py +3 -3
- mapFolding/syntheticModules/A007822/algorithmNumba.py +1 -2
- mapFolding/syntheticModules/A007822/asynchronous.py +6 -4
- mapFolding/syntheticModules/A007822/asynchronousAnnex.py +5 -7
- mapFolding/syntheticModules/A007822/asynchronousAnnexNumba.py +70 -0
- mapFolding/syntheticModules/A007822/asynchronousNumba.py +79 -0
- mapFolding/syntheticModules/A007822/asynchronousTheorem2.py +15 -3
- mapFolding/syntheticModules/A007822/asynchronousTrimmed.py +12 -3
- mapFolding/syntheticModules/A007822/initializeState.py +1 -2
- mapFolding/syntheticModules/A007822/theorem2.py +7 -2
- mapFolding/syntheticModules/A007822/theorem2Numba.py +31 -4
- mapFolding/syntheticModules/A007822/theorem2Trimmed.py +8 -3
- mapFolding/syntheticModules/countParallelNumba.py +5 -2
- mapFolding/syntheticModules/dataPacking.py +1 -1
- mapFolding/syntheticModules/dataPackingA007822.py +92 -26
- mapFolding/syntheticModules/meanders/__init__.py +1 -0
- mapFolding/syntheticModules/meanders/bigInt.py +52 -0
- mapFolding/syntheticModules/theorem2.py +6 -0
- mapFolding/syntheticModules/theorem2Numba.py +8 -2
- mapFolding/syntheticModules/theorem2Trimmed.py +6 -0
- mapFolding/tests/conftest.py +28 -13
- mapFolding/tests/test_computations.py +68 -61
- mapFolding/tests/test_oeis.py +6 -6
- mapFolding/zCuzDocStoopid/__init__.py +4 -1
- mapFolding/zCuzDocStoopid/makeDocstrings.py +35 -28
- mapfolding-0.16.2.dist-info/METADATA +99 -0
- mapfolding-0.16.2.dist-info/RECORD +115 -0
- {mapfolding-0.16.0.dist-info → mapfolding-0.16.2.dist-info}/top_level.txt +1 -0
- mapFolding/algorithms/getBucketsTotal.py +0 -137
- mapFolding/reference/matrixMeandersAnalysis/evenEven.py +0 -144
- mapFolding/reference/matrixMeandersAnalysis/oddEven.py +0 -54
- mapFolding/trim_memory.py +0 -62
- mapfolding-0.16.0.dist-info/METADATA +0 -85
- mapfolding-0.16.0.dist-info/RECORD +0 -100
- {mapfolding-0.16.0.dist-info → mapfolding-0.16.2.dist-info}/WHEEL +0 -0
- {mapfolding-0.16.0.dist-info → mapfolding-0.16.2.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.16.0.dist-info → mapfolding-0.16.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from mapFolding.dataBaskets import MapFoldingState
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
def filterAsymmetricFolds(state: MapFoldingState) -> MapFoldingState:
|
|
4
5
|
state.indexLeaf = 0
|
|
5
6
|
leafConnectee = 0
|
|
@@ -18,8 +19,7 @@ def filterAsymmetricFolds(state: MapFoldingState) -> MapFoldingState:
|
|
|
18
19
|
ImaSymmetricFold = False
|
|
19
20
|
break
|
|
20
21
|
leafConnectee += 1
|
|
21
|
-
|
|
22
|
-
state.groupsOfFolds += 1
|
|
22
|
+
state.groupsOfFolds += ImaSymmetricFold
|
|
23
23
|
state.indexMiniGap += 1
|
|
24
24
|
return state
|
|
25
25
|
|
|
@@ -163,4 +163,4 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
163
163
|
|
|
164
164
|
def doTheNeedful(state: MapFoldingState) -> MapFoldingState:
|
|
165
165
|
state = count(state)
|
|
166
|
-
return state
|
|
166
|
+
return state
|
|
@@ -23,8 +23,7 @@ def count(groupsOfFolds: DatatypeFoldsTotal, gap1ndex: DatatypeElephino, gap1nde
|
|
|
23
23
|
ImaSymmetricFold = False
|
|
24
24
|
break
|
|
25
25
|
leafConnectee += 1
|
|
26
|
-
|
|
27
|
-
groupsOfFolds += 1
|
|
26
|
+
groupsOfFolds += ImaSymmetricFold
|
|
28
27
|
indexMiniGap += 1
|
|
29
28
|
else:
|
|
30
29
|
dimensionsUnconstrained = dimensionsTotal
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from mapFolding.dataBaskets import MapFoldingState
|
|
2
2
|
from mapFolding.syntheticModules.A007822.asynchronousAnnex import (
|
|
3
|
-
|
|
3
|
+
filterAsymmetricFolds, getSymmetricFoldsTotal,
|
|
4
|
+
initializeConcurrencyManager)
|
|
5
|
+
|
|
4
6
|
|
|
5
7
|
def activeLeafGreaterThan0(state: MapFoldingState) -> bool:
|
|
6
8
|
return state.leaf1ndex > 0
|
|
@@ -138,11 +140,11 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
138
140
|
if gapAvailable(state):
|
|
139
141
|
state = insertActiveLeafAtGap(state)
|
|
140
142
|
else:
|
|
141
|
-
state.groupsOfFolds =
|
|
143
|
+
state.groupsOfFolds = getSymmetricFoldsTotal()
|
|
142
144
|
state.groupsOfFolds = (state.groupsOfFolds + 1) // 2
|
|
143
145
|
return state
|
|
144
146
|
|
|
145
|
-
def doTheNeedful(state: MapFoldingState) -> MapFoldingState:
|
|
146
|
-
initializeConcurrencyManager()
|
|
147
|
+
def doTheNeedful(state: MapFoldingState, maxWorkers: int | None=None) -> MapFoldingState:
|
|
148
|
+
initializeConcurrencyManager(maxWorkers)
|
|
147
149
|
state = count(state)
|
|
148
150
|
return state
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
from concurrent.futures import Future as ConcurrentFuture,
|
|
1
|
+
from concurrent.futures import Future as ConcurrentFuture, ThreadPoolExecutor
|
|
2
2
|
from hunterMakesPy import raiseIfNone
|
|
3
3
|
from mapFolding import Array1DLeavesTotal
|
|
4
4
|
from queue import Empty, Queue
|
|
5
5
|
from threading import Thread
|
|
6
6
|
import numpy
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
concurrencyManager = None
|
|
10
9
|
groupsOfFoldsTotal: int = 0
|
|
11
10
|
processingThread = None
|
|
@@ -13,7 +12,7 @@ queueFutures: Queue[ConcurrentFuture[int]] = Queue()
|
|
|
13
12
|
|
|
14
13
|
def initializeConcurrencyManager(maxWorkers: int | None=None, groupsOfFolds: int=0) -> None:
|
|
15
14
|
global concurrencyManager, queueFutures, groupsOfFoldsTotal, processingThread
|
|
16
|
-
concurrencyManager =
|
|
15
|
+
concurrencyManager = ThreadPoolExecutor(max_workers=maxWorkers)
|
|
17
16
|
queueFutures = Queue()
|
|
18
17
|
groupsOfFoldsTotal = groupsOfFolds
|
|
19
18
|
processingThread = Thread(target=_processCompletedFutures)
|
|
@@ -51,16 +50,15 @@ def _filterAsymmetricFolds(leafBelow: Array1DLeavesTotal) -> int:
|
|
|
51
50
|
ImaSymmetricFold = False
|
|
52
51
|
break
|
|
53
52
|
leafConnectee += 1
|
|
54
|
-
|
|
55
|
-
groupsOfFolds += 1
|
|
53
|
+
groupsOfFolds += ImaSymmetricFold
|
|
56
54
|
indexDistance += 1
|
|
57
55
|
return groupsOfFolds
|
|
58
56
|
|
|
59
57
|
def filterAsymmetricFolds(leafBelow: Array1DLeavesTotal) -> None:
|
|
60
58
|
global concurrencyManager, queueFutures
|
|
61
|
-
queueFutures.
|
|
59
|
+
queueFutures.put_nowait(raiseIfNone(concurrencyManager).submit(_filterAsymmetricFolds, leafBelow.copy()))
|
|
62
60
|
|
|
63
|
-
def
|
|
61
|
+
def getSymmetricFoldsTotal() -> int:
|
|
64
62
|
global concurrencyManager, queueFutures, processingThread
|
|
65
63
|
raiseIfNone(concurrencyManager).shutdown(wait=True)
|
|
66
64
|
queueFutures.put(None)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from mapFolding import Array1DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal
|
|
2
|
+
from queue import Queue
|
|
3
|
+
from threading import Lock, Thread
|
|
4
|
+
import numba
|
|
5
|
+
import numpy
|
|
6
|
+
|
|
7
|
+
listThreads: list[Thread] = []
|
|
8
|
+
queueFutures: Queue[Array1DLeavesTotal] = Queue()
|
|
9
|
+
groupsOfFoldsTotal: int = 0
|
|
10
|
+
groupsOfFoldsTotalLock = Lock()
|
|
11
|
+
sentinelStop = object()
|
|
12
|
+
|
|
13
|
+
def initializeConcurrencyManager(maxWorkers: int, groupsOfFolds: int=0) -> None:
|
|
14
|
+
global listThreads, groupsOfFoldsTotal, queueFutures # noqa: PLW0603
|
|
15
|
+
listThreads = []
|
|
16
|
+
queueFutures = Queue()
|
|
17
|
+
groupsOfFoldsTotal = groupsOfFolds
|
|
18
|
+
indexThread = 0
|
|
19
|
+
while indexThread < maxWorkers:
|
|
20
|
+
thread = Thread(target=_threadDoesSomething, name=f"thread{indexThread}", daemon=True)
|
|
21
|
+
thread.start()
|
|
22
|
+
listThreads.append(thread)
|
|
23
|
+
indexThread += 1
|
|
24
|
+
|
|
25
|
+
def _threadDoesSomething() -> None:
|
|
26
|
+
global groupsOfFoldsTotal # noqa: PLW0603
|
|
27
|
+
while True:
|
|
28
|
+
leafBelow = queueFutures.get()
|
|
29
|
+
if leafBelow is sentinelStop: # pyright: ignore[reportUnnecessaryComparison]
|
|
30
|
+
break
|
|
31
|
+
symmetricFolds = _filterAsymmetricFolds(leafBelow)
|
|
32
|
+
with groupsOfFoldsTotalLock:
|
|
33
|
+
groupsOfFoldsTotal += symmetricFolds
|
|
34
|
+
|
|
35
|
+
@numba.jit(cache=True, error_model='numpy', fastmath=True)
|
|
36
|
+
def _filterAsymmetricFolds(leafBelow: Array1DLeavesTotal) -> int:
|
|
37
|
+
groupsOfFolds = 0
|
|
38
|
+
leafComparison: Array1DLeavesTotal = numpy.zeros_like(leafBelow)
|
|
39
|
+
leavesTotal = leafBelow.size - 1
|
|
40
|
+
indexLeaf = 0
|
|
41
|
+
leafConnectee = 0
|
|
42
|
+
while leafConnectee < leavesTotal + 1:
|
|
43
|
+
leafNumber = int(leafBelow[indexLeaf])
|
|
44
|
+
leafComparison[leafConnectee] = (leafNumber - indexLeaf + leavesTotal) % leavesTotal
|
|
45
|
+
indexLeaf = leafNumber
|
|
46
|
+
leafConnectee += 1
|
|
47
|
+
indexInMiddle = leavesTotal // 2
|
|
48
|
+
indexDistance = 0
|
|
49
|
+
while indexDistance < leavesTotal + 1:
|
|
50
|
+
ImaSymmetricFold = True
|
|
51
|
+
leafConnectee = 0
|
|
52
|
+
while leafConnectee < indexInMiddle:
|
|
53
|
+
if leafComparison[(indexDistance + leafConnectee) % (leavesTotal + 1)] != leafComparison[(indexDistance + leavesTotal - 1 - leafConnectee) % (leavesTotal + 1)]:
|
|
54
|
+
ImaSymmetricFold = False
|
|
55
|
+
break
|
|
56
|
+
leafConnectee += 1
|
|
57
|
+
groupsOfFolds += ImaSymmetricFold
|
|
58
|
+
indexDistance += 1
|
|
59
|
+
return groupsOfFolds
|
|
60
|
+
|
|
61
|
+
def filterAsymmetricFolds(leafBelow: Array1DLeavesTotal) -> None:
|
|
62
|
+
queueFutures.put_nowait(leafBelow.copy())
|
|
63
|
+
|
|
64
|
+
def getSymmetricFoldsTotal() -> DatatypeFoldsTotal:
|
|
65
|
+
global listThreads # noqa: PLW0602
|
|
66
|
+
for _thread in listThreads:
|
|
67
|
+
queueFutures.put(sentinelStop) # pyright: ignore[reportArgumentType]
|
|
68
|
+
for thread in listThreads:
|
|
69
|
+
thread.join()
|
|
70
|
+
return groupsOfFoldsTotal
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from mapFolding.dataBaskets import (
|
|
2
|
+
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal,
|
|
3
|
+
MapFoldingState)
|
|
4
|
+
from mapFolding.syntheticModules.A007822.asynchronousAnnex import (
|
|
5
|
+
filterAsymmetricFolds, getSymmetricFoldsTotal, initializeConcurrencyManager)
|
|
6
|
+
from mapFolding.syntheticModules.A007822.initializeState import transitionOnGroupsOfFolds
|
|
7
|
+
from numba import jit
|
|
8
|
+
|
|
9
|
+
@jit(cache=True, error_model='numpy', fastmath=True, forceinline=True)
|
|
10
|
+
def count(groupsOfFolds: DatatypeFoldsTotal, gap1ndex: DatatypeElephino, gap1ndexCeiling: DatatypeElephino, indexDimension: DatatypeLeavesTotal, indexMiniGap: DatatypeElephino, leaf1ndex: DatatypeLeavesTotal, leafConnectee: DatatypeLeavesTotal, dimensionsUnconstrained: DatatypeLeavesTotal, countDimensionsGapped: Array1DLeavesTotal, gapRangeStart: Array1DElephino, gapsWhere: Array1DLeavesTotal, leafAbove: Array1DLeavesTotal, leafBelow: Array1DLeavesTotal, connectionGraph: Array3DLeavesTotal, dimensionsTotal: DatatypeLeavesTotal, leavesTotal: DatatypeLeavesTotal) -> tuple[DatatypeFoldsTotal, DatatypeElephino, DatatypeElephino, DatatypeLeavesTotal, DatatypeElephino, DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal, Array1DLeavesTotal, Array1DElephino, Array1DLeavesTotal, Array1DLeavesTotal, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal]:
|
|
11
|
+
while leaf1ndex > 4:
|
|
12
|
+
if leafBelow[0] == 1:
|
|
13
|
+
if leaf1ndex > leavesTotal:
|
|
14
|
+
filterAsymmetricFolds(leafBelow)
|
|
15
|
+
else:
|
|
16
|
+
dimensionsUnconstrained = dimensionsTotal
|
|
17
|
+
gap1ndexCeiling = gapRangeStart[leaf1ndex - 1]
|
|
18
|
+
indexDimension = 0
|
|
19
|
+
while indexDimension < dimensionsTotal:
|
|
20
|
+
leafConnectee = connectionGraph[indexDimension, leaf1ndex, leaf1ndex]
|
|
21
|
+
if leafConnectee == leaf1ndex:
|
|
22
|
+
dimensionsUnconstrained -= 1
|
|
23
|
+
else:
|
|
24
|
+
while leafConnectee != leaf1ndex:
|
|
25
|
+
gapsWhere[gap1ndexCeiling] = leafConnectee
|
|
26
|
+
if countDimensionsGapped[leafConnectee] == 0:
|
|
27
|
+
gap1ndexCeiling += 1
|
|
28
|
+
countDimensionsGapped[leafConnectee] += 1
|
|
29
|
+
leafConnectee = connectionGraph[indexDimension, leaf1ndex, leafBelow[leafConnectee]]
|
|
30
|
+
indexDimension += 1
|
|
31
|
+
indexMiniGap = gap1ndex
|
|
32
|
+
while indexMiniGap < gap1ndexCeiling:
|
|
33
|
+
gapsWhere[gap1ndex] = gapsWhere[indexMiniGap]
|
|
34
|
+
if countDimensionsGapped[gapsWhere[indexMiniGap]] == dimensionsUnconstrained:
|
|
35
|
+
gap1ndex += 1
|
|
36
|
+
countDimensionsGapped[gapsWhere[indexMiniGap]] = 0
|
|
37
|
+
indexMiniGap += 1
|
|
38
|
+
while gap1ndex == gapRangeStart[leaf1ndex - 1]:
|
|
39
|
+
leaf1ndex -= 1
|
|
40
|
+
leafBelow[leafAbove[leaf1ndex]] = leafBelow[leaf1ndex]
|
|
41
|
+
leafAbove[leafBelow[leaf1ndex]] = leafAbove[leaf1ndex]
|
|
42
|
+
gap1ndex -= 1
|
|
43
|
+
leafAbove[leaf1ndex] = gapsWhere[gap1ndex]
|
|
44
|
+
leafBelow[leaf1ndex] = leafBelow[leafAbove[leaf1ndex]]
|
|
45
|
+
leafBelow[leafAbove[leaf1ndex]] = leaf1ndex
|
|
46
|
+
leafAbove[leafBelow[leaf1ndex]] = leaf1ndex
|
|
47
|
+
gapRangeStart[leaf1ndex] = gap1ndex
|
|
48
|
+
leaf1ndex += 1
|
|
49
|
+
return (groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal)
|
|
50
|
+
|
|
51
|
+
def doTheNeedful(state: MapFoldingState, maxWorkers: int | None=None) -> MapFoldingState:
|
|
52
|
+
state = transitionOnGroupsOfFolds(state)
|
|
53
|
+
initializeConcurrencyManager(maxWorkers, state.groupsOfFolds)
|
|
54
|
+
state.groupsOfFolds = 0
|
|
55
|
+
mapShape: tuple[DatatypeLeavesTotal, ...] = state.mapShape
|
|
56
|
+
groupsOfFolds: DatatypeFoldsTotal = state.groupsOfFolds
|
|
57
|
+
gap1ndex: DatatypeElephino = state.gap1ndex
|
|
58
|
+
gap1ndexCeiling: DatatypeElephino = state.gap1ndexCeiling
|
|
59
|
+
indexDimension: DatatypeLeavesTotal = state.indexDimension
|
|
60
|
+
indexLeaf: DatatypeLeavesTotal = state.indexLeaf
|
|
61
|
+
indexMiniGap: DatatypeElephino = state.indexMiniGap
|
|
62
|
+
leaf1ndex: DatatypeLeavesTotal = state.leaf1ndex
|
|
63
|
+
leafConnectee: DatatypeLeavesTotal = state.leafConnectee
|
|
64
|
+
dimensionsUnconstrained: DatatypeLeavesTotal = state.dimensionsUnconstrained
|
|
65
|
+
countDimensionsGapped: Array1DLeavesTotal = state.countDimensionsGapped
|
|
66
|
+
gapRangeStart: Array1DElephino = state.gapRangeStart
|
|
67
|
+
gapsWhere: Array1DLeavesTotal = state.gapsWhere
|
|
68
|
+
leafAbove: Array1DLeavesTotal = state.leafAbove
|
|
69
|
+
leafBelow: Array1DLeavesTotal = state.leafBelow
|
|
70
|
+
leafComparison: Array1DLeavesTotal = state.leafComparison
|
|
71
|
+
connectionGraph: Array3DLeavesTotal = state.connectionGraph
|
|
72
|
+
dimensionsTotal: DatatypeLeavesTotal = state.dimensionsTotal
|
|
73
|
+
leavesTotal: DatatypeLeavesTotal = state.leavesTotal
|
|
74
|
+
groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal = count(groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal)
|
|
75
|
+
groupsOfFolds = getSymmetricFoldsTotal()
|
|
76
|
+
groupsOfFolds *= 2
|
|
77
|
+
groupsOfFolds = (groupsOfFolds + 1) // 2
|
|
78
|
+
state = MapFoldingState(mapShape=mapShape, groupsOfFolds=groupsOfFolds, gap1ndex=gap1ndex, gap1ndexCeiling=gap1ndexCeiling, indexDimension=indexDimension, indexLeaf=indexLeaf, indexMiniGap=indexMiniGap, leaf1ndex=leaf1ndex, leafConnectee=leafConnectee, dimensionsUnconstrained=dimensionsUnconstrained, countDimensionsGapped=countDimensionsGapped, gapRangeStart=gapRangeStart, gapsWhere=gapsWhere, leafAbove=leafAbove, leafBelow=leafBelow, leafComparison=leafComparison)
|
|
79
|
+
return state
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
from mapFolding.dataBaskets import MapFoldingState
|
|
2
|
-
from mapFolding.syntheticModules.A007822.
|
|
2
|
+
from mapFolding.syntheticModules.A007822.asynchronousAnnexNumba import (
|
|
3
|
+
filterAsymmetricFolds, getSymmetricFoldsTotal,
|
|
4
|
+
initializeConcurrencyManager)
|
|
5
|
+
from mapFolding.syntheticModules.A007822.initializeState import \
|
|
6
|
+
transitionOnGroupsOfFolds
|
|
7
|
+
|
|
3
8
|
|
|
4
9
|
def count(state: MapFoldingState) -> MapFoldingState:
|
|
5
10
|
while state.leaf1ndex > 4:
|
|
@@ -47,7 +52,14 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
47
52
|
state.gapRangeStart[state.leaf1ndex] = state.gap1ndex
|
|
48
53
|
state.leaf1ndex += 1
|
|
49
54
|
else:
|
|
50
|
-
state.groupsOfFolds =
|
|
55
|
+
state.groupsOfFolds = getSymmetricFoldsTotal()
|
|
51
56
|
state.groupsOfFolds *= 2
|
|
52
57
|
state.groupsOfFolds = (state.groupsOfFolds + 1) // 2
|
|
53
|
-
return state
|
|
58
|
+
return state
|
|
59
|
+
|
|
60
|
+
def doTheNeedful(state: MapFoldingState, maxWorkers: int | None=None) -> MapFoldingState:
|
|
61
|
+
state = transitionOnGroupsOfFolds(state)
|
|
62
|
+
initializeConcurrencyManager(maxWorkers, state.groupsOfFolds)
|
|
63
|
+
state.groupsOfFolds = 0
|
|
64
|
+
state = count(state)
|
|
65
|
+
return state
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from mapFolding.dataBaskets import MapFoldingState
|
|
2
|
-
from mapFolding.syntheticModules.A007822.
|
|
2
|
+
from mapFolding.syntheticModules.A007822.asynchronousAnnexNumba import (
|
|
3
|
+
filterAsymmetricFolds, getSymmetricFoldsTotal, initializeConcurrencyManager)
|
|
4
|
+
from mapFolding.syntheticModules.A007822.initializeState import transitionOnGroupsOfFolds
|
|
3
5
|
|
|
4
6
|
def count(state: MapFoldingState) -> MapFoldingState:
|
|
5
7
|
while state.leaf1ndex > 4:
|
|
@@ -41,7 +43,14 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
41
43
|
state.gapRangeStart[state.leaf1ndex] = state.gap1ndex
|
|
42
44
|
state.leaf1ndex += 1
|
|
43
45
|
else:
|
|
44
|
-
state.groupsOfFolds =
|
|
46
|
+
state.groupsOfFolds = getSymmetricFoldsTotal()
|
|
45
47
|
state.groupsOfFolds *= 2
|
|
46
48
|
state.groupsOfFolds = (state.groupsOfFolds + 1) // 2
|
|
47
|
-
return state
|
|
49
|
+
return state
|
|
50
|
+
|
|
51
|
+
def doTheNeedful(state: MapFoldingState, maxWorkers: int | None=None) -> MapFoldingState:
|
|
52
|
+
state = transitionOnGroupsOfFolds(state)
|
|
53
|
+
initializeConcurrencyManager(maxWorkers, state.groupsOfFolds)
|
|
54
|
+
state.groupsOfFolds = 0
|
|
55
|
+
state = count(state)
|
|
56
|
+
return state
|
|
@@ -21,8 +21,7 @@ def transitionOnGroupsOfFolds(state: MapFoldingState) -> MapFoldingState:
|
|
|
21
21
|
ImaSymmetricFold = False
|
|
22
22
|
break
|
|
23
23
|
leafConnectee += 1
|
|
24
|
-
|
|
25
|
-
state.groupsOfFolds += 1
|
|
24
|
+
state.groupsOfFolds += ImaSymmetricFold
|
|
26
25
|
state.indexMiniGap += 1
|
|
27
26
|
else:
|
|
28
27
|
state.dimensionsUnconstrained = state.dimensionsTotal
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from mapFolding.dataBaskets import MapFoldingState
|
|
2
|
+
from mapFolding.syntheticModules.A007822.initializeState import transitionOnGroupsOfFolds
|
|
2
3
|
|
|
3
4
|
def count(state: MapFoldingState) -> MapFoldingState:
|
|
4
5
|
while state.leaf1ndex > 4:
|
|
@@ -21,8 +22,7 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
21
22
|
ImaSymmetricFold = False
|
|
22
23
|
break
|
|
23
24
|
leafConnectee += 1
|
|
24
|
-
|
|
25
|
-
state.groupsOfFolds += 1
|
|
25
|
+
state.groupsOfFolds += ImaSymmetricFold
|
|
26
26
|
state.indexMiniGap += 1
|
|
27
27
|
else:
|
|
28
28
|
state.dimensionsUnconstrained = state.dimensionsTotal
|
|
@@ -67,4 +67,9 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
67
67
|
else:
|
|
68
68
|
state.groupsOfFolds *= 2
|
|
69
69
|
state.groupsOfFolds = (state.groupsOfFolds + 1) // 2
|
|
70
|
+
return state
|
|
71
|
+
|
|
72
|
+
def doTheNeedful(state: MapFoldingState) -> MapFoldingState:
|
|
73
|
+
state = transitionOnGroupsOfFolds(state)
|
|
74
|
+
state = count(state)
|
|
70
75
|
return state
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
from mapFolding.dataBaskets import
|
|
1
|
+
from mapFolding.dataBaskets import (
|
|
2
|
+
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal,
|
|
3
|
+
MapFoldingState)
|
|
4
|
+
from mapFolding.syntheticModules.A007822.initializeState import transitionOnGroupsOfFolds
|
|
2
5
|
from numba import jit
|
|
3
6
|
|
|
4
7
|
@jit(cache=True, error_model='numpy', fastmath=True, forceinline=True)
|
|
@@ -23,8 +26,7 @@ def count(groupsOfFolds: DatatypeFoldsTotal, gap1ndex: DatatypeElephino, gap1nde
|
|
|
23
26
|
ImaSymmetricFold = False
|
|
24
27
|
break
|
|
25
28
|
leafConnectee += 1
|
|
26
|
-
|
|
27
|
-
groupsOfFolds += 1
|
|
29
|
+
groupsOfFolds += ImaSymmetricFold
|
|
28
30
|
indexMiniGap += 1
|
|
29
31
|
else:
|
|
30
32
|
dimensionsUnconstrained = dimensionsTotal
|
|
@@ -63,4 +65,29 @@ def count(groupsOfFolds: DatatypeFoldsTotal, gap1ndex: DatatypeElephino, gap1nde
|
|
|
63
65
|
else:
|
|
64
66
|
groupsOfFolds *= 2
|
|
65
67
|
groupsOfFolds = (groupsOfFolds + 1) // 2
|
|
66
|
-
return (groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, leafComparison, connectionGraph, dimensionsTotal, leavesTotal)
|
|
68
|
+
return (groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, leafComparison, connectionGraph, dimensionsTotal, leavesTotal)
|
|
69
|
+
|
|
70
|
+
def doTheNeedful(state: MapFoldingState) -> MapFoldingState:
|
|
71
|
+
state = transitionOnGroupsOfFolds(state)
|
|
72
|
+
mapShape: tuple[DatatypeLeavesTotal, ...] = state.mapShape
|
|
73
|
+
groupsOfFolds: DatatypeFoldsTotal = state.groupsOfFolds
|
|
74
|
+
gap1ndex: DatatypeElephino = state.gap1ndex
|
|
75
|
+
gap1ndexCeiling: DatatypeElephino = state.gap1ndexCeiling
|
|
76
|
+
indexDimension: DatatypeLeavesTotal = state.indexDimension
|
|
77
|
+
indexLeaf: DatatypeLeavesTotal = state.indexLeaf
|
|
78
|
+
indexMiniGap: DatatypeElephino = state.indexMiniGap
|
|
79
|
+
leaf1ndex: DatatypeLeavesTotal = state.leaf1ndex
|
|
80
|
+
leafConnectee: DatatypeLeavesTotal = state.leafConnectee
|
|
81
|
+
dimensionsUnconstrained: DatatypeLeavesTotal = state.dimensionsUnconstrained
|
|
82
|
+
countDimensionsGapped: Array1DLeavesTotal = state.countDimensionsGapped
|
|
83
|
+
gapRangeStart: Array1DElephino = state.gapRangeStart
|
|
84
|
+
gapsWhere: Array1DLeavesTotal = state.gapsWhere
|
|
85
|
+
leafAbove: Array1DLeavesTotal = state.leafAbove
|
|
86
|
+
leafBelow: Array1DLeavesTotal = state.leafBelow
|
|
87
|
+
leafComparison: Array1DLeavesTotal = state.leafComparison
|
|
88
|
+
connectionGraph: Array3DLeavesTotal = state.connectionGraph
|
|
89
|
+
dimensionsTotal: DatatypeLeavesTotal = state.dimensionsTotal
|
|
90
|
+
leavesTotal: DatatypeLeavesTotal = state.leavesTotal
|
|
91
|
+
groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, leafComparison, connectionGraph, dimensionsTotal, leavesTotal = count(groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, leafComparison, connectionGraph, dimensionsTotal, leavesTotal)
|
|
92
|
+
state = MapFoldingState(mapShape=mapShape, groupsOfFolds=groupsOfFolds, gap1ndex=gap1ndex, gap1ndexCeiling=gap1ndexCeiling, indexDimension=indexDimension, indexLeaf=indexLeaf, indexMiniGap=indexMiniGap, leaf1ndex=leaf1ndex, leafConnectee=leafConnectee, dimensionsUnconstrained=dimensionsUnconstrained, countDimensionsGapped=countDimensionsGapped, gapRangeStart=gapRangeStart, gapsWhere=gapsWhere, leafAbove=leafAbove, leafBelow=leafBelow, leafComparison=leafComparison)
|
|
93
|
+
return state
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from mapFolding.dataBaskets import MapFoldingState
|
|
2
|
+
from mapFolding.syntheticModules.A007822.initializeState import transitionOnGroupsOfFolds
|
|
2
3
|
|
|
3
4
|
def count(state: MapFoldingState) -> MapFoldingState:
|
|
4
5
|
while state.leaf1ndex > 4:
|
|
@@ -21,8 +22,7 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
21
22
|
ImaSymmetricFold = False
|
|
22
23
|
break
|
|
23
24
|
leafConnectee += 1
|
|
24
|
-
|
|
25
|
-
state.groupsOfFolds += 1
|
|
25
|
+
state.groupsOfFolds += ImaSymmetricFold
|
|
26
26
|
state.indexMiniGap += 1
|
|
27
27
|
else:
|
|
28
28
|
state.dimensionsUnconstrained = state.dimensionsTotal
|
|
@@ -61,4 +61,9 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
61
61
|
else:
|
|
62
62
|
state.groupsOfFolds *= 2
|
|
63
63
|
state.groupsOfFolds = (state.groupsOfFolds + 1) // 2
|
|
64
|
-
return state
|
|
64
|
+
return state
|
|
65
|
+
|
|
66
|
+
def doTheNeedful(state: MapFoldingState) -> MapFoldingState:
|
|
67
|
+
state = transitionOnGroupsOfFolds(state)
|
|
68
|
+
state = count(state)
|
|
69
|
+
return state
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
from concurrent.futures import Future as ConcurrentFuture, ProcessPoolExecutor
|
|
2
2
|
from copy import deepcopy
|
|
3
|
-
from mapFolding.dataBaskets import
|
|
3
|
+
from mapFolding.dataBaskets import (
|
|
4
|
+
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal,
|
|
5
|
+
ParallelMapFoldingState)
|
|
4
6
|
from multiprocessing import set_start_method as multiprocessing_set_start_method
|
|
5
7
|
from numba import jit
|
|
8
|
+
|
|
6
9
|
if __name__ == '__main__':
|
|
7
10
|
multiprocessing_set_start_method('spawn')
|
|
8
11
|
|
|
@@ -96,4 +99,4 @@ def doTheNeedful(state: ParallelMapFoldingState, concurrencyLimit: int) -> tuple
|
|
|
96
99
|
listStatesParallel[indexSherpa] = dictionaryConcurrency[indexSherpa].result()
|
|
97
100
|
groupsOfFoldsTotal += listStatesParallel[indexSherpa].groupsOfFolds
|
|
98
101
|
foldsTotal: int = groupsOfFoldsTotal * stateParallel.leavesTotal
|
|
99
|
-
return (foldsTotal, listStatesParallel)
|
|
102
|
+
return (foldsTotal, listStatesParallel)
|
|
@@ -21,6 +21,6 @@ def sequential(state: MapFoldingState) -> MapFoldingState:
|
|
|
21
21
|
connectionGraph: Array3DLeavesTotal = state.connectionGraph
|
|
22
22
|
dimensionsTotal: DatatypeLeavesTotal = state.dimensionsTotal
|
|
23
23
|
leavesTotal: DatatypeLeavesTotal = state.leavesTotal
|
|
24
|
-
groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal = count(groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal)
|
|
24
|
+
groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal = count(groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal)
|
|
25
25
|
state = MapFoldingState(mapShape=mapShape, groupsOfFolds=groupsOfFolds, gap1ndex=gap1ndex, gap1ndexCeiling=gap1ndexCeiling, indexDimension=indexDimension, indexLeaf=indexLeaf, indexMiniGap=indexMiniGap, leaf1ndex=leaf1ndex, leafConnectee=leafConnectee, dimensionsUnconstrained=dimensionsUnconstrained, countDimensionsGapped=countDimensionsGapped, gapRangeStart=gapRangeStart, gapsWhere=gapsWhere, leafAbove=leafAbove, leafBelow=leafBelow, leafComparison=leafComparison)
|
|
26
26
|
return state
|
|
@@ -1,26 +1,92 @@
|
|
|
1
|
-
from
|
|
2
|
-
from mapFolding.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
from mapFolding.dataBaskets import (
|
|
3
|
+
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal,
|
|
4
|
+
MapFoldingState)
|
|
5
|
+
|
|
6
|
+
def unRePackDataclassA007822(callableTarget: Callable[[
|
|
7
|
+
DatatypeFoldsTotal, DatatypeElephino, DatatypeElephino, DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeElephino,
|
|
8
|
+
DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal, Array1DLeavesTotal, Array1DElephino, Array1DLeavesTotal,
|
|
9
|
+
Array1DLeavesTotal, Array1DLeavesTotal, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal
|
|
10
|
+
], tuple[
|
|
11
|
+
DatatypeFoldsTotal, DatatypeElephino, DatatypeElephino, DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeElephino,
|
|
12
|
+
DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal, Array1DLeavesTotal, Array1DElephino, Array1DLeavesTotal,
|
|
13
|
+
Array1DLeavesTotal, Array1DLeavesTotal, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal
|
|
14
|
+
]]) -> Callable[[MapFoldingState], MapFoldingState]:
|
|
15
|
+
def workhorse(state: MapFoldingState) -> MapFoldingState:
|
|
16
|
+
mapShape: tuple[DatatypeLeavesTotal, ...] = state.mapShape
|
|
17
|
+
groupsOfFolds: DatatypeFoldsTotal = state.groupsOfFolds
|
|
18
|
+
gap1ndex: DatatypeElephino = state.gap1ndex
|
|
19
|
+
gap1ndexCeiling: DatatypeElephino = state.gap1ndexCeiling
|
|
20
|
+
indexDimension: DatatypeLeavesTotal = state.indexDimension
|
|
21
|
+
indexLeaf: DatatypeLeavesTotal = state.indexLeaf
|
|
22
|
+
indexMiniGap: DatatypeElephino = state.indexMiniGap
|
|
23
|
+
leaf1ndex: DatatypeLeavesTotal = state.leaf1ndex
|
|
24
|
+
leafConnectee: DatatypeLeavesTotal = state.leafConnectee
|
|
25
|
+
dimensionsUnconstrained: DatatypeLeavesTotal = state.dimensionsUnconstrained
|
|
26
|
+
countDimensionsGapped: Array1DLeavesTotal = state.countDimensionsGapped
|
|
27
|
+
gapRangeStart: Array1DElephino = state.gapRangeStart
|
|
28
|
+
gapsWhere: Array1DLeavesTotal = state.gapsWhere
|
|
29
|
+
leafAbove: Array1DLeavesTotal = state.leafAbove
|
|
30
|
+
leafBelow: Array1DLeavesTotal = state.leafBelow
|
|
31
|
+
leafComparison: Array1DLeavesTotal = state.leafComparison
|
|
32
|
+
connectionGraph: Array3DLeavesTotal = state.connectionGraph
|
|
33
|
+
dimensionsTotal: DatatypeLeavesTotal = state.dimensionsTotal
|
|
34
|
+
leavesTotal: DatatypeLeavesTotal = state.leavesTotal
|
|
35
|
+
|
|
36
|
+
(groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained,
|
|
37
|
+
countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, leafComparison, connectionGraph, dimensionsTotal, leavesTotal
|
|
38
|
+
) = callableTarget(
|
|
39
|
+
groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained,
|
|
40
|
+
countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, leafComparison, connectionGraph, dimensionsTotal, leavesTotal)
|
|
41
|
+
|
|
42
|
+
state = MapFoldingState(mapShape=mapShape, groupsOfFolds=groupsOfFolds, gap1ndex=gap1ndex, gap1ndexCeiling=gap1ndexCeiling,
|
|
43
|
+
indexDimension=indexDimension, indexLeaf=indexLeaf, indexMiniGap=indexMiniGap, leaf1ndex=leaf1ndex, leafConnectee=leafConnectee,
|
|
44
|
+
dimensionsUnconstrained=dimensionsUnconstrained, countDimensionsGapped=countDimensionsGapped, gapRangeStart=gapRangeStart,
|
|
45
|
+
gapsWhere=gapsWhere, leafAbove=leafAbove, leafBelow=leafBelow, leafComparison=leafComparison)
|
|
46
|
+
return state
|
|
47
|
+
|
|
48
|
+
return workhorse
|
|
49
|
+
|
|
50
|
+
def unRePackDataclassAsynchronous(callableTarget: Callable[[
|
|
51
|
+
DatatypeFoldsTotal, DatatypeElephino, DatatypeElephino, DatatypeLeavesTotal, DatatypeElephino,
|
|
52
|
+
DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal, Array1DLeavesTotal, Array1DElephino, Array1DLeavesTotal,
|
|
53
|
+
Array1DLeavesTotal, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal
|
|
54
|
+
], tuple[
|
|
55
|
+
DatatypeFoldsTotal, DatatypeElephino, DatatypeElephino, DatatypeLeavesTotal, DatatypeElephino,
|
|
56
|
+
DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal, Array1DLeavesTotal, Array1DElephino, Array1DLeavesTotal,
|
|
57
|
+
Array1DLeavesTotal, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal
|
|
58
|
+
]]) -> Callable[[MapFoldingState], MapFoldingState]:
|
|
59
|
+
def workhorse(state: MapFoldingState) -> MapFoldingState:
|
|
60
|
+
mapShape: tuple[DatatypeLeavesTotal, ...] = state.mapShape
|
|
61
|
+
groupsOfFolds: DatatypeFoldsTotal = state.groupsOfFolds
|
|
62
|
+
gap1ndex: DatatypeElephino = state.gap1ndex
|
|
63
|
+
gap1ndexCeiling: DatatypeElephino = state.gap1ndexCeiling
|
|
64
|
+
indexDimension: DatatypeLeavesTotal = state.indexDimension
|
|
65
|
+
indexLeaf: DatatypeLeavesTotal = state.indexLeaf
|
|
66
|
+
indexMiniGap: DatatypeElephino = state.indexMiniGap
|
|
67
|
+
leaf1ndex: DatatypeLeavesTotal = state.leaf1ndex
|
|
68
|
+
leafConnectee: DatatypeLeavesTotal = state.leafConnectee
|
|
69
|
+
dimensionsUnconstrained: DatatypeLeavesTotal = state.dimensionsUnconstrained
|
|
70
|
+
countDimensionsGapped: Array1DLeavesTotal = state.countDimensionsGapped
|
|
71
|
+
gapRangeStart: Array1DElephino = state.gapRangeStart
|
|
72
|
+
gapsWhere: Array1DLeavesTotal = state.gapsWhere
|
|
73
|
+
leafAbove: Array1DLeavesTotal = state.leafAbove
|
|
74
|
+
leafBelow: Array1DLeavesTotal = state.leafBelow
|
|
75
|
+
leafComparison: Array1DLeavesTotal = state.leafComparison
|
|
76
|
+
connectionGraph: Array3DLeavesTotal = state.connectionGraph
|
|
77
|
+
dimensionsTotal: DatatypeLeavesTotal = state.dimensionsTotal
|
|
78
|
+
leavesTotal: DatatypeLeavesTotal = state.leavesTotal
|
|
79
|
+
|
|
80
|
+
(groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained,
|
|
81
|
+
countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal
|
|
82
|
+
) = callableTarget(
|
|
83
|
+
groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained,
|
|
84
|
+
countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal)
|
|
85
|
+
|
|
86
|
+
state = MapFoldingState(mapShape=mapShape, groupsOfFolds=groupsOfFolds, gap1ndex=gap1ndex, gap1ndexCeiling=gap1ndexCeiling,
|
|
87
|
+
indexDimension=indexDimension, indexLeaf=indexLeaf, indexMiniGap=indexMiniGap, leaf1ndex=leaf1ndex, leafConnectee=leafConnectee,
|
|
88
|
+
dimensionsUnconstrained=dimensionsUnconstrained, countDimensionsGapped=countDimensionsGapped, gapRangeStart=gapRangeStart,
|
|
89
|
+
gapsWhere=gapsWhere, leafAbove=leafAbove, leafBelow=leafBelow, leafComparison=leafComparison)
|
|
90
|
+
return state
|
|
91
|
+
|
|
92
|
+
return workhorse
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Everything in this directory is synthesized by other modules in the package."""
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from mapFolding.algorithms.matrixMeandersBeDry import (areIntegersWide,
|
|
2
|
+
walkDyckPath)
|
|
3
|
+
from mapFolding.dataBaskets import MatrixMeandersNumPyState
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def countBigInt(state: MatrixMeandersNumPyState) -> MatrixMeandersNumPyState:
|
|
7
|
+
"""Count meanders with matrix transfer algorithm using Python `int` (*int*eger) contained in a Python `dict` (*dict*ionary).
|
|
8
|
+
|
|
9
|
+
Parameters
|
|
10
|
+
----------
|
|
11
|
+
state : MatrixMeandersState
|
|
12
|
+
The algorithm state.
|
|
13
|
+
|
|
14
|
+
Notes
|
|
15
|
+
-----
|
|
16
|
+
The matrix transfer algorithm is sophisticated, but this implementation is straightforward: compute each index one at a time,
|
|
17
|
+
compute each `arcCode` one at a time, and compute each type of analysis one at a time.
|
|
18
|
+
"""
|
|
19
|
+
dictionaryArcCodeToCrossings: dict[int, int] = {}
|
|
20
|
+
while state.boundary > 0 and areIntegersWide(state):
|
|
21
|
+
state.boundary -= 1
|
|
22
|
+
state.bitWidth = max(state.dictionaryMeanders.keys()).bit_length()
|
|
23
|
+
dictionaryArcCodeToCrossings = state.dictionaryMeanders.copy()
|
|
24
|
+
state.dictionaryMeanders = {}
|
|
25
|
+
for arcCode, crossings in dictionaryArcCodeToCrossings.items():
|
|
26
|
+
bitsAlpha: int = arcCode & state.locatorBits
|
|
27
|
+
bitsZulu: int = arcCode >> 1 & state.locatorBits
|
|
28
|
+
bitsAlphaHasArcs: bool = bitsAlpha > 1
|
|
29
|
+
bitsZuluHasArcs: bool = bitsZulu > 1
|
|
30
|
+
bitsAlphaIsEven: int = bitsAlpha & 1 ^ 1
|
|
31
|
+
bitsZuluIsEven: int = bitsZulu & 1 ^ 1
|
|
32
|
+
arcCodeAnalysis = (bitsAlpha | bitsZulu << 1) << 2 | 3
|
|
33
|
+
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
34
|
+
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
35
|
+
if bitsAlphaHasArcs:
|
|
36
|
+
arcCodeAnalysis = bitsAlpha >> 2 | bitsZulu << 3 | bitsAlphaIsEven << 1
|
|
37
|
+
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
38
|
+
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
39
|
+
if bitsZuluHasArcs:
|
|
40
|
+
arcCodeAnalysis = bitsZulu >> 1 | bitsAlpha << 2 | bitsZuluIsEven
|
|
41
|
+
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
42
|
+
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
43
|
+
if bitsAlphaHasArcs and bitsZuluHasArcs and (bitsAlphaIsEven or bitsZuluIsEven):
|
|
44
|
+
if bitsAlphaIsEven and (not bitsZuluIsEven):
|
|
45
|
+
bitsAlpha ^= walkDyckPath(bitsAlpha)
|
|
46
|
+
elif bitsZuluIsEven and (not bitsAlphaIsEven):
|
|
47
|
+
bitsZulu ^= walkDyckPath(bitsZulu)
|
|
48
|
+
arcCodeAnalysis: int = bitsZulu >> 2 << 1 | bitsAlpha >> 2
|
|
49
|
+
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
50
|
+
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
51
|
+
dictionaryArcCodeToCrossings = {}
|
|
52
|
+
return state
|