mapFolding 0.12.1__py3-none-any.whl → 0.12.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 +46 -20
- mapFolding/_theSSOT.py +81 -0
- mapFolding/_theTypes.py +148 -0
- mapFolding/basecamp.py +62 -47
- mapFolding/beDRY.py +100 -73
- mapFolding/dataBaskets.py +226 -31
- mapFolding/filesystemToolkit.py +161 -107
- mapFolding/oeis.py +388 -174
- mapFolding/reference/flattened.py +1 -1
- mapFolding/someAssemblyRequired/RecipeJob.py +146 -20
- mapFolding/someAssemblyRequired/__init__.py +60 -38
- mapFolding/someAssemblyRequired/_toolIfThis.py +125 -35
- mapFolding/someAssemblyRequired/_toolkitContainers.py +125 -44
- mapFolding/someAssemblyRequired/getLLVMforNoReason.py +35 -26
- mapFolding/someAssemblyRequired/infoBooth.py +37 -2
- mapFolding/someAssemblyRequired/makeAllModules.py +785 -0
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +161 -74
- mapFolding/someAssemblyRequired/toolkitNumba.py +218 -36
- mapFolding/someAssemblyRequired/transformationTools.py +125 -58
- mapfolding-0.12.3.dist-info/METADATA +163 -0
- mapfolding-0.12.3.dist-info/RECORD +53 -0
- {mapfolding-0.12.1.dist-info → mapfolding-0.12.3.dist-info}/WHEEL +1 -1
- tests/__init__.py +28 -44
- tests/conftest.py +66 -61
- tests/test_computations.py +64 -89
- tests/test_filesystem.py +25 -1
- tests/test_oeis.py +37 -7
- tests/test_other.py +29 -2
- tests/test_tasks.py +30 -2
- mapFolding/datatypes.py +0 -18
- mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py +0 -433
- mapFolding/theSSOT.py +0 -34
- mapfolding-0.12.1.dist-info/METADATA +0 -184
- mapfolding-0.12.1.dist-info/RECORD +0 -53
- {mapfolding-0.12.1.dist-info → mapfolding-0.12.3.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.12.1.dist-info → mapfolding-0.12.3.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.12.1.dist-info → mapfolding-0.12.3.dist-info}/top_level.txt +0 -0
|
@@ -1,41 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"""
|
|
2
|
+
Map folding AST transformation system: Specialized job generation and optimization implementation.
|
|
3
|
+
|
|
4
|
+
This module implements the specialized job generation layer of the map folding AST transformation
|
|
5
|
+
system, executing the complete transformation process to convert generic map folding algorithms
|
|
6
|
+
into highly optimized, standalone computation modules. Building upon the configuration orchestration
|
|
7
|
+
established in the recipe system, this module applies the full sequence of transformations from
|
|
8
|
+
pattern recognition through Numba compilation to produce self-contained computational solutions
|
|
9
|
+
optimized for specific map dimensions and calculation contexts.
|
|
10
|
+
|
|
11
|
+
The transformation implementation addresses the computational demands of map folding research where
|
|
12
|
+
calculations can require hours or days to complete. The specialization process converts abstract
|
|
13
|
+
algorithms with flexible parameters into concrete, statically-optimized code that leverages
|
|
14
|
+
just-in-time compilation for maximum performance. Each generated module targets specific map
|
|
15
|
+
shapes and calculation modes, enabling aggressive compiler optimizations based on known constraints
|
|
16
|
+
and embedded constants.
|
|
17
|
+
|
|
18
|
+
The optimization process executes systematic transformations including static value embedding to
|
|
19
|
+
replace parameterized values with compile-time constants, dead code elimination to remove unused
|
|
20
|
+
variables and code paths, parameter internalization to convert function parameters into embedded
|
|
21
|
+
variables, import optimization to replace generic imports with specific implementations, Numba
|
|
22
|
+
decoration with appropriate compilation directives, progress integration for long-running calculations,
|
|
23
|
+
and launcher generation for standalone execution entry points.
|
|
24
|
+
|
|
25
|
+
The resulting modules represent the culmination of the entire AST transformation system, producing
|
|
26
|
+
self-contained Python scripts that execute independently with dramatically improved performance
|
|
27
|
+
compared to original generic algorithms while maintaining mathematical correctness and providing
|
|
28
|
+
essential progress feedback capabilities for large-scale computational research.
|
|
29
|
+
"""
|
|
30
|
+
|
|
3
31
|
from astToolkit import (
|
|
4
|
-
Be,
|
|
5
|
-
|
|
6
|
-
extractFunctionDef,
|
|
7
|
-
IngredientsFunction,
|
|
8
|
-
IngredientsModule,
|
|
9
|
-
LedgerOfImports,
|
|
10
|
-
Make,
|
|
11
|
-
NodeChanger,
|
|
12
|
-
NodeTourist,
|
|
13
|
-
str_nameDOTname,
|
|
14
|
-
Then,
|
|
15
|
-
)
|
|
32
|
+
Be, extractFunctionDef, identifierDotAttribute, IngredientsFunction, IngredientsModule, LedgerOfImports, Make,
|
|
33
|
+
NodeChanger, NodeTourist, Then)
|
|
16
34
|
from astToolkit.transformationTools import write_astModule
|
|
35
|
+
from hunterMakesPy import autoDecodingRLE, raiseIfNone
|
|
36
|
+
from mapFolding import getPathFilenameFoldsTotal, MapFoldingState, packageSettings
|
|
37
|
+
from mapFolding.someAssemblyRequired import IfThis
|
|
17
38
|
from mapFolding.someAssemblyRequired.RecipeJob import RecipeJobTheorem2Numba
|
|
18
39
|
from mapFolding.someAssemblyRequired.toolkitNumba import decorateCallableWithNumba, parametersNumbaLight, SpicesJobNumba
|
|
19
40
|
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds
|
|
20
41
|
from pathlib import PurePosixPath
|
|
21
|
-
from typing import cast, NamedTuple
|
|
22
|
-
from
|
|
42
|
+
from typing import cast, NamedTuple, TYPE_CHECKING
|
|
43
|
+
from typing_extensions import TypeIs
|
|
23
44
|
import ast
|
|
24
|
-
"""Synthesize one file to compute `foldsTotal` of `mapShape`."""
|
|
25
45
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
listIdentifiersNotUsedSequentialHARDCODED = ['foldGroups', 'taskDivisions', 'taskIndex',]
|
|
46
|
+
if TYPE_CHECKING:
|
|
47
|
+
from collections.abc import Callable
|
|
29
48
|
|
|
30
|
-
|
|
49
|
+
# Configuration lists for code optimization and dead code elimination
|
|
50
|
+
listIdentifiersNotUsedAllHARDCODED: list[str] = ['concurrencyLimit', 'foldsTotal', 'mapShape']
|
|
51
|
+
"""Identifiers that are universally unused across all optimization contexts."""
|
|
31
52
|
|
|
32
|
-
|
|
53
|
+
listIdentifiersNotUsedParallelSequentialHARDCODED: list[str] = ['indexLeaf']
|
|
54
|
+
"""Identifiers unused in both parallel and sequential execution modes."""
|
|
33
55
|
|
|
34
|
-
|
|
56
|
+
listIdentifiersNotUsedSequentialHARDCODED: list[str] = ['foldGroups', 'taskDivisions', 'taskIndex']
|
|
57
|
+
"""Identifiers unused specifically in sequential execution mode."""
|
|
58
|
+
|
|
59
|
+
listIdentifiersReplacedHARDCODED: list[str] = ['groupsOfFolds']
|
|
60
|
+
"""Identifiers that get replaced with optimized equivalents during transformation."""
|
|
61
|
+
|
|
62
|
+
listIdentifiersStaticValuesHARDCODED: list[str] = ['dimensionsTotal', 'leavesTotal']
|
|
63
|
+
"""Identifiers with compile-time constant values that can be embedded directly."""
|
|
64
|
+
|
|
65
|
+
listIdentifiersNotUsedHARDCODED: list[str] = listIdentifiersStaticValuesHARDCODED + listIdentifiersReplacedHARDCODED + listIdentifiersNotUsedAllHARDCODED + listIdentifiersNotUsedParallelSequentialHARDCODED + listIdentifiersNotUsedSequentialHARDCODED
|
|
66
|
+
"""Complete list of all identifiers that can be eliminated during optimization."""
|
|
35
67
|
|
|
36
68
|
def addLauncherNumbaProgress(ingredientsModule: IngredientsModule, ingredientsFunction: IngredientsFunction, job: RecipeJobTheorem2Numba, spices: SpicesJobNumba) -> tuple[IngredientsModule, IngredientsFunction]:
|
|
37
|
-
"""
|
|
38
|
-
|
|
69
|
+
"""Add progress tracking capabilities to a Numba-optimized function.
|
|
70
|
+
|
|
71
|
+
(AI generated docstring)
|
|
39
72
|
|
|
40
73
|
This function modifies both the module and the function to integrate Numba-compatible
|
|
41
74
|
progress tracking for long-running calculations. It performs several key transformations:
|
|
@@ -49,14 +82,22 @@ def addLauncherNumbaProgress(ingredientsModule: IngredientsModule, ingredientsFu
|
|
|
49
82
|
which can take hours or days to complete, providing visual feedback and
|
|
50
83
|
estimated completion times.
|
|
51
84
|
|
|
52
|
-
Parameters
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
85
|
+
Parameters
|
|
86
|
+
----------
|
|
87
|
+
ingredientsModule : IngredientsModule
|
|
88
|
+
The module where the function is defined.
|
|
89
|
+
ingredientsFunction : IngredientsFunction
|
|
90
|
+
The function to modify with progress tracking.
|
|
91
|
+
job : RecipeJobTheorem2Numba
|
|
92
|
+
Configuration specifying shape details and output paths.
|
|
93
|
+
spices : SpicesJobNumba
|
|
94
|
+
Configuration specifying progress bar details.
|
|
95
|
+
|
|
96
|
+
Returns
|
|
97
|
+
-------
|
|
98
|
+
moduleAndFunction : tuple[IngredientsModule, IngredientsFunction]
|
|
99
|
+
Modified module and function with integrated progress tracking capabilities.
|
|
57
100
|
|
|
58
|
-
Returns:
|
|
59
|
-
A tuple containing the modified module and function with progress tracking.
|
|
60
101
|
"""
|
|
61
102
|
linesLaunch: str = f"""
|
|
62
103
|
if __name__ == '__main__':
|
|
@@ -76,9 +117,9 @@ if __name__ == '__main__':
|
|
|
76
117
|
ast_argNumbaProgress = ast.arg(arg=spices.numbaProgressBarIdentifier, annotation=ast.Name(id=numba_progressPythonClass, ctx=ast.Load()))
|
|
77
118
|
ingredientsFunction.astFunctionDef.args.args.append(ast_argNumbaProgress)
|
|
78
119
|
|
|
79
|
-
findThis =
|
|
80
|
-
doThat = Then.replaceWith(Make.Expr(Make.Call(Make.Attribute(Make.Name(spices.numbaProgressBarIdentifier),'update'),[Make.Constant(1)])))
|
|
81
|
-
countWithProgressBar = NodeChanger(findThis, doThat)
|
|
120
|
+
findThis: Callable[[ast.AST], TypeIs[ast.AugAssign] | bool] = Be.AugAssign.targetIs(IfThis.isNameIdentifier(job.shatteredDataclass.countingVariableName.id))
|
|
121
|
+
doThat: Callable[[ast.AugAssign], ast.Expr] = Then.replaceWith(Make.Expr(Make.Call(Make.Attribute(Make.Name(spices.numbaProgressBarIdentifier),'update'),[Make.Constant(1)])))
|
|
122
|
+
countWithProgressBar: NodeChanger[ast.AugAssign, ast.Expr] = NodeChanger(findThis, doThat)
|
|
82
123
|
countWithProgressBar.visit(ingredientsFunction.astFunctionDef)
|
|
83
124
|
|
|
84
125
|
removeReturnStatement = NodeChanger(Be.Return, Then.removeIt)
|
|
@@ -90,32 +131,39 @@ if __name__ == '__main__':
|
|
|
90
131
|
return ingredientsModule, ingredientsFunction
|
|
91
132
|
|
|
92
133
|
def move_arg2FunctionDefDOTbodyAndAssignInitialValues(ingredientsFunction: IngredientsFunction, job: RecipeJobTheorem2Numba) -> IngredientsFunction:
|
|
93
|
-
"""
|
|
94
|
-
|
|
134
|
+
"""Convert function parameters into initialized variables with concrete values.
|
|
135
|
+
|
|
136
|
+
(AI generated docstring)
|
|
95
137
|
|
|
96
138
|
This function implements a critical transformation that converts function parameters
|
|
97
139
|
into statically initialized variables in the function body. This enables several
|
|
98
140
|
optimizations:
|
|
99
141
|
|
|
100
|
-
1. Eliminating parameter passing overhead
|
|
101
|
-
2. Embedding concrete values directly in the code
|
|
102
|
-
3. Allowing Numba to optimize based on known value characteristics
|
|
103
|
-
4. Simplifying function signatures for specialized use cases
|
|
142
|
+
1. Eliminating parameter passing overhead
|
|
143
|
+
2. Embedding concrete values directly in the code
|
|
144
|
+
3. Allowing Numba to optimize based on known value characteristics
|
|
145
|
+
4. Simplifying function signatures for specialized use cases
|
|
104
146
|
|
|
105
147
|
The function handles different data types (scalars, arrays, custom types) appropriately,
|
|
106
148
|
replacing abstract parameter references with concrete values from the computation state.
|
|
107
149
|
It also removes unused parameters and variables to eliminate dead code.
|
|
108
150
|
|
|
109
|
-
Parameters
|
|
110
|
-
|
|
111
|
-
|
|
151
|
+
Parameters
|
|
152
|
+
----------
|
|
153
|
+
ingredientsFunction : IngredientsFunction
|
|
154
|
+
The function to transform.
|
|
155
|
+
job : RecipeJobTheorem2Numba
|
|
156
|
+
Recipe containing concrete values for parameters and field metadata.
|
|
112
157
|
|
|
113
|
-
Returns
|
|
158
|
+
Returns
|
|
159
|
+
-------
|
|
160
|
+
modifiedFunction : IngredientsFunction
|
|
114
161
|
The modified function with parameters converted to initialized variables.
|
|
162
|
+
|
|
115
163
|
"""
|
|
116
164
|
ingredientsFunction.imports.update(job.shatteredDataclass.imports)
|
|
117
165
|
|
|
118
|
-
list_argCuzMyBrainRefusesToThink = ingredientsFunction.astFunctionDef.args.args + ingredientsFunction.astFunctionDef.args.posonlyargs + ingredientsFunction.astFunctionDef.args.kwonlyargs
|
|
166
|
+
list_argCuzMyBrainRefusesToThink: list[ast.arg] = ingredientsFunction.astFunctionDef.args.args + ingredientsFunction.astFunctionDef.args.posonlyargs + ingredientsFunction.astFunctionDef.args.kwonlyargs
|
|
119
167
|
list_arg_arg: list[str] = [ast_arg.arg for ast_arg in list_argCuzMyBrainRefusesToThink]
|
|
120
168
|
listName: list[ast.Name] = []
|
|
121
169
|
NodeTourist(Be.Name, Then.appendTo(listName)).visit(ingredientsFunction.astFunctionDef)
|
|
@@ -130,47 +178,70 @@ def move_arg2FunctionDefDOTbodyAndAssignInitialValues(ingredientsFunction: Ingre
|
|
|
130
178
|
ImaAnnAssign, elementConstructor = job.shatteredDataclass.Z0Z_field2AnnAssign[ast_arg.arg]
|
|
131
179
|
match elementConstructor:
|
|
132
180
|
case 'scalar':
|
|
133
|
-
cast(ast.Constant, cast(ast.Call, ImaAnnAssign.value).args[0]).value = int(job.state.__dict__[ast_arg.arg])
|
|
181
|
+
cast('ast.Constant', cast('ast.Call', ImaAnnAssign.value).args[0]).value = int(job.state.__dict__[ast_arg.arg])
|
|
134
182
|
case 'array':
|
|
135
|
-
dataAsStrRLE: str = autoDecodingRLE(job.state.__dict__[ast_arg.arg], True)
|
|
136
|
-
dataAs_astExpr: ast.expr = cast(ast.Expr, ast.parse(dataAsStrRLE).body[0]).value
|
|
137
|
-
cast(ast.Call, ImaAnnAssign.value).args = [dataAs_astExpr]
|
|
183
|
+
dataAsStrRLE: str = autoDecodingRLE(job.state.__dict__[ast_arg.arg], assumeAddSpaces=True)
|
|
184
|
+
dataAs_astExpr: ast.expr = cast('ast.Expr', ast.parse(dataAsStrRLE).body[0]).value
|
|
185
|
+
cast('ast.Call', ImaAnnAssign.value).args = [dataAs_astExpr]
|
|
138
186
|
case _:
|
|
139
187
|
list_exprDOTannotation: list[ast.expr] = []
|
|
140
188
|
list_exprDOTvalue: list[ast.expr] = []
|
|
141
189
|
for dimension in job.state.mapShape:
|
|
142
190
|
list_exprDOTannotation.append(Make.Name(elementConstructor))
|
|
143
191
|
list_exprDOTvalue.append(Make.Call(Make.Name(elementConstructor), [Make.Constant(dimension)]))
|
|
144
|
-
cast(ast.Tuple, cast(ast.Subscript, cast(ast.AnnAssign, ImaAnnAssign).annotation).slice).elts = list_exprDOTannotation
|
|
145
|
-
cast(ast.Tuple, ImaAnnAssign.value).elts = list_exprDOTvalue
|
|
192
|
+
cast('ast.Tuple', cast('ast.Subscript', cast('ast.AnnAssign', ImaAnnAssign).annotation).slice).elts = list_exprDOTannotation
|
|
193
|
+
cast('ast.Tuple', ImaAnnAssign.value).elts = list_exprDOTvalue
|
|
146
194
|
|
|
147
195
|
ingredientsFunction.astFunctionDef.body.insert(0, ImaAnnAssign)
|
|
148
196
|
|
|
149
|
-
findThis = IfThis.is_argIdentifier(ast_arg.arg)
|
|
150
|
-
remove_arg = NodeChanger(findThis, Then.removeIt)
|
|
197
|
+
findThis: Callable[[ast.AST], TypeIs[ast.arg] | bool] = IfThis.is_argIdentifier(ast_arg.arg)
|
|
198
|
+
remove_arg: NodeChanger[ast.arg, None] = NodeChanger(findThis, Then.removeIt)
|
|
151
199
|
remove_arg.visit(ingredientsFunction.astFunctionDef)
|
|
152
200
|
|
|
153
201
|
ast.fix_missing_locations(ingredientsFunction.astFunctionDef)
|
|
154
202
|
return ingredientsFunction
|
|
155
203
|
|
|
156
204
|
def makeJobNumba(job: RecipeJobTheorem2Numba, spices: SpicesJobNumba) -> None:
|
|
205
|
+
"""Generate an optimized Numba-compiled computation module for map folding calculations.
|
|
206
|
+
|
|
207
|
+
(AI generated docstring)
|
|
208
|
+
|
|
209
|
+
This function orchestrates the complete code transformation pipeline to convert
|
|
210
|
+
a generic map folding algorithm into a highly optimized, specialized computation
|
|
211
|
+
module. The transformation process includes:
|
|
212
|
+
|
|
213
|
+
1. Extract and modify the source function from the generic algorithm
|
|
214
|
+
2. Replace static-valued identifiers with their concrete values
|
|
215
|
+
3. Convert function parameters to embedded initialized variables
|
|
216
|
+
4. Remove unused code paths and variables for optimization
|
|
217
|
+
5. Configure appropriate Numba decorators for JIT compilation
|
|
218
|
+
6. Add progress tracking capabilities for long-running computations
|
|
219
|
+
7. Generate standalone launcher code for direct execution
|
|
220
|
+
8. Write the complete optimized module to the filesystem
|
|
221
|
+
|
|
222
|
+
The resulting module is a self-contained Python script that can execute
|
|
223
|
+
map folding calculations for the specific map dimensions with maximum
|
|
224
|
+
performance through just-in-time compilation.
|
|
225
|
+
|
|
226
|
+
Parameters
|
|
227
|
+
----------
|
|
228
|
+
job : RecipeJobTheorem2Numba
|
|
229
|
+
Configuration recipe containing source locations, target paths, and state.
|
|
230
|
+
spices : SpicesJobNumba
|
|
231
|
+
Optimization settings including Numba parameters and progress options.
|
|
157
232
|
|
|
158
|
-
|
|
159
|
-
|
|
233
|
+
"""
|
|
234
|
+
astFunctionDef: ast.FunctionDef = raiseIfNone(extractFunctionDef(job.source_astModule, job.countCallable))
|
|
160
235
|
ingredientsCount: IngredientsFunction = IngredientsFunction(astFunctionDef, LedgerOfImports())
|
|
161
236
|
|
|
162
237
|
# Remove `foldGroups` and any other unused statements, so you can dynamically determine which variables are not used
|
|
163
|
-
|
|
164
|
-
# findThis = IfThis.isAssignAndTargets0Is(IfThis.isSubscriptIdentifier('foldGroups'))
|
|
165
|
-
doThat = Then.removeIt
|
|
166
|
-
remove_foldGroups = NodeChanger(findThis, doThat)
|
|
167
|
-
# remove_foldGroups.visit(ingredientsCount.astFunctionDef)
|
|
238
|
+
# NodeChanger[ast.Name, None](Be.Assign.targetsIs(lambda list_expr: any(IfThis.isSubscriptIdentifier('foldGroups')(node) for node in list_expr)) , Then.removeIt).visit(ingredientsCount.astFunctionDef) # noqa: ERA001
|
|
168
239
|
|
|
169
240
|
# replace identifiers with static values with their values, so you can dynamically determine which variables are not used
|
|
170
|
-
listIdentifiersStaticValues = listIdentifiersStaticValuesHARDCODED
|
|
241
|
+
listIdentifiersStaticValues: list[str] = listIdentifiersStaticValuesHARDCODED
|
|
171
242
|
for identifier in listIdentifiersStaticValues:
|
|
172
|
-
findThis = IfThis.isNameIdentifier(identifier)
|
|
173
|
-
doThat = Then.replaceWith(Make.Constant(int(job.state.__dict__[identifier])))
|
|
243
|
+
findThis: Callable[[ast.AST], TypeIs[ast.Name] | bool] = IfThis.isNameIdentifier(identifier)
|
|
244
|
+
doThat: Callable[[ast.Name], ast.Constant] = Then.replaceWith(Make.Constant(int(job.state.__dict__[identifier])))
|
|
174
245
|
NodeChanger(findThis, doThat).visit(ingredientsCount.astFunctionDef)
|
|
175
246
|
|
|
176
247
|
ingredientsModule = IngredientsModule()
|
|
@@ -190,22 +261,40 @@ if __name__ == '__main__':
|
|
|
190
261
|
writeStream.write(str(foldsTotal))
|
|
191
262
|
writeStream.close()
|
|
192
263
|
"""
|
|
193
|
-
# from mapFolding.oeis import getFoldsTotalKnown
|
|
194
|
-
# print(foldsTotal == getFoldsTotalKnown({job.state.mapShape}))
|
|
264
|
+
# from mapFolding.oeis import getFoldsTotalKnown # noqa: ERA001
|
|
265
|
+
# print(foldsTotal == getFoldsTotalKnown({job.state.mapShape})) # noqa: ERA001
|
|
195
266
|
ingredientsModule.appendLauncher(ast.parse(linesLaunch))
|
|
196
267
|
changeReturnParallelCallable = NodeChanger(Be.Return, Then.replaceWith(Make.Return(job.shatteredDataclass.countingVariableName)))
|
|
197
268
|
changeReturnParallelCallable.visit(ingredientsCount.astFunctionDef)
|
|
198
269
|
ingredientsCount.astFunctionDef.returns = job.shatteredDataclass.countingVariableAnnotation
|
|
199
270
|
|
|
200
271
|
ingredientsCount = move_arg2FunctionDefDOTbodyAndAssignInitialValues(ingredientsCount, job)
|
|
201
|
-
|
|
202
272
|
class DatatypeConfig(NamedTuple):
|
|
203
|
-
|
|
273
|
+
"""Configuration for mapping framework datatypes to Numba-compatible types.
|
|
274
|
+
|
|
275
|
+
This configuration class defines how abstract datatypes used in the map folding
|
|
276
|
+
framework should be replaced with concrete Numba-compatible types during code
|
|
277
|
+
generation. Each configuration specifies the source module, target type name,
|
|
278
|
+
and optional import alias for the transformation.
|
|
279
|
+
|
|
280
|
+
Attributes
|
|
281
|
+
----------
|
|
282
|
+
fml : str
|
|
283
|
+
Framework datatype identifier to be replaced.
|
|
284
|
+
Z0Z_module : identifierDotAttribute
|
|
285
|
+
Module containing the target datatype (e.g., 'numba', 'numpy').
|
|
286
|
+
Z0Z_type_name : str
|
|
287
|
+
Concrete type name in the target module.
|
|
288
|
+
Z0Z_asname : str | None = None
|
|
289
|
+
Optional import alias for the type.
|
|
290
|
+
"""
|
|
291
|
+
|
|
204
292
|
fml: str
|
|
293
|
+
Z0Z_module: identifierDotAttribute
|
|
205
294
|
Z0Z_type_name: str
|
|
206
295
|
Z0Z_asname: str | None = None
|
|
207
296
|
|
|
208
|
-
listDatatypeConfigs = [
|
|
297
|
+
listDatatypeConfigs: list[DatatypeConfig] = [
|
|
209
298
|
DatatypeConfig(fml='DatatypeLeavesTotal', Z0Z_module='numba', Z0Z_type_name='uint8'),
|
|
210
299
|
DatatypeConfig(fml='DatatypeElephino', Z0Z_module='numba', Z0Z_type_name='uint16'),
|
|
211
300
|
DatatypeConfig(fml='DatatypeFoldsTotal', Z0Z_module='numba', Z0Z_type_name='uint64'),
|
|
@@ -232,9 +321,7 @@ if __name__ == '__main__':
|
|
|
232
321
|
ingredientsCount.imports.addImportFrom_asStr(typeConfig.Z0Z_module, typeConfig.Z0Z_type_name, typeConfig.Z0Z_asname)
|
|
233
322
|
|
|
234
323
|
ingredientsCount.astFunctionDef.decorator_list = [] # TODO low-priority, handle this more elegantly
|
|
235
|
-
# TODO when I add the function signature in numba style back to the decorator, the logic needs to handle `ProgressBarType:`
|
|
236
324
|
ingredientsCount = decorateCallableWithNumba(ingredientsCount, spices.parametersNumba)
|
|
237
|
-
|
|
238
325
|
ingredientsModule.appendIngredientsFunction(ingredientsCount)
|
|
239
326
|
write_astModule(ingredientsModule, job.pathFilenameModule, job.packageIdentifier)
|
|
240
327
|
|
|
@@ -263,12 +350,12 @@ if __name__ == '__main__':
|
|
|
263
350
|
mapShape = (2,4)
|
|
264
351
|
state = MapFoldingState(mapShape)
|
|
265
352
|
state = initializeGroupsOfFolds(state)
|
|
266
|
-
# foldsTotalEstimated = getFoldsTotalKnown(state.mapShape) // state.leavesTotal
|
|
267
|
-
# foldsTotalEstimated = dictionaryEstimates[state.mapShape] // state.leavesTotal
|
|
353
|
+
# foldsTotalEstimated = getFoldsTotalKnown(state.mapShape) // state.leavesTotal # noqa: ERA001
|
|
354
|
+
# foldsTotalEstimated = dictionaryEstimates[state.mapShape] // state.leavesTotal # noqa: ERA001
|
|
268
355
|
foldsTotalEstimated = 0
|
|
269
356
|
pathModule = PurePosixPath(packageSettings.pathPackage, 'jobs')
|
|
270
357
|
pathFilenameFoldsTotal = PurePosixPath(getPathFilenameFoldsTotal(state.mapShape, pathModule))
|
|
271
358
|
aJob = RecipeJobTheorem2Numba(state, foldsTotalEstimated, pathModule=pathModule, pathFilenameFoldsTotal=pathFilenameFoldsTotal)
|
|
272
359
|
spices = SpicesJobNumba(useNumbaProgressBar=False, parametersNumba=parametersNumbaLight)
|
|
273
|
-
# spices = SpicesJobNumba()
|
|
360
|
+
# spices = SpicesJobNumba() # noqa: ERA001
|
|
274
361
|
makeJobNumba(aJob, spices)
|