mapFolding 0.12.0__py3-none-any.whl → 0.12.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/Z0Z_makeAllModules.py +27 -27
- mapFolding/someAssemblyRequired/_toolIfThis.py +2 -2
- mapFolding/someAssemblyRequired/_toolkitContainers.py +4 -4
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +16 -16
- mapFolding/someAssemblyRequired/transformationTools.py +13 -13
- {mapfolding-0.12.0.dist-info → mapfolding-0.12.1.dist-info}/METADATA +2 -2
- {mapfolding-0.12.0.dist-info → mapfolding-0.12.1.dist-info}/RECORD +11 -11
- {mapfolding-0.12.0.dist-info → mapfolding-0.12.1.dist-info}/WHEEL +1 -1
- {mapfolding-0.12.0.dist-info → mapfolding-0.12.1.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.12.0.dist-info → mapfolding-0.12.1.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.12.0.dist-info → mapfolding-0.12.1.dist-info}/top_level.txt +0 -0
|
@@ -43,17 +43,17 @@ import dataclasses
|
|
|
43
43
|
|
|
44
44
|
def findDataclass(ingredientsFunction: IngredientsFunction) -> tuple[str, str, str]:
|
|
45
45
|
dataclassName: ast.expr = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
46
|
-
|
|
46
|
+
dataclassIdentifier: str = raiseIfNone(NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName))
|
|
47
47
|
dataclassLogicalPathModule = None
|
|
48
48
|
for moduleWithLogicalPath, listNameTuples in ingredientsFunction.imports.dictionaryImportFrom.items():
|
|
49
49
|
for nameTuple in listNameTuples:
|
|
50
|
-
if nameTuple[0] ==
|
|
50
|
+
if nameTuple[0] == dataclassIdentifier:
|
|
51
51
|
dataclassLogicalPathModule = moduleWithLogicalPath
|
|
52
52
|
break
|
|
53
53
|
if dataclassLogicalPathModule:
|
|
54
54
|
break
|
|
55
55
|
dataclassInstanceIdentifier = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
56
|
-
return raiseIfNone(dataclassLogicalPathModule),
|
|
56
|
+
return raiseIfNone(dataclassLogicalPathModule), dataclassIdentifier, dataclassInstanceIdentifier
|
|
57
57
|
|
|
58
58
|
def _getLogicalPath(packageName: str | None = None, logicalPathInfix: str | None = None, moduleIdentifier: str | None = None, *modules: str) -> str_nameDOTname:
|
|
59
59
|
listLogicalPathParts: list[str] = []
|
|
@@ -127,7 +127,7 @@ def makeDaoOfMapFolding(astModule: ast.Module, moduleIdentifier: str, callableId
|
|
|
127
127
|
astTuple = raiseIfNone(NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
128
128
|
cast(ast.Tuple, astTuple).ctx = ast.Store()
|
|
129
129
|
|
|
130
|
-
findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.
|
|
130
|
+
findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCallIdentifier(targetCallableIdentifier))
|
|
131
131
|
doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), cast(ast.Tuple, astTuple).elts)))
|
|
132
132
|
changeAssignCallToTarget = NodeChanger(findThis, doThat)
|
|
133
133
|
changeAssignCallToTarget.visit(ingredientsFunctionDispatcher.astFunctionDef)
|
|
@@ -150,31 +150,31 @@ def makeDaoOfMapFoldingParallel(astModule: ast.Module, moduleIdentifier: str, ca
|
|
|
150
150
|
ingredientsFunction.astFunctionDef.name = callableIdentifier
|
|
151
151
|
|
|
152
152
|
dataclassName: ast.expr = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
153
|
-
|
|
153
|
+
dataclassIdentifier: str = raiseIfNone(NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName))
|
|
154
154
|
|
|
155
155
|
dataclassLogicalPathModule = None
|
|
156
156
|
for moduleWithLogicalPath, listNameTuples in ingredientsFunction.imports.dictionaryImportFrom.items():
|
|
157
157
|
for nameTuple in listNameTuples:
|
|
158
|
-
if nameTuple[0] ==
|
|
158
|
+
if nameTuple[0] == dataclassIdentifier:
|
|
159
159
|
dataclassLogicalPathModule = moduleWithLogicalPath
|
|
160
160
|
break
|
|
161
161
|
if dataclassLogicalPathModule:
|
|
162
162
|
break
|
|
163
163
|
if dataclassLogicalPathModule is None: raise Exception
|
|
164
164
|
dataclassInstanceIdentifier = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
165
|
-
shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule,
|
|
165
|
+
shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclassIdentifier, dataclassInstanceIdentifier)
|
|
166
166
|
|
|
167
167
|
# Start add the parallel state fields to the count function ================================================
|
|
168
|
-
dataclassBaseFields = dataclasses.fields(importLogicalPath2Callable(dataclassLogicalPathModule,
|
|
169
|
-
|
|
170
|
-
dataclassFieldsParallel = dataclasses.fields(importLogicalPath2Callable(dataclassLogicalPathModule,
|
|
168
|
+
dataclassBaseFields = dataclasses.fields(importLogicalPath2Callable(dataclassLogicalPathModule, dataclassIdentifier)) # pyright: ignore [reportArgumentType]
|
|
169
|
+
dataclassIdentifierParallel = 'Parallel' + dataclassIdentifier
|
|
170
|
+
dataclassFieldsParallel = dataclasses.fields(importLogicalPath2Callable(dataclassLogicalPathModule, dataclassIdentifierParallel)) # pyright: ignore [reportArgumentType]
|
|
171
171
|
onlyParallelFields = [field for field in dataclassFieldsParallel if field.name not in [fieldBase.name for fieldBase in dataclassBaseFields]]
|
|
172
172
|
|
|
173
173
|
Official_fieldOrder: list[str] = []
|
|
174
174
|
dictionaryDeReConstruction: dict[str, DeReConstructField2ast] = {}
|
|
175
175
|
|
|
176
|
-
dataclassClassDef = extractClassDef(parseLogicalPath2astModule(dataclassLogicalPathModule),
|
|
177
|
-
if not isinstance(dataclassClassDef, ast.ClassDef): raise ValueError(f"I could not find `{
|
|
176
|
+
dataclassClassDef = extractClassDef(parseLogicalPath2astModule(dataclassLogicalPathModule), dataclassIdentifierParallel)
|
|
177
|
+
if not isinstance(dataclassClassDef, ast.ClassDef): raise ValueError(f"I could not find `{dataclassIdentifierParallel = }` in `{dataclassLogicalPathModule = }`.")
|
|
178
178
|
|
|
179
179
|
for aField in onlyParallelFields:
|
|
180
180
|
Official_fieldOrder.append(aField.name)
|
|
@@ -193,13 +193,13 @@ def makeDaoOfMapFoldingParallel(astModule: ast.Module, moduleIdentifier: str, ca
|
|
|
193
193
|
map_stateDOTfield2Name={**shatteredDataclass.map_stateDOTfield2Name, **{dictionaryDeReConstruction[field].ast_nameDOTname: dictionaryDeReConstruction[field].astName for field in Official_fieldOrder}},
|
|
194
194
|
)
|
|
195
195
|
shatteredDataclassParallel.fragments4AssignmentOrParameters = Make.Tuple(shatteredDataclassParallel.listName4Parameters, ast.Store())
|
|
196
|
-
shatteredDataclassParallel.repack = Make.Assign([Make.Name(dataclassInstanceIdentifier)], value=Make.Call(Make.Name(
|
|
196
|
+
shatteredDataclassParallel.repack = Make.Assign([Make.Name(dataclassInstanceIdentifier)], value=Make.Call(Make.Name(dataclassIdentifierParallel), list_keyword=shatteredDataclassParallel.list_keyword_field__field4init))
|
|
197
197
|
shatteredDataclassParallel.signatureReturnAnnotation = Make.Subscript(Make.Name('tuple'), Make.Tuple(shatteredDataclassParallel.listAnnotations))
|
|
198
198
|
|
|
199
199
|
shatteredDataclassParallel.imports.update(*(dictionaryDeReConstruction[field].ledger for field in Official_fieldOrder))
|
|
200
|
-
shatteredDataclassParallel.imports.addImportFrom_asStr(dataclassLogicalPathModule,
|
|
200
|
+
shatteredDataclassParallel.imports.addImportFrom_asStr(dataclassLogicalPathModule, dataclassIdentifierParallel)
|
|
201
201
|
shatteredDataclassParallel.imports.update(shatteredDataclass.imports)
|
|
202
|
-
shatteredDataclassParallel.imports.removeImportFrom(dataclassLogicalPathModule,
|
|
202
|
+
shatteredDataclassParallel.imports.removeImportFrom(dataclassLogicalPathModule, dataclassIdentifier)
|
|
203
203
|
|
|
204
204
|
# End add the parallel state fields to the count function ================================================
|
|
205
205
|
|
|
@@ -208,7 +208,7 @@ def makeDaoOfMapFoldingParallel(astModule: ast.Module, moduleIdentifier: str, ca
|
|
|
208
208
|
|
|
209
209
|
# Start add the parallel logic to the count function ================================================
|
|
210
210
|
|
|
211
|
-
findThis = ClassIsAndAttribute.testIs(ast.While, ClassIsAndAttribute.leftIs(ast.Compare, IfThis.
|
|
211
|
+
findThis = ClassIsAndAttribute.testIs(ast.While, ClassIsAndAttribute.leftIs(ast.Compare, IfThis.isNameIdentifier('leafConnectee')))
|
|
212
212
|
doThat = Then.extractIt(DOT.body)
|
|
213
213
|
captureCountGapsCodeBlock: NodeTourist[ast.While, Sequence[ast.stmt]] = NodeTourist(findThis, doThat)
|
|
214
214
|
countGapsCodeBlock = raiseIfNone(captureCountGapsCodeBlock.captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
@@ -233,30 +233,30 @@ def makeDaoOfMapFoldingParallel(astModule: ast.Module, moduleIdentifier: str, ca
|
|
|
233
233
|
sourceCallableIdentifier = sourceCallableDispatcherDEFAULT
|
|
234
234
|
|
|
235
235
|
unRepackDataclass: IngredientsFunction = astModuleToIngredientsFunction(astModule, sourceCallableIdentifier)
|
|
236
|
-
unRepackDataclass.astFunctionDef.name = 'unRepack' +
|
|
236
|
+
unRepackDataclass.astFunctionDef.name = 'unRepack' + dataclassIdentifierParallel
|
|
237
237
|
unRepackDataclass.imports.update(shatteredDataclassParallel.imports)
|
|
238
|
-
findThis = ClassIsAndAttribute.annotationIs(ast.arg, IfThis.
|
|
239
|
-
doThat = Grab.annotationAttribute(Grab.idAttribute(Then.replaceWith(
|
|
238
|
+
findThis = ClassIsAndAttribute.annotationIs(ast.arg, IfThis.isNameIdentifier(dataclassIdentifier)) # pyright: ignore[reportArgumentType, reportUnknownVariableType, reportCallIssue]
|
|
239
|
+
doThat = Grab.annotationAttribute(Grab.idAttribute(Then.replaceWith(dataclassIdentifierParallel))) # pyright: ignore[reportArgumentType]
|
|
240
240
|
NodeChanger(findThis, doThat).visit(unRepackDataclass.astFunctionDef) # pyright: ignore[reportUnknownArgumentType]
|
|
241
|
-
unRepackDataclass.astFunctionDef.returns = Make.Name(
|
|
241
|
+
unRepackDataclass.astFunctionDef.returns = Make.Name(dataclassIdentifierParallel)
|
|
242
242
|
targetCallableIdentifier = ingredientsFunction.astFunctionDef.name
|
|
243
243
|
unRepackDataclass = unpackDataclassCallFunctionRepackDataclass(unRepackDataclass, targetCallableIdentifier, shatteredDataclassParallel)
|
|
244
244
|
|
|
245
245
|
astTuple = raiseIfNone(NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
246
246
|
cast(ast.Tuple, astTuple).ctx = ast.Store()
|
|
247
|
-
findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.
|
|
247
|
+
findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCallIdentifier(targetCallableIdentifier))
|
|
248
248
|
doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), cast(ast.Tuple, astTuple).elts)))
|
|
249
249
|
changeAssignCallToTarget = NodeChanger(findThis, doThat)
|
|
250
250
|
changeAssignCallToTarget.visit(unRepackDataclass.astFunctionDef)
|
|
251
251
|
|
|
252
252
|
ingredientsDoTheNeedful: IngredientsFunction = IngredientsFunction(
|
|
253
253
|
astFunctionDef = ast.FunctionDef(name='doTheNeedful'
|
|
254
|
-
, args=ast.arguments(args=[ast.arg('state', annotation=ast.Name(
|
|
254
|
+
, args=ast.arguments(args=[ast.arg('state', annotation=ast.Name(dataclassIdentifierParallel)), ast.arg('concurrencyLimit', annotation=ast.Name('int'))])
|
|
255
255
|
, body=[ast.Assign(targets=[ast.Name('stateParallel', ctx=ast.Store())], value=ast.Call(func=ast.Name('deepcopy'), args=[ast.Name('state')]))
|
|
256
|
-
, ast.AnnAssign(target=ast.Name('listStatesParallel', ctx=ast.Store()), annotation=ast.Subscript(value=ast.Name('list'), slice=ast.Name(
|
|
256
|
+
, ast.AnnAssign(target=ast.Name('listStatesParallel', ctx=ast.Store()), annotation=ast.Subscript(value=ast.Name('list'), slice=ast.Name(dataclassIdentifierParallel)), value=ast.BinOp(left=ast.List(elts=[ast.Name('stateParallel')]), op=ast.Mult(), right=ast.Attribute(value=ast.Name('stateParallel'), attr='taskDivisions')), simple=1)
|
|
257
257
|
, ast.AnnAssign(target=ast.Name('groupsOfFoldsTotal', ctx=ast.Store()), annotation=ast.Name('int'), value=ast.Constant(value=0), simple=1)
|
|
258
258
|
|
|
259
|
-
, ast.AnnAssign(target=ast.Name('dictionaryConcurrency', ctx=ast.Store()), annotation=ast.Subscript(value=ast.Name('dict'), slice=ast.Tuple(elts=[ast.Name('int'), ast.Subscript(value=ast.Name('ConcurrentFuture'), slice=ast.Name(
|
|
259
|
+
, ast.AnnAssign(target=ast.Name('dictionaryConcurrency', ctx=ast.Store()), annotation=ast.Subscript(value=ast.Name('dict'), slice=ast.Tuple(elts=[ast.Name('int'), ast.Subscript(value=ast.Name('ConcurrentFuture'), slice=ast.Name(dataclassIdentifierParallel))])), value=ast.Dict(), simple=1)
|
|
260
260
|
, ast.With(items=[ast.withitem(context_expr=ast.Call(func=ast.Name('ProcessPoolExecutor'), args=[ast.Name('concurrencyLimit')]), optional_vars=ast.Name('concurrencyManager', ctx=ast.Store()))]
|
|
261
261
|
, body=[ast.For(target=ast.Name('indexSherpa', ctx=ast.Store()), iter=ast.Call(func=ast.Name('range'), args=[ast.Attribute(value=ast.Name('stateParallel'), attr='taskDivisions')])
|
|
262
262
|
, body=[ast.Assign(targets=[ast.Name('state', ctx=ast.Store())], value=ast.Call(func=ast.Name('deepcopy'), args=[ast.Name('stateParallel')]))
|
|
@@ -268,7 +268,7 @@ def makeDaoOfMapFoldingParallel(astModule: ast.Module, moduleIdentifier: str, ca
|
|
|
268
268
|
|
|
269
269
|
, ast.AnnAssign(target=ast.Name('foldsTotal', ctx=ast.Store()), annotation=ast.Name('int'), value=ast.BinOp(left=ast.Name('groupsOfFoldsTotal'), op=ast.Mult(), right=ast.Attribute(value=ast.Name('stateParallel'), attr='leavesTotal')), simple=1)
|
|
270
270
|
, ast.Return(value=ast.Tuple(elts=[ast.Name('foldsTotal'), ast.Name('listStatesParallel')]))]
|
|
271
|
-
, returns=ast.Subscript(value=ast.Name('tuple'), slice=ast.Tuple(elts=[ast.Name('int'), ast.Subscript(value=ast.Name('list'), slice=ast.Name(
|
|
271
|
+
, returns=ast.Subscript(value=ast.Name('tuple'), slice=ast.Tuple(elts=[ast.Name('int'), ast.Subscript(value=ast.Name('list'), slice=ast.Name(dataclassIdentifierParallel))])))
|
|
272
272
|
, imports = LedgerOfImports(Make.Module([ast.ImportFrom(module='concurrent.futures', names=[ast.alias(name='Future', asname='ConcurrentFuture'), ast.alias(name='ProcessPoolExecutor')], level=0),
|
|
273
273
|
ast.ImportFrom(module='copy', names=[ast.alias(name='deepcopy')], level=0),
|
|
274
274
|
ast.ImportFrom(module='multiprocessing', names=[ast.alias(name='set_start_method', asname='multiprocessing_set_start_method')], level=0),])
|
|
@@ -339,7 +339,7 @@ def trimTheorem2(astModule: ast.Module, moduleIdentifier: str, callableIdentifie
|
|
|
339
339
|
|
|
340
340
|
dataclassInstanceIdentifier = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
341
341
|
|
|
342
|
-
findThis = IfThis.
|
|
342
|
+
findThis = IfThis.isIfUnaryNotAttributeNamespaceIdentifier(dataclassInstanceIdentifier, 'dimensionsUnconstrained')
|
|
343
343
|
doThat = Then.removeIt
|
|
344
344
|
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
345
345
|
|
|
@@ -399,7 +399,7 @@ def makeUnRePackDataclass(astImportFrom: ast.ImportFrom) -> None:
|
|
|
399
399
|
astTuple = raiseIfNone(NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(targetFunctionDef))
|
|
400
400
|
cast(ast.Tuple, astTuple).ctx = ast.Store()
|
|
401
401
|
|
|
402
|
-
findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.
|
|
402
|
+
findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCallIdentifier(targetCallableIdentifier))
|
|
403
403
|
doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), cast(ast.Tuple, astTuple).elts)))
|
|
404
404
|
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
405
405
|
|
|
@@ -38,7 +38,7 @@ class IfThis(astToolkit_IfThis):
|
|
|
38
38
|
@staticmethod
|
|
39
39
|
def isAttributeNamespaceIdentifierGreaterThan0(namespace: str, identifier: str) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
|
|
40
40
|
return lambda node: (Be.Compare(node)
|
|
41
|
-
and IfThis.
|
|
41
|
+
and IfThis.isAttributeNamespaceIdentifier(namespace, identifier)(DOT.left(node))
|
|
42
42
|
and Be.Gt(node.ops[0])
|
|
43
43
|
and IfThis.isConstant_value(0)(node.comparators[0]))
|
|
44
44
|
@staticmethod
|
|
@@ -54,5 +54,5 @@ class IfThis(astToolkit_IfThis):
|
|
|
54
54
|
@staticmethod
|
|
55
55
|
def isAttributeNamespaceIdentifierLessThanOrEqual0(namespace: str, identifier: str) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
|
|
56
56
|
return lambda node: (Be.Compare(node)
|
|
57
|
-
and IfThis.
|
|
57
|
+
and IfThis.isAttributeNamespaceIdentifier(namespace, identifier)(DOT.left(node))
|
|
58
58
|
and Be.LtE(node.ops[0]))
|
|
@@ -93,7 +93,7 @@ class DeReConstructField2ast:
|
|
|
93
93
|
"""
|
|
94
94
|
dataclassesDOTdataclassLogicalPathModule: dataclasses.InitVar[str_nameDOTname]
|
|
95
95
|
dataclassClassDef: dataclasses.InitVar[ast.ClassDef]
|
|
96
|
-
|
|
96
|
+
dataclassesDOTdataclassInstanceIdentifier: dataclasses.InitVar[str]
|
|
97
97
|
field: dataclasses.InitVar[dataclasses.Field[Any]]
|
|
98
98
|
|
|
99
99
|
ledger: LedgerOfImports = dataclasses.field(default_factory=LedgerOfImports)
|
|
@@ -117,7 +117,7 @@ class DeReConstructField2ast:
|
|
|
117
117
|
astAnnAssignConstructor: ast.AnnAssign|ast.Assign = dataclasses.field(init=False)
|
|
118
118
|
Z0Z_hack: tuple[ast.AnnAssign|ast.Assign, str] = dataclasses.field(init=False)
|
|
119
119
|
|
|
120
|
-
def __post_init__(self, dataclassesDOTdataclassLogicalPathModule: str_nameDOTname, dataclassClassDef: ast.ClassDef,
|
|
120
|
+
def __post_init__(self, dataclassesDOTdataclassLogicalPathModule: str_nameDOTname, dataclassClassDef: ast.ClassDef, dataclassesDOTdataclassInstanceIdentifier: str, field: dataclasses.Field[Any]) -> None:
|
|
121
121
|
self.compare = field.compare
|
|
122
122
|
self.default = field.default if field.default is not dataclasses.MISSING else None
|
|
123
123
|
self.default_factory = field.default_factory if field.default_factory is not dataclasses.MISSING else None
|
|
@@ -131,10 +131,10 @@ class DeReConstructField2ast:
|
|
|
131
131
|
|
|
132
132
|
self.astName = Make.Name(self.name)
|
|
133
133
|
self.ast_keyword_field__field = Make.keyword(self.name, self.astName)
|
|
134
|
-
self.ast_nameDOTname = Make.Attribute(Make.Name(
|
|
134
|
+
self.ast_nameDOTname = Make.Attribute(Make.Name(dataclassesDOTdataclassInstanceIdentifier), self.name)
|
|
135
135
|
|
|
136
136
|
sherpa = NodeTourist( # pyright: ignore[reportUnknownVariableType]
|
|
137
|
-
findThis=ClassIsAndAttribute.targetIs(ast.AnnAssign, IfThis.
|
|
137
|
+
findThis=ClassIsAndAttribute.targetIs(ast.AnnAssign, IfThis.isNameIdentifier(self.name))
|
|
138
138
|
, doThat=Then.extractIt(DOT.annotation) # pyright: ignore[reportArgumentType]
|
|
139
139
|
).captureLastMatch(dataclassClassDef)
|
|
140
140
|
|
|
@@ -23,15 +23,15 @@ from Z0Z_tools import autoDecodingRLE
|
|
|
23
23
|
import ast
|
|
24
24
|
"""Synthesize one file to compute `foldsTotal` of `mapShape`."""
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
listIdentifiersNotUsedAllHARDCODED = ['concurrencyLimit', 'foldsTotal', 'mapShape',]
|
|
27
|
+
listIdentifiersNotUsedParallelSequentialHARDCODED = ['indexLeaf']
|
|
28
|
+
listIdentifiersNotUsedSequentialHARDCODED = ['foldGroups', 'taskDivisions', 'taskIndex',]
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
listIdentifiersReplacedHARDCODED = ['groupsOfFolds',]
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
listIdentifiersStaticValuesHARDCODED = ['dimensionsTotal', 'leavesTotal',]
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
listIdentifiersNotUsedHARDCODED = listIdentifiersStaticValuesHARDCODED + listIdentifiersReplacedHARDCODED + listIdentifiersNotUsedAllHARDCODED + listIdentifiersNotUsedParallelSequentialHARDCODED + listIdentifiersNotUsedSequentialHARDCODED
|
|
35
35
|
|
|
36
36
|
def addLauncherNumbaProgress(ingredientsModule: IngredientsModule, ingredientsFunction: IngredientsFunction, job: RecipeJobTheorem2Numba, spices: SpicesJobNumba) -> tuple[IngredientsModule, IngredientsFunction]:
|
|
37
37
|
"""
|
|
@@ -76,7 +76,7 @@ if __name__ == '__main__':
|
|
|
76
76
|
ast_argNumbaProgress = ast.arg(arg=spices.numbaProgressBarIdentifier, annotation=ast.Name(id=numba_progressPythonClass, ctx=ast.Load()))
|
|
77
77
|
ingredientsFunction.astFunctionDef.args.args.append(ast_argNumbaProgress)
|
|
78
78
|
|
|
79
|
-
findThis = ClassIsAndAttribute.targetIs(ast.AugAssign, IfThis.
|
|
79
|
+
findThis = ClassIsAndAttribute.targetIs(ast.AugAssign, IfThis.isNameIdentifier(job.shatteredDataclass.countingVariableName.id))
|
|
80
80
|
doThat = Then.replaceWith(Make.Expr(Make.Call(Make.Attribute(Make.Name(spices.numbaProgressBarIdentifier),'update'),[Make.Constant(1)])))
|
|
81
81
|
countWithProgressBar = NodeChanger(findThis, doThat)
|
|
82
82
|
countWithProgressBar.visit(ingredientsFunction.astFunctionDef)
|
|
@@ -119,12 +119,12 @@ def move_arg2FunctionDefDOTbodyAndAssignInitialValues(ingredientsFunction: Ingre
|
|
|
119
119
|
list_arg_arg: list[str] = [ast_arg.arg for ast_arg in list_argCuzMyBrainRefusesToThink]
|
|
120
120
|
listName: list[ast.Name] = []
|
|
121
121
|
NodeTourist(Be.Name, Then.appendTo(listName)).visit(ingredientsFunction.astFunctionDef)
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
listIdentifiers: list[str] = [astName.id for astName in listName]
|
|
123
|
+
listIdentifiersNotUsed: list[str] = list(set(list_arg_arg) - set(listIdentifiers))
|
|
124
124
|
|
|
125
125
|
for ast_arg in list_argCuzMyBrainRefusesToThink:
|
|
126
126
|
if ast_arg.arg in job.shatteredDataclass.field2AnnAssign:
|
|
127
|
-
if ast_arg.arg in
|
|
127
|
+
if ast_arg.arg in listIdentifiersNotUsed:
|
|
128
128
|
pass
|
|
129
129
|
else:
|
|
130
130
|
ImaAnnAssign, elementConstructor = job.shatteredDataclass.Z0Z_field2AnnAssign[ast_arg.arg]
|
|
@@ -146,7 +146,7 @@ def move_arg2FunctionDefDOTbodyAndAssignInitialValues(ingredientsFunction: Ingre
|
|
|
146
146
|
|
|
147
147
|
ingredientsFunction.astFunctionDef.body.insert(0, ImaAnnAssign)
|
|
148
148
|
|
|
149
|
-
findThis = IfThis.
|
|
149
|
+
findThis = IfThis.is_argIdentifier(ast_arg.arg)
|
|
150
150
|
remove_arg = NodeChanger(findThis, Then.removeIt)
|
|
151
151
|
remove_arg.visit(ingredientsFunction.astFunctionDef)
|
|
152
152
|
|
|
@@ -160,16 +160,16 @@ def makeJobNumba(job: RecipeJobTheorem2Numba, spices: SpicesJobNumba) -> None:
|
|
|
160
160
|
ingredientsCount: IngredientsFunction = IngredientsFunction(astFunctionDef, LedgerOfImports())
|
|
161
161
|
|
|
162
162
|
# Remove `foldGroups` and any other unused statements, so you can dynamically determine which variables are not used
|
|
163
|
-
findThis = ClassIsAndAttribute.targetsIs(ast.Assign, lambda list_expr: any([IfThis.
|
|
164
|
-
# findThis = IfThis.isAssignAndTargets0Is(IfThis.
|
|
163
|
+
findThis = ClassIsAndAttribute.targetsIs(ast.Assign, lambda list_expr: any([IfThis.isSubscriptIdentifier('foldGroups')(node) for node in list_expr ]))
|
|
164
|
+
# findThis = IfThis.isAssignAndTargets0Is(IfThis.isSubscriptIdentifier('foldGroups'))
|
|
165
165
|
doThat = Then.removeIt
|
|
166
166
|
remove_foldGroups = NodeChanger(findThis, doThat)
|
|
167
167
|
# remove_foldGroups.visit(ingredientsCount.astFunctionDef)
|
|
168
168
|
|
|
169
169
|
# replace identifiers with static values with their values, so you can dynamically determine which variables are not used
|
|
170
|
-
|
|
171
|
-
for identifier in
|
|
172
|
-
findThis = IfThis.
|
|
170
|
+
listIdentifiersStaticValues = listIdentifiersStaticValuesHARDCODED
|
|
171
|
+
for identifier in listIdentifiersStaticValues:
|
|
172
|
+
findThis = IfThis.isNameIdentifier(identifier)
|
|
173
173
|
doThat = Then.replaceWith(Make.Constant(int(job.state.__dict__[identifier])))
|
|
174
174
|
NodeChanger(findThis, doThat).visit(ingredientsCount.astFunctionDef)
|
|
175
175
|
|
|
@@ -39,7 +39,7 @@ from Z0Z_tools import importLogicalPath2Callable
|
|
|
39
39
|
import ast
|
|
40
40
|
import dataclasses
|
|
41
41
|
|
|
42
|
-
def shatter_dataclassesDOTdataclass(logicalPathModule: str_nameDOTname,
|
|
42
|
+
def shatter_dataclassesDOTdataclass(logicalPathModule: str_nameDOTname, dataclassIdentifier: str, instanceIdentifier: str) -> ShatteredDataclass:
|
|
43
43
|
"""
|
|
44
44
|
Decompose a dataclass definition into AST components for manipulation and code generation.
|
|
45
45
|
|
|
@@ -59,8 +59,8 @@ def shatter_dataclassesDOTdataclass(logicalPathModule: str_nameDOTname, dataclas
|
|
|
59
59
|
|
|
60
60
|
Parameters:
|
|
61
61
|
logicalPathModule: The fully qualified module path containing the dataclass definition.
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
dataclassIdentifier: The name of the dataclass to decompose.
|
|
63
|
+
instanceIdentifier: The variable name to use for the dataclass instance in generated code.
|
|
64
64
|
|
|
65
65
|
Returns:
|
|
66
66
|
shatteredDataclass: A ShatteredDataclass containing AST representations of all dataclass components,
|
|
@@ -72,19 +72,19 @@ def shatter_dataclassesDOTdataclass(logicalPathModule: str_nameDOTname, dataclas
|
|
|
72
72
|
Official_fieldOrder: list[str] = []
|
|
73
73
|
dictionaryDeReConstruction: dict[str, DeReConstructField2ast] = {}
|
|
74
74
|
|
|
75
|
-
dataclassClassDef = extractClassDef(parseLogicalPath2astModule(logicalPathModule),
|
|
76
|
-
if not isinstance(dataclassClassDef, ast.ClassDef): raise ValueError(f"I could not find `{
|
|
75
|
+
dataclassClassDef = extractClassDef(parseLogicalPath2astModule(logicalPathModule), dataclassIdentifier)
|
|
76
|
+
if not isinstance(dataclassClassDef, ast.ClassDef): raise ValueError(f"I could not find `{dataclassIdentifier = }` in `{logicalPathModule = }`.")
|
|
77
77
|
|
|
78
78
|
countingVariable = None
|
|
79
|
-
for aField in dataclasses.fields(importLogicalPath2Callable(logicalPathModule,
|
|
79
|
+
for aField in dataclasses.fields(importLogicalPath2Callable(logicalPathModule, dataclassIdentifier)): # pyright: ignore [reportArgumentType]
|
|
80
80
|
Official_fieldOrder.append(aField.name)
|
|
81
|
-
dictionaryDeReConstruction[aField.name] = DeReConstructField2ast(logicalPathModule, dataclassClassDef,
|
|
81
|
+
dictionaryDeReConstruction[aField.name] = DeReConstructField2ast(logicalPathModule, dataclassClassDef, instanceIdentifier, aField)
|
|
82
82
|
if aField.metadata.get('theCountingIdentifier', False):
|
|
83
83
|
countingVariable = dictionaryDeReConstruction[aField.name].name
|
|
84
84
|
|
|
85
85
|
if countingVariable is None:
|
|
86
86
|
import warnings
|
|
87
|
-
warnings.warn(message=f"I could not find the counting variable in `{
|
|
87
|
+
warnings.warn(message=f"I could not find the counting variable in `{dataclassIdentifier = }` in `{logicalPathModule = }`.", category=UserWarning)
|
|
88
88
|
raise Exception
|
|
89
89
|
|
|
90
90
|
shatteredDataclass = ShatteredDataclass(
|
|
@@ -100,11 +100,11 @@ def shatter_dataclassesDOTdataclass(logicalPathModule: str_nameDOTname, dataclas
|
|
|
100
100
|
map_stateDOTfield2Name={dictionaryDeReConstruction[field].ast_nameDOTname: dictionaryDeReConstruction[field].astName for field in Official_fieldOrder},
|
|
101
101
|
)
|
|
102
102
|
shatteredDataclass.fragments4AssignmentOrParameters = Make.Tuple(shatteredDataclass.listName4Parameters, ast.Store())
|
|
103
|
-
shatteredDataclass.repack = Make.Assign([Make.Name(
|
|
103
|
+
shatteredDataclass.repack = Make.Assign([Make.Name(instanceIdentifier)], value=Make.Call(Make.Name(dataclassIdentifier), list_keyword=shatteredDataclass.list_keyword_field__field4init))
|
|
104
104
|
shatteredDataclass.signatureReturnAnnotation = Make.Subscript(Make.Name('tuple'), Make.Tuple(shatteredDataclass.listAnnotations))
|
|
105
105
|
|
|
106
106
|
shatteredDataclass.imports.update(*(dictionaryDeReConstruction[field].ledger for field in Official_fieldOrder))
|
|
107
|
-
shatteredDataclass.imports.addImportFrom_asStr(logicalPathModule,
|
|
107
|
+
shatteredDataclass.imports.addImportFrom_asStr(logicalPathModule, dataclassIdentifier)
|
|
108
108
|
|
|
109
109
|
return shatteredDataclass
|
|
110
110
|
|
|
@@ -118,9 +118,9 @@ def removeDataclassFromFunction(ingredientsTarget: IngredientsFunction, shattere
|
|
|
118
118
|
|
|
119
119
|
def unpackDataclassCallFunctionRepackDataclass(ingredientsCaller: IngredientsFunction, targetCallableIdentifier: str, shatteredDataclass: ShatteredDataclass) -> IngredientsFunction:
|
|
120
120
|
astCallTargetCallable = Make.Call(Make.Name(targetCallableIdentifier), shatteredDataclass.listName4Parameters)
|
|
121
|
-
replaceAssignTargetCallable = NodeChanger(ClassIsAndAttribute.valueIs(ast.Assign, IfThis.
|
|
122
|
-
unpack4targetCallable = NodeChanger(ClassIsAndAttribute.valueIs(ast.Assign, IfThis.
|
|
123
|
-
repack4targetCallable = NodeChanger(ClassIsAndAttribute.valueIs(ast.Assign, IfThis.
|
|
121
|
+
replaceAssignTargetCallable = NodeChanger(ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCallIdentifier(targetCallableIdentifier)), Then.replaceWith(Make.Assign([shatteredDataclass.fragments4AssignmentOrParameters], value=astCallTargetCallable)))
|
|
122
|
+
unpack4targetCallable = NodeChanger(ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCallIdentifier(targetCallableIdentifier)), Then.insertThisAbove(shatteredDataclass.listUnpack))
|
|
123
|
+
repack4targetCallable = NodeChanger(ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCallIdentifier(targetCallableIdentifier)), Then.insertThisBelow([shatteredDataclass.repack]))
|
|
124
124
|
replaceAssignTargetCallable.visit(ingredientsCaller.astFunctionDef)
|
|
125
125
|
unpack4targetCallable.visit(ingredientsCaller.astFunctionDef)
|
|
126
126
|
repack4targetCallable.visit(ingredientsCaller.astFunctionDef)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mapFolding
|
|
3
|
-
Version: 0.12.
|
|
3
|
+
Version: 0.12.1
|
|
4
4
|
Summary: Map folding algorithm with code transformation framework for optimizing numerical computations
|
|
5
5
|
Author-email: Hunter Hogan <HunterHogan@pm.me>
|
|
6
6
|
License: CC-BY-NC-4.0
|
|
@@ -29,7 +29,7 @@ Classifier: Typing :: Typed
|
|
|
29
29
|
Requires-Python: >=3.12
|
|
30
30
|
Description-Content-Type: text/markdown
|
|
31
31
|
License-File: LICENSE
|
|
32
|
-
Requires-Dist: astToolkit
|
|
32
|
+
Requires-Dist: astToolkit>=0.3.0
|
|
33
33
|
Requires-Dist: autoflake
|
|
34
34
|
Requires-Dist: numba_progress
|
|
35
35
|
Requires-Dist: numba
|
|
@@ -21,15 +21,15 @@ mapFolding/reference/jobsCompleted/__init__.py,sha256=TU93ZGUW1xEkT6d9mQFn_rp5Dv
|
|
|
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
23
|
mapFolding/someAssemblyRequired/RecipeJob.py,sha256=oDOg5FVGTlnZQFW1K0OVucoHbApjsLTpPXy9GtMbjp4,4339
|
|
24
|
-
mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py,sha256
|
|
24
|
+
mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py,sha256=-YAScEzC13nvECZloNYZo-uvZOriLQUiSYaMxMmjsA8,28843
|
|
25
25
|
mapFolding/someAssemblyRequired/__init__.py,sha256=ndEXbwc6SSGnAyYkgL2I4nvDGQa8EbJu_f9l9NJwTsw,2931
|
|
26
|
-
mapFolding/someAssemblyRequired/_toolIfThis.py,sha256=
|
|
27
|
-
mapFolding/someAssemblyRequired/_toolkitContainers.py,sha256=
|
|
26
|
+
mapFolding/someAssemblyRequired/_toolIfThis.py,sha256=cOQC6ldgFdn7djpLR-Qo8mj_rePTrpal6_cg_rR4Lzs,3010
|
|
27
|
+
mapFolding/someAssemblyRequired/_toolkitContainers.py,sha256=XoOxTijpbYJK2hFPzSqOrd-UOG0_FQzhS_n240hsUMo,9763
|
|
28
28
|
mapFolding/someAssemblyRequired/getLLVMforNoReason.py,sha256=9RPU6vK_eUg64GtVFI_nZnvUryXw8gfHJs9NyDYHIvg,2745
|
|
29
29
|
mapFolding/someAssemblyRequired/infoBooth.py,sha256=RbYswVvjE0mfORepk4tUzScMCb7WYf0GFMs0u-MUmn0,635
|
|
30
|
-
mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py,sha256=
|
|
30
|
+
mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py,sha256=nJlqE-PVbylfUa8NxfgjouYfpWlBFtmgPv1JW0S0pB4,13905
|
|
31
31
|
mapFolding/someAssemblyRequired/toolkitNumba.py,sha256=F4DriKPj9TeEJ1qB9H74ekJfMfw2vJvW1zeJXHtxE0E,6680
|
|
32
|
-
mapFolding/someAssemblyRequired/transformationTools.py,sha256=
|
|
32
|
+
mapFolding/someAssemblyRequired/transformationTools.py,sha256=Gt-kB1JqXfLgiM_SGjUZxcx8MoZo6d7pYaoNmTbrgfY,7853
|
|
33
33
|
mapFolding/syntheticModules/__init__.py,sha256=evVFqhCGa-WZKDiLcnQWjs-Bj34eRnfSLqz_d7dFYZY,83
|
|
34
34
|
mapFolding/syntheticModules/countParallel.py,sha256=OK_IB9w4yy9MMAiGvkei5ezPm_00v2nYjPrQZ_IlELg,7733
|
|
35
35
|
mapFolding/syntheticModules/daoOfMapFolding.py,sha256=cfWPABtXyCxJ0BwPI7rhfLh_2UYV_XKAL8lJ4GLNXaQ,5896
|
|
@@ -38,7 +38,7 @@ mapFolding/syntheticModules/initializeCount.py,sha256=nWSlJMMfIM3DvZxMn6ISQusUJq
|
|
|
38
38
|
mapFolding/syntheticModules/theorem2.py,sha256=9jrbZNNX4BWYZW1S0JjvRY2k7RU7I1RNUMV7JdCt1ZY,3017
|
|
39
39
|
mapFolding/syntheticModules/theorem2Numba.py,sha256=-cKjNyxgUMFhEyFVs0VJ7hw4LfrV0WSNK5tPYbQ1oNU,3369
|
|
40
40
|
mapFolding/syntheticModules/theorem2Trimmed.py,sha256=DHW3NxBdtABQYBKm2WRvfQ5kzc2_UwGI2h4ePuYEJoM,2685
|
|
41
|
-
mapfolding-0.12.
|
|
41
|
+
mapfolding-0.12.1.dist-info/licenses/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
|
|
42
42
|
tests/__init__.py,sha256=5VhHf0JJ2_DSh58zJ0rR5UkpoCon-0IkdljspTCzZ04,1950
|
|
43
43
|
tests/conftest.py,sha256=eumQRoDuWVrhsjDxWXGhW0N7lH0ZZ9XD-5q81bWFqOs,10874
|
|
44
44
|
tests/test_computations.py,sha256=HNpfs9Yz3rdfJInD15Jwd6DYsSR5TCwnR5EW0n7KbeI,5682
|
|
@@ -46,8 +46,8 @@ tests/test_filesystem.py,sha256=imlcetleJc4G9pDZTgS1j8UAs7ADbRxXVuNPecJAvqc,2964
|
|
|
46
46
|
tests/test_oeis.py,sha256=uxvwmgbnylSDdsVJfuAT0LuYLbIVFwSgdLxHm-xUGBM,5043
|
|
47
47
|
tests/test_other.py,sha256=DT7YE82YCHrSjdxhpY4UJnXmZvDm1b4e1QpZV3LyzcM,3747
|
|
48
48
|
tests/test_tasks.py,sha256=pEDukf2SVTOMEsn82JpAWKQzn1ZCTlkhLzQ5hYLg2yY,2780
|
|
49
|
-
mapfolding-0.12.
|
|
50
|
-
mapfolding-0.12.
|
|
51
|
-
mapfolding-0.12.
|
|
52
|
-
mapfolding-0.12.
|
|
53
|
-
mapfolding-0.12.
|
|
49
|
+
mapfolding-0.12.1.dist-info/METADATA,sha256=t1Kp8tQ-xZP-VCuxz5dMWu47UJafTcDu0kG7Pmaxi8g,7617
|
|
50
|
+
mapfolding-0.12.1.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
|
51
|
+
mapfolding-0.12.1.dist-info/entry_points.txt,sha256=F3OUeZR1XDTpoH7k3wXuRb3KF_kXTTeYhu5AGK1SiOQ,146
|
|
52
|
+
mapfolding-0.12.1.dist-info/top_level.txt,sha256=1gP2vFaqPwHujGwb3UjtMlLEGN-943VSYFR7V4gDqW8,17
|
|
53
|
+
mapfolding-0.12.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|