mapFolding 0.12.3__tar.gz → 0.13.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. {mapfolding-0.12.3 → mapfolding-0.13.0}/PKG-INFO +18 -27
  2. {mapfolding-0.12.3 → mapfolding-0.13.0}/README.md +3 -19
  3. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/basecamp.py +6 -6
  4. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/dataBaskets.py +38 -51
  5. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/oeis.py +1 -1
  6. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/someAssemblyRequired/RecipeJob.py +78 -77
  7. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/someAssemblyRequired/makeAllModules.py +6 -9
  8. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +10 -35
  9. mapfolding-0.13.0/mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +256 -0
  10. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/someAssemblyRequired/toolkitNumba.py +1 -1
  11. {mapfolding-0.12.3 → mapfolding-0.13.0/mapFolding}/tests/__init__.py +2 -2
  12. {mapfolding-0.12.3 → mapfolding-0.13.0/mapFolding}/tests/conftest.py +232 -63
  13. {mapfolding-0.12.3 → mapfolding-0.13.0/mapFolding}/tests/test_computations.py +36 -14
  14. {mapfolding-0.12.3 → mapfolding-0.13.0/mapFolding}/tests/test_filesystem.py +10 -13
  15. {mapfolding-0.12.3 → mapfolding-0.13.0/mapFolding}/tests/test_oeis.py +5 -19
  16. {mapfolding-0.12.3 → mapfolding-0.13.0/mapFolding}/tests/test_other.py +6 -6
  17. {mapfolding-0.12.3 → mapfolding-0.13.0/mapFolding}/tests/test_tasks.py +5 -5
  18. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding.egg-info/PKG-INFO +18 -27
  19. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding.egg-info/SOURCES.txt +8 -7
  20. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding.egg-info/requires.txt +7 -4
  21. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding.egg-info/top_level.txt +0 -1
  22. {mapfolding-0.12.3 → mapfolding-0.13.0}/pyproject.toml +17 -10
  23. {mapfolding-0.12.3 → mapfolding-0.13.0}/LICENSE +0 -0
  24. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/__init__.py +0 -0
  25. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/_theSSOT.py +0 -0
  26. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/_theTypes.py +0 -0
  27. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/beDRY.py +0 -0
  28. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/daoOfMapFolding.py +0 -0
  29. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/filesystemToolkit.py +0 -0
  30. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/py.typed +0 -0
  31. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/reference/__init__.py +0 -0
  32. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/reference/flattened.py +0 -0
  33. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/reference/hunterNumba.py +0 -0
  34. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/reference/irvineJavaPort.py +0 -0
  35. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/reference/jaxCount.py +0 -0
  36. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/reference/jobsCompleted/[2x19]/p2x19.py +0 -0
  37. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/reference/jobsCompleted/__init__.py +0 -0
  38. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/reference/jobsCompleted/p2x19/p2x19.py +0 -0
  39. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/reference/lunnonNumpy.py +0 -0
  40. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/reference/lunnonWhile.py +0 -0
  41. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/reference/rotatedEntryPoint.py +0 -0
  42. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
  43. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/someAssemblyRequired/__init__.py +0 -0
  44. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/someAssemblyRequired/_toolIfThis.py +0 -0
  45. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/someAssemblyRequired/_toolkitContainers.py +0 -0
  46. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/someAssemblyRequired/getLLVMforNoReason.py +0 -0
  47. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/someAssemblyRequired/infoBooth.py +0 -0
  48. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/someAssemblyRequired/transformationTools.py +0 -0
  49. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/syntheticModules/__init__.py +0 -0
  50. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/syntheticModules/countParallel.py +0 -0
  51. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/syntheticModules/daoOfMapFolding.py +0 -0
  52. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/syntheticModules/dataPacking.py +0 -0
  53. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/syntheticModules/initializeCount.py +0 -0
  54. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/syntheticModules/theorem2.py +0 -0
  55. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/syntheticModules/theorem2Numba.py +0 -0
  56. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding/syntheticModules/theorem2Trimmed.py +0 -0
  57. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding.egg-info/dependency_links.txt +0 -0
  58. {mapfolding-0.12.3 → mapfolding-0.13.0}/mapFolding.egg-info/entry_points.txt +0 -0
  59. {mapfolding-0.12.3 → mapfolding-0.13.0}/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.0
4
4
  Summary: Map folding algorithm with code transformation framework for optimizing numerical computations.
5
5
  Author-email: Hunter Hogan <HunterHogan@pm.me>
6
6
  License: CC-BY-NC-4.0
@@ -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
@@ -40,20 +13,18 @@ from typing import TypeAlias
40
13
  import dataclasses
41
14
 
42
15
  @dataclasses.dataclass
43
- class RecipeJobTheorem2Numba:
44
- """Configuration recipe for generating Numba-optimized map folding computation jobs.
16
+ class RecipeJobTheorem2:
17
+ """Configuration recipe for generating map folding computation jobs.
45
18
 
46
19
  This dataclass serves as the central configuration hub for the code transformation
47
- pipeline that converts generic map folding algorithms into highly optimized,
20
+ assembly line that converts generic map folding algorithms into highly optimized,
48
21
  specialized computation modules. The recipe encapsulates all parameters required
49
22
  for source code analysis, target file generation, datatype mapping, and compilation
50
23
  optimization settings.
51
24
 
52
25
  The transformation process operates by extracting functions from source modules,
53
26
  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.
27
+ standalone Python modules optimized for specific map dimensions.
57
28
 
58
29
  The recipe maintains both source configuration (where to find the generic algorithm)
59
30
  and target configuration (where to write the optimized module), along with the
@@ -61,84 +32,118 @@ class RecipeJobTheorem2Numba:
61
32
 
62
33
  Attributes
63
34
  ----------
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.
35
+ state : MapFoldingState
36
+ The map folding computation state containing dimensions and initial values.
37
+ foldsTotalEstimated : int = 0
38
+ Estimated total number of folds for progress tracking.
39
+ shatteredDataclass : ShatteredDataclass = None
40
+ Deconstructed dataclass metadata for code transformation.
41
+ source_astModule : Module
42
+ Parsed AST of the source module containing the generic algorithm.
43
+ sourceCountCallable : str = 'count'
44
+ Name of the counting function to extract.
45
+ sourceLogicalPathModuleDataclass : identifierDotAttribute
46
+ Logical path to the dataclass module.
47
+ sourceDataclassIdentifier : str = 'MapFoldingState'
48
+ Name of the source dataclass.
49
+ sourceDataclassInstance : str
50
+ Instance identifier for the dataclass.
51
+ sourcePathPackage : PurePosixPath | None
52
+ Path to the source package.
53
+ sourcePackageIdentifier : str | None
54
+ Name of the source package.
55
+ pathPackage : PurePosixPath | None = None
56
+ Override path for the target package.
57
+ pathModule : PurePosixPath | None
58
+ Override path for the target module directory.
59
+ fileExtension : str
60
+ File extension for generated modules.
61
+ pathFilenameFoldsTotal : PurePosixPath = None
62
+ Path for writing fold count results.
63
+ packageIdentifier : str | None = None
64
+ Target package identifier.
65
+ logicalPathRoot : identifierDotAttribute | None = None
66
+ Logical path root; probably corresponds to physical filesystem directory.
67
+ moduleIdentifier : str = None
68
+ Target module identifier.
69
+ countCallable : str
70
+ Name of the counting function in generated module.
71
+ dataclassIdentifier : str | None
72
+ Target dataclass identifier.
73
+ dataclassInstance : str | None
74
+ Target dataclass instance identifier.
75
+ logicalPathModuleDataclass : identifierDotAttribute | None
76
+ Logical path to target dataclass module.
77
+ DatatypeFoldsTotal : TypeAlias
78
+ Type alias for fold count datatype.
79
+ DatatypeElephino : TypeAlias
80
+ Type alias for intermediate computation datatype.
81
+ DatatypeLeavesTotal : TypeAlias
82
+ Type alias for leaf count datatype.
88
83
  """
89
84
 
90
85
  state: MapFoldingState
91
- # TODO create function to calculate `foldsTotalEstimated`
86
+ """The map folding computation state containing dimensions and initial values."""
92
87
  foldsTotalEstimated: int = 0
88
+ """Estimated total number of folds for progress tracking."""
93
89
  shatteredDataclass: ShatteredDataclass = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType]
90
+ """Deconstructed dataclass metadata for code transformation."""
94
91
 
95
92
  # Source -----------------------------------------
96
93
  source_astModule: Module = parseLogicalPath2astModule('mapFolding.syntheticModules.theorem2Numba') # noqa: RUF009
94
+ """Parsed AST of the source module containing the generic algorithm."""
97
95
  sourceCountCallable: str = 'count'
96
+ """Name of the counting function to extract."""
98
97
 
99
98
  sourceLogicalPathModuleDataclass: identifierDotAttribute = 'mapFolding.dataBaskets'
99
+ """Logical path to the dataclass module."""
100
100
  sourceDataclassIdentifier: str = 'MapFoldingState'
101
+ """Name of the source dataclass."""
101
102
  sourceDataclassInstance: str = dataclassInstanceIdentifierDEFAULT
103
+ """Instance identifier for the dataclass."""
102
104
 
103
105
  sourcePathPackage: PurePosixPath | None = PurePosixPath(packageSettings.pathPackage) # noqa: RUF009
106
+ """Path to the source package."""
104
107
  sourcePackageIdentifier: str | None = packageSettings.identifierPackage
108
+ """Name of the source package."""
105
109
 
106
110
  # Filesystem, names of physical objects ------------------------------------------
107
111
  pathPackage: PurePosixPath | None = None
112
+ """Override path for the target package."""
108
113
  pathModule: PurePosixPath | None = PurePosixPath(getPathRootJobDEFAULT()) # noqa: RUF009
109
- """ `pathModule` will override `pathPackage` and `logicalPathRoot`."""
114
+ """Override path for the target module directory."""
110
115
  fileExtension: str = packageSettings.fileExtension
116
+ """File extension for generated modules."""
111
117
  pathFilenameFoldsTotal: PurePosixPath = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType]
118
+ """Path for writing fold count results."""
112
119
 
113
120
  # Logical identifiers, as opposed to physical identifiers ------------------------
114
121
  packageIdentifier: str | None = None
122
+ """Target package identifier."""
115
123
  logicalPathRoot: identifierDotAttribute | None = None
116
- """ `logicalPathRoot` likely corresponds to a physical filesystem directory."""
124
+ """Logical path root; probably corresponds to physical filesystem directory."""
117
125
  moduleIdentifier: str = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType]
126
+ """Target module identifier."""
118
127
  countCallable: str = sourceCountCallable
128
+ """Name of the counting function in generated module."""
119
129
  dataclassIdentifier: str | None = sourceDataclassIdentifier
130
+ """Target dataclass identifier."""
120
131
  dataclassInstance: str | None = sourceDataclassInstance
132
+ """Target dataclass instance identifier."""
121
133
  logicalPathModuleDataclass: identifierDotAttribute | None = sourceLogicalPathModuleDataclass
134
+ """Logical path to target dataclass module."""
122
135
 
123
136
  # Datatypes ------------------------------------------
124
137
  DatatypeFoldsTotal: TypeAlias = TheDatatypeFoldsTotal
138
+ """Type alias for datatype linked to the magnitude of `foldsTotal`."""
125
139
  DatatypeElephino: TypeAlias = TheDatatypeElephino
140
+ """Type alias for intermediate computation datatype."""
126
141
  DatatypeLeavesTotal: TypeAlias = TheDatatypeLeavesTotal
142
+ """Type alias for datatype linked to the magnitude of `leavesTotal`."""
127
143
 
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:
144
+ def _makePathFilename(self, pathRoot: PurePosixPath | None = None, logicalPathINFIX: identifierDotAttribute | None = None, filenameStem: str | None = None, fileExtension: str | None = None) -> PurePosixPath:
134
145
  """Construct a complete file path from component parts.
135
146
 
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
147
  Parameters
143
148
  ----------
144
149
  pathRoot : PurePosixPath | None = None
@@ -172,8 +177,6 @@ class RecipeJobTheorem2Numba:
172
177
  def pathFilenameModule(self) -> PurePosixPath:
173
178
  """Generate the complete path and filename for the output module.
174
179
 
175
- (AI generated docstring)
176
-
177
180
  This property computes the target location where the generated computation
178
181
  module will be written. It respects the `pathModule` override if specified,
179
182
  otherwise constructs the path using the default package structure.
@@ -192,8 +195,6 @@ class RecipeJobTheorem2Numba:
192
195
  def __post_init__(self) -> None:
193
196
  """Initialize computed fields and validate configuration after dataclass creation.
194
197
 
195
- (AI generated docstring)
196
-
197
198
  This method performs post-initialization setup including deriving module
198
199
  identifier from map shape if not explicitly provided, setting default paths
199
200
  for fold total output files, and creating shattered dataclass metadata for
@@ -329,7 +329,7 @@ def makeDaoOfMapFoldingParallel(astModule: ast.Module, moduleIdentifier: str, ca
329
329
 
330
330
  The generated module contains multiple functions including core counting function with parallel-aware task filtering,
331
331
  dataclass unpacking/repacking function for process communication, and main dispatcher function that manages the parallel
332
- execution pipeline.
332
+ execution assembly line.
333
333
 
334
334
  Parameters
335
335
  ----------
@@ -591,15 +591,12 @@ def trimTheorem2(astModule: ast.Module, moduleIdentifier: str, callableIdentifie
591
591
 
592
592
  (AI generated docstring)
593
593
 
594
- Creates a trimmed version of the Theorem 2 implementation by eliminating
595
- conditional logic that is not needed under specific constraint assumptions.
596
- This transformation removes checks for unconstrained dimensions, simplifying
597
- the algorithm for cases where dimensional constraints are guaranteed to be
598
- satisfied by external conditions.
594
+ Creates a trimmed version of the Theorem 2 implementation by eliminating conditional logic that is not needed under specific
595
+ constraint assumptions. This transformation removes checks for unconstrained dimensions, simplifying the algorithm for cases
596
+ where dimensional constraints are guaranteed to be satisfied by external conditions.
599
597
 
600
- The trimming operation is particularly valuable for generating lean implementations
601
- where the calling context ensures that certain conditions will always be met,
602
- allowing the removal of defensive programming constructs that add computational
598
+ The trimming operation is particularly valuable for generating lean implementations where the calling context ensures that
599
+ certain conditions will always be met, allowing the removal of defensive programming constructs that add computational
603
600
  overhead without providing benefits in the constrained environment.
604
601
 
605
602
  Parameters