mapFolding 0.11.4__tar.gz → 0.12.1__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.
- {mapfolding-0.11.4 → mapfolding-0.12.1}/PKG-INFO +3 -5
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/oeis.py +9 -5
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/RecipeJob.py +2 -2
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py +160 -212
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/__init__.py +7 -2
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/_toolIfThis.py +2 -2
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/_toolkitContainers.py +8 -8
- mapfolding-0.12.1/mapFolding/someAssemblyRequired/infoBooth.py +17 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +16 -16
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/toolkitNumba.py +1 -1
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/transformationTools.py +13 -13
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding.egg-info/PKG-INFO +3 -5
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding.egg-info/requires.txt +1 -1
- {mapfolding-0.11.4 → mapfolding-0.12.1}/pyproject.toml +3 -5
- mapfolding-0.11.4/mapFolding/someAssemblyRequired/infoBooth.py +0 -20
- {mapfolding-0.11.4 → mapfolding-0.12.1}/LICENSE +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/README.md +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/__init__.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/basecamp.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/beDRY.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/daoOfMapFolding.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/dataBaskets.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/datatypes.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/filesystemToolkit.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/py.typed +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/reference/__init__.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/reference/flattened.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/reference/hunterNumba.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/reference/irvineJavaPort.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/reference/jaxCount.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/reference/jobsCompleted/[2x19]/p2x19.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/reference/jobsCompleted/__init__.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/reference/jobsCompleted/p2x19/p2x19.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/reference/lunnonNumpy.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/reference/lunnonWhile.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/reference/rotatedEntryPoint.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/getLLVMforNoReason.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/syntheticModules/__init__.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/syntheticModules/countParallel.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/syntheticModules/daoOfMapFolding.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/syntheticModules/dataPacking.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/syntheticModules/initializeCount.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/syntheticModules/theorem2.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/syntheticModules/theorem2Numba.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/syntheticModules/theorem2Trimmed.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/theSSOT.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding.egg-info/SOURCES.txt +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding.egg-info/dependency_links.txt +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding.egg-info/entry_points.txt +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding.egg-info/top_level.txt +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/setup.cfg +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/tests/__init__.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/tests/conftest.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/tests/test_computations.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/tests/test_filesystem.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/tests/test_oeis.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/tests/test_other.py +0 -0
- {mapfolding-0.11.4 → mapfolding-0.12.1}/tests/test_tasks.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mapFolding
|
|
3
|
-
Version: 0.
|
|
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
|
|
@@ -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,10 +26,10 @@ 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.
|
|
29
|
+
Requires-Python: >=3.12
|
|
32
30
|
Description-Content-Type: text/markdown
|
|
33
31
|
License-File: LICENSE
|
|
34
|
-
Requires-Dist: astToolkit
|
|
32
|
+
Requires-Dist: astToolkit>=0.3.0
|
|
35
33
|
Requires-Dist: autoflake
|
|
36
34
|
Requires-Dist: numba_progress
|
|
37
35
|
Requires-Dist: numba
|
|
@@ -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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
1
|
from astToolkit import parseLogicalPath2astModule, str_nameDOTname
|
|
2
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
|
|
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
|
|
@@ -21,7 +21,7 @@ class RecipeJobTheorem2Numba:
|
|
|
21
21
|
|
|
22
22
|
sourceLogicalPathModuleDataclass: str_nameDOTname = 'mapFolding.dataBaskets'
|
|
23
23
|
sourceDataclassIdentifier: str = 'MapFoldingState'
|
|
24
|
-
sourceDataclassInstance: str =
|
|
24
|
+
sourceDataclassInstance: str = dataclassInstanceIdentifierDEFAULT
|
|
25
25
|
|
|
26
26
|
sourcePathPackage: PurePosixPath | None = PurePosixPath(packageSettings.pathPackage)
|
|
27
27
|
sourcePackageIdentifier: str | None = packageSettings.packageName
|
{mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py
RENAMED
|
@@ -23,26 +23,57 @@ from mapFolding import packageSettings
|
|
|
23
23
|
from mapFolding.someAssemblyRequired import (
|
|
24
24
|
DeReConstructField2ast,
|
|
25
25
|
IfThis,
|
|
26
|
-
|
|
26
|
+
raiseIfNone,
|
|
27
27
|
ShatteredDataclass,
|
|
28
|
-
|
|
28
|
+
sourceCallableDispatcherDEFAULT,
|
|
29
29
|
)
|
|
30
|
-
from mapFolding.someAssemblyRequired.infoBooth import
|
|
30
|
+
from mapFolding.someAssemblyRequired.infoBooth import algorithmSourceModuleDEFAULT, dataPackingModuleIdentifierDEFAULT, logicalPathInfixDEFAULT, sourceCallableIdentifierDEFAULT, theCountingIdentifierDEFAULT
|
|
31
31
|
from mapFolding.someAssemblyRequired.toolkitNumba import decorateCallableWithNumba, parametersNumbaLight
|
|
32
32
|
from mapFolding.someAssemblyRequired.transformationTools import (
|
|
33
33
|
removeDataclassFromFunction,
|
|
34
34
|
shatter_dataclassesDOTdataclass,
|
|
35
35
|
unpackDataclassCallFunctionRepackDataclass,
|
|
36
36
|
)
|
|
37
|
+
from os import PathLike
|
|
37
38
|
from pathlib import PurePath
|
|
39
|
+
from typing import cast
|
|
38
40
|
from Z0Z_tools import importLogicalPath2Callable
|
|
39
41
|
import ast
|
|
40
42
|
import dataclasses
|
|
41
|
-
from os import PathLike
|
|
42
43
|
|
|
43
|
-
def
|
|
44
|
-
|
|
45
|
-
|
|
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
|
+
dataclassIdentifier: 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] == dataclassIdentifier:
|
|
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), dataclassIdentifier, 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:
|
|
46
77
|
pathFilename = PurePath(moduleIdentifier + fileExtension)
|
|
47
78
|
if logicalPathInfix:
|
|
48
79
|
pathFilename = PurePath(logicalPathInfix, pathFilename)
|
|
@@ -50,65 +81,39 @@ def _getPathFilename(pathRoot: PathLike[str] | PurePath | None = packageSettings
|
|
|
50
81
|
pathFilename = PurePath(pathRoot, pathFilename)
|
|
51
82
|
return pathFilename
|
|
52
83
|
|
|
53
|
-
def makeInitializeGroupsOfFolds(moduleIdentifier: str, callableIdentifier: str, logicalPathInfix: PathLike[str] | PurePath | str | None = None) ->
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
countInitializeIngredients = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
|
|
60
|
-
|
|
61
|
-
countInitializeIngredients.astFunctionDef.name = callableIdentifier
|
|
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
|
|
62
90
|
|
|
63
|
-
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(
|
|
64
|
-
|
|
65
|
-
theCountingIdentifier = theCountingIdentifierHARDCODED
|
|
91
|
+
dataclassInstanceIdentifier = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
92
|
+
theCountingIdentifier = theCountingIdentifierDEFAULT
|
|
66
93
|
|
|
67
94
|
findThis = IfThis.isWhileAttributeNamespaceIdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
68
|
-
doThat = Grab.testAttribute(Grab.andDoAllOf([
|
|
69
|
-
NodeChanger(findThis, doThat).visit(
|
|
70
|
-
|
|
71
|
-
ingredientsModule = IngredientsModule(countInitializeIngredients)
|
|
72
|
-
|
|
73
|
-
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier + packageSettings.fileExtension)
|
|
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])
|
|
74
97
|
|
|
98
|
+
ingredientsModule = IngredientsModule(ingredientsFunction)
|
|
99
|
+
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
|
|
75
100
|
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
76
101
|
|
|
77
|
-
|
|
78
|
-
, logicalPathInfix: PathLike[str] | PurePath | str | None = None
|
|
79
|
-
, sourceCallableDispatcher: str | None = None) -> PurePath:
|
|
80
|
-
algorithmSourceModule = algorithmSourceModuleHARDCODED
|
|
81
|
-
sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
|
|
82
|
-
if callableIdentifier is None:
|
|
83
|
-
callableIdentifier = sourceCallableIdentifier
|
|
84
|
-
logicalPathSourceModule = '.'.join([packageSettings.packageName, algorithmSourceModule])
|
|
102
|
+
return pathFilename
|
|
85
103
|
|
|
86
|
-
|
|
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
|
|
87
106
|
ingredientsFunction = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
|
|
88
107
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
108
|
+
if callableIdentifier is None:
|
|
109
|
+
callableIdentifier = sourceCallableIdentifier
|
|
110
|
+
ingredientsFunction.astFunctionDef.name = callableIdentifier
|
|
93
111
|
|
|
94
|
-
|
|
95
|
-
for moduleWithLogicalPath, listNameTuples in ingredientsFunction.imports.dictionaryImportFrom.items():
|
|
96
|
-
for nameTuple in listNameTuples:
|
|
97
|
-
if nameTuple[0] == dataclass_Identifier:
|
|
98
|
-
dataclassLogicalPathModule = moduleWithLogicalPath
|
|
99
|
-
break
|
|
100
|
-
if dataclassLogicalPathModule:
|
|
101
|
-
break
|
|
102
|
-
if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
|
|
103
|
-
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
104
|
-
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
105
|
-
shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
|
|
112
|
+
shatteredDataclass = shatter_dataclassesDOTdataclass(*findDataclass(ingredientsFunction))
|
|
106
113
|
|
|
107
114
|
ingredientsFunction.imports.update(shatteredDataclass.imports)
|
|
108
115
|
ingredientsFunction = removeDataclassFromFunction(ingredientsFunction, shatteredDataclass)
|
|
109
|
-
|
|
110
116
|
ingredientsFunction = removeUnusedParameters(ingredientsFunction)
|
|
111
|
-
|
|
112
117
|
ingredientsFunction = decorateCallableWithNumba(ingredientsFunction, parametersNumbaLight)
|
|
113
118
|
|
|
114
119
|
ingredientsModule = IngredientsModule(ingredientsFunction)
|
|
@@ -119,12 +124,11 @@ def makeDaoOfMapFolding(moduleIdentifier: str, callableIdentifier: str | None =
|
|
|
119
124
|
ingredientsFunctionDispatcher.imports.update(shatteredDataclass.imports)
|
|
120
125
|
targetCallableIdentifier = ingredientsFunction.astFunctionDef.name
|
|
121
126
|
ingredientsFunctionDispatcher = unpackDataclassCallFunctionRepackDataclass(ingredientsFunctionDispatcher, targetCallableIdentifier, shatteredDataclass)
|
|
122
|
-
astTuple
|
|
123
|
-
|
|
124
|
-
astTuple.ctx = ast.Store()
|
|
127
|
+
astTuple = raiseIfNone(NodeTourist(Be.Return, Then.extractIt(DOT.value)).captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
128
|
+
cast(ast.Tuple, astTuple).ctx = ast.Store()
|
|
125
129
|
|
|
126
|
-
findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.
|
|
127
|
-
doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), astTuple.elts)))
|
|
130
|
+
findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCallIdentifier(targetCallableIdentifier))
|
|
131
|
+
doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), cast(ast.Tuple, astTuple).elts)))
|
|
128
132
|
changeAssignCallToTarget = NodeChanger(findThis, doThat)
|
|
129
133
|
changeAssignCallToTarget.visit(ingredientsFunctionDispatcher.astFunctionDef)
|
|
130
134
|
|
|
@@ -132,54 +136,45 @@ def makeDaoOfMapFolding(moduleIdentifier: str, callableIdentifier: str | None =
|
|
|
132
136
|
|
|
133
137
|
ingredientsModule.removeImportFromModule('numpy')
|
|
134
138
|
|
|
135
|
-
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier
|
|
139
|
+
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
|
|
136
140
|
|
|
137
141
|
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
138
142
|
|
|
139
143
|
return pathFilename
|
|
140
144
|
|
|
141
|
-
def makeDaoOfMapFoldingParallel() -> PurePath:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
|
|
146
|
-
logicalPathSourceModule = '.'.join([packageSettings.packageName, algorithmSourceModule])
|
|
147
|
-
|
|
148
|
-
logicalPathInfix = logicalPathInfixHARDCODED
|
|
149
|
-
moduleIdentifier = moduleIdentifierHARDCODED
|
|
150
|
-
|
|
151
|
-
astModule = parseLogicalPath2astModule(logicalPathSourceModule)
|
|
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
|
|
152
149
|
ingredientsFunction = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
|
|
150
|
+
ingredientsFunction.astFunctionDef.name = callableIdentifier
|
|
153
151
|
|
|
154
|
-
dataclassName: ast.expr
|
|
155
|
-
|
|
156
|
-
dataclass_Identifier: str | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
|
|
157
|
-
if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
152
|
+
dataclassName: ast.expr = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
153
|
+
dataclassIdentifier: str = raiseIfNone(NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName))
|
|
158
154
|
|
|
159
155
|
dataclassLogicalPathModule = None
|
|
160
156
|
for moduleWithLogicalPath, listNameTuples in ingredientsFunction.imports.dictionaryImportFrom.items():
|
|
161
157
|
for nameTuple in listNameTuples:
|
|
162
|
-
if nameTuple[0] ==
|
|
158
|
+
if nameTuple[0] == dataclassIdentifier:
|
|
163
159
|
dataclassLogicalPathModule = moduleWithLogicalPath
|
|
164
160
|
break
|
|
165
161
|
if dataclassLogicalPathModule:
|
|
166
162
|
break
|
|
167
|
-
if dataclassLogicalPathModule is None: raise
|
|
168
|
-
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
169
|
-
|
|
170
|
-
shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
|
|
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, dataclassIdentifier, dataclassInstanceIdentifier)
|
|
171
166
|
|
|
172
167
|
# Start add the parallel state fields to the count function ================================================
|
|
173
|
-
dataclassBaseFields = dataclasses.fields(importLogicalPath2Callable(dataclassLogicalPathModule,
|
|
174
|
-
|
|
175
|
-
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]
|
|
176
171
|
onlyParallelFields = [field for field in dataclassFieldsParallel if field.name not in [fieldBase.name for fieldBase in dataclassBaseFields]]
|
|
177
172
|
|
|
178
173
|
Official_fieldOrder: list[str] = []
|
|
179
174
|
dictionaryDeReConstruction: dict[str, DeReConstructField2ast] = {}
|
|
180
175
|
|
|
181
|
-
dataclassClassDef = extractClassDef(parseLogicalPath2astModule(dataclassLogicalPathModule),
|
|
182
|
-
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 = }`.")
|
|
183
178
|
|
|
184
179
|
for aField in onlyParallelFields:
|
|
185
180
|
Official_fieldOrder.append(aField.name)
|
|
@@ -198,13 +193,13 @@ def makeDaoOfMapFoldingParallel() -> PurePath:
|
|
|
198
193
|
map_stateDOTfield2Name={**shatteredDataclass.map_stateDOTfield2Name, **{dictionaryDeReConstruction[field].ast_nameDOTname: dictionaryDeReConstruction[field].astName for field in Official_fieldOrder}},
|
|
199
194
|
)
|
|
200
195
|
shatteredDataclassParallel.fragments4AssignmentOrParameters = Make.Tuple(shatteredDataclassParallel.listName4Parameters, ast.Store())
|
|
201
|
-
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))
|
|
202
197
|
shatteredDataclassParallel.signatureReturnAnnotation = Make.Subscript(Make.Name('tuple'), Make.Tuple(shatteredDataclassParallel.listAnnotations))
|
|
203
198
|
|
|
204
199
|
shatteredDataclassParallel.imports.update(*(dictionaryDeReConstruction[field].ledger for field in Official_fieldOrder))
|
|
205
|
-
shatteredDataclassParallel.imports.addImportFrom_asStr(dataclassLogicalPathModule,
|
|
200
|
+
shatteredDataclassParallel.imports.addImportFrom_asStr(dataclassLogicalPathModule, dataclassIdentifierParallel)
|
|
206
201
|
shatteredDataclassParallel.imports.update(shatteredDataclass.imports)
|
|
207
|
-
shatteredDataclassParallel.imports.removeImportFrom(dataclassLogicalPathModule,
|
|
202
|
+
shatteredDataclassParallel.imports.removeImportFrom(dataclassLogicalPathModule, dataclassIdentifier)
|
|
208
203
|
|
|
209
204
|
# End add the parallel state fields to the count function ================================================
|
|
210
205
|
|
|
@@ -213,11 +208,10 @@ def makeDaoOfMapFoldingParallel() -> PurePath:
|
|
|
213
208
|
|
|
214
209
|
# Start add the parallel logic to the count function ================================================
|
|
215
210
|
|
|
216
|
-
findThis = ClassIsAndAttribute.testIs(ast.While, ClassIsAndAttribute.leftIs(ast.Compare, IfThis.
|
|
211
|
+
findThis = ClassIsAndAttribute.testIs(ast.While, ClassIsAndAttribute.leftIs(ast.Compare, IfThis.isNameIdentifier('leafConnectee')))
|
|
217
212
|
doThat = Then.extractIt(DOT.body)
|
|
218
213
|
captureCountGapsCodeBlock: NodeTourist[ast.While, Sequence[ast.stmt]] = NodeTourist(findThis, doThat)
|
|
219
|
-
countGapsCodeBlock = captureCountGapsCodeBlock.captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
220
|
-
if countGapsCodeBlock is None: raise raiseIfNoneGitHubIssueNumber3
|
|
214
|
+
countGapsCodeBlock = raiseIfNone(captureCountGapsCodeBlock.captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
221
215
|
|
|
222
216
|
thisIsMyTaskIndexCodeBlock = ast.If(ast.BoolOp(ast.Or()
|
|
223
217
|
, values=[ast.Compare(ast.Name('leaf1ndex'), ops=[ast.NotEq()], comparators=[ast.Name('taskDivisions')])
|
|
@@ -236,34 +230,33 @@ def makeDaoOfMapFoldingParallel() -> PurePath:
|
|
|
236
230
|
ingredientsFunction = decorateCallableWithNumba(ingredientsFunction, parametersNumbaLight)
|
|
237
231
|
|
|
238
232
|
# Start unpack/repack the dataclass function ================================================
|
|
239
|
-
sourceCallableIdentifier =
|
|
233
|
+
sourceCallableIdentifier = sourceCallableDispatcherDEFAULT
|
|
240
234
|
|
|
241
235
|
unRepackDataclass: IngredientsFunction = astModuleToIngredientsFunction(astModule, sourceCallableIdentifier)
|
|
242
|
-
unRepackDataclass.astFunctionDef.name = 'unRepack' +
|
|
236
|
+
unRepackDataclass.astFunctionDef.name = 'unRepack' + dataclassIdentifierParallel
|
|
243
237
|
unRepackDataclass.imports.update(shatteredDataclassParallel.imports)
|
|
244
|
-
findThis = ClassIsAndAttribute.annotationIs(ast.arg, IfThis.
|
|
245
|
-
doThat = Grab.annotationAttribute(Grab.idAttribute(Then.replaceWith(
|
|
246
|
-
NodeChanger(findThis, doThat).visit(unRepackDataclass.astFunctionDef) #
|
|
247
|
-
unRepackDataclass.astFunctionDef.returns = Make.Name(
|
|
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
|
+
NodeChanger(findThis, doThat).visit(unRepackDataclass.astFunctionDef) # pyright: ignore[reportUnknownArgumentType]
|
|
241
|
+
unRepackDataclass.astFunctionDef.returns = Make.Name(dataclassIdentifierParallel)
|
|
248
242
|
targetCallableIdentifier = ingredientsFunction.astFunctionDef.name
|
|
249
243
|
unRepackDataclass = unpackDataclassCallFunctionRepackDataclass(unRepackDataclass, targetCallableIdentifier, shatteredDataclassParallel)
|
|
250
244
|
|
|
251
|
-
astTuple
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), astTuple.elts)))
|
|
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.isCallIdentifier(targetCallableIdentifier))
|
|
248
|
+
doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), cast(ast.Tuple, astTuple).elts)))
|
|
256
249
|
changeAssignCallToTarget = NodeChanger(findThis, doThat)
|
|
257
250
|
changeAssignCallToTarget.visit(unRepackDataclass.astFunctionDef)
|
|
258
251
|
|
|
259
252
|
ingredientsDoTheNeedful: IngredientsFunction = IngredientsFunction(
|
|
260
253
|
astFunctionDef = ast.FunctionDef(name='doTheNeedful'
|
|
261
|
-
, 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'))])
|
|
262
255
|
, body=[ast.Assign(targets=[ast.Name('stateParallel', ctx=ast.Store())], value=ast.Call(func=ast.Name('deepcopy'), args=[ast.Name('state')]))
|
|
263
|
-
, 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)
|
|
264
257
|
, ast.AnnAssign(target=ast.Name('groupsOfFoldsTotal', ctx=ast.Store()), annotation=ast.Name('int'), value=ast.Constant(value=0), simple=1)
|
|
265
258
|
|
|
266
|
-
, 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)
|
|
267
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()))]
|
|
268
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')])
|
|
269
262
|
, body=[ast.Assign(targets=[ast.Name('state', ctx=ast.Store())], value=ast.Call(func=ast.Name('deepcopy'), args=[ast.Name('stateParallel')]))
|
|
@@ -275,7 +268,7 @@ def makeDaoOfMapFoldingParallel() -> PurePath:
|
|
|
275
268
|
|
|
276
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)
|
|
277
270
|
, ast.Return(value=ast.Tuple(elts=[ast.Name('foldsTotal'), ast.Name('listStatesParallel')]))]
|
|
278
|
-
, 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))])))
|
|
279
272
|
, imports = LedgerOfImports(Make.Module([ast.ImportFrom(module='concurrent.futures', names=[ast.alias(name='Future', asname='ConcurrentFuture'), ast.alias(name='ProcessPoolExecutor')], level=0),
|
|
280
273
|
ast.ImportFrom(module='copy', names=[ast.alias(name='deepcopy')], level=0),
|
|
281
274
|
ast.ImportFrom(module='multiprocessing', names=[ast.alias(name='set_start_method', asname='multiprocessing_set_start_method')], level=0),])
|
|
@@ -287,28 +280,22 @@ def makeDaoOfMapFoldingParallel() -> PurePath:
|
|
|
287
280
|
)
|
|
288
281
|
ingredientsModule.removeImportFromModule('numpy')
|
|
289
282
|
|
|
290
|
-
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier
|
|
283
|
+
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
|
|
291
284
|
|
|
292
285
|
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
293
286
|
return pathFilename
|
|
294
287
|
|
|
295
|
-
def makeTheorem2(moduleIdentifier: str, callableIdentifier: str | None = None
|
|
296
|
-
|
|
297
|
-
, sourceCallableDispatcher: str | None = None) -> PurePath:
|
|
298
|
-
algorithmSourceModule = algorithmSourceModuleHARDCODED
|
|
299
|
-
sourceCallableIdentifier = sourceCallableIdentifierHARDCODED
|
|
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
|
|
300
290
|
if callableIdentifier is None:
|
|
301
291
|
callableIdentifier = sourceCallableIdentifier
|
|
302
|
-
logicalPathSourceModule = '.'.join([packageSettings.packageName, algorithmSourceModule])
|
|
303
|
-
|
|
304
|
-
astModule = parseLogicalPath2astModule(logicalPathSourceModule)
|
|
305
292
|
ingredientsFunction = IngredientsFunction(inlineFunctionDef(sourceCallableIdentifier, astModule), LedgerOfImports(astModule))
|
|
293
|
+
ingredientsFunction.astFunctionDef.name = callableIdentifier
|
|
306
294
|
|
|
307
|
-
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
308
|
-
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
295
|
+
dataclassInstanceIdentifier = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
309
296
|
|
|
310
297
|
findThis = IfThis.isWhileAttributeNamespaceIdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
311
|
-
doThat = Grab.testAttribute(Grab.comparatorsAttribute(Then.replaceWith([Make.Constant(4)]))) #
|
|
298
|
+
doThat = Grab.testAttribute(Grab.comparatorsAttribute(Then.replaceWith([Make.Constant(4)]))) # pyright: ignore[reportArgumentType]
|
|
312
299
|
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
313
300
|
|
|
314
301
|
findThis = IfThis.isIfAttributeNamespaceIdentifierGreaterThan0(dataclassInstanceIdentifier, 'leaf1ndex')
|
|
@@ -326,7 +313,7 @@ def makeTheorem2(moduleIdentifier: str, callableIdentifier: str | None = None
|
|
|
326
313
|
doThat = Then.removeIt
|
|
327
314
|
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
328
315
|
|
|
329
|
-
theCountingIdentifier =
|
|
316
|
+
theCountingIdentifier = theCountingIdentifierDEFAULT
|
|
330
317
|
doubleTheCount = Make.AugAssign(Make.Attribute(ast.Name(dataclassInstanceIdentifier), theCountingIdentifier), ast.Mult(), Make.Constant(2))
|
|
331
318
|
findThis = Be.Return
|
|
332
319
|
doThat = Then.insertThisAbove([doubleTheCount])
|
|
@@ -337,149 +324,110 @@ def makeTheorem2(moduleIdentifier: str, callableIdentifier: str | None = None
|
|
|
337
324
|
if sourceCallableDispatcher is not None:
|
|
338
325
|
raise NotImplementedError('sourceCallableDispatcher is not implemented yet')
|
|
339
326
|
|
|
340
|
-
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier
|
|
327
|
+
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
|
|
341
328
|
|
|
342
329
|
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
343
330
|
|
|
344
331
|
return pathFilename
|
|
345
332
|
|
|
346
|
-
def trimTheorem2(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
|
350
339
|
|
|
351
|
-
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
352
|
-
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
340
|
+
dataclassInstanceIdentifier = raiseIfNone(NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef))
|
|
353
341
|
|
|
354
|
-
findThis = IfThis.
|
|
342
|
+
findThis = IfThis.isIfUnaryNotAttributeNamespaceIdentifier(dataclassInstanceIdentifier, 'dimensionsUnconstrained')
|
|
355
343
|
doThat = Then.removeIt
|
|
356
344
|
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
357
345
|
|
|
358
346
|
ingredientsModule = IngredientsModule(ingredientsFunction)
|
|
359
347
|
ingredientsModule.removeImportFromModule('numpy')
|
|
360
348
|
|
|
361
|
-
pathFilename =
|
|
349
|
+
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
|
|
362
350
|
|
|
363
351
|
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
364
352
|
|
|
365
|
-
logicalPath: list[str] = []
|
|
366
|
-
if packageSettings.packageName:
|
|
367
|
-
logicalPath.append(packageSettings.packageName)
|
|
368
|
-
if logicalPathInfix:
|
|
369
|
-
logicalPath.append(logicalPathInfix)
|
|
370
|
-
logicalPath.append(pathFilename.stem)
|
|
371
|
-
moduleWithLogicalPath: str_nameDOTname = '.'.join(logicalPath)
|
|
372
|
-
|
|
373
|
-
astImportFrom: ast.ImportFrom = Make.ImportFrom(moduleWithLogicalPath, list_alias=[Make.alias(ingredientsFunction.astFunctionDef.name)])
|
|
374
|
-
|
|
375
353
|
return pathFilename
|
|
376
354
|
|
|
377
|
-
def numbaOnTheorem2(
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
dataclass_Identifier: str | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
|
|
384
|
-
if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
385
|
-
|
|
386
|
-
dataclassLogicalPathModule = None
|
|
387
|
-
for moduleWithLogicalPath, listNameTuples in countNumbaTheorem2.imports.dictionaryImportFrom.items():
|
|
388
|
-
for nameTuple in listNameTuples:
|
|
389
|
-
if nameTuple[0] == dataclass_Identifier:
|
|
390
|
-
dataclassLogicalPathModule = moduleWithLogicalPath
|
|
391
|
-
break
|
|
392
|
-
if dataclassLogicalPathModule:
|
|
393
|
-
break
|
|
394
|
-
if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
|
|
395
|
-
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(countNumbaTheorem2.astFunctionDef)
|
|
396
|
-
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
397
|
-
shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
|
|
398
|
-
|
|
399
|
-
countNumbaTheorem2.imports.update(shatteredDataclass.imports)
|
|
400
|
-
countNumbaTheorem2 = removeDataclassFromFunction(countNumbaTheorem2, shatteredDataclass)
|
|
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
|
|
401
361
|
|
|
402
|
-
|
|
362
|
+
shatteredDataclass = shatter_dataclassesDOTdataclass(*findDataclass(ingredientsFunction))
|
|
403
363
|
|
|
404
|
-
|
|
364
|
+
ingredientsFunction.imports.update(shatteredDataclass.imports)
|
|
365
|
+
ingredientsFunction = removeDataclassFromFunction(ingredientsFunction, shatteredDataclass)
|
|
366
|
+
ingredientsFunction = removeUnusedParameters(ingredientsFunction)
|
|
367
|
+
ingredientsFunction = decorateCallableWithNumba(ingredientsFunction, parametersNumbaLight)
|
|
405
368
|
|
|
406
|
-
ingredientsModule = IngredientsModule(
|
|
369
|
+
ingredientsModule = IngredientsModule(ingredientsFunction)
|
|
407
370
|
ingredientsModule.removeImportFromModule('numpy')
|
|
408
371
|
|
|
409
|
-
pathFilename =
|
|
372
|
+
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
|
|
410
373
|
|
|
411
374
|
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
412
375
|
|
|
413
|
-
|
|
414
|
-
if packageSettings.packageName:
|
|
415
|
-
logicalPath.append(packageSettings.packageName)
|
|
416
|
-
if logicalPathInfix:
|
|
417
|
-
logicalPath.append(logicalPathInfix)
|
|
418
|
-
logicalPath.append(pathFilename.stem)
|
|
419
|
-
moduleWithLogicalPath: str_nameDOTname = '.'.join(logicalPath)
|
|
420
|
-
|
|
421
|
-
astImportFrom: ast.ImportFrom = Make.ImportFrom(moduleWithLogicalPath, list_alias=[Make.alias(countNumbaTheorem2.astFunctionDef.name)])
|
|
422
|
-
|
|
423
|
-
return astImportFrom
|
|
376
|
+
return pathFilename
|
|
424
377
|
|
|
425
378
|
def makeUnRePackDataclass(astImportFrom: ast.ImportFrom) -> None:
|
|
426
379
|
callableIdentifierHARDCODED: str = 'sequential'
|
|
427
380
|
|
|
428
|
-
algorithmSourceModule =
|
|
429
|
-
sourceCallableIdentifier =
|
|
381
|
+
algorithmSourceModule = algorithmSourceModuleDEFAULT
|
|
382
|
+
sourceCallableIdentifier = sourceCallableDispatcherDEFAULT
|
|
430
383
|
logicalPathSourceModule = '.'.join([packageSettings.packageName, algorithmSourceModule])
|
|
431
384
|
|
|
432
|
-
logicalPathInfix =
|
|
433
|
-
moduleIdentifier =
|
|
385
|
+
logicalPathInfix = logicalPathInfixDEFAULT
|
|
386
|
+
moduleIdentifier = dataPackingModuleIdentifierDEFAULT
|
|
434
387
|
callableIdentifier = callableIdentifierHARDCODED
|
|
435
388
|
|
|
436
389
|
ingredientsFunction: IngredientsFunction = astModuleToIngredientsFunction(parseLogicalPath2astModule(logicalPathSourceModule), sourceCallableIdentifier)
|
|
437
390
|
ingredientsFunction.astFunctionDef.name = callableIdentifier
|
|
438
|
-
dataclassName: ast.expr | None = NodeTourist(Be.arg, Then.extractIt(DOT.annotation)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
439
|
-
if dataclassName is None: raise raiseIfNoneGitHubIssueNumber3
|
|
440
|
-
dataclass_Identifier: str | None = NodeTourist(Be.Name, Then.extractIt(DOT.id)).captureLastMatch(dataclassName)
|
|
441
|
-
if dataclass_Identifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
442
391
|
|
|
443
|
-
|
|
444
|
-
for moduleWithLogicalPath, listNameTuples in ingredientsFunction.imports.dictionaryImportFrom.items():
|
|
445
|
-
for nameTuple in listNameTuples:
|
|
446
|
-
if nameTuple[0] == dataclass_Identifier:
|
|
447
|
-
dataclassLogicalPathModule = moduleWithLogicalPath
|
|
448
|
-
break
|
|
449
|
-
if dataclassLogicalPathModule:
|
|
450
|
-
break
|
|
451
|
-
if dataclassLogicalPathModule is None: raise raiseIfNoneGitHubIssueNumber3
|
|
452
|
-
dataclassInstanceIdentifier = NodeTourist(Be.arg, Then.extractIt(DOT.arg)).captureLastMatch(ingredientsFunction.astFunctionDef)
|
|
453
|
-
if dataclassInstanceIdentifier is None: raise raiseIfNoneGitHubIssueNumber3
|
|
454
|
-
shatteredDataclass = shatter_dataclassesDOTdataclass(dataclassLogicalPathModule, dataclass_Identifier, dataclassInstanceIdentifier)
|
|
392
|
+
shatteredDataclass = shatter_dataclassesDOTdataclass(*findDataclass(ingredientsFunction))
|
|
455
393
|
|
|
456
394
|
ingredientsFunction.imports.update(shatteredDataclass.imports)
|
|
457
395
|
ingredientsFunction.imports.addAst(astImportFrom)
|
|
458
396
|
targetCallableIdentifier = astImportFrom.names[0].name
|
|
459
|
-
ingredientsFunction = unpackDataclassCallFunctionRepackDataclass(ingredientsFunction, targetCallableIdentifier, shatteredDataclass)
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
astTuple
|
|
466
|
-
|
|
467
|
-
findThis = ClassIsAndAttribute.valueIs(ast.Assign, IfThis.isCall_Identifier(targetCallableIdentifier))
|
|
468
|
-
doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), astTuple.elts)))
|
|
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.isCallIdentifier(targetCallableIdentifier))
|
|
403
|
+
doThat = Then.replaceWith(Make.Assign([astTuple], value=Make.Call(Make.Name(targetCallableIdentifier), cast(ast.Tuple, astTuple).elts)))
|
|
469
404
|
NodeChanger(findThis, doThat).visit(ingredientsFunction.astFunctionDef)
|
|
470
405
|
|
|
471
406
|
ingredientsModule = IngredientsModule(ingredientsFunction)
|
|
472
407
|
ingredientsModule.removeImportFromModule('numpy')
|
|
473
408
|
|
|
474
|
-
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier
|
|
409
|
+
pathFilename = _getPathFilename(packageSettings.pathPackage, logicalPathInfix, moduleIdentifier)
|
|
475
410
|
|
|
476
411
|
write_astModule(ingredientsModule, pathFilename, packageSettings.packageName)
|
|
477
412
|
|
|
478
413
|
if __name__ == '__main__':
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
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)])
|
|
483
433
|
makeUnRePackDataclass(astImportFrom)
|
|
484
|
-
pathFilename = makeDaoOfMapFolding('daoOfMapFolding', None, logicalPathInfixHARDCODED, sourceCallableDispatcherHARDCODED)
|
|
485
|
-
makeDaoOfMapFoldingParallel()
|
|
@@ -45,9 +45,9 @@ test suite.
|
|
|
45
45
|
"""
|
|
46
46
|
|
|
47
47
|
from mapFolding.someAssemblyRequired.infoBooth import (
|
|
48
|
-
|
|
48
|
+
dataclassInstanceIdentifierDEFAULT as dataclassInstanceIdentifierDEFAULT,
|
|
49
49
|
raiseIfNoneGitHubIssueNumber3 as raiseIfNoneGitHubIssueNumber3,
|
|
50
|
-
|
|
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
|
|
@@ -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]))
|
{mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/_toolkitContainers.py
RENAMED
|
@@ -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,17 +131,17 @@ 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
|
-
sherpa
|
|
137
|
-
findThis=ClassIsAndAttribute.targetIs(ast.AnnAssign, IfThis.
|
|
138
|
-
, doThat=Then.extractIt(DOT.annotation) #
|
|
136
|
+
sherpa = NodeTourist( # pyright: ignore[reportUnknownVariableType]
|
|
137
|
+
findThis=ClassIsAndAttribute.targetIs(ast.AnnAssign, IfThis.isNameIdentifier(self.name))
|
|
138
|
+
, doThat=Then.extractIt(DOT.annotation) # pyright: ignore[reportArgumentType]
|
|
139
139
|
).captureLastMatch(dataclassClassDef)
|
|
140
140
|
|
|
141
|
-
if sherpa is None: raise raiseIfNoneGitHubIssueNumber3
|
|
141
|
+
if sherpa is None: raise raiseIfNoneGitHubIssueNumber3
|
|
142
142
|
else: self.astAnnotation = sherpa
|
|
143
143
|
|
|
144
|
-
self.ast_argAnnotated = Make.arg(self.name, self.astAnnotation)
|
|
144
|
+
self.ast_argAnnotated = Make.arg(self.name, self.astAnnotation) # pyright: ignore[reportUnknownArgumentType, reportUnknownMemberType]
|
|
145
145
|
|
|
146
146
|
dtype = self.metadata.get('dtype', None)
|
|
147
147
|
if dtype:
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
algorithmSourceModuleDEFAULT: str = 'daoOfMapFolding'
|
|
2
|
+
dataclassInstanceIdentifierDEFAULT: str = 'state'
|
|
3
|
+
dataPackingModuleIdentifierDEFAULT: str = 'dataPacking'
|
|
4
|
+
logicalPathInfixDEFAULT: str = 'syntheticModules'
|
|
5
|
+
sourceCallableDispatcherDEFAULT: str = 'doTheNeedful'
|
|
6
|
+
sourceCallableIdentifierDEFAULT: str = 'count'
|
|
7
|
+
theCountingIdentifierDEFAULT: str = 'groupsOfFolds'
|
|
8
|
+
|
|
9
|
+
class raiseIfNoneGitHubIssueNumber3(Exception): pass
|
|
10
|
+
|
|
11
|
+
dictionaryEstimates: dict[tuple[int, ...], int] = {
|
|
12
|
+
(2,2,2,2,2,2,2,2): 798148657152000,
|
|
13
|
+
(2,21): 776374224866624,
|
|
14
|
+
(3,15): 824761667826225,
|
|
15
|
+
(3,3,3,3): 85109616000000000000000000000000,
|
|
16
|
+
(8,8): 791274195985524900,
|
|
17
|
+
}
|
{mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py
RENAMED
|
@@ -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
|
|
|
@@ -129,4 +129,4 @@ def decorateCallableWithNumba(ingredientsFunction: IngredientsFunction, paramete
|
|
|
129
129
|
class SpicesJobNumba:
|
|
130
130
|
useNumbaProgressBar: bool = True
|
|
131
131
|
numbaProgressBarIdentifier: str = 'ProgressBarGroupsOfFolds'
|
|
132
|
-
parametersNumba: ParametersNumba = dataclasses.field(default_factory=ParametersNumba)
|
|
132
|
+
parametersNumba: ParametersNumba = dataclasses.field(default_factory=ParametersNumba) # pyright: ignore[reportArgumentType, reportCallIssue, reportUnknownVariableType]
|
{mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/transformationTools.py
RENAMED
|
@@ -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.
|
|
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
|
|
@@ -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,10 +26,10 @@ 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.
|
|
29
|
+
Requires-Python: >=3.12
|
|
32
30
|
Description-Content-Type: text/markdown
|
|
33
31
|
License-File: LICENSE
|
|
34
|
-
Requires-Dist: astToolkit
|
|
32
|
+
Requires-Dist: astToolkit>=0.3.0
|
|
35
33
|
Requires-Dist: autoflake
|
|
36
34
|
Requires-Dist: numba_progress
|
|
37
35
|
Requires-Dist: numba
|
|
@@ -14,8 +14,6 @@ classifiers = [
|
|
|
14
14
|
"Operating System :: OS Independent",
|
|
15
15
|
"Programming Language :: Python",
|
|
16
16
|
"Programming Language :: Python :: 3",
|
|
17
|
-
"Programming Language :: Python :: 3.10",
|
|
18
|
-
"Programming Language :: Python :: 3.11",
|
|
19
17
|
"Programming Language :: Python :: 3.12",
|
|
20
18
|
"Programming Language :: Python :: 3.13",
|
|
21
19
|
"Topic :: Scientific/Engineering :: Mathematics",
|
|
@@ -25,7 +23,7 @@ classifiers = [
|
|
|
25
23
|
"Topic :: Software Development :: Compilers",
|
|
26
24
|
"Typing :: Typed",]
|
|
27
25
|
dependencies = [
|
|
28
|
-
"astToolkit",
|
|
26
|
+
"astToolkit>=0.3.0",
|
|
29
27
|
"autoflake",
|
|
30
28
|
"numba_progress",
|
|
31
29
|
"numba",
|
|
@@ -69,10 +67,10 @@ optional-dependencies = { testing = [
|
|
|
69
67
|
"pyupgrade",
|
|
70
68
|
"ruff",] }
|
|
71
69
|
readme = { file = "README.md", content-type = "text/markdown" }
|
|
72
|
-
requires-python = ">=3.
|
|
70
|
+
requires-python = ">=3.12"
|
|
73
71
|
scripts = { getOEISids = "mapFolding.oeis:getOEISids", clearOEIScache = "mapFolding.oeis:clearOEIScache", OEIS_for_n = "mapFolding.oeis:OEIS_for_n" }
|
|
74
72
|
urls = { Donate = "https://www.patreon.com/integrated", Homepage = "https://github.com/hunterhogan/mapFolding", Repository = "https://github.com/hunterhogan/mapFolding.git", Issues = "https://github.com/hunterhogan/mapFolding/issues"}
|
|
75
|
-
version = "0.
|
|
73
|
+
version = "0.12.1"
|
|
76
74
|
|
|
77
75
|
[tool.coverage]
|
|
78
76
|
report = { exclude_lines = [
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
from mapFolding import PackageSettings
|
|
2
|
-
import dataclasses
|
|
3
|
-
|
|
4
|
-
dataclassInstanceIdentifierHardcoded: str = 'state'
|
|
5
|
-
sourceCallableDispatcherHARDCODED: str = 'doTheNeedful'
|
|
6
|
-
|
|
7
|
-
class raiseIfNoneGitHubIssueNumber3(Exception): pass
|
|
8
|
-
|
|
9
|
-
dictionaryEstimates: dict[tuple[int, ...], int] = {
|
|
10
|
-
(2,2,2,2,2,2,2,2): 798148657152000,
|
|
11
|
-
(2,21): 776374224866624,
|
|
12
|
-
(3,15): 824761667826225,
|
|
13
|
-
(3,3,3,3): 85109616000000000000000000000000,
|
|
14
|
-
(8,8): 791274195985524900,
|
|
15
|
-
}
|
|
16
|
-
algorithmSourceModuleHARDCODED: str = 'daoOfMapFolding'
|
|
17
|
-
sourceCallableIdentifierHARDCODED: str = 'count'
|
|
18
|
-
logicalPathInfixHARDCODED: str = 'syntheticModules'
|
|
19
|
-
theCountingIdentifierHARDCODED: str = 'groupsOfFolds'
|
|
20
|
-
dataPackingModuleIdentifierHARDCODED: str = 'dataPacking'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mapfolding-0.11.4 → mapfolding-0.12.1}/mapFolding/someAssemblyRequired/getLLVMforNoReason.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|