mapFolding 0.11.1__py3-none-any.whl → 0.11.3__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.
- mapFolding/__init__.py +7 -60
- mapFolding/basecamp.py +15 -13
- mapFolding/beDRY.py +4 -36
- mapFolding/dataBaskets.py +24 -2
- mapFolding/datatypes.py +0 -3
- mapFolding/{toolboxFilesystem.py → filesystemToolkit.py} +3 -3
- mapFolding/oeis.py +3 -5
- mapFolding/someAssemblyRequired/RecipeJob.py +8 -116
- mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py +492 -0
- mapFolding/someAssemblyRequired/__init__.py +5 -31
- mapFolding/someAssemblyRequired/_toolIfThis.py +5 -6
- mapFolding/someAssemblyRequired/{_toolboxContainers.py → _toolkitContainers.py} +6 -127
- mapFolding/someAssemblyRequired/infoBooth.py +70 -0
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +13 -12
- mapFolding/someAssemblyRequired/{toolboxNumba.py → toolkitNumba.py} +2 -44
- mapFolding/someAssemblyRequired/transformationTools.py +16 -174
- mapFolding/syntheticModules/countParallel.py +98 -0
- mapFolding/syntheticModules/dataPacking.py +1 -1
- mapFolding/theSSOT.py +12 -246
- {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/METADATA +16 -11
- mapfolding-0.11.3.dist-info/RECORD +53 -0
- {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/WHEEL +1 -1
- tests/conftest.py +2 -79
- tests/test_computations.py +12 -19
- tests/test_filesystem.py +1 -2
- tests/test_other.py +1 -1
- tests/test_tasks.py +3 -4
- mapFolding/someAssemblyRequired/Z0Z_makeSomeModules.py +0 -325
- mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +0 -314
- mapFolding/syntheticModules/numbaCount.py +0 -201
- mapFolding/theDao.py +0 -243
- mapfolding-0.11.1.dist-info/RECORD +0 -54
- {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
from collections.abc import Sequence
|
|
2
|
+
from astToolkit import (
|
|
3
|
+
ast_Identifier,
|
|
4
|
+
astModuleToIngredientsFunction,
|
|
5
|
+
Be,
|
|
6
|
+
ClassIsAndAttribute,
|
|
7
|
+
DOT,
|
|
8
|
+
extractClassDef,
|
|
9
|
+
extractFunctionDef,
|
|
10
|
+
Grab,
|
|
11
|
+
IngredientsFunction,
|
|
12
|
+
IngredientsModule,
|
|
13
|
+
LedgerOfImports,
|
|
14
|
+
Make,
|
|
15
|
+
NodeChanger,
|
|
16
|
+
NodeTourist,
|
|
17
|
+
parseLogicalPath2astModule,
|
|
18
|
+
parsePathFilename2astModule,
|
|
19
|
+
str_nameDOTname,
|
|
20
|
+
Then,
|
|
21
|
+
)
|
|
22
|
+
from astToolkit.transformationTools import inlineFunctionDef, removeUnusedParameters, write_astModule
|
|
23
|
+
from mapFolding.someAssemblyRequired import (
|
|
24
|
+
DeReConstructField2ast,
|
|
25
|
+
IfThis,
|
|
26
|
+
packageInformation,
|
|
27
|
+
raiseIfNoneGitHubIssueNumber3,
|
|
28
|
+
ShatteredDataclass,
|
|
29
|
+
)
|
|
30
|
+
from mapFolding.someAssemblyRequired.toolkitNumba import decorateCallableWithNumba, parametersNumbaLight
|
|
31
|
+
from mapFolding.someAssemblyRequired.transformationTools import (
|
|
32
|
+
removeDataclassFromFunction,
|
|
33
|
+
shatter_dataclassesDOTdataclass,
|
|
34
|
+
unpackDataclassCallFunctionRepackDataclass,
|
|
35
|
+
)
|
|
36
|
+
from pathlib import PurePath
|
|
37
|
+
from Z0Z_tools import importLogicalPath2Callable
|
|
38
|
+
import ast
|
|
39
|
+
import dataclasses
|
|
40
|
+
|
|
41
|
+
algorithmSourceModuleHARDCODED = 'daoOfMapFolding'
|
|
42
|
+
sourceCallableIdentifierHARDCODED = 'count'
|
|
43
|
+
logicalPathInfixHARDCODED: ast_Identifier = 'syntheticModules'
|
|
44
|
+
theCountingIdentifierHARDCODED: ast_Identifier = 'groupsOfFolds'
|
|
45
|
+
dataPackingModuleIdentifierHARDCODED: ast_Identifier = 'dataPacking'
|
|
46
|
+
|
|
47
|
+
def makeInitializeGroupsOfFolds() -> None:
|
|
48
|
+
callableIdentifierHARDCODED = 'initializeGroupsOfFolds'
|
|
49
|
+
moduleIdentifierHARDCODED: ast_Identifier = 'initializeCount'
|
|
50
|
+
|
|
51
|
+
algorithmSourceModule = algorithmSourceModuleHARDCODED
|
|
52
|
+
sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
|
|
53
|
+
logicalPathSourceModule = '.'.join([packageInformation.packageName, algorithmSourceModule])
|
|
54
|
+
|
|
55
|
+
callableIdentifier = callableIdentifierHARDCODED
|
|
56
|
+
logicalPathInfix = logicalPathInfixHARDCODED
|
|
57
|
+
moduleIdentifier = moduleIdentifierHARDCODED
|
|
58
|
+
|
|
59
|
+
astModule = parseLogicalPath2astModule(logicalPathSourceModule)
|
|
60
|
+
countInitializeIngredients = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule)
|
|
61
|
+
, LedgerOfImports(astModule))
|
|
62
|
+
|
|
63
|
+
countInitializeIngredients.astFunctionDef.name = callableIdentifier
|
|
64
|
+
|
|
65
|
+
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(countInitializeIngredients.astFunctionDef)
|
|
66
|
+
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
67
|
+
theCountingIdentifier = theCountingIdentifierHARDCODED
|
|
68
|
+
|
|
69
|
+
findThis = IfThis.isWhileAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
70
|
+
doThat = Grab.testAttribute(Grab.andDoAllOf([ Grab.opsAttribute(Then.replaceWith([ast.Eq()])), Grab.leftAttribute(Grab.attrAttribute(Then.replaceWith(theCountingIdentifier))) ])) # type: ignore
|
|
71
|
+
NodeChanger(findThis, doThat).visit(countInitializeIngredients.astFunctionDef.body[0])
|
|
72
|
+
|
|
73
|
+
ingredientsModule = IngredientsModule(countInitializeIngredients)
|
|
74
|
+
|
|
75
|
+
pathFilename = PurePath(packageInformation.pathPackage, logicalPathInfix, moduleIdentifier + packageInformation.fileExtension)
|
|
76
|
+
|
|
77
|
+
write_astModule(ingredientsModule, pathFilename, packageInformation.packageName)
|
|
78
|
+
|
|
79
|
+
def makeDaoOfMapFolding() -> PurePath:
|
|
80
|
+
moduleIdentifierHARDCODED: ast_Identifier = 'daoOfMapFolding'
|
|
81
|
+
|
|
82
|
+
algorithmSourceModule = algorithmSourceModuleHARDCODED
|
|
83
|
+
sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
|
|
84
|
+
logicalPathSourceModule = '.'.join([packageInformation.packageName, algorithmSourceModule])
|
|
85
|
+
|
|
86
|
+
logicalPathInfix = logicalPathInfixHARDCODED
|
|
87
|
+
moduleIdentifier = moduleIdentifierHARDCODED
|
|
88
|
+
|
|
89
|
+
astModule = parseLogicalPath2astModule(logicalPathSourceModule)
|
|
90
|
+
daoOfMapFolding = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule)
|
|
91
|
+
, LedgerOfImports(astModule))
|
|
92
|
+
|
|
93
|
+
dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(daoOfMapFolding.astFunctionDef)
|
|
94
|
+
if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
|
|
95
|
+
dataclass_Identifier: ast_Identifier | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
|
|
96
|
+
if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
97
|
+
|
|
98
|
+
dataclassLogicalPathModule = None
|
|
99
|
+
for moduleWithLogicalPath, listNameTuples in daoOfMapFolding.imports.dictionaryImportFrom.items():
|
|
100
|
+
for nameTuple in listNameTuples:
|
|
101
|
+
if nameTuple[0] == dataclass_Identifier:
|
|
102
|
+
dataclassLogicalPathModule = moduleWithLogicalPath
|
|
103
|
+
break
|
|
104
|
+
if dataclassLogicalPathModule:
|
|
105
|
+
break
|
|
106
|
+
if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
|
|
107
|
+
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(daoOfMapFolding.astFunctionDef)
|
|
108
|
+
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
109
|
+
shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
|
|
110
|
+
|
|
111
|
+
# theCountingIdentifier = theCountingIdentifierHARDCODED
|
|
112
|
+
# doubleTheCount = Make.AugAssign(Make.Attribute(ast.Name(dataclassInstanceIdentifier), theCountingIdentifier), ast.Mult(), Make.Constant(2))
|
|
113
|
+
# findThis = be.Return
|
|
114
|
+
# doThat = Then.insertThisAbove([doubleTheCount])
|
|
115
|
+
# NodeChanger(findThis, doThat).visit(daoOfMapFolding.astFunctionDef)
|
|
116
|
+
|
|
117
|
+
daoOfMapFolding.imports.update(shatteredDataclass.imports)
|
|
118
|
+
daoOfMapFolding = removeDataclassFromFunction(daoOfMapFolding, shatteredDataclass)
|
|
119
|
+
|
|
120
|
+
daoOfMapFolding = removeUnusedParameters(daoOfMapFolding)
|
|
121
|
+
|
|
122
|
+
daoOfMapFolding = decorateCallableWithNumba(daoOfMapFolding, parametersNumbaLight)
|
|
123
|
+
|
|
124
|
+
sourceCallableIdentifier = packageInformation.sourceCallableDispatcher
|
|
125
|
+
|
|
126
|
+
doTheNeedful: IngredientsFunction = astModuleToIngredientsFunction(astModule, sourceCallableIdentifier)
|
|
127
|
+
doTheNeedful.imports.update(shatteredDataclass.imports)
|
|
128
|
+
targetCallableIdentifier = daoOfMapFolding.astFunctionDef.name
|
|
129
|
+
doTheNeedful = unpackDataclassCallFunctionRepackDataclass(doTheNeedful, targetCallableIdentifier, shatteredDataclass)
|
|
130
|
+
astTuple: ast.Tuple | None = NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(daoOfMapFolding.astFunctionDef) # type: ignore
|
|
131
|
+
if astTuple is None: raise raiseIfNoneGitHubIssueNumber3
|
|
132
|
+
astTuple.ctx = ast.Store()
|
|
133
|
+
ast.Return()
|
|
134
|
+
|
|
135
|
+
findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCall_Identifier(targetCallableIdentifier))
|
|
136
|
+
doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), astTuple.elts)))
|
|
137
|
+
changeAssignCallToTarget = NodeChanger(findThis, doThat)
|
|
138
|
+
changeAssignCallToTarget.visit(doTheNeedful.astFunctionDef)
|
|
139
|
+
|
|
140
|
+
ingredientsModule = IngredientsModule([daoOfMapFolding, doTheNeedful])
|
|
141
|
+
ingredientsModule.removeImportFromModule('numpy')
|
|
142
|
+
|
|
143
|
+
pathFilename = PurePath(packageInformation.pathPackage, logicalPathInfix, moduleIdentifier + packageInformation.fileExtension)
|
|
144
|
+
|
|
145
|
+
write_astModule(ingredientsModule, pathFilename, packageInformation.packageName)
|
|
146
|
+
|
|
147
|
+
return pathFilename
|
|
148
|
+
|
|
149
|
+
def makeDaoOfMapFoldingParallel() -> PurePath:
|
|
150
|
+
moduleIdentifierHARDCODED: ast_Identifier = 'countParallel'
|
|
151
|
+
|
|
152
|
+
algorithmSourceModule = algorithmSourceModuleHARDCODED
|
|
153
|
+
sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
|
|
154
|
+
logicalPathSourceModule = '.'.join([packageInformation.packageName, algorithmSourceModule])
|
|
155
|
+
|
|
156
|
+
logicalPathInfix = logicalPathInfixHARDCODED
|
|
157
|
+
moduleIdentifier = moduleIdentifierHARDCODED
|
|
158
|
+
|
|
159
|
+
astModule = parseLogicalPath2astModule(logicalPathSourceModule)
|
|
160
|
+
ingredientsFunction = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
|
|
161
|
+
|
|
162
|
+
dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
163
|
+
if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
|
|
164
|
+
dataclass_Identifier: ast_Identifier | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
|
|
165
|
+
if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
166
|
+
|
|
167
|
+
dataclassLogicalPathModule = None
|
|
168
|
+
for moduleWithLogicalPath, listNameTuples in ingredientsFunction.imports.dictionaryImportFrom.items():
|
|
169
|
+
for nameTuple in listNameTuples:
|
|
170
|
+
if nameTuple[0] == dataclass_Identifier:
|
|
171
|
+
dataclassLogicalPathModule = moduleWithLogicalPath
|
|
172
|
+
break
|
|
173
|
+
if dataclassLogicalPathModule:
|
|
174
|
+
break
|
|
175
|
+
if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
|
|
176
|
+
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
177
|
+
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
178
|
+
shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
|
|
179
|
+
|
|
180
|
+
# Start add the parallel state fields to the count function ================================================
|
|
181
|
+
dataclassBaseFields = dataclasses.fields(importLogicalPath2Callable(dataclassLogicalPathModule, dataclass_Identifier)) # pyright: ignore [reportArgumentType]
|
|
182
|
+
dataclass_IdentifierParallel = 'Parallel' + dataclass_Identifier
|
|
183
|
+
dataclassFieldsParallel = dataclasses.fields(importLogicalPath2Callable(dataclassLogicalPathModule, dataclass_IdentifierParallel)) # pyright: ignore [reportArgumentType]
|
|
184
|
+
onlyParallelFields = [field for field in dataclassFieldsParallel if field.name not in [fieldBase.name for fieldBase in dataclassBaseFields]]
|
|
185
|
+
|
|
186
|
+
Official_fieldOrder: list[ast_Identifier] = []
|
|
187
|
+
dictionaryDeReConstruction: dict[ast_Identifier, DeReConstructField2ast] = {}
|
|
188
|
+
|
|
189
|
+
dataclassClassDef = extractClassDef(parseLogicalPath2astModule(dataclassLogicalPathModule), dataclass_IdentifierParallel)
|
|
190
|
+
if not isinstance(dataclassClassDef, ast.ClassDef): raise ValueError(f"I could not find `{dataclass_IdentifierParallel = }` in `{dataclassLogicalPathModule = }`.")
|
|
191
|
+
|
|
192
|
+
for aField in onlyParallelFields:
|
|
193
|
+
Official_fieldOrder.append(aField.name)
|
|
194
|
+
dictionaryDeReConstruction[aField.name] = DeReConstructField2ast(dataclassLogicalPathModule, dataclassClassDef, dataclassInstanceIdentifier, aField)
|
|
195
|
+
|
|
196
|
+
shatteredDataclassParallel = ShatteredDataclass(
|
|
197
|
+
countingVariableAnnotation=shatteredDataclass.countingVariableAnnotation,
|
|
198
|
+
countingVariableName=shatteredDataclass.countingVariableName,
|
|
199
|
+
field2AnnAssign={**shatteredDataclass.field2AnnAssign, **{dictionaryDeReConstruction[field].name: dictionaryDeReConstruction[field].astAnnAssignConstructor for field in Official_fieldOrder}},
|
|
200
|
+
Z0Z_field2AnnAssign={**shatteredDataclass.Z0Z_field2AnnAssign, **{dictionaryDeReConstruction[field].name: dictionaryDeReConstruction[field].Z0Z_hack for field in Official_fieldOrder}},
|
|
201
|
+
list_argAnnotated4ArgumentsSpecification=shatteredDataclass.list_argAnnotated4ArgumentsSpecification + [dictionaryDeReConstruction[field].ast_argAnnotated for field in Official_fieldOrder],
|
|
202
|
+
list_keyword_field__field4init=shatteredDataclass.list_keyword_field__field4init + [dictionaryDeReConstruction[field].ast_keyword_field__field for field in Official_fieldOrder if dictionaryDeReConstruction[field].init],
|
|
203
|
+
listAnnotations=shatteredDataclass.listAnnotations + [dictionaryDeReConstruction[field].astAnnotation for field in Official_fieldOrder],
|
|
204
|
+
listName4Parameters=shatteredDataclass.listName4Parameters + [dictionaryDeReConstruction[field].astName for field in Official_fieldOrder],
|
|
205
|
+
listUnpack=shatteredDataclass.listUnpack + [Make.AnnAssign(dictionaryDeReConstruction[field].astName, dictionaryDeReConstruction[field].astAnnotation, dictionaryDeReConstruction[field].ast_nameDOTname) for field in Official_fieldOrder],
|
|
206
|
+
map_stateDOTfield2Name={**shatteredDataclass.map_stateDOTfield2Name, **{dictionaryDeReConstruction[field].ast_nameDOTname: dictionaryDeReConstruction[field].astName for field in Official_fieldOrder}},
|
|
207
|
+
)
|
|
208
|
+
shatteredDataclassParallel.fragments4AssignmentOrParameters = Make.Tuple(shatteredDataclassParallel.listName4Parameters, ast.Store())
|
|
209
|
+
shatteredDataclassParallel.repack = Make.Assign([Make.Name(dataclassInstanceIdentifier)], value=Make.Call(Make.Name(dataclass_IdentifierParallel), list_keyword=shatteredDataclassParallel.list_keyword_field__field4init))
|
|
210
|
+
shatteredDataclassParallel.signatureReturnAnnotation = Make.Subscript(Make.Name('tuple'), Make.Tuple(shatteredDataclassParallel.listAnnotations))
|
|
211
|
+
|
|
212
|
+
shatteredDataclassParallel.imports.update(*(dictionaryDeReConstruction[field].ledger for field in Official_fieldOrder))
|
|
213
|
+
shatteredDataclassParallel.imports.addImportFrom_asStr(dataclassLogicalPathModule, dataclass_IdentifierParallel)
|
|
214
|
+
shatteredDataclassParallel.imports.update(shatteredDataclass.imports)
|
|
215
|
+
shatteredDataclassParallel.imports.removeImportFrom(dataclassLogicalPathModule, dataclass_Identifier)
|
|
216
|
+
|
|
217
|
+
# End add the parallel state fields to the count function ================================================
|
|
218
|
+
|
|
219
|
+
ingredientsFunction.imports.update(shatteredDataclassParallel.imports)
|
|
220
|
+
ingredientsFunction = removeDataclassFromFunction(ingredientsFunction, shatteredDataclassParallel)
|
|
221
|
+
|
|
222
|
+
# Start add the parallel logic to the count function ================================================
|
|
223
|
+
|
|
224
|
+
findThis = ClassIsAndAttribute.testIs(ast.While, ClassIsAndAttribute.leftIs(ast.Compare, IfThis.isName_Identifier('leafConnectee')))
|
|
225
|
+
doThat = Then.extractIt(DOT.body)
|
|
226
|
+
captureCountGapsCodeBlock: NodeTourist[ast.While, Sequence[ast.stmt]] = NodeTourist(findThis, doThat)
|
|
227
|
+
countGapsCodeBlock = captureCountGapsCodeBlock.captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
228
|
+
if countGapsCodeBlock is None: raise raiseIfNoneGitHubIssueNumber3
|
|
229
|
+
|
|
230
|
+
thisIsMyTaskIndexCodeBlock = ast.If(ast.BoolOp(ast.Or()
|
|
231
|
+
, values=[ast.Compare(ast.Name('leaf1ndex'), ops=[ast.NotEq()], comparators=[ast.Name('taskDivisions')])
|
|
232
|
+
, ast.Compare(ast.BinOp(ast.Name('leafConnectee'), op=ast.Mod(), right=ast.Name('taskDivisions')), ops=[ast.Eq()], comparators=[ast.Name('taskIndex')])])
|
|
233
|
+
, body=list(countGapsCodeBlock[0:-1]))
|
|
234
|
+
|
|
235
|
+
countGapsCodeBlockNew: list[ast.stmt] = [thisIsMyTaskIndexCodeBlock, countGapsCodeBlock[-1]]
|
|
236
|
+
|
|
237
|
+
doThat = Grab.bodyAttribute(Then.replaceWith(countGapsCodeBlockNew))
|
|
238
|
+
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
239
|
+
|
|
240
|
+
# End add the parallel logic to the count function ================================================
|
|
241
|
+
|
|
242
|
+
ingredientsFunction = removeUnusedParameters(ingredientsFunction)
|
|
243
|
+
|
|
244
|
+
ingredientsFunction = decorateCallableWithNumba(ingredientsFunction, parametersNumbaLight)
|
|
245
|
+
|
|
246
|
+
# Start unpack/repack the dataclass function ================================================
|
|
247
|
+
sourceCallableIdentifier = packageInformation.sourceCallableDispatcher
|
|
248
|
+
|
|
249
|
+
unRepackDataclass: IngredientsFunction = astModuleToIngredientsFunction(astModule, sourceCallableIdentifier)
|
|
250
|
+
unRepackDataclass.astFunctionDef.name = 'unRepack' + dataclass_IdentifierParallel
|
|
251
|
+
unRepackDataclass.imports.update(shatteredDataclassParallel.imports)
|
|
252
|
+
findThis = ClassIsAndAttribute.annotationIs(ast.arg, IfThis.isName_Identifier(dataclass_Identifier)) # type: ignore
|
|
253
|
+
doThat = Grab.annotationAttribute(Grab.idAttribute(Then.replaceWith(dataclass_IdentifierParallel))) # type: ignore
|
|
254
|
+
NodeChanger(findThis, doThat).visit(unRepackDataclass.astFunctionDef) # type: ignore
|
|
255
|
+
unRepackDataclass.astFunctionDef.returns = Make.Name(dataclass_IdentifierParallel)
|
|
256
|
+
targetCallableIdentifier = ingredientsFunction.astFunctionDef.name
|
|
257
|
+
unRepackDataclass = unpackDataclassCallFunctionRepackDataclass(unRepackDataclass, targetCallableIdentifier, shatteredDataclassParallel)
|
|
258
|
+
|
|
259
|
+
astTuple: ast.Tuple | None = NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(ingredientsFunction.astFunctionDef) # type: ignore
|
|
260
|
+
if astTuple is None: raise raiseIfNoneGitHubIssueNumber3
|
|
261
|
+
astTuple.ctx = ast.Store()
|
|
262
|
+
findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCall_Identifier(targetCallableIdentifier))
|
|
263
|
+
doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), astTuple.elts)))
|
|
264
|
+
changeAssignCallToTarget = NodeChanger(findThis, doThat)
|
|
265
|
+
changeAssignCallToTarget.visit(unRepackDataclass.astFunctionDef)
|
|
266
|
+
|
|
267
|
+
ingredientsDoTheNeedful: IngredientsFunction = IngredientsFunction(
|
|
268
|
+
astFunctionDef = ast.FunctionDef(name='doTheNeedful'
|
|
269
|
+
, args=ast.arguments(args=[ast.arg('state', annotation=ast.Name(dataclass_IdentifierParallel)), ast.arg('concurrencyLimit', annotation=ast.Name('int'))])
|
|
270
|
+
, body=[ast.Assign(targets=[ast.Name('stateParallel', ctx=ast.Store())], value=ast.Call(func=ast.Name('deepcopy'), args=[ast.Name('state')]))
|
|
271
|
+
, ast.AnnAssign(target=ast.Name('listStatesParallel', ctx=ast.Store()), annotation=ast.Subscript(value=ast.Name('list'), slice=ast.Name(dataclass_IdentifierParallel)), value=ast.BinOp(left=ast.List(elts=[ast.Name('stateParallel')]), op=ast.Mult(), right=ast.Attribute(value=ast.Name('stateParallel'), attr='taskDivisions')), simple=1)
|
|
272
|
+
, ast.AnnAssign(target=ast.Name('groupsOfFoldsTotal', ctx=ast.Store()), annotation=ast.Name('int'), value=ast.Constant(value=0), simple=1)
|
|
273
|
+
|
|
274
|
+
, ast.AnnAssign(target=ast.Name('dictionaryConcurrency', ctx=ast.Store()), annotation=ast.Subscript(value=ast.Name('dict'), slice=ast.Tuple(elts=[ast.Name('int'), ast.Subscript(value=ast.Name('ConcurrentFuture'), slice=ast.Name(dataclass_IdentifierParallel))])), value=ast.Dict(), simple=1)
|
|
275
|
+
, ast.With(items=[ast.withitem(context_expr=ast.Call(func=ast.Name('ProcessPoolExecutor'), args=[ast.Name('concurrencyLimit')]), optional_vars=ast.Name('concurrencyManager', ctx=ast.Store()))]
|
|
276
|
+
, body=[ast.For(target=ast.Name('indexSherpa', ctx=ast.Store()), iter=ast.Call(func=ast.Name('range'), args=[ast.Attribute(value=ast.Name('stateParallel'), attr='taskDivisions')])
|
|
277
|
+
, body=[ast.Assign(targets=[ast.Name('state', ctx=ast.Store())], value=ast.Call(func=ast.Name('deepcopy'), args=[ast.Name('stateParallel')]))
|
|
278
|
+
, ast.Assign(targets=[ast.Attribute(value=ast.Name('state'), attr='taskIndex', ctx=ast.Store())], value=ast.Name('indexSherpa'))
|
|
279
|
+
, ast.Assign(targets=[ast.Subscript(value=ast.Name('dictionaryConcurrency'), slice=ast.Name('indexSherpa'), ctx=ast.Store())], value=ast.Call(func=ast.Attribute(value=ast.Name('concurrencyManager'), attr='submit'), args=[ast.Name(unRepackDataclass.astFunctionDef.name), ast.Name('state')]))])
|
|
280
|
+
, ast.For(target=ast.Name('indexSherpa', ctx=ast.Store()), iter=ast.Call(func=ast.Name('range'), args=[ast.Attribute(value=ast.Name('stateParallel'), attr='taskDivisions')])
|
|
281
|
+
, body=[ast.Assign(targets=[ast.Subscript(value=ast.Name('listStatesParallel'), slice=ast.Name('indexSherpa'), ctx=ast.Store())], value=ast.Call(func=ast.Attribute(value=ast.Subscript(value=ast.Name('dictionaryConcurrency'), slice=ast.Name('indexSherpa')), attr='result')))
|
|
282
|
+
, ast.AugAssign(target=ast.Name('groupsOfFoldsTotal', ctx=ast.Store()), op=ast.Add(), value=ast.Attribute(value=ast.Subscript(value=ast.Name('listStatesParallel'), slice=ast.Name('indexSherpa')), attr='groupsOfFolds'))])])
|
|
283
|
+
|
|
284
|
+
, ast.AnnAssign(target=ast.Name('foldsTotal', ctx=ast.Store()), annotation=ast.Name('int'), value=ast.BinOp(left=ast.Name('groupsOfFoldsTotal'), op=ast.Mult(), right=ast.Attribute(value=ast.Name('stateParallel'), attr='leavesTotal')), simple=1)
|
|
285
|
+
, ast.Return(value=ast.Tuple(elts=[ast.Name('foldsTotal'), ast.Name('listStatesParallel')]))]
|
|
286
|
+
, returns=ast.Subscript(value=ast.Name('tuple'), slice=ast.Tuple(elts=[ast.Name('int'), ast.Subscript(value=ast.Name('list'), slice=ast.Name(dataclass_IdentifierParallel))])))
|
|
287
|
+
, imports = LedgerOfImports(Make.Module([ast.ImportFrom(module='concurrent.futures', names=[ast.alias(name='Future', asname='ConcurrentFuture'), ast.alias(name='ProcessPoolExecutor')], level=0),
|
|
288
|
+
ast.ImportFrom(module='copy', names=[ast.alias(name='deepcopy')], level=0),
|
|
289
|
+
ast.ImportFrom(module='multiprocessing', names=[ast.alias(name='set_start_method', asname='multiprocessing_set_start_method')], level=0),])
|
|
290
|
+
)
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
ingredientsModule = IngredientsModule([ingredientsFunction, unRepackDataclass, ingredientsDoTheNeedful]
|
|
294
|
+
, prologue = Make.Module([ast.If(test=ast.Compare(left=ast.Name('__name__'), ops=[ast.Eq()], comparators=[ast.Constant(value='__main__')]), body=[ast.Expr(value=ast.Call(func=ast.Name('multiprocessing_set_start_method'), args=[ast.Constant(value='spawn')]))])])
|
|
295
|
+
)
|
|
296
|
+
ingredientsModule.removeImportFromModule('numpy')
|
|
297
|
+
|
|
298
|
+
pathFilename = PurePath(packageInformation.pathPackage, logicalPathInfix, moduleIdentifier + packageInformation.fileExtension)
|
|
299
|
+
|
|
300
|
+
write_astModule(ingredientsModule, pathFilename, packageInformation.packageName)
|
|
301
|
+
return pathFilename
|
|
302
|
+
|
|
303
|
+
def makeTheorem2() -> PurePath:
|
|
304
|
+
moduleIdentifierHARDCODED: ast_Identifier = 'theorem2'
|
|
305
|
+
|
|
306
|
+
algorithmSourceModule = algorithmSourceModuleHARDCODED
|
|
307
|
+
sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
|
|
308
|
+
logicalPathSourceModule = '.'.join([packageInformation.packageName, algorithmSourceModule])
|
|
309
|
+
|
|
310
|
+
logicalPathInfix = logicalPathInfixHARDCODED
|
|
311
|
+
moduleIdentifier = moduleIdentifierHARDCODED
|
|
312
|
+
|
|
313
|
+
astModule = parseLogicalPath2astModule(logicalPathSourceModule)
|
|
314
|
+
countTheorem2 = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule)
|
|
315
|
+
, LedgerOfImports(astModule))
|
|
316
|
+
|
|
317
|
+
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(countTheorem2.astFunctionDef)
|
|
318
|
+
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
319
|
+
|
|
320
|
+
findThis = IfThis.isWhileAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
321
|
+
doThat = Grab.testAttribute(Grab.comparatorsAttribute(Then.replaceWith([Make.Constant(4)]))) # type: ignore
|
|
322
|
+
NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
|
|
323
|
+
|
|
324
|
+
findThis = IfThis.isIfAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
325
|
+
doThat = Then.extractIt(DOT.body)
|
|
326
|
+
insertLeaf = NodeTourist(findThis, doThat).captureLastMatch(countTheorem2.astFunctionDef)
|
|
327
|
+
findThis = IfThis.isIfAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
328
|
+
doThat = Then.replaceWith(insertLeaf)
|
|
329
|
+
NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
|
|
330
|
+
|
|
331
|
+
findThis = IfThis.isAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
332
|
+
doThat = Then.removeIt
|
|
333
|
+
NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
|
|
334
|
+
|
|
335
|
+
findThis = IfThis.isAttributeNamespace_IdentifierLessThanOrEqual0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
336
|
+
doThat = Then.removeIt
|
|
337
|
+
NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
|
|
338
|
+
|
|
339
|
+
theCountingIdentifier = theCountingIdentifierHARDCODED
|
|
340
|
+
doubleTheCount = Make.AugAssign(Make.Attribute(ast.Name(dataclassInstanceIdentifier), theCountingIdentifier), ast.Mult(), Make.Constant(2))
|
|
341
|
+
findThis = Be.Return
|
|
342
|
+
doThat = Then.insertThisAbove([doubleTheCount])
|
|
343
|
+
NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
|
|
344
|
+
|
|
345
|
+
ingredientsModule = IngredientsModule(countTheorem2)
|
|
346
|
+
|
|
347
|
+
pathFilename = PurePath(packageInformation.pathPackage, logicalPathInfix, moduleIdentifier + packageInformation.fileExtension)
|
|
348
|
+
|
|
349
|
+
write_astModule(ingredientsModule, pathFilename, packageInformation.packageName)
|
|
350
|
+
|
|
351
|
+
return pathFilename
|
|
352
|
+
|
|
353
|
+
def trimTheorem2(pathFilenameSource: PurePath) -> PurePath:
|
|
354
|
+
logicalPathInfix = logicalPathInfixHARDCODED
|
|
355
|
+
sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
|
|
356
|
+
ingredientsFunction = astModuleToIngredientsFunction(parsePathFilename2astModule(pathFilenameSource), sourceCallableIdentifier)
|
|
357
|
+
|
|
358
|
+
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
359
|
+
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
360
|
+
|
|
361
|
+
findThis = IfThis.isIfUnaryNotAttributeNamespace_Identifier(dataclassInstanceIdentifier, 'dimensionsUnconstrained')
|
|
362
|
+
doThat = Then.removeIt
|
|
363
|
+
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
364
|
+
|
|
365
|
+
ingredientsModule = IngredientsModule(ingredientsFunction)
|
|
366
|
+
ingredientsModule.removeImportFromModule('numpy')
|
|
367
|
+
|
|
368
|
+
pathFilename = pathFilenameSource.with_stem(pathFilenameSource.stem + 'Trimmed')
|
|
369
|
+
|
|
370
|
+
write_astModule(ingredientsModule, pathFilename, packageInformation.packageName)
|
|
371
|
+
|
|
372
|
+
logicalPath: list[str] = []
|
|
373
|
+
if packageInformation.packageName:
|
|
374
|
+
logicalPath.append(packageInformation.packageName)
|
|
375
|
+
if logicalPathInfix:
|
|
376
|
+
logicalPath.append(logicalPathInfix)
|
|
377
|
+
logicalPath.append(pathFilename.stem)
|
|
378
|
+
moduleWithLogicalPath: str_nameDOTname = '.'.join(logicalPath)
|
|
379
|
+
|
|
380
|
+
astImportFrom: ast.ImportFrom = Make.ImportFrom(moduleWithLogicalPath, list_alias=[Make.alias(ingredientsFunction.astFunctionDef.name)])
|
|
381
|
+
|
|
382
|
+
return pathFilename
|
|
383
|
+
|
|
384
|
+
def numbaOnTheorem2(pathFilenameSource: PurePath) -> ast.ImportFrom:
|
|
385
|
+
logicalPathInfix = logicalPathInfixHARDCODED
|
|
386
|
+
sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
|
|
387
|
+
countNumbaTheorem2 = astModuleToIngredientsFunction(parsePathFilename2astModule(pathFilenameSource), sourceCallableIdentifier)
|
|
388
|
+
dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(countNumbaTheorem2.astFunctionDef)
|
|
389
|
+
if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
|
|
390
|
+
dataclass_Identifier: ast_Identifier | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
|
|
391
|
+
if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
392
|
+
|
|
393
|
+
dataclassLogicalPathModule = None
|
|
394
|
+
for moduleWithLogicalPath, listNameTuples in countNumbaTheorem2.imports.dictionaryImportFrom.items():
|
|
395
|
+
for nameTuple in listNameTuples:
|
|
396
|
+
if nameTuple[0] == dataclass_Identifier:
|
|
397
|
+
dataclassLogicalPathModule = moduleWithLogicalPath
|
|
398
|
+
break
|
|
399
|
+
if dataclassLogicalPathModule:
|
|
400
|
+
break
|
|
401
|
+
if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
|
|
402
|
+
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(countNumbaTheorem2.astFunctionDef)
|
|
403
|
+
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
404
|
+
shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
|
|
405
|
+
|
|
406
|
+
countNumbaTheorem2.imports.update(shatteredDataclass.imports)
|
|
407
|
+
countNumbaTheorem2 = removeDataclassFromFunction(countNumbaTheorem2, shatteredDataclass)
|
|
408
|
+
|
|
409
|
+
countNumbaTheorem2 = removeUnusedParameters(countNumbaTheorem2)
|
|
410
|
+
|
|
411
|
+
countNumbaTheorem2 = decorateCallableWithNumba(countNumbaTheorem2, parametersNumbaLight)
|
|
412
|
+
|
|
413
|
+
ingredientsModule = IngredientsModule(countNumbaTheorem2)
|
|
414
|
+
ingredientsModule.removeImportFromModule('numpy')
|
|
415
|
+
|
|
416
|
+
pathFilename = pathFilenameSource.with_stem(pathFilenameSource.stem.replace('Trimmed', '') + 'Numba')
|
|
417
|
+
|
|
418
|
+
write_astModule(ingredientsModule, pathFilename, packageInformation.packageName)
|
|
419
|
+
|
|
420
|
+
logicalPath: list[str] = []
|
|
421
|
+
if packageInformation.packageName:
|
|
422
|
+
logicalPath.append(packageInformation.packageName)
|
|
423
|
+
if logicalPathInfix:
|
|
424
|
+
logicalPath.append(logicalPathInfix)
|
|
425
|
+
logicalPath.append(pathFilename.stem)
|
|
426
|
+
moduleWithLogicalPath: str_nameDOTname = '.'.join(logicalPath)
|
|
427
|
+
|
|
428
|
+
astImportFrom: ast.ImportFrom = Make.ImportFrom(moduleWithLogicalPath, list_alias=[Make.alias(countNumbaTheorem2.astFunctionDef.name)])
|
|
429
|
+
|
|
430
|
+
return astImportFrom
|
|
431
|
+
|
|
432
|
+
def makeUnRePackDataclass(astImportFrom: ast.ImportFrom) -> None:
|
|
433
|
+
callableIdentifierHARDCODED: ast_Identifier = 'sequential'
|
|
434
|
+
|
|
435
|
+
algorithmSourceModule = algorithmSourceModuleHARDCODED
|
|
436
|
+
sourceCallableIdentifier = packageInformation.sourceCallableDispatcher
|
|
437
|
+
logicalPathSourceModule = '.'.join([packageInformation.packageName, algorithmSourceModule])
|
|
438
|
+
|
|
439
|
+
logicalPathInfix = logicalPathInfixHARDCODED
|
|
440
|
+
moduleIdentifier = dataPackingModuleIdentifierHARDCODED
|
|
441
|
+
callableIdentifier = callableIdentifierHARDCODED
|
|
442
|
+
|
|
443
|
+
ingredientsFunction: IngredientsFunction = astModuleToIngredientsFunction(parseLogicalPath2astModule(logicalPathSourceModule), sourceCallableIdentifier)
|
|
444
|
+
ingredientsFunction.astFunctionDef.name = callableIdentifier
|
|
445
|
+
dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
446
|
+
if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
|
|
447
|
+
dataclass_Identifier: ast_Identifier | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
|
|
448
|
+
if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
449
|
+
|
|
450
|
+
dataclassLogicalPathModule = None
|
|
451
|
+
for moduleWithLogicalPath, listNameTuples in ingredientsFunction.imports.dictionaryImportFrom.items():
|
|
452
|
+
for nameTuple in listNameTuples:
|
|
453
|
+
if nameTuple[0] == dataclass_Identifier:
|
|
454
|
+
dataclassLogicalPathModule = moduleWithLogicalPath
|
|
455
|
+
break
|
|
456
|
+
if dataclassLogicalPathModule:
|
|
457
|
+
break
|
|
458
|
+
if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
|
|
459
|
+
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
460
|
+
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
461
|
+
shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
|
|
462
|
+
|
|
463
|
+
ingredientsFunction.imports.update(shatteredDataclass.imports)
|
|
464
|
+
ingredientsFunction.imports.addAst(astImportFrom)
|
|
465
|
+
targetCallableIdentifier = astImportFrom.names[0].name
|
|
466
|
+
ingredientsFunction = unpackDataclassCallFunctionRepackDataclass(ingredientsFunction, targetCallableIdentifier, shatteredDataclass)
|
|
467
|
+
if astImportFrom.module is None: raise raiseIfNoneGitHubIssueNumber3
|
|
468
|
+
targetFunctionDef = extractFunctionDef(parseLogicalPath2astModule(astImportFrom.module), targetCallableIdentifier)
|
|
469
|
+
if targetFunctionDef is None: raise raiseIfNoneGitHubIssueNumber3
|
|
470
|
+
astTuple: ast.Tuple | None = NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(targetFunctionDef) # type: ignore
|
|
471
|
+
if astTuple is None: raise raiseIfNoneGitHubIssueNumber3
|
|
472
|
+
astTuple.ctx = ast.Store()
|
|
473
|
+
|
|
474
|
+
findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCall_Identifier(targetCallableIdentifier))
|
|
475
|
+
doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), astTuple.elts)))
|
|
476
|
+
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
477
|
+
|
|
478
|
+
ingredientsModule = IngredientsModule(ingredientsFunction)
|
|
479
|
+
ingredientsModule.removeImportFromModule('numpy')
|
|
480
|
+
|
|
481
|
+
pathFilename = PurePath(packageInformation.pathPackage, logicalPathInfix, moduleIdentifier + packageInformation.fileExtension)
|
|
482
|
+
|
|
483
|
+
write_astModule(ingredientsModule, pathFilename, packageInformation.packageName)
|
|
484
|
+
|
|
485
|
+
if __name__ == '__main__':
|
|
486
|
+
makeInitializeGroupsOfFolds()
|
|
487
|
+
pathFilename = makeTheorem2()
|
|
488
|
+
pathFilename = trimTheorem2(pathFilename)
|
|
489
|
+
astImportFrom = numbaOnTheorem2(pathFilename)
|
|
490
|
+
makeUnRePackDataclass(astImportFrom)
|
|
491
|
+
pathFilename = makeDaoOfMapFolding()
|
|
492
|
+
makeDaoOfMapFoldingParallel()
|
|
@@ -44,41 +44,15 @@ optimizations - while maintaining the ability to verify correctness at each tran
|
|
|
44
44
|
test suite.
|
|
45
45
|
"""
|
|
46
46
|
|
|
47
|
-
from
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Be as Be,
|
|
52
|
-
DOT as DOT,
|
|
53
|
-
extractClassDef as extractClassDef,
|
|
54
|
-
extractFunctionDef as extractFunctionDef,
|
|
55
|
-
Grab as Grab,
|
|
56
|
-
importLogicalPath2Callable as importLogicalPath2Callable,
|
|
57
|
-
importPathFilename2Callable as importPathFilename2Callable,
|
|
58
|
-
IngredientsFunction as IngredientsFunction,
|
|
59
|
-
IngredientsModule as IngredientsModule,
|
|
60
|
-
LedgerOfImports as LedgerOfImports,
|
|
61
|
-
Make as Make,
|
|
62
|
-
NodeChanger as NodeChanger,
|
|
63
|
-
NodeORattribute as NodeORattribute,
|
|
64
|
-
NodeTourist as NodeTourist,
|
|
65
|
-
parseLogicalPath2astModule as parseLogicalPath2astModule,
|
|
66
|
-
parsePathFilename2astModule as parsePathFilename2astModule,
|
|
67
|
-
str_nameDOTname as str_nameDOTname,
|
|
68
|
-
Then as Then,
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
from astToolkit.transformationTools import (
|
|
72
|
-
inlineFunctionDef as inlineFunctionDef,
|
|
73
|
-
removeUnusedParameters as removeUnusedParameters,
|
|
74
|
-
unparseFindReplace as unparseFindReplace,
|
|
75
|
-
write_astModule as write_astModule,
|
|
47
|
+
from mapFolding.someAssemblyRequired.infoBooth import (
|
|
48
|
+
PackageInformation as PackageInformation,
|
|
49
|
+
raiseIfNoneGitHubIssueNumber3 as raiseIfNoneGitHubIssueNumber3,
|
|
50
|
+
packageInformation as packageInformation,
|
|
76
51
|
)
|
|
77
52
|
|
|
78
53
|
from mapFolding.someAssemblyRequired._toolIfThis import IfThis as IfThis
|
|
79
54
|
|
|
80
|
-
from mapFolding.someAssemblyRequired.
|
|
55
|
+
from mapFolding.someAssemblyRequired._toolkitContainers import (
|
|
81
56
|
DeReConstructField2ast as DeReConstructField2ast,
|
|
82
|
-
RecipeSynthesizeFlow as RecipeSynthesizeFlow,
|
|
83
57
|
ShatteredDataclass as ShatteredDataclass,
|
|
84
58
|
)
|
|
@@ -19,9 +19,8 @@ they implement a declarative approach to AST manipulation that separates node id
|
|
|
19
19
|
(be), and data access (DOT).
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
|
-
from astToolkit import IfThis as astToolkit_IfThis
|
|
22
|
+
from astToolkit import ast_Identifier, Be, DOT, IfThis as astToolkit_IfThis
|
|
23
23
|
from collections.abc import Callable
|
|
24
|
-
from mapFolding.someAssemblyRequired import ast_Identifier, Be
|
|
25
24
|
from typing import TypeGuard
|
|
26
25
|
import ast
|
|
27
26
|
|
|
@@ -39,21 +38,21 @@ class IfThis(astToolkit_IfThis):
|
|
|
39
38
|
@staticmethod
|
|
40
39
|
def isAttributeNamespace_IdentifierGreaterThan0(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
|
|
41
40
|
return lambda node: (Be.Compare(node)
|
|
42
|
-
and IfThis.isAttributeNamespace_Identifier(namespace, identifier)(
|
|
41
|
+
and IfThis.isAttributeNamespace_Identifier(namespace, identifier)(DOT.left(node))
|
|
43
42
|
and Be.Gt(node.ops[0])
|
|
44
43
|
and IfThis.isConstant_value(0)(node.comparators[0]))
|
|
45
44
|
@staticmethod
|
|
46
45
|
def isIfAttributeNamespace_IdentifierGreaterThan0(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.If] | bool]:
|
|
47
46
|
return lambda node: (Be.If(node)
|
|
48
|
-
and IfThis.isAttributeNamespace_IdentifierGreaterThan0(namespace, identifier)(
|
|
47
|
+
and IfThis.isAttributeNamespace_IdentifierGreaterThan0(namespace, identifier)(DOT.test(node)))
|
|
49
48
|
|
|
50
49
|
@staticmethod
|
|
51
50
|
def isWhileAttributeNamespace_IdentifierGreaterThan0(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.While] | bool]:
|
|
52
51
|
return lambda node: (Be.While(node)
|
|
53
|
-
and IfThis.isAttributeNamespace_IdentifierGreaterThan0(namespace, identifier)(
|
|
52
|
+
and IfThis.isAttributeNamespace_IdentifierGreaterThan0(namespace, identifier)(DOT.test(node)))
|
|
54
53
|
|
|
55
54
|
@staticmethod
|
|
56
55
|
def isAttributeNamespace_IdentifierLessThanOrEqual0(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
|
|
57
56
|
return lambda node: (Be.Compare(node)
|
|
58
|
-
and IfThis.isAttributeNamespace_Identifier(namespace, identifier)(
|
|
57
|
+
and IfThis.isAttributeNamespace_Identifier(namespace, identifier)(DOT.left(node))
|
|
59
58
|
and Be.LtE(node.ops[0]))
|