mapFolding 0.11.1__py3-none-any.whl → 0.11.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.
Files changed (35) hide show
  1. mapFolding/__init__.py +7 -60
  2. mapFolding/basecamp.py +15 -13
  3. mapFolding/beDRY.py +4 -36
  4. mapFolding/dataBaskets.py +24 -2
  5. mapFolding/datatypes.py +0 -3
  6. mapFolding/{toolboxFilesystem.py → filesystemToolkit.py} +3 -3
  7. mapFolding/oeis.py +3 -5
  8. mapFolding/someAssemblyRequired/RecipeJob.py +8 -116
  9. mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py +492 -0
  10. mapFolding/someAssemblyRequired/__init__.py +5 -31
  11. mapFolding/someAssemblyRequired/_toolIfThis.py +5 -6
  12. mapFolding/someAssemblyRequired/{_toolboxContainers.py → _toolkitContainers.py} +6 -127
  13. mapFolding/someAssemblyRequired/infoBooth.py +70 -0
  14. mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +13 -12
  15. mapFolding/someAssemblyRequired/{toolboxNumba.py → toolkitNumba.py} +2 -44
  16. mapFolding/someAssemblyRequired/transformationTools.py +16 -174
  17. mapFolding/syntheticModules/countParallel.py +98 -0
  18. mapFolding/syntheticModules/dataPacking.py +1 -1
  19. mapFolding/theSSOT.py +12 -246
  20. {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/METADATA +16 -11
  21. mapfolding-0.11.3.dist-info/RECORD +53 -0
  22. {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/WHEEL +1 -1
  23. tests/conftest.py +2 -79
  24. tests/test_computations.py +12 -19
  25. tests/test_filesystem.py +1 -2
  26. tests/test_other.py +1 -1
  27. tests/test_tasks.py +3 -4
  28. mapFolding/someAssemblyRequired/Z0Z_makeSomeModules.py +0 -325
  29. mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +0 -314
  30. mapFolding/syntheticModules/numbaCount.py +0 -201
  31. mapFolding/theDao.py +0 -243
  32. mapfolding-0.11.1.dist-info/RECORD +0 -54
  33. {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/entry_points.txt +0 -0
  34. {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/licenses/LICENSE +0 -0
  35. {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/top_level.txt +0 -0
@@ -85,13 +85,14 @@ All tests leverage standardized utilities like `standardizedEqualToCallableRetur
85
85
  that provide consistent, informative error messages and simplify test validation.
86
86
  """
87
87
 
88
- from typing import Literal
89
88
  from mapFolding import countFolds, getFoldsTotalKnown, oeisIDfor_n
89
+ from mapFolding.dataBaskets import MapFoldingState
90
90
  from mapFolding.oeis import settingsOEIS
91
- from mapFolding.someAssemblyRequired.RecipeJob import RecipeJob
92
- from mapFolding.someAssemblyRequired.transformationTools import makeInitializedComputationState
91
+ from mapFolding.someAssemblyRequired.RecipeJob import RecipeJobTheorem2Numba
92
+ from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds
93
93
  from pathlib import Path, PurePosixPath
94
94
  from tests.conftest import standardizedEqualToCallableReturn, registrarRecordsTmpObject
95
+ from typing import Literal
95
96
  import importlib.util
96
97
  import multiprocessing
97
98
  import pytest
@@ -99,41 +100,33 @@ import pytest
99
100
  if __name__ == '__main__':
100
101
  multiprocessing.set_start_method('spawn')
101
102
 
102
- def test_algorithmSourceParallel(mapShapeTestParallelization: tuple[int, ...], useAlgorithmSourceDispatcher: None) -> None:
103
- standardizedEqualToCallableReturn(getFoldsTotalKnown(mapShapeTestParallelization), countFolds, mapShapeTestParallelization, None, 'maximum', None)
103
+ # TODO test synthesis
104
104
 
105
105
  @pytest.mark.parametrize('flow', ['daoOfMapFolding', 'theorem2', 'theorem2Trimmed', 'theorem2numba'])
106
106
  def test_flowControl(mapShapeTestCountFolds: tuple[int, ...], flow: Literal['daoOfMapFolding'] | Literal['theorem2'] | Literal['theorem2numba']) -> None:
107
107
  standardizedEqualToCallableReturn(getFoldsTotalKnown(mapShapeTestCountFolds), countFolds, None, None, None, None, mapShapeTestCountFolds, None, None, flow)
108
108
 
109
- def test_algorithmSourceSequential(mapShapeTestCountFolds: tuple[int, ...], useAlgorithmSourceDispatcher: None) -> None:
110
- standardizedEqualToCallableReturn(getFoldsTotalKnown(mapShapeTestCountFolds), countFolds, mapShapeTestCountFolds)
111
-
112
109
  def test_aOFn_calculate_value(oeisID: str) -> None:
113
110
  for n in settingsOEIS[oeisID]['valuesTestValidation']:
114
111
  standardizedEqualToCallableReturn(settingsOEIS[oeisID]['valuesKnown'][n], oeisIDfor_n, oeisID, n)
115
112
 
116
- def test_syntheticParallel(syntheticDispatcherFixture: None, mapShapeTestParallelization: tuple[int, ...]) -> None:
117
- standardizedEqualToCallableReturn(getFoldsTotalKnown(mapShapeTestParallelization), countFolds, mapShapeTestParallelization, None, 'maximum')
118
-
119
- def test_syntheticSequential(syntheticDispatcherFixture: None, mapShapeTestCountFolds: tuple[int, ...]) -> None:
120
- standardizedEqualToCallableReturn(getFoldsTotalKnown(mapShapeTestCountFolds), countFolds, mapShapeTestCountFolds)
121
-
122
113
  @pytest.mark.parametrize('pathFilenameTmpTesting', ['.py'], indirect=True)
123
114
  def test_writeJobNumba(oneTestCuzTestsOverwritingTests: tuple[int, ...], pathFilenameTmpTesting: Path) -> None:
124
- from mapFolding.someAssemblyRequired.toolboxNumba import SpicesJobNumba
125
- from mapFolding.someAssemblyRequired.synthesizeNumbaJob import makeJobNumba
126
- state = makeInitializedComputationState(oneTestCuzTestsOverwritingTests)
115
+ from mapFolding.someAssemblyRequired.toolkitNumba import SpicesJobNumba
116
+ from mapFolding.someAssemblyRequired.makeJobTheorem2Numba import makeJobNumba
117
+ mapShape = oneTestCuzTestsOverwritingTests
118
+ state = MapFoldingState(mapShape)
119
+ state = initializeGroupsOfFolds(state)
127
120
 
128
121
  pathFilenameModule = pathFilenameTmpTesting.absolute()
129
122
  pathFilenameFoldsTotal = pathFilenameModule.with_suffix('.foldsTotalTesting')
130
123
  registrarRecordsTmpObject(pathFilenameFoldsTotal)
131
124
 
132
- jobTest = RecipeJob(state
125
+ jobTest = RecipeJobTheorem2Numba(state
133
126
  , pathModule=PurePosixPath(pathFilenameModule.parent)
134
127
  , moduleIdentifier=pathFilenameModule.stem
135
128
  , pathFilenameFoldsTotal=PurePosixPath(pathFilenameFoldsTotal))
136
- spices = SpicesJobNumba()
129
+ spices = SpicesJobNumba(useNumbaProgressBar=False)
137
130
  makeJobNumba(jobTest, spices)
138
131
 
139
132
  Don_Lapre_Road_to_Self_Improvement = importlib.util.spec_from_file_location("__main__", pathFilenameModule)
tests/test_filesystem.py CHANGED
@@ -1,6 +1,5 @@
1
1
  from contextlib import redirect_stdout
2
- from mapFolding import validateListDimensions, getPathRootJobDEFAULT, getPathFilenameFoldsTotal, saveFoldsTotal
3
- from mapFolding.toolboxFilesystem import getFilenameFoldsTotal
2
+ from mapFolding import validateListDimensions, getPathRootJobDEFAULT, getPathFilenameFoldsTotal, saveFoldsTotal, getFilenameFoldsTotal
4
3
  from pathlib import Path
5
4
  import io
6
5
  import pytest
tests/test_other.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from collections.abc import Callable
2
- from mapFolding.beDRY import getLeavesTotal, setProcessorLimit, validateListDimensions
2
+ from mapFolding import getLeavesTotal, setProcessorLimit, validateListDimensions
3
3
  from tests.conftest import standardizedEqualToCallableReturn
4
4
  from typing import Any, Literal
5
5
  from Z0Z_tools import intInnit
tests/test_tasks.py CHANGED
@@ -1,14 +1,13 @@
1
1
  from collections.abc import Callable
2
- from mapFolding import countFolds
3
- from mapFolding.beDRY import getTaskDivisions, setProcessorLimit, validateListDimensions, getLeavesTotal
4
- from mapFolding.oeis import getFoldsTotalKnown
2
+ from mapFolding import countFolds, getTaskDivisions, setProcessorLimit, validateListDimensions, getLeavesTotal, getFoldsTotalKnown
5
3
  from tests.conftest import standardizedEqualToCallableReturn
6
4
  from typing import Literal
7
5
  from Z0Z_tools.pytestForYourUse import PytestFor_defineConcurrencyLimit
8
6
  import multiprocessing
9
7
  import pytest
10
8
 
11
- # When to use multiprocessing.set_start_method https://github.com/hunterhogan/mapFolding/issues/6
9
+ # When to use multiprocessing.set_start_method
10
+ # https://github.com/hunterhogan/mapFolding/issues/6
12
11
  if __name__ == '__main__':
13
12
  multiprocessing.set_start_method('spawn')
14
13
 
@@ -1,325 +0,0 @@
1
- from mapFolding import raiseIfNoneGitHubIssueNumber3, The
2
- from mapFolding.someAssemblyRequired import (
3
- ast_Identifier,
4
- astModuleToIngredientsFunction,
5
- Be,
6
- DOT,
7
- extractFunctionDef,
8
- Grab,
9
- IfThis,
10
- IngredientsFunction,
11
- IngredientsModule,
12
- inlineFunctionDef,
13
- LedgerOfImports,
14
- Make,
15
- NodeChanger,
16
- NodeTourist,
17
- parseLogicalPath2astModule,
18
- parsePathFilename2astModule,
19
- removeUnusedParameters,
20
- str_nameDOTname,
21
- Then,
22
- write_astModule,
23
- )
24
- from mapFolding.someAssemblyRequired.toolboxNumba import decorateCallableWithNumba, parametersNumbaLight
25
- from mapFolding.someAssemblyRequired.transformationTools import (
26
- removeDataclassFromFunction,
27
- shatter_dataclassesDOTdataclass,
28
- unpackDataclassCallFunctionRepackDataclass,
29
- )
30
- from pathlib import PurePath
31
- import ast
32
-
33
- algorithmSourceModuleHARDCODED = 'daoOfMapFolding'
34
- sourceCallableIdentifierHARDCODED = 'count'
35
- logicalPathInfixHARDCODED: ast_Identifier = 'syntheticModules'
36
- theCountingIdentifierHARDCODED: ast_Identifier = 'groupsOfFolds'
37
-
38
- def makeInitializeGroupsOfFolds() -> None:
39
- callableIdentifierHARDCODED = 'initializeGroupsOfFolds'
40
- moduleIdentifierHARDCODED: ast_Identifier = 'initializeCount'
41
-
42
- algorithmSourceModule = algorithmSourceModuleHARDCODED
43
- sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
44
- logicalPathSourceModule = '.'.join([The.packageName, algorithmSourceModule])
45
-
46
- callableIdentifier = callableIdentifierHARDCODED
47
- logicalPathInfix = logicalPathInfixHARDCODED
48
- moduleIdentifier = moduleIdentifierHARDCODED
49
-
50
- astModule = parseLogicalPath2astModule(logicalPathSourceModule)
51
- countInitializeIngredients = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule)
52
- , LedgerOfImports(astModule))
53
-
54
- countInitializeIngredients.astFunctionDef.name = callableIdentifier
55
-
56
- dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(countInitializeIngredients.astFunctionDef)
57
- if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
58
- theCountingIdentifier = theCountingIdentifierHARDCODED
59
-
60
- findThis = IfThis.isWhileAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
61
- doThat = Grab.testAttribute(Grab.andDoAllOf([ Grab.opsAttribute(Then.replaceWith([ast.Eq()])), Grab.leftAttribute(Grab.attrAttribute(Then.replaceWith(theCountingIdentifier))) ])) # type: ignore
62
- NodeChanger(findThis, doThat).visit(countInitializeIngredients.astFunctionDef.body[0])
63
-
64
- ingredientsModule = IngredientsModule(countInitializeIngredients)
65
-
66
- pathFilename = PurePath(The.pathPackage, logicalPathInfix, moduleIdentifier + The.fileExtension)
67
-
68
- write_astModule(ingredientsModule, pathFilename, The.packageName)
69
-
70
- def makeDaoOfMapFolding() -> PurePath:
71
- moduleIdentifierHARDCODED: ast_Identifier = 'daoOfMapFolding'
72
-
73
- algorithmSourceModule = algorithmSourceModuleHARDCODED
74
- sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
75
- logicalPathSourceModule = '.'.join([The.packageName, algorithmSourceModule])
76
-
77
- logicalPathInfix = logicalPathInfixHARDCODED
78
- moduleIdentifier = moduleIdentifierHARDCODED
79
-
80
- astModule = parseLogicalPath2astModule(logicalPathSourceModule)
81
- daoOfMapFolding = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule)
82
- , LedgerOfImports(astModule))
83
-
84
- dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(daoOfMapFolding.astFunctionDef)
85
- if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
86
- dataclass_Identifier: ast_Identifier | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
87
- if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
88
-
89
- dataclassLogicalPathModule = None
90
- for moduleWithLogicalPath, listNameTuples in daoOfMapFolding.imports.dictionaryImportFrom.items():
91
- for nameTuple in listNameTuples:
92
- if nameTuple[0] == dataclass_Identifier:
93
- dataclassLogicalPathModule = moduleWithLogicalPath
94
- break
95
- if dataclassLogicalPathModule:
96
- break
97
- if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
98
- dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(daoOfMapFolding.astFunctionDef)
99
- if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
100
- shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
101
-
102
- # theCountingIdentifier = theCountingIdentifierHARDCODED
103
- # doubleTheCount = Make.AugAssign(Make.Attribute(ast.Name(dataclassInstanceIdentifier), theCountingIdentifier), ast.Mult(), Make.Constant(2))
104
- # findThis = be.Return
105
- # doThat = Then.insertThisAbove([doubleTheCount])
106
- # NodeChanger(findThis, doThat).visit(daoOfMapFolding.astFunctionDef)
107
-
108
- daoOfMapFolding.imports.update(shatteredDataclass.imports)
109
- daoOfMapFolding = removeDataclassFromFunction(daoOfMapFolding, shatteredDataclass)
110
-
111
- daoOfMapFolding = removeUnusedParameters(daoOfMapFolding)
112
-
113
- daoOfMapFolding = decorateCallableWithNumba(daoOfMapFolding, parametersNumbaLight)
114
-
115
- sourceCallableIdentifier = The.sourceCallableDispatcher
116
-
117
- doTheNeedful: IngredientsFunction = astModuleToIngredientsFunction(astModule, sourceCallableIdentifier)
118
- doTheNeedful.imports.update(shatteredDataclass.imports)
119
- targetCallableIdentifier = daoOfMapFolding.astFunctionDef.name
120
- doTheNeedful = unpackDataclassCallFunctionRepackDataclass(doTheNeedful, targetCallableIdentifier, shatteredDataclass)
121
- astTuple: ast.Tuple | None = NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(daoOfMapFolding.astFunctionDef)
122
- if astTuple is None: raise raiseIfNoneGitHubIssueNumber3
123
- astTuple.ctx = ast.Store()
124
-
125
- findThis = IfThis.isAssignAndValueIs(IfThis.isCall_Identifier(targetCallableIdentifier))
126
- doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), astTuple.elts)))
127
- changeAssignCallToTarget = NodeChanger(findThis, doThat)
128
- changeAssignCallToTarget.visit(doTheNeedful.astFunctionDef)
129
-
130
- ingredientsModule = IngredientsModule([daoOfMapFolding, doTheNeedful])
131
- ingredientsModule.removeImportFromModule('numpy')
132
-
133
- pathFilename = PurePath(The.pathPackage, logicalPathInfix, moduleIdentifier + The.fileExtension)
134
-
135
- write_astModule(ingredientsModule, pathFilename, The.packageName)
136
-
137
- return pathFilename
138
-
139
- def makeTheorem2() -> PurePath:
140
- moduleIdentifierHARDCODED: ast_Identifier = 'theorem2'
141
-
142
- algorithmSourceModule = algorithmSourceModuleHARDCODED
143
- sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
144
- logicalPathSourceModule = '.'.join([The.packageName, algorithmSourceModule])
145
-
146
- logicalPathInfix = logicalPathInfixHARDCODED
147
- moduleIdentifier = moduleIdentifierHARDCODED
148
-
149
- astModule = parseLogicalPath2astModule(logicalPathSourceModule)
150
- countTheorem2 = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule)
151
- , LedgerOfImports(astModule))
152
-
153
- dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(countTheorem2.astFunctionDef)
154
- if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
155
-
156
- findThis = IfThis.isWhileAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
157
- doThat = Grab.testAttribute(Grab.comparatorsAttribute(Then.replaceWith([Make.Constant(4)]))) # type: ignore
158
- NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
159
-
160
- findThis = IfThis.isIfAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
161
- doThat = Then.extractIt(DOT.body)
162
- insertLeaf = NodeTourist(findThis, doThat).captureLastMatch(countTheorem2.astFunctionDef)
163
- findThis = IfThis.isIfAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
164
- doThat = Then.replaceWith(insertLeaf)
165
- NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
166
-
167
- findThis = IfThis.isAttributeNamespace_IdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
168
- doThat = Then.removeIt
169
- NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
170
-
171
- findThis = IfThis.isAttributeNamespace_IdentifierLessThanOrEqual0(dataclassInstanceIdentifier, 'leaf1ndex')
172
- doThat = Then.removeIt
173
- NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
174
-
175
- theCountingIdentifier = theCountingIdentifierHARDCODED
176
- doubleTheCount = Make.AugAssign(Make.Attribute(ast.Name(dataclassInstanceIdentifier), theCountingIdentifier), ast.Mult(), Make.Constant(2))
177
- findThis = Be.Return
178
- doThat = Then.insertThisAbove([doubleTheCount])
179
- NodeChanger(findThis, doThat).visit(countTheorem2.astFunctionDef)
180
-
181
- ingredientsModule = IngredientsModule(countTheorem2)
182
-
183
- pathFilename = PurePath(The.pathPackage, logicalPathInfix, moduleIdentifier + The.fileExtension)
184
-
185
- write_astModule(ingredientsModule, pathFilename, The.packageName)
186
-
187
- return pathFilename
188
-
189
- def trimTheorem2(pathFilenameSource: PurePath) -> PurePath:
190
- logicalPathInfix = logicalPathInfixHARDCODED
191
- sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
192
- ingredientsFunction = astModuleToIngredientsFunction(parsePathFilename2astModule(pathFilenameSource), sourceCallableIdentifier)
193
-
194
- dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef)
195
- if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
196
-
197
- findThis = IfThis.isIfUnaryNotAttributeNamespace_Identifier(dataclassInstanceIdentifier, 'dimensionsUnconstrained')
198
- doThat = Then.removeIt
199
- NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
200
-
201
- ingredientsModule = IngredientsModule(ingredientsFunction)
202
- ingredientsModule.removeImportFromModule('numpy')
203
-
204
- pathFilename = pathFilenameSource.with_stem(pathFilenameSource.stem + 'Trimmed')
205
-
206
- write_astModule(ingredientsModule, pathFilename, The.packageName)
207
-
208
- logicalPath: list[str] = []
209
- if The.packageName:
210
- logicalPath.append(The.packageName)
211
- if logicalPathInfix:
212
- logicalPath.append(logicalPathInfix)
213
- logicalPath.append(pathFilename.stem)
214
- moduleWithLogicalPath: str_nameDOTname = '.'.join(logicalPath)
215
-
216
- astImportFrom: ast.ImportFrom = Make.ImportFrom(moduleWithLogicalPath, list_alias=[Make.alias(ingredientsFunction.astFunctionDef.name)])
217
-
218
- return pathFilename
219
-
220
- def numbaOnTheorem2(pathFilenameSource: PurePath) -> ast.ImportFrom:
221
- logicalPathInfix = logicalPathInfixHARDCODED
222
- sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
223
- countNumbaTheorem2 = astModuleToIngredientsFunction(parsePathFilename2astModule(pathFilenameSource), sourceCallableIdentifier)
224
- dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(countNumbaTheorem2.astFunctionDef)
225
- if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
226
- dataclass_Identifier: ast_Identifier | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
227
- if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
228
-
229
- dataclassLogicalPathModule = None
230
- for moduleWithLogicalPath, listNameTuples in countNumbaTheorem2.imports.dictionaryImportFrom.items():
231
- for nameTuple in listNameTuples:
232
- if nameTuple[0] == dataclass_Identifier:
233
- dataclassLogicalPathModule = moduleWithLogicalPath
234
- break
235
- if dataclassLogicalPathModule:
236
- break
237
- if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
238
- dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(countNumbaTheorem2.astFunctionDef)
239
- if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
240
- shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
241
-
242
- countNumbaTheorem2.imports.update(shatteredDataclass.imports)
243
- countNumbaTheorem2 = removeDataclassFromFunction(countNumbaTheorem2, shatteredDataclass)
244
-
245
- countNumbaTheorem2 = removeUnusedParameters(countNumbaTheorem2)
246
-
247
- countNumbaTheorem2 = decorateCallableWithNumba(countNumbaTheorem2, parametersNumbaLight)
248
-
249
- ingredientsModule = IngredientsModule(countNumbaTheorem2)
250
- ingredientsModule.removeImportFromModule('numpy')
251
-
252
- pathFilename = pathFilenameSource.with_stem(pathFilenameSource.stem.replace('Trimmed', '') + 'Numba')
253
-
254
- write_astModule(ingredientsModule, pathFilename, The.packageName)
255
-
256
- logicalPath: list[str] = []
257
- if The.packageName:
258
- logicalPath.append(The.packageName)
259
- if logicalPathInfix:
260
- logicalPath.append(logicalPathInfix)
261
- logicalPath.append(pathFilename.stem)
262
- moduleWithLogicalPath: str_nameDOTname = '.'.join(logicalPath)
263
-
264
- astImportFrom: ast.ImportFrom = Make.ImportFrom(moduleWithLogicalPath, list_alias=[Make.alias(countNumbaTheorem2.astFunctionDef.name)])
265
-
266
- return astImportFrom
267
-
268
- def makeUnRePackDataclass(astImportFrom: ast.ImportFrom) -> None:
269
- moduleIdentifierHARDCODED: ast_Identifier = 'dataPacking'
270
-
271
- algorithmSourceModule = algorithmSourceModuleHARDCODED
272
- sourceCallableIdentifier = The.sourceCallableDispatcher
273
- logicalPathSourceModule = '.'.join([The.packageName, algorithmSourceModule])
274
-
275
- logicalPathInfix = logicalPathInfixHARDCODED
276
- moduleIdentifier = moduleIdentifierHARDCODED
277
-
278
- doTheNeedful: IngredientsFunction = astModuleToIngredientsFunction(parseLogicalPath2astModule(logicalPathSourceModule), sourceCallableIdentifier)
279
- dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(doTheNeedful.astFunctionDef)
280
- if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
281
- dataclass_Identifier: ast_Identifier | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
282
- if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
283
-
284
- dataclassLogicalPathModule = None
285
- for moduleWithLogicalPath, listNameTuples in doTheNeedful.imports.dictionaryImportFrom.items():
286
- for nameTuple in listNameTuples:
287
- if nameTuple[0] == dataclass_Identifier:
288
- dataclassLogicalPathModule = moduleWithLogicalPath
289
- break
290
- if dataclassLogicalPathModule:
291
- break
292
- if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
293
- dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(doTheNeedful.astFunctionDef)
294
- if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
295
- shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
296
-
297
- doTheNeedful.imports.update(shatteredDataclass.imports)
298
- doTheNeedful.imports.addAst(astImportFrom)
299
- targetCallableIdentifier = astImportFrom.names[0].name
300
- doTheNeedful = unpackDataclassCallFunctionRepackDataclass(doTheNeedful, targetCallableIdentifier, shatteredDataclass)
301
- if astImportFrom.module is None: raise raiseIfNoneGitHubIssueNumber3
302
- targetFunctionDef = extractFunctionDef(parseLogicalPath2astModule(astImportFrom.module), targetCallableIdentifier)
303
- if targetFunctionDef is None: raise raiseIfNoneGitHubIssueNumber3
304
- astTuple: ast.Tuple | None = NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(targetFunctionDef)
305
- if astTuple is None: raise raiseIfNoneGitHubIssueNumber3
306
- astTuple.ctx = ast.Store()
307
-
308
- findThis = IfThis.isAssignAndValueIs(IfThis.isCall_Identifier(targetCallableIdentifier))
309
- doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), astTuple.elts)))
310
- NodeChanger(findThis, doThat).visit(doTheNeedful.astFunctionDef)
311
-
312
- ingredientsModule = IngredientsModule(doTheNeedful)
313
- ingredientsModule.removeImportFromModule('numpy')
314
-
315
- pathFilename = PurePath(The.pathPackage, logicalPathInfix, moduleIdentifier + The.fileExtension)
316
-
317
- write_astModule(ingredientsModule, pathFilename, The.packageName)
318
-
319
- if __name__ == '__main__':
320
- makeInitializeGroupsOfFolds()
321
- pathFilename = makeTheorem2()
322
- pathFilename = trimTheorem2(pathFilename)
323
- astImportFrom = numbaOnTheorem2(pathFilename)
324
- makeUnRePackDataclass(astImportFrom)
325
- makeDaoOfMapFolding()