mapFolding 0.16.2__py3-none-any.whl → 0.17.0__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 +2 -2
- easyRun/NOTcountingFolds.py +16 -8
- easyRun/countFolds.py +9 -2
- easyRun/generateAllModules.py +14 -0
- easyRun/meanders.py +4 -4
- mapFolding/__init__.py +1 -0
- mapFolding/_theSSOT.py +3 -2
- mapFolding/_theTypes.py +3 -0
- mapFolding/algorithms/A000136constraintPropagation.py +95 -0
- mapFolding/algorithms/A000136elimination.py +163 -0
- mapFolding/algorithms/A000136eliminationParallel.py +77 -0
- mapFolding/algorithms/A086345.py +75 -0
- mapFolding/algorithms/matrixMeanders.py +59 -18
- mapFolding/algorithms/matrixMeandersNumPyndas.py +841 -0
- mapFolding/algorithms/oeisIDbyFormula.py +2 -2
- mapFolding/algorithms/symmetricFolds.py +35 -0
- mapFolding/basecamp.py +100 -153
- mapFolding/dataBaskets.py +142 -65
- mapFolding/filesystemToolkit.py +4 -32
- mapFolding/oeis.py +5 -12
- mapFolding/reference/A086345Wu.py +25 -0
- mapFolding/reference/irvineJavaPort.py +3 -3
- mapFolding/reference/matrixMeandersAnalysis/signatures.py +3 -0
- mapFolding/reference/meandersDumpingGround/matrixMeandersNumPyV1finalForm.py +1 -1
- mapFolding/someAssemblyRequired/A007822/A007822rawMaterials.py +10 -45
- mapFolding/someAssemblyRequired/A007822/_asynchronousAnnex.py +51 -0
- mapFolding/someAssemblyRequired/A007822/makeA007822AsynchronousModules.py +39 -196
- mapFolding/someAssemblyRequired/A007822/makeA007822Modules.py +57 -43
- mapFolding/someAssemblyRequired/RecipeJob.py +84 -34
- mapFolding/someAssemblyRequired/__init__.py +4 -8
- mapFolding/someAssemblyRequired/_toolkitContainers.py +38 -7
- mapFolding/someAssemblyRequired/infoBooth.py +41 -23
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +140 -164
- mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +63 -96
- mapFolding/someAssemblyRequired/makingModules_count.py +26 -30
- mapFolding/someAssemblyRequired/makingModules_doTheNeedful.py +10 -72
- mapFolding/someAssemblyRequired/{mapFolding → mapFoldingModules}/makeMapFoldingModules.py +30 -35
- mapFolding/someAssemblyRequired/meanders/makeMeandersModules.py +13 -11
- mapFolding/someAssemblyRequired/toolkitMakeModules.py +5 -31
- mapFolding/someAssemblyRequired/toolkitNumba.py +3 -2
- mapFolding/someAssemblyRequired/transformationTools.py +12 -15
- mapFolding/syntheticModules/A007822/algorithm.py +45 -50
- mapFolding/syntheticModules/A007822/asynchronous.py +92 -36
- mapFolding/syntheticModules/A007822/initializeState.py +19 -23
- mapFolding/syntheticModules/A007822/theorem2.py +20 -24
- mapFolding/syntheticModules/A007822/theorem2Numba.py +23 -25
- mapFolding/syntheticModules/A007822/theorem2Trimmed.py +19 -23
- mapFolding/syntheticModules/countParallelNumba.py +1 -2
- mapFolding/syntheticModules/daoOfMapFoldingNumba.py +5 -4
- mapFolding/syntheticModules/initializeState.py +1 -1
- mapFolding/syntheticModules/meanders/bigInt.py +59 -22
- mapFolding/syntheticModules/theorem2.py +1 -1
- mapFolding/syntheticModules/theorem2Numba.py +30 -9
- mapFolding/syntheticModules/theorem2Trimmed.py +2 -2
- mapFolding/tests/test_computations.py +29 -3
- {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/METADATA +11 -8
- mapfolding-0.17.0.dist-info/RECORD +107 -0
- mapFolding/_dataPacking.py +0 -68
- mapFolding/algorithms/matrixMeandersBeDry.py +0 -182
- mapFolding/algorithms/matrixMeandersNumPy.py +0 -333
- mapFolding/algorithms/matrixMeandersPandas.py +0 -334
- mapFolding/reference/meandersDumpingGround/A005316intOptimized.py +0 -122
- mapFolding/reference/meandersDumpingGround/A005316optimized128bit.py +0 -79
- mapFolding/reference/meandersDumpingGround/matrixMeandersBaseline.py +0 -65
- mapFolding/reference/meandersDumpingGround/matrixMeandersBaselineAnnex.py +0 -84
- mapFolding/reference/meandersDumpingGround/matrixMeandersSimpleQueue.py +0 -90
- mapFolding/syntheticModules/A007822/algorithmNumba.py +0 -94
- mapFolding/syntheticModules/A007822/asynchronousAnnex.py +0 -66
- mapFolding/syntheticModules/A007822/asynchronousAnnexNumba.py +0 -70
- mapFolding/syntheticModules/A007822/asynchronousNumba.py +0 -79
- mapFolding/syntheticModules/A007822/asynchronousTheorem2.py +0 -65
- mapFolding/syntheticModules/A007822/asynchronousTrimmed.py +0 -56
- mapFolding/syntheticModules/dataPacking.py +0 -26
- mapFolding/syntheticModules/dataPackingA007822.py +0 -92
- mapfolding-0.16.2.dist-info/RECORD +0 -115
- /mapFolding/someAssemblyRequired/{mapFolding → mapFoldingModules}/__init__.py +0 -0
- {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/WHEEL +0 -0
- {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/top_level.txt +0 -0
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
from mapFolding._oeisFormulas.matrixMeandersAnnex import curveMaximum as curveMaximum
|
|
2
|
-
from queue import Empty, SimpleQueue
|
|
3
|
-
from typing import NamedTuple
|
|
4
|
-
import contextlib
|
|
5
|
-
|
|
6
|
-
class BifurcatedCurves(NamedTuple):
|
|
7
|
-
bifurcationZulu: int
|
|
8
|
-
bifurcationAlpha: int
|
|
9
|
-
distinctCrossings: int
|
|
10
|
-
curveLocationsMAXIMUM: int
|
|
11
|
-
|
|
12
|
-
dictionaryCurveLocations: dict[int, int] = {}
|
|
13
|
-
simpleQueueCurveLocations: SimpleQueue[tuple[int, int]] = SimpleQueue()
|
|
14
|
-
|
|
15
|
-
def unpackQueue() -> dict[int, int]:
|
|
16
|
-
with contextlib.suppress(Empty):
|
|
17
|
-
while True:
|
|
18
|
-
curveLocations, distinctCrossings = simpleQueueCurveLocations.get_nowait()
|
|
19
|
-
dictionaryCurveLocations[curveLocations] = dictionaryCurveLocations.get(curveLocations, 0) + distinctCrossings
|
|
20
|
-
|
|
21
|
-
return dictionaryCurveLocations
|
|
22
|
-
|
|
23
|
-
def getCurveLocations(bridges: int) -> list[BifurcatedCurves]:
|
|
24
|
-
global dictionaryCurveLocations # noqa: PLW0603
|
|
25
|
-
dictionaryCurveLocations = unpackQueue()
|
|
26
|
-
curveLocationsMAXIMUM, bifurcationZuluLocator, bifurcationAlphaLocator = curveMaximum[bridges]
|
|
27
|
-
listBifurcatedCurves: list[BifurcatedCurves] = []
|
|
28
|
-
# TODO This is ready for concurrency and/or vectorization.
|
|
29
|
-
for curveLocations, distinctCrossings in dictionaryCurveLocations.items():
|
|
30
|
-
bifurcationZulu = (curveLocations & bifurcationZuluLocator) >> 1
|
|
31
|
-
bifurcationAlpha = (curveLocations & bifurcationAlphaLocator)
|
|
32
|
-
listBifurcatedCurves.append(BifurcatedCurves(bifurcationZulu, bifurcationAlpha, distinctCrossings, curveLocationsMAXIMUM))
|
|
33
|
-
dictionaryCurveLocations = {}
|
|
34
|
-
return listBifurcatedCurves
|
|
35
|
-
|
|
36
|
-
def recordAnalysis(curveLocationAnalysis: int, curveLocationsMAXIMUM: int, distinctCrossings: int) -> None:
|
|
37
|
-
if curveLocationAnalysis < curveLocationsMAXIMUM:
|
|
38
|
-
simpleQueueCurveLocations.put((curveLocationAnalysis, distinctCrossings))
|
|
39
|
-
|
|
40
|
-
def analyzeCurve(bifurcationZulu: int, bifurcationAlpha: int, distinctCrossings: int, curveLocationsMAXIMUM: int) -> None:
|
|
41
|
-
bifurcationZuluFinalZero = (bifurcationZulu & 0b1) == 0
|
|
42
|
-
bifurcationZuluHasCurves = bifurcationZulu != 1
|
|
43
|
-
bifurcationAlphaFinalZero = (bifurcationAlpha & 0b1) == 0
|
|
44
|
-
bifurcationAlphaHasCurves = bifurcationAlpha != 1
|
|
45
|
-
|
|
46
|
-
if bifurcationZuluHasCurves:
|
|
47
|
-
curveLocationAnalysis = (bifurcationZulu >> 1) | (bifurcationAlpha << 2) | bifurcationZuluFinalZero
|
|
48
|
-
recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
|
|
49
|
-
|
|
50
|
-
if bifurcationAlphaHasCurves:
|
|
51
|
-
curveLocationAnalysis = (bifurcationAlpha >> 2) | (bifurcationZulu << 3) | (bifurcationAlphaFinalZero << 1)
|
|
52
|
-
recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
|
|
53
|
-
|
|
54
|
-
curveLocationAnalysis = ((bifurcationAlpha | (bifurcationZulu << 1)) << 2) | 3
|
|
55
|
-
recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
|
|
56
|
-
|
|
57
|
-
if bifurcationZuluHasCurves and bifurcationAlphaHasCurves and (bifurcationZuluFinalZero or bifurcationAlphaFinalZero):
|
|
58
|
-
XOrHere2makePair = 0b1
|
|
59
|
-
findUnpairedBinary1 = 0
|
|
60
|
-
|
|
61
|
-
if bifurcationZuluFinalZero and not bifurcationAlphaFinalZero:
|
|
62
|
-
while findUnpairedBinary1 >= 0:
|
|
63
|
-
XOrHere2makePair <<= 2
|
|
64
|
-
findUnpairedBinary1 += 1 if (bifurcationZulu & XOrHere2makePair) == 0 else -1
|
|
65
|
-
bifurcationZulu ^= XOrHere2makePair
|
|
66
|
-
|
|
67
|
-
elif bifurcationAlphaFinalZero and not bifurcationZuluFinalZero:
|
|
68
|
-
while findUnpairedBinary1 >= 0:
|
|
69
|
-
XOrHere2makePair <<= 2
|
|
70
|
-
findUnpairedBinary1 += 1 if (bifurcationAlpha & XOrHere2makePair) == 0 else -1
|
|
71
|
-
bifurcationAlpha ^= XOrHere2makePair
|
|
72
|
-
|
|
73
|
-
curveLocationAnalysis = ((bifurcationZulu >> 2) << 1) | (bifurcationAlpha >> 2)
|
|
74
|
-
recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
|
|
75
|
-
|
|
76
|
-
def initializeCurveLocations(startingCurveLocations: dict[int, int]) -> None:
|
|
77
|
-
global dictionaryCurveLocations # noqa: PLW0603
|
|
78
|
-
dictionaryCurveLocations = startingCurveLocations.copy()
|
|
79
|
-
|
|
80
|
-
def count(bridges: int, startingCurveLocations: dict[int, int]) -> int:
|
|
81
|
-
initializeCurveLocations(startingCurveLocations)
|
|
82
|
-
|
|
83
|
-
while bridges > 0:
|
|
84
|
-
bridges -= 1
|
|
85
|
-
|
|
86
|
-
# TODO This could be parallelized when `recordAnalysis` is thread-safe
|
|
87
|
-
for bifurcatedCurve in getCurveLocations(bridges):
|
|
88
|
-
analyzeCurve(*bifurcatedCurve)
|
|
89
|
-
|
|
90
|
-
return getCurveLocations(bridges)[0].distinctCrossings
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
from mapFolding.dataBaskets import Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal, MapFoldingState
|
|
2
|
-
from numba import jit
|
|
3
|
-
|
|
4
|
-
@jit(cache=True, error_model='numpy', fastmath=True, forceinline=True)
|
|
5
|
-
def count(groupsOfFolds: DatatypeFoldsTotal, gap1ndex: DatatypeElephino, gap1ndexCeiling: DatatypeElephino, indexDimension: DatatypeLeavesTotal, indexLeaf: DatatypeLeavesTotal, indexMiniGap: DatatypeElephino, leaf1ndex: DatatypeLeavesTotal, leafConnectee: DatatypeLeavesTotal, dimensionsUnconstrained: DatatypeLeavesTotal, countDimensionsGapped: Array1DLeavesTotal, gapRangeStart: Array1DElephino, gapsWhere: Array1DLeavesTotal, leafAbove: Array1DLeavesTotal, leafBelow: Array1DLeavesTotal, leafComparison: Array1DLeavesTotal, connectionGraph: Array3DLeavesTotal, dimensionsTotal: DatatypeLeavesTotal, leavesTotal: DatatypeLeavesTotal) -> tuple[DatatypeFoldsTotal, DatatypeElephino, DatatypeElephino, DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeElephino, DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal, Array1DLeavesTotal, Array1DElephino, Array1DLeavesTotal, Array1DLeavesTotal, Array1DLeavesTotal, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal]:
|
|
6
|
-
while leaf1ndex > 0:
|
|
7
|
-
if leaf1ndex <= 1 or leafBelow[0] == 1:
|
|
8
|
-
if leaf1ndex > leavesTotal:
|
|
9
|
-
indexLeaf = 0
|
|
10
|
-
leafConnectee = 0
|
|
11
|
-
while leafConnectee < leavesTotal + 1:
|
|
12
|
-
leafNumber = int(leafBelow[indexLeaf])
|
|
13
|
-
leafComparison[leafConnectee] = (leafNumber - indexLeaf + leavesTotal) % leavesTotal
|
|
14
|
-
indexLeaf = leafNumber
|
|
15
|
-
leafConnectee += 1
|
|
16
|
-
indexInMiddle = leavesTotal // 2
|
|
17
|
-
indexMiniGap = 0
|
|
18
|
-
while indexMiniGap < leavesTotal + 1:
|
|
19
|
-
ImaSymmetricFold = True
|
|
20
|
-
leafConnectee = 0
|
|
21
|
-
while leafConnectee < indexInMiddle:
|
|
22
|
-
if leafComparison[(indexMiniGap + leafConnectee) % (leavesTotal + 1)] != leafComparison[(indexMiniGap + leavesTotal - 1 - leafConnectee) % (leavesTotal + 1)]:
|
|
23
|
-
ImaSymmetricFold = False
|
|
24
|
-
break
|
|
25
|
-
leafConnectee += 1
|
|
26
|
-
groupsOfFolds += ImaSymmetricFold
|
|
27
|
-
indexMiniGap += 1
|
|
28
|
-
else:
|
|
29
|
-
dimensionsUnconstrained = dimensionsTotal
|
|
30
|
-
gap1ndexCeiling = gapRangeStart[leaf1ndex - 1]
|
|
31
|
-
indexDimension = 0
|
|
32
|
-
while indexDimension < dimensionsTotal:
|
|
33
|
-
leafConnectee = connectionGraph[indexDimension, leaf1ndex, leaf1ndex]
|
|
34
|
-
if leafConnectee == leaf1ndex:
|
|
35
|
-
dimensionsUnconstrained -= 1
|
|
36
|
-
else:
|
|
37
|
-
while leafConnectee != leaf1ndex:
|
|
38
|
-
gapsWhere[gap1ndexCeiling] = leafConnectee
|
|
39
|
-
if countDimensionsGapped[leafConnectee] == 0:
|
|
40
|
-
gap1ndexCeiling += 1
|
|
41
|
-
countDimensionsGapped[leafConnectee] += 1
|
|
42
|
-
leafConnectee = connectionGraph[indexDimension, leaf1ndex, leafBelow[leafConnectee]]
|
|
43
|
-
indexDimension += 1
|
|
44
|
-
if not dimensionsUnconstrained:
|
|
45
|
-
indexLeaf = 0
|
|
46
|
-
while indexLeaf < leaf1ndex:
|
|
47
|
-
gapsWhere[gap1ndexCeiling] = indexLeaf
|
|
48
|
-
gap1ndexCeiling += 1
|
|
49
|
-
indexLeaf += 1
|
|
50
|
-
indexMiniGap = gap1ndex
|
|
51
|
-
while indexMiniGap < gap1ndexCeiling:
|
|
52
|
-
gapsWhere[gap1ndex] = gapsWhere[indexMiniGap]
|
|
53
|
-
if countDimensionsGapped[gapsWhere[indexMiniGap]] == dimensionsUnconstrained:
|
|
54
|
-
gap1ndex += 1
|
|
55
|
-
countDimensionsGapped[gapsWhere[indexMiniGap]] = 0
|
|
56
|
-
indexMiniGap += 1
|
|
57
|
-
while leaf1ndex > 0 and gap1ndex == gapRangeStart[leaf1ndex - 1]:
|
|
58
|
-
leaf1ndex -= 1
|
|
59
|
-
leafBelow[leafAbove[leaf1ndex]] = leafBelow[leaf1ndex]
|
|
60
|
-
leafAbove[leafBelow[leaf1ndex]] = leafAbove[leaf1ndex]
|
|
61
|
-
if leaf1ndex > 0:
|
|
62
|
-
gap1ndex -= 1
|
|
63
|
-
leafAbove[leaf1ndex] = gapsWhere[gap1ndex]
|
|
64
|
-
leafBelow[leaf1ndex] = leafBelow[leafAbove[leaf1ndex]]
|
|
65
|
-
leafBelow[leafAbove[leaf1ndex]] = leaf1ndex
|
|
66
|
-
leafAbove[leafBelow[leaf1ndex]] = leaf1ndex
|
|
67
|
-
gapRangeStart[leaf1ndex] = gap1ndex
|
|
68
|
-
leaf1ndex += 1
|
|
69
|
-
groupsOfFolds = (groupsOfFolds + 1) // 2
|
|
70
|
-
return (groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, leafComparison, connectionGraph, dimensionsTotal, leavesTotal)
|
|
71
|
-
|
|
72
|
-
def doTheNeedful(state: MapFoldingState) -> MapFoldingState:
|
|
73
|
-
mapShape: tuple[DatatypeLeavesTotal, ...] = state.mapShape
|
|
74
|
-
groupsOfFolds: DatatypeFoldsTotal = state.groupsOfFolds
|
|
75
|
-
gap1ndex: DatatypeElephino = state.gap1ndex
|
|
76
|
-
gap1ndexCeiling: DatatypeElephino = state.gap1ndexCeiling
|
|
77
|
-
indexDimension: DatatypeLeavesTotal = state.indexDimension
|
|
78
|
-
indexLeaf: DatatypeLeavesTotal = state.indexLeaf
|
|
79
|
-
indexMiniGap: DatatypeElephino = state.indexMiniGap
|
|
80
|
-
leaf1ndex: DatatypeLeavesTotal = state.leaf1ndex
|
|
81
|
-
leafConnectee: DatatypeLeavesTotal = state.leafConnectee
|
|
82
|
-
dimensionsUnconstrained: DatatypeLeavesTotal = state.dimensionsUnconstrained
|
|
83
|
-
countDimensionsGapped: Array1DLeavesTotal = state.countDimensionsGapped
|
|
84
|
-
gapRangeStart: Array1DElephino = state.gapRangeStart
|
|
85
|
-
gapsWhere: Array1DLeavesTotal = state.gapsWhere
|
|
86
|
-
leafAbove: Array1DLeavesTotal = state.leafAbove
|
|
87
|
-
leafBelow: Array1DLeavesTotal = state.leafBelow
|
|
88
|
-
leafComparison: Array1DLeavesTotal = state.leafComparison
|
|
89
|
-
connectionGraph: Array3DLeavesTotal = state.connectionGraph
|
|
90
|
-
dimensionsTotal: DatatypeLeavesTotal = state.dimensionsTotal
|
|
91
|
-
leavesTotal: DatatypeLeavesTotal = state.leavesTotal
|
|
92
|
-
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)
|
|
93
|
-
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)
|
|
94
|
-
return state
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
from concurrent.futures import Future as ConcurrentFuture, ThreadPoolExecutor
|
|
2
|
-
from hunterMakesPy import raiseIfNone
|
|
3
|
-
from mapFolding import Array1DLeavesTotal
|
|
4
|
-
from queue import Empty, Queue
|
|
5
|
-
from threading import Thread
|
|
6
|
-
import numpy
|
|
7
|
-
|
|
8
|
-
concurrencyManager = None
|
|
9
|
-
groupsOfFoldsTotal: int = 0
|
|
10
|
-
processingThread = None
|
|
11
|
-
queueFutures: Queue[ConcurrentFuture[int]] = Queue()
|
|
12
|
-
|
|
13
|
-
def initializeConcurrencyManager(maxWorkers: int | None=None, groupsOfFolds: int=0) -> None:
|
|
14
|
-
global concurrencyManager, queueFutures, groupsOfFoldsTotal, processingThread
|
|
15
|
-
concurrencyManager = ThreadPoolExecutor(max_workers=maxWorkers)
|
|
16
|
-
queueFutures = Queue()
|
|
17
|
-
groupsOfFoldsTotal = groupsOfFolds
|
|
18
|
-
processingThread = Thread(target=_processCompletedFutures)
|
|
19
|
-
processingThread.start()
|
|
20
|
-
|
|
21
|
-
def _processCompletedFutures() -> None:
|
|
22
|
-
global queueFutures, groupsOfFoldsTotal
|
|
23
|
-
while True:
|
|
24
|
-
try:
|
|
25
|
-
claimTicket: ConcurrentFuture[int] = queueFutures.get(timeout=1)
|
|
26
|
-
if claimTicket is None:
|
|
27
|
-
break
|
|
28
|
-
groupsOfFoldsTotal += claimTicket.result()
|
|
29
|
-
except Empty:
|
|
30
|
-
continue
|
|
31
|
-
|
|
32
|
-
def _filterAsymmetricFolds(leafBelow: Array1DLeavesTotal) -> int:
|
|
33
|
-
groupsOfFolds = 0
|
|
34
|
-
leafComparison: Array1DLeavesTotal = numpy.zeros_like(leafBelow)
|
|
35
|
-
leavesTotal = leafBelow.size - 1
|
|
36
|
-
indexLeaf = 0
|
|
37
|
-
leafConnectee = 0
|
|
38
|
-
while leafConnectee < leavesTotal + 1:
|
|
39
|
-
leafNumber = int(leafBelow[indexLeaf])
|
|
40
|
-
leafComparison[leafConnectee] = (leafNumber - indexLeaf + leavesTotal) % leavesTotal
|
|
41
|
-
indexLeaf = leafNumber
|
|
42
|
-
leafConnectee += 1
|
|
43
|
-
indexInMiddle = leavesTotal // 2
|
|
44
|
-
indexDistance = 0
|
|
45
|
-
while indexDistance < leavesTotal + 1:
|
|
46
|
-
ImaSymmetricFold = True
|
|
47
|
-
leafConnectee = 0
|
|
48
|
-
while leafConnectee < indexInMiddle:
|
|
49
|
-
if leafComparison[(indexDistance + leafConnectee) % (leavesTotal + 1)] != leafComparison[(indexDistance + leavesTotal - 1 - leafConnectee) % (leavesTotal + 1)]:
|
|
50
|
-
ImaSymmetricFold = False
|
|
51
|
-
break
|
|
52
|
-
leafConnectee += 1
|
|
53
|
-
groupsOfFolds += ImaSymmetricFold
|
|
54
|
-
indexDistance += 1
|
|
55
|
-
return groupsOfFolds
|
|
56
|
-
|
|
57
|
-
def filterAsymmetricFolds(leafBelow: Array1DLeavesTotal) -> None:
|
|
58
|
-
global concurrencyManager, queueFutures
|
|
59
|
-
queueFutures.put_nowait(raiseIfNone(concurrencyManager).submit(_filterAsymmetricFolds, leafBelow.copy()))
|
|
60
|
-
|
|
61
|
-
def getSymmetricFoldsTotal() -> int:
|
|
62
|
-
global concurrencyManager, queueFutures, processingThread
|
|
63
|
-
raiseIfNone(concurrencyManager).shutdown(wait=True)
|
|
64
|
-
queueFutures.put(None)
|
|
65
|
-
raiseIfNone(processingThread).join()
|
|
66
|
-
return groupsOfFoldsTotal
|
|
@@ -1,70 +0,0 @@
|
|
|
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
|
|
@@ -1,79 +0,0 @@
|
|
|
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,65 +0,0 @@
|
|
|
1
|
-
from mapFolding.dataBaskets import MapFoldingState
|
|
2
|
-
from mapFolding.syntheticModules.A007822.asynchronousAnnexNumba import (
|
|
3
|
-
filterAsymmetricFolds, getSymmetricFoldsTotal,
|
|
4
|
-
initializeConcurrencyManager)
|
|
5
|
-
from mapFolding.syntheticModules.A007822.initializeState import \
|
|
6
|
-
transitionOnGroupsOfFolds
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def count(state: MapFoldingState) -> MapFoldingState:
|
|
10
|
-
while state.leaf1ndex > 4:
|
|
11
|
-
if state.leafBelow[0] == 1:
|
|
12
|
-
if state.leaf1ndex > state.leavesTotal:
|
|
13
|
-
filterAsymmetricFolds(state.leafBelow)
|
|
14
|
-
else:
|
|
15
|
-
state.dimensionsUnconstrained = state.dimensionsTotal
|
|
16
|
-
state.gap1ndexCeiling = state.gapRangeStart[state.leaf1ndex - 1]
|
|
17
|
-
state.indexDimension = 0
|
|
18
|
-
while state.indexDimension < state.dimensionsTotal:
|
|
19
|
-
state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leaf1ndex]
|
|
20
|
-
if state.leafConnectee == state.leaf1ndex:
|
|
21
|
-
state.dimensionsUnconstrained -= 1
|
|
22
|
-
else:
|
|
23
|
-
while state.leafConnectee != state.leaf1ndex:
|
|
24
|
-
state.gapsWhere[state.gap1ndexCeiling] = state.leafConnectee
|
|
25
|
-
if state.countDimensionsGapped[state.leafConnectee] == 0:
|
|
26
|
-
state.gap1ndexCeiling += 1
|
|
27
|
-
state.countDimensionsGapped[state.leafConnectee] += 1
|
|
28
|
-
state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leafBelow[state.leafConnectee]]
|
|
29
|
-
state.indexDimension += 1
|
|
30
|
-
if not state.dimensionsUnconstrained:
|
|
31
|
-
state.indexLeaf = 0
|
|
32
|
-
while state.indexLeaf < state.leaf1ndex:
|
|
33
|
-
state.gapsWhere[state.gap1ndexCeiling] = state.indexLeaf
|
|
34
|
-
state.gap1ndexCeiling += 1
|
|
35
|
-
state.indexLeaf += 1
|
|
36
|
-
state.indexMiniGap = state.gap1ndex
|
|
37
|
-
while state.indexMiniGap < state.gap1ndexCeiling:
|
|
38
|
-
state.gapsWhere[state.gap1ndex] = state.gapsWhere[state.indexMiniGap]
|
|
39
|
-
if state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] == state.dimensionsUnconstrained:
|
|
40
|
-
state.gap1ndex += 1
|
|
41
|
-
state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] = 0
|
|
42
|
-
state.indexMiniGap += 1
|
|
43
|
-
while state.gap1ndex == state.gapRangeStart[state.leaf1ndex - 1]:
|
|
44
|
-
state.leaf1ndex -= 1
|
|
45
|
-
state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leafBelow[state.leaf1ndex]
|
|
46
|
-
state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leafAbove[state.leaf1ndex]
|
|
47
|
-
state.gap1ndex -= 1
|
|
48
|
-
state.leafAbove[state.leaf1ndex] = state.gapsWhere[state.gap1ndex]
|
|
49
|
-
state.leafBelow[state.leaf1ndex] = state.leafBelow[state.leafAbove[state.leaf1ndex]]
|
|
50
|
-
state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leaf1ndex
|
|
51
|
-
state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leaf1ndex
|
|
52
|
-
state.gapRangeStart[state.leaf1ndex] = state.gap1ndex
|
|
53
|
-
state.leaf1ndex += 1
|
|
54
|
-
else:
|
|
55
|
-
state.groupsOfFolds = getSymmetricFoldsTotal()
|
|
56
|
-
state.groupsOfFolds *= 2
|
|
57
|
-
state.groupsOfFolds = (state.groupsOfFolds + 1) // 2
|
|
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,56 +0,0 @@
|
|
|
1
|
-
from mapFolding.dataBaskets import MapFoldingState
|
|
2
|
-
from mapFolding.syntheticModules.A007822.asynchronousAnnexNumba import (
|
|
3
|
-
filterAsymmetricFolds, getSymmetricFoldsTotal, initializeConcurrencyManager)
|
|
4
|
-
from mapFolding.syntheticModules.A007822.initializeState import transitionOnGroupsOfFolds
|
|
5
|
-
|
|
6
|
-
def count(state: MapFoldingState) -> MapFoldingState:
|
|
7
|
-
while state.leaf1ndex > 4:
|
|
8
|
-
if state.leafBelow[0] == 1:
|
|
9
|
-
if state.leaf1ndex > state.leavesTotal:
|
|
10
|
-
filterAsymmetricFolds(state.leafBelow)
|
|
11
|
-
else:
|
|
12
|
-
state.dimensionsUnconstrained = state.dimensionsTotal
|
|
13
|
-
state.gap1ndexCeiling = state.gapRangeStart[state.leaf1ndex - 1]
|
|
14
|
-
state.indexDimension = 0
|
|
15
|
-
while state.indexDimension < state.dimensionsTotal:
|
|
16
|
-
state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leaf1ndex]
|
|
17
|
-
if state.leafConnectee == state.leaf1ndex:
|
|
18
|
-
state.dimensionsUnconstrained -= 1
|
|
19
|
-
else:
|
|
20
|
-
while state.leafConnectee != state.leaf1ndex:
|
|
21
|
-
state.gapsWhere[state.gap1ndexCeiling] = state.leafConnectee
|
|
22
|
-
if state.countDimensionsGapped[state.leafConnectee] == 0:
|
|
23
|
-
state.gap1ndexCeiling += 1
|
|
24
|
-
state.countDimensionsGapped[state.leafConnectee] += 1
|
|
25
|
-
state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leafBelow[state.leafConnectee]]
|
|
26
|
-
state.indexDimension += 1
|
|
27
|
-
state.indexMiniGap = state.gap1ndex
|
|
28
|
-
while state.indexMiniGap < state.gap1ndexCeiling:
|
|
29
|
-
state.gapsWhere[state.gap1ndex] = state.gapsWhere[state.indexMiniGap]
|
|
30
|
-
if state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] == state.dimensionsUnconstrained:
|
|
31
|
-
state.gap1ndex += 1
|
|
32
|
-
state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] = 0
|
|
33
|
-
state.indexMiniGap += 1
|
|
34
|
-
while state.gap1ndex == state.gapRangeStart[state.leaf1ndex - 1]:
|
|
35
|
-
state.leaf1ndex -= 1
|
|
36
|
-
state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leafBelow[state.leaf1ndex]
|
|
37
|
-
state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leafAbove[state.leaf1ndex]
|
|
38
|
-
state.gap1ndex -= 1
|
|
39
|
-
state.leafAbove[state.leaf1ndex] = state.gapsWhere[state.gap1ndex]
|
|
40
|
-
state.leafBelow[state.leaf1ndex] = state.leafBelow[state.leafAbove[state.leaf1ndex]]
|
|
41
|
-
state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leaf1ndex
|
|
42
|
-
state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leaf1ndex
|
|
43
|
-
state.gapRangeStart[state.leaf1ndex] = state.gap1ndex
|
|
44
|
-
state.leaf1ndex += 1
|
|
45
|
-
else:
|
|
46
|
-
state.groupsOfFolds = getSymmetricFoldsTotal()
|
|
47
|
-
state.groupsOfFolds *= 2
|
|
48
|
-
state.groupsOfFolds = (state.groupsOfFolds + 1) // 2
|
|
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
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
from mapFolding.dataBaskets import Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal, MapFoldingState
|
|
2
|
-
from mapFolding.syntheticModules.theorem2Numba import count
|
|
3
|
-
|
|
4
|
-
def sequential(state: MapFoldingState) -> MapFoldingState:
|
|
5
|
-
mapShape: tuple[DatatypeLeavesTotal, ...] = state.mapShape
|
|
6
|
-
groupsOfFolds: DatatypeFoldsTotal = state.groupsOfFolds
|
|
7
|
-
gap1ndex: DatatypeElephino = state.gap1ndex
|
|
8
|
-
gap1ndexCeiling: DatatypeElephino = state.gap1ndexCeiling
|
|
9
|
-
indexDimension: DatatypeLeavesTotal = state.indexDimension
|
|
10
|
-
indexLeaf: DatatypeLeavesTotal = state.indexLeaf
|
|
11
|
-
indexMiniGap: DatatypeElephino = state.indexMiniGap
|
|
12
|
-
leaf1ndex: DatatypeLeavesTotal = state.leaf1ndex
|
|
13
|
-
leafConnectee: DatatypeLeavesTotal = state.leafConnectee
|
|
14
|
-
dimensionsUnconstrained: DatatypeLeavesTotal = state.dimensionsUnconstrained
|
|
15
|
-
countDimensionsGapped: Array1DLeavesTotal = state.countDimensionsGapped
|
|
16
|
-
gapRangeStart: Array1DElephino = state.gapRangeStart
|
|
17
|
-
gapsWhere: Array1DLeavesTotal = state.gapsWhere
|
|
18
|
-
leafAbove: Array1DLeavesTotal = state.leafAbove
|
|
19
|
-
leafBelow: Array1DLeavesTotal = state.leafBelow
|
|
20
|
-
leafComparison: Array1DLeavesTotal = state.leafComparison
|
|
21
|
-
connectionGraph: Array3DLeavesTotal = state.connectionGraph
|
|
22
|
-
dimensionsTotal: DatatypeLeavesTotal = state.dimensionsTotal
|
|
23
|
-
leavesTotal: DatatypeLeavesTotal = state.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
|
-
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
|
-
return state
|
|
@@ -1,92 +0,0 @@
|
|
|
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
|