mapFolding 0.12.2__py3-none-any.whl → 0.13.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. mapFolding/__init__.py +4 -2
  2. mapFolding/_theSSOT.py +32 -88
  3. mapFolding/{datatypes.py → _theTypes.py} +25 -3
  4. mapFolding/basecamp.py +38 -33
  5. mapFolding/beDRY.py +79 -54
  6. mapFolding/dataBaskets.py +123 -93
  7. mapFolding/filesystemToolkit.py +140 -91
  8. mapFolding/oeis.py +243 -145
  9. mapFolding/reference/flattened.py +1 -1
  10. mapFolding/someAssemblyRequired/RecipeJob.py +116 -100
  11. mapFolding/someAssemblyRequired/__init__.py +40 -15
  12. mapFolding/someAssemblyRequired/_toolIfThis.py +82 -54
  13. mapFolding/someAssemblyRequired/_toolkitContainers.py +19 -16
  14. mapFolding/someAssemblyRequired/getLLVMforNoReason.py +35 -26
  15. mapFolding/someAssemblyRequired/makeAllModules.py +353 -283
  16. mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +83 -84
  17. mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +256 -0
  18. mapFolding/someAssemblyRequired/toolkitNumba.py +80 -50
  19. mapFolding/someAssemblyRequired/transformationTools.py +63 -40
  20. {tests → mapFolding/tests}/__init__.py +2 -2
  21. {tests → mapFolding/tests}/conftest.py +232 -63
  22. {tests → mapFolding/tests}/test_computations.py +58 -18
  23. {tests → mapFolding/tests}/test_filesystem.py +10 -13
  24. {tests → mapFolding/tests}/test_oeis.py +5 -18
  25. {tests → mapFolding/tests}/test_other.py +9 -9
  26. {tests → mapFolding/tests}/test_tasks.py +7 -9
  27. {mapfolding-0.12.2.dist-info → mapfolding-0.13.0.dist-info}/METADATA +24 -37
  28. mapfolding-0.13.0.dist-info/RECORD +54 -0
  29. {mapfolding-0.12.2.dist-info → mapfolding-0.13.0.dist-info}/top_level.txt +0 -1
  30. mapfolding-0.12.2.dist-info/RECORD +0 -53
  31. {mapfolding-0.12.2.dist-info → mapfolding-0.13.0.dist-info}/WHEEL +0 -0
  32. {mapfolding-0.12.2.dist-info → mapfolding-0.13.0.dist-info}/entry_points.txt +0 -0
  33. {mapfolding-0.12.2.dist-info → mapfolding-0.13.0.dist-info}/licenses/LICENSE +0 -0
@@ -25,15 +25,12 @@ to low-level optimized functions while maintaining semantic equivalence and type
25
25
  the compilation process.
26
26
  """
27
27
 
28
- from astToolkit import (
29
- ClassIsAndAttribute, DOT, hasDOTtarget_NameOrAttributeOrSubscript, identifierDotAttribute,
30
- LedgerOfImports, Make, NodeTourist, Then,
31
- )
28
+ from astToolkit import Be, DOT, identifierDotAttribute, LedgerOfImports, Make, NodeTourist, Then
32
29
  from collections.abc import Callable
33
30
  from copy import deepcopy
31
+ from hunterMakesPy import raiseIfNone
34
32
  from mapFolding.someAssemblyRequired import IfThis
35
33
  from typing import Any, cast
36
- from Z0Z_tools import raiseIfNone
37
34
  import ast
38
35
  import dataclasses
39
36
 
@@ -43,8 +40,7 @@ dummyTuple = Make.Tuple([Make.Name("dummyElement")])
43
40
 
44
41
  @dataclasses.dataclass
45
42
  class ShatteredDataclass:
46
- """
47
- Container for decomposed dataclass components organized as AST nodes for code generation.
43
+ """Container for decomposed dataclass components organized as AST nodes for code generation.
48
44
 
49
45
  This class holds the decomposed representation of a dataclass, breaking it down into individual
50
46
  AST components that can be manipulated and recombined for different code generation contexts.
@@ -59,6 +55,7 @@ class ShatteredDataclass:
59
55
  dataclass fields into individual parameters) and result reconstruction (packing individual
60
56
  values back into dataclass instances).
61
57
  """
58
+
62
59
  countingVariableAnnotation: ast.expr
63
60
  """Type annotation for the counting variable extracted from the dataclass."""
64
61
 
@@ -194,11 +191,16 @@ class DeReConstructField2ast:
194
191
  scalar types, and complex type annotations, creating appropriate constructor
195
192
  calls and import requirements.
196
193
 
197
- Parameters:
198
- dataclassesDOTdataclassLogicalPathModule: Module path containing the dataclass
199
- dataclassClassDef: AST class definition for type annotation extraction
200
- dataclassesDOTdataclassInstanceIdentifier: Instance variable name for attribute access
201
- field: Dataclass field to transform
194
+ Parameters
195
+ ----------
196
+ dataclassesDOTdataclassLogicalPathModule : identifierDotAttribute
197
+ Module path containing the dataclass
198
+ dataclassClassDef : ast.ClassDef
199
+ AST class definition for type annotation extraction
200
+ dataclassesDOTdataclassInstanceIdentifier : str
201
+ Instance variable name for attribute access
202
+ field : dataclasses.Field[Any]
203
+ Dataclass field to transform
202
204
  """
203
205
  self.compare = field.compare
204
206
  self.default = field.default if field.default is not dataclasses.MISSING else None
@@ -215,9 +217,10 @@ class DeReConstructField2ast:
215
217
  self.ast_keyword_field__field = Make.keyword(self.name, self.astName)
216
218
  self.ast_nameDOTname = Make.Attribute(Make.Name(dataclassesDOTdataclassInstanceIdentifier), self.name)
217
219
 
218
- findThis=ClassIsAndAttribute.targetIs(ast.AnnAssign, IfThis.isNameIdentifier(self.name))
219
- doThat=cast(Callable[[hasDOTtarget_NameOrAttributeOrSubscript], ast.expr], Then.extractIt(DOT.annotation))
220
- self.astAnnotation = raiseIfNone(NodeTourist(findThis, doThat).captureLastMatch(dataclassClassDef))
220
+ self.astAnnotation = raiseIfNone(NodeTourist[ast.AnnAssign, ast.Name | None](
221
+ findThis = Be.AnnAssign.targetIs(IfThis.isNameIdentifier(self.name))
222
+ , doThat = Then.extractIt(cast("Callable[[ast.AnnAssign], ast.Name | None]", DOT.annotation))
223
+ ).captureLastMatch(dataclassClassDef))
221
224
 
222
225
  self.ast_argAnnotated = Make.arg(self.name, self.astAnnotation)
223
226
 
@@ -228,7 +231,7 @@ class DeReConstructField2ast:
228
231
  self.ledger.addImportFrom_asStr(moduleWithLogicalPath, annotationType)
229
232
  self.ledger.addImportFrom_asStr(moduleWithLogicalPath, 'dtype')
230
233
  axesSubscript = Make.Subscript(Make.Name('tuple'), Make.Name('uint8'))
231
- dtype_asnameName: ast.Name = cast(ast.Name, self.astAnnotation)
234
+ dtype_asnameName: ast.Name = self.astAnnotation
232
235
  if dtype_asnameName.id == 'Array3D':
233
236
  axesSubscript = Make.Subscript(Make.Name('tuple'), Make.Tuple([Make.Name('uint8'), Make.Name('uint8'), Make.Name('uint8')]))
234
237
  ast_expr = Make.Subscript(Make.Name(annotationType), Make.Tuple([axesSubscript, Make.Subscript(Make.Name('dtype'), dtype_asnameName)]))
@@ -24,34 +24,43 @@ While originally part of a tighter integration with the code generation assembly
24
24
  this module now operates as a standalone utility that can be applied to any module
25
25
  containing Numba-compiled functions.
26
26
  """
27
- from importlib.machinery import ModuleSpec
28
27
  from pathlib import Path
29
- from types import ModuleType
28
+ from typing import TYPE_CHECKING
30
29
  import importlib.util
31
30
  import llvmlite.binding
32
31
 
32
+ if TYPE_CHECKING:
33
+ from importlib.machinery import ModuleSpec
34
+ from types import ModuleType
35
+
33
36
  def writeModuleLLVM(pathFilename: Path, identifierCallable: str) -> Path:
34
- """Import the generated module directly and get its LLVM IR.
35
-
36
- Parameters
37
- pathFilename: Path to the Python module file containing the Numba-compiled function
38
- identifierCallable: Name of the function within the module to extract LLVM IR from
39
-
40
- Returns
41
- Path to the generated .ll file containing the extracted LLVM IR
42
-
43
- For an example of the output, see reference/jobsCompleted/[2x19]/[2x19].ll,
44
- which contains the IR for the historically significant 2x19 map calculation.
45
- """
46
- specTarget: ModuleSpec | None = importlib.util.spec_from_file_location("generatedModule", pathFilename)
47
- if specTarget is None or specTarget.loader is None:
48
- raise ImportError(f"Could not create module spec or loader for {pathFilename}")
49
- moduleTarget: ModuleType = importlib.util.module_from_spec(specTarget)
50
- specTarget.loader.exec_module(moduleTarget)
51
-
52
- # Get LLVM IR and write to file
53
- linesLLVM = moduleTarget.__dict__[identifierCallable].inspect_llvm()[()]
54
- moduleLLVM: llvmlite.binding.ModuleRef = llvmlite.binding.module.parse_assembly(linesLLVM)
55
- pathFilenameLLVM: Path = pathFilename.with_suffix(".ll")
56
- pathFilenameLLVM.write_text(str(moduleLLVM))
57
- return pathFilenameLLVM
37
+ """Import the generated module directly and get its LLVM IR.
38
+
39
+ Parameters
40
+ ----------
41
+ pathFilename : Path
42
+ Path to the Python module file containing the Numba-compiled function
43
+ identifierCallable : str
44
+ Name of the function within the module to extract LLVM IR from
45
+
46
+ Returns
47
+ -------
48
+ pathFilenameLLVM : Path
49
+ Path to the generated .ll file containing the extracted LLVM IR
50
+
51
+ For an example of the output, see reference/jobsCompleted/[2x19]/[2x19].ll,
52
+ which contains the IR for the historically significant 2x19 map calculation.
53
+ """
54
+ specTarget: ModuleSpec | None = importlib.util.spec_from_file_location("generatedModule", pathFilename)
55
+ if specTarget is None or specTarget.loader is None:
56
+ message = f"Could not create module spec or loader for {pathFilename}"
57
+ raise ImportError(message)
58
+ moduleTarget: ModuleType = importlib.util.module_from_spec(specTarget)
59
+ specTarget.loader.exec_module(moduleTarget)
60
+
61
+ # Get LLVM IR and write to file
62
+ linesLLVM = moduleTarget.__dict__[identifierCallable].inspect_llvm()[()]
63
+ moduleLLVM: llvmlite.binding.ModuleRef = llvmlite.binding.module.parse_assembly(linesLLVM)
64
+ pathFilenameLLVM: Path = pathFilename.with_suffix(".ll")
65
+ pathFilenameLLVM.write_text(str(moduleLLVM))
66
+ return pathFilenameLLVM