mapFolding 0.11.2__py3-none-any.whl → 0.11.4__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 +0 -13
- mapFolding/basecamp.py +2 -3
- mapFolding/beDRY.py +2 -145
- mapFolding/datatypes.py +0 -3
- mapFolding/oeis.py +0 -3
- mapFolding/someAssemblyRequired/RecipeJob.py +14 -121
- mapFolding/someAssemblyRequired/{Z0Z_makeSomeModules.py → Z0Z_makeAllModules.py} +109 -114
- mapFolding/someAssemblyRequired/__init__.py +4 -30
- mapFolding/someAssemblyRequired/_toolIfThis.py +7 -8
- mapFolding/someAssemblyRequired/_toolkitContainers.py +9 -129
- mapFolding/someAssemblyRequired/infoBooth.py +20 -0
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +17 -18
- mapFolding/someAssemblyRequired/toolkitNumba.py +4 -46
- mapFolding/someAssemblyRequired/transformationTools.py +11 -181
- mapFolding/theSSOT.py +9 -4
- {mapfolding-0.11.2.dist-info → mapfolding-0.11.4.dist-info}/METADATA +1 -4
- {mapfolding-0.11.2.dist-info → mapfolding-0.11.4.dist-info}/RECORD +24 -27
- {mapfolding-0.11.2.dist-info → mapfolding-0.11.4.dist-info}/WHEEL +1 -1
- tests/conftest.py +2 -77
- tests/test_computations.py +11 -18
- tests/test_tasks.py +2 -1
- mapFolding/infoBooth.py +0 -96
- mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +0 -315
- mapFolding/syntheticModules/numbaCount.py +0 -202
- mapFolding/theDao.py +0 -243
- {mapfolding-0.11.2.dist-info → mapfolding-0.11.4.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.11.2.dist-info → mapfolding-0.11.4.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.11.2.dist-info → mapfolding-0.11.4.dist-info}/top_level.txt +0 -0
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
from
|
|
2
|
-
from astToolkit import ClassIsAndAttribute, extractClassDef
|
|
3
|
-
from mapFolding import raiseIfNoneGitHubIssueNumber3, The
|
|
4
|
-
from mapFolding.someAssemblyRequired import (
|
|
5
|
-
ast_Identifier,
|
|
1
|
+
from astToolkit import (
|
|
6
2
|
astModuleToIngredientsFunction,
|
|
7
3
|
Be,
|
|
4
|
+
ClassIsAndAttribute,
|
|
8
5
|
DOT,
|
|
6
|
+
extractClassDef,
|
|
9
7
|
extractFunctionDef,
|
|
10
8
|
Grab,
|
|
11
|
-
IfThis,
|
|
12
9
|
IngredientsFunction,
|
|
13
10
|
IngredientsModule,
|
|
14
|
-
inlineFunctionDef,
|
|
15
11
|
LedgerOfImports,
|
|
16
12
|
Make,
|
|
17
13
|
NodeChanger,
|
|
18
14
|
NodeTourist,
|
|
19
15
|
parseLogicalPath2astModule,
|
|
20
16
|
parsePathFilename2astModule,
|
|
21
|
-
removeUnusedParameters,
|
|
22
17
|
str_nameDOTname,
|
|
23
18
|
Then,
|
|
24
|
-
|
|
19
|
+
)
|
|
20
|
+
from astToolkit.transformationTools import inlineFunctionDef, removeUnusedParameters, write_astModule
|
|
21
|
+
from collections.abc import Sequence
|
|
22
|
+
from mapFolding import packageSettings
|
|
23
|
+
from mapFolding.someAssemblyRequired import (
|
|
25
24
|
DeReConstructField2ast,
|
|
25
|
+
IfThis,
|
|
26
|
+
raiseIfNoneGitHubIssueNumber3,
|
|
26
27
|
ShatteredDataclass,
|
|
28
|
+
sourceCallableDispatcherHARDCODED,
|
|
27
29
|
)
|
|
30
|
+
from mapFolding.someAssemblyRequired.infoBooth import algorithmSourceModuleHARDCODED, dataPackingModuleIdentifierHARDCODED, logicalPathInfixHARDCODED, sourceCallableIdentifierHARDCODED, theCountingIdentifierHARDCODED
|
|
28
31
|
from mapFolding.someAssemblyRequired.toolkitNumba import decorateCallableWithNumba, parametersNumbaLight
|
|
29
32
|
from mapFolding.someAssemblyRequired.transformationTools import (
|
|
30
33
|
removeDataclassFromFunction,
|
|
@@ -35,28 +38,25 @@ from pathlib import PurePath
|
|
|
35
38
|
from Z0Z_tools import importLogicalPath2Callable
|
|
36
39
|
import ast
|
|
37
40
|
import dataclasses
|
|
41
|
+
from os import PathLike
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
def _getPathFilename(pathRoot: PathLike[str] | PurePath | None = packageSettings.pathPackage
|
|
44
|
+
, logicalPathInfix: PathLike[str] | PurePath | str | None = None
|
|
45
|
+
, moduleIdentifier: str = '', fileExtension: str = packageSettings.fileExtension) -> PurePath:
|
|
46
|
+
pathFilename = PurePath(moduleIdentifier + fileExtension)
|
|
47
|
+
if logicalPathInfix:
|
|
48
|
+
pathFilename = PurePath(logicalPathInfix, pathFilename)
|
|
49
|
+
if pathRoot:
|
|
50
|
+
pathFilename = PurePath(pathRoot, pathFilename)
|
|
51
|
+
return pathFilename
|
|
48
52
|
|
|
53
|
+
def makeInitializeGroupsOfFolds(moduleIdentifier: str, callableIdentifier: str, logicalPathInfix: PathLike[str] | PurePath | str | None = None) -> None:
|
|
49
54
|
algorithmSourceModule = algorithmSourceModuleHARDCODED
|
|
50
55
|
sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
|
|
51
|
-
logicalPathSourceModule = '.'.join([
|
|
52
|
-
|
|
53
|
-
callableIdentifier = callableIdentifierHARDCODED
|
|
54
|
-
logicalPathInfix = logicalPathInfixHARDCODED
|
|
55
|
-
moduleIdentifier = moduleIdentifierHARDCODED
|
|
56
|
+
logicalPathSourceModule = '.'.join([packageSettings.packageName, algorithmSourceModule])
|
|
56
57
|
|
|
57
58
|
astModule = parseLogicalPath2astModule(logicalPathSourceModule)
|
|
58
|
-
countInitializeIngredients = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule)
|
|
59
|
-
, LedgerOfImports(astModule))
|
|
59
|
+
countInitializeIngredients = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
|
|
60
60
|
|
|
61
61
|
countInitializeIngredients.astFunctionDef.name = callableIdentifier
|
|
62
62
|
|
|
@@ -64,37 +64,35 @@ def makeInitializeGroupsOfFolds() -> None:
|
|
|
64
64
|
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
65
65
|
theCountingIdentifier = theCountingIdentifierHARDCODED
|
|
66
66
|
|
|
67
|
-
findThis = IfThis.
|
|
67
|
+
findThis = IfThis.isWhileAttributeNamespaceIdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
68
68
|
doThat = Grab.testAttribute(Grab.andDoAllOf([ Grab.opsAttribute(Then.replaceWith([ast.Eq()])), Grab.leftAttribute(Grab.attrAttribute(Then.replaceWith(theCountingIdentifier))) ])) # type: ignore
|
|
69
69
|
NodeChanger(findThis, doThat).visit(countInitializeIngredients.astFunctionDef.body[0])
|
|
70
70
|
|
|
71
71
|
ingredientsModule = IngredientsModule(countInitializeIngredients)
|
|
72
72
|
|
|
73
|
-
pathFilename =
|
|
74
|
-
|
|
75
|
-
write_astModule(ingredientsModule, pathFilename, The.packageName)
|
|
73
|
+
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier + packageSettings.fileExtension)
|
|
76
74
|
|
|
77
|
-
|
|
78
|
-
moduleIdentifierHARDCODED: ast_Identifier = 'daoOfMapFolding'
|
|
75
|
+
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
79
76
|
|
|
77
|
+
def makeDaoOfMapFolding(moduleIdentifier: str, callableIdentifier: str | None = None
|
|
78
|
+
, logicalPathInfix: PathLike[str] | PurePath | str | None = None
|
|
79
|
+
, sourceCallableDispatcher: str | None = None) -> PurePath:
|
|
80
80
|
algorithmSourceModule = algorithmSourceModuleHARDCODED
|
|
81
81
|
sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
moduleIdentifier = moduleIdentifierHARDCODED
|
|
82
|
+
if callableIdentifier is None:
|
|
83
|
+
callableIdentifier = sourceCallableIdentifier
|
|
84
|
+
logicalPathSourceModule = '.'.join([packageSettings.packageName, algorithmSourceModule])
|
|
86
85
|
|
|
87
86
|
astModule = parseLogicalPath2astModule(logicalPathSourceModule)
|
|
88
|
-
|
|
89
|
-
, LedgerOfImports(astModule))
|
|
87
|
+
ingredientsFunction = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
|
|
90
88
|
|
|
91
|
-
dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(
|
|
89
|
+
dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
92
90
|
if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
|
|
93
|
-
dataclass_Identifier:
|
|
91
|
+
dataclass_Identifier: str | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
|
|
94
92
|
if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
95
93
|
|
|
96
94
|
dataclassLogicalPathModule = None
|
|
97
|
-
for moduleWithLogicalPath, listNameTuples in
|
|
95
|
+
for moduleWithLogicalPath, listNameTuples in ingredientsFunction.imports.dictionaryImportFrom.items():
|
|
98
96
|
for nameTuple in listNameTuples:
|
|
99
97
|
if nameTuple[0] == dataclass_Identifier:
|
|
100
98
|
dataclassLogicalPathModule = moduleWithLogicalPath
|
|
@@ -102,54 +100,50 @@ def makeDaoOfMapFolding() -> PurePath:
|
|
|
102
100
|
if dataclassLogicalPathModule:
|
|
103
101
|
break
|
|
104
102
|
if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
|
|
105
|
-
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(
|
|
103
|
+
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
106
104
|
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
107
105
|
shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
|
|
108
106
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
# findThis = be.Return
|
|
112
|
-
# doThat = Then.insertThisAbove([doubleTheCount])
|
|
113
|
-
# NodeChanger(findThis, doThat).visit(daoOfMapFolding.astFunctionDef)
|
|
107
|
+
ingredientsFunction.imports.update(shatteredDataclass.imports)
|
|
108
|
+
ingredientsFunction = removeDataclassFromFunction(ingredientsFunction, shatteredDataclass)
|
|
114
109
|
|
|
115
|
-
|
|
116
|
-
daoOfMapFolding = removeDataclassFromFunction(daoOfMapFolding, shatteredDataclass)
|
|
110
|
+
ingredientsFunction = removeUnusedParameters(ingredientsFunction)
|
|
117
111
|
|
|
118
|
-
|
|
112
|
+
ingredientsFunction = decorateCallableWithNumba(ingredientsFunction, parametersNumbaLight)
|
|
119
113
|
|
|
120
|
-
|
|
114
|
+
ingredientsModule = IngredientsModule(ingredientsFunction)
|
|
121
115
|
|
|
122
|
-
|
|
116
|
+
if sourceCallableDispatcher is not None:
|
|
123
117
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
ast.Return()
|
|
118
|
+
ingredientsFunctionDispatcher: IngredientsFunction = astModuleToIngredientsFunction(astModule, sourceCallableDispatcher)
|
|
119
|
+
ingredientsFunctionDispatcher.imports.update(shatteredDataclass.imports)
|
|
120
|
+
targetCallableIdentifier = ingredientsFunction.astFunctionDef.name
|
|
121
|
+
ingredientsFunctionDispatcher = unpackDataclassCallFunctionRepackDataclass(ingredientsFunctionDispatcher, targetCallableIdentifier, shatteredDataclass)
|
|
122
|
+
astTuple: ast.Tuple | None = NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(ingredientsFunction.astFunctionDef) # type: ignore
|
|
123
|
+
if astTuple is None: raise raiseIfNoneGitHubIssueNumber3
|
|
124
|
+
astTuple.ctx = ast.Store()
|
|
132
125
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
126
|
+
findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCall_Identifier(targetCallableIdentifier))
|
|
127
|
+
doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), astTuple.elts)))
|
|
128
|
+
changeAssignCallToTarget = NodeChanger(findThis, doThat)
|
|
129
|
+
changeAssignCallToTarget.visit(ingredientsFunctionDispatcher.astFunctionDef)
|
|
130
|
+
|
|
131
|
+
ingredientsModule.appendIngredientsFunction(ingredientsFunctionDispatcher)
|
|
137
132
|
|
|
138
|
-
ingredientsModule = IngredientsModule([daoOfMapFolding, doTheNeedful])
|
|
139
133
|
ingredientsModule.removeImportFromModule('numpy')
|
|
140
134
|
|
|
141
|
-
pathFilename =
|
|
135
|
+
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier + packageSettings.fileExtension)
|
|
142
136
|
|
|
143
|
-
write_astModule(ingredientsModule, pathFilename,
|
|
137
|
+
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
144
138
|
|
|
145
139
|
return pathFilename
|
|
146
140
|
|
|
147
141
|
def makeDaoOfMapFoldingParallel() -> PurePath:
|
|
148
|
-
moduleIdentifierHARDCODED:
|
|
142
|
+
moduleIdentifierHARDCODED: str = 'countParallel'
|
|
149
143
|
|
|
150
144
|
algorithmSourceModule = algorithmSourceModuleHARDCODED
|
|
151
145
|
sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
|
|
152
|
-
logicalPathSourceModule = '.'.join([
|
|
146
|
+
logicalPathSourceModule = '.'.join([packageSettings.packageName, algorithmSourceModule])
|
|
153
147
|
|
|
154
148
|
logicalPathInfix = logicalPathInfixHARDCODED
|
|
155
149
|
moduleIdentifier = moduleIdentifierHARDCODED
|
|
@@ -159,7 +153,7 @@ def makeDaoOfMapFoldingParallel() -> PurePath:
|
|
|
159
153
|
|
|
160
154
|
dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
161
155
|
if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
|
|
162
|
-
dataclass_Identifier:
|
|
156
|
+
dataclass_Identifier: str | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
|
|
163
157
|
if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
164
158
|
|
|
165
159
|
dataclassLogicalPathModule = None
|
|
@@ -181,8 +175,8 @@ def makeDaoOfMapFoldingParallel() -> PurePath:
|
|
|
181
175
|
dataclassFieldsParallel = dataclasses.fields(importLogicalPath2Callable(dataclassLogicalPathModule, dataclass_IdentifierParallel)) # pyright: ignore [reportArgumentType]
|
|
182
176
|
onlyParallelFields = [field for field in dataclassFieldsParallel if field.name not in [fieldBase.name for fieldBase in dataclassBaseFields]]
|
|
183
177
|
|
|
184
|
-
Official_fieldOrder: list[
|
|
185
|
-
dictionaryDeReConstruction: dict[
|
|
178
|
+
Official_fieldOrder: list[str] = []
|
|
179
|
+
dictionaryDeReConstruction: dict[str, DeReConstructField2ast] = {}
|
|
186
180
|
|
|
187
181
|
dataclassClassDef = extractClassDef(parseLogicalPath2astModule(dataclassLogicalPathModule), dataclass_IdentifierParallel)
|
|
188
182
|
if not isinstance(dataclassClassDef, ast.ClassDef): raise ValueError(f"I could not find `{dataclass_IdentifierParallel = }` in `{dataclassLogicalPathModule = }`.")
|
|
@@ -242,7 +236,7 @@ def makeDaoOfMapFoldingParallel() -> PurePath:
|
|
|
242
236
|
ingredientsFunction = decorateCallableWithNumba(ingredientsFunction, parametersNumbaLight)
|
|
243
237
|
|
|
244
238
|
# Start unpack/repack the dataclass function ================================================
|
|
245
|
-
sourceCallableIdentifier =
|
|
239
|
+
sourceCallableIdentifier = sourceCallableDispatcherHARDCODED
|
|
246
240
|
|
|
247
241
|
unRepackDataclass: IngredientsFunction = astModuleToIngredientsFunction(astModule, sourceCallableIdentifier)
|
|
248
242
|
unRepackDataclass.astFunctionDef.name = 'unRepack' + dataclass_IdentifierParallel
|
|
@@ -293,58 +287,59 @@ def makeDaoOfMapFoldingParallel() -> PurePath:
|
|
|
293
287
|
)
|
|
294
288
|
ingredientsModule.removeImportFromModule('numpy')
|
|
295
289
|
|
|
296
|
-
pathFilename =
|
|
290
|
+
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier + packageSettings.fileExtension)
|
|
297
291
|
|
|
298
|
-
write_astModule(ingredientsModule, pathFilename,
|
|
292
|
+
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
299
293
|
return pathFilename
|
|
300
294
|
|
|
301
|
-
def makeTheorem2(
|
|
302
|
-
|
|
303
|
-
|
|
295
|
+
def makeTheorem2(moduleIdentifier: str, callableIdentifier: str | None = None
|
|
296
|
+
, logicalPathInfix: PathLike[str] | PurePath | str | None = None
|
|
297
|
+
, sourceCallableDispatcher: str | None = None) -> PurePath:
|
|
304
298
|
algorithmSourceModule = algorithmSourceModuleHARDCODED
|
|
305
299
|
sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
moduleIdentifier = moduleIdentifierHARDCODED
|
|
300
|
+
if callableIdentifier is None:
|
|
301
|
+
callableIdentifier = sourceCallableIdentifier
|
|
302
|
+
logicalPathSourceModule = '.'.join([packageSettings.packageName, algorithmSourceModule])
|
|
310
303
|
|
|
311
304
|
astModule = parseLogicalPath2astModule(logicalPathSourceModule)
|
|
312
|
-
|
|
313
|
-
, LedgerOfImports(astModule))
|
|
305
|
+
ingredientsFunction = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
|
|
314
306
|
|
|
315
|
-
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(
|
|
307
|
+
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
316
308
|
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
317
309
|
|
|
318
|
-
findThis = IfThis.
|
|
310
|
+
findThis = IfThis.isWhileAttributeNamespaceIdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
319
311
|
doThat = Grab.testAttribute(Grab.comparatorsAttribute(Then.replaceWith([Make.Constant(4)]))) # type: ignore
|
|
320
|
-
NodeChanger(findThis, doThat).visit(
|
|
312
|
+
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
321
313
|
|
|
322
|
-
findThis = IfThis.
|
|
314
|
+
findThis = IfThis.isIfAttributeNamespaceIdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
323
315
|
doThat = Then.extractIt(DOT.body)
|
|
324
|
-
insertLeaf = NodeTourist(findThis, doThat).captureLastMatch(
|
|
325
|
-
findThis = IfThis.
|
|
316
|
+
insertLeaf = NodeTourist(findThis, doThat).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
317
|
+
findThis = IfThis.isIfAttributeNamespaceIdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
326
318
|
doThat = Then.replaceWith(insertLeaf)
|
|
327
|
-
NodeChanger(findThis, doThat).visit(
|
|
319
|
+
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
328
320
|
|
|
329
|
-
findThis = IfThis.
|
|
321
|
+
findThis = IfThis.isAttributeNamespaceIdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
330
322
|
doThat = Then.removeIt
|
|
331
|
-
NodeChanger(findThis, doThat).visit(
|
|
323
|
+
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
332
324
|
|
|
333
|
-
findThis = IfThis.
|
|
325
|
+
findThis = IfThis.isAttributeNamespaceIdentifierLessThanOrEqual0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
334
326
|
doThat = Then.removeIt
|
|
335
|
-
NodeChanger(findThis, doThat).visit(
|
|
327
|
+
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
336
328
|
|
|
337
329
|
theCountingIdentifier = theCountingIdentifierHARDCODED
|
|
338
330
|
doubleTheCount = Make.AugAssign(Make.Attribute(ast.Name(dataclassInstanceIdentifier), theCountingIdentifier), ast.Mult(), Make.Constant(2))
|
|
339
331
|
findThis = Be.Return
|
|
340
332
|
doThat = Then.insertThisAbove([doubleTheCount])
|
|
341
|
-
NodeChanger(findThis, doThat).visit(
|
|
333
|
+
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
334
|
+
|
|
335
|
+
ingredientsModule = IngredientsModule(ingredientsFunction)
|
|
342
336
|
|
|
343
|
-
|
|
337
|
+
if sourceCallableDispatcher is not None:
|
|
338
|
+
raise NotImplementedError('sourceCallableDispatcher is not implemented yet')
|
|
344
339
|
|
|
345
|
-
pathFilename =
|
|
340
|
+
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier + packageSettings.fileExtension)
|
|
346
341
|
|
|
347
|
-
write_astModule(ingredientsModule, pathFilename,
|
|
342
|
+
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
348
343
|
|
|
349
344
|
return pathFilename
|
|
350
345
|
|
|
@@ -365,11 +360,11 @@ def trimTheorem2(pathFilenameSource: PurePath) -> PurePath:
|
|
|
365
360
|
|
|
366
361
|
pathFilename = pathFilenameSource.with_stem(pathFilenameSource.stem + 'Trimmed')
|
|
367
362
|
|
|
368
|
-
write_astModule(ingredientsModule, pathFilename,
|
|
363
|
+
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
369
364
|
|
|
370
365
|
logicalPath: list[str] = []
|
|
371
|
-
if
|
|
372
|
-
logicalPath.append(
|
|
366
|
+
if packageSettings.packageName:
|
|
367
|
+
logicalPath.append(packageSettings.packageName)
|
|
373
368
|
if logicalPathInfix:
|
|
374
369
|
logicalPath.append(logicalPathInfix)
|
|
375
370
|
logicalPath.append(pathFilename.stem)
|
|
@@ -385,7 +380,7 @@ def numbaOnTheorem2(pathFilenameSource: PurePath) -> ast.ImportFrom:
|
|
|
385
380
|
countNumbaTheorem2 = astModuleToIngredientsFunction(parsePathFilename2astModule(pathFilenameSource), sourceCallableIdentifier)
|
|
386
381
|
dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(countNumbaTheorem2.astFunctionDef)
|
|
387
382
|
if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
|
|
388
|
-
dataclass_Identifier:
|
|
383
|
+
dataclass_Identifier: str | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
|
|
389
384
|
if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
390
385
|
|
|
391
386
|
dataclassLogicalPathModule = None
|
|
@@ -413,11 +408,11 @@ def numbaOnTheorem2(pathFilenameSource: PurePath) -> ast.ImportFrom:
|
|
|
413
408
|
|
|
414
409
|
pathFilename = pathFilenameSource.with_stem(pathFilenameSource.stem.replace('Trimmed', '') + 'Numba')
|
|
415
410
|
|
|
416
|
-
write_astModule(ingredientsModule, pathFilename,
|
|
411
|
+
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
417
412
|
|
|
418
413
|
logicalPath: list[str] = []
|
|
419
|
-
if
|
|
420
|
-
logicalPath.append(
|
|
414
|
+
if packageSettings.packageName:
|
|
415
|
+
logicalPath.append(packageSettings.packageName)
|
|
421
416
|
if logicalPathInfix:
|
|
422
417
|
logicalPath.append(logicalPathInfix)
|
|
423
418
|
logicalPath.append(pathFilename.stem)
|
|
@@ -428,11 +423,11 @@ def numbaOnTheorem2(pathFilenameSource: PurePath) -> ast.ImportFrom:
|
|
|
428
423
|
return astImportFrom
|
|
429
424
|
|
|
430
425
|
def makeUnRePackDataclass(astImportFrom: ast.ImportFrom) -> None:
|
|
431
|
-
callableIdentifierHARDCODED:
|
|
426
|
+
callableIdentifierHARDCODED: str = 'sequential'
|
|
432
427
|
|
|
433
428
|
algorithmSourceModule = algorithmSourceModuleHARDCODED
|
|
434
|
-
sourceCallableIdentifier =
|
|
435
|
-
logicalPathSourceModule = '.'.join([
|
|
429
|
+
sourceCallableIdentifier = sourceCallableDispatcherHARDCODED
|
|
430
|
+
logicalPathSourceModule = '.'.join([packageSettings.packageName, algorithmSourceModule])
|
|
436
431
|
|
|
437
432
|
logicalPathInfix = logicalPathInfixHARDCODED
|
|
438
433
|
moduleIdentifier = dataPackingModuleIdentifierHARDCODED
|
|
@@ -442,7 +437,7 @@ def makeUnRePackDataclass(astImportFrom: ast.ImportFrom) -> None:
|
|
|
442
437
|
ingredientsFunction.astFunctionDef.name = callableIdentifier
|
|
443
438
|
dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
444
439
|
if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
|
|
445
|
-
dataclass_Identifier:
|
|
440
|
+
dataclass_Identifier: str | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
|
|
446
441
|
if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
447
442
|
|
|
448
443
|
dataclassLogicalPathModule = None
|
|
@@ -476,15 +471,15 @@ def makeUnRePackDataclass(astImportFrom: ast.ImportFrom) -> None:
|
|
|
476
471
|
ingredientsModule = IngredientsModule(ingredientsFunction)
|
|
477
472
|
ingredientsModule.removeImportFromModule('numpy')
|
|
478
473
|
|
|
479
|
-
pathFilename =
|
|
474
|
+
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier + packageSettings.fileExtension)
|
|
480
475
|
|
|
481
|
-
write_astModule(ingredientsModule, pathFilename,
|
|
476
|
+
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
482
477
|
|
|
483
478
|
if __name__ == '__main__':
|
|
484
|
-
makeInitializeGroupsOfFolds()
|
|
485
|
-
pathFilename = makeTheorem2()
|
|
479
|
+
makeInitializeGroupsOfFolds('initializeCount', 'initializeGroupsOfFolds', logicalPathInfixHARDCODED)
|
|
480
|
+
pathFilename = makeTheorem2('theorem2', None, logicalPathInfixHARDCODED)
|
|
486
481
|
pathFilename = trimTheorem2(pathFilename)
|
|
487
482
|
astImportFrom = numbaOnTheorem2(pathFilename)
|
|
488
483
|
makeUnRePackDataclass(astImportFrom)
|
|
489
|
-
pathFilename = makeDaoOfMapFolding()
|
|
484
|
+
pathFilename = makeDaoOfMapFolding('daoOfMapFolding', None, logicalPathInfixHARDCODED, sourceCallableDispatcherHARDCODED)
|
|
490
485
|
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
|
-
IngredientsFunction as IngredientsFunction,
|
|
57
|
-
IngredientsModule as IngredientsModule,
|
|
58
|
-
LedgerOfImports as LedgerOfImports,
|
|
59
|
-
Make as Make,
|
|
60
|
-
NodeChanger as NodeChanger,
|
|
61
|
-
NodeORattribute as NodeORattribute,
|
|
62
|
-
NodeTourist as NodeTourist,
|
|
63
|
-
parseLogicalPath2astModule as parseLogicalPath2astModule,
|
|
64
|
-
parsePathFilename2astModule as parsePathFilename2astModule,
|
|
65
|
-
str_nameDOTname as str_nameDOTname,
|
|
66
|
-
Then as Then,
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
from Z0Z_tools import importLogicalPath2Callable as importLogicalPath2Callable, importPathFilename2Callable as importPathFilename2Callable
|
|
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
|
+
dataclassInstanceIdentifierHardcoded as dataclassInstanceIdentifierHardcoded,
|
|
49
|
+
raiseIfNoneGitHubIssueNumber3 as raiseIfNoneGitHubIssueNumber3,
|
|
50
|
+
sourceCallableDispatcherHARDCODED as sourceCallableDispatcherHARDCODED,
|
|
76
51
|
)
|
|
77
52
|
|
|
78
53
|
from mapFolding.someAssemblyRequired._toolIfThis import IfThis as IfThis
|
|
79
54
|
|
|
80
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 Be, DOT, IfThis as astToolkit_IfThis
|
|
23
23
|
from collections.abc import Callable
|
|
24
|
-
from mapFolding.someAssemblyRequired import ast_Identifier, Be, DOT
|
|
25
24
|
from typing import TypeGuard
|
|
26
25
|
import ast
|
|
27
26
|
|
|
@@ -37,23 +36,23 @@ class IfThis(astToolkit_IfThis):
|
|
|
37
36
|
enabling precise targeting of AST elements for analysis or transformation.
|
|
38
37
|
"""
|
|
39
38
|
@staticmethod
|
|
40
|
-
def
|
|
39
|
+
def isAttributeNamespaceIdentifierGreaterThan0(namespace: str, identifier: str) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
|
|
41
40
|
return lambda node: (Be.Compare(node)
|
|
42
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
|
-
def
|
|
45
|
+
def isIfAttributeNamespaceIdentifierGreaterThan0(namespace: str, identifier: str) -> Callable[[ast.AST], TypeGuard[ast.If] | bool]:
|
|
47
46
|
return lambda node: (Be.If(node)
|
|
48
|
-
and IfThis.
|
|
47
|
+
and IfThis.isAttributeNamespaceIdentifierGreaterThan0(namespace, identifier)(DOT.test(node)))
|
|
49
48
|
|
|
50
49
|
@staticmethod
|
|
51
|
-
def
|
|
50
|
+
def isWhileAttributeNamespaceIdentifierGreaterThan0(namespace: str, identifier: str) -> Callable[[ast.AST], TypeGuard[ast.While] | bool]:
|
|
52
51
|
return lambda node: (Be.While(node)
|
|
53
|
-
and IfThis.
|
|
52
|
+
and IfThis.isAttributeNamespaceIdentifierGreaterThan0(namespace, identifier)(DOT.test(node)))
|
|
54
53
|
|
|
55
54
|
@staticmethod
|
|
56
|
-
def
|
|
55
|
+
def isAttributeNamespaceIdentifierLessThanOrEqual0(namespace: str, identifier: str) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
|
|
57
56
|
return lambda node: (Be.Compare(node)
|
|
58
57
|
and IfThis.isAttributeNamespace_Identifier(namespace, identifier)(DOT.left(node))
|
|
59
58
|
and Be.LtE(node.ops[0]))
|