mapFolding 0.11.1__py3-none-any.whl → 0.11.3__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 (35) hide show
  1. mapFolding/__init__.py +7 -60
  2. mapFolding/basecamp.py +15 -13
  3. mapFolding/beDRY.py +4 -36
  4. mapFolding/dataBaskets.py +24 -2
  5. mapFolding/datatypes.py +0 -3
  6. mapFolding/{toolboxFilesystem.py → filesystemToolkit.py} +3 -3
  7. mapFolding/oeis.py +3 -5
  8. mapFolding/someAssemblyRequired/RecipeJob.py +8 -116
  9. mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py +492 -0
  10. mapFolding/someAssemblyRequired/__init__.py +5 -31
  11. mapFolding/someAssemblyRequired/_toolIfThis.py +5 -6
  12. mapFolding/someAssemblyRequired/{_toolboxContainers.py → _toolkitContainers.py} +6 -127
  13. mapFolding/someAssemblyRequired/infoBooth.py +70 -0
  14. mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +13 -12
  15. mapFolding/someAssemblyRequired/{toolboxNumba.py → toolkitNumba.py} +2 -44
  16. mapFolding/someAssemblyRequired/transformationTools.py +16 -174
  17. mapFolding/syntheticModules/countParallel.py +98 -0
  18. mapFolding/syntheticModules/dataPacking.py +1 -1
  19. mapFolding/theSSOT.py +12 -246
  20. {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/METADATA +16 -11
  21. mapfolding-0.11.3.dist-info/RECORD +53 -0
  22. {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/WHEEL +1 -1
  23. tests/conftest.py +2 -79
  24. tests/test_computations.py +12 -19
  25. tests/test_filesystem.py +1 -2
  26. tests/test_other.py +1 -1
  27. tests/test_tasks.py +3 -4
  28. mapFolding/someAssemblyRequired/Z0Z_makeSomeModules.py +0 -325
  29. mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +0 -314
  30. mapFolding/syntheticModules/numbaCount.py +0 -201
  31. mapFolding/theDao.py +0 -243
  32. mapfolding-0.11.1.dist-info/RECORD +0 -54
  33. {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/entry_points.txt +0 -0
  34. {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/licenses/LICENSE +0 -0
  35. {mapfolding-0.11.1.dist-info → mapfolding-0.11.3.dist-info}/top_level.txt +0 -0
mapFolding/theDao.py DELETED
@@ -1,243 +0,0 @@
1
- """
2
- Core computational algorithm for map folding counting and enumeration.
3
-
4
- This module implements the core algorithms for enumerating and counting the various ways a rectangular map can be
5
- folded. It uses a functional state-transformation approach, where each function performs a specific state mutation and
6
- returns the updated state. The module provides three main counting algorithms:
7
-
8
- 1. `countInitialize`: Sets up the initial state for computation.
9
- 2. `countSequential`: Processes the folding computation sequentially.
10
- 3. `countParallel`: Distributes the computation across multiple processes.
11
-
12
- All algorithms operate on a `ComputationState` object that tracks the folding process, including:
13
- - A "leaf" is a unit square in the map.
14
- - A "gap" is a potential position where a new leaf can be folded.
15
- - Connections track how leaves can connect above/below each other.
16
- - Leaves are enumerated starting from 1, not 0; hence, `leaf1ndex` not `leafIndex`.
17
-
18
- The `doTheNeedful` function is the main entry point that orchestrates the computation strategy based on task divisions and
19
- concurrency parameters.
20
- """
21
- from concurrent.futures import Future as ConcurrentFuture, ProcessPoolExecutor
22
- from copy import deepcopy
23
- from mapFolding.theSSOT import ComputationState
24
- from multiprocessing import set_start_method as multiprocessing_set_start_method
25
-
26
- # When to use multiprocessing.set_start_method https://github.com/hunterhogan/mapFolding/issues/6
27
- if __name__ == '__main__':
28
- multiprocessing_set_start_method('spawn')
29
-
30
- def activeLeafConnectedToItself(state: ComputationState) -> bool:
31
- return state.leafConnectee == state.leaf1ndex
32
-
33
- def activeLeafGreaterThan0(state: ComputationState) -> bool:
34
- return state.leaf1ndex > 0
35
-
36
- def activeLeafGreaterThanLeavesTotal(state: ComputationState) -> bool:
37
- return state.leaf1ndex > state.leavesTotal
38
-
39
- def activeLeafIsTheFirstLeaf(state: ComputationState) -> bool:
40
- return state.leaf1ndex <= 1
41
-
42
- def allDimensionsAreUnconstrained(state: ComputationState) -> bool:
43
- return not state.dimensionsUnconstrained
44
-
45
- def countGaps(state: ComputationState) -> ComputationState:
46
- state.gapsWhere[state.gap1ndexCeiling] = state.leafConnectee
47
- if state.countDimensionsGapped[state.leafConnectee] == 0:
48
- state = incrementGap1ndexCeiling(state)
49
- state.countDimensionsGapped[state.leafConnectee] += 1
50
- return state
51
-
52
- def decrementDimensionsUnconstrained(state: ComputationState) -> ComputationState:
53
- state.dimensionsUnconstrained -= 1
54
- return state
55
-
56
- def dimensionsUnconstrainedCondition(state: ComputationState) -> bool:
57
- return state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leaf1ndex] == state.leaf1ndex
58
-
59
- def filterCommonGaps(state: ComputationState) -> ComputationState:
60
- state.gapsWhere[state.gap1ndex] = state.gapsWhere[state.indexMiniGap]
61
- if state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] == state.dimensionsUnconstrained:
62
- state = incrementActiveGap(state)
63
- state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] = 0
64
- return state
65
-
66
- def incrementActiveGap(state: ComputationState) -> ComputationState:
67
- state.gap1ndex += 1
68
- return state
69
-
70
- def incrementGap1ndexCeiling(state: ComputationState) -> ComputationState:
71
- state.gap1ndexCeiling += 1
72
- return state
73
-
74
- def incrementIndexDimension(state: ComputationState) -> ComputationState:
75
- state.indexDimension += 1
76
- return state
77
-
78
- def incrementIndexMiniGap(state: ComputationState) -> ComputationState:
79
- state.indexMiniGap += 1
80
- return state
81
-
82
- def initializeIndexMiniGap(state: ComputationState) -> ComputationState:
83
- state.indexMiniGap = state.gap1ndex
84
- return state
85
-
86
- def initializeLeafConnectee(state: ComputationState) -> ComputationState:
87
- state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leaf1ndex]
88
- return state
89
-
90
- def initializeVariablesToFindGaps(state: ComputationState) -> ComputationState:
91
- state.dimensionsUnconstrained = state.dimensionsTotal
92
- state.gap1ndexCeiling = state.gapRangeStart[state.leaf1ndex - 1]
93
- state.indexDimension = 0
94
- return state
95
-
96
- def insertLeafAtGap(state: ComputationState) -> ComputationState:
97
- state.gap1ndex -= 1
98
- state.leafAbove[state.leaf1ndex] = state.gapsWhere[state.gap1ndex]
99
- state.leafBelow[state.leaf1ndex] = state.leafBelow[state.leafAbove[state.leaf1ndex]]
100
- state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leaf1ndex
101
- state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leaf1ndex
102
- state.gapRangeStart[state.leaf1ndex] = state.gap1ndex
103
- state.leaf1ndex += 1
104
- return state
105
-
106
- def insertUnconstrainedLeaf(state: ComputationState) -> ComputationState:
107
- state.indexLeaf = 0
108
- while state.indexLeaf < state.leaf1ndex:
109
- state.gapsWhere[state.gap1ndexCeiling] = state.indexLeaf
110
- state.gap1ndexCeiling += 1
111
- state.indexLeaf += 1
112
- return state
113
-
114
- def leafBelowSentinelIs1(state: ComputationState) -> bool:
115
- return state.leafBelow[0] == 1
116
-
117
- def loopingLeavesConnectedToActiveLeaf(state: ComputationState) -> bool:
118
- return state.leafConnectee != state.leaf1ndex
119
-
120
- def loopingToActiveGapCeiling(state: ComputationState) -> bool:
121
- return state.indexMiniGap < state.gap1ndexCeiling
122
-
123
- def loopUpToDimensionsTotal(state: ComputationState) -> bool:
124
- return state.indexDimension < state.dimensionsTotal
125
-
126
- def noGapsHere(state: ComputationState) -> bool:
127
- return (state.leaf1ndex > 0) and (state.gap1ndex == state.gapRangeStart[state.leaf1ndex - 1])
128
-
129
- def thereIsAnActiveLeaf(state: ComputationState) -> bool:
130
- return state.leaf1ndex > 0
131
-
132
- def thisIsMyTaskIndex(state: ComputationState) -> bool:
133
- return (state.leaf1ndex != state.taskDivisions) or (state.leafConnectee % state.taskDivisions == state.taskIndex)
134
-
135
- def undoLastLeafPlacement(state: ComputationState) -> ComputationState:
136
- state.leaf1ndex -= 1
137
- state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leafBelow[state.leaf1ndex]
138
- state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leafAbove[state.leaf1ndex]
139
- return state
140
-
141
- def updateLeafConnectee(state: ComputationState) -> ComputationState:
142
- state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leafBelow[state.leafConnectee]]
143
- return state
144
-
145
- def countInitialize(state: ComputationState) -> ComputationState:
146
- while state.gap1ndex == 0:
147
- if activeLeafIsTheFirstLeaf(state) or leafBelowSentinelIs1(state):
148
- state = initializeVariablesToFindGaps(state)
149
- while loopUpToDimensionsTotal(state):
150
- state = initializeLeafConnectee(state)
151
- if activeLeafConnectedToItself(state):
152
- state = decrementDimensionsUnconstrained(state)
153
- else:
154
- while loopingLeavesConnectedToActiveLeaf(state):
155
- state = countGaps(state)
156
- state = updateLeafConnectee(state)
157
- state = incrementIndexDimension(state)
158
- if allDimensionsAreUnconstrained(state):
159
- state = insertUnconstrainedLeaf(state)
160
- state = initializeIndexMiniGap(state)
161
- while loopingToActiveGapCeiling(state):
162
- state = filterCommonGaps(state)
163
- state = incrementIndexMiniGap(state)
164
- if thereIsAnActiveLeaf(state):
165
- state = insertLeafAtGap(state)
166
- return state
167
-
168
- def countParallel(state: ComputationState) -> ComputationState:
169
- while activeLeafGreaterThan0(state):
170
- if activeLeafIsTheFirstLeaf(state) or leafBelowSentinelIs1(state):
171
- if activeLeafGreaterThanLeavesTotal(state):
172
- state.groupsOfFolds += 1
173
- else:
174
- state = initializeVariablesToFindGaps(state)
175
- while loopUpToDimensionsTotal(state):
176
- if dimensionsUnconstrainedCondition(state):
177
- state = decrementDimensionsUnconstrained(state)
178
- else:
179
- state = initializeLeafConnectee(state)
180
- while loopingLeavesConnectedToActiveLeaf(state):
181
- if thisIsMyTaskIndex(state):
182
- state = countGaps(state)
183
- state = updateLeafConnectee(state)
184
- state = incrementIndexDimension(state)
185
- state = initializeIndexMiniGap(state)
186
- while loopingToActiveGapCeiling(state):
187
- state = filterCommonGaps(state)
188
- state = incrementIndexMiniGap(state)
189
- while noGapsHere(state):
190
- state = undoLastLeafPlacement(state)
191
- if thereIsAnActiveLeaf(state):
192
- state = insertLeafAtGap(state)
193
- state.foldGroups[state.taskIndex] = state.groupsOfFolds
194
- return state
195
-
196
- def countSequential(state: ComputationState) -> ComputationState:
197
- while activeLeafGreaterThan0(state):
198
- if activeLeafIsTheFirstLeaf(state) or leafBelowSentinelIs1(state):
199
- if activeLeafGreaterThanLeavesTotal(state):
200
- state.groupsOfFolds += 1
201
- else:
202
- state = initializeVariablesToFindGaps(state)
203
- while loopUpToDimensionsTotal(state):
204
- state = initializeLeafConnectee(state)
205
- if activeLeafConnectedToItself(state):
206
- state = decrementDimensionsUnconstrained(state)
207
- else:
208
- while loopingLeavesConnectedToActiveLeaf(state):
209
- state = countGaps(state)
210
- state = updateLeafConnectee(state)
211
- state = incrementIndexDimension(state)
212
- state = initializeIndexMiniGap(state)
213
- while loopingToActiveGapCeiling(state):
214
- state = filterCommonGaps(state)
215
- state = incrementIndexMiniGap(state)
216
- while noGapsHere(state):
217
- state = undoLastLeafPlacement(state)
218
- if state.leaf1ndex == 3 and state.groupsOfFolds:
219
- state.groupsOfFolds *= 2
220
- # print('break')
221
- break
222
- if thereIsAnActiveLeaf(state):
223
- state = insertLeafAtGap(state)
224
- state.foldGroups[state.taskIndex] = state.groupsOfFolds
225
- return state
226
-
227
- def doTheNeedful(state: ComputationState) -> ComputationState:
228
- state = countInitialize(state)
229
- if state.taskDivisions > 0:
230
- dictionaryConcurrency: dict[int, ConcurrentFuture[ComputationState]] = {}
231
- stateParallel = deepcopy(state)
232
- with ProcessPoolExecutor(stateParallel.concurrencyLimit) as concurrencyManager:
233
- for indexSherpa in range(stateParallel.taskDivisions):
234
- state = deepcopy(stateParallel)
235
- state.taskIndex = indexSherpa
236
- dictionaryConcurrency[indexSherpa] = concurrencyManager.submit(countParallel, state)
237
- for indexSherpa in range(stateParallel.taskDivisions):
238
- stateParallel.foldGroups[indexSherpa] = dictionaryConcurrency[indexSherpa].result().foldGroups[indexSherpa]
239
- state = stateParallel
240
- else:
241
- state = countSequential(state)
242
-
243
- return state
@@ -1,54 +0,0 @@
1
- mapFolding/__init__.py,sha256=P2guQYFN19PSAl8yd9NQjIapMvZnZlasPOvKJ1KUGvA,4883
2
- mapFolding/basecamp.py,sha256=hs7hlTmbX7KTjI_eIRVU4xn7HR4l448SIpHk1cKDwRk,8071
3
- mapFolding/beDRY.py,sha256=JQ7T9v4aKzweGjvpzyghyq4N9l3Wf9HZco_K_DWoiW0,15368
4
- mapFolding/daoOfMapFolding.py,sha256=ncTIiBfTsM8SNVx9qefZ0bBcBtviWLSk4iPv3Z9nGiE,5442
5
- mapFolding/dataBaskets.py,sha256=80ALoRqaOfNEgz8QTdDJPsyVBnm8MkWLtRHD3DPPoRw,5073
6
- mapFolding/datatypes.py,sha256=-TdXqAlEWEwUP_VUb9-X5pvaBBedbZOQbBuu5j1ZoTA,962
7
- mapFolding/oeis.py,sha256=zHk5Mygd7qpDj1NYXsvY_l3e8jg3tHDQ1Cpt6NrWiuc,17019
8
- mapFolding/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- mapFolding/theDao.py,sha256=kc3rzTX3yts0PxgPCXFbgWvaqsBexsiU5ib2pzpvID0,10019
10
- mapFolding/theSSOT.py,sha256=rbv8esQeBG6uLWpFZu_ncMA4zIuQG3lj4FZNzC_6JGI,16138
11
- mapFolding/toolboxFilesystem.py,sha256=kVZoU-NBvfYSvI4R8mEpMXRUZee-1JV0fjtMFWPhk8Y,9818
12
- mapFolding/reference/__init__.py,sha256=GKcSgYE49NcTISx-JZbELXyq-eRkMeTL5g4DXInWFw0,2206
13
- mapFolding/reference/flattened.py,sha256=QK1xG9SllqCoi68e86Hyl9d9ATUAAFNpTQI-3zmcp5I,16072
14
- mapFolding/reference/hunterNumba.py,sha256=iLfyqwGdAh6c5GbapnKsWhAsNsR3O-fyGGHAdohluLw,7258
15
- mapFolding/reference/irvineJavaPort.py,sha256=UEfIX4QbPLl5jnyfYIyX5YRR3_rYvPUikK8jLehsFko,4076
16
- mapFolding/reference/jaxCount.py,sha256=TuDNKOnyhQfuixKmIxO9Algv7dvy7KMGhgsV3h96FGE,14853
17
- mapFolding/reference/lunnonNumpy.py,sha256=mMgrgbrBpe4nmo72ThEI-MGH0OwEHmfMPczSXHp2qKo,4357
18
- mapFolding/reference/lunnonWhile.py,sha256=ZL8GAQtPs5nJZSgoDl5USrLSS_zs03y98y1Z9E4jOmQ,3799
19
- mapFolding/reference/rotatedEntryPoint.py,sha256=5ughpKUT2JQhoAKgoDUdYNjgWQYPGV8v-7dWEAdDmfE,10274
20
- mapFolding/reference/total_countPlus1vsPlusN.py,sha256=yJZAVLVdoXqHag2_N6_6CT-Q6HXBgRro-eny93-Rlpw,9307
21
- mapFolding/reference/jobsCompleted/__init__.py,sha256=TU93ZGUW1xEkT6d9mQFn_rp5DvRy0ZslEB2Q6MF5ZDc,2596
22
- mapFolding/reference/jobsCompleted/[2x19]/p2x19.py,sha256=_tvYtfzMWVo2VtUbIAieoscb4N8FFflgTdW4-ljBUuA,19626
23
- mapFolding/reference/jobsCompleted/p2x19/p2x19.py,sha256=eZEw4Me4ocTt6VXoK2-Sbd5SowZtxRIbN9dZmc7OCVg,6395
24
- mapFolding/someAssemblyRequired/RecipeJob.py,sha256=6RD4F4Yde7K-Rz0F4IokQ62BVzRSx4vCCYY4H-Dfug4,10190
25
- mapFolding/someAssemblyRequired/Z0Z_makeSomeModules.py,sha256=Ss9YlFAAodsydiYWz9TrcTneeYn_IUR2iQfEPjFf3IY,15805
26
- mapFolding/someAssemblyRequired/__init__.py,sha256=p2mbSsdEefBu0Hnwuis91cnSr0i49ZV9_bhfncGLxls,3571
27
- mapFolding/someAssemblyRequired/_toolIfThis.py,sha256=Ey6byfbpzRmgrnuOVIA9M068Lo7S1Jk6wzNgBMPci3A,3140
28
- mapFolding/someAssemblyRequired/_toolboxContainers.py,sha256=DZDFfCcRsCY0wFlkoZ9l8Ozw7bsT5OA3qMcG2KnABGI,16003
29
- mapFolding/someAssemblyRequired/getLLVMforNoReason.py,sha256=9RPU6vK_eUg64GtVFI_nZnvUryXw8gfHJs9NyDYHIvg,2745
30
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py,sha256=zZFfHhNG0VWaCigeHID-eAWQBRbYmo_59JycdstxJTc,13784
31
- mapFolding/someAssemblyRequired/synthesizeNumbaJob.py,sha256=4ZwOQA4FWrILYe5eiawTZgeTiJ7RRUUCpI0Th5Mezso,15668
32
- mapFolding/someAssemblyRequired/toolboxNumba.py,sha256=LZdosArlkNzFUwy8BMhswivW5xfhREAPyx2ApNOuse8,8961
33
- mapFolding/someAssemblyRequired/transformationTools.py,sha256=o4gORDvDuTnTPofeDLwfZItW5MFJljNcHagVprJeBU4,18966
34
- mapFolding/syntheticModules/__init__.py,sha256=evVFqhCGa-WZKDiLcnQWjs-Bj34eRnfSLqz_d7dFYZY,83
35
- mapFolding/syntheticModules/daoOfMapFolding.py,sha256=cfWPABtXyCxJ0BwPI7rhfLh_2UYV_XKAL8lJ4GLNXaQ,5896
36
- mapFolding/syntheticModules/dataPacking.py,sha256=J4WLJzQTOAm2d8itzWWSixTUcCGQl4KuEfqrzkb2tJQ,2294
37
- mapFolding/syntheticModules/initializeCount.py,sha256=nWSlJMMfIM3DvZxMn6ISQusUJqRYAjKQyLF5hwLEdBQ,3119
38
- mapFolding/syntheticModules/numbaCount.py,sha256=zM-bp07c9tEDdvidwzZ_bJTd0JC0VUkYEEiHG--P1tQ,15525
39
- mapFolding/syntheticModules/theorem2.py,sha256=9jrbZNNX4BWYZW1S0JjvRY2k7RU7I1RNUMV7JdCt1ZY,3017
40
- mapFolding/syntheticModules/theorem2Numba.py,sha256=-cKjNyxgUMFhEyFVs0VJ7hw4LfrV0WSNK5tPYbQ1oNU,3369
41
- mapFolding/syntheticModules/theorem2Trimmed.py,sha256=DHW3NxBdtABQYBKm2WRvfQ5kzc2_UwGI2h4ePuYEJoM,2685
42
- mapfolding-0.11.1.dist-info/licenses/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
43
- tests/__init__.py,sha256=5VhHf0JJ2_DSh58zJ0rR5UkpoCon-0IkdljspTCzZ04,1950
44
- tests/conftest.py,sha256=x8zMZQyTss3sn0GwHm_TSRwD9_LVlR8l_qF8r43Vxl4,14178
45
- tests/test_computations.py,sha256=5sg1PpSp6aeOrXZeO5NwWK5ipPAe49wVKC2J7yT5MFg,6524
46
- tests/test_filesystem.py,sha256=T2DkjBoI3lW6tCxd5BilPmUFrVukNKLjOOZVZxLM560,3004
47
- tests/test_oeis.py,sha256=uxvwmgbnylSDdsVJfuAT0LuYLbIVFwSgdLxHm-xUGBM,5043
48
- tests/test_other.py,sha256=UMlK4JPInalpOZuPvTnUrgXWCJOxAw-OsPs6CxMR254,3753
49
- tests/test_tasks.py,sha256=tOQc4uomKXGwWnENfbcThaVa1XofwXNCkGZbg4yS6VI,2833
50
- mapfolding-0.11.1.dist-info/METADATA,sha256=z1Z2MfDiXFSxbortwiHbjCex9X3zD9RvC7qWYs4l50g,7560
51
- mapfolding-0.11.1.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
52
- mapfolding-0.11.1.dist-info/entry_points.txt,sha256=F3OUeZR1XDTpoH7k3wXuRb3KF_kXTTeYhu5AGK1SiOQ,146
53
- mapfolding-0.11.1.dist-info/top_level.txt,sha256=1gP2vFaqPwHujGwb3UjtMlLEGN-943VSYFR7V4gDqW8,17
54
- mapfolding-0.11.1.dist-info/RECORD,,