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,30 +1,49 @@
|
|
|
1
1
|
"""addSymmetryCheckAsynchronous."""
|
|
2
|
-
from astToolkit import
|
|
2
|
+
from astToolkit import (
|
|
3
|
+
Be, extractFunctionDef, Grab, identifierDotAttribute, Make, NodeChanger, NodeTourist, parsePathFilename2astModule,
|
|
4
|
+
Then)
|
|
3
5
|
from hunterMakesPy import raiseIfNone
|
|
4
6
|
from mapFolding import packageSettings
|
|
5
|
-
from mapFolding.someAssemblyRequired import
|
|
7
|
+
from mapFolding.someAssemblyRequired import (
|
|
8
|
+
identifierCallableSourceDispatcherDEFAULT, identifierCountingDEFAULT, identifierDataclassInstanceDEFAULT, IfThis,
|
|
9
|
+
logicalPathInfixAlgorithmDEFAULT)
|
|
6
10
|
from mapFolding.someAssemblyRequired.A007822.A007822rawMaterials import (
|
|
7
11
|
A007822adjustFoldsTotal, astExprCall_filterAsymmetricFoldsDataclass, identifier_filterAsymmetricFolds,
|
|
8
12
|
identifierCounting, identifierDataclass, logicalPathInfixA007822, sourceCallableDispatcherA007822,
|
|
9
13
|
sourceCallableIdentifierA007822)
|
|
14
|
+
from mapFolding.someAssemblyRequired.infoBooth import identifierCallableSourceDEFAULT
|
|
10
15
|
from mapFolding.someAssemblyRequired.makingModules_count import makeTheorem2, numbaOnTheorem2, trimTheorem2
|
|
11
|
-
from mapFolding.someAssemblyRequired.toolkitMakeModules import
|
|
12
|
-
|
|
16
|
+
from mapFolding.someAssemblyRequired.toolkitMakeModules import (
|
|
17
|
+
getLogicalPath, getModule, getPathFilename, write_astModule)
|
|
13
18
|
from pathlib import PurePath
|
|
14
19
|
import ast
|
|
15
20
|
|
|
21
|
+
identifier_asynchronous = 'asynchronous'
|
|
22
|
+
identifier_getSymmetricFoldsTotal = 'getSymmetricFoldsTotal'
|
|
16
23
|
identifier_initializeConcurrencyManager = 'initializeConcurrencyManager'
|
|
24
|
+
identifier_processCompletedFutures = '_processCompletedFutures'
|
|
17
25
|
|
|
18
|
-
astExprCall_initializeConcurrencyManager = Make.Expr(Make.Call(Make.Name(identifier_initializeConcurrencyManager)))
|
|
19
|
-
identifier_getAsymmetricFoldsTotal = 'getAsymmetricFoldsTotal'
|
|
26
|
+
astExprCall_initializeConcurrencyManager: ast.Expr = Make.Expr(Make.Call(Make.Name(identifier_initializeConcurrencyManager), listParameters=[Make.Name('maxWorkers')]))
|
|
20
27
|
AssignTotal2CountingIdentifier: ast.Assign = Make.Assign(
|
|
21
28
|
[Make.Attribute(Make.Name(identifierDataclass), identifierCounting, context=Make.Store())]
|
|
22
|
-
, value=Make.Call(Make.Name(
|
|
29
|
+
, value=Make.Call(Make.Name(identifier_getSymmetricFoldsTotal))
|
|
23
30
|
)
|
|
24
|
-
identifier_processCompletedFutures = '_processCompletedFutures'
|
|
25
31
|
|
|
26
|
-
def addSymmetryCheckAsynchronous(astModule: ast.Module,
|
|
27
|
-
"""Add symmetry check to the counting function.
|
|
32
|
+
def addSymmetryCheckAsynchronous(astModule: ast.Module, identifierModule: str, identifierCallable: str | None = None, logicalPathInfix: identifierDotAttribute | None = None, sourceCallableDispatcher: str | None = None) -> PurePath: # noqa: ARG001
|
|
33
|
+
"""Add symmetry check to the counting function.
|
|
34
|
+
|
|
35
|
+
To do asynchronous filtering, a few things must happen.
|
|
36
|
+
1. When the algorithm finds a `groupOfFolds`, the call to `filterAsymmetricFolds` must be non-blocking.
|
|
37
|
+
2. Filtering the `groupOfFolds` into symmetric folds must start immediately, and run concurrently.
|
|
38
|
+
3. When filtering, the module must immediately discard `leafBelow` and sum the filtered folds into a global total.
|
|
39
|
+
4. Of course, the filtering must be complete before `getAsymmetricFoldsTotal` fulfills the request for the total.
|
|
40
|
+
|
|
41
|
+
Why _must_ those things happen?
|
|
42
|
+
1. Filtering takes as long as finding the `groupOfFolds`, so we can't block.
|
|
43
|
+
2. Filtering must start immediately to keep up with the finding process.
|
|
44
|
+
3. To discover A007822(27), which is currently unknown, I estimate there will be 369192702554 calls to filterAsymmetricFolds.
|
|
45
|
+
Each `leafBelow` array will be 28 * 8-bits, so if the queue has only 0.3% of the total calls in it, that is 28 GiB of data.
|
|
46
|
+
"""
|
|
28
47
|
astFunctionDef_count: ast.FunctionDef = raiseIfNone(NodeTourist(
|
|
29
48
|
findThis = Be.FunctionDef.nameIs(IfThis.isIdentifier(sourceCallableIdentifierA007822))
|
|
30
49
|
, doThat = Then.extractIt
|
|
@@ -53,24 +72,26 @@ def addSymmetryCheckAsynchronous(astModule: ast.Module, moduleIdentifier: str, c
|
|
|
53
72
|
).captureLastMatch(astModule))
|
|
54
73
|
|
|
55
74
|
astFunctionDef_doTheNeedful.body.insert(0, astExprCall_initializeConcurrencyManager)
|
|
75
|
+
astFunctionDef_doTheNeedful.args.args.append(Make.arg('maxWorkers', Make.BitOr.join([Make.Name('int'), Make.Constant(None)])))
|
|
76
|
+
astFunctionDef_doTheNeedful.args.defaults.append(Make.Constant(None))
|
|
56
77
|
|
|
57
78
|
NodeChanger(
|
|
58
79
|
findThis=Be.FunctionDef.nameIs(IfThis.isIdentifier(sourceCallableDispatcher))
|
|
59
80
|
, doThat=Then.replaceWith(astFunctionDef_doTheNeedful)
|
|
60
81
|
).visit(astModule)
|
|
61
82
|
|
|
62
|
-
astImportFrom = ast.ImportFrom(
|
|
63
|
-
, [Make.alias(identifier_filterAsymmetricFolds), Make.alias(
|
|
83
|
+
astImportFrom = ast.ImportFrom(getLogicalPath(packageSettings.identifierPackage, logicalPathInfix, identifierModule + 'Annex')
|
|
84
|
+
, [Make.alias(identifier_filterAsymmetricFolds), Make.alias(identifier_getSymmetricFoldsTotal), Make.alias(identifier_initializeConcurrencyManager)], 0)
|
|
64
85
|
|
|
65
86
|
astModule.body.insert(0, astImportFrom)
|
|
66
87
|
|
|
67
|
-
pathFilename: PurePath = getPathFilename(packageSettings.pathPackage, logicalPathInfix,
|
|
68
|
-
pathFilenameAnnex: PurePath = getPathFilename(packageSettings.pathPackage, logicalPathInfix,
|
|
88
|
+
pathFilename: PurePath = getPathFilename(packageSettings.pathPackage, logicalPathInfix, identifierModule)
|
|
89
|
+
pathFilenameAnnex: PurePath = getPathFilename(packageSettings.pathPackage, logicalPathInfix, identifierModule + 'Annex')
|
|
69
90
|
|
|
70
91
|
write_astModule(astModule, pathFilename, packageSettings.identifierPackage)
|
|
71
92
|
del astModule
|
|
72
93
|
# ----------------- Ingredients Module Annex ------------------------------------------------------------------------------
|
|
73
|
-
ImaString = """from concurrent.futures import Future as ConcurrentFuture,
|
|
94
|
+
ImaString = """from concurrent.futures import Future as ConcurrentFuture, ThreadPoolExecutor
|
|
74
95
|
from hunterMakesPy import raiseIfNone
|
|
75
96
|
from mapFolding import Array1DLeavesTotal
|
|
76
97
|
from queue import Empty, Queue
|
|
@@ -90,7 +111,7 @@ queueFutures: Queue[ConcurrentFuture[int]] = Queue()
|
|
|
90
111
|
|
|
91
112
|
ImaString = f"""def {identifier_initializeConcurrencyManager}(maxWorkers: int | None = None, {identifierCounting}: int = 0) -> None:
|
|
92
113
|
global concurrencyManager, queueFutures, {identifierCounting}Total, processingThread
|
|
93
|
-
concurrencyManager =
|
|
114
|
+
concurrencyManager = ThreadPoolExecutor(max_workers=maxWorkers)
|
|
94
115
|
queueFutures = Queue()
|
|
95
116
|
{identifierCounting}Total = {identifierCounting}
|
|
96
117
|
processingThread = Thread(target={identifier_processCompletedFutures})
|
|
@@ -136,8 +157,7 @@ queueFutures: Queue[ConcurrentFuture[int]] = Queue()
|
|
|
136
157
|
ImaSymmetricFold = False
|
|
137
158
|
break
|
|
138
159
|
leafConnectee += 1
|
|
139
|
-
|
|
140
|
-
{identifierCounting} += 1
|
|
160
|
+
{identifierCounting} += ImaSymmetricFold
|
|
141
161
|
indexDistance += 1
|
|
142
162
|
return {identifierCounting}
|
|
143
163
|
"""
|
|
@@ -147,39 +167,93 @@ queueFutures: Queue[ConcurrentFuture[int]] = Queue()
|
|
|
147
167
|
ImaString = f"""
|
|
148
168
|
def {identifier_filterAsymmetricFolds}(leafBelow: Array1DLeavesTotal) -> None:
|
|
149
169
|
global concurrencyManager, queueFutures
|
|
150
|
-
queueFutures.
|
|
170
|
+
queueFutures.put_nowait(raiseIfNone(concurrencyManager).submit(_{identifier_filterAsymmetricFolds}, leafBelow.copy()))
|
|
151
171
|
"""
|
|
152
172
|
astModule.body.append(raiseIfNone(extractFunctionDef(ast.parse(ImaString), identifier_filterAsymmetricFolds)))
|
|
153
173
|
del ImaString
|
|
154
174
|
|
|
155
175
|
ImaString = f"""
|
|
156
|
-
def {
|
|
176
|
+
def {identifier_getSymmetricFoldsTotal}() -> int:
|
|
157
177
|
global concurrencyManager, queueFutures, processingThread
|
|
158
178
|
raiseIfNone(concurrencyManager).shutdown(wait=True)
|
|
159
179
|
queueFutures.put(None)
|
|
160
180
|
raiseIfNone(processingThread).join()
|
|
161
181
|
return {identifierCounting}Total
|
|
162
182
|
"""
|
|
163
|
-
astModule.body.append(raiseIfNone(extractFunctionDef(ast.parse(ImaString),
|
|
183
|
+
astModule.body.append(raiseIfNone(extractFunctionDef(ast.parse(ImaString), identifier_getSymmetricFoldsTotal)))
|
|
164
184
|
del ImaString
|
|
165
|
-
|
|
166
185
|
write_astModule(astModule, pathFilenameAnnex, packageSettings.identifierPackage)
|
|
167
186
|
|
|
168
187
|
return pathFilename
|
|
169
188
|
|
|
189
|
+
def makeAsynchronousNumbaOnTheorem2(astModule: ast.Module, identifierModule: str, identifierCallable: str | None = None, logicalPathInfix: identifierDotAttribute | None = None, sourceCallableDispatcher: str | None = None) -> PurePath:
|
|
190
|
+
"""Make the asynchronous numba on theorem2 module."""
|
|
191
|
+
pathFilename: PurePath = numbaOnTheorem2(astModule, identifierModule, identifierCallable, logicalPathInfix, sourceCallableDispatcher)
|
|
192
|
+
|
|
193
|
+
astModule = parsePathFilename2astModule(pathFilename)
|
|
194
|
+
|
|
195
|
+
listAssignToMove: list[ast.Assign] = []
|
|
196
|
+
|
|
197
|
+
findThis = IfThis.isAnyOf(IfThis.isAssignAndTargets0Is(IfThis.isNameIdentifier(identifierCountingDEFAULT))
|
|
198
|
+
, Be.AugAssign.targetIs(IfThis.isNameIdentifier(identifierCountingDEFAULT)))
|
|
199
|
+
NodeTourist(findThis, Then.appendTo(listAssignToMove)).visit(astModule)
|
|
200
|
+
|
|
201
|
+
NodeChanger(findThis, Then.removeIt).visit(astModule)
|
|
202
|
+
|
|
203
|
+
NodeChanger(
|
|
204
|
+
findThis=Be.Assign.valueIs(IfThis.isCallIdentifier(identifierCallableSourceDEFAULT))
|
|
205
|
+
, doThat=Then.insertThisBelow(listAssignToMove)
|
|
206
|
+
).visit(astModule)
|
|
207
|
+
|
|
208
|
+
write_astModule(astModule, pathFilename, packageSettings.identifierPackage)
|
|
209
|
+
|
|
210
|
+
return pathFilename
|
|
211
|
+
|
|
212
|
+
def makeAsynchronousTheorem2(astModule: ast.Module, identifierModule: str, identifierCallable: str | None = None, logicalPathInfix: identifierDotAttribute | None = None, sourceCallableDispatcher: str | None = None) -> PurePath:
|
|
213
|
+
"""Make the asynchronous theorem2 module."""
|
|
214
|
+
pathFilename: PurePath = makeTheorem2(astModule, identifierModule, identifierCallable, logicalPathInfix, sourceCallableDispatcher)
|
|
215
|
+
|
|
216
|
+
astModule = parsePathFilename2astModule(pathFilename)
|
|
217
|
+
|
|
218
|
+
astAttribute = Make.Attribute(Make.Name(identifierDataclassInstanceDEFAULT), identifierCountingDEFAULT)
|
|
219
|
+
astAssign = Make.Assign([astAttribute], value=Make.Constant(0))
|
|
220
|
+
|
|
221
|
+
NodeChanger[ast.Call, ast.Call](
|
|
222
|
+
findThis = IfThis.isCallIdentifier(identifier_initializeConcurrencyManager)
|
|
223
|
+
, doThat = Grab.argsAttribute(lambda args: [*args, astAttribute]) # pyright: ignore[reportArgumentType]
|
|
224
|
+
).visit(astModule)
|
|
225
|
+
|
|
226
|
+
NodeChanger(
|
|
227
|
+
findThis = Be.Expr.valueIs(IfThis.isCallIdentifier(identifier_initializeConcurrencyManager))
|
|
228
|
+
, doThat = Then.insertThisBelow([astAssign])
|
|
229
|
+
).visit(astModule)
|
|
230
|
+
|
|
231
|
+
identifierAnnex: identifierDotAttribute = getLogicalPath(packageSettings.identifierPackage, logicalPathInfix, identifier_asynchronous + 'Annex')
|
|
232
|
+
identifierAnnexNumba: identifierDotAttribute = identifierAnnex + 'Numba'
|
|
233
|
+
|
|
234
|
+
NodeChanger(
|
|
235
|
+
findThis=Be.ImportFrom.moduleIs(IfThis.isIdentifier(identifierAnnex))
|
|
236
|
+
, doThat=Grab.moduleAttribute(Then.replaceWith(identifierAnnexNumba))
|
|
237
|
+
).visit(astModule)
|
|
238
|
+
|
|
239
|
+
write_astModule(astModule, pathFilename, packageSettings.identifierPackage)
|
|
240
|
+
|
|
241
|
+
return pathFilename
|
|
242
|
+
|
|
170
243
|
def _makeA007822AsynchronousModules() -> None:
|
|
171
244
|
|
|
172
|
-
astModule = getModule(logicalPathInfix=logicalPathInfixAlgorithmDEFAULT)
|
|
173
|
-
pathFilename = addSymmetryCheckAsynchronous(astModule, 'asynchronous', None, logicalPathInfixA007822, sourceCallableDispatcherA007822)
|
|
245
|
+
astModule: ast.Module = getModule(logicalPathInfix=logicalPathInfixAlgorithmDEFAULT)
|
|
246
|
+
pathFilename: PurePath = addSymmetryCheckAsynchronous(astModule, 'asynchronous', None, logicalPathInfixA007822, sourceCallableDispatcherA007822)
|
|
174
247
|
|
|
175
|
-
astModule = getModule(logicalPathInfix=logicalPathInfixA007822,
|
|
176
|
-
pathFilename =
|
|
248
|
+
astModule = getModule(logicalPathInfix=logicalPathInfixA007822, identifierModule='asynchronous')
|
|
249
|
+
pathFilename = makeAsynchronousTheorem2(astModule, 'asynchronousTheorem2', None, logicalPathInfixA007822, identifierCallableSourceDispatcherDEFAULT)
|
|
177
250
|
|
|
178
251
|
astModule = parsePathFilename2astModule(pathFilename)
|
|
179
|
-
pathFilename = trimTheorem2(astModule, 'asynchronousTrimmed', None, logicalPathInfixA007822,
|
|
252
|
+
pathFilename = trimTheorem2(astModule, 'asynchronousTrimmed', None, logicalPathInfixA007822, identifierCallableSourceDispatcherDEFAULT)
|
|
180
253
|
|
|
181
|
-
|
|
182
|
-
|
|
254
|
+
astModule = parsePathFilename2astModule(pathFilename)
|
|
255
|
+
pathFilename = makeAsynchronousNumbaOnTheorem2(astModule, 'asynchronousNumba', None, logicalPathInfixA007822, identifierCallableSourceDispatcherDEFAULT)
|
|
183
256
|
|
|
184
257
|
if __name__ == '__main__':
|
|
185
258
|
_makeA007822AsynchronousModules()
|
|
259
|
+
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"""addSymmetryCheck."""
|
|
2
|
-
from astToolkit import Be, Make, NodeChanger, NodeTourist, parsePathFilename2astModule, Then
|
|
2
|
+
from astToolkit import Be, identifierDotAttribute, Make, NodeChanger, NodeTourist, parsePathFilename2astModule, Then
|
|
3
3
|
from hunterMakesPy import raiseIfNone
|
|
4
4
|
from mapFolding import packageSettings
|
|
5
5
|
from mapFolding.someAssemblyRequired import (
|
|
6
|
-
identifierCallableSourceDEFAULT,
|
|
6
|
+
identifierCallableSourceDEFAULT, identifierCallableSourceDispatcherDEFAULT, identifierCountingDEFAULT,
|
|
7
|
+
identifierDataclassInstanceDEFAULT, IfThis)
|
|
7
8
|
from mapFolding.someAssemblyRequired.A007822.A007822rawMaterials import (
|
|
8
9
|
A007822adjustFoldsTotal, A007822incrementCount, FunctionDef_filterAsymmetricFolds, logicalPathInfixA007822,
|
|
9
10
|
sourceCallableDispatcherA007822, sourceCallableIdentifierA007822)
|
|
10
11
|
from mapFolding.someAssemblyRequired.makingModules_count import (
|
|
11
|
-
|
|
12
|
+
makeMapFoldingNumba, makeTheorem2, numbaOnTheorem2, trimTheorem2)
|
|
12
13
|
from mapFolding.someAssemblyRequired.makingModules_doTheNeedful import makeInitializeState, makeUnRePackDataclass
|
|
13
14
|
from mapFolding.someAssemblyRequired.toolkitMakeModules import (
|
|
14
15
|
getLogicalPath, getModule, getPathFilename, write_astModule)
|
|
@@ -16,7 +17,7 @@ from os import PathLike
|
|
|
16
17
|
from pathlib import PurePath
|
|
17
18
|
import ast
|
|
18
19
|
|
|
19
|
-
def addSymmetryCheck(astModule: ast.Module,
|
|
20
|
+
def addSymmetryCheck(astModule: ast.Module, identifierModule: str, identifierCallable: str | None = None, logicalPathInfix: identifierDotAttribute | None = None, sourceCallableDispatcher: str | None = None) -> PurePath: # noqa: ARG001
|
|
20
21
|
"""Add logic to check for symmetric folds."""
|
|
21
22
|
# NOTE HEY HEY! Are you trying to figure out why there is more than one copy of `filterAsymmetricFolds`? See the TODO NOTE, below.
|
|
22
23
|
|
|
@@ -37,7 +38,7 @@ def addSymmetryCheck(astModule: ast.Module, moduleIdentifier: str, callableIdent
|
|
|
37
38
|
# system to replace the `Ingredients` paradigm.
|
|
38
39
|
NodeChanger(Be.ImportFrom, Then.insertThisBelow([FunctionDef_filterAsymmetricFolds])).visit(astModule)
|
|
39
40
|
|
|
40
|
-
pathFilename: PurePath = getPathFilename(packageSettings.pathPackage, logicalPathInfix,
|
|
41
|
+
pathFilename: PurePath = getPathFilename(packageSettings.pathPackage, logicalPathInfix, identifierModule)
|
|
41
42
|
|
|
42
43
|
write_astModule(astModule, pathFilename, packageSettings.identifierPackage)
|
|
43
44
|
|
|
@@ -47,25 +48,28 @@ def _makeA007822Modules() -> None:
|
|
|
47
48
|
astModule = getModule(logicalPathInfix='algorithms')
|
|
48
49
|
pathFilename = addSymmetryCheck(astModule, 'algorithm', None, logicalPathInfixA007822, None)
|
|
49
50
|
|
|
50
|
-
astModule = getModule(logicalPathInfix=logicalPathInfixA007822,
|
|
51
|
-
pathFilename: PurePath =
|
|
51
|
+
astModule = getModule(logicalPathInfix=logicalPathInfixA007822, identifierModule='algorithm')
|
|
52
|
+
pathFilename: PurePath = makeMapFoldingNumba(astModule, 'algorithmNumba', None, logicalPathInfixA007822, sourceCallableDispatcherA007822)
|
|
52
53
|
|
|
53
54
|
# NOTE I can't handle parallel right now.
|
|
54
55
|
|
|
55
|
-
astModule = getModule(logicalPathInfix=logicalPathInfixA007822,
|
|
56
|
+
astModule = getModule(logicalPathInfix=logicalPathInfixA007822, identifierModule='algorithm')
|
|
56
57
|
makeInitializeState(astModule, 'initializeState', 'transitionOnGroupsOfFolds', logicalPathInfixA007822)
|
|
57
58
|
|
|
58
|
-
astModule = getModule(logicalPathInfix=logicalPathInfixA007822,
|
|
59
|
-
pathFilename = makeTheorem2(astModule, 'theorem2', None, logicalPathInfixA007822,
|
|
59
|
+
astModule = getModule(logicalPathInfix=logicalPathInfixA007822, identifierModule='algorithm')
|
|
60
|
+
pathFilename = makeTheorem2(astModule, 'theorem2', None, logicalPathInfixA007822, identifierCallableSourceDispatcherDEFAULT)
|
|
60
61
|
|
|
61
62
|
astModule = parsePathFilename2astModule(pathFilename)
|
|
62
|
-
pathFilename = trimTheorem2(astModule, 'theorem2Trimmed', None, logicalPathInfixA007822,
|
|
63
|
+
pathFilename = trimTheorem2(astModule, 'theorem2Trimmed', None, logicalPathInfixA007822, identifierCallableSourceDispatcherDEFAULT)
|
|
63
64
|
|
|
64
65
|
astModule = parsePathFilename2astModule(pathFilename)
|
|
65
|
-
pathFilename = numbaOnTheorem2(astModule, 'theorem2Numba', None, logicalPathInfixA007822,
|
|
66
|
+
pathFilename = numbaOnTheorem2(astModule, 'theorem2Numba', None, logicalPathInfixA007822, identifierCallableSourceDispatcherDEFAULT)
|
|
67
|
+
# TODO from mapFolding.syntheticModules.dataPackingA007822 import unRePackDataclass
|
|
68
|
+
# @unRePackDataclass
|
|
66
69
|
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
# TODO Make this decorator.
|
|
71
|
+
# astImportFrom: ast.ImportFrom = Make.ImportFrom(getLogicalPath(packageSettings.identifierPackage, logicalPathInfixA007822, 'theorem2Numba'), list_alias=[Make.alias(sourceCallableIdentifierA007822)])
|
|
72
|
+
# makeUnRePackDataclass(astImportFrom, 'dataPackingA007822')
|
|
69
73
|
|
|
70
74
|
if __name__ == '__main__':
|
|
71
75
|
_makeA007822Modules()
|
|
@@ -4,8 +4,8 @@ from ast import Module
|
|
|
4
4
|
from astToolkit import identifierDotAttribute, parseLogicalPath2astModule
|
|
5
5
|
from mapFolding import (
|
|
6
6
|
DatatypeElephino as TheDatatypeElephino, DatatypeFoldsTotal as TheDatatypeFoldsTotal,
|
|
7
|
-
DatatypeLeavesTotal as TheDatatypeLeavesTotal, getPathFilenameFoldsTotal, getPathRootJobDEFAULT,
|
|
8
|
-
|
|
7
|
+
DatatypeLeavesTotal as TheDatatypeLeavesTotal, getPathFilenameFoldsTotal, getPathRootJobDEFAULT, packageSettings)
|
|
8
|
+
from mapFolding.dataBaskets import MapFoldingState
|
|
9
9
|
from mapFolding.someAssemblyRequired import identifierDataclassInstanceDEFAULT, ShatteredDataclass
|
|
10
10
|
from mapFolding.someAssemblyRequired.transformationTools import shatter_dataclassesDOTdataclass
|
|
11
11
|
from pathlib import Path, PurePosixPath
|
|
@@ -33,7 +33,8 @@ from astToolkit import (
|
|
|
33
33
|
NodeChanger, NodeTourist, Then)
|
|
34
34
|
from astToolkit.transformationTools import write_astModule
|
|
35
35
|
from hunterMakesPy import autoDecodingRLE, raiseIfNone
|
|
36
|
-
from mapFolding import getPathFilenameFoldsTotal,
|
|
36
|
+
from mapFolding import getPathFilenameFoldsTotal, packageSettings
|
|
37
|
+
from mapFolding.dataBaskets import MapFoldingState
|
|
37
38
|
from mapFolding.someAssemblyRequired import IfThis
|
|
38
39
|
from mapFolding.someAssemblyRequired.RecipeJob import RecipeJobTheorem2
|
|
39
40
|
from mapFolding.someAssemblyRequired.toolkitNumba import decorateCallableWithNumba, parametersNumbaLight, SpicesJobNumba
|
|
@@ -161,9 +162,9 @@ def move_arg2FunctionDefDOTbodyAndAssignInitialValues(ingredientsFunction: Ingre
|
|
|
161
162
|
ImaAnnAssign, elementConstructor = job.shatteredDataclass.Z0Z_field2AnnAssign[ast_arg.arg]
|
|
162
163
|
match elementConstructor:
|
|
163
164
|
case 'scalar':
|
|
164
|
-
cast('ast.Constant', cast('ast.Call', ImaAnnAssign.value).args[0]).value = int(job.state.
|
|
165
|
+
cast('ast.Constant', cast('ast.Call', ImaAnnAssign.value).args[0]).value = int(eval(f"job.state.{ast_arg.arg}")) # noqa: S307
|
|
165
166
|
case 'array':
|
|
166
|
-
dataAsStrRLE: str = autoDecodingRLE(job.state.
|
|
167
|
+
dataAsStrRLE: str = autoDecodingRLE(eval(f"job.state.{ast_arg.arg}"), assumeAddSpaces=True) # noqa: S307
|
|
167
168
|
dataAs_astExpr: ast.expr = cast('ast.Expr', ast.parse(dataAsStrRLE).body[0]).value
|
|
168
169
|
cast('ast.Call', ImaAnnAssign.value).args = [dataAs_astExpr]
|
|
169
170
|
case _:
|
|
@@ -220,7 +221,7 @@ def makeJobNumba(job: RecipeJobTheorem2, spices: SpicesJobNumba) -> None:
|
|
|
220
221
|
listIdentifiersStaticValues: list[str] = listIdentifiersStaticValuesHARDCODED
|
|
221
222
|
for identifier in listIdentifiersStaticValues:
|
|
222
223
|
findThis: Callable[[ast.AST], TypeIs[ast.Name] | bool] = IfThis.isNameIdentifier(identifier)
|
|
223
|
-
doThat: Callable[[ast.Name], ast.Constant] = Then.replaceWith(Make.Constant(int(job.state.
|
|
224
|
+
doThat: Callable[[ast.Name], ast.Constant] = Then.replaceWith(Make.Constant(int(eval(f"job.state.{identifier}")))) # noqa: S307
|
|
224
225
|
NodeChanger(findThis, doThat).visit(ingredientsCount.astFunctionDef)
|
|
225
226
|
|
|
226
227
|
ingredientsModule = IngredientsModule()
|
|
@@ -326,11 +327,11 @@ if __name__ == '__main__':
|
|
|
326
327
|
"""
|
|
327
328
|
|
|
328
329
|
if __name__ == '__main__':
|
|
329
|
-
state = transitionOnGroupsOfFolds(MapFoldingState((
|
|
330
|
+
state = transitionOnGroupsOfFolds(MapFoldingState((2,5)))
|
|
330
331
|
pathModule = PurePosixPath(packageSettings.pathPackage, 'jobs')
|
|
331
332
|
pathFilenameFoldsTotal = PurePosixPath(getPathFilenameFoldsTotal(state.mapShape, pathModule))
|
|
332
333
|
aJob = RecipeJobTheorem2(state, pathModule=pathModule, pathFilenameFoldsTotal=pathFilenameFoldsTotal)
|
|
333
|
-
spices = SpicesJobNumba(useNumbaProgressBar=
|
|
334
|
+
spices = SpicesJobNumba(useNumbaProgressBar=True, parametersNumba=parametersNumbaLight)
|
|
334
335
|
makeJobNumba(aJob, spices)
|
|
335
336
|
|
|
336
337
|
# TODO Improve this module with lessons learned in `makeJobTheorem2codon`.
|
|
@@ -8,10 +8,11 @@ from astToolkit import (
|
|
|
8
8
|
NodeTourist, parseLogicalPath2astModule, Then)
|
|
9
9
|
from astToolkit.transformationTools import removeUnusedParameters, write_astModule
|
|
10
10
|
from hunterMakesPy import autoDecodingRLE, raiseIfNone
|
|
11
|
-
from mapFolding import DatatypeLeavesTotal, getPathFilenameFoldsTotal
|
|
11
|
+
from mapFolding import DatatypeLeavesTotal, getPathFilenameFoldsTotal
|
|
12
|
+
from mapFolding.dataBaskets import MapFoldingState
|
|
12
13
|
from mapFolding.someAssemblyRequired import IfThis
|
|
13
14
|
from mapFolding.someAssemblyRequired.RecipeJob import RecipeJobTheorem2
|
|
14
|
-
from mapFolding.syntheticModules.
|
|
15
|
+
from mapFolding.syntheticModules.A007822.initializeState import transitionOnGroupsOfFolds
|
|
15
16
|
from pathlib import Path, PurePosixPath
|
|
16
17
|
from typing import cast, NamedTuple, TYPE_CHECKING
|
|
17
18
|
import ast
|
|
@@ -102,7 +103,6 @@ def _variableCompatibility(ingredientsFunction: IngredientsFunction, job: Recipe
|
|
|
102
103
|
Be.AugAssign.targetIs(IfThis.isNestedNameIdentifier(identifier))
|
|
103
104
|
, IfThis.isAllOf(
|
|
104
105
|
Be.Assign.targetsIs(Be.at(0, IfThis.isNestedNameIdentifier(identifier)))
|
|
105
|
-
# IfThis.isAssignAndTargets0Is(IfThis.isNameIdentifier(identifier))
|
|
106
106
|
, Be.Assign.valueIs(Be.Constant))
|
|
107
107
|
)
|
|
108
108
|
, doThat=lambda node, annotation=annotation: Grab.valueAttribute(Then.replaceWith(Make.Call(annotation, listParameters=[node.value])))(node)
|
|
@@ -115,7 +115,6 @@ def _variableCompatibility(ingredientsFunction: IngredientsFunction, job: Recipe
|
|
|
115
115
|
|
|
116
116
|
# `identifier` in Comparison.
|
|
117
117
|
NodeChanger(Be.Compare.leftIs(IfThis.isNestedNameIdentifier(identifier))
|
|
118
|
-
# , doThat=Grab.comparatorsAttribute(Grab.index(0, lambda comparator, annotation=annotation: Then.replaceWith(Make.Call(annotation, listParameters=[comparator]))))
|
|
119
118
|
, doThat=lambda node, annotation=annotation: Grab.comparatorsAttribute(lambda at, annotation=annotation: Then.replaceWith([Make.Call(annotation, listParameters=[node.comparators[0]])])(at[0]))(node)
|
|
120
119
|
).visit(ingredientsFunction.astFunctionDef)
|
|
121
120
|
|