mapFolding 0.16.1__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 +1 -1
- easyRun/A005316.py +2 -3
- easyRun/NOTcountingFolds.py +3 -3
- easyRun/meanders.py +17 -19
- mapFolding/algorithms/matrixMeanders.py +15 -28
- mapFolding/algorithms/matrixMeandersBeDry.py +34 -116
- mapFolding/algorithms/matrixMeandersNumPy.py +117 -70
- mapFolding/algorithms/matrixMeandersPandas.py +113 -130
- mapFolding/algorithms/oeisIDbyFormula.py +23 -12
- mapFolding/algorithms/zCuzDocStoopidoeisIDbyFormula.py +26 -12
- mapFolding/basecamp.py +140 -242
- mapFolding/dataBaskets.py +14 -30
- mapFolding/reference/A000682facts.py +785 -1264
- mapFolding/reference/A005316facts.py +958 -923
- mapFolding/reference/matrixMeandersAnalysis/signatures.py +2030 -0
- mapFolding/someAssemblyRequired/A007822/A007822rawMaterials.py +2 -2
- mapFolding/someAssemblyRequired/A007822/makeA007822AsynchronousModules.py +83 -21
- mapFolding/someAssemblyRequired/A007822/makeA007822Modules.py +13 -12
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +2 -2
- mapFolding/someAssemblyRequired/makingModules_count.py +88 -80
- mapFolding/someAssemblyRequired/makingModules_doTheNeedful.py +11 -7
- mapFolding/someAssemblyRequired/mapFolding/makeMapFoldingModules.py +3 -3
- mapFolding/someAssemblyRequired/meanders/makeMeandersModules.py +7 -8
- mapFolding/someAssemblyRequired/toolkitMakeModules.py +9 -9
- mapFolding/someAssemblyRequired/transformationTools.py +8 -8
- mapFolding/syntheticModules/A007822/algorithm.py +1 -0
- mapFolding/syntheticModules/A007822/asynchronous.py +6 -4
- mapFolding/syntheticModules/A007822/asynchronousAnnex.py +1 -1
- mapFolding/syntheticModules/A007822/asynchronousAnnexNumba.py +2 -17
- mapFolding/syntheticModules/A007822/asynchronousNumba.py +35 -8
- mapFolding/syntheticModules/A007822/asynchronousTheorem2.py +15 -3
- mapFolding/syntheticModules/A007822/asynchronousTrimmed.py +12 -3
- mapFolding/syntheticModules/A007822/theorem2.py +6 -0
- mapFolding/syntheticModules/A007822/theorem2Numba.py +28 -3
- mapFolding/syntheticModules/A007822/theorem2Trimmed.py +7 -1
- mapFolding/syntheticModules/daoOfMapFoldingNumba.py +2 -4
- mapFolding/syntheticModules/dataPacking.py +3 -5
- mapFolding/syntheticModules/meanders/bigInt.py +24 -34
- mapFolding/syntheticModules/theorem2.py +6 -0
- mapFolding/syntheticModules/theorem2Numba.py +9 -4
- mapFolding/syntheticModules/theorem2Trimmed.py +6 -0
- mapFolding/tests/test_computations.py +1 -1
- mapFolding/zCuzDocStoopid/makeDocstrings.py +2 -0
- {mapfolding-0.16.1.dist-info → mapfolding-0.16.2.dist-info}/METADATA +1 -1
- {mapfolding-0.16.1.dist-info → mapfolding-0.16.2.dist-info}/RECORD +49 -48
- {mapfolding-0.16.1.dist-info → mapfolding-0.16.2.dist-info}/WHEEL +0 -0
- {mapfolding-0.16.1.dist-info → mapfolding-0.16.2.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.16.1.dist-info → mapfolding-0.16.2.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.16.1.dist-info → mapfolding-0.16.2.dist-info}/top_level.txt +0 -0
|
@@ -7,7 +7,6 @@ from mapFolding.someAssemblyRequired import (
|
|
|
7
7
|
identifierCallableSourceDEFAULT, identifierCallableSourceDispatcherDEFAULT, IfThis, logicalPathInfixDEFAULT)
|
|
8
8
|
from mapFolding.someAssemblyRequired.toolkitMakeModules import (
|
|
9
9
|
findDataclass, getModule, getPathFilename, write_astModule)
|
|
10
|
-
from os import PathLike
|
|
11
10
|
from pathlib import PurePath
|
|
12
11
|
import ast
|
|
13
12
|
|
|
@@ -15,7 +14,7 @@ identifierDataclassNumPyHARDCODED = 'MatrixMeandersNumPyState'
|
|
|
15
14
|
|
|
16
15
|
logicalPathInfixMeanders: str = logicalPathInfixDEFAULT + '.meanders'
|
|
17
16
|
|
|
18
|
-
def makeCountBigInt(astModule: ast.Module,
|
|
17
|
+
def makeCountBigInt(astModule: ast.Module, identifierModule: str, callableIdentifier: str | None = None, logicalPathInfix: identifierDotAttribute | None = None, sourceCallableDispatcher: str | None = None) -> PurePath:
|
|
19
18
|
"""Make `countBigInt` module for meanders using `MatrixMeandersNumPyState` dataclass."""
|
|
20
19
|
identifierDataclassNumPy: str = identifierDataclassNumPyHARDCODED
|
|
21
20
|
_logicalPathDataclass, identifierDataclassOld, identifierDataclassInstance = findDataclass(astModuleToIngredientsFunction(astModule, raiseIfNone(sourceCallableDispatcher)))
|
|
@@ -36,29 +35,29 @@ def makeCountBigInt(astModule: ast.Module, moduleIdentifier: str, callableIdenti
|
|
|
36
35
|
, Grab.nameAttribute(Then.replaceWith(identifierDataclassNumPy))
|
|
37
36
|
).visit(astModule)
|
|
38
37
|
|
|
39
|
-
# while (state.
|
|
38
|
+
# while (state.boundary > 0 and areIntegersWide(state)): # noqa: ERA001
|
|
40
39
|
Call_areIntegersWide: ast.Call = Make.Call(Make.Name('areIntegersWide'), listParameters=[Make.Name('state')])
|
|
41
40
|
astCompare: ast.Compare = raiseIfNone(NodeTourist(
|
|
42
|
-
findThis=IfThis.isAttributeNamespaceIdentifierGreaterThan0(identifierDataclassInstance, '
|
|
41
|
+
findThis=IfThis.isAttributeNamespaceIdentifierGreaterThan0(identifierDataclassInstance, 'boundary')
|
|
43
42
|
, doThat=Then.extractIt
|
|
44
43
|
).captureLastMatch(astModule))
|
|
45
44
|
newTest: ast.expr = Make.And.join([astCompare, Call_areIntegersWide])
|
|
46
45
|
|
|
47
|
-
NodeChanger(IfThis.isWhileAttributeNamespaceIdentifierGreaterThan0(identifierDataclassInstance, '
|
|
46
|
+
NodeChanger(IfThis.isWhileAttributeNamespaceIdentifierGreaterThan0(identifierDataclassInstance, 'boundary')
|
|
48
47
|
, Grab.testAttribute(Then.replaceWith(newTest))
|
|
49
48
|
).visit(astModule)
|
|
50
49
|
|
|
51
50
|
# from mapFolding.algorithms.matrixMeandersBeDry import areIntegersWide # noqa: ERA001
|
|
52
51
|
astModule.body.insert(0, Make.ImportFrom('mapFolding.algorithms.matrixMeandersBeDry', list_alias=[Make.alias('areIntegersWide')]))
|
|
53
52
|
|
|
54
|
-
pathFilename = getPathFilename(logicalPathInfix=logicalPathInfix,
|
|
53
|
+
pathFilename: PurePath = getPathFilename(logicalPathInfix=logicalPathInfix, identifierModule=identifierModule)
|
|
55
54
|
|
|
56
55
|
write_astModule(astModule, pathFilename, packageSettings.identifierPackage)
|
|
57
56
|
|
|
58
57
|
return pathFilename
|
|
59
58
|
|
|
60
59
|
if __name__ == '__main__':
|
|
61
|
-
astModule = getModule(logicalPathInfix='algorithms',
|
|
62
|
-
pathFilename = makeCountBigInt(astModule, 'bigInt', 'countBigInt', logicalPathInfixMeanders, identifierCallableSourceDispatcherDEFAULT)
|
|
60
|
+
astModule: ast.Module = getModule(logicalPathInfix='algorithms', identifierModule='matrixMeanders')
|
|
61
|
+
pathFilename: PurePath = makeCountBigInt(astModule, 'bigInt', 'countBigInt', logicalPathInfixMeanders, identifierCallableSourceDispatcherDEFAULT)
|
|
63
62
|
|
|
64
63
|
|
|
@@ -85,32 +85,32 @@ def findDataclass(ingredientsFunction: IngredientsFunction) -> tuple[identifierD
|
|
|
85
85
|
identifierDataclassInstance: identifierDotAttribute = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
86
86
|
return raiseIfNone(logicalPathDataclass), identifierDataclass, identifierDataclassInstance
|
|
87
87
|
|
|
88
|
-
def getLogicalPath(identifierPackage: str | None = None, logicalPathInfix: identifierDotAttribute | None = None, *
|
|
88
|
+
def getLogicalPath(identifierPackage: str | None = None, logicalPathInfix: identifierDotAttribute | None = None, *identifierModule: str | None) -> identifierDotAttribute:
|
|
89
89
|
"""Get logical path from components."""
|
|
90
90
|
listLogicalPathParts: list[str] = []
|
|
91
91
|
if identifierPackage:
|
|
92
92
|
listLogicalPathParts.append(identifierPackage)
|
|
93
93
|
if logicalPathInfix:
|
|
94
94
|
listLogicalPathParts.append(logicalPathInfix)
|
|
95
|
-
if
|
|
96
|
-
listLogicalPathParts.extend([module for module in
|
|
95
|
+
if identifierModule:
|
|
96
|
+
listLogicalPathParts.extend([module for module in identifierModule if module is not None])
|
|
97
97
|
return '.'.join(listLogicalPathParts)
|
|
98
98
|
|
|
99
|
-
def getModule(identifierPackage: str | None = packageSettings.identifierPackage, logicalPathInfix: identifierDotAttribute | None = logicalPathInfixDEFAULT,
|
|
99
|
+
def getModule(identifierPackage: str | None = packageSettings.identifierPackage, logicalPathInfix: identifierDotAttribute | None = logicalPathInfixDEFAULT, identifierModule: str | None = identifierModuleSourceAlgorithmDEFAULT) -> ast.Module:
|
|
100
100
|
"""Get Module."""
|
|
101
|
-
logicalPathSourceModule: identifierDotAttribute = getLogicalPath(identifierPackage, logicalPathInfix,
|
|
101
|
+
logicalPathSourceModule: identifierDotAttribute = getLogicalPath(identifierPackage, logicalPathInfix, identifierModule)
|
|
102
102
|
astModule: ast.Module = parseLogicalPath2astModule(logicalPathSourceModule)
|
|
103
103
|
return astModule
|
|
104
104
|
|
|
105
|
-
def getPathFilename(pathRoot: PathLike[str] | PurePath | None = packageSettings.pathPackage, logicalPathInfix:
|
|
105
|
+
def getPathFilename(pathRoot: PathLike[str] | PurePath | None = packageSettings.pathPackage, logicalPathInfix: identifierDotAttribute | None = None, identifierModule: str = '', fileExtension: str = packageSettings.fileExtension) -> PurePath:
|
|
106
106
|
"""Construct filesystem path from logical path.
|
|
107
107
|
|
|
108
108
|
Parameters
|
|
109
109
|
----------
|
|
110
110
|
pathRoot : PathLike[str] | PurePath | None = packageSettings.pathPackage
|
|
111
111
|
Base directory for the package structure.
|
|
112
|
-
logicalPathInfix :
|
|
113
|
-
|
|
112
|
+
logicalPathInfix : identifierDotAttribute | None = None
|
|
113
|
+
Logical path in dot notation.
|
|
114
114
|
moduleIdentifier : str = ''
|
|
115
115
|
Name of the specific module file.
|
|
116
116
|
fileExtension : str = packageSettings.fileExtension
|
|
@@ -122,7 +122,7 @@ def getPathFilename(pathRoot: PathLike[str] | PurePath | None = packageSettings.
|
|
|
122
122
|
Complete filesystem path for the generated module file.
|
|
123
123
|
|
|
124
124
|
"""
|
|
125
|
-
pathFilename = PurePath(
|
|
125
|
+
pathFilename = PurePath(identifierModule + fileExtension)
|
|
126
126
|
if logicalPathInfix:
|
|
127
127
|
pathFilename = PurePath(*(str(logicalPathInfix).split('.')), pathFilename)
|
|
128
128
|
if pathRoot:
|
|
@@ -34,7 +34,7 @@ from mapFolding.someAssemblyRequired import DeReConstructField2ast, IfThis, Shat
|
|
|
34
34
|
import ast
|
|
35
35
|
import dataclasses
|
|
36
36
|
|
|
37
|
-
def shatter_dataclassesDOTdataclass(
|
|
37
|
+
def shatter_dataclassesDOTdataclass(logicalPathDataclass: identifierDotAttribute, identifierDataclass: str, identifierDataclassInstance: str) -> ShatteredDataclass:
|
|
38
38
|
"""Decompose a dataclass definition into AST components for manipulation and code generation.
|
|
39
39
|
|
|
40
40
|
(AI generated docstring)
|
|
@@ -77,19 +77,19 @@ def shatter_dataclassesDOTdataclass(logicalPathModule: identifierDotAttribute, d
|
|
|
77
77
|
Official_fieldOrder: list[str] = []
|
|
78
78
|
dictionaryDeReConstruction: dict[str, DeReConstructField2ast] = {}
|
|
79
79
|
|
|
80
|
-
dataclassClassDef: ast.ClassDef | None = extractClassDef(parseLogicalPath2astModule(
|
|
80
|
+
dataclassClassDef: ast.ClassDef | None = extractClassDef(parseLogicalPath2astModule(logicalPathDataclass), identifierDataclass)
|
|
81
81
|
if not dataclassClassDef:
|
|
82
|
-
message = f"I could not find `{
|
|
82
|
+
message = f"I could not find `{identifierDataclass = }` in `{logicalPathDataclass = }`."
|
|
83
83
|
raise ValueError(message)
|
|
84
84
|
|
|
85
85
|
countingVariable = None
|
|
86
|
-
for aField in dataclasses.fields(importLogicalPath2Identifier(
|
|
86
|
+
for aField in dataclasses.fields(importLogicalPath2Identifier(logicalPathDataclass, identifierDataclass)): # pyright: ignore [reportArgumentType]
|
|
87
87
|
Official_fieldOrder.append(aField.name)
|
|
88
|
-
dictionaryDeReConstruction[aField.name] = DeReConstructField2ast(
|
|
88
|
+
dictionaryDeReConstruction[aField.name] = DeReConstructField2ast(logicalPathDataclass, dataclassClassDef, identifierDataclassInstance, aField)
|
|
89
89
|
if aField.metadata.get('theCountingIdentifier', False):
|
|
90
90
|
countingVariable = dictionaryDeReConstruction[aField.name].name
|
|
91
91
|
if countingVariable is None:
|
|
92
|
-
message = f"I could not find the counting variable in `{
|
|
92
|
+
message = f"I could not find the counting variable in `{identifierDataclass = }` in `{logicalPathDataclass = }`."
|
|
93
93
|
raise ValueError(message)
|
|
94
94
|
|
|
95
95
|
shatteredDataclass = ShatteredDataclass(
|
|
@@ -105,11 +105,11 @@ def shatter_dataclassesDOTdataclass(logicalPathModule: identifierDotAttribute, d
|
|
|
105
105
|
map_stateDOTfield2Name={dictionaryDeReConstruction[field].ast_nameDOTname: dictionaryDeReConstruction[field].astName for field in Official_fieldOrder},
|
|
106
106
|
)
|
|
107
107
|
shatteredDataclass.fragments4AssignmentOrParameters = Make.Tuple(shatteredDataclass.listName4Parameters, ast.Store())
|
|
108
|
-
shatteredDataclass.repack = Make.Assign([Make.Name(
|
|
108
|
+
shatteredDataclass.repack = Make.Assign([Make.Name(identifierDataclassInstance)], value=Make.Call(Make.Name(identifierDataclass), list_keyword=shatteredDataclass.list_keyword_field__field4init))
|
|
109
109
|
shatteredDataclass.signatureReturnAnnotation = Make.Subscript(Make.Name('tuple'), Make.Tuple(shatteredDataclass.listAnnotations))
|
|
110
110
|
|
|
111
111
|
shatteredDataclass.imports.update(*(dictionaryDeReConstruction[field].ledger for field in Official_fieldOrder))
|
|
112
|
-
shatteredDataclass.imports.addImportFrom_asStr(
|
|
112
|
+
shatteredDataclass.imports.addImportFrom_asStr(logicalPathDataclass, identifierDataclass)
|
|
113
113
|
|
|
114
114
|
return shatteredDataclass
|
|
115
115
|
|
|
@@ -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
|
|
@@ -58,7 +58,7 @@ def filterAsymmetricFolds(leafBelow: Array1DLeavesTotal) -> None:
|
|
|
58
58
|
global concurrencyManager, queueFutures
|
|
59
59
|
queueFutures.put_nowait(raiseIfNone(concurrencyManager).submit(_filterAsymmetricFolds, leafBelow.copy()))
|
|
60
60
|
|
|
61
|
-
def
|
|
61
|
+
def getSymmetricFoldsTotal() -> int:
|
|
62
62
|
global concurrencyManager, queueFutures, processingThread
|
|
63
63
|
raiseIfNone(concurrencyManager).shutdown(wait=True)
|
|
64
64
|
queueFutures.put(None)
|
|
@@ -58,28 +58,13 @@ def _filterAsymmetricFolds(leafBelow: Array1DLeavesTotal) -> int:
|
|
|
58
58
|
indexDistance += 1
|
|
59
59
|
return groupsOfFolds
|
|
60
60
|
|
|
61
|
-
def
|
|
61
|
+
def filterAsymmetricFolds(leafBelow: Array1DLeavesTotal) -> None:
|
|
62
62
|
queueFutures.put_nowait(leafBelow.copy())
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
# @numba.jit(numba.int64(numba.int64[:]), cache=True, error_model='numpy', fastmath=True)
|
|
66
|
-
def filterAsymmetricFolds(leafBelow: Array1DLeavesTotal) -> int: # non-blocking submission
|
|
67
|
-
# Must not block caller; enqueue for background processing
|
|
68
|
-
_go(leafBelow)
|
|
69
|
-
return 60 # GO
|
|
70
|
-
|
|
71
|
-
def _stop() -> DatatypeFoldsTotal:
|
|
64
|
+
def getSymmetricFoldsTotal() -> DatatypeFoldsTotal:
|
|
72
65
|
global listThreads # noqa: PLW0602
|
|
73
|
-
# Signal all workers to stop after queue drained
|
|
74
66
|
for _thread in listThreads:
|
|
75
67
|
queueFutures.put(sentinelStop) # pyright: ignore[reportArgumentType]
|
|
76
68
|
for thread in listThreads:
|
|
77
69
|
thread.join()
|
|
78
70
|
return groupsOfFoldsTotal
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
@numba.jit(numba.uint64(), cache=True, error_model='numpy', fastmath=True, forceobj=True)
|
|
83
|
-
def getAsymmetricFoldsTotal() -> DatatypeFoldsTotal:
|
|
84
|
-
total = _stop()
|
|
85
|
-
return total
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from mapFolding.dataBaskets import (
|
|
2
|
-
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal
|
|
3
|
-
|
|
4
|
-
from mapFolding.syntheticModules.
|
|
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
|
|
5
7
|
from numba import jit
|
|
6
8
|
|
|
7
|
-
@unRePackDataclassAsynchronous
|
|
8
9
|
@jit(cache=True, error_model='numpy', fastmath=True, forceinline=True)
|
|
9
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]:
|
|
10
11
|
while leaf1ndex > 4:
|
|
@@ -45,8 +46,34 @@ def count(groupsOfFolds: DatatypeFoldsTotal, gap1ndex: DatatypeElephino, gap1nde
|
|
|
45
46
|
leafAbove[leafBelow[leaf1ndex]] = leaf1ndex
|
|
46
47
|
gapRangeStart[leaf1ndex] = gap1ndex
|
|
47
48
|
leaf1ndex += 1
|
|
48
|
-
else:
|
|
49
|
-
groupsOfFolds = getAsymmetricFoldsTotal()
|
|
50
|
-
groupsOfFolds *= 2
|
|
51
|
-
groupsOfFolds = (groupsOfFolds + 1) // 2
|
|
52
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
|
|
@@ -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:
|
|
@@ -66,4 +67,9 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
66
67
|
else:
|
|
67
68
|
state.groupsOfFolds *= 2
|
|
68
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)
|
|
69
75
|
return state
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from mapFolding.dataBaskets import (
|
|
2
|
-
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal
|
|
3
|
-
|
|
2
|
+
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal,
|
|
3
|
+
MapFoldingState)
|
|
4
|
+
from mapFolding.syntheticModules.A007822.initializeState import transitionOnGroupsOfFolds
|
|
4
5
|
from numba import jit
|
|
5
6
|
|
|
6
|
-
@unRePackDataclassA007822
|
|
7
7
|
@jit(cache=True, error_model='numpy', fastmath=True, forceinline=True)
|
|
8
8
|
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]:
|
|
9
9
|
while leaf1ndex > 4:
|
|
@@ -66,3 +66,28 @@ def count(groupsOfFolds: DatatypeFoldsTotal, gap1ndex: DatatypeElephino, gap1nde
|
|
|
66
66
|
groupsOfFolds *= 2
|
|
67
67
|
groupsOfFolds = (groupsOfFolds + 1) // 2
|
|
68
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:
|
|
@@ -60,4 +61,9 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
60
61
|
else:
|
|
61
62
|
state.groupsOfFolds *= 2
|
|
62
63
|
state.groupsOfFolds = (state.groupsOfFolds + 1) // 2
|
|
63
|
-
return state
|
|
64
|
+
return state
|
|
65
|
+
|
|
66
|
+
def doTheNeedful(state: MapFoldingState) -> MapFoldingState:
|
|
67
|
+
state = transitionOnGroupsOfFolds(state)
|
|
68
|
+
state = count(state)
|
|
69
|
+
return state
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
from mapFolding.dataBaskets import
|
|
2
|
-
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal,
|
|
3
|
-
MapFoldingState)
|
|
1
|
+
from mapFolding.dataBaskets import Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal, MapFoldingState
|
|
4
2
|
from numba import jit
|
|
5
3
|
|
|
6
4
|
@jit(cache=True, error_model='numpy', fastmath=True, forceinline=True)
|
|
@@ -74,4 +72,4 @@ def doTheNeedful(state: MapFoldingState) -> MapFoldingState:
|
|
|
74
72
|
leavesTotal: DatatypeLeavesTotal = state.leavesTotal
|
|
75
73
|
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)
|
|
76
74
|
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)
|
|
77
|
-
return state
|
|
75
|
+
return state
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
from mapFolding.dataBaskets import
|
|
2
|
-
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal,
|
|
3
|
-
MapFoldingState)
|
|
1
|
+
from mapFolding.dataBaskets import Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal, MapFoldingState
|
|
4
2
|
from mapFolding.syntheticModules.theorem2Numba import count
|
|
5
3
|
|
|
6
4
|
def sequential(state: MapFoldingState) -> MapFoldingState:
|
|
@@ -23,6 +21,6 @@ def sequential(state: MapFoldingState) -> MapFoldingState:
|
|
|
23
21
|
connectionGraph: Array3DLeavesTotal = state.connectionGraph
|
|
24
22
|
dimensionsTotal: DatatypeLeavesTotal = state.dimensionsTotal
|
|
25
23
|
leavesTotal: DatatypeLeavesTotal = state.leavesTotal
|
|
26
|
-
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)
|
|
27
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)
|
|
28
|
-
return state
|
|
26
|
+
return state
|
|
@@ -1,53 +1,43 @@
|
|
|
1
|
-
from mapFolding.algorithms.matrixMeandersBeDry import areIntegersWide,
|
|
1
|
+
from mapFolding.algorithms.matrixMeandersBeDry import (areIntegersWide,
|
|
2
|
+
walkDyckPath)
|
|
2
3
|
from mapFolding.dataBaskets import MatrixMeandersNumPyState
|
|
3
4
|
|
|
4
|
-
def outfitDictionaryBitGroups(state: MatrixMeandersNumPyState) -> dict[tuple[int, int], int]:
|
|
5
|
-
"""Outfit `dictionaryBitGroups` so it may manage the computations for one iteration of the transfer matrix.
|
|
6
|
-
|
|
7
|
-
Parameters
|
|
8
|
-
----------
|
|
9
|
-
state : MatrixMeandersState
|
|
10
|
-
The current state of the computation, including `dictionaryMeanders`.
|
|
11
|
-
|
|
12
|
-
Returns
|
|
13
|
-
-------
|
|
14
|
-
dictionaryBitGroups : dict[tuple[int, int], int]
|
|
15
|
-
A dictionary of `(bitsAlpha, bitsZulu)` to `crossings`.
|
|
16
|
-
"""
|
|
17
|
-
state.bitWidth = max(state.dictionaryMeanders.keys()).bit_length()
|
|
18
|
-
return {(arcCode & state.locatorBits, arcCode >> 1 & state.locatorBits): crossings for arcCode, crossings in state.dictionaryMeanders.items()}
|
|
19
5
|
|
|
20
6
|
def countBigInt(state: MatrixMeandersNumPyState) -> MatrixMeandersNumPyState:
|
|
21
7
|
"""Count meanders with matrix transfer algorithm using Python `int` (*int*eger) contained in a Python `dict` (*dict*ionary).
|
|
22
8
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
Parameters
|
|
10
|
+
----------
|
|
11
|
+
state : MatrixMeandersState
|
|
12
|
+
The algorithm state.
|
|
27
13
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
while state.
|
|
35
|
-
state.
|
|
36
|
-
|
|
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()
|
|
37
24
|
state.dictionaryMeanders = {}
|
|
38
|
-
for
|
|
25
|
+
for arcCode, crossings in dictionaryArcCodeToCrossings.items():
|
|
26
|
+
bitsAlpha: int = arcCode & state.locatorBits
|
|
27
|
+
bitsZulu: int = arcCode >> 1 & state.locatorBits
|
|
39
28
|
bitsAlphaHasArcs: bool = bitsAlpha > 1
|
|
40
29
|
bitsZuluHasArcs: bool = bitsZulu > 1
|
|
41
|
-
bitsAlphaIsEven =
|
|
30
|
+
bitsAlphaIsEven: int = bitsAlpha & 1 ^ 1
|
|
31
|
+
bitsZuluIsEven: int = bitsZulu & 1 ^ 1
|
|
42
32
|
arcCodeAnalysis = (bitsAlpha | bitsZulu << 1) << 2 | 3
|
|
43
33
|
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
44
34
|
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
45
35
|
if bitsAlphaHasArcs:
|
|
46
|
-
arcCodeAnalysis = bitsAlpha >> 2 | bitsZulu << 3 |
|
|
36
|
+
arcCodeAnalysis = bitsAlpha >> 2 | bitsZulu << 3 | bitsAlphaIsEven << 1
|
|
47
37
|
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
48
38
|
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
49
39
|
if bitsZuluHasArcs:
|
|
50
|
-
arcCodeAnalysis = bitsZulu >> 1 | bitsAlpha << 2 |
|
|
40
|
+
arcCodeAnalysis = bitsZulu >> 1 | bitsAlpha << 2 | bitsZuluIsEven
|
|
51
41
|
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
52
42
|
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
53
43
|
if bitsAlphaHasArcs and bitsZuluHasArcs and (bitsAlphaIsEven or bitsZuluIsEven):
|
|
@@ -58,5 +48,5 @@ def countBigInt(state: MatrixMeandersNumPyState) -> MatrixMeandersNumPyState:
|
|
|
58
48
|
arcCodeAnalysis: int = bitsZulu >> 2 << 1 | bitsAlpha >> 2
|
|
59
49
|
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
60
50
|
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
61
|
-
|
|
51
|
+
dictionaryArcCodeToCrossings = {}
|
|
62
52
|
return state
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from mapFolding.dataBaskets import MapFoldingState
|
|
2
|
+
from mapFolding.syntheticModules.initializeState import transitionOnGroupsOfFolds
|
|
2
3
|
|
|
3
4
|
def count(state: MapFoldingState) -> MapFoldingState:
|
|
4
5
|
while state.leaf1ndex > 4:
|
|
@@ -47,4 +48,9 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
47
48
|
state.leaf1ndex += 1
|
|
48
49
|
else:
|
|
49
50
|
state.groupsOfFolds *= 2
|
|
51
|
+
return state
|
|
52
|
+
|
|
53
|
+
def doTheNeedful(state: MapFoldingState) -> MapFoldingState:
|
|
54
|
+
state = transitionOnGroupsOfFolds(state)
|
|
55
|
+
state = count(state)
|
|
50
56
|
return state
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
from mapFolding.dataBaskets import
|
|
2
|
-
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal)
|
|
1
|
+
from mapFolding.dataBaskets import Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal
|
|
3
2
|
from numba import jit
|
|
4
3
|
|
|
5
4
|
@jit(cache=True, error_model='numpy', fastmath=True, forceinline=True)
|
|
6
|
-
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]:
|
|
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, connectionGraph: Array3DLeavesTotal, dimensionsTotal: DatatypeLeavesTotal, leavesTotal: DatatypeLeavesTotal) -> tuple[DatatypeFoldsTotal, DatatypeElephino, DatatypeElephino, DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeElephino, DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal, Array1DLeavesTotal, Array1DElephino, Array1DLeavesTotal, Array1DLeavesTotal, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal]:
|
|
7
6
|
while leaf1ndex > 4:
|
|
8
7
|
if leafBelow[0] == 1:
|
|
9
8
|
if leaf1ndex > leavesTotal:
|
|
@@ -24,6 +23,12 @@ def count(groupsOfFolds: DatatypeFoldsTotal, gap1ndex: DatatypeElephino, gap1nde
|
|
|
24
23
|
countDimensionsGapped[leafConnectee] += 1
|
|
25
24
|
leafConnectee = connectionGraph[indexDimension, leaf1ndex, leafBelow[leafConnectee]]
|
|
26
25
|
indexDimension += 1
|
|
26
|
+
if not dimensionsUnconstrained:
|
|
27
|
+
indexLeaf = 0
|
|
28
|
+
while indexLeaf < leaf1ndex:
|
|
29
|
+
gapsWhere[gap1ndexCeiling] = indexLeaf
|
|
30
|
+
gap1ndexCeiling += 1
|
|
31
|
+
indexLeaf += 1
|
|
27
32
|
indexMiniGap = gap1ndex
|
|
28
33
|
while indexMiniGap < gap1ndexCeiling:
|
|
29
34
|
gapsWhere[gap1ndex] = gapsWhere[indexMiniGap]
|
|
@@ -44,4 +49,4 @@ def count(groupsOfFolds: DatatypeFoldsTotal, gap1ndex: DatatypeElephino, gap1nde
|
|
|
44
49
|
leaf1ndex += 1
|
|
45
50
|
else:
|
|
46
51
|
groupsOfFolds *= 2
|
|
47
|
-
return (groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal)
|
|
52
|
+
return (groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from mapFolding.dataBaskets import MapFoldingState
|
|
2
|
+
from mapFolding.syntheticModules.initializeState import transitionOnGroupsOfFolds
|
|
2
3
|
|
|
3
4
|
def count(state: MapFoldingState) -> MapFoldingState:
|
|
4
5
|
while state.leaf1ndex > 4:
|
|
@@ -41,4 +42,9 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
41
42
|
state.leaf1ndex += 1
|
|
42
43
|
else:
|
|
43
44
|
state.groupsOfFolds *= 2
|
|
45
|
+
return state
|
|
46
|
+
|
|
47
|
+
def doTheNeedful(state: MapFoldingState, /) -> MapFoldingState:
|
|
48
|
+
state = transitionOnGroupsOfFolds(state)
|
|
49
|
+
state = count(state)
|
|
44
50
|
return state
|
|
@@ -40,7 +40,7 @@ import pytest
|
|
|
40
40
|
if __name__ == '__main__':
|
|
41
41
|
multiprocessing.set_start_method('spawn')
|
|
42
42
|
|
|
43
|
-
@pytest.mark.parametrize('flow', ['algorithm', 'asynchronous', 'asynchronousTrimmed', 'numba', 'theorem2', 'theorem2Numba', 'theorem2Trimmed'])
|
|
43
|
+
@pytest.mark.parametrize('flow', ['algorithm', 'asynchronous', 'asynchronousTheorem2', 'asynchronousTrimmed', 'numba', 'theorem2', 'theorem2Numba', 'theorem2Trimmed'])
|
|
44
44
|
def test_A007822(flow: str) -> None:
|
|
45
45
|
"""Test A007822 flow options.
|
|
46
46
|
|
|
@@ -21,6 +21,8 @@ def transformOEISidByFormula(pathFilenameSource: Path) -> None:
|
|
|
21
21
|
functionOf: str = 'Error during transformation' # The value of `functionOf` is in the docstring of function `oeisID` in `pathFilenameSource`.
|
|
22
22
|
|
|
23
23
|
for oeisID, FunctionDef in dictionaryFunctionDef.items():
|
|
24
|
+
if not oeisID.startswith('A') or not oeisID[1:7].isdigit():
|
|
25
|
+
continue
|
|
24
26
|
dictionary = dictionaryOEISMapFolding if oeisID in dictionaryOEISMapFolding else dictionaryOEIS
|
|
25
27
|
functionOf = raiseIfNone(ast.get_docstring(FunctionDef))
|
|
26
28
|
|