mapFolding 0.13.0__py3-none-any.whl → 0.13.1__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/someAssemblyRequired/RecipeJob.py +3 -4
- mapFolding/someAssemblyRequired/_toolkitContainers.py +3 -3
- mapFolding/someAssemblyRequired/makeAllModules.py +2 -2
- mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +68 -128
- mapFolding/someAssemblyRequired/toolkitNumba.py +9 -7
- {mapfolding-0.13.0.dist-info → mapfolding-0.13.1.dist-info}/METADATA +1 -1
- {mapfolding-0.13.0.dist-info → mapfolding-0.13.1.dist-info}/RECORD +11 -11
- {mapfolding-0.13.0.dist-info → mapfolding-0.13.1.dist-info}/WHEEL +0 -0
- {mapfolding-0.13.0.dist-info → mapfolding-0.13.1.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.13.0.dist-info → mapfolding-0.13.1.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.13.0.dist-info → mapfolding-0.13.1.dist-info}/top_level.txt +0 -0
|
@@ -9,7 +9,6 @@ from mapFolding import (
|
|
|
9
9
|
from mapFolding.someAssemblyRequired import dataclassInstanceIdentifierDEFAULT, ShatteredDataclass
|
|
10
10
|
from mapFolding.someAssemblyRequired.transformationTools import shatter_dataclassesDOTdataclass
|
|
11
11
|
from pathlib import Path, PurePosixPath
|
|
12
|
-
from typing import TypeAlias
|
|
13
12
|
import dataclasses
|
|
14
13
|
|
|
15
14
|
@dataclasses.dataclass
|
|
@@ -134,11 +133,11 @@ class RecipeJobTheorem2:
|
|
|
134
133
|
"""Logical path to target dataclass module."""
|
|
135
134
|
|
|
136
135
|
# Datatypes ------------------------------------------
|
|
137
|
-
DatatypeFoldsTotal
|
|
136
|
+
type DatatypeFoldsTotal = TheDatatypeFoldsTotal
|
|
138
137
|
"""Type alias for datatype linked to the magnitude of `foldsTotal`."""
|
|
139
|
-
DatatypeElephino
|
|
138
|
+
type DatatypeElephino = TheDatatypeElephino
|
|
140
139
|
"""Type alias for intermediate computation datatype."""
|
|
141
|
-
DatatypeLeavesTotal
|
|
140
|
+
type DatatypeLeavesTotal = TheDatatypeLeavesTotal
|
|
142
141
|
"""Type alias for datatype linked to the magnitude of `leavesTotal`."""
|
|
143
142
|
|
|
144
143
|
def _makePathFilename(self, pathRoot: PurePosixPath | None = None, logicalPathINFIX: identifierDotAttribute | None = None, filenameStem: str | None = None, fileExtension: str | None = None) -> PurePosixPath:
|
|
@@ -217,10 +217,10 @@ class DeReConstructField2ast:
|
|
|
217
217
|
self.ast_keyword_field__field = Make.keyword(self.name, self.astName)
|
|
218
218
|
self.ast_nameDOTname = Make.Attribute(Make.Name(dataclassesDOTdataclassInstanceIdentifier), self.name)
|
|
219
219
|
|
|
220
|
-
self.astAnnotation =
|
|
220
|
+
self.astAnnotation = cast('ast.Name', raiseIfNone(NodeTourist(
|
|
221
221
|
findThis = Be.AnnAssign.targetIs(IfThis.isNameIdentifier(self.name))
|
|
222
|
-
, doThat = Then.extractIt(
|
|
223
|
-
).captureLastMatch(dataclassClassDef))
|
|
222
|
+
, doThat = Then.extractIt(DOT.annotation)
|
|
223
|
+
).captureLastMatch(dataclassClassDef)))
|
|
224
224
|
|
|
225
225
|
self.ast_argAnnotated = Make.arg(self.name, self.astAnnotation)
|
|
226
226
|
|
|
@@ -299,7 +299,7 @@ def makeDaoOfMapFolding(astModule: ast.Module, moduleIdentifier: str, callableId
|
|
|
299
299
|
ingredientsFunctionDispatcher.imports.update(shatteredDataclass.imports)
|
|
300
300
|
targetCallableIdentifier = ingredientsFunction.astFunctionDef.name
|
|
301
301
|
ingredientsFunctionDispatcher = unpackDataclassCallFunctionRepackDataclass(ingredientsFunctionDispatcher, targetCallableIdentifier, shatteredDataclass)
|
|
302
|
-
astTuple: ast.Tuple = cast('ast.Tuple', raiseIfNone(NodeTourist
|
|
302
|
+
astTuple: ast.Tuple = cast('ast.Tuple', raiseIfNone(NodeTourist(Be.Return.valueIs(Be.Tuple)
|
|
303
303
|
, doThat=Then.extractIt(DOT.value)).captureLastMatch(ingredientsFunction.astFunctionDef)))
|
|
304
304
|
astTuple.ctx = ast.Store()
|
|
305
305
|
|
|
@@ -743,7 +743,7 @@ def makeUnRePackDataclass(astImportFrom: ast.ImportFrom) -> None:
|
|
|
743
743
|
targetCallableIdentifier = astImportFrom.names[0].name
|
|
744
744
|
ingredientsFunction = raiseIfNone(unpackDataclassCallFunctionRepackDataclass(ingredientsFunction, targetCallableIdentifier, shatteredDataclass))
|
|
745
745
|
targetFunctionDef: ast.FunctionDef = raiseIfNone(extractFunctionDef(parseLogicalPath2astModule(raiseIfNone(astImportFrom.module)), targetCallableIdentifier))
|
|
746
|
-
astTuple: ast.Tuple = cast('ast.Tuple', raiseIfNone(NodeTourist
|
|
746
|
+
astTuple: ast.Tuple = cast('ast.Tuple', raiseIfNone(NodeTourist(Be.Return.valueIs(Be.Tuple)
|
|
747
747
|
, doThat=Then.extractIt(DOT.value)).captureLastMatch(targetFunctionDef)))
|
|
748
748
|
astTuple.ctx = ast.Store()
|
|
749
749
|
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"""codon.
|
|
2
2
|
|
|
3
|
-
https://docs.exaloop.io/start/install/
|
|
3
|
+
https://docs.exaloop.io/start/install/
|
|
4
|
+
"""
|
|
4
5
|
|
|
5
6
|
from astToolkit import (
|
|
6
|
-
Be, DOT, extractFunctionDef, Grab,
|
|
7
|
-
|
|
8
|
-
from astToolkit.transformationTools import write_astModule
|
|
7
|
+
Be, DOT, extractFunctionDef, Grab, identifierDotAttribute, IngredientsFunction, IngredientsModule, Make, NodeChanger,
|
|
8
|
+
NodeTourist, Then)
|
|
9
|
+
from astToolkit.transformationTools import removeUnusedParameters, write_astModule
|
|
9
10
|
from hunterMakesPy import autoDecodingRLE, raiseIfNone
|
|
10
|
-
from mapFolding import getPathFilenameFoldsTotal, MapFoldingState
|
|
11
|
+
from mapFolding import getPathFilenameFoldsTotal, MapFoldingState
|
|
11
12
|
from mapFolding.someAssemblyRequired import IfThis
|
|
12
13
|
from mapFolding.someAssemblyRequired.RecipeJob import RecipeJobTheorem2
|
|
13
14
|
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds
|
|
@@ -44,34 +45,38 @@ class DatatypeConfiguration(NamedTuple):
|
|
|
44
45
|
# TODO replace with dynamic system. Probably use `Final` in the dataclass.
|
|
45
46
|
listIdentifiersStaticValuesHARDCODED: list[str] = ['dimensionsTotal', 'leavesTotal']
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
listDatatypeConfigurations: list[DatatypeConfiguration] = [
|
|
48
49
|
DatatypeConfiguration(datatypeIdentifier='DatatypeLeavesTotal', typeModule='numpy', typeIdentifier='uint16', type_asname='DatatypeLeavesTotal'),
|
|
49
50
|
DatatypeConfiguration(datatypeIdentifier='DatatypeElephino', typeModule='numpy', typeIdentifier='uint16', type_asname='DatatypeElephino'),
|
|
50
51
|
DatatypeConfiguration(datatypeIdentifier='DatatypeFoldsTotal', typeModule='numpy', typeIdentifier='int64', type_asname='DatatypeFoldsTotal'),
|
|
51
52
|
]
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
listNumPy_dtype: list[DatatypeConfiguration] = [
|
|
54
55
|
DatatypeConfiguration(datatypeIdentifier='Array1DLeavesTotal', typeModule='numpy', typeIdentifier='uint16', type_asname='Array1DLeavesTotal'),
|
|
55
56
|
DatatypeConfiguration(datatypeIdentifier='Array1DElephino', typeModule='numpy', typeIdentifier='uint16', type_asname='Array1DElephino'),
|
|
56
57
|
DatatypeConfiguration(datatypeIdentifier='Array3D', typeModule='numpy', typeIdentifier='uint16', type_asname='Array3D'),
|
|
57
58
|
]
|
|
58
59
|
|
|
59
|
-
def
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
def _addWriteFoldsTotal(ingredientsFunction: IngredientsFunction, job: RecipeJobTheorem2) -> IngredientsFunction:
|
|
61
|
+
NodeChanger(Be.Return, Then.removeIt).visit(ingredientsFunction.astFunctionDef)
|
|
62
|
+
ingredientsFunction.astFunctionDef.returns = Make.Constant(None)
|
|
63
|
+
|
|
64
|
+
writeFoldsTotal = Make.Expr(Make.Call(Make.Attribute(
|
|
65
|
+
Make.Call(Make.Name('open'), listParameters=[Make.Constant(str(job.pathFilenameFoldsTotal.as_posix())), Make.Constant('w')])
|
|
66
|
+
, 'write'), listParameters=[Make.Call(Make.Name('str'), listParameters=[
|
|
67
|
+
Make.Mult().join([job.shatteredDataclass.countingVariableName, Make.Constant(job.state.leavesTotal * 2)])])]))
|
|
68
|
+
|
|
69
|
+
NodeChanger(IfThis.isAllOf(Be.AugAssign.targetIs(IfThis.isNameIdentifier(job.shatteredDataclass.countingVariableName.id))
|
|
70
|
+
, Be.AugAssign.opIs(Be.Mult), Be.AugAssign.valueIs(Be.Constant))
|
|
71
|
+
, doThat=Then.replaceWith(writeFoldsTotal)
|
|
72
|
+
).visit(ingredientsFunction.astFunctionDef)
|
|
73
|
+
|
|
74
|
+
return ingredientsFunction
|
|
67
75
|
|
|
68
|
-
|
|
76
|
+
def _datatypeDefinitions(ingredientsFunction: IngredientsFunction, ingredientsModule: IngredientsModule) -> tuple[IngredientsFunction, IngredientsModule]:
|
|
77
|
+
for datatypeConfig in [*listDatatypeConfigurations, *listNumPy_dtype]:
|
|
69
78
|
ingredientsFunction.imports.removeImportFrom(datatypeConfig.typeModule, None, datatypeConfig.datatypeIdentifier)
|
|
70
79
|
ingredientsFunction.imports.addImportFrom_asStr(datatypeConfig.typeModule, datatypeConfig.typeIdentifier, datatypeConfig.type_asname)
|
|
71
|
-
continue
|
|
72
|
-
ingredientsModule.appendPrologue(statement=Make.Assign([Make.Name(datatypeConfig.datatypeIdentifier, ast.Store())]
|
|
73
|
-
, value=Make.Name(datatypeConfig.typeIdentifier)
|
|
74
|
-
))
|
|
75
80
|
|
|
76
81
|
ingredientsFunction.imports.removeImportFromModule('mapFolding.dataBaskets')
|
|
77
82
|
|
|
@@ -82,104 +87,60 @@ def _pythonCode2expr(string: str) -> ast.expr:
|
|
|
82
87
|
return raiseIfNone(NodeTourist(Be.Expr, Then.extractIt(DOT.value)).captureLastMatch(ast.parse(string)))
|
|
83
88
|
|
|
84
89
|
def _variableCompatibility(ingredientsFunction: IngredientsFunction, job: RecipeJobTheorem2) -> IngredientsFunction:
|
|
90
|
+
# On some assignment or comparison values, add a type constructor to ensure compatibility.
|
|
91
|
+
# On some values-as-indexer, add a type constructor to ensure indexing-method compatibility.
|
|
85
92
|
for ast_arg in job.shatteredDataclass.list_argAnnotated4ArgumentsSpecification:
|
|
86
93
|
identifier = ast_arg.arg
|
|
87
94
|
annotation = raiseIfNone(ast_arg.annotation)
|
|
88
95
|
|
|
89
|
-
# `identifier` in Augmented Assignment.
|
|
90
|
-
NodeChanger(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
and Be.Assign.valueIs(Be.Constant)(node)
|
|
97
|
-
, doThat=lambda node: Grab.valueAttribute(Then.replaceWith(Make.Call(annotation, listParameters=[node.value])))(node)
|
|
96
|
+
# `identifier` in Augmented Assignment, or in Assignments and value is Constant.
|
|
97
|
+
NodeChanger(findThis=IfThis.isAnyOf(
|
|
98
|
+
Be.AugAssign.targetIs(IfThis.isNestedNameIdentifier(identifier))
|
|
99
|
+
, IfThis.isAllOf(IfThis.isAssignAndTargets0Is(IfThis.isNameIdentifier(identifier))
|
|
100
|
+
, Be.Assign.valueIs(Be.Constant))
|
|
101
|
+
)
|
|
102
|
+
, doThat=lambda node, annotation=annotation: Grab.valueAttribute(Then.replaceWith(Make.Call(annotation, listParameters=[node.value])))(node)
|
|
98
103
|
).visit(ingredientsFunction.astFunctionDef)
|
|
99
104
|
|
|
100
105
|
# `identifier` - 1.
|
|
101
106
|
NodeChanger(Be.BinOp.leftIs(IfThis.isNestedNameIdentifier(identifier))
|
|
102
|
-
, doThat=lambda node: Grab.rightAttribute(Then.replaceWith(Make.Call(annotation, listParameters=[node.right])))(node)
|
|
107
|
+
, doThat=lambda node, annotation=annotation: Grab.rightAttribute(Then.replaceWith(Make.Call(annotation, listParameters=[node.right])))(node)
|
|
103
108
|
).visit(ingredientsFunction.astFunctionDef)
|
|
104
109
|
|
|
105
110
|
# `identifier` in Comparison.
|
|
106
111
|
NodeChanger(Be.Compare.leftIs(IfThis.isNestedNameIdentifier(identifier))
|
|
107
|
-
, doThat=lambda node: Grab.comparatorsAttribute(lambda at: Then.replaceWith([Make.Call(annotation, listParameters=[node.comparators[0]])])(at[0]))(node)
|
|
112
|
+
, doThat=lambda node, annotation=annotation: Grab.comparatorsAttribute(lambda at, annotation=annotation: Then.replaceWith([Make.Call(annotation, listParameters=[node.comparators[0]])])(at[0]))(node)
|
|
108
113
|
).visit(ingredientsFunction.astFunctionDef)
|
|
109
114
|
|
|
110
115
|
# `identifier` has exactly one index value.
|
|
111
|
-
NodeChanger(
|
|
112
|
-
|
|
113
|
-
and not Be.Subscript.sliceIs(Be.Tuple)(node)
|
|
116
|
+
NodeChanger(IfThis.isAllOf(Be.Subscript.valueIs(IfThis.isNestedNameIdentifier(identifier))
|
|
117
|
+
, lambda node: not Be.Subscript.sliceIs(Be.Tuple)(node))
|
|
114
118
|
, doThat=lambda node: Grab.sliceAttribute(Then.replaceWith(Make.Call(Make.Name('int'), listParameters=[node.slice])))(node)
|
|
115
119
|
).visit(ingredientsFunction.astFunctionDef)
|
|
116
120
|
|
|
117
121
|
# `identifier` has multiple index values.
|
|
118
|
-
NodeChanger(
|
|
119
|
-
|
|
120
|
-
and Be.Subscript.sliceIs(Be.Tuple)(node)
|
|
122
|
+
NodeChanger(IfThis.isAllOf(Be.Subscript.valueIs(IfThis.isNestedNameIdentifier(identifier))
|
|
123
|
+
, Be.Subscript.sliceIs(Be.Tuple))
|
|
121
124
|
, doThat=lambda node: Grab.sliceAttribute(Grab.eltsAttribute(
|
|
122
125
|
Then.replaceWith([
|
|
123
|
-
Make.Call(Make.Name('int'), listParameters=[cast(ast.Tuple, node.slice).elts[index]])
|
|
124
|
-
for index in range(len(cast(ast.Tuple, node.slice).elts))
|
|
125
|
-
])
|
|
126
|
-
))(node)
|
|
126
|
+
Make.Call(Make.Name('int'), listParameters=[cast('ast.Tuple', node.slice).elts[index]])
|
|
127
|
+
for index in range(len(cast('ast.Tuple', node.slice).elts))])))(node)
|
|
127
128
|
).visit(ingredientsFunction.astFunctionDef)
|
|
128
129
|
|
|
129
130
|
return ingredientsFunction
|
|
130
131
|
|
|
131
|
-
def
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
job : RecipeJobTheorem2
|
|
144
|
-
Recipe containing concrete values for parameters and field metadata.
|
|
145
|
-
|
|
146
|
-
Returns
|
|
147
|
-
-------
|
|
148
|
-
modifiedFunction : IngredientsFunction
|
|
149
|
-
The modified function with parameters converted to initialized variables.
|
|
150
|
-
|
|
151
|
-
"""
|
|
152
|
-
ingredientsFunction.imports.update(job.shatteredDataclass.imports)
|
|
153
|
-
|
|
154
|
-
list_argCuzMyBrainRefusesToThink: list[ast.arg] = ingredientsFunction.astFunctionDef.args.args + ingredientsFunction.astFunctionDef.args.posonlyargs + ingredientsFunction.astFunctionDef.args.kwonlyargs
|
|
155
|
-
list_arg_arg: list[str] = [ast_arg.arg for ast_arg in list_argCuzMyBrainRefusesToThink]
|
|
156
|
-
listName: list[ast.Name] = []
|
|
157
|
-
NodeTourist(Be.Name, Then.appendTo(listName)).visit(ingredientsFunction.astFunctionDef)
|
|
158
|
-
listIdentifiers: list[str] = [astName.id for astName in listName]
|
|
159
|
-
listIdentifiersNotUsed: list[str] = list(set(list_arg_arg) - set(listIdentifiers))
|
|
160
|
-
|
|
161
|
-
for ast_arg in list_argCuzMyBrainRefusesToThink:
|
|
162
|
-
if ast_arg.arg in job.shatteredDataclass.field2AnnAssign:
|
|
163
|
-
if ast_arg.arg in listIdentifiersNotUsed:
|
|
164
|
-
pass
|
|
165
|
-
else:
|
|
166
|
-
Ima___Assign, elementConstructor = job.shatteredDataclass.Z0Z_field2AnnAssign[ast_arg.arg]
|
|
167
|
-
match elementConstructor:
|
|
168
|
-
case 'scalar':
|
|
169
|
-
cast('ast.Constant', cast('ast.Call', Ima___Assign.value).args[0]).value = int(job.state.__dict__[ast_arg.arg])
|
|
170
|
-
case 'array':
|
|
171
|
-
dataAsStrRLE: str = autoDecodingRLE(job.state.__dict__[ast_arg.arg], assumeAddSpaces=True)
|
|
172
|
-
dataAs_ast_expr: ast.expr = _pythonCode2expr(dataAsStrRLE)
|
|
173
|
-
cast('ast.Call', Ima___Assign.value).args = [dataAs_ast_expr]
|
|
174
|
-
case _:
|
|
175
|
-
pass
|
|
176
|
-
|
|
177
|
-
ingredientsFunction.astFunctionDef.body.insert(0, Ima___Assign)
|
|
178
|
-
|
|
179
|
-
NodeChanger(IfThis.is_argIdentifier(ast_arg.arg), Then.removeIt).visit(ingredientsFunction.astFunctionDef)
|
|
180
|
-
|
|
181
|
-
ast.fix_missing_locations(ingredientsFunction.astFunctionDef)
|
|
182
|
-
return ingredientsFunction
|
|
132
|
+
def _move_arg2body(identifier: str, job: RecipeJobTheorem2) -> ast.AnnAssign | ast.Assign:
|
|
133
|
+
Ima___Assign, elementConstructor = job.shatteredDataclass.Z0Z_field2AnnAssign[identifier]
|
|
134
|
+
match elementConstructor:
|
|
135
|
+
case 'scalar':
|
|
136
|
+
cast('ast.Constant', cast('ast.Call', Ima___Assign.value).args[0]).value = int(job.state.__dict__[identifier])
|
|
137
|
+
case 'array':
|
|
138
|
+
dataAsStrRLE: str = autoDecodingRLE(job.state.__dict__[identifier], assumeAddSpaces=True)
|
|
139
|
+
dataAs_ast_expr: ast.expr = _pythonCode2expr(dataAsStrRLE)
|
|
140
|
+
cast('ast.Call', Ima___Assign.value).args = [dataAs_ast_expr]
|
|
141
|
+
case _:
|
|
142
|
+
pass
|
|
143
|
+
return Ima___Assign
|
|
183
144
|
|
|
184
145
|
def makeJob(job: RecipeJobTheorem2) -> None:
|
|
185
146
|
"""Generate an optimized module for map folding calculations.
|
|
@@ -204,53 +165,32 @@ def makeJob(job: RecipeJobTheorem2) -> None:
|
|
|
204
165
|
, Then.replaceWith(Make.Constant(int(job.state.__dict__[identifier])))
|
|
205
166
|
).visit(ingredientsCount.astFunctionDef)
|
|
206
167
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
print('\\nmap {job.state.mapShape} =', foldsTotal)
|
|
211
|
-
writeStream = open('{job.pathFilenameFoldsTotal.as_posix()}', 'w')
|
|
212
|
-
writeStream.write(str(foldsTotal))
|
|
213
|
-
writeStream.close()
|
|
214
|
-
"""
|
|
215
|
-
ingredientsModule = IngredientsModule(launcher=ast.parse(linesLaunch))
|
|
168
|
+
ingredientsCount.imports.update(job.shatteredDataclass.imports)
|
|
169
|
+
ingredientsCount = removeUnusedParameters(ingredientsCount)
|
|
170
|
+
NodeChanger(Be.arg, lambda removeIt: ingredientsCount.astFunctionDef.body.insert(0, _move_arg2body(removeIt.arg, job))).visit(ingredientsCount.astFunctionDef)
|
|
216
171
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
, Then.replaceWith(Make.Return(job.shatteredDataclass.countingVariableName))).visit(ingredientsCount.astFunctionDef)
|
|
220
|
-
groupsOfFolds2foldsTotal = NodeChanger[ast.AugAssign, hasDOTvalue](
|
|
221
|
-
findThis=(lambda node: Be.AugAssign.targetIs(IfThis.isNameIdentifier(job.shatteredDataclass.countingVariableName.id))(node)
|
|
222
|
-
and Be.AugAssign.opIs(Be.Mult)(node)
|
|
223
|
-
and Be.AugAssign.valueIs(Be.Constant)(node)
|
|
224
|
-
)
|
|
225
|
-
, doThat=lambda node: Grab.valueAttribute(Then.replaceWith(Make.Constant(job.state.leavesTotal * ast.literal_eval(node.value))))(node)
|
|
226
|
-
)
|
|
227
|
-
groupsOfFolds2foldsTotal.visit(ingredientsCount.astFunctionDef)
|
|
228
|
-
|
|
229
|
-
# TODO think about assigning `returns` here, then removing `returns` a few lines from now.
|
|
230
|
-
ingredientsCount.astFunctionDef.returns = job.shatteredDataclass.countingVariableAnnotation
|
|
172
|
+
ingredientsCount = _addWriteFoldsTotal(ingredientsCount, job)
|
|
173
|
+
ingredientsCount = _variableCompatibility(ingredientsCount, job)
|
|
231
174
|
|
|
232
|
-
|
|
175
|
+
ingredientsModule = IngredientsModule(launcher=Make.Module([
|
|
176
|
+
Make.If(Make.Compare(Make.Name('__name__'), [Make.Eq()], [Make.Constant('__main__')])
|
|
177
|
+
, body=[Make.Expr(Make.Call(Make.Name(job.countCallable)))])]))
|
|
233
178
|
|
|
234
179
|
ingredientsCount, ingredientsModule = _datatypeDefinitions(ingredientsCount, ingredientsModule)
|
|
235
|
-
# NOTE Reminder, `returns = None` means "type information is null"; the identifier for the return was removed by `_datatypeDefinitions`.
|
|
236
|
-
ingredientsCount.astFunctionDef.returns = None
|
|
237
|
-
|
|
238
|
-
ingredientsCount = _variableCompatibility(ingredientsCount, job)
|
|
239
180
|
|
|
240
181
|
ingredientsModule.appendIngredientsFunction(ingredientsCount)
|
|
241
182
|
write_astModule(ingredientsModule, pathFilename=job.pathFilenameModule, packageName=job.packageIdentifier)
|
|
242
183
|
|
|
243
184
|
if sys.platform == 'linux':
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
buildCommand =
|
|
248
|
-
subprocess.run(
|
|
185
|
+
buildCommand: list[str] = ['codon', 'build', '--exe', '--release',
|
|
186
|
+
'--fast-math', '--enable-unsafe-fp-math', '--disable-exceptions',
|
|
187
|
+
str(job.pathFilenameModule)]
|
|
188
|
+
subprocess.run(buildCommand, check=False)
|
|
189
|
+
subprocess.run(['/usr/bin/strip', str(job.pathFilenameModule.with_suffix(''))], check=False)
|
|
249
190
|
|
|
250
191
|
if __name__ == '__main__':
|
|
251
192
|
state = initializeGroupsOfFolds(MapFoldingState((2,4)))
|
|
252
|
-
pathModule = PurePosixPath(
|
|
253
|
-
# TODO put `pathFilenameFoldsTotal` in wsl.
|
|
193
|
+
pathModule = PurePosixPath(Path.home(), 'mapFolding', 'jobs')
|
|
254
194
|
pathFilenameFoldsTotal = PurePosixPath(getPathFilenameFoldsTotal(state.mapShape, pathModule))
|
|
255
195
|
aJob = RecipeJobTheorem2(state, pathModule=pathModule, pathFilenameFoldsTotal=pathFilenameFoldsTotal)
|
|
256
196
|
makeJob(aJob)
|
|
@@ -26,7 +26,9 @@ system to produce standalone modules optimized for specific map dimensions and c
|
|
|
26
26
|
"""
|
|
27
27
|
|
|
28
28
|
from astToolkit import identifierDotAttribute, IngredientsFunction, Make
|
|
29
|
-
from
|
|
29
|
+
from collections.abc import Callable
|
|
30
|
+
from numba.core.compiler import CompilerBase as numbaCompilerBase
|
|
31
|
+
from typing import Any, Final, NotRequired, TYPE_CHECKING, TypedDict
|
|
30
32
|
import ast
|
|
31
33
|
import dataclasses
|
|
32
34
|
import warnings
|
|
@@ -69,7 +71,7 @@ class ParametersNumba(TypedDict):
|
|
|
69
71
|
forceinline: NotRequired[bool]
|
|
70
72
|
forceobj: NotRequired[bool]
|
|
71
73
|
inline: NotRequired[str]
|
|
72
|
-
|
|
74
|
+
locals: NotRequired[dict[str, Any]]
|
|
73
75
|
looplift: NotRequired[bool]
|
|
74
76
|
no_cfunc_wrapper: NotRequired[bool]
|
|
75
77
|
no_cpython_wrapper: NotRequired[bool]
|
|
@@ -77,8 +79,8 @@ class ParametersNumba(TypedDict):
|
|
|
77
79
|
nogil: NotRequired[bool]
|
|
78
80
|
nopython: NotRequired[bool]
|
|
79
81
|
parallel: NotRequired[bool]
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
pipeline_class: NotRequired[type[numbaCompilerBase]]
|
|
83
|
+
signature_or_function: NotRequired[Any | Callable[..., Any] | str | tuple[Any, ...]]
|
|
82
84
|
target: NotRequired[str]
|
|
83
85
|
|
|
84
86
|
parametersNumbaDefault: Final[ParametersNumba] = { '_nrt': True, 'boundscheck': False, 'cache': True, 'error_model': 'numpy', 'fastmath': True, 'forceinline': True, 'inline': 'always', 'looplift': False, 'no_cfunc_wrapper': False, 'no_cpython_wrapper': False, 'nopython': True, 'parallel': False }
|
|
@@ -257,10 +259,10 @@ def decorateCallableWithNumba(ingredientsFunction: IngredientsFunction, paramete
|
|
|
257
259
|
|
|
258
260
|
if ingredientsFunction.astFunctionDef.returns and isinstance(ingredientsFunction.astFunctionDef.returns, ast.Name):
|
|
259
261
|
theReturn: ast.Name = ingredientsFunction.astFunctionDef.returns
|
|
260
|
-
list_argsDecorator = [
|
|
261
|
-
, list_arg4signature_or_function if list_arg4signature_or_function else [], [] )
|
|
262
|
+
list_argsDecorator = [Make.Call(Make.Name(theReturn.id)
|
|
263
|
+
, list_arg4signature_or_function if list_arg4signature_or_function else [], [] )]
|
|
262
264
|
elif list_arg4signature_or_function:
|
|
263
|
-
list_argsDecorator = [
|
|
265
|
+
list_argsDecorator = [Make.Tuple(list_arg4signature_or_function)]
|
|
264
266
|
|
|
265
267
|
ingredientsFunction.astFunctionDef = Z0Z_UnhandledDecorators(ingredientsFunction.astFunctionDef)
|
|
266
268
|
if parametersNumba is None:
|
|
@@ -20,16 +20,16 @@ mapFolding/reference/total_countPlus1vsPlusN.py,sha256=yJZAVLVdoXqHag2_N6_6CT-Q6
|
|
|
20
20
|
mapFolding/reference/jobsCompleted/__init__.py,sha256=TU93ZGUW1xEkT6d9mQFn_rp5DvRy0ZslEB2Q6MF5ZDc,2596
|
|
21
21
|
mapFolding/reference/jobsCompleted/[2x19]/p2x19.py,sha256=_tvYtfzMWVo2VtUbIAieoscb4N8FFflgTdW4-ljBUuA,19626
|
|
22
22
|
mapFolding/reference/jobsCompleted/p2x19/p2x19.py,sha256=eZEw4Me4ocTt6VXoK2-Sbd5SowZtxRIbN9dZmc7OCVg,6395
|
|
23
|
-
mapFolding/someAssemblyRequired/RecipeJob.py,sha256=
|
|
23
|
+
mapFolding/someAssemblyRequired/RecipeJob.py,sha256=yGGPHq9JX-Gf7QlJz50EPpkO7sADwGvSZNA1aC_F_PQ,9866
|
|
24
24
|
mapFolding/someAssemblyRequired/__init__.py,sha256=UNDh6O86jT5ywlw9LgeWsUHwOfNvoMJRDAzYXbwCbeM,5779
|
|
25
25
|
mapFolding/someAssemblyRequired/_toolIfThis.py,sha256=VDZC10Xo3E1Y5n6FmaBBbOBR-rinV9DFkpgw8zrDyzg,6339
|
|
26
|
-
mapFolding/someAssemblyRequired/_toolkitContainers.py,sha256=
|
|
26
|
+
mapFolding/someAssemblyRequired/_toolkitContainers.py,sha256=vRmetlZI1Kxhe6qjw7ysHeARn5e6F5hmB6ib2BCRxtE,13614
|
|
27
27
|
mapFolding/someAssemblyRequired/getLLVMforNoReason.py,sha256=tY0-2K0BFkwLAAjSrFJLPoG8CevDHOFc3OH3TxXANzg,2806
|
|
28
28
|
mapFolding/someAssemblyRequired/infoBooth.py,sha256=GWiqnHbqk7te_pvVuk4G_gbFa_W2aeSx19w4pakvqfM,2300
|
|
29
|
-
mapFolding/someAssemblyRequired/makeAllModules.py,sha256=
|
|
29
|
+
mapFolding/someAssemblyRequired/makeAllModules.py,sha256=o22qQ35N9M3N3kra16IayOpXMI1bkwVNQ5c04_rxMGw,44295
|
|
30
30
|
mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py,sha256=ZSplXKPwRAbvMA2bvEGcXFdgvuYGBk3Ncxajzk-Zy0A,17170
|
|
31
|
-
mapFolding/someAssemblyRequired/makeJobTheorem2codon.py,sha256=
|
|
32
|
-
mapFolding/someAssemblyRequired/toolkitNumba.py,sha256=
|
|
31
|
+
mapFolding/someAssemblyRequired/makeJobTheorem2codon.py,sha256=06FfCgHJDmNFv8li0v0O82Te8FvlFIOCm4OEMZ1EiRM,10160
|
|
32
|
+
mapFolding/someAssemblyRequired/toolkitNumba.py,sha256=nCCVsGidAlcKRVAvA__hu4bXtat3B-cO9YloKtqOAc4,14919
|
|
33
33
|
mapFolding/someAssemblyRequired/transformationTools.py,sha256=nPGZsvb5GquaCCxdDh_XzNIZYSiVJpWKd7wfhfRvxnk,11512
|
|
34
34
|
mapFolding/syntheticModules/__init__.py,sha256=evVFqhCGa-WZKDiLcnQWjs-Bj34eRnfSLqz_d7dFYZY,83
|
|
35
35
|
mapFolding/syntheticModules/countParallel.py,sha256=OK_IB9w4yy9MMAiGvkei5ezPm_00v2nYjPrQZ_IlELg,7733
|
|
@@ -46,9 +46,9 @@ mapFolding/tests/test_filesystem.py,sha256=0rYQ62f4e3HOoymXrxDWbqNEBJQ7DGN8RUOMI
|
|
|
46
46
|
mapFolding/tests/test_oeis.py,sha256=Sn3jpg6YQJMtAAc1W8Ic2PTbTwSckzBdJnkN1rz_O6w,5834
|
|
47
47
|
mapFolding/tests/test_other.py,sha256=ScBiJ78LnyAaW-RhxcouX6Xw10wgpSdqfvT4LO3WjnQ,4766
|
|
48
48
|
mapFolding/tests/test_tasks.py,sha256=_pr9JRWjjNKA7sww70XvkJJdGPruBVzubM63RmD_Du0,4013
|
|
49
|
-
mapfolding-0.13.
|
|
50
|
-
mapfolding-0.13.
|
|
51
|
-
mapfolding-0.13.
|
|
52
|
-
mapfolding-0.13.
|
|
53
|
-
mapfolding-0.13.
|
|
54
|
-
mapfolding-0.13.
|
|
49
|
+
mapfolding-0.13.1.dist-info/licenses/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
|
|
50
|
+
mapfolding-0.13.1.dist-info/METADATA,sha256=mBuToDW06Q7w6hF6KNus2yvB9FQ-V7Lsd958OEXcYrk,8040
|
|
51
|
+
mapfolding-0.13.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
52
|
+
mapfolding-0.13.1.dist-info/entry_points.txt,sha256=F3OUeZR1XDTpoH7k3wXuRb3KF_kXTTeYhu5AGK1SiOQ,146
|
|
53
|
+
mapfolding-0.13.1.dist-info/top_level.txt,sha256=aG3bjFBoxxuaV3Iu1wZAd241Ubs3cdaJtKYBQBDIjsg,11
|
|
54
|
+
mapfolding-0.13.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|