mapFolding 0.12.3__tar.gz → 0.13.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.
Files changed (59) hide show
  1. {mapfolding-0.12.3 → mapfolding-0.13.1}/PKG-INFO +18 -27
  2. {mapfolding-0.12.3 → mapfolding-0.13.1}/README.md +3 -19
  3. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/basecamp.py +6 -6
  4. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/dataBaskets.py +38 -51
  5. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/oeis.py +1 -1
  6. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/someAssemblyRequired/RecipeJob.py +82 -82
  7. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/someAssemblyRequired/_toolkitContainers.py +3 -3
  8. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/someAssemblyRequired/makeAllModules.py +8 -11
  9. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +10 -35
  10. mapfolding-0.13.1/mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +196 -0
  11. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/someAssemblyRequired/toolkitNumba.py +10 -8
  12. {mapfolding-0.12.3 → mapfolding-0.13.1/mapFolding}/tests/__init__.py +2 -2
  13. {mapfolding-0.12.3 → mapfolding-0.13.1/mapFolding}/tests/conftest.py +232 -63
  14. {mapfolding-0.12.3 → mapfolding-0.13.1/mapFolding}/tests/test_computations.py +36 -14
  15. {mapfolding-0.12.3 → mapfolding-0.13.1/mapFolding}/tests/test_filesystem.py +10 -13
  16. {mapfolding-0.12.3 → mapfolding-0.13.1/mapFolding}/tests/test_oeis.py +5 -19
  17. {mapfolding-0.12.3 → mapfolding-0.13.1/mapFolding}/tests/test_other.py +6 -6
  18. {mapfolding-0.12.3 → mapfolding-0.13.1/mapFolding}/tests/test_tasks.py +5 -5
  19. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding.egg-info/PKG-INFO +18 -27
  20. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding.egg-info/SOURCES.txt +8 -7
  21. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding.egg-info/requires.txt +7 -4
  22. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding.egg-info/top_level.txt +0 -1
  23. {mapfolding-0.12.3 → mapfolding-0.13.1}/pyproject.toml +17 -10
  24. {mapfolding-0.12.3 → mapfolding-0.13.1}/LICENSE +0 -0
  25. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/__init__.py +0 -0
  26. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/_theSSOT.py +0 -0
  27. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/_theTypes.py +0 -0
  28. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/beDRY.py +0 -0
  29. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/daoOfMapFolding.py +0 -0
  30. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/filesystemToolkit.py +0 -0
  31. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/py.typed +0 -0
  32. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/reference/__init__.py +0 -0
  33. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/reference/flattened.py +0 -0
  34. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/reference/hunterNumba.py +0 -0
  35. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/reference/irvineJavaPort.py +0 -0
  36. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/reference/jaxCount.py +0 -0
  37. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/reference/jobsCompleted/[2x19]/p2x19.py +0 -0
  38. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/reference/jobsCompleted/__init__.py +0 -0
  39. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/reference/jobsCompleted/p2x19/p2x19.py +0 -0
  40. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/reference/lunnonNumpy.py +0 -0
  41. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/reference/lunnonWhile.py +0 -0
  42. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/reference/rotatedEntryPoint.py +0 -0
  43. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
  44. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/someAssemblyRequired/__init__.py +0 -0
  45. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/someAssemblyRequired/_toolIfThis.py +0 -0
  46. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/someAssemblyRequired/getLLVMforNoReason.py +0 -0
  47. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/someAssemblyRequired/infoBooth.py +0 -0
  48. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/someAssemblyRequired/transformationTools.py +0 -0
  49. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/syntheticModules/__init__.py +0 -0
  50. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/syntheticModules/countParallel.py +0 -0
  51. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/syntheticModules/daoOfMapFolding.py +0 -0
  52. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/syntheticModules/dataPacking.py +0 -0
  53. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/syntheticModules/initializeCount.py +0 -0
  54. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/syntheticModules/theorem2.py +0 -0
  55. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/syntheticModules/theorem2Numba.py +0 -0
  56. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding/syntheticModules/theorem2Trimmed.py +0 -0
  57. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding.egg-info/dependency_links.txt +0 -0
  58. {mapfolding-0.12.3 → mapfolding-0.13.1}/mapFolding.egg-info/entry_points.txt +0 -0
  59. {mapfolding-0.12.3 → mapfolding-0.13.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mapFolding
3
- Version: 0.12.3
3
+ Version: 0.13.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
@@ -8,42 +8,49 @@ Project-URL: Donate, https://www.patreon.com/integrated
8
8
  Project-URL: Homepage, https://github.com/hunterhogan/mapFolding
9
9
  Project-URL: Issues, https://github.com/hunterhogan/mapFolding/issues
10
10
  Project-URL: Repository, https://github.com/hunterhogan/mapFolding.git
11
- Keywords: A000136,A001415,A001416,A001417,A001418,A195646,AST manipulation,Numba optimization,OEIS,algorithmic optimization,code generation,code transformation,combinatorics,computational geometry,dataclass transformation,folding pattern enumeration,just-in-time compilation,map folding,performance optimization,source code analysis,stamp folding
11
+ Keywords: A000136,A001415,A001416,A001417,A001418,A195646,AST manipulation,Numba optimization,OEIS,algorithmic optimization,code generation,code transformation,codon optimization,combinatorics,computational geometry,dataclass transformation,folding pattern enumeration,just-in-time compilation,map folding,performance optimization,source code analysis,stamp folding
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Environment :: Console
14
14
  Classifier: Intended Audience :: Developers
15
15
  Classifier: Intended Audience :: Education
16
16
  Classifier: Intended Audience :: Science/Research
17
17
  Classifier: Natural Language :: English
18
+ Classifier: Operating System :: MacOS
18
19
  Classifier: Operating System :: OS Independent
19
- Classifier: Programming Language :: Python
20
- Classifier: Programming Language :: Python :: 3
20
+ Classifier: Operating System :: POSIX :: Linux
21
+ Classifier: Programming Language :: Python :: 3 :: Only
21
22
  Classifier: Programming Language :: Python :: 3.12
22
23
  Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3
25
+ Classifier: Programming Language :: Python :: Implementation :: CPython
26
+ Classifier: Programming Language :: Python
23
27
  Classifier: Topic :: Scientific/Engineering :: Information Analysis
24
28
  Classifier: Topic :: Scientific/Engineering :: Mathematics
25
29
  Classifier: Topic :: Software Development :: Code Generators
26
30
  Classifier: Topic :: Software Development :: Compilers
27
31
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
32
+ Classifier: Topic :: Software Development :: Pre-processors
28
33
  Classifier: Typing :: Typed
29
34
  Requires-Python: >=3.12
30
35
  Description-Content-Type: text/markdown
31
36
  License-File: LICENSE
32
- Requires-Dist: astToolkit>=0.5.0
37
+ Requires-Dist: astToolkit
33
38
  Requires-Dist: hunterMakesPy
34
- Requires-Dist: numba
35
- Requires-Dist: numba_progress
36
39
  Requires-Dist: numpy
37
40
  Requires-Dist: platformdirs
38
41
  Provides-Extra: development
39
42
  Requires-Dist: mypy; extra == "development"
40
43
  Requires-Dist: pyupgrade; extra == "development"
41
44
  Requires-Dist: setuptools-scm; extra == "development"
45
+ Provides-Extra: numba
46
+ Requires-Dist: numba; extra == "numba"
47
+ Requires-Dist: numba_progress; extra == "numba"
42
48
  Provides-Extra: testing
43
- Requires-Dist: pytest; extra == "testing"
49
+ Requires-Dist: numba; extra == "testing"
44
50
  Requires-Dist: pytest-cov; extra == "testing"
45
51
  Requires-Dist: pytest-env; extra == "testing"
46
52
  Requires-Dist: pytest-xdist; extra == "testing"
53
+ Requires-Dist: pytest; extra == "testing"
47
54
  Dynamic: license-file
48
55
 
49
56
  # mapFolding
@@ -94,6 +101,7 @@ For larger maps, these calculations require hours or days to complete. A 2×20 s
94
101
  - **Automatic code generation** that produces standalone, highly optimized computation modules
95
102
  - **Dataclass decomposition** to enable Numba compatibility while preserving readable source code
96
103
  - **Comprehensive optimization** including dead code elimination, static value embedding, and aggressive compilation settings
104
+ - **codon code generation**: compile map folding computation modules using [Codon](https://docs.exaloop.io/start/install/), enabling high-performance native binaries from Python source code.
97
105
 
98
106
  ### Educational Resources
99
107
 
@@ -106,35 +114,18 @@ For larger maps, these calculations require hours or days to complete. A 2×20 s
106
114
 
107
115
  **Mathematical Research**: Explore folding pattern properties, extend known sequences, or validate theoretical results against computed values.
108
116
 
109
- **Algorithm Optimization Learning**: Study a complete transformation pipeline that converts high-level algorithms into production-ready optimized code.
117
+ **Algorithm Optimization Learning**: Study a complete transformation assembly line that converts high-level algorithms into production-ready optimized code.
110
118
 
111
119
  **Performance Computing Education**: Examine techniques for achieving maximum Python performance through Numba integration, AST manipulation, and specialized code generation.
112
120
 
113
121
  **Combinatorial Problem Solving**: Use the framework as a template for optimizing other recursive combinatorial algorithms.
114
122
 
115
- ## Example Usage
116
-
117
- ```python
118
- from mapFolding import countFolds
119
-
120
- # Count folding patterns for a 3×3 square
121
- result = countFolds([3, 3])
122
-
123
- # Access OEIS sequences directly
124
- from mapFolding import oeisIDfor_n
125
- strip_foldings = oeisIDfor_n('A001415', 6) # 2×6 strip
126
-
127
- # Generate optimized code for specific dimensions
128
- from mapFolding.someAssemblyRequired import makeJobTheorem2Numba
129
- # Creates specialized modules for maximum performance
130
- ```
131
-
132
123
  ## Repository Structure
133
124
 
134
125
  - `mapFolding/`: Core implementation with modular architecture
135
126
  - `reference/`: Historical algorithm implementations and performance studies
136
127
  - `someAssemblyRequired/`: AST transformation framework
137
- - `tests/`: Comprehensive validation suite
128
+ - `mapFolding/tests/`: Comprehensive validation suite
138
129
  - `jobs/`: Generated optimized modules for specific calculations
139
130
 
140
131
  ## Performance Characteristics
@@ -46,6 +46,7 @@ For larger maps, these calculations require hours or days to complete. A 2×20 s
46
46
  - **Automatic code generation** that produces standalone, highly optimized computation modules
47
47
  - **Dataclass decomposition** to enable Numba compatibility while preserving readable source code
48
48
  - **Comprehensive optimization** including dead code elimination, static value embedding, and aggressive compilation settings
49
+ - **codon code generation**: compile map folding computation modules using [Codon](https://docs.exaloop.io/start/install/), enabling high-performance native binaries from Python source code.
49
50
 
50
51
  ### Educational Resources
51
52
 
@@ -58,35 +59,18 @@ For larger maps, these calculations require hours or days to complete. A 2×20 s
58
59
 
59
60
  **Mathematical Research**: Explore folding pattern properties, extend known sequences, or validate theoretical results against computed values.
60
61
 
61
- **Algorithm Optimization Learning**: Study a complete transformation pipeline that converts high-level algorithms into production-ready optimized code.
62
+ **Algorithm Optimization Learning**: Study a complete transformation assembly line that converts high-level algorithms into production-ready optimized code.
62
63
 
63
64
  **Performance Computing Education**: Examine techniques for achieving maximum Python performance through Numba integration, AST manipulation, and specialized code generation.
64
65
 
65
66
  **Combinatorial Problem Solving**: Use the framework as a template for optimizing other recursive combinatorial algorithms.
66
67
 
67
- ## Example Usage
68
-
69
- ```python
70
- from mapFolding import countFolds
71
-
72
- # Count folding patterns for a 3×3 square
73
- result = countFolds([3, 3])
74
-
75
- # Access OEIS sequences directly
76
- from mapFolding import oeisIDfor_n
77
- strip_foldings = oeisIDfor_n('A001415', 6) # 2×6 strip
78
-
79
- # Generate optimized code for specific dimensions
80
- from mapFolding.someAssemblyRequired import makeJobTheorem2Numba
81
- # Creates specialized modules for maximum performance
82
- ```
83
-
84
68
  ## Repository Structure
85
69
 
86
70
  - `mapFolding/`: Core implementation with modular architecture
87
71
  - `reference/`: Historical algorithm implementations and performance studies
88
72
  - `someAssemblyRequired/`: AST transformation framework
89
- - `tests/`: Comprehensive validation suite
73
+ - `mapFolding/tests/`: Comprehensive validation suite
90
74
  - `jobs/`: Generated optimized modules for specific calculations
91
75
 
92
76
  ## Performance Characteristics
@@ -31,11 +31,11 @@ from os import PathLike
31
31
  from pathlib import PurePath
32
32
  import contextlib
33
33
 
34
- def countFolds(listDimensions: Sequence[int] | None = None # noqa: C901
34
+ def countFolds(listDimensions: Sequence[int] | None = None # noqa: C901, PLR0912, PLR0915
35
35
  , pathLikeWriteFoldsTotal: PathLike[str] | PurePath | None = None
36
36
  , computationDivisions: int | str | None = None
37
- , CPUlimit: int | float | bool | None = None
38
- # , * I need to improve `standardizedEqualToCallableReturn` so it will work with keyword arguments
37
+ # , * # TODO improve `standardizedEqualToCallableReturn` so it will work with keyword arguments
38
+ , CPUlimit: int | float | bool | None = None # noqa: FBT001
39
39
  , mapShape: tuple[int, ...] | None = None
40
40
  , oeisID: str | None = None
41
41
  , oeis_n: int | None = None
@@ -142,7 +142,7 @@ def countFolds(listDimensions: Sequence[int] | None = None # noqa: C901
142
142
  mapFoldingState = doTheNeedful(mapFoldingState)
143
143
  foldsTotal = mapFoldingState.foldsTotal
144
144
 
145
- elif flow == 'theorem2' and any(dimension > 2 for dimension in mapShape): # noqa: PLR2004
145
+ elif flow == 'theorem2' and any(dimension > 2 for dimension in mapShape):
146
146
  from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
147
147
  mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
148
148
 
@@ -154,7 +154,7 @@ def countFolds(listDimensions: Sequence[int] | None = None # noqa: C901
154
154
 
155
155
  foldsTotal = mapFoldingState.foldsTotal
156
156
 
157
- elif flow == 'theorem2Trimmed' and any(dimension > 2 for dimension in mapShape): # noqa: PLR2004
157
+ elif flow == 'theorem2Trimmed' and any(dimension > 2 for dimension in mapShape):
158
158
  from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
159
159
  mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
160
160
 
@@ -166,7 +166,7 @@ def countFolds(listDimensions: Sequence[int] | None = None # noqa: C901
166
166
 
167
167
  foldsTotal = mapFoldingState.foldsTotal
168
168
 
169
- elif (flow == 'theorem2Numba' or taskDivisions == 0) and any(dimension > 2 for dimension in mapShape): # noqa: PLR2004
169
+ elif (flow == 'theorem2Numba' or taskDivisions == 0) and any(dimension > 2 for dimension in mapShape):
170
170
  from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
171
171
  mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
172
172
 
@@ -29,122 +29,109 @@ import dataclasses
29
29
  class MapFoldingState:
30
30
  """Core computational state for map folding algorithms.
31
31
 
32
- (AI generated docstring)
33
-
34
- This class encapsulates all data needed to perform map folding computations,
35
- from the basic map dimensions through the complex internal arrays needed
36
- for efficient algorithmic processing. It serves as both a data container
37
- and a computational interface, providing properties and methods that
38
- abstract the underlying complexity.
39
-
40
- The class handles automatic initialization of all computational arrays
41
- based on the map dimensions, ensuring consistent sizing and type usage
42
- throughout the computation. It also manages the relationship between
43
- different data domains (leaves, elephino, folds) defined in the type system.
44
-
45
- Key Design Features include automatic array sizing based on map dimensions,
46
- type-safe access to computational data, lazy initialization of expensive arrays,
47
- integration with NumPy for performance, and metadata preservation for code generation.
32
+ This class encapsulates all data needed to perform map folding computations and metadata useful for code transformations.
48
33
 
49
34
  Attributes
50
35
  ----------
51
36
  mapShape : tuple[DatatypeLeavesTotal, ...]
52
37
  Dimensions of the map being analyzed for folding patterns.
53
38
  groupsOfFolds : DatatypeFoldsTotal = DatatypeFoldsTotal(0)
54
- Current count of distinct folding pattern groups discovered.
39
+ Current count of distinct folding pattern groups: each group has `leavesTotal`-many foldings.
55
40
  gap1ndex : DatatypeElephino = DatatypeElephino(0)
56
- Current position in gap enumeration algorithms.
41
+ The current 1-indexed position of the 'gap' during computation: 1-indexed as opposed to 0-indexed.
57
42
  gap1ndexCeiling : DatatypeElephino = DatatypeElephino(0)
58
- Upper bound for gap enumeration operations.
43
+ The upper bound of `gap1ndex`.
59
44
  indexDimension : DatatypeLeavesTotal = DatatypeLeavesTotal(0)
60
- Current dimension being processed in multi-dimensional algorithms.
45
+ The current 0-indexed position of the dimension during computation.
61
46
  indexLeaf : DatatypeLeavesTotal = DatatypeLeavesTotal(0)
62
- Current leaf being processed in sequential algorithms.
47
+ The current 0-indexed position of a leaf in a loop during computation: not to be confused with `leaf1ndex`.
63
48
  indexMiniGap : DatatypeElephino = DatatypeElephino(0)
64
- Current position within a gap subdivision.
49
+ The current 0-indexed position of a 'gap' in a loop during computation.
65
50
  leaf1ndex : DatatypeLeavesTotal = DatatypeLeavesTotal(1)
66
- One-based leaf index for algorithmic compatibility.
51
+ The current 1-indexed position of the leaf during computation: 1-indexed as opposed to 0-indexed.
67
52
  leafConnectee : DatatypeLeavesTotal = DatatypeLeavesTotal(0)
68
53
  Target leaf for connection operations.
69
54
  dimensionsUnconstrained : DatatypeLeavesTotal = None
70
55
  Count of dimensions not subject to folding constraints.
71
56
  countDimensionsGapped : Array1DLeavesTotal = None
72
- Array tracking gap counts across dimensions.
57
+ Array tracking computed number of dimensions with gaps.
73
58
  gapRangeStart : Array1DElephino = None
74
- Array of starting positions for gap ranges.
59
+ Array tracking computed starting positions of gap ranges.
75
60
  gapsWhere : Array1DLeavesTotal = None
76
61
  Array indicating locations of gaps in the folding pattern.
77
62
  leafAbove : Array1DLeavesTotal = None
78
- Array mapping each leaf to the leaf above it in the folding.
63
+ Array tracking the leaves above to the current leaf, `leaf1ndex`, during computation.
79
64
  leafBelow : Array1DLeavesTotal = None
80
- Array mapping each leaf to the leaf below it in the folding.
65
+ Array tracking the leaves below to the current leaf, `leaf1ndex`, during computation.
81
66
  connectionGraph : Array3D
82
- Three-dimensional representation of leaf connectivity.
67
+ Unchanging array representing connections between all leaves.
83
68
  dimensionsTotal : DatatypeLeavesTotal
84
- Total number of dimensions in the map.
69
+ Unchanging total number of dimensions in the map.
85
70
  leavesTotal : DatatypeLeavesTotal
86
- Total number of individual leaves in the map.
71
+ Unchanging total number of leaves in the map.
87
72
 
88
73
  """
89
74
 
90
75
  mapShape: tuple[DatatypeLeavesTotal, ...] = dataclasses.field(init=True, metadata={'elementConstructor': 'DatatypeLeavesTotal'})
76
+ """Dimensions of the map being analyzed for folding patterns."""
91
77
 
92
78
  groupsOfFolds: DatatypeFoldsTotal = dataclasses.field(default=DatatypeFoldsTotal(0), metadata={'theCountingIdentifier': True})
79
+ """Current count of distinct folding pattern groups: each group has `leavesTotal`-many foldings."""
93
80
 
94
81
  gap1ndex: DatatypeElephino = DatatypeElephino(0) # noqa: RUF009
82
+ """The current 1-indexed position of the 'gap' during computation: 1-indexed as opposed to 0-indexed."""
95
83
  gap1ndexCeiling: DatatypeElephino = DatatypeElephino(0) # noqa: RUF009
84
+ """The upper bound of `gap1ndex`."""
96
85
  indexDimension: DatatypeLeavesTotal = DatatypeLeavesTotal(0) # noqa: RUF009
86
+ """The current 0-indexed position of the dimension during computation."""
97
87
  indexLeaf: DatatypeLeavesTotal = DatatypeLeavesTotal(0) # noqa: RUF009
88
+ """The current 0-indexed position of a leaf in a loop during computation: not to be confused with `leaf1ndex`."""
98
89
  indexMiniGap: DatatypeElephino = DatatypeElephino(0) # noqa: RUF009
90
+ """The current 0-indexed position of a 'gap' in a loop during computation."""
99
91
  leaf1ndex: DatatypeLeavesTotal = DatatypeLeavesTotal(1) # noqa: RUF009
92
+ """The current 1-indexed position of the leaf during computation: 1-indexed as opposed to 0-indexed."""
100
93
  leafConnectee: DatatypeLeavesTotal = DatatypeLeavesTotal(0) # noqa: RUF009
94
+ """Target leaf for connection operations."""
101
95
 
102
96
  dimensionsUnconstrained: DatatypeLeavesTotal = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType, reportAttributeAccessIssue, reportUnknownMemberType]
97
+ """Count of dimensions not subject to folding constraints."""
103
98
 
104
99
  countDimensionsGapped: Array1DLeavesTotal = dataclasses.field(default=None, init=True, metadata={'dtype': Array1DLeavesTotal.__args__[1].__args__[0]}) # pyright: ignore[reportAssignmentType, reportAttributeAccessIssue, reportUnknownMemberType]
100
+ """Array tracking computed number of dimensions with gaps."""
105
101
  gapRangeStart: Array1DElephino = dataclasses.field(default=None, init=True, metadata={'dtype': Array1DElephino.__args__[1].__args__[0]}) # pyright: ignore[reportAssignmentType, reportAttributeAccessIssue, reportUnknownMemberType]
102
+ """Array tracking computed starting positions of gap ranges."""
106
103
  gapsWhere: Array1DLeavesTotal = dataclasses.field(default=None, init=True, metadata={'dtype': Array1DLeavesTotal.__args__[1].__args__[0]}) # pyright: ignore[reportAssignmentType, reportAttributeAccessIssue, reportUnknownMemberType]
104
+ """Array indicating locations of gaps in the folding pattern."""
107
105
  leafAbove: Array1DLeavesTotal = dataclasses.field(default=None, init=True, metadata={'dtype': Array1DLeavesTotal.__args__[1].__args__[0]}) # pyright: ignore[reportAssignmentType, reportAttributeAccessIssue, reportUnknownMemberType]
106
+ """Array tracking the leaves above to the current leaf, `leaf1ndex`, during computation."""
108
107
  leafBelow: Array1DLeavesTotal = dataclasses.field(default=None, init=True, metadata={'dtype': Array1DLeavesTotal.__args__[1].__args__[0]}) # pyright: ignore[reportAssignmentType, reportAttributeAccessIssue, reportUnknownMemberType]
108
+ """Array tracking the leaves below to the current leaf, `leaf1ndex`, during computation."""
109
109
 
110
110
  connectionGraph: Array3D = dataclasses.field(init=False, metadata={'dtype': Array3D.__args__[1].__args__[0]}) # pyright: ignore[reportUnknownMemberType, reportAttributeAccessIssue]
111
+ """Unchanging array representing connections between all leaves."""
111
112
  dimensionsTotal: DatatypeLeavesTotal = dataclasses.field(init=False)
113
+ """Unchanging total number of dimensions in the map."""
112
114
  leavesTotal: DatatypeLeavesTotal = dataclasses.field(init=False)
115
+ """Unchanging total number of leaves in the map."""
113
116
  @property
114
117
  def foldsTotal(self) -> DatatypeFoldsTotal:
115
- """Calculate the total number of possible folding patterns for this map.
116
-
117
- (AI generated docstring)
118
+ """The total number of possible folding patterns for this map.
118
119
 
119
120
  Returns
120
121
  -------
121
- totalFoldingPatterns : DatatypeFoldsTotal
122
+ totalFoldings : DatatypeFoldsTotal
122
123
  The complete count of distinct folding patterns achievable with the current map configuration.
123
124
 
124
- Notes
125
- -----
126
- This represents the fundamental result of map folding analysis - the total
127
- number of unique ways a map can be folded given its dimensional constraints.
128
-
129
125
  """
130
126
  return DatatypeFoldsTotal(self.leavesTotal) * self.groupsOfFolds
131
127
 
132
128
  def __post_init__(self) -> None:
133
- """Initialize all computational arrays and derived values after dataclass construction.
134
-
135
- (AI generated docstring)
136
-
137
- This method performs the expensive operations needed to prepare the state
138
- for computation, including array allocation, dimension calculation, and
139
- connection graph generation. It runs automatically after the dataclass
140
- constructor completes.
129
+ """Ensure all fields have a value.
141
130
 
142
131
  Notes
143
132
  -----
144
- Arrays that are not explicitly provided (None) are automatically
145
- allocated with appropriate sizes based on the map dimensions.
146
- The connection graph is always regenerated to ensure consistency
147
- with the provided map shape.
133
+ Arrays that are not explicitly provided (None) are automatically allocated with appropriate sizes based on the map
134
+ dimensions. `dimensionsTotal`, `leavesTotal`, and `connectionGraph` cannot be set: they are calculated.
148
135
 
149
136
  """
150
137
  self.dimensionsTotal = DatatypeLeavesTotal(len(self.mapShape))
@@ -8,7 +8,7 @@ folding ecosystem into the broader mathematical community through comprehensive
8
8
  integration with the Online Encyclopedia of Integer Sequences (OEIS). This bridge
9
9
  enables validation of computational results against established mathematical
10
10
  knowledge while supporting the discovery of new sequence values through the
11
- sophisticated computational pipeline.
11
+ sophisticated computational assembly line.
12
12
 
13
13
  The integration provides multiple pathways for mathematical verification: direct
14
14
  computation of OEIS sequences using the complete algorithmic implementation,
@@ -1,31 +1,4 @@
1
- """
2
- Map folding AST transformation system: Configuration management and transformation orchestration.
3
-
4
- This module provides the configuration orchestration layer of the map folding AST transformation
5
- system, implementing comprehensive recipes that coordinate the entire transformation process from
6
- abstract mathematical algorithms to optimized computational modules. The `RecipeJobTheorem2Numba`
7
- dataclass serves as the central configuration blueprint that bridges pattern recognition, dataclass
8
- decomposition, function optimization, and Numba compilation into a unified transformation process.
9
-
10
- The recipe system addresses the complexity of managing transformation parameters across multiple
11
- stages while maintaining consistency between source algorithm metadata and target optimization
12
- requirements. The orchestration layer coordinates the systematic extraction of mathematical
13
- functions from source modules, embedding of concrete parameter values, elimination of dead code
14
- paths, and generation of standalone Python modules optimized for specific map dimensions through
15
- the complete transformation process.
16
-
17
- Configuration management separates source analysis capabilities from target generation parameters,
18
- enabling systematic exploration of computational spaces through automated generation of optimized
19
- solvers. Source analysis encompasses parsing and analysis of abstract syntax trees from generic
20
- algorithm modules, extraction of specific mathematical functions for specialization, and
21
- identification of dataclass structures for parameter embedding. Target generation coordinates
22
- creation of standalone Python modules with optimized implementations, integration of Numba
23
- optimization directives, and preservation of mathematical correctness throughout optimization.
24
-
25
- The recipe system enables the broader map folding research framework by providing systematic
26
- control over the transformation process while ensuring that generated modules achieve maximum
27
- performance through compile-time specialization and runtime optimization strategies.
28
- """
1
+ """Configuration by dataclass."""
29
2
 
30
3
  from ast import Module
31
4
  from astToolkit import identifierDotAttribute, parseLogicalPath2astModule
@@ -36,24 +9,21 @@ from mapFolding import (
36
9
  from mapFolding.someAssemblyRequired import dataclassInstanceIdentifierDEFAULT, ShatteredDataclass
37
10
  from mapFolding.someAssemblyRequired.transformationTools import shatter_dataclassesDOTdataclass
38
11
  from pathlib import Path, PurePosixPath
39
- from typing import TypeAlias
40
12
  import dataclasses
41
13
 
42
14
  @dataclasses.dataclass
43
- class RecipeJobTheorem2Numba:
44
- """Configuration recipe for generating Numba-optimized map folding computation jobs.
15
+ class RecipeJobTheorem2:
16
+ """Configuration recipe for generating map folding computation jobs.
45
17
 
46
18
  This dataclass serves as the central configuration hub for the code transformation
47
- pipeline that converts generic map folding algorithms into highly optimized,
19
+ assembly line that converts generic map folding algorithms into highly optimized,
48
20
  specialized computation modules. The recipe encapsulates all parameters required
49
21
  for source code analysis, target file generation, datatype mapping, and compilation
50
22
  optimization settings.
51
23
 
52
24
  The transformation process operates by extracting functions from source modules,
53
25
  embedding concrete parameter values, eliminating dead code paths, and generating
54
- standalone Python modules optimized for specific map dimensions. These generated
55
- modules achieve maximum performance through Numba just-in-time compilation and
56
- embedded compile-time constants.
26
+ standalone Python modules optimized for specific map dimensions.
57
27
 
58
28
  The recipe maintains both source configuration (where to find the generic algorithm)
59
29
  and target configuration (where to write the optimized module), along with the
@@ -61,84 +31,118 @@ class RecipeJobTheorem2Numba:
61
31
 
62
32
  Attributes
63
33
  ----------
64
- state: The map folding computation state containing dimensions and initial values.
65
- foldsTotalEstimated: Estimated total number of folds for progress tracking (0).
66
- shatteredDataclass: Deconstructed dataclass metadata for code transformation.
67
- source_astModule: Parsed AST of the source module containing the generic algorithm.
68
- sourceCountCallable: Name of the counting function to extract ('count').
69
- sourceLogicalPathModuleDataclass: Logical path to the dataclass module.
70
- sourceDataclassIdentifier: Name of the source dataclass ('MapFoldingState').
71
- sourceDataclassInstance: Instance identifier for the dataclass.
72
- sourcePathPackage: Path to the source package.
73
- sourcePackageIdentifier: Name of the source package.
74
- pathPackage: Override path for the target package (None).
75
- pathModule: Override path for the target module directory.
76
- fileExtension: File extension for generated modules.
77
- pathFilenameFoldsTotal: Path for writing fold count results.
78
- packageIdentifier: Target package identifier (None).
79
- logicalPathRoot: Logical path root corresponding to filesystem directory.
80
- moduleIdentifier: Target module identifier.
81
- countCallable: Name of the counting function in generated module.
82
- dataclassIdentifier: Target dataclass identifier.
83
- dataclassInstance: Target dataclass instance identifier.
84
- logicalPathModuleDataclass: Logical path to target dataclass module.
85
- DatatypeFoldsTotal: Type alias for fold count datatype.
86
- DatatypeElephino: Type alias for intermediate computation datatype.
87
- DatatypeLeavesTotal: Type alias for leaf count datatype.
34
+ state : MapFoldingState
35
+ The map folding computation state containing dimensions and initial values.
36
+ foldsTotalEstimated : int = 0
37
+ Estimated total number of folds for progress tracking.
38
+ shatteredDataclass : ShatteredDataclass = None
39
+ Deconstructed dataclass metadata for code transformation.
40
+ source_astModule : Module
41
+ Parsed AST of the source module containing the generic algorithm.
42
+ sourceCountCallable : str = 'count'
43
+ Name of the counting function to extract.
44
+ sourceLogicalPathModuleDataclass : identifierDotAttribute
45
+ Logical path to the dataclass module.
46
+ sourceDataclassIdentifier : str = 'MapFoldingState'
47
+ Name of the source dataclass.
48
+ sourceDataclassInstance : str
49
+ Instance identifier for the dataclass.
50
+ sourcePathPackage : PurePosixPath | None
51
+ Path to the source package.
52
+ sourcePackageIdentifier : str | None
53
+ Name of the source package.
54
+ pathPackage : PurePosixPath | None = None
55
+ Override path for the target package.
56
+ pathModule : PurePosixPath | None
57
+ Override path for the target module directory.
58
+ fileExtension : str
59
+ File extension for generated modules.
60
+ pathFilenameFoldsTotal : PurePosixPath = None
61
+ Path for writing fold count results.
62
+ packageIdentifier : str | None = None
63
+ Target package identifier.
64
+ logicalPathRoot : identifierDotAttribute | None = None
65
+ Logical path root; probably corresponds to physical filesystem directory.
66
+ moduleIdentifier : str = None
67
+ Target module identifier.
68
+ countCallable : str
69
+ Name of the counting function in generated module.
70
+ dataclassIdentifier : str | None
71
+ Target dataclass identifier.
72
+ dataclassInstance : str | None
73
+ Target dataclass instance identifier.
74
+ logicalPathModuleDataclass : identifierDotAttribute | None
75
+ Logical path to target dataclass module.
76
+ DatatypeFoldsTotal : TypeAlias
77
+ Type alias for fold count datatype.
78
+ DatatypeElephino : TypeAlias
79
+ Type alias for intermediate computation datatype.
80
+ DatatypeLeavesTotal : TypeAlias
81
+ Type alias for leaf count datatype.
88
82
  """
89
83
 
90
84
  state: MapFoldingState
91
- # TODO create function to calculate `foldsTotalEstimated`
85
+ """The map folding computation state containing dimensions and initial values."""
92
86
  foldsTotalEstimated: int = 0
87
+ """Estimated total number of folds for progress tracking."""
93
88
  shatteredDataclass: ShatteredDataclass = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType]
89
+ """Deconstructed dataclass metadata for code transformation."""
94
90
 
95
91
  # Source -----------------------------------------
96
92
  source_astModule: Module = parseLogicalPath2astModule('mapFolding.syntheticModules.theorem2Numba') # noqa: RUF009
93
+ """Parsed AST of the source module containing the generic algorithm."""
97
94
  sourceCountCallable: str = 'count'
95
+ """Name of the counting function to extract."""
98
96
 
99
97
  sourceLogicalPathModuleDataclass: identifierDotAttribute = 'mapFolding.dataBaskets'
98
+ """Logical path to the dataclass module."""
100
99
  sourceDataclassIdentifier: str = 'MapFoldingState'
100
+ """Name of the source dataclass."""
101
101
  sourceDataclassInstance: str = dataclassInstanceIdentifierDEFAULT
102
+ """Instance identifier for the dataclass."""
102
103
 
103
104
  sourcePathPackage: PurePosixPath | None = PurePosixPath(packageSettings.pathPackage) # noqa: RUF009
105
+ """Path to the source package."""
104
106
  sourcePackageIdentifier: str | None = packageSettings.identifierPackage
107
+ """Name of the source package."""
105
108
 
106
109
  # Filesystem, names of physical objects ------------------------------------------
107
110
  pathPackage: PurePosixPath | None = None
111
+ """Override path for the target package."""
108
112
  pathModule: PurePosixPath | None = PurePosixPath(getPathRootJobDEFAULT()) # noqa: RUF009
109
- """ `pathModule` will override `pathPackage` and `logicalPathRoot`."""
113
+ """Override path for the target module directory."""
110
114
  fileExtension: str = packageSettings.fileExtension
115
+ """File extension for generated modules."""
111
116
  pathFilenameFoldsTotal: PurePosixPath = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType]
117
+ """Path for writing fold count results."""
112
118
 
113
119
  # Logical identifiers, as opposed to physical identifiers ------------------------
114
120
  packageIdentifier: str | None = None
121
+ """Target package identifier."""
115
122
  logicalPathRoot: identifierDotAttribute | None = None
116
- """ `logicalPathRoot` likely corresponds to a physical filesystem directory."""
123
+ """Logical path root; probably corresponds to physical filesystem directory."""
117
124
  moduleIdentifier: str = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType]
125
+ """Target module identifier."""
118
126
  countCallable: str = sourceCountCallable
127
+ """Name of the counting function in generated module."""
119
128
  dataclassIdentifier: str | None = sourceDataclassIdentifier
129
+ """Target dataclass identifier."""
120
130
  dataclassInstance: str | None = sourceDataclassInstance
131
+ """Target dataclass instance identifier."""
121
132
  logicalPathModuleDataclass: identifierDotAttribute | None = sourceLogicalPathModuleDataclass
133
+ """Logical path to target dataclass module."""
122
134
 
123
135
  # Datatypes ------------------------------------------
124
- DatatypeFoldsTotal: TypeAlias = TheDatatypeFoldsTotal
125
- DatatypeElephino: TypeAlias = TheDatatypeElephino
126
- DatatypeLeavesTotal: TypeAlias = TheDatatypeLeavesTotal
127
-
128
- def _makePathFilename(self,
129
- pathRoot: PurePosixPath | None = None,
130
- logicalPathINFIX: identifierDotAttribute | None = None,
131
- filenameStem: str | None = None,
132
- fileExtension: str | None = None,
133
- ) -> PurePosixPath:
136
+ type DatatypeFoldsTotal = TheDatatypeFoldsTotal
137
+ """Type alias for datatype linked to the magnitude of `foldsTotal`."""
138
+ type DatatypeElephino = TheDatatypeElephino
139
+ """Type alias for intermediate computation datatype."""
140
+ type DatatypeLeavesTotal = TheDatatypeLeavesTotal
141
+ """Type alias for datatype linked to the magnitude of `leavesTotal`."""
142
+
143
+ def _makePathFilename(self, pathRoot: PurePosixPath | None = None, logicalPathINFIX: identifierDotAttribute | None = None, filenameStem: str | None = None, fileExtension: str | None = None) -> PurePosixPath:
134
144
  """Construct a complete file path from component parts.
135
145
 
136
- (AI generated docstring)
137
-
138
- This helper method builds filesystem paths by combining a root directory,
139
- optional subdirectory structure, filename stem, and file extension. It provides
140
- sensible defaults for missing components based on the recipe configuration.
141
-
142
146
  Parameters
143
147
  ----------
144
148
  pathRoot : PurePosixPath | None = None
@@ -172,8 +176,6 @@ class RecipeJobTheorem2Numba:
172
176
  def pathFilenameModule(self) -> PurePosixPath:
173
177
  """Generate the complete path and filename for the output module.
174
178
 
175
- (AI generated docstring)
176
-
177
179
  This property computes the target location where the generated computation
178
180
  module will be written. It respects the `pathModule` override if specified,
179
181
  otherwise constructs the path using the default package structure.
@@ -192,8 +194,6 @@ class RecipeJobTheorem2Numba:
192
194
  def __post_init__(self) -> None:
193
195
  """Initialize computed fields and validate configuration after dataclass creation.
194
196
 
195
- (AI generated docstring)
196
-
197
197
  This method performs post-initialization setup including deriving module
198
198
  identifier from map shape if not explicitly provided, setting default paths
199
199
  for fold total output files, and creating shattered dataclass metadata for
@@ -217,10 +217,10 @@ class DeReConstructField2ast:
217
217
  self.ast_keyword_field__field = Make.keyword(self.name, self.astName)
218
218
  self.ast_nameDOTname = Make.Attribute(Make.Name(dataclassesDOTdataclassInstanceIdentifier), self.name)
219
219
 
220
- self.astAnnotation = raiseIfNone(NodeTourist[ast.AnnAssign, ast.Name | None](
220
+ self.astAnnotation = cast('ast.Name', raiseIfNone(NodeTourist(
221
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))
222
+ , doThat = Then.extractIt(DOT.annotation)
223
+ ).captureLastMatch(dataclassClassDef)))
224
224
 
225
225
  self.ast_argAnnotated = Make.arg(self.name, self.astAnnotation)
226
226