mapFolding 0.8.3__py3-none-any.whl → 0.8.5__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.
Files changed (38) hide show
  1. mapFolding/__init__.py +6 -3
  2. mapFolding/basecamp.py +13 -7
  3. mapFolding/beDRY.py +241 -68
  4. mapFolding/oeis.py +4 -4
  5. mapFolding/reference/hunterNumba.py +1 -1
  6. mapFolding/someAssemblyRequired/__init__.py +40 -20
  7. mapFolding/someAssemblyRequired/_theTypes.py +53 -0
  8. mapFolding/someAssemblyRequired/_tool_Make.py +99 -0
  9. mapFolding/someAssemblyRequired/_tool_Then.py +72 -0
  10. mapFolding/someAssemblyRequired/_toolboxAntecedents.py +358 -0
  11. mapFolding/someAssemblyRequired/_toolboxContainers.py +334 -0
  12. mapFolding/someAssemblyRequired/_toolboxPython.py +62 -0
  13. mapFolding/someAssemblyRequired/getLLVMforNoReason.py +2 -2
  14. mapFolding/someAssemblyRequired/newInliner.py +22 -0
  15. mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +158 -0
  16. mapFolding/someAssemblyRequired/toolboxNumba.py +358 -0
  17. mapFolding/someAssemblyRequired/transformationTools.py +289 -698
  18. mapFolding/syntheticModules/numbaCount_doTheNeedful.py +36 -33
  19. mapFolding/theDao.py +13 -11
  20. mapFolding/theSSOT.py +83 -128
  21. mapFolding/toolboxFilesystem.py +219 -0
  22. {mapfolding-0.8.3.dist-info → mapfolding-0.8.5.dist-info}/METADATA +4 -2
  23. mapfolding-0.8.5.dist-info/RECORD +48 -0
  24. {mapfolding-0.8.3.dist-info → mapfolding-0.8.5.dist-info}/WHEEL +1 -1
  25. tests/conftest.py +56 -52
  26. tests/test_computations.py +42 -32
  27. tests/test_filesystem.py +4 -4
  28. tests/test_other.py +2 -2
  29. tests/test_tasks.py +2 -2
  30. mapFolding/filesystem.py +0 -129
  31. mapFolding/someAssemblyRequired/ingredientsNumba.py +0 -206
  32. mapFolding/someAssemblyRequired/synthesizeNumbaFlow.py +0 -211
  33. mapFolding/someAssemblyRequired/synthesizeNumbaJobVESTIGIAL.py +0 -413
  34. mapFolding/someAssemblyRequired/transformDataStructures.py +0 -168
  35. mapfolding-0.8.3.dist-info/RECORD +0 -43
  36. {mapfolding-0.8.3.dist-info → mapfolding-0.8.5.dist-info}/entry_points.txt +0 -0
  37. {mapfolding-0.8.3.dist-info → mapfolding-0.8.5.dist-info}/licenses/LICENSE +0 -0
  38. {mapfolding-0.8.3.dist-info → mapfolding-0.8.5.dist-info}/top_level.txt +0 -0
@@ -1,206 +0,0 @@
1
- """
2
- Numba-specific ingredients for optimized code generation.
3
-
4
- This module provides specialized tools, constants, and types specifically designed
5
- for transforming Python code into Numba-accelerated implementations. It implements:
6
-
7
- 1. A range of Numba jit decorator configurations for different optimization scenarios
8
- 2. Functions to identify and manipulate Numba decorators in abstract syntax trees
9
- 3. Utilities for applying appropriate Numba typing to transformed code
10
- 4. Parameter management for Numba compilation options
11
-
12
- The configurations range from conservative options that prioritize compatibility and
13
- error detection to aggressive optimizations that maximize performance at the cost of
14
- flexibility. While this module specifically targets Numba, its design follows the pattern
15
- of generic code transformation tools in the package, allowing similar approaches to be
16
- applied to other acceleration technologies.
17
-
18
- This module works in conjunction with transformation tools to convert the general-purpose
19
- algorithm implementation into a highly-optimized Numba version.
20
- """
21
-
22
- from collections.abc import Callable, Sequence
23
- from mapFolding.someAssemblyRequired import ifThis, IngredientsFunction, Make
24
- from numba.core.compiler import CompilerBase as numbaCompilerBase
25
- from typing import Any, cast, Final, TYPE_CHECKING
26
- import ast
27
-
28
- try:
29
- from typing import NotRequired
30
- except Exception:
31
- from typing_extensions import NotRequired
32
-
33
- if TYPE_CHECKING:
34
- from typing import TypedDict
35
- else:
36
- TypedDict = dict
37
-
38
- class ParametersNumba(TypedDict):
39
- _dbg_extend_lifetimes: NotRequired[bool]
40
- _dbg_optnone: NotRequired[bool]
41
- _nrt: NotRequired[bool]
42
- boundscheck: NotRequired[bool]
43
- cache: bool
44
- debug: NotRequired[bool]
45
- error_model: str
46
- fastmath: bool
47
- forceinline: bool
48
- forceobj: NotRequired[bool]
49
- inline: str
50
- locals: NotRequired[dict[str, Any]]
51
- looplift: bool
52
- no_cfunc_wrapper: bool
53
- no_cpython_wrapper: bool
54
- no_rewrites: NotRequired[bool]
55
- nogil: NotRequired[bool]
56
- nopython: bool
57
- parallel: bool
58
- pipeline_class: NotRequired[type[numbaCompilerBase]]
59
- signature_or_function: NotRequired[Any | Callable[..., Any] | str | tuple[Any, ...]]
60
- target: NotRequired[str]
61
-
62
- parametersNumbaFailEarly: Final[ParametersNumba] = {
63
- '_nrt': True,
64
- 'boundscheck': True,
65
- 'cache': True,
66
- 'error_model': 'python',
67
- 'fastmath': False,
68
- 'forceinline': True,
69
- 'inline': 'always',
70
- 'looplift': False,
71
- 'no_cfunc_wrapper': False,
72
- 'no_cpython_wrapper': False,
73
- 'nopython': True,
74
- 'parallel': False, }
75
- """For a production function: speed is irrelevant, error discovery is paramount, must be compatible with anything downstream."""
76
-
77
- parametersNumbaDEFAULT: Final[ParametersNumba] = {
78
- '_nrt': True,
79
- 'boundscheck': False,
80
- 'cache': True,
81
- 'error_model': 'numpy',
82
- 'fastmath': True,
83
- 'forceinline': True,
84
- 'inline': 'always',
85
- 'looplift': False,
86
- 'no_cfunc_wrapper': False,
87
- 'no_cpython_wrapper': False,
88
- 'nopython': True,
89
- 'parallel': False, }
90
- """Middle of the road: fast, lean, but will talk to non-jitted functions."""
91
-
92
- parametersNumbaParallelDEFAULT: Final[ParametersNumba] = {
93
- **parametersNumbaDEFAULT,
94
- '_nrt': True,
95
- 'parallel': True, }
96
- """Middle of the road: fast, lean, but will talk to non-jitted functions."""
97
-
98
- parametersNumbaSuperJit: Final[ParametersNumba] = {
99
- **parametersNumbaDEFAULT,
100
- 'no_cfunc_wrapper': True,
101
- 'no_cpython_wrapper': True, }
102
- """Speed, no helmet, no talking to non-jitted functions."""
103
-
104
- parametersNumbaSuperJitParallel: Final[ParametersNumba] = {
105
- **parametersNumbaSuperJit,
106
- '_nrt': True,
107
- 'parallel': True, }
108
- """Speed, no helmet, concurrency, no talking to non-jitted functions."""
109
-
110
- parametersNumbaMinimum: Final[ParametersNumba] = {
111
- '_nrt': True,
112
- 'boundscheck': True,
113
- 'cache': True,
114
- 'error_model': 'numpy',
115
- 'fastmath': True,
116
- 'forceinline': False,
117
- 'inline': 'always',
118
- 'looplift': False,
119
- 'no_cfunc_wrapper': False,
120
- 'no_cpython_wrapper': False,
121
- 'nopython': False,
122
- 'forceobj': True,
123
- 'parallel': False, }
124
-
125
- Z0Z_numbaDataTypeModule = 'numba'
126
- Z0Z_decoratorCallable = 'jit'
127
-
128
- def thisIsNumbaDotJit(Ima: ast.AST) -> bool:
129
- return ifThis.isCallNamespace_Identifier(Z0Z_numbaDataTypeModule, Z0Z_decoratorCallable)(Ima)
130
-
131
- def thisIsJit(Ima: ast.AST) -> bool:
132
- return ifThis.isCall_Identifier(Z0Z_decoratorCallable)(Ima)
133
-
134
- def thisIsAnyNumbaJitDecorator(Ima: ast.AST) -> bool:
135
- return thisIsNumbaDotJit(Ima) or thisIsJit(Ima)
136
-
137
- def decorateCallableWithNumba(ingredientsFunction: IngredientsFunction, parametersNumba: ParametersNumba | None = None) -> IngredientsFunction:
138
- def Z0Z_UnhandledDecorators(astCallable: ast.FunctionDef) -> ast.FunctionDef:
139
- # TODO: more explicit handling of decorators. I'm able to ignore this because I know `algorithmSource` doesn't have any decorators.
140
- for decoratorItem in astCallable.decorator_list.copy():
141
- import warnings
142
- astCallable.decorator_list.remove(decoratorItem)
143
- warnings.warn(f"Removed decorator {ast.unparse(decoratorItem)} from {astCallable.name}")
144
- return astCallable
145
-
146
- def makeSpecialSignatureForNumba(signatureElement: ast.arg) -> ast.Subscript | ast.Name | None:
147
- if isinstance(signatureElement.annotation, ast.Subscript) and isinstance(signatureElement.annotation.slice, ast.Tuple):
148
- annotationShape: ast.expr = signatureElement.annotation.slice.elts[0]
149
- if isinstance(annotationShape, ast.Subscript) and isinstance(annotationShape.slice, ast.Tuple):
150
- shapeAsListSlices: list[ast.Slice] = [ast.Slice() for _axis in range(len(annotationShape.slice.elts))]
151
- shapeAsListSlices[-1] = ast.Slice(step=ast.Constant(value=1))
152
- shapeAST: ast.Slice | ast.Tuple = ast.Tuple(elts=list(shapeAsListSlices), ctx=ast.Load())
153
- else:
154
- shapeAST = ast.Slice(step=ast.Constant(value=1))
155
-
156
- annotationDtype: ast.expr = signatureElement.annotation.slice.elts[1]
157
- if (isinstance(annotationDtype, ast.Subscript) and isinstance(annotationDtype.slice, ast.Attribute)):
158
- datatypeAST = annotationDtype.slice.attr
159
- else:
160
- datatypeAST = None
161
-
162
- ndarrayName = signatureElement.arg
163
- Z0Z_hacky_dtype: str = ndarrayName
164
- datatype_attr = datatypeAST or Z0Z_hacky_dtype
165
- ingredientsFunction.imports.addImportFromStr(datatypeModuleDecorator, datatype_attr)
166
- datatypeNumba = ast.Name(id=datatype_attr, ctx=ast.Load())
167
-
168
- return ast.Subscript(value=datatypeNumba, slice=shapeAST, ctx=ast.Load())
169
-
170
- elif isinstance(signatureElement.annotation, ast.Name):
171
- return signatureElement.annotation
172
- return None
173
-
174
- datatypeModuleDecorator: str = Z0Z_numbaDataTypeModule
175
- list_argsDecorator: Sequence[ast.expr] = []
176
-
177
- list_arg4signature_or_function: list[ast.expr] = []
178
- for parameter in ingredientsFunction.astFunctionDef.args.args:
179
- # Efficient translation of Python scalar types to Numba types https://github.com/hunterhogan/mapFolding/issues/8
180
- # For now, let Numba infer them.
181
- continue
182
- signatureElement: ast.Subscript | ast.Name | None = makeSpecialSignatureForNumba(parameter)
183
- if signatureElement:
184
- list_arg4signature_or_function.append(signatureElement)
185
-
186
- if ingredientsFunction.astFunctionDef.returns and isinstance(ingredientsFunction.astFunctionDef.returns, ast.Name):
187
- theReturn: ast.Name = ingredientsFunction.astFunctionDef.returns
188
- list_argsDecorator = [cast(ast.expr, ast.Call(func=ast.Name(id=theReturn.id, ctx=ast.Load())
189
- , args=list_arg4signature_or_function if list_arg4signature_or_function else [], keywords=[] ) )]
190
- elif list_arg4signature_or_function:
191
- list_argsDecorator = [cast(ast.expr, ast.Tuple(elts=list_arg4signature_or_function, ctx=ast.Load()))]
192
-
193
- ingredientsFunction.astFunctionDef = Z0Z_UnhandledDecorators(ingredientsFunction.astFunctionDef)
194
- if parametersNumba is None:
195
- parametersNumba = parametersNumbaDEFAULT
196
- listDecoratorKeywords: list[ast.keyword] = [Make.ast_keyword(parameterName, Make.astConstant(parameterValue)) for parameterName, parameterValue in parametersNumba.items()]
197
-
198
- decoratorModule: str = Z0Z_numbaDataTypeModule
199
- decoratorCallable: str = Z0Z_decoratorCallable
200
- ingredientsFunction.imports.addImportFromStr(decoratorModule, decoratorCallable)
201
- # Leave this line in so that global edits will change it.
202
- astDecorator: ast.Call = Make.astCall(Make.astName(decoratorCallable), list_argsDecorator, listDecoratorKeywords)
203
- astDecorator: ast.Call = Make.astCall(Make.astName(decoratorCallable), list_astKeywords=listDecoratorKeywords) # type: ignore[no-redef]
204
-
205
- ingredientsFunction.astFunctionDef.decorator_list = [astDecorator]
206
- return ingredientsFunction
@@ -1,211 +0,0 @@
1
- """
2
- Orchestrator for generating Numba-optimized versions of the map folding algorithm.
3
-
4
- This module transforms the pure Python implementation of the map folding algorithm
5
- into a highly-optimized Numba implementation. It serves as the high-level coordinator
6
- for the code transformation process, orchestrating the following steps:
7
-
8
- 1. Extracting the core algorithm functions from the source implementation
9
- 2. Transforming function signatures and state handling for Numba compatibility
10
- 3. Converting state-based operations to direct primitive operations
11
- 4. Applying Numba decorators with appropriate optimization parameters
12
- 5. Managing imports and dependencies for the generated code
13
- 6. Assembling and writing the transformed implementation
14
-
15
- The transformation process preserves the algorithm's logic while dramatically improving
16
- performance by leveraging Numba's just-in-time compilation capabilities. This module
17
- depends on the abstract transformation tools, dataclass handling utilities, and
18
- Numba-specific optimization configurations from other modules in the package.
19
-
20
- The primary entry point is the makeNumbaFlow function, which can be executed directly
21
- to generate a fresh optimized implementation.
22
- """
23
-
24
- from mapFolding.someAssemblyRequired import (
25
- ast_Identifier,
26
- extractFunctionDef,
27
- ifThis,
28
- IngredientsFunction,
29
- IngredientsModule,
30
- LedgerOfImports,
31
- Make,
32
- makeDictionaryReplacementStatements,
33
- NodeCollector,
34
- NodeReplacer,
35
- RecipeSynthesizeFlow,
36
- Then,
37
- write_astModule,
38
- Z0Z_replaceMatchingASTnodes,
39
- inlineThisFunctionWithTheseValues,
40
- )
41
- from mapFolding.someAssemblyRequired.ingredientsNumba import decorateCallableWithNumba
42
- from mapFolding.someAssemblyRequired.transformDataStructures import shatter_dataclassesDOTdataclass
43
- from mapFolding.theSSOT import raiseIfNoneGitHubIssueNumber3
44
- import ast
45
-
46
- def astModuleToIngredientsFunction(astModule: ast.Module, identifierFunctionDef: ast_Identifier) -> IngredientsFunction:
47
- astFunctionDef = extractFunctionDef(astModule, identifierFunctionDef)
48
- if not astFunctionDef: raise raiseIfNoneGitHubIssueNumber3
49
- return IngredientsFunction(astFunctionDef, LedgerOfImports(astModule))
50
-
51
-
52
- def makeNumbaFlow(numbaFlow: RecipeSynthesizeFlow = RecipeSynthesizeFlow()) -> None:
53
- # TODO a tool to automatically remove unused variables from the ArgumentsSpecification (return, and returns) _might_ be nice.
54
- # TODO remember that `sequentialCallable` and `sourceSequentialCallable` are two different values.
55
- # Figure out dynamic flow control to synthesized modules https://github.com/hunterhogan/mapFolding/issues/4
56
- # ===========================================================
57
- """
58
- Think about a better organization of this function.
59
-
60
- Currently, transform `Callable` in order:
61
- sourceDispatcherCallable
62
- sourceInitializeCallable
63
- sourceParallelCallable
64
- sourceSequentialCallable
65
-
66
- But, it should be organized around each transformation. So, when the parameters of `sourceSequentialCallable`
67
- are transformed, for example, the statement in `sourceDispatcherCallable` that calls `sourceSequentialCallable` should be
68
- transformed at the same time: literally in the same function-or-NodeReplacer-or-subroutine. That would help
69
- avoid bugs.
70
-
71
- Furthermore, if the above example transformation requires unpacking the dataclass, for example, then the unpacking
72
- would be automatically triggered. I have no idea how that would happen, but the transformations are highly predictable,
73
- so using a programming language to construct if-this-then-that cascades shouldn't be a problem, you know?
74
-
75
- """
76
- ingredientsDispatcher: IngredientsFunction = astModuleToIngredientsFunction(numbaFlow.source_astModule, numbaFlow.sourceDispatcherCallable)
77
- ingredientsInitialize: IngredientsFunction = astModuleToIngredientsFunction(numbaFlow.source_astModule, numbaFlow.sourceInitializeCallable)
78
- ingredientsParallel: IngredientsFunction = astModuleToIngredientsFunction(numbaFlow.source_astModule, numbaFlow.sourceParallelCallable)
79
- ingredientsSequential: IngredientsFunction = astModuleToIngredientsFunction(numbaFlow.source_astModule, numbaFlow.sourceSequentialCallable)
80
-
81
- # Inline functions
82
- # NOTE Replacements statements are based on the identifiers in the _source_
83
- dictionaryReplacementStatements = makeDictionaryReplacementStatements(numbaFlow.source_astModule)
84
- ingredientsInitialize.astFunctionDef = inlineThisFunctionWithTheseValues(ingredientsInitialize.astFunctionDef, dictionaryReplacementStatements)
85
- ingredientsParallel.astFunctionDef = inlineThisFunctionWithTheseValues(ingredientsParallel.astFunctionDef, dictionaryReplacementStatements)
86
- ingredientsSequential.astFunctionDef = inlineThisFunctionWithTheseValues(ingredientsSequential.astFunctionDef, dictionaryReplacementStatements)
87
-
88
- # Assign CALLABLE identifiers per the recipe.
89
- # TODO Assign the other identifiers.
90
- listIngredientsFunctions = [ingredientsDispatcher, ingredientsInitialize, ingredientsParallel, ingredientsSequential]
91
- listFindReplace = [(numbaFlow.sourceDispatcherCallable, numbaFlow.dispatcherCallable),
92
- (numbaFlow.sourceInitializeCallable, numbaFlow.initializeCallable),
93
- (numbaFlow.sourceParallelCallable, numbaFlow.parallelCallable),
94
- (numbaFlow.sourceSequentialCallable, numbaFlow.sequentialCallable)]
95
- for ingredients in listIngredientsFunctions:
96
- ImaNode = ingredients.astFunctionDef
97
- for source_Identifier, Z0Z_Identifier in listFindReplace:
98
- findThis = ifThis.isCall_Identifier(source_Identifier)
99
- doThis = Then.replaceDOTfuncWith(Make.astName(Z0Z_Identifier))
100
- NodeReplacer(findThis, doThis).visit(ImaNode)
101
-
102
- ingredientsDispatcher.astFunctionDef.name = numbaFlow.dispatcherCallable
103
- ingredientsInitialize.astFunctionDef.name = numbaFlow.initializeCallable
104
- ingredientsParallel.astFunctionDef.name = numbaFlow.parallelCallable
105
- ingredientsSequential.astFunctionDef.name = numbaFlow.sequentialCallable
106
- # ===========================================================
107
- # Old organization
108
-
109
- # sourceParallelCallable
110
- shatteredDataclass = shatter_dataclassesDOTdataclass(numbaFlow.logicalPathModuleDataclass, numbaFlow.sourceDataclassIdentifier, numbaFlow.sourceDataclassInstanceTaskDistribution)
111
- ingredientsDispatcher.imports.update(shatteredDataclass.ledgerDataclassANDFragments)
112
-
113
- NodeReplacer(
114
- findThis = ifThis.isAssignAndValueIsCallNamespace_Identifier(numbaFlow.sourceConcurrencyManagerNamespace, numbaFlow.sourceConcurrencyManagerIdentifier)
115
- , doThat = Then.insertThisAbove(shatteredDataclass.listAnnAssign4DataclassUnpack)
116
- ).visit(ingredientsDispatcher.astFunctionDef)
117
- NodeReplacer(
118
- findThis = ifThis.isCallNamespace_Identifier(numbaFlow.sourceConcurrencyManagerNamespace, numbaFlow.sourceConcurrencyManagerIdentifier)
119
- , doThat = Then.replaceWith(Make.astCall(Make.astAttribute(Make.astName(numbaFlow.sourceConcurrencyManagerNamespace), numbaFlow.sourceConcurrencyManagerIdentifier)
120
- , listArguments=[Make.astName(numbaFlow.parallelCallable)] + shatteredDataclass.listNameDataclassFragments4Parameters))
121
- ).visit(ingredientsDispatcher.astFunctionDef)
122
-
123
- CapturedAssign: list[ast.AST] = []
124
- CapturedCall: list[ast.Call] = []
125
- findThis = ifThis.isCall
126
- doThat = [Then.appendTo(CapturedCall)]
127
- capture = NodeCollector(findThis, doThat)
128
-
129
- NodeCollector(
130
- findThis = ifThis.isAssignAndTargets0Is(ifThis.isSubscript_Identifier(numbaFlow.sourceDataclassInstance))
131
- , doThat = [Then.appendTo(CapturedAssign)
132
- , lambda node: capture.visit(node)]
133
- ).visit(ingredientsDispatcher.astFunctionDef)
134
-
135
- newAssign = CapturedAssign[0]
136
- NodeReplacer(
137
- findThis = lambda node: ifThis.isSubscript(node) and ifThis.isAttribute(node.value) and ifThis.isCall(node.value.value)
138
- , doThat = Then.replaceWith(CapturedCall[0])
139
- ).visit(newAssign)
140
-
141
- NodeReplacer(
142
- findThis = ifThis.isAssignAndTargets0Is(ifThis.isSubscript_Identifier(numbaFlow.sourceDataclassInstance))
143
- , doThat = Then.replaceWith(newAssign)
144
- ).visit(ingredientsDispatcher.astFunctionDef)
145
-
146
- # sourceSequentialCallable
147
- shatteredDataclass = shatter_dataclassesDOTdataclass(numbaFlow.logicalPathModuleDataclass, numbaFlow.sourceDataclassIdentifier, numbaFlow.sourceDataclassInstance)
148
-
149
- ingredientsDispatcher.imports.update(shatteredDataclass.ledgerDataclassANDFragments)
150
-
151
- NodeReplacer(
152
- findThis = ifThis.isAssignAndValueIsCall_Identifier(numbaFlow.sourceSequentialCallable) # NOTE source
153
- , doThat = Then.insertThisAbove(shatteredDataclass.listAnnAssign4DataclassUnpack)
154
- ).visit(ingredientsDispatcher.astFunctionDef)
155
- NodeReplacer(
156
- findThis = ifThis.isAssignAndValueIsCall_Identifier(numbaFlow.sourceSequentialCallable) # NOTE source
157
- , doThat = Then.insertThisBelow([shatteredDataclass.astAssignDataclassRepack])
158
- ).visit(ingredientsDispatcher.astFunctionDef)
159
- NodeReplacer(
160
- findThis = ifThis.isAssignAndValueIsCall_Identifier(numbaFlow.sourceSequentialCallable) # NOTE source
161
- , doThat = Then.replaceWith(Make.astAssign(listTargets=[shatteredDataclass.astTuple4AssignTargetsToFragments], value=Make.astCall(Make.astName(numbaFlow.sequentialCallable), shatteredDataclass.listNameDataclassFragments4Parameters)))
162
- ).visit(ingredientsDispatcher.astFunctionDef)
163
-
164
-
165
- # ===========================================================
166
- ingredientsParallel.astFunctionDef.args = Make.astArgumentsSpecification(args=shatteredDataclass.list_ast_argAnnotated4ArgumentsSpecification)
167
- NodeReplacer(
168
- findThis = ifThis.isReturn
169
- , doThat = Then.replaceWith(Make.astReturn(shatteredDataclass.astTuple4AssignTargetsToFragments))
170
- ).visit(ingredientsParallel.astFunctionDef)
171
-
172
- NodeReplacer(
173
- findThis = ifThis.isReturn
174
- , doThat = Then.replaceWith(Make.astReturn(shatteredDataclass.countingVariableName))
175
- ).visit(ingredientsParallel.astFunctionDef)
176
- ingredientsParallel.astFunctionDef.returns = shatteredDataclass.countingVariableAnnotation
177
- replacementMap = {statement.value: statement.target for statement in shatteredDataclass.listAnnAssign4DataclassUnpack}
178
- ingredientsParallel.astFunctionDef = Z0Z_replaceMatchingASTnodes(ingredientsParallel.astFunctionDef, replacementMap) # type: ignore
179
- ingredientsParallel = decorateCallableWithNumba(ingredientsParallel)
180
-
181
- # ===========================================================
182
- ingredientsSequential.astFunctionDef.args = Make.astArgumentsSpecification(args=shatteredDataclass.list_ast_argAnnotated4ArgumentsSpecification)
183
- NodeReplacer(
184
- findThis = ifThis.isReturn
185
- , doThat = Then.replaceWith(Make.astReturn(shatteredDataclass.astTuple4AssignTargetsToFragments))
186
- ).visit(ingredientsSequential.astFunctionDef)
187
- NodeReplacer(
188
- findThis = ifThis.isReturn
189
- , doThat = Then.replaceWith(Make.astReturn(shatteredDataclass.astTuple4AssignTargetsToFragments))
190
- ).visit(ingredientsSequential.astFunctionDef)
191
- ingredientsSequential.astFunctionDef.returns = shatteredDataclass.astSubscriptPrimitiveTupleAnnotations4FunctionDef_returns
192
- replacementMap = {statement.value: statement.target for statement in shatteredDataclass.listAnnAssign4DataclassUnpack}
193
- ingredientsSequential.astFunctionDef = Z0Z_replaceMatchingASTnodes(ingredientsSequential.astFunctionDef, replacementMap) # type: ignore
194
- ingredientsSequential = decorateCallableWithNumba(ingredientsSequential)
195
- # End old organization
196
- # ===========================================================
197
-
198
- # ===========================================================
199
- # End function-level transformations
200
- # ===========================================================
201
- # Module-level transformations
202
- ingredientsModuleNumbaUnified = IngredientsModule(
203
- ingredientsFunction=[ingredientsInitialize,
204
- ingredientsParallel,
205
- ingredientsSequential,
206
- ingredientsDispatcher], imports=LedgerOfImports(numbaFlow.source_astModule))
207
-
208
- write_astModule(ingredientsModuleNumbaUnified, numbaFlow.pathFilenameDispatcher, numbaFlow.packageName)
209
-
210
- if __name__ == '__main__':
211
- makeNumbaFlow()