mapFolding 0.4.3__py3-none-any.whl → 0.5.1__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 (41) hide show
  1. mapFolding/__init__.py +93 -58
  2. mapFolding/basecamp.py +9 -11
  3. mapFolding/beDRY.py +24 -23
  4. mapFolding/oeis.py +47 -45
  5. mapFolding/theDao.py +48 -48
  6. mapFolding/theSSOT.py +22 -20
  7. mapFolding/theSSOTdatatypes.py +20 -32
  8. {mapFolding-0.4.3.dist-info → mapFolding-0.5.1.dist-info}/METADATA +3 -1
  9. mapFolding-0.5.1.dist-info/RECORD +14 -0
  10. {mapFolding-0.4.3.dist-info → mapFolding-0.5.1.dist-info}/top_level.txt +0 -1
  11. mapFolding/reference/flattened.py +0 -377
  12. mapFolding/reference/hunterNumba.py +0 -132
  13. mapFolding/reference/irvineJavaPort.py +0 -120
  14. mapFolding/reference/jax.py +0 -208
  15. mapFolding/reference/lunnan.py +0 -153
  16. mapFolding/reference/lunnanNumpy.py +0 -123
  17. mapFolding/reference/lunnanWhile.py +0 -121
  18. mapFolding/reference/rotatedEntryPoint.py +0 -240
  19. mapFolding/reference/total_countPlus1vsPlusN.py +0 -211
  20. mapFolding/someAssemblyRequired/__init__.py +0 -5
  21. mapFolding/someAssemblyRequired/getLLVMforNoReason.py +0 -19
  22. mapFolding/someAssemblyRequired/makeJob.py +0 -55
  23. mapFolding/someAssemblyRequired/synthesizeModuleJAX.py +0 -29
  24. mapFolding/someAssemblyRequired/synthesizeNumba.py +0 -340
  25. mapFolding/someAssemblyRequired/synthesizeNumbaGeneralized.py +0 -396
  26. mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +0 -162
  27. mapFolding/someAssemblyRequired/synthesizeNumbaModules.py +0 -129
  28. mapFolding/syntheticModules/numbaCount.py +0 -158
  29. mapFolding/syntheticModules/numba_doTheNeedful.py +0 -13
  30. mapFolding-0.4.3.dist-info/RECORD +0 -40
  31. tests/__init__.py +0 -1
  32. tests/conftest.py +0 -306
  33. tests/test_computations.py +0 -43
  34. tests/test_oeis.py +0 -129
  35. tests/test_other.py +0 -171
  36. tests/test_tasks.py +0 -40
  37. tests/test_types.py +0 -5
  38. /mapFolding/{syntheticModules/__init__.py → py.typed} +0 -0
  39. {mapFolding-0.4.3.dist-info → mapFolding-0.5.1.dist-info}/LICENSE +0 -0
  40. {mapFolding-0.4.3.dist-info → mapFolding-0.5.1.dist-info}/WHEEL +0 -0
  41. {mapFolding-0.4.3.dist-info → mapFolding-0.5.1.dist-info}/entry_points.txt +0 -0
@@ -1,158 +0,0 @@
1
- from mapFolding import indexMy, indexTrack
2
- from numba import jit, int64, prange, uint16
3
- from numpy import ndarray, dtype, integer
4
- from typing import Tuple, Any
5
-
6
- @jit((uint16[:, :, ::1], uint16[::1], uint16[::1], uint16[:, ::1]), _nrt=True, boundscheck=False, cache=True, error_model='numpy', fastmath=True, forceinline=True, inline='always', looplift=False, no_cfunc_wrapper=False, no_cpython_wrapper=False, nopython=True, parallel=False)
7
- def countInitialize(connectionGraph: ndarray[Tuple[int, int, int], dtype[integer[Any]]], gapsWhere: ndarray[Tuple[int], dtype[integer[Any]]], my: ndarray[Tuple[int], dtype[integer[Any]]], track: ndarray[Tuple[int, int], dtype[integer[Any]]]) -> None:
8
- while my[indexMy.leaf1ndex.value] > 0:
9
- if my[indexMy.leaf1ndex.value] <= 1 or track[indexTrack.leafBelow.value, 0] == 1:
10
- my[indexMy.dimensionsUnconstrained.value] = my[indexMy.dimensionsTotal.value]
11
- my[indexMy.gap1ndexCeiling.value] = track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
12
- my[indexMy.indexDimension.value] = 0
13
- while my[indexMy.indexDimension.value] < my[indexMy.dimensionsTotal.value]:
14
- if connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]] == my[indexMy.leaf1ndex.value]:
15
- my[indexMy.dimensionsUnconstrained.value] -= 1
16
- else:
17
- my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]]
18
- while my[indexMy.leafConnectee.value] != my[indexMy.leaf1ndex.value]:
19
- gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.leafConnectee.value]
20
- if track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] == 0:
21
- my[indexMy.gap1ndexCeiling.value] += 1
22
- track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] += 1
23
- my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], track[indexTrack.leafBelow.value, my[indexMy.leafConnectee.value]]]
24
- my[indexMy.indexDimension.value] += 1
25
- if not my[indexMy.dimensionsUnconstrained.value]:
26
- my[indexMy.indexLeaf.value] = 0
27
- while my[indexMy.indexLeaf.value] < my[indexMy.leaf1ndex.value]:
28
- gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.indexLeaf.value]
29
- my[indexMy.gap1ndexCeiling.value] += 1
30
- my[indexMy.indexLeaf.value] += 1
31
- my[indexMy.indexMiniGap.value] = my[indexMy.gap1ndex.value]
32
- while my[indexMy.indexMiniGap.value] < my[indexMy.gap1ndexCeiling.value]:
33
- gapsWhere[my[indexMy.gap1ndex.value]] = gapsWhere[my[indexMy.indexMiniGap.value]]
34
- if track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] == my[indexMy.dimensionsUnconstrained.value]:
35
- my[indexMy.gap1ndex.value] += 1
36
- track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] = 0
37
- my[indexMy.indexMiniGap.value] += 1
38
- if my[indexMy.leaf1ndex.value] > 0:
39
- my[indexMy.gap1ndex.value] -= 1
40
- track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]] = gapsWhere[my[indexMy.gap1ndex.value]]
41
- track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]] = track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]]
42
- track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
43
- track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
44
- track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value]] = my[indexMy.gap1ndex.value]
45
- my[indexMy.leaf1ndex.value] += 1
46
- if my[indexMy.gap1ndex.value] > 0:
47
- return
48
-
49
- @jit((uint16[:, :, ::1], int64[::1], uint16[::1], uint16[::1], uint16[:, ::1]), _nrt=True, boundscheck=False, cache=True, error_model='numpy', fastmath=True, forceinline=True, inline='always', looplift=False, no_cfunc_wrapper=True, no_cpython_wrapper=True, nopython=True, parallel=True)
50
- def countParallel(connectionGraph: ndarray[Tuple[int, int, int], dtype[integer[Any]]], foldGroups: ndarray[Tuple[int], dtype[integer[Any]]], gapsWhere: ndarray[Tuple[int], dtype[integer[Any]]], my: ndarray[Tuple[int], dtype[integer[Any]]], track: ndarray[Tuple[int, int], dtype[integer[Any]]]) -> None:
51
- gapsWherePARALLEL = gapsWhere.copy()
52
- myPARALLEL = my.copy()
53
- trackPARALLEL = track.copy()
54
- taskDivisionsPrange = myPARALLEL[indexMy.taskDivisions.value]
55
- for indexSherpa in prange(taskDivisionsPrange):
56
- groupsOfFolds: int = 0
57
- gapsWhere = gapsWherePARALLEL.copy()
58
- my = myPARALLEL.copy()
59
- track = trackPARALLEL.copy()
60
- my[indexMy.taskIndex.value] = indexSherpa
61
- while my[indexMy.leaf1ndex.value] > 0:
62
- if my[indexMy.leaf1ndex.value] <= 1 or track[indexTrack.leafBelow.value, 0] == 1:
63
- if my[indexMy.leaf1ndex.value] > foldGroups[-1]:
64
- groupsOfFolds += 1
65
- else:
66
- my[indexMy.dimensionsUnconstrained.value] = my[indexMy.dimensionsTotal.value]
67
- my[indexMy.gap1ndexCeiling.value] = track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
68
- my[indexMy.indexDimension.value] = 0
69
- while my[indexMy.indexDimension.value] < my[indexMy.dimensionsTotal.value]:
70
- if connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]] == my[indexMy.leaf1ndex.value]:
71
- my[indexMy.dimensionsUnconstrained.value] -= 1
72
- else:
73
- my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]]
74
- while my[indexMy.leafConnectee.value] != my[indexMy.leaf1ndex.value]:
75
- if my[indexMy.leaf1ndex.value] != my[indexMy.taskDivisions.value] or my[indexMy.leafConnectee.value] % my[indexMy.taskDivisions.value] == my[indexMy.taskIndex.value]:
76
- gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.leafConnectee.value]
77
- if track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] == 0:
78
- my[indexMy.gap1ndexCeiling.value] += 1
79
- track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] += 1
80
- my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], track[indexTrack.leafBelow.value, my[indexMy.leafConnectee.value]]]
81
- my[indexMy.indexDimension.value] += 1
82
- my[indexMy.indexMiniGap.value] = my[indexMy.gap1ndex.value]
83
- while my[indexMy.indexMiniGap.value] < my[indexMy.gap1ndexCeiling.value]:
84
- gapsWhere[my[indexMy.gap1ndex.value]] = gapsWhere[my[indexMy.indexMiniGap.value]]
85
- if track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] == my[indexMy.dimensionsUnconstrained.value]:
86
- my[indexMy.gap1ndex.value] += 1
87
- track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] = 0
88
- my[indexMy.indexMiniGap.value] += 1
89
- while my[indexMy.leaf1ndex.value] > 0 and my[indexMy.gap1ndex.value] == track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]:
90
- my[indexMy.leaf1ndex.value] -= 1
91
- track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]
92
- track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]
93
- if my[indexMy.leaf1ndex.value] > 0:
94
- my[indexMy.gap1ndex.value] -= 1
95
- track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]] = gapsWhere[my[indexMy.gap1ndex.value]]
96
- track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]] = track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]]
97
- track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
98
- track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
99
- track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value]] = my[indexMy.gap1ndex.value]
100
- my[indexMy.leaf1ndex.value] += 1
101
- foldGroups[my[indexMy.taskIndex.value]] = groupsOfFolds
102
-
103
- @jit((uint16[:, :, ::1], int64[::1], uint16[::1], uint16[::1], uint16[:, ::1]), _nrt=True, boundscheck=False, cache=True, error_model='numpy', fastmath=True, forceinline=True, inline='always', looplift=False, no_cfunc_wrapper=True, no_cpython_wrapper=True, nopython=True, parallel=False)
104
- def countSequential(connectionGraph: ndarray[Tuple[int, int, int], dtype[integer[Any]]], foldGroups: ndarray[Tuple[int], dtype[integer[Any]]], gapsWhere: ndarray[Tuple[int], dtype[integer[Any]]], my: ndarray[Tuple[int], dtype[integer[Any]]], track: ndarray[Tuple[int, int], dtype[integer[Any]]]) -> None:
105
- leafBelow = track[indexTrack.leafBelow.value]
106
- gapRangeStart = track[indexTrack.gapRangeStart.value]
107
- countDimensionsGapped = track[indexTrack.countDimensionsGapped.value]
108
- leafAbove = track[indexTrack.leafAbove.value]
109
- leaf1ndex = my[indexMy.leaf1ndex.value]
110
- dimensionsUnconstrained = my[indexMy.dimensionsUnconstrained.value]
111
- dimensionsTotal = my[indexMy.dimensionsTotal.value]
112
- gap1ndexCeiling = my[indexMy.gap1ndexCeiling.value]
113
- indexDimension = my[indexMy.indexDimension.value]
114
- leafConnectee = my[indexMy.leafConnectee.value]
115
- indexMiniGap = my[indexMy.indexMiniGap.value]
116
- gap1ndex = my[indexMy.gap1ndex.value]
117
- taskIndex = my[indexMy.taskIndex.value]
118
- groupsOfFolds: int = 0
119
- while leaf1ndex > 0:
120
- if leaf1ndex <= 1 or leafBelow[0] == 1:
121
- if leaf1ndex > foldGroups[-1]:
122
- groupsOfFolds += 1
123
- else:
124
- dimensionsUnconstrained = dimensionsTotal
125
- gap1ndexCeiling = gapRangeStart[leaf1ndex - 1]
126
- indexDimension = 0
127
- while indexDimension < dimensionsTotal:
128
- leafConnectee = connectionGraph[indexDimension, leaf1ndex, leaf1ndex]
129
- if leafConnectee == leaf1ndex:
130
- dimensionsUnconstrained -= 1
131
- else:
132
- while leafConnectee != leaf1ndex:
133
- gapsWhere[gap1ndexCeiling] = leafConnectee
134
- if countDimensionsGapped[leafConnectee] == 0:
135
- gap1ndexCeiling += 1
136
- countDimensionsGapped[leafConnectee] += 1
137
- leafConnectee = connectionGraph[indexDimension, leaf1ndex, leafBelow[leafConnectee]]
138
- indexDimension += 1
139
- indexMiniGap = gap1ndex
140
- while indexMiniGap < gap1ndexCeiling:
141
- gapsWhere[gap1ndex] = gapsWhere[indexMiniGap]
142
- if countDimensionsGapped[gapsWhere[indexMiniGap]] == dimensionsUnconstrained:
143
- gap1ndex += 1
144
- countDimensionsGapped[gapsWhere[indexMiniGap]] = 0
145
- indexMiniGap += 1
146
- while leaf1ndex > 0 and gap1ndex == gapRangeStart[leaf1ndex - 1]:
147
- leaf1ndex -= 1
148
- leafBelow[leafAbove[leaf1ndex]] = leafBelow[leaf1ndex]
149
- leafAbove[leafBelow[leaf1ndex]] = leafAbove[leaf1ndex]
150
- if leaf1ndex > 0:
151
- gap1ndex -= 1
152
- leafAbove[leaf1ndex] = gapsWhere[gap1ndex]
153
- leafBelow[leaf1ndex] = leafBelow[leafAbove[leaf1ndex]]
154
- leafBelow[leafAbove[leaf1ndex]] = leaf1ndex
155
- leafAbove[leafBelow[leaf1ndex]] = leaf1ndex
156
- gapRangeStart[leaf1ndex] = gap1ndex
157
- leaf1ndex += 1
158
- foldGroups[taskIndex] = groupsOfFolds
@@ -1,13 +0,0 @@
1
- from mapFolding import indexMy
2
- from mapFolding.syntheticModules.numbaCount import countParallel, countSequential, countInitialize
3
- from numba import jit, int64, uint16
4
- from numpy import ndarray, dtype, integer
5
- from typing import Tuple, Any
6
-
7
- @jit((uint16[:, :, ::1], int64[::1], uint16[::1], uint16[::1], uint16[::1], uint16[:, ::1]), _nrt=True, boundscheck=False, cache=True, error_model='numpy', fastmath=True, forceinline=True, inline='always', looplift=False, no_cfunc_wrapper=False, no_cpython_wrapper=False, nopython=True, parallel=False)
8
- def doTheNeedful(connectionGraph: ndarray[Tuple[int, int, int], dtype[integer[Any]]], foldGroups: ndarray[Tuple[int], dtype[integer[Any]]], gapsWhere: ndarray[Tuple[int], dtype[integer[Any]]], mapShape: ndarray[Tuple[int], dtype[integer[Any]]], my: ndarray[Tuple[int], dtype[integer[Any]]], track: ndarray[Tuple[int, int], dtype[integer[Any]]]) -> None:
9
- countInitialize(connectionGraph, gapsWhere, my, track)
10
- if my[indexMy.taskDivisions.value] > 0:
11
- countParallel(connectionGraph, foldGroups, gapsWhere, my, track)
12
- else:
13
- countSequential(connectionGraph, foldGroups, gapsWhere, my, track)
@@ -1,40 +0,0 @@
1
- mapFolding/__init__.py,sha256=1-iO5PCGKlW81fhMDjSLrsKxuSeV-UMcU1NlKW352FM,1347
2
- mapFolding/basecamp.py,sha256=MyrkAbJZawW6CPVEJ_7iPfCYjngdFHmicSs8Ylq5S1E,3787
3
- mapFolding/beDRY.py,sha256=tDLddJzQoGvbcttJro8ML2B59KspMkZwIeZdm4hOy_4,16785
4
- mapFolding/oeis.py,sha256=8c6q3STjgp-c4Reode9PLLYS3c00wCsJW-yfte7NI60,11103
5
- mapFolding/theDao.py,sha256=PZgx_0X7QfdIpLpEO5mbdVNFMCRuP8PD-f62xU7C4U0,12618
6
- mapFolding/theSSOT.py,sha256=RQmSsjmysc9izjGLsVseZ0J0nDzG_rKY7QkrOF-47SU,5794
7
- mapFolding/theSSOTdatatypes.py,sha256=H0d1vAn59VCRPMhn28PtlBEZnjmQjEKofiefgvpBFsg,5955
8
- mapFolding/reference/flattened.py,sha256=S6D9wiFTlbeoetEqaMLOcA-R22BHOzjqPRujffNxxUM,14875
9
- mapFolding/reference/hunterNumba.py,sha256=jDS0ORHkIhcJ1rzA5hT49sZHKf3rgJOoGesUCcbKFFY,6054
10
- mapFolding/reference/irvineJavaPort.py,sha256=7GvBU0tnS6wpFgkYad3465do9jBQW-2bYvbCYyABPHM,3341
11
- mapFolding/reference/jax.py,sha256=7ji9YWia6Kof0cjcNdiS1GG1rMbC5SBjcyVr_07AeUk,13845
12
- mapFolding/reference/lunnan.py,sha256=iAbJELfW6RKNMdPcBY9b6rGQ-z1zoRf-1XCurCRMOo8,3951
13
- mapFolding/reference/lunnanNumpy.py,sha256=rwVP3WIDXimpAuaxhRIuBYU56nVDTKlfGiclw_FkgUU,3765
14
- mapFolding/reference/lunnanWhile.py,sha256=uRrMT23jTJvoQDlD_FzeIQe_pfMXJG6_bRvs7uhC8z0,3271
15
- mapFolding/reference/rotatedEntryPoint.py,sha256=USZY3n3zwhSE68ATscUuN66t1qShuEbMI790Gz9JFTw,9352
16
- mapFolding/reference/total_countPlus1vsPlusN.py,sha256=wpgay-uqPOBd64Z4Pg6tg40j7-4pzWHGMM6v0bnmjhE,6288
17
- mapFolding/someAssemblyRequired/__init__.py,sha256=wtec_hIz-AKz0_hGdXsWnCKTcCxdMV9-WK6SiIriAeU,396
18
- mapFolding/someAssemblyRequired/getLLVMforNoReason.py,sha256=nX8tghZClYt7zJd6RpZBXhE_h-CGRHOS17biqiEdf-o,855
19
- mapFolding/someAssemblyRequired/makeJob.py,sha256=c9sTRUK90snTCcXCvs86VKBH6z_nt3OVFjNs_WgCoIg,2422
20
- mapFolding/someAssemblyRequired/synthesizeModuleJAX.py,sha256=jatvtYhK5ZJK-YmCKATt7w3icFXXO79cZDAYVrU9bgA,1258
21
- mapFolding/someAssemblyRequired/synthesizeNumba.py,sha256=eJRZ8ttfaONMq-s3BawswJrHu_m0DUHp4dGpx6uVpuk,16920
22
- mapFolding/someAssemblyRequired/synthesizeNumbaGeneralized.py,sha256=3FiD6fDGzam6uvgTg7YEsGlLftbBOol2ajvEa4GNTec,16698
23
- mapFolding/someAssemblyRequired/synthesizeNumbaJob.py,sha256=pknX6CeH9iuDTs9tp0gz33T2U5gjO8NMpPnQnnBU2gA,9138
24
- mapFolding/someAssemblyRequired/synthesizeNumbaModules.py,sha256=V9xpM1r4MQlhXoKLkF2PTg69gid7Ec64pbMc2ZZ2xXo,5590
25
- mapFolding/syntheticModules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- mapFolding/syntheticModules/numbaCount.py,sha256=VkTHk97gIBRZg7FwX7hCgfunSBK2Gyr4pp3fzHNrLhw,12907
27
- mapFolding/syntheticModules/numba_doTheNeedful.py,sha256=9syuZEc1KwH3BFp2TmK7-pBuT2N4lVJTiUhqu7ahaKY,1157
28
- tests/__init__.py,sha256=eg9smg-6VblOr0kisM40CpGnuDtU2JgEEWGDTFVOlW8,57
29
- tests/conftest.py,sha256=qP-ZCyyqXC4E9W_psMVbHPlXE-8Ue01fBckGqhzlhGQ,11972
30
- tests/test_computations.py,sha256=WO28l9AmrFY6kbcx9iJr6YNoqLbZ8Lgs7FryH5DG0BI,2856
31
- tests/test_oeis.py,sha256=C2F6XrI5oRPjc29lykN3e83rIcgl01UwBLB6L-Qz2pE,4733
32
- tests/test_other.py,sha256=u0vINT5EyVsXTNTR2DZIMpWCg4FH471jjHLRzC2JX7U,8351
33
- tests/test_tasks.py,sha256=iq6_dh43JQkC2vAWXua0Xe915BKFGbvRJAkmbco854A,2389
34
- tests/test_types.py,sha256=58tmPG9WOeGGAQbdQK_h_7t4SnENnZugH4WXlI8-L-M,171
35
- mapFolding-0.4.3.dist-info/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
36
- mapFolding-0.4.3.dist-info/METADATA,sha256=52v3PWTTXMbJwXFaUQFAnJilfn29HFiESW83sPFUL1M,7633
37
- mapFolding-0.4.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
38
- mapFolding-0.4.3.dist-info/entry_points.txt,sha256=F3OUeZR1XDTpoH7k3wXuRb3KF_kXTTeYhu5AGK1SiOQ,146
39
- mapFolding-0.4.3.dist-info/top_level.txt,sha256=1gP2vFaqPwHujGwb3UjtMlLEGN-943VSYFR7V4gDqW8,17
40
- mapFolding-0.4.3.dist-info/RECORD,,
tests/__init__.py DELETED
@@ -1 +0,0 @@
1
- from tests.conftest import makeDictionaryFoldsTotalKnown
tests/conftest.py DELETED
@@ -1,306 +0,0 @@
1
- """SSOT for Pytest"""
2
-
3
- # TODO learn how to run tests and coverage analysis without `env = ["NUMBA_DISABLE_JIT=1"]`
4
-
5
- from mapFolding import *
6
- from mapFolding import basecamp, getAlgorithmDispatcher, getDispatcherCallable
7
- from mapFolding.beDRY import *
8
- from mapFolding.someAssemblyRequired import *
9
- from mapFolding.oeis import *
10
- from types import ModuleType
11
- from typing import Any, Callable, ContextManager, Dict, Generator, List, Literal, NoReturn, Optional, Sequence, Set, Tuple, Type, Union
12
- from Z0Z_tools.pytestForYourUse import PytestFor_defineConcurrencyLimit, PytestFor_intInnit, PytestFor_oopsieKwargsie
13
- import importlib.util
14
- import pathlib
15
- import pytest
16
- import random
17
- import shutil
18
- import unittest.mock
19
- import uuid
20
-
21
- # SSOT for test data paths and filenames
22
- pathDataSamples = pathlib.Path("tests/dataSamples")
23
- # NOTE `tmp` is not a diminutive form of temporary: it signals a technical term. And "temp" is strongly disfavored.
24
- pathTmpRoot = pathDataSamples / "tmp"
25
-
26
- # The registrar maintains the register of temp files
27
- registerOfTemporaryFilesystemObjects: Set[pathlib.Path] = set()
28
-
29
- def registrarRecordsTmpObject(path: pathlib.Path) -> None:
30
- """The registrar adds a tmp file to the register."""
31
- registerOfTemporaryFilesystemObjects.add(path)
32
-
33
- def registrarDeletesTmpObjects() -> None:
34
- """The registrar cleans up tmp files in the register."""
35
- for pathTmp in sorted(registerOfTemporaryFilesystemObjects, reverse=True):
36
- try:
37
- if pathTmp.is_file():
38
- pathTmp.unlink(missing_ok=True)
39
- elif pathTmp.is_dir():
40
- shutil.rmtree(pathTmp, ignore_errors=True)
41
- except Exception as ERRORmessage:
42
- print(f"Warning: Failed to clean up {pathTmp}: {ERRORmessage}")
43
- registerOfTemporaryFilesystemObjects.clear()
44
-
45
- @pytest.fixture(scope="session", autouse=True)
46
- def setupTeardownTmpObjects() -> Generator[None, None, None]:
47
- """Auto-fixture to setup test data directories and cleanup after."""
48
- pathDataSamples.mkdir(exist_ok=True)
49
- pathTmpRoot.mkdir(exist_ok=True)
50
- yield
51
- registrarDeletesTmpObjects()
52
-
53
- @pytest.fixture
54
- def pathTmpTesting(request: pytest.FixtureRequest) -> pathlib.Path:
55
- # "Z0Z_" ensures the directory name does not start with a number, which would make it an invalid Python identifier
56
- pathTmp = pathTmpRoot / ("Z0Z_" + str(uuid.uuid4().hex))
57
- pathTmp.mkdir(parents=True, exist_ok=False)
58
-
59
- registrarRecordsTmpObject(pathTmp)
60
- return pathTmp
61
-
62
- @pytest.fixture
63
- def pathFilenameTmpTesting(request: pytest.FixtureRequest) -> pathlib.Path:
64
- try:
65
- extension = request.param
66
- except AttributeError:
67
- extension = ".txt"
68
-
69
- # "Z0Z_" ensures the name does not start with a number, which would make it an invalid Python identifier
70
- uuidHex = uuid.uuid4().hex
71
- subpath = "Z0Z_" + uuidHex[0:-8]
72
- filenameStem = "Z0Z_" + uuidHex[-8:None]
73
-
74
- pathFilenameTmp = pathlib.Path(pathTmpRoot, subpath, filenameStem + extension)
75
- pathFilenameTmp.parent.mkdir(parents=True, exist_ok=False)
76
-
77
- registrarRecordsTmpObject(pathFilenameTmp)
78
- return pathFilenameTmp
79
-
80
- @pytest.fixture
81
- def pathCacheTesting(pathTmpTesting: pathlib.Path) -> Generator[pathlib.Path, Any, None]:
82
- """Temporarily replace the OEIS cache directory with a test directory."""
83
- from mapFolding import oeis as there_must_be_a_better_way
84
- pathCacheOriginal = there_must_be_a_better_way._pathCache
85
- there_must_be_a_better_way._pathCache = pathTmpTesting
86
- yield pathTmpTesting
87
- there_must_be_a_better_way._pathCache = pathCacheOriginal
88
-
89
- @pytest.fixture
90
- def pathFilenameFoldsTotalTesting(pathTmpTesting: pathlib.Path) -> pathlib.Path:
91
- return pathTmpTesting.joinpath("foldsTotalTest.txt")
92
-
93
- def makeDictionaryFoldsTotalKnown() -> Dict[Tuple[int,...], int]:
94
- """Returns a dictionary mapping dimension tuples to their known folding totals."""
95
- dictionaryMapDimensionsToFoldsTotalKnown: Dict[Tuple[int, ...], int] = {}
96
-
97
- for settings in settingsOEIS.values():
98
- sequence = settings['valuesKnown']
99
-
100
- for n, foldingsTotal in sequence.items():
101
- dimensions = settings['getMapShape'](n)
102
- dimensions.sort()
103
- dictionaryMapDimensionsToFoldsTotalKnown[tuple(dimensions)] = foldingsTotal
104
- return dictionaryMapDimensionsToFoldsTotalKnown
105
-
106
- """
107
- Section: Fixtures"""
108
-
109
- @pytest.fixture(autouse=True)
110
- def setupWarningsAsErrors() -> Generator[None, Any, None]:
111
- """Convert all warnings to errors for all tests."""
112
- import warnings
113
- warnings.filterwarnings("error")
114
- yield
115
- warnings.resetwarnings()
116
-
117
- @pytest.fixture
118
- def foldsTotalKnown() -> Dict[Tuple[int,...], int]:
119
- """Returns a dictionary mapping dimension tuples to their known folding totals.
120
- NOTE I am not convinced this is the best way to do this.
121
- Advantage: I call `makeDictionaryFoldsTotalKnown()` from modules other than test modules.
122
- Preference: I _think_ I would prefer a SSOT function available to any module
123
- similar to `foldsTotalKnown = getFoldsTotalKnown(listDimensions)`."""
124
- return makeDictionaryFoldsTotalKnown()
125
-
126
- @pytest.fixture
127
- def listDimensionsTestCountFolds(oeisID: str) -> List[int]:
128
- """For each `oeisID` from the `pytest.fixture`, returns `listDimensions` from `valuesTestValidation`
129
- if `validateListDimensions` approves. Each `listDimensions` is suitable for testing counts."""
130
- while True:
131
- n = random.choice(settingsOEIS[oeisID]['valuesTestValidation'])
132
- if n < 2:
133
- continue
134
- listDimensionsCandidate = settingsOEIS[oeisID]['getMapShape'](n)
135
-
136
- try:
137
- return validateListDimensions(listDimensionsCandidate)
138
- except (ValueError, NotImplementedError):
139
- pass
140
-
141
- @pytest.fixture
142
- def listDimensionsTestFunctionality(oeisID_1random: str) -> List[int]:
143
- """To test functionality, get one `listDimensions` from `valuesTestValidation` if
144
- `validateListDimensions` approves. The algorithm can count the folds of the returned
145
- `listDimensions` in a short enough time suitable for testing."""
146
- while True:
147
- n = random.choice(settingsOEIS[oeisID_1random]['valuesTestValidation'])
148
- if n < 2:
149
- continue
150
- listDimensionsCandidate = settingsOEIS[oeisID_1random]['getMapShape'](n)
151
-
152
- try:
153
- return validateListDimensions(listDimensionsCandidate)
154
- except (ValueError, NotImplementedError):
155
- pass
156
-
157
- @pytest.fixture
158
- def listDimensionsTestParallelization(oeisID: str) -> List[int]:
159
- """For each `oeisID` from the `pytest.fixture`, returns `listDimensions` from `valuesTestParallelization`"""
160
- n = random.choice(settingsOEIS[oeisID]['valuesTestParallelization'])
161
- return settingsOEIS[oeisID]['getMapShape'](n)
162
-
163
- @pytest.fixture
164
- def mockBenchmarkTimer() -> Generator[unittest.mock.MagicMock | unittest.mock.AsyncMock, Any, None]:
165
- """Mock time.perf_counter_ns for consistent benchmark timing."""
166
- with unittest.mock.patch('time.perf_counter_ns') as mockTimer:
167
- mockTimer.side_effect = [0, 1e9] # Start and end times for 1 second
168
- yield mockTimer
169
-
170
- @pytest.fixture
171
- def mockFoldingFunction() -> Callable[..., Callable[..., None]]:
172
- """Creates a mock function that simulates _countFolds behavior."""
173
- def make_mock(foldsValue: int, listDimensions: List[int]) -> Callable[..., None]:
174
- mock_array = makeDataContainer(2)
175
- mock_array[0] = foldsValue
176
- mock_array[-1] = getLeavesTotal(listDimensions)
177
-
178
- def mock_countFolds(**keywordArguments: Any) -> None:
179
- keywordArguments['foldGroups'][:] = mock_array
180
- return None
181
-
182
- return mock_countFolds
183
- return make_mock
184
-
185
- @pytest.fixture
186
- def mockDispatcher() -> Callable[[Any], ContextManager[Any]]:
187
- """Context manager for mocking dispatcher callable."""
188
- def wrapper(mockFunction: Any) -> ContextManager[Any]:
189
- dispatcherCallable = getDispatcherCallable()
190
- return unittest.mock.patch(
191
- f"{dispatcherCallable.__module__}.{dispatcherCallable.__name__}",
192
- side_effect=mockFunction
193
- )
194
- return wrapper
195
-
196
- @pytest.fixture(params=oeisIDsImplemented)
197
- def oeisID(request: pytest.FixtureRequest) -> Any:
198
- return request.param
199
-
200
- @pytest.fixture
201
- def oeisID_1random() -> str:
202
- """Return one random valid OEIS ID."""
203
- return random.choice(oeisIDsImplemented)
204
-
205
- @pytest.fixture
206
- def useThisDispatcher():
207
- """A fixture providing a context manager for temporarily replacing the dispatcher.
208
-
209
- Returns
210
- A context manager for patching the dispatcher
211
- """
212
- dispatcherOriginal = basecamp.getDispatcherCallable
213
-
214
- def patchDispatcher(callableTarget: Callable) -> None:
215
- def callableParameterized(*arguments: Any, **keywordArguments: Any) -> Callable:
216
- return callableTarget
217
- basecamp.getDispatcherCallable = callableParameterized
218
-
219
- yield patchDispatcher
220
- basecamp.getDispatcherCallable = dispatcherOriginal
221
-
222
- @pytest.fixture
223
- def useAlgorithmSourceDispatcher(useThisDispatcher: Callable) -> Generator[None, None, None]:
224
- """Temporarily patches getDispatcherCallable to return the algorithm dispatcher."""
225
- useThisDispatcher(getAlgorithmDispatcher())
226
- yield
227
-
228
- @pytest.fixture
229
- def syntheticDispatcherFixture(useThisDispatcher):
230
- listCallablesInlineHARDCODED: List[str] = ['countInitialize', 'countParallel', 'countSequential']
231
- listCallablesInline = listCallablesInlineHARDCODED
232
- callableDispatcher = True
233
- algorithmSource = None
234
- relativePathWrite = None
235
- filenameModuleWrite = 'pytestCount.py'
236
- formatFilenameWrite = "pytest_{callableTarget}.py"
237
- listSynthesizedModules: List[youOughtaKnow] = makeFlowNumbaOptimized(listCallablesInline, callableDispatcher, algorithmSource, relativePathWrite, filenameModuleWrite, formatFilenameWrite)
238
- dispatcherSynthetic = youOughtaKnow('','','')
239
- for stuff in listSynthesizedModules:
240
- registrarRecordsTmpObject(stuff.pathFilenameForMe)
241
- if stuff.callableSynthesized not in listCallablesInline:
242
- dispatcherSynthetic: youOughtaKnow = stuff
243
-
244
- dispatcherSpec = importlib.util.spec_from_file_location(dispatcherSynthetic.callableSynthesized, dispatcherSynthetic.pathFilenameForMe)
245
- if dispatcherSpec is None:
246
- raise ImportError(f"{dispatcherSynthetic.pathFilenameForMe=}")
247
- if dispatcherSpec.loader is None:
248
- raise ImportError(f"Failed to get loader for module {dispatcherSynthetic.pathFilenameForMe}")
249
-
250
- dispatcherModule = importlib.util.module_from_spec(dispatcherSpec)
251
- dispatcherSpec.loader.exec_module(dispatcherModule)
252
- callableDispatcherSynthetic = getattr(dispatcherModule, dispatcherSynthetic.callableSynthesized)
253
-
254
- useThisDispatcher(callableDispatcherSynthetic)
255
- return callableDispatcherSynthetic
256
-
257
- def uniformTestMessage(expected: Any, actual: Any, functionName: str, *arguments: Any) -> str:
258
- """Format assertion message for any test comparison."""
259
- return (f"\nTesting: `{functionName}({', '.join(str(parameter) for parameter in arguments)})`\n"
260
- f"Expected: {expected}\n"
261
- f"Got: {actual}")
262
-
263
- def standardizedEqualTo(expected: Any, functionTarget: Callable, *arguments: Any) -> None:
264
- """Template for tests expecting an error."""
265
- if type(expected) is Type[Exception]:
266
- messageExpected = expected.__name__
267
- else:
268
- messageExpected = expected
269
-
270
- try:
271
- messageActual = actual = functionTarget(*arguments)
272
- except Exception as actualError:
273
- messageActual = type(actualError).__name__
274
- actual = type(actualError)
275
-
276
- assert actual == expected, uniformTestMessage(messageExpected, messageActual, functionTarget.__name__, *arguments)
277
-
278
- def standardizedSystemExit(expected: Union[str, int, Sequence[int]], functionTarget: Callable, *arguments: Any) -> None:
279
- """Template for tests expecting SystemExit.
280
-
281
- Parameters
282
- expected: Exit code expectation:
283
- - "error": any non-zero exit code
284
- - "nonError": specifically zero exit code
285
- - int: exact exit code match
286
- - Sequence[int]: exit code must be one of these values
287
- functionTarget: The function to test
288
- arguments: Arguments to pass to the function
289
- """
290
- with pytest.raises(SystemExit) as exitInfo:
291
- functionTarget(*arguments)
292
-
293
- exitCode = exitInfo.value.code
294
-
295
- if expected == "error":
296
- assert exitCode != 0, \
297
- f"Expected error exit (non-zero) but got code {exitCode}"
298
- elif expected == "nonError":
299
- assert exitCode == 0, \
300
- f"Expected non-error exit (0) but got code {exitCode}"
301
- elif isinstance(expected, (list, tuple)):
302
- assert exitCode in expected, \
303
- f"Expected exit code to be one of {expected} but got {exitCode}"
304
- else:
305
- assert exitCode == expected, \
306
- f"Expected exit code {expected} but got {exitCode}"
@@ -1,43 +0,0 @@
1
- from pathlib import Path
2
- from tests.conftest import *
3
- import importlib.util
4
- import pytest
5
-
6
- def test_algorithmSourceParallel(listDimensionsTestParallelization: List[int], foldsTotalKnown: Dict[Tuple[int, ...], int], useAlgorithmSourceDispatcher: None) -> None:
7
- standardizedEqualTo(foldsTotalKnown[tuple(listDimensionsTestParallelization)], countFolds, listDimensionsTestParallelization, None, 'maximum')
8
-
9
- def test_algorithmSourceSequential(listDimensionsTestCountFolds: List[int], foldsTotalKnown: Dict[Tuple[int, ...], int], useAlgorithmSourceDispatcher: None) -> None:
10
- standardizedEqualTo(foldsTotalKnown[tuple(listDimensionsTestCountFolds)], countFolds, listDimensionsTestCountFolds)
11
-
12
- def test_aOFn_calculate_value(oeisID: str) -> None:
13
- for n in settingsOEIS[oeisID]['valuesTestValidation']:
14
- standardizedEqualTo(settingsOEIS[oeisID]['valuesKnown'][n], oeisIDfor_n, oeisID, n)
15
-
16
- @pytest.mark.parametrize('pathFilenameTmpTesting', ['.py'], indirect=True)
17
- def test_writeJobNumba(listDimensionsTestCountFolds: List[int], foldsTotalKnown: Dict[Tuple[int, ...], int], pathFilenameTmpTesting: Path) -> None:
18
- from mapFolding.syntheticModules import numbaCount
19
- algorithmSourceHARDCODED: ModuleType = numbaCount
20
- algorithmSource = algorithmSourceHARDCODED
21
- callableTargetHARDCODED = 'countSequential'
22
- callableTarget = callableTargetHARDCODED
23
- pathFilenameModule = writeJobNumba(listDimensionsTestCountFolds, algorithmSource, callableTarget, pathFilenameWriteJob=pathFilenameTmpTesting.absolute())
24
-
25
- Don_Lapre_Road_to_Self_Improvement = importlib.util.spec_from_file_location("__main__", pathFilenameModule)
26
- if Don_Lapre_Road_to_Self_Improvement is None:
27
- raise ImportError(f"Failed to create module specification from {pathFilenameModule}")
28
- if Don_Lapre_Road_to_Self_Improvement.loader is None:
29
- raise ImportError(f"Failed to get loader for module {pathFilenameModule}")
30
- module = importlib.util.module_from_spec(Don_Lapre_Road_to_Self_Improvement)
31
-
32
- module.__name__ = "__main__"
33
- Don_Lapre_Road_to_Self_Improvement.loader.exec_module(module)
34
-
35
- pathFilenameFoldsTotal = getPathFilenameFoldsTotal(listDimensionsTestCountFolds)
36
- registrarRecordsTmpObject(pathFilenameFoldsTotal)
37
- standardizedEqualTo(str(foldsTotalKnown[tuple(listDimensionsTestCountFolds)]), pathFilenameFoldsTotal.read_text().strip)
38
-
39
- def test_syntheticParallel(syntheticDispatcherFixture, listDimensionsTestParallelization: List[int], foldsTotalKnown: Dict[Tuple[int, ...], int]):
40
- standardizedEqualTo(foldsTotalKnown[tuple(listDimensionsTestParallelization)], countFolds, listDimensionsTestParallelization, None, 'maximum')
41
-
42
- def test_syntheticSequential(syntheticDispatcherFixture, listDimensionsTestCountFolds: List[int], foldsTotalKnown: Dict[Tuple[int, ...], int]):
43
- standardizedEqualTo(foldsTotalKnown[tuple(listDimensionsTestCountFolds)], countFolds, listDimensionsTestCountFolds)