mapFolding 0.11.3__tar.gz → 0.12.0__tar.gz

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 (60) hide show
  1. {mapfolding-0.11.3 → mapfolding-0.12.0}/PKG-INFO +2 -4
  2. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/oeis.py +9 -5
  3. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/someAssemblyRequired/RecipeJob.py +14 -14
  4. mapfolding-0.12.0/mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py +433 -0
  5. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/someAssemblyRequired/__init__.py +7 -2
  6. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/someAssemblyRequired/_toolIfThis.py +7 -7
  7. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/someAssemblyRequired/_toolkitContainers.py +12 -12
  8. mapfolding-0.12.0/mapFolding/someAssemblyRequired/infoBooth.py +17 -0
  9. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +11 -12
  10. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/someAssemblyRequired/toolkitNumba.py +4 -4
  11. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/someAssemblyRequired/transformationTools.py +4 -15
  12. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding.egg-info/PKG-INFO +2 -4
  13. {mapfolding-0.11.3 → mapfolding-0.12.0}/pyproject.toml +2 -4
  14. mapfolding-0.11.3/mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py +0 -492
  15. mapfolding-0.11.3/mapFolding/someAssemblyRequired/infoBooth.py +0 -70
  16. {mapfolding-0.11.3 → mapfolding-0.12.0}/LICENSE +0 -0
  17. {mapfolding-0.11.3 → mapfolding-0.12.0}/README.md +0 -0
  18. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/__init__.py +0 -0
  19. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/basecamp.py +0 -0
  20. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/beDRY.py +0 -0
  21. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/daoOfMapFolding.py +0 -0
  22. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/dataBaskets.py +0 -0
  23. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/datatypes.py +0 -0
  24. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/filesystemToolkit.py +0 -0
  25. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/py.typed +0 -0
  26. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/reference/__init__.py +0 -0
  27. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/reference/flattened.py +0 -0
  28. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/reference/hunterNumba.py +0 -0
  29. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/reference/irvineJavaPort.py +0 -0
  30. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/reference/jaxCount.py +0 -0
  31. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/reference/jobsCompleted/[2x19]/p2x19.py +0 -0
  32. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/reference/jobsCompleted/__init__.py +0 -0
  33. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/reference/jobsCompleted/p2x19/p2x19.py +0 -0
  34. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/reference/lunnonNumpy.py +0 -0
  35. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/reference/lunnonWhile.py +0 -0
  36. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/reference/rotatedEntryPoint.py +0 -0
  37. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
  38. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/someAssemblyRequired/getLLVMforNoReason.py +0 -0
  39. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/syntheticModules/__init__.py +0 -0
  40. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/syntheticModules/countParallel.py +0 -0
  41. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/syntheticModules/daoOfMapFolding.py +0 -0
  42. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/syntheticModules/dataPacking.py +0 -0
  43. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/syntheticModules/initializeCount.py +0 -0
  44. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/syntheticModules/theorem2.py +0 -0
  45. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/syntheticModules/theorem2Numba.py +0 -0
  46. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/syntheticModules/theorem2Trimmed.py +0 -0
  47. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding/theSSOT.py +0 -0
  48. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding.egg-info/SOURCES.txt +0 -0
  49. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding.egg-info/dependency_links.txt +0 -0
  50. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding.egg-info/entry_points.txt +0 -0
  51. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding.egg-info/requires.txt +0 -0
  52. {mapfolding-0.11.3 → mapfolding-0.12.0}/mapFolding.egg-info/top_level.txt +0 -0
  53. {mapfolding-0.11.3 → mapfolding-0.12.0}/setup.cfg +0 -0
  54. {mapfolding-0.11.3 → mapfolding-0.12.0}/tests/__init__.py +0 -0
  55. {mapfolding-0.11.3 → mapfolding-0.12.0}/tests/conftest.py +0 -0
  56. {mapfolding-0.11.3 → mapfolding-0.12.0}/tests/test_computations.py +0 -0
  57. {mapfolding-0.11.3 → mapfolding-0.12.0}/tests/test_filesystem.py +0 -0
  58. {mapfolding-0.11.3 → mapfolding-0.12.0}/tests/test_oeis.py +0 -0
  59. {mapfolding-0.11.3 → mapfolding-0.12.0}/tests/test_other.py +0 -0
  60. {mapfolding-0.11.3 → mapfolding-0.12.0}/tests/test_tasks.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mapFolding
3
- Version: 0.11.3
3
+ Version: 0.12.0
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
@@ -18,8 +18,6 @@ Classifier: Natural Language :: English
18
18
  Classifier: Operating System :: OS Independent
19
19
  Classifier: Programming Language :: Python
20
20
  Classifier: Programming Language :: Python :: 3
21
- Classifier: Programming Language :: Python :: 3.10
22
- Classifier: Programming Language :: Python :: 3.11
23
21
  Classifier: Programming Language :: Python :: 3.12
24
22
  Classifier: Programming Language :: Python :: 3.13
25
23
  Classifier: Topic :: Scientific/Engineering :: Mathematics
@@ -28,7 +26,7 @@ Classifier: Topic :: Software Development :: Code Generators
28
26
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
29
27
  Classifier: Topic :: Software Development :: Compilers
30
28
  Classifier: Typing :: Typed
31
- Requires-Python: >=3.10
29
+ Requires-Python: >=3.12
32
30
  Description-Content-Type: text/markdown
33
31
  License-File: LICENSE
34
32
  Requires-Dist: astToolkit
@@ -23,13 +23,13 @@ from functools import cache
23
23
  from mapFolding import countFolds, packageSettings, TypedDict
24
24
  from pathlib import Path
25
25
  from typing import Any, Final
26
+ from urllib.parse import urlparse
26
27
  from Z0Z_tools import writeStringToHere
27
28
  import argparse
28
29
  import random
29
30
  import sys
30
31
  import time
31
32
  import urllib.request
32
- import urllib.response
33
33
  import warnings
34
34
 
35
35
  cacheDays = 30
@@ -186,10 +186,14 @@ def getOEISofficial(pathFilenameCache: Path, url: str) -> None | str:
186
186
  tryCache = False
187
187
 
188
188
  if not tryCache:
189
- # Change http handling #13
190
- httpResponse: urllib.response.addinfourl = urllib.request.urlopen(url)
191
- oeisInformation = httpResponse.read().decode('utf-8')
192
- writeStringToHere(oeisInformation, pathFilenameCache)
189
+ parsedUrl = urlparse(url)
190
+ if parsedUrl.scheme not in ("http", "https"):
191
+ warnings.warn(f"I received the URL '{url}', but only 'http' and 'https' schemes are permitted.")
192
+ else:
193
+ httpResponse = urllib.request.urlopen(url)
194
+ oeisInformationRaw = httpResponse.read().decode('utf-8')
195
+ oeisInformation = str(oeisInformationRaw)
196
+ writeStringToHere(oeisInformation, pathFilenameCache)
193
197
 
194
198
  if not oeisInformation:
195
199
  warnings.warn(f"Failed to retrieve OEIS sequence information for {pathFilenameCache.stem}.")
@@ -1,7 +1,7 @@
1
- from astToolkit import ast_Identifier, parseLogicalPath2astModule, str_nameDOTname
2
- from mapFolding import getPathFilenameFoldsTotal, getPathRootJobDEFAULT, MapFoldingState
1
+ from astToolkit import parseLogicalPath2astModule, str_nameDOTname
2
+ from mapFolding import getPathFilenameFoldsTotal, getPathRootJobDEFAULT, MapFoldingState, packageSettings
3
3
  from mapFolding import DatatypeElephino as TheDatatypeElephino, DatatypeFoldsTotal as TheDatatypeFoldsTotal, DatatypeLeavesTotal as TheDatatypeLeavesTotal
4
- from mapFolding.someAssemblyRequired import ShatteredDataclass, packageInformation
4
+ from mapFolding.someAssemblyRequired import dataclassInstanceIdentifierDEFAULT, ShatteredDataclass
5
5
  from mapFolding.someAssemblyRequired.transformationTools import shatter_dataclassesDOTdataclass
6
6
  from pathlib import Path, PurePosixPath
7
7
  from typing import TypeAlias
@@ -17,32 +17,32 @@ class RecipeJobTheorem2Numba:
17
17
  # ========================================
18
18
  # Source
19
19
  source_astModule = parseLogicalPath2astModule('mapFolding.syntheticModules.theorem2Numba')
20
- sourceCountCallable: ast_Identifier = 'count'
20
+ sourceCountCallable: str = 'count'
21
21
 
22
22
  sourceLogicalPathModuleDataclass: str_nameDOTname = 'mapFolding.dataBaskets'
23
- sourceDataclassIdentifier: ast_Identifier = 'MapFoldingState'
24
- sourceDataclassInstance: ast_Identifier = packageInformation.dataclassInstance
23
+ sourceDataclassIdentifier: str = 'MapFoldingState'
24
+ sourceDataclassInstance: str = dataclassInstanceIdentifierDEFAULT
25
25
 
26
- sourcePathPackage: PurePosixPath | None = PurePosixPath(packageInformation.pathPackage)
27
- sourcePackageIdentifier: ast_Identifier | None = packageInformation.packageName
26
+ sourcePathPackage: PurePosixPath | None = PurePosixPath(packageSettings.pathPackage)
27
+ sourcePackageIdentifier: str | None = packageSettings.packageName
28
28
 
29
29
  # ========================================
30
30
  # Filesystem (names of physical objects)
31
31
  pathPackage: PurePosixPath | None = None
32
32
  pathModule: PurePosixPath | None = PurePosixPath(getPathRootJobDEFAULT())
33
33
  """ `pathModule` will override `pathPackage` and `logicalPathRoot`."""
34
- fileExtension: str = packageInformation.fileExtension
34
+ fileExtension: str = packageSettings.fileExtension
35
35
  pathFilenameFoldsTotal: PurePosixPath = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType]
36
36
 
37
37
  # ========================================
38
38
  # Logical identifiers (as opposed to physical identifiers)
39
- packageIdentifier: ast_Identifier | None = None
39
+ packageIdentifier: str | None = None
40
40
  logicalPathRoot: str_nameDOTname | None = None
41
41
  """ `logicalPathRoot` likely corresponds to a physical filesystem directory."""
42
- moduleIdentifier: ast_Identifier = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType]
43
- countCallable: ast_Identifier = sourceCountCallable
44
- dataclassIdentifier: ast_Identifier | None = sourceDataclassIdentifier
45
- dataclassInstance: ast_Identifier | None = sourceDataclassInstance
42
+ moduleIdentifier: str = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType]
43
+ countCallable: str = sourceCountCallable
44
+ dataclassIdentifier: str | None = sourceDataclassIdentifier
45
+ dataclassInstance: str | None = sourceDataclassInstance
46
46
  logicalPathModuleDataclass: str_nameDOTname | None = sourceLogicalPathModuleDataclass
47
47
 
48
48
  # ========================================
@@ -0,0 +1,433 @@
1
+ from astToolkit import (
2
+ astModuleToIngredientsFunction,
3
+ Be,
4
+ ClassIsAndAttribute,
5
+ DOT,
6
+ extractClassDef,
7
+ extractFunctionDef,
8
+ Grab,
9
+ IngredientsFunction,
10
+ IngredientsModule,
11
+ LedgerOfImports,
12
+ Make,
13
+ NodeChanger,
14
+ NodeTourist,
15
+ parseLogicalPath2astModule,
16
+ parsePathFilename2astModule,
17
+ str_nameDOTname,
18
+ Then,
19
+ )
20
+ from astToolkit.transformationTools import inlineFunctionDef, removeUnusedParameters, write_astModule
21
+ from collections.abc import Sequence
22
+ from mapFolding import packageSettings
23
+ from mapFolding.someAssemblyRequired import (
24
+ DeReConstructField2ast,
25
+ IfThis,
26
+ raiseIfNone,
27
+ ShatteredDataclass,
28
+ sourceCallableDispatcherDEFAULT,
29
+ )
30
+ from mapFolding.someAssemblyRequired.infoBooth import algorithmSourceModuleDEFAULT, dataPackingModuleIdentifierDEFAULT, logicalPathInfixDEFAULT, sourceCallableIdentifierDEFAULT, theCountingIdentifierDEFAULT
31
+ from mapFolding.someAssemblyRequired.toolkitNumba import decorateCallableWithNumba, parametersNumbaLight
32
+ from mapFolding.someAssemblyRequired.transformationTools import (
33
+ removeDataclassFromFunction,
34
+ shatter_dataclassesDOTdataclass,
35
+ unpackDataclassCallFunctionRepackDataclass,
36
+ )
37
+ from os import PathLike
38
+ from pathlib import PurePath
39
+ from typing import cast
40
+ from Z0Z_tools import importLogicalPath2Callable
41
+ import ast
42
+ import dataclasses
43
+
44
+ def findDataclass(ingredientsFunction: IngredientsFunction) -> tuple[str, str, str]:
45
+ dataclassName: ast.expr = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(ingredientsFunction.astFunctionDef))
46
+ dataclass_Identifier: str = raiseIfNone(NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName))
47
+ dataclassLogicalPathModule = None
48
+ for moduleWithLogicalPath, listNameTuples in ingredientsFunction.imports.dictionaryImportFrom.items():
49
+ for nameTuple in listNameTuples:
50
+ if nameTuple[0] == dataclass_Identifier:
51
+ dataclassLogicalPathModule = moduleWithLogicalPath
52
+ break
53
+ if dataclassLogicalPathModule:
54
+ break
55
+ dataclassInstanceIdentifier = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef))
56
+ return raiseIfNone(dataclassLogicalPathModule), dataclass_Identifier, dataclassInstanceIdentifier
57
+
58
+ def _getLogicalPath(packageName: str | None = None, logicalPathInfix: str | None = None, moduleIdentifier: str | None = None, *modules: str) -> str_nameDOTname:
59
+ listLogicalPathParts: list[str] = []
60
+ if packageName:
61
+ listLogicalPathParts.append(packageName)
62
+ if logicalPathInfix:
63
+ listLogicalPathParts.append(logicalPathInfix)
64
+ if moduleIdentifier:
65
+ listLogicalPathParts.append(moduleIdentifier)
66
+ if modules:
67
+ listLogicalPathParts.extend(modules)
68
+ logicalPath = '.'.join(listLogicalPathParts)
69
+ return logicalPath
70
+
71
+ def getModule(packageName: str | None = packageSettings.packageName, logicalPathInfix: str | None = logicalPathInfixDEFAULT, moduleIdentifier: str | None = algorithmSourceModuleDEFAULT) -> ast.Module:
72
+ logicalPathSourceModule = _getLogicalPath(packageName, logicalPathInfix, moduleIdentifier)
73
+ astModule = parseLogicalPath2astModule(logicalPathSourceModule)
74
+ return astModule
75
+
76
+ def _getPathFilename(pathRoot: PathLike[str] | PurePath | None = packageSettings.pathPackage, logicalPathInfix: PathLike[str] | PurePath | str | None = None, moduleIdentifier: str = '', fileExtension: str = packageSettings.fileExtension) -> PurePath:
77
+ pathFilename = PurePath(moduleIdentifier + fileExtension)
78
+ if logicalPathInfix:
79
+ pathFilename = PurePath(logicalPathInfix, pathFilename)
80
+ if pathRoot:
81
+ pathFilename = PurePath(pathRoot, pathFilename)
82
+ return pathFilename
83
+
84
+ def makeInitializeGroupsOfFolds(astModule: ast.Module, moduleIdentifier: str, callableIdentifier: str | None = None, logicalPathInfix: PathLike[str] | PurePath | str | None = None, sourceCallableDispatcher: str | None = None) -> PurePath:
85
+ sourceCallableIdentifier = sourceCallableIdentifierDEFAULT
86
+ if callableIdentifier is None:
87
+ callableIdentifier = sourceCallableIdentifier
88
+ ingredientsFunction = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
89
+ ingredientsFunction.astFunctionDef.name = callableIdentifier
90
+
91
+ dataclassInstanceIdentifier = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef))
92
+ theCountingIdentifier = theCountingIdentifierDEFAULT
93
+
94
+ findThis = IfThis.isWhileAttributeNamespaceIdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
95
+ doThat = Grab.testAttribute(Grab.andDoAllOf([Grab.opsAttribute(Then.replaceWith([ast.Eq()])), Grab.leftAttribute(Grab.attrAttribute(Then.replaceWith(theCountingIdentifier)))])) # pyright: ignore[reportArgumentType]
96
+ NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef.body[0])
97
+
98
+ ingredientsModule = IngredientsModule(ingredientsFunction)
99
+ pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
100
+ write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
101
+
102
+ return pathFilename
103
+
104
+ def makeDaoOfMapFolding(astModule: ast.Module, moduleIdentifier: str, callableIdentifier: str | None = None, logicalPathInfix: PathLike[str] | PurePath | str | None = None, sourceCallableDispatcher: str | None = None) -> PurePath:
105
+ sourceCallableIdentifier = sourceCallableIdentifierDEFAULT
106
+ ingredientsFunction = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
107
+
108
+ if callableIdentifier is None:
109
+ callableIdentifier = sourceCallableIdentifier
110
+ ingredientsFunction.astFunctionDef.name = callableIdentifier
111
+
112
+ shatteredDataclass = shatter_dataclassesDOTdataclass(*findDataclass(ingredientsFunction))
113
+
114
+ ingredientsFunction.imports.update(shatteredDataclass.imports)
115
+ ingredientsFunction = removeDataclassFromFunction(ingredientsFunction, shatteredDataclass)
116
+ ingredientsFunction = removeUnusedParameters(ingredientsFunction)
117
+ ingredientsFunction = decorateCallableWithNumba(ingredientsFunction, parametersNumbaLight)
118
+
119
+ ingredientsModule = IngredientsModule(ingredientsFunction)
120
+
121
+ if sourceCallableDispatcher is not None:
122
+
123
+ ingredientsFunctionDispatcher: IngredientsFunction = astModuleToIngredientsFunction(astModule, sourceCallableDispatcher)
124
+ ingredientsFunctionDispatcher.imports.update(shatteredDataclass.imports)
125
+ targetCallableIdentifier = ingredientsFunction.astFunctionDef.name
126
+ ingredientsFunctionDispatcher = unpackDataclassCallFunctionRepackDataclass(ingredientsFunctionDispatcher, targetCallableIdentifier, shatteredDataclass)
127
+ astTuple = raiseIfNone(NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(ingredientsFunction.astFunctionDef))
128
+ cast(ast.Tuple, astTuple).ctx = ast.Store()
129
+
130
+ findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCall_Identifier(targetCallableIdentifier))
131
+ doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), cast(ast.Tuple, astTuple).elts)))
132
+ changeAssignCallToTarget = NodeChanger(findThis, doThat)
133
+ changeAssignCallToTarget.visit(ingredientsFunctionDispatcher.astFunctionDef)
134
+
135
+ ingredientsModule.appendIngredientsFunction(ingredientsFunctionDispatcher)
136
+
137
+ ingredientsModule.removeImportFromModule('numpy')
138
+
139
+ pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
140
+
141
+ write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
142
+
143
+ return pathFilename
144
+
145
+ def makeDaoOfMapFoldingParallel(astModule: ast.Module, moduleIdentifier: str, callableIdentifier: str | None = None, logicalPathInfix: PathLike[str] | PurePath | str | None = None, sourceCallableDispatcher: str | None = None) -> PurePath:
146
+ sourceCallableIdentifier = sourceCallableIdentifierDEFAULT
147
+ if callableIdentifier is None:
148
+ callableIdentifier = sourceCallableIdentifier
149
+ ingredientsFunction = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
150
+ ingredientsFunction.astFunctionDef.name = callableIdentifier
151
+
152
+ dataclassName: ast.expr = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(ingredientsFunction.astFunctionDef))
153
+ dataclass_Identifier: str = raiseIfNone(NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName))
154
+
155
+ dataclassLogicalPathModule = None
156
+ for moduleWithLogicalPath, listNameTuples in ingredientsFunction.imports.dictionaryImportFrom.items():
157
+ for nameTuple in listNameTuples:
158
+ if nameTuple[0] == dataclass_Identifier:
159
+ dataclassLogicalPathModule = moduleWithLogicalPath
160
+ break
161
+ if dataclassLogicalPathModule:
162
+ break
163
+ if dataclassLogicalPathModule is None: raise Exception
164
+ dataclassInstanceIdentifier = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef))
165
+ shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
166
+
167
+ # Start add the parallel state fields to the count function ================================================
168
+ dataclassBaseFields = dataclasses.fields(importLogicalPath2Callable(dataclassLogicalPathModule, dataclass_Identifier)) # pyright: ignore [reportArgumentType]
169
+ dataclass_IdentifierParallel = 'Parallel' + dataclass_Identifier
170
+ dataclassFieldsParallel = dataclasses.fields(importLogicalPath2Callable(dataclassLogicalPathModule, dataclass_IdentifierParallel)) # pyright: ignore [reportArgumentType]
171
+ onlyParallelFields = [field for field in dataclassFieldsParallel if field.name not in [fieldBase.name for fieldBase in dataclassBaseFields]]
172
+
173
+ Official_fieldOrder: list[str] = []
174
+ dictionaryDeReConstruction: dict[str, DeReConstructField2ast] = {}
175
+
176
+ dataclassClassDef = extractClassDef(parseLogicalPath2astModule(dataclassLogicalPathModule), dataclass_IdentifierParallel)
177
+ if not isinstance(dataclassClassDef, ast.ClassDef): raise ValueError(f"I could not find `{dataclass_IdentifierParallel = }` in `{dataclassLogicalPathModule = }`.")
178
+
179
+ for aField in onlyParallelFields:
180
+ Official_fieldOrder.append(aField.name)
181
+ dictionaryDeReConstruction[aField.name] = DeReConstructField2ast(dataclassLogicalPathModule, dataclassClassDef, dataclassInstanceIdentifier, aField)
182
+
183
+ shatteredDataclassParallel = ShatteredDataclass(
184
+ countingVariableAnnotation=shatteredDataclass.countingVariableAnnotation,
185
+ countingVariableName=shatteredDataclass.countingVariableName,
186
+ field2AnnAssign={**shatteredDataclass.field2AnnAssign, **{dictionaryDeReConstruction[field].name: dictionaryDeReConstruction[field].astAnnAssignConstructor for field in Official_fieldOrder}},
187
+ Z0Z_field2AnnAssign={**shatteredDataclass.Z0Z_field2AnnAssign, **{dictionaryDeReConstruction[field].name: dictionaryDeReConstruction[field].Z0Z_hack for field in Official_fieldOrder}},
188
+ list_argAnnotated4ArgumentsSpecification=shatteredDataclass.list_argAnnotated4ArgumentsSpecification + [dictionaryDeReConstruction[field].ast_argAnnotated for field in Official_fieldOrder],
189
+ list_keyword_field__field4init=shatteredDataclass.list_keyword_field__field4init + [dictionaryDeReConstruction[field].ast_keyword_field__field for field in Official_fieldOrder if dictionaryDeReConstruction[field].init],
190
+ listAnnotations=shatteredDataclass.listAnnotations + [dictionaryDeReConstruction[field].astAnnotation for field in Official_fieldOrder],
191
+ listName4Parameters=shatteredDataclass.listName4Parameters + [dictionaryDeReConstruction[field].astName for field in Official_fieldOrder],
192
+ listUnpack=shatteredDataclass.listUnpack + [Make.AnnAssign(dictionaryDeReConstruction[field].astName, dictionaryDeReConstruction[field].astAnnotation, dictionaryDeReConstruction[field].ast_nameDOTname) for field in Official_fieldOrder],
193
+ map_stateDOTfield2Name={**shatteredDataclass.map_stateDOTfield2Name, **{dictionaryDeReConstruction[field].ast_nameDOTname: dictionaryDeReConstruction[field].astName for field in Official_fieldOrder}},
194
+ )
195
+ shatteredDataclassParallel.fragments4AssignmentOrParameters = Make.Tuple(shatteredDataclassParallel.listName4Parameters, ast.Store())
196
+ shatteredDataclassParallel.repack = Make.Assign([Make.Name(dataclassInstanceIdentifier)], value=Make.Call(Make.Name(dataclass_IdentifierParallel), list_keyword=shatteredDataclassParallel.list_keyword_field__field4init))
197
+ shatteredDataclassParallel.signatureReturnAnnotation = Make.Subscript(Make.Name('tuple'), Make.Tuple(shatteredDataclassParallel.listAnnotations))
198
+
199
+ shatteredDataclassParallel.imports.update(*(dictionaryDeReConstruction[field].ledger for field in Official_fieldOrder))
200
+ shatteredDataclassParallel.imports.addImportFrom_asStr(dataclassLogicalPathModule, dataclass_IdentifierParallel)
201
+ shatteredDataclassParallel.imports.update(shatteredDataclass.imports)
202
+ shatteredDataclassParallel.imports.removeImportFrom(dataclassLogicalPathModule, dataclass_Identifier)
203
+
204
+ # End add the parallel state fields to the count function ================================================
205
+
206
+ ingredientsFunction.imports.update(shatteredDataclassParallel.imports)
207
+ ingredientsFunction = removeDataclassFromFunction(ingredientsFunction, shatteredDataclassParallel)
208
+
209
+ # Start add the parallel logic to the count function ================================================
210
+
211
+ findThis = ClassIsAndAttribute.testIs(ast.While, ClassIsAndAttribute.leftIs(ast.Compare, IfThis.isName_Identifier('leafConnectee')))
212
+ doThat = Then.extractIt(DOT.body)
213
+ captureCountGapsCodeBlock: NodeTourist[ast.While, Sequence[ast.stmt]] = NodeTourist(findThis, doThat)
214
+ countGapsCodeBlock = raiseIfNone(captureCountGapsCodeBlock.captureLastMatch(ingredientsFunction.astFunctionDef))
215
+
216
+ thisIsMyTaskIndexCodeBlock = ast.If(ast.BoolOp(ast.Or()
217
+ , values=[ast.Compare(ast.Name('leaf1ndex'), ops=[ast.NotEq()], comparators=[ast.Name('taskDivisions')])
218
+ , ast.Compare(ast.BinOp(ast.Name('leafConnectee'), op=ast.Mod(), right=ast.Name('taskDivisions')), ops=[ast.Eq()], comparators=[ast.Name('taskIndex')])])
219
+ , body=list(countGapsCodeBlock[0:-1]))
220
+
221
+ countGapsCodeBlockNew: list[ast.stmt] = [thisIsMyTaskIndexCodeBlock, countGapsCodeBlock[-1]]
222
+
223
+ doThat = Grab.bodyAttribute(Then.replaceWith(countGapsCodeBlockNew))
224
+ NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
225
+
226
+ # End add the parallel logic to the count function ================================================
227
+
228
+ ingredientsFunction = removeUnusedParameters(ingredientsFunction)
229
+
230
+ ingredientsFunction = decorateCallableWithNumba(ingredientsFunction, parametersNumbaLight)
231
+
232
+ # Start unpack/repack the dataclass function ================================================
233
+ sourceCallableIdentifier = sourceCallableDispatcherDEFAULT
234
+
235
+ unRepackDataclass: IngredientsFunction = astModuleToIngredientsFunction(astModule, sourceCallableIdentifier)
236
+ unRepackDataclass.astFunctionDef.name = 'unRepack' + dataclass_IdentifierParallel
237
+ unRepackDataclass.imports.update(shatteredDataclassParallel.imports)
238
+ findThis = ClassIsAndAttribute.annotationIs(ast.arg, IfThis.isName_Identifier(dataclass_Identifier)) # pyright: ignore[reportArgumentType, reportUnknownVariableType, reportCallIssue]
239
+ doThat = Grab.annotationAttribute(Grab.idAttribute(Then.replaceWith(dataclass_IdentifierParallel))) # pyright: ignore[reportArgumentType]
240
+ NodeChanger(findThis, doThat).visit(unRepackDataclass.astFunctionDef) # pyright: ignore[reportUnknownArgumentType]
241
+ unRepackDataclass.astFunctionDef.returns = Make.Name(dataclass_IdentifierParallel)
242
+ targetCallableIdentifier = ingredientsFunction.astFunctionDef.name
243
+ unRepackDataclass = unpackDataclassCallFunctionRepackDataclass(unRepackDataclass, targetCallableIdentifier, shatteredDataclassParallel)
244
+
245
+ astTuple = raiseIfNone(NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(ingredientsFunction.astFunctionDef))
246
+ cast(ast.Tuple, astTuple).ctx = ast.Store()
247
+ findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCall_Identifier(targetCallableIdentifier))
248
+ doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), cast(ast.Tuple, astTuple).elts)))
249
+ changeAssignCallToTarget = NodeChanger(findThis, doThat)
250
+ changeAssignCallToTarget.visit(unRepackDataclass.astFunctionDef)
251
+
252
+ ingredientsDoTheNeedful: IngredientsFunction = IngredientsFunction(
253
+ astFunctionDef = ast.FunctionDef(name='doTheNeedful'
254
+ , args=ast.arguments(args=[ast.arg('state', annotation=ast.Name(dataclass_IdentifierParallel)), ast.arg('concurrencyLimit', annotation=ast.Name('int'))])
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(dataclass_IdentifierParallel)), 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
+ , ast.AnnAssign(target=ast.Name('groupsOfFoldsTotal', ctx=ast.Store()), annotation=ast.Name('int'), value=ast.Constant(value=0), simple=1)
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(dataclass_IdentifierParallel))])), value=ast.Dict(), simple=1)
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
+ , 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
+ , body=[ast.Assign(targets=[ast.Name('state', ctx=ast.Store())], value=ast.Call(func=ast.Name('deepcopy'), args=[ast.Name('stateParallel')]))
263
+ , ast.Assign(targets=[ast.Attribute(value=ast.Name('state'), attr='taskIndex', ctx=ast.Store())], value=ast.Name('indexSherpa'))
264
+ , ast.Assign(targets=[ast.Subscript(value=ast.Name('dictionaryConcurrency'), slice=ast.Name('indexSherpa'), ctx=ast.Store())], value=ast.Call(func=ast.Attribute(value=ast.Name('concurrencyManager'), attr='submit'), args=[ast.Name(unRepackDataclass.astFunctionDef.name), ast.Name('state')]))])
265
+ , 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')])
266
+ , body=[ast.Assign(targets=[ast.Subscript(value=ast.Name('listStatesParallel'), slice=ast.Name('indexSherpa'), ctx=ast.Store())], value=ast.Call(func=ast.Attribute(value=ast.Subscript(value=ast.Name('dictionaryConcurrency'), slice=ast.Name('indexSherpa')), attr='result')))
267
+ , ast.AugAssign(target=ast.Name('groupsOfFoldsTotal', ctx=ast.Store()), op=ast.Add(), value=ast.Attribute(value=ast.Subscript(value=ast.Name('listStatesParallel'), slice=ast.Name('indexSherpa')), attr='groupsOfFolds'))])])
268
+
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
+ , 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(dataclass_IdentifierParallel))])))
272
+ , imports = LedgerOfImports(Make.Module([ast.ImportFrom(module='concurrent.futures', names=[ast.alias(name='Future', asname='ConcurrentFuture'), ast.alias(name='ProcessPoolExecutor')], level=0),
273
+ ast.ImportFrom(module='copy', names=[ast.alias(name='deepcopy')], level=0),
274
+ ast.ImportFrom(module='multiprocessing', names=[ast.alias(name='set_start_method', asname='multiprocessing_set_start_method')], level=0),])
275
+ )
276
+ )
277
+
278
+ ingredientsModule = IngredientsModule([ingredientsFunction, unRepackDataclass, ingredientsDoTheNeedful]
279
+ , prologue = Make.Module([ast.If(test=ast.Compare(left=ast.Name('__name__'), ops=[ast.Eq()], comparators=[ast.Constant(value='__main__')]), body=[ast.Expr(value=ast.Call(func=ast.Name('multiprocessing_set_start_method'), args=[ast.Constant(value='spawn')]))])])
280
+ )
281
+ ingredientsModule.removeImportFromModule('numpy')
282
+
283
+ pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
284
+
285
+ write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
286
+ return pathFilename
287
+
288
+ def makeTheorem2(astModule: ast.Module, moduleIdentifier: str, callableIdentifier: str | None = None, logicalPathInfix: PathLike[str] | PurePath | str | None = None, sourceCallableDispatcher: str | None = None) -> PurePath:
289
+ sourceCallableIdentifier = sourceCallableIdentifierDEFAULT
290
+ if callableIdentifier is None:
291
+ callableIdentifier = sourceCallableIdentifier
292
+ ingredientsFunction = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
293
+ ingredientsFunction.astFunctionDef.name = callableIdentifier
294
+
295
+ dataclassInstanceIdentifier = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef))
296
+
297
+ findThis = IfThis.isWhileAttributeNamespaceIdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
298
+ doThat = Grab.testAttribute(Grab.comparatorsAttribute(Then.replaceWith([Make.Constant(4)]))) # pyright: ignore[reportArgumentType]
299
+ NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
300
+
301
+ findThis = IfThis.isIfAttributeNamespaceIdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
302
+ doThat = Then.extractIt(DOT.body)
303
+ insertLeaf = NodeTourist(findThis, doThat).captureLastMatch(ingredientsFunction.astFunctionDef)
304
+ findThis = IfThis.isIfAttributeNamespaceIdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
305
+ doThat = Then.replaceWith(insertLeaf)
306
+ NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
307
+
308
+ findThis = IfThis.isAttributeNamespaceIdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
309
+ doThat = Then.removeIt
310
+ NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
311
+
312
+ findThis = IfThis.isAttributeNamespaceIdentifierLessThanOrEqual0(dataclassInstanceIdentifier, 'leaf1ndex')
313
+ doThat = Then.removeIt
314
+ NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
315
+
316
+ theCountingIdentifier = theCountingIdentifierDEFAULT
317
+ doubleTheCount = Make.AugAssign(Make.Attribute(ast.Name(dataclassInstanceIdentifier), theCountingIdentifier), ast.Mult(), Make.Constant(2))
318
+ findThis = Be.Return
319
+ doThat = Then.insertThisAbove([doubleTheCount])
320
+ NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
321
+
322
+ ingredientsModule = IngredientsModule(ingredientsFunction)
323
+
324
+ if sourceCallableDispatcher is not None:
325
+ raise NotImplementedError('sourceCallableDispatcher is not implemented yet')
326
+
327
+ pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
328
+
329
+ write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
330
+
331
+ return pathFilename
332
+
333
+ def trimTheorem2(astModule: ast.Module, moduleIdentifier: str, callableIdentifier: str | None = None, logicalPathInfix: PathLike[str] | PurePath | str | None = None, sourceCallableDispatcher: str | None = None) -> PurePath:
334
+ sourceCallableIdentifier = sourceCallableIdentifierDEFAULT
335
+ if callableIdentifier is None:
336
+ callableIdentifier = sourceCallableIdentifier
337
+ ingredientsFunction = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
338
+ ingredientsFunction.astFunctionDef.name = callableIdentifier
339
+
340
+ dataclassInstanceIdentifier = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef))
341
+
342
+ findThis = IfThis.isIfUnaryNotAttributeNamespace_Identifier(dataclassInstanceIdentifier, 'dimensionsUnconstrained')
343
+ doThat = Then.removeIt
344
+ NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
345
+
346
+ ingredientsModule = IngredientsModule(ingredientsFunction)
347
+ ingredientsModule.removeImportFromModule('numpy')
348
+
349
+ pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
350
+
351
+ write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
352
+
353
+ return pathFilename
354
+
355
+ def numbaOnTheorem2(astModule: ast.Module, moduleIdentifier: str, callableIdentifier: str | None = None, logicalPathInfix: PathLike[str] | PurePath | str | None = None, sourceCallableDispatcher: str | None = None) -> PurePath:
356
+ sourceCallableIdentifier = sourceCallableIdentifierDEFAULT
357
+ if callableIdentifier is None:
358
+ callableIdentifier = sourceCallableIdentifier
359
+ ingredientsFunction = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
360
+ ingredientsFunction.astFunctionDef.name = callableIdentifier
361
+
362
+ shatteredDataclass = shatter_dataclassesDOTdataclass(*findDataclass(ingredientsFunction))
363
+
364
+ ingredientsFunction.imports.update(shatteredDataclass.imports)
365
+ ingredientsFunction = removeDataclassFromFunction(ingredientsFunction, shatteredDataclass)
366
+ ingredientsFunction = removeUnusedParameters(ingredientsFunction)
367
+ ingredientsFunction = decorateCallableWithNumba(ingredientsFunction, parametersNumbaLight)
368
+
369
+ ingredientsModule = IngredientsModule(ingredientsFunction)
370
+ ingredientsModule.removeImportFromModule('numpy')
371
+
372
+ pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
373
+
374
+ write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
375
+
376
+ return pathFilename
377
+
378
+ def makeUnRePackDataclass(astImportFrom: ast.ImportFrom) -> None:
379
+ callableIdentifierHARDCODED: str = 'sequential'
380
+
381
+ algorithmSourceModule = algorithmSourceModuleDEFAULT
382
+ sourceCallableIdentifier = sourceCallableDispatcherDEFAULT
383
+ logicalPathSourceModule = '.'.join([packageSettings.packageName, algorithmSourceModule])
384
+
385
+ logicalPathInfix = logicalPathInfixDEFAULT
386
+ moduleIdentifier = dataPackingModuleIdentifierDEFAULT
387
+ callableIdentifier = callableIdentifierHARDCODED
388
+
389
+ ingredientsFunction: IngredientsFunction = astModuleToIngredientsFunction(parseLogicalPath2astModule(logicalPathSourceModule), sourceCallableIdentifier)
390
+ ingredientsFunction.astFunctionDef.name = callableIdentifier
391
+
392
+ shatteredDataclass = shatter_dataclassesDOTdataclass(*findDataclass(ingredientsFunction))
393
+
394
+ ingredientsFunction.imports.update(shatteredDataclass.imports)
395
+ ingredientsFunction.imports.addAst(astImportFrom)
396
+ targetCallableIdentifier = astImportFrom.names[0].name
397
+ ingredientsFunction = raiseIfNone(unpackDataclassCallFunctionRepackDataclass(ingredientsFunction, targetCallableIdentifier, shatteredDataclass))
398
+ targetFunctionDef = raiseIfNone(extractFunctionDef(parseLogicalPath2astModule(raiseIfNone(astImportFrom.module)), targetCallableIdentifier))
399
+ astTuple = raiseIfNone(NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(targetFunctionDef))
400
+ cast(ast.Tuple, astTuple).ctx = ast.Store()
401
+
402
+ findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCall_Identifier(targetCallableIdentifier))
403
+ doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), cast(ast.Tuple, astTuple).elts)))
404
+ NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
405
+
406
+ ingredientsModule = IngredientsModule(ingredientsFunction)
407
+ ingredientsModule.removeImportFromModule('numpy')
408
+
409
+ pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
410
+
411
+ write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
412
+
413
+ if __name__ == '__main__':
414
+ astModule = getModule(logicalPathInfix=None)
415
+ makeInitializeGroupsOfFolds(astModule, 'initializeCount', 'initializeGroupsOfFolds', logicalPathInfixDEFAULT)
416
+
417
+ astModule = getModule(logicalPathInfix=None)
418
+ pathFilename = makeDaoOfMapFolding(astModule, 'daoOfMapFolding', None, logicalPathInfixDEFAULT, sourceCallableDispatcherDEFAULT)
419
+
420
+ astModule = getModule(logicalPathInfix=None)
421
+ pathFilename = makeDaoOfMapFoldingParallel(astModule, 'countParallel', None, logicalPathInfixDEFAULT, sourceCallableDispatcherDEFAULT)
422
+
423
+ astModule = getModule(logicalPathInfix=None)
424
+ pathFilename = makeTheorem2(astModule, 'theorem2', None, logicalPathInfixDEFAULT, None)
425
+
426
+ astModule = parsePathFilename2astModule(pathFilename)
427
+ pathFilename = trimTheorem2(astModule, 'theorem2Trimmed', None, logicalPathInfixDEFAULT, None)
428
+
429
+ astModule = parsePathFilename2astModule(pathFilename)
430
+ pathFilename = numbaOnTheorem2(astModule, 'theorem2Numba', None, logicalPathInfixDEFAULT, None)
431
+
432
+ astImportFrom = Make.ImportFrom(_getLogicalPath(packageSettings.packageName, logicalPathInfixDEFAULT, 'theorem2Numba'), list_alias=[Make.alias(sourceCallableIdentifierDEFAULT)])
433
+ makeUnRePackDataclass(astImportFrom)
@@ -45,9 +45,9 @@ test suite.
45
45
  """
46
46
 
47
47
  from mapFolding.someAssemblyRequired.infoBooth import (
48
- PackageInformation as PackageInformation,
48
+ dataclassInstanceIdentifierDEFAULT as dataclassInstanceIdentifierDEFAULT,
49
49
  raiseIfNoneGitHubIssueNumber3 as raiseIfNoneGitHubIssueNumber3,
50
- packageInformation as packageInformation,
50
+ sourceCallableDispatcherDEFAULT as sourceCallableDispatcherDEFAULT,
51
51
  )
52
52
 
53
53
  from mapFolding.someAssemblyRequired._toolIfThis import IfThis as IfThis
@@ -56,3 +56,8 @@ from mapFolding.someAssemblyRequired._toolkitContainers import (
56
56
  DeReConstructField2ast as DeReConstructField2ast,
57
57
  ShatteredDataclass as ShatteredDataclass,
58
58
  )
59
+
60
+ def raiseIfNone[TypeSansNone](returnTarget: TypeSansNone | None) -> TypeSansNone:
61
+ if returnTarget is None:
62
+ raise ValueError('Return is None.')
63
+ return returnTarget
@@ -19,7 +19,7 @@ they implement a declarative approach to AST manipulation that separates node id
19
19
  (be), and data access (DOT).
20
20
  """
21
21
 
22
- from astToolkit import ast_Identifier, Be, DOT, IfThis as astToolkit_IfThis
22
+ from astToolkit import Be, DOT, IfThis as astToolkit_IfThis
23
23
  from collections.abc import Callable
24
24
  from typing import TypeGuard
25
25
  import ast
@@ -36,23 +36,23 @@ class IfThis(astToolkit_IfThis):
36
36
  enabling precise targeting of AST elements for analysis or transformation.
37
37
  """
38
38
  @staticmethod
39
- def isAttributeNamespace_IdentifierGreaterThan0(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
39
+ def isAttributeNamespaceIdentifierGreaterThan0(namespace: str, identifier: str) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
40
40
  return lambda node: (Be.Compare(node)
41
41
  and IfThis.isAttributeNamespace_Identifier(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
45
- def isIfAttributeNamespace_IdentifierGreaterThan0(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.If] | bool]:
45
+ def isIfAttributeNamespaceIdentifierGreaterThan0(namespace: str, identifier: str) -> Callable[[ast.AST], TypeGuard[ast.If] | bool]:
46
46
  return lambda node: (Be.If(node)
47
- and IfThis.isAttributeNamespace_IdentifierGreaterThan0(namespace, identifier)(DOT.test(node)))
47
+ and IfThis.isAttributeNamespaceIdentifierGreaterThan0(namespace, identifier)(DOT.test(node)))
48
48
 
49
49
  @staticmethod
50
- def isWhileAttributeNamespace_IdentifierGreaterThan0(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.While] | bool]:
50
+ def isWhileAttributeNamespaceIdentifierGreaterThan0(namespace: str, identifier: str) -> Callable[[ast.AST], TypeGuard[ast.While] | bool]:
51
51
  return lambda node: (Be.While(node)
52
- and IfThis.isAttributeNamespace_IdentifierGreaterThan0(namespace, identifier)(DOT.test(node)))
52
+ and IfThis.isAttributeNamespaceIdentifierGreaterThan0(namespace, identifier)(DOT.test(node)))
53
53
 
54
54
  @staticmethod
55
- def isAttributeNamespace_IdentifierLessThanOrEqual0(namespace: ast_Identifier, identifier: ast_Identifier) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
55
+ def isAttributeNamespaceIdentifierLessThanOrEqual0(namespace: str, identifier: str) -> Callable[[ast.AST], TypeGuard[ast.Compare] | bool]:
56
56
  return lambda node: (Be.Compare(node)
57
57
  and IfThis.isAttributeNamespace_Identifier(namespace, identifier)(DOT.left(node))
58
58
  and Be.LtE(node.ops[0]))