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.
- mapFolding/__init__.py +93 -58
- mapFolding/basecamp.py +9 -11
- mapFolding/beDRY.py +24 -23
- mapFolding/oeis.py +47 -45
- mapFolding/theDao.py +48 -48
- mapFolding/theSSOT.py +22 -20
- mapFolding/theSSOTdatatypes.py +20 -32
- {mapFolding-0.4.3.dist-info → mapFolding-0.5.1.dist-info}/METADATA +3 -1
- mapFolding-0.5.1.dist-info/RECORD +14 -0
- {mapFolding-0.4.3.dist-info → mapFolding-0.5.1.dist-info}/top_level.txt +0 -1
- mapFolding/reference/flattened.py +0 -377
- mapFolding/reference/hunterNumba.py +0 -132
- mapFolding/reference/irvineJavaPort.py +0 -120
- mapFolding/reference/jax.py +0 -208
- mapFolding/reference/lunnan.py +0 -153
- mapFolding/reference/lunnanNumpy.py +0 -123
- mapFolding/reference/lunnanWhile.py +0 -121
- mapFolding/reference/rotatedEntryPoint.py +0 -240
- mapFolding/reference/total_countPlus1vsPlusN.py +0 -211
- mapFolding/someAssemblyRequired/__init__.py +0 -5
- mapFolding/someAssemblyRequired/getLLVMforNoReason.py +0 -19
- mapFolding/someAssemblyRequired/makeJob.py +0 -55
- mapFolding/someAssemblyRequired/synthesizeModuleJAX.py +0 -29
- mapFolding/someAssemblyRequired/synthesizeNumba.py +0 -340
- mapFolding/someAssemblyRequired/synthesizeNumbaGeneralized.py +0 -396
- mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +0 -162
- mapFolding/someAssemblyRequired/synthesizeNumbaModules.py +0 -129
- mapFolding/syntheticModules/numbaCount.py +0 -158
- mapFolding/syntheticModules/numba_doTheNeedful.py +0 -13
- mapFolding-0.4.3.dist-info/RECORD +0 -40
- tests/__init__.py +0 -1
- tests/conftest.py +0 -306
- tests/test_computations.py +0 -43
- tests/test_oeis.py +0 -129
- tests/test_other.py +0 -171
- tests/test_tasks.py +0 -40
- tests/test_types.py +0 -5
- /mapFolding/{syntheticModules/__init__.py → py.typed} +0 -0
- {mapFolding-0.4.3.dist-info → mapFolding-0.5.1.dist-info}/LICENSE +0 -0
- {mapFolding-0.4.3.dist-info → mapFolding-0.5.1.dist-info}/WHEEL +0 -0
- {mapFolding-0.4.3.dist-info → mapFolding-0.5.1.dist-info}/entry_points.txt +0 -0
mapFolding/theDao.py
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
1
|
from mapFolding import indexMy, indexTrack
|
|
2
2
|
from numba import prange
|
|
3
3
|
from numpy import dtype, integer, ndarray
|
|
4
|
-
from typing import Any
|
|
4
|
+
from typing import Any
|
|
5
5
|
|
|
6
6
|
# `.value` is not necessary for this module or most modules. But, this module is transformed into Numba "jitted" functions, and Numba won't use `Enum` for an ndarray index without `.value`.
|
|
7
|
-
def activeLeafConnectedToItself(my: ndarray[
|
|
7
|
+
def activeLeafConnectedToItself(my: ndarray[tuple[int], dtype[integer[Any]]]) -> Any:
|
|
8
8
|
return my[indexMy.leafConnectee.value] == my[indexMy.leaf1ndex.value]
|
|
9
9
|
|
|
10
|
-
def activeLeafGreaterThan0(my: ndarray[
|
|
10
|
+
def activeLeafGreaterThan0(my: ndarray[tuple[int], dtype[integer[Any]]]) -> Any:
|
|
11
11
|
return my[indexMy.leaf1ndex.value] > 0
|
|
12
12
|
|
|
13
|
-
def activeLeafGreaterThanLeavesTotal(foldGroups: ndarray[
|
|
13
|
+
def activeLeafGreaterThanLeavesTotal(foldGroups: ndarray[tuple[int], dtype[integer[Any]]], my: ndarray[tuple[int], dtype[integer[Any]]]) -> Any:
|
|
14
14
|
return my[indexMy.leaf1ndex.value] > foldGroups[-1]
|
|
15
15
|
|
|
16
|
-
def activeLeafIsTheFirstLeaf(my: ndarray[
|
|
16
|
+
def activeLeafIsTheFirstLeaf(my: ndarray[tuple[int], dtype[integer[Any]]]) -> Any:
|
|
17
17
|
return my[indexMy.leaf1ndex.value] <= 1
|
|
18
18
|
|
|
19
|
-
def allDimensionsAreUnconstrained(my: ndarray[
|
|
19
|
+
def allDimensionsAreUnconstrained(my: ndarray[tuple[int], dtype[integer[Any]]]) -> Any:
|
|
20
20
|
return not my[indexMy.dimensionsUnconstrained.value]
|
|
21
21
|
|
|
22
|
-
def backtrack(my: ndarray[
|
|
22
|
+
def backtrack(my: ndarray[tuple[int], dtype[integer[Any]]], track: ndarray[tuple[int, int], dtype[integer[Any]]]) -> None:
|
|
23
23
|
my[indexMy.leaf1ndex.value] -= 1
|
|
24
24
|
track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]
|
|
25
25
|
track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]
|
|
26
26
|
|
|
27
|
-
def countGaps(gapsWhere: ndarray[
|
|
27
|
+
def countGaps(gapsWhere: ndarray[tuple[int], dtype[integer[Any]]], my: ndarray[tuple[int], dtype[integer[Any]]], track: ndarray[tuple[int, int], dtype[integer[Any]]]) -> None:
|
|
28
28
|
gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.leafConnectee.value]
|
|
29
29
|
if track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] == 0:
|
|
30
30
|
incrementGap1ndexCeiling(my=my)
|
|
31
31
|
track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] += 1
|
|
32
32
|
|
|
33
|
-
def decrementDimensionsUnconstrained(my: ndarray[
|
|
33
|
+
def decrementDimensionsUnconstrained(my: ndarray[tuple[int], dtype[integer[Any]]]) -> None:
|
|
34
34
|
my[indexMy.dimensionsUnconstrained.value] -= 1
|
|
35
35
|
|
|
36
|
-
def dimensionsUnconstrainedCondition(connectionGraph: ndarray[
|
|
36
|
+
def dimensionsUnconstrainedCondition(connectionGraph: ndarray[tuple[int, int, int], dtype[integer[Any]]], my: ndarray[tuple[int], dtype[integer[Any]]]) -> Any:
|
|
37
37
|
return connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]] == my[indexMy.leaf1ndex.value]
|
|
38
38
|
|
|
39
|
-
def filterCommonGaps(gapsWhere: ndarray[
|
|
39
|
+
def filterCommonGaps(gapsWhere: ndarray[tuple[int], dtype[integer[Any]]], my: ndarray[tuple[int], dtype[integer[Any]]], track: ndarray[tuple[int, int], dtype[integer[Any]]]) -> None:
|
|
40
40
|
gapsWhere[my[indexMy.gap1ndex.value]] = gapsWhere[my[indexMy.indexMiniGap.value]]
|
|
41
41
|
if track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] == my[indexMy.dimensionsUnconstrained.value]:
|
|
42
42
|
incrementActiveGap(my=my)
|
|
43
43
|
track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] = 0
|
|
44
44
|
|
|
45
|
-
def incrementActiveGap(my: ndarray[
|
|
45
|
+
def incrementActiveGap(my: ndarray[tuple[int], dtype[integer[Any]]]) -> None:
|
|
46
46
|
my[indexMy.gap1ndex.value] += 1
|
|
47
47
|
|
|
48
|
-
def incrementGap1ndexCeiling(my: ndarray[
|
|
48
|
+
def incrementGap1ndexCeiling(my: ndarray[tuple[int], dtype[integer[Any]]]) -> None:
|
|
49
49
|
my[indexMy.gap1ndexCeiling.value] += 1
|
|
50
50
|
|
|
51
|
-
def incrementIndexDimension(my: ndarray[
|
|
51
|
+
def incrementIndexDimension(my: ndarray[tuple[int], dtype[integer[Any]]]) -> None:
|
|
52
52
|
my[indexMy.indexDimension.value] += 1
|
|
53
53
|
|
|
54
|
-
def incrementIndexMiniGap(my: ndarray[
|
|
54
|
+
def incrementIndexMiniGap(my: ndarray[tuple[int], dtype[integer[Any]]]) -> None:
|
|
55
55
|
my[indexMy.indexMiniGap.value] += 1
|
|
56
56
|
|
|
57
|
-
def initializeIndexMiniGap(my: ndarray[
|
|
57
|
+
def initializeIndexMiniGap(my: ndarray[tuple[int], dtype[integer[Any]]]) -> None:
|
|
58
58
|
my[indexMy.indexMiniGap.value] = my[indexMy.gap1ndex.value]
|
|
59
59
|
|
|
60
|
-
def initializeLeafConnectee(connectionGraph: ndarray[
|
|
60
|
+
def initializeLeafConnectee(connectionGraph: ndarray[tuple[int, int, int], dtype[integer[Any]]], my: ndarray[tuple[int], dtype[integer[Any]]]) -> None:
|
|
61
61
|
my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]]
|
|
62
62
|
|
|
63
|
-
def initializeVariablesToFindGaps(my: ndarray[
|
|
63
|
+
def initializeVariablesToFindGaps(my: ndarray[tuple[int], dtype[integer[Any]]], track: ndarray[tuple[int, int], dtype[integer[Any]]]) -> None:
|
|
64
64
|
my[indexMy.dimensionsUnconstrained.value] = my[indexMy.dimensionsTotal.value]
|
|
65
65
|
my[indexMy.gap1ndexCeiling.value] = track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
|
|
66
66
|
my[indexMy.indexDimension.value] = 0
|
|
67
67
|
|
|
68
|
-
def insertUnconstrainedLeaf(gapsWhere: ndarray[
|
|
68
|
+
def insertUnconstrainedLeaf(gapsWhere: ndarray[tuple[int], dtype[integer[Any]]], my: ndarray[tuple[int], dtype[integer[Any]]]) -> None:
|
|
69
69
|
my[indexMy.indexLeaf.value] = 0
|
|
70
70
|
while my[indexMy.indexLeaf.value] < my[indexMy.leaf1ndex.value]:
|
|
71
71
|
gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.indexLeaf.value]
|
|
72
72
|
my[indexMy.gap1ndexCeiling.value] += 1
|
|
73
73
|
my[indexMy.indexLeaf.value] += 1
|
|
74
74
|
|
|
75
|
-
def leafBelowSentinelIs1(track: ndarray[
|
|
75
|
+
def leafBelowSentinelIs1(track: ndarray[tuple[int, int], dtype[integer[Any]]]) -> Any:
|
|
76
76
|
return track[indexTrack.leafBelow.value, 0] == 1
|
|
77
77
|
|
|
78
|
-
def loopingLeavesConnectedToActiveLeaf(my: ndarray[
|
|
78
|
+
def loopingLeavesConnectedToActiveLeaf(my: ndarray[tuple[int], dtype[integer[Any]]]) -> Any:
|
|
79
79
|
return my[indexMy.leafConnectee.value] != my[indexMy.leaf1ndex.value]
|
|
80
80
|
|
|
81
|
-
def loopingToActiveGapCeiling(my: ndarray[
|
|
81
|
+
def loopingToActiveGapCeiling(my: ndarray[tuple[int], dtype[integer[Any]]]) -> Any:
|
|
82
82
|
return my[indexMy.indexMiniGap.value] < my[indexMy.gap1ndexCeiling.value]
|
|
83
83
|
|
|
84
|
-
def loopUpToDimensionsTotal(my: ndarray[
|
|
84
|
+
def loopUpToDimensionsTotal(my: ndarray[tuple[int], dtype[integer[Any]]]) -> Any:
|
|
85
85
|
return my[indexMy.indexDimension.value] < my[indexMy.dimensionsTotal.value]
|
|
86
86
|
|
|
87
|
-
def noGapsHere(my: ndarray[
|
|
87
|
+
def noGapsHere(my: ndarray[tuple[int], dtype[integer[Any]]], track: ndarray[tuple[int, int], dtype[integer[Any]]]) -> Any:
|
|
88
88
|
return my[indexMy.leaf1ndex.value] > 0 and my[indexMy.gap1ndex.value] == track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
|
|
89
89
|
|
|
90
|
-
def placeLeaf(gapsWhere: ndarray[
|
|
90
|
+
def placeLeaf(gapsWhere: ndarray[tuple[int], dtype[integer[Any]]], my: ndarray[tuple[int], dtype[integer[Any]]], track: ndarray[tuple[int, int], dtype[integer[Any]]]) -> None:
|
|
91
91
|
my[indexMy.gap1ndex.value] -= 1
|
|
92
92
|
track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]] = gapsWhere[my[indexMy.gap1ndex.value]]
|
|
93
93
|
track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]] = track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]]
|
|
@@ -96,19 +96,19 @@ def placeLeaf(gapsWhere: ndarray[Tuple[int], dtype[integer[Any]]], my: ndarray[T
|
|
|
96
96
|
track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value]] = my[indexMy.gap1ndex.value]
|
|
97
97
|
my[indexMy.leaf1ndex.value] += 1
|
|
98
98
|
|
|
99
|
-
def thereIsAnActiveLeaf(my: ndarray[
|
|
99
|
+
def thereIsAnActiveLeaf(my: ndarray[tuple[int], dtype[integer[Any]]]) -> Any:
|
|
100
100
|
return my[indexMy.leaf1ndex.value] > 0
|
|
101
101
|
|
|
102
|
-
def thisIsMyTaskIndex(my: ndarray[
|
|
102
|
+
def thisIsMyTaskIndex(my: ndarray[tuple[int], dtype[integer[Any]]]) -> Any:
|
|
103
103
|
return my[indexMy.leaf1ndex.value] != my[indexMy.taskDivisions.value] or my[indexMy.leafConnectee.value] % my[indexMy.taskDivisions.value] == my[indexMy.taskIndex.value]
|
|
104
104
|
|
|
105
|
-
def updateLeafConnectee(connectionGraph: ndarray[
|
|
105
|
+
def updateLeafConnectee(connectionGraph: ndarray[tuple[int, int, int], dtype[integer[Any]]], my: ndarray[tuple[int], dtype[integer[Any]]], track: ndarray[tuple[int, int], dtype[integer[Any]]]) -> None:
|
|
106
106
|
my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], track[indexTrack.leafBelow.value, my[indexMy.leafConnectee.value]]]
|
|
107
107
|
|
|
108
|
-
def countInitialize(connectionGraph: ndarray[
|
|
109
|
-
, gapsWhere: ndarray[
|
|
110
|
-
, my: ndarray[
|
|
111
|
-
, track: ndarray[
|
|
108
|
+
def countInitialize(connectionGraph: ndarray[tuple[int, int, int], dtype[integer[Any]]]
|
|
109
|
+
, gapsWhere: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
110
|
+
, my: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
111
|
+
, track: ndarray[tuple[int, int] , dtype[integer[Any]]]
|
|
112
112
|
) -> None:
|
|
113
113
|
|
|
114
114
|
while activeLeafGreaterThan0(my=my):
|
|
@@ -134,11 +134,11 @@ def countInitialize(connectionGraph: ndarray[Tuple[int, int, int], dtype[integer
|
|
|
134
134
|
if my[indexMy.gap1ndex.value] > 0:
|
|
135
135
|
return
|
|
136
136
|
|
|
137
|
-
def countParallel(connectionGraph: ndarray[
|
|
138
|
-
, foldGroups: ndarray[
|
|
139
|
-
, gapsWhere: ndarray[
|
|
140
|
-
, my: ndarray[
|
|
141
|
-
, track: ndarray[
|
|
137
|
+
def countParallel(connectionGraph: ndarray[tuple[int, int, int], dtype[integer[Any]]]
|
|
138
|
+
, foldGroups: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
139
|
+
, gapsWhere: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
140
|
+
, my: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
141
|
+
, track: ndarray[tuple[int, int] , dtype[integer[Any]]]
|
|
142
142
|
) -> None:
|
|
143
143
|
|
|
144
144
|
gapsWherePARALLEL = gapsWhere.copy()
|
|
@@ -182,11 +182,11 @@ def countParallel(connectionGraph: ndarray[Tuple[int, int, int], dtype[integer[A
|
|
|
182
182
|
placeLeaf(gapsWhere=gapsWhere, my=my, track=track)
|
|
183
183
|
foldGroups[my[indexMy.taskIndex.value]] = groupsOfFolds
|
|
184
184
|
|
|
185
|
-
def countSequential( connectionGraph: ndarray[
|
|
186
|
-
, foldGroups: ndarray[
|
|
187
|
-
, gapsWhere: ndarray[
|
|
188
|
-
, my: ndarray[
|
|
189
|
-
, track: ndarray[
|
|
185
|
+
def countSequential( connectionGraph: ndarray[tuple[int, int, int], dtype[integer[Any]]]
|
|
186
|
+
, foldGroups: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
187
|
+
, gapsWhere: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
188
|
+
, my: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
189
|
+
, track: ndarray[tuple[int, int] , dtype[integer[Any]]]
|
|
190
190
|
) -> None:
|
|
191
191
|
|
|
192
192
|
groupsOfFolds: int = 0
|
|
@@ -216,12 +216,12 @@ def countSequential( connectionGraph: ndarray[Tuple[int, int, int], dtype[intege
|
|
|
216
216
|
placeLeaf(gapsWhere=gapsWhere, my=my, track=track)
|
|
217
217
|
foldGroups[my[indexMy.taskIndex.value]] = groupsOfFolds
|
|
218
218
|
|
|
219
|
-
def doTheNeedful(connectionGraph: ndarray[
|
|
220
|
-
, foldGroups: ndarray[
|
|
221
|
-
, gapsWhere: ndarray[
|
|
222
|
-
, mapShape: ndarray[
|
|
223
|
-
, my: ndarray[
|
|
224
|
-
, track: ndarray[
|
|
219
|
+
def doTheNeedful(connectionGraph: ndarray[tuple[int, int, int], dtype[integer[Any]]]
|
|
220
|
+
, foldGroups: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
221
|
+
, gapsWhere: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
222
|
+
, mapShape: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
223
|
+
, my: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
224
|
+
, track: ndarray[tuple[int, int] , dtype[integer[Any]]]
|
|
225
225
|
) -> None:
|
|
226
226
|
|
|
227
227
|
countInitialize(connectionGraph, gapsWhere, my, track)
|
mapFolding/theSSOT.py
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
1
2
|
from mapFolding.theSSOTdatatypes import *
|
|
2
3
|
from numba.core.compiler import CompilerBase as numbaCompilerBase
|
|
3
4
|
from numpy import dtype, integer, ndarray
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from sys import modules as sysModules
|
|
4
7
|
from types import ModuleType
|
|
5
|
-
from typing import Any,
|
|
6
|
-
import pathlib
|
|
7
|
-
import sys
|
|
8
|
+
from typing import Any, Final, TYPE_CHECKING, cast
|
|
8
9
|
|
|
9
10
|
try:
|
|
10
11
|
from typing import NotRequired
|
|
11
|
-
except
|
|
12
|
-
from typing_extensions import NotRequired
|
|
12
|
+
except Exception:
|
|
13
|
+
from typing_extensions import NotRequired # type: ignore
|
|
13
14
|
|
|
14
15
|
if TYPE_CHECKING:
|
|
15
16
|
from typing import TypedDict
|
|
@@ -31,23 +32,24 @@ myPackageNameIs = "mapFolding"
|
|
|
31
32
|
moduleOfSyntheticModules = "syntheticModules"
|
|
32
33
|
# TODO I'm not sure if this is the right tool for the job.
|
|
33
34
|
formatFilenameModuleDEFAULT = "numba_{callableTarget}.py"
|
|
35
|
+
# TODO figure out how to implement this
|
|
34
36
|
dispatcherCallableNameDEFAULT = "doTheNeedful"
|
|
35
37
|
|
|
36
|
-
def getPathPackage() ->
|
|
38
|
+
def getPathPackage() -> Path:
|
|
37
39
|
import importlib, inspect
|
|
38
|
-
pathPackage =
|
|
40
|
+
pathPackage = Path(inspect.getfile(importlib.import_module(myPackageNameIs)))
|
|
39
41
|
if pathPackage.is_file():
|
|
40
42
|
pathPackage = pathPackage.parent
|
|
41
43
|
return pathPackage
|
|
42
44
|
|
|
43
|
-
def getPathJobRootDEFAULT() ->
|
|
44
|
-
if 'google.colab' in
|
|
45
|
-
pathJobDEFAULT =
|
|
45
|
+
def getPathJobRootDEFAULT() -> Path:
|
|
46
|
+
if 'google.colab' in sysModules:
|
|
47
|
+
pathJobDEFAULT = Path("/content/drive/MyDrive") / "jobs"
|
|
46
48
|
else:
|
|
47
49
|
pathJobDEFAULT = getPathPackage() / "jobs"
|
|
48
50
|
return pathJobDEFAULT
|
|
49
51
|
|
|
50
|
-
def getPathSyntheticModules() ->
|
|
52
|
+
def getPathSyntheticModules() -> Path:
|
|
51
53
|
pathSyntheticModules = getPathPackage() / moduleOfSyntheticModules
|
|
52
54
|
return pathSyntheticModules
|
|
53
55
|
|
|
@@ -65,12 +67,12 @@ def getDispatcherCallable() -> Callable[..., None]:
|
|
|
65
67
|
|
|
66
68
|
# NOTE I want this _concept_, not necessarily this method, to be well implemented and usable everywhere: Python, Numba, Jax, CUDA, idc
|
|
67
69
|
class computationState(TypedDict):
|
|
68
|
-
connectionGraph: ndarray[
|
|
69
|
-
foldGroups: ndarray[
|
|
70
|
-
gapsWhere: ndarray[
|
|
71
|
-
mapShape: ndarray[
|
|
72
|
-
my: ndarray[
|
|
73
|
-
track: ndarray[
|
|
70
|
+
connectionGraph: ndarray[tuple[int, int, int], dtype[integer[Any]]]
|
|
71
|
+
foldGroups: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
72
|
+
gapsWhere: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
73
|
+
mapShape: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
74
|
+
my: ndarray[tuple[int] , dtype[integer[Any]]]
|
|
75
|
+
track: ndarray[tuple[int, int] , dtype[integer[Any]]]
|
|
74
76
|
|
|
75
77
|
_datatypeModuleScalar = 'numba'
|
|
76
78
|
_decoratorCallable = 'jit'
|
|
@@ -110,7 +112,7 @@ class ParametersNumba(TypedDict):
|
|
|
110
112
|
forceinline: bool
|
|
111
113
|
forceobj: NotRequired[bool]
|
|
112
114
|
inline: str
|
|
113
|
-
locals: NotRequired[
|
|
115
|
+
locals: NotRequired[dict[str, Any]]
|
|
114
116
|
looplift: bool
|
|
115
117
|
no_cfunc_wrapper: bool
|
|
116
118
|
no_cpython_wrapper: bool
|
|
@@ -118,8 +120,8 @@ class ParametersNumba(TypedDict):
|
|
|
118
120
|
nogil: NotRequired[bool]
|
|
119
121
|
nopython: bool
|
|
120
122
|
parallel: bool
|
|
121
|
-
pipeline_class: NotRequired[
|
|
122
|
-
signature_or_function: NotRequired[
|
|
123
|
+
pipeline_class: NotRequired[type[numbaCompilerBase]]
|
|
124
|
+
signature_or_function: NotRequired[Any | Callable[..., Any] | str | tuple[Any, ...]]
|
|
123
125
|
target: NotRequired[str]
|
|
124
126
|
|
|
125
127
|
parametersNumbaFailEarly: Final[ParametersNumba] = { '_nrt': True, 'boundscheck': True, 'cache': True, 'error_model': 'python', 'fastmath': False, 'forceinline': True, 'inline': 'always', 'looplift': False, 'no_cfunc_wrapper': False, 'no_cpython_wrapper': False, 'nopython': True, 'parallel': False, }
|
mapFolding/theSSOTdatatypes.py
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
from collections import defaultdict
|
|
2
|
-
from typing import Any, cast,
|
|
2
|
+
from typing import Any, cast, Final
|
|
3
3
|
import enum
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import numpy
|
|
4
|
+
import numba # type: ignore
|
|
5
|
+
import numpy # type: ignore
|
|
7
6
|
|
|
8
|
-
try:
|
|
9
|
-
from typing import NotRequired
|
|
10
|
-
except ImportError:
|
|
11
|
-
from typing_extensions import NotRequired
|
|
12
|
-
|
|
13
|
-
if TYPE_CHECKING:
|
|
14
|
-
from typing import TypedDict
|
|
15
|
-
else:
|
|
16
|
-
TypedDict = dict
|
|
17
|
-
|
|
18
|
-
@enum.verify(enum.CONTINUOUS, enum.UNIQUE) if sys.version_info >= (3, 11) else lambda x: x
|
|
19
7
|
class EnumIndices(enum.IntEnum):
|
|
20
8
|
@staticmethod
|
|
21
9
|
def _generate_next_value_(name: str, start: int, count: int, last_values: list[Any]) -> int:
|
|
@@ -48,17 +36,17 @@ class indexTrack(EnumIndices):
|
|
|
48
36
|
countDimensionsGapped = enum.auto()
|
|
49
37
|
gapRangeStart = enum.auto()
|
|
50
38
|
|
|
51
|
-
_datatypeDefault: Final[
|
|
39
|
+
_datatypeDefault: Final[dict[str, str]] = {
|
|
52
40
|
'elephino': 'uint16',
|
|
53
41
|
'foldsTotal': 'int64',
|
|
54
42
|
'leavesTotal': 'uint16',
|
|
55
43
|
}
|
|
56
|
-
_datatypeModule = ''
|
|
44
|
+
_datatypeModule: str = ''
|
|
57
45
|
_datatypeModuleDEFAULT: Final[str] = 'numpy'
|
|
58
46
|
|
|
59
|
-
_datatype:
|
|
47
|
+
_datatype: dict[str, str] = defaultdict(str)
|
|
60
48
|
|
|
61
|
-
def reportDatatypeLimit(identifier: str, datatype: str, sourGrapes:
|
|
49
|
+
def reportDatatypeLimit(identifier: str, datatype: str, sourGrapes: bool | None = False) -> str:
|
|
62
50
|
global _datatype
|
|
63
51
|
if not _datatype[identifier]:
|
|
64
52
|
_datatype[identifier] = datatype
|
|
@@ -68,7 +56,7 @@ def reportDatatypeLimit(identifier: str, datatype: str, sourGrapes: Optional[boo
|
|
|
68
56
|
raise Exception(f"Datatype is '{_datatype[identifier]}' not '{datatype}', so you can take your ball and go home.")
|
|
69
57
|
return _datatype[identifier]
|
|
70
58
|
|
|
71
|
-
def setDatatypeModule(datatypeModule: str, sourGrapes:
|
|
59
|
+
def setDatatypeModule(datatypeModule: str, sourGrapes: bool | None = False) -> str:
|
|
72
60
|
global _datatypeModule
|
|
73
61
|
if not _datatypeModule:
|
|
74
62
|
_datatypeModule = datatypeModule
|
|
@@ -78,13 +66,13 @@ def setDatatypeModule(datatypeModule: str, sourGrapes: Optional[bool] = False) -
|
|
|
78
66
|
raise Exception(f"Datatype module is '{_datatypeModule}' not '{datatypeModule}', so you can take your ball and go home.")
|
|
79
67
|
return _datatypeModule
|
|
80
68
|
|
|
81
|
-
def setDatatypeElephino(datatype: str, sourGrapes:
|
|
69
|
+
def setDatatypeElephino(datatype: str, sourGrapes: bool | None = False) -> str:
|
|
82
70
|
return reportDatatypeLimit('elephino', datatype, sourGrapes)
|
|
83
71
|
|
|
84
|
-
def setDatatypeFoldsTotal(datatype: str, sourGrapes:
|
|
72
|
+
def setDatatypeFoldsTotal(datatype: str, sourGrapes: bool | None = False) -> str:
|
|
85
73
|
return reportDatatypeLimit('foldsTotal', datatype, sourGrapes)
|
|
86
74
|
|
|
87
|
-
def setDatatypeLeavesTotal(datatype: str, sourGrapes:
|
|
75
|
+
def setDatatypeLeavesTotal(datatype: str, sourGrapes: bool | None = False) -> str:
|
|
88
76
|
return reportDatatypeLimit('leavesTotal', datatype, sourGrapes)
|
|
89
77
|
|
|
90
78
|
def _get_datatype(identifier: str) -> str:
|
|
@@ -104,13 +92,13 @@ def getDatatypeModule() -> str:
|
|
|
104
92
|
_datatypeModule = _datatypeModuleDEFAULT
|
|
105
93
|
return _datatypeModule
|
|
106
94
|
|
|
107
|
-
def setInStone(identifier: str) ->
|
|
108
|
-
datatypeModule = getDatatypeModule()
|
|
109
|
-
datatypeStr = _get_datatype(identifier)
|
|
110
|
-
return cast(
|
|
95
|
+
def setInStone(identifier: str) -> type[Any]:
|
|
96
|
+
datatypeModule: str = getDatatypeModule()
|
|
97
|
+
datatypeStr: str = _get_datatype(identifier)
|
|
98
|
+
return cast(type[Any], getattr(eval(datatypeModule), datatypeStr))
|
|
111
99
|
|
|
112
|
-
def hackSSOTdtype(identifier: str) ->
|
|
113
|
-
_hackSSOTdtype={
|
|
100
|
+
def hackSSOTdtype(identifier: str) -> type[Any]:
|
|
101
|
+
_hackSSOTdtype: dict[str, str]={
|
|
114
102
|
'connectionGraph': 'dtypeLeavesTotal',
|
|
115
103
|
'dtypeElephino': 'dtypeElephino',
|
|
116
104
|
'dtypeFoldsTotal': 'dtypeFoldsTotal',
|
|
@@ -121,7 +109,7 @@ def hackSSOTdtype(identifier: str) -> Type[Any]:
|
|
|
121
109
|
'my': 'dtypeElephino',
|
|
122
110
|
'track': 'dtypeElephino',
|
|
123
111
|
}
|
|
124
|
-
RubeGoldBerg = _hackSSOTdtype[identifier]
|
|
112
|
+
RubeGoldBerg: str = _hackSSOTdtype[identifier]
|
|
125
113
|
if RubeGoldBerg == 'dtypeElephino':
|
|
126
114
|
return setInStone('elephino')
|
|
127
115
|
elif RubeGoldBerg == 'dtypeFoldsTotal':
|
|
@@ -131,7 +119,7 @@ def hackSSOTdtype(identifier: str) -> Type[Any]:
|
|
|
131
119
|
raise Exception("Dude, you forgot to set a value in `hackSSOTdtype`.")
|
|
132
120
|
|
|
133
121
|
def hackSSOTdatatype(identifier: str) -> str:
|
|
134
|
-
_hackSSOTdatatype={
|
|
122
|
+
_hackSSOTdatatype: dict[str, str]={
|
|
135
123
|
'connectionGraph': 'datatypeLeavesTotal',
|
|
136
124
|
'countDimensionsGapped': 'datatypeLeavesTotal',
|
|
137
125
|
'datatypeElephino': 'datatypeElephino',
|
|
@@ -158,7 +146,7 @@ def hackSSOTdatatype(identifier: str) -> str:
|
|
|
158
146
|
'taskIndex': 'datatypeLeavesTotal',
|
|
159
147
|
'track': 'datatypeElephino',
|
|
160
148
|
}
|
|
161
|
-
RubeGoldBerg = _hackSSOTdatatype[identifier]
|
|
149
|
+
RubeGoldBerg: str = _hackSSOTdatatype[identifier]
|
|
162
150
|
if RubeGoldBerg == 'datatypeElephino':
|
|
163
151
|
return _get_datatype('elephino')
|
|
164
152
|
elif RubeGoldBerg == 'datatypeFoldsTotal':
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: mapFolding
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: Count distinct ways to fold a map (or a strip of stamps)
|
|
5
5
|
Author-email: Hunter Hogan <HunterHogan@pm.me>
|
|
6
6
|
License: CC-BY-NC-4.0
|
|
@@ -33,12 +33,14 @@ Requires-Dist: numpy
|
|
|
33
33
|
Requires-Dist: Z0Z_tools
|
|
34
34
|
Provides-Extra: testing
|
|
35
35
|
Requires-Dist: autoflake; extra == "testing"
|
|
36
|
+
Requires-Dist: mypy; extra == "testing"
|
|
36
37
|
Requires-Dist: more_itertools; extra == "testing"
|
|
37
38
|
Requires-Dist: pytest-cov; extra == "testing"
|
|
38
39
|
Requires-Dist: pytest-env; extra == "testing"
|
|
39
40
|
Requires-Dist: pytest-xdist; extra == "testing"
|
|
40
41
|
Requires-Dist: pytest; extra == "testing"
|
|
41
42
|
Requires-Dist: python_minifier; extra == "testing"
|
|
43
|
+
Requires-Dist: pyupgrade; extra == "testing"
|
|
42
44
|
Requires-Dist: updateCitation; extra == "testing"
|
|
43
45
|
|
|
44
46
|
# mapFolding: Algorithms for enumerating distinct map/stamp folding patterns 🗺️
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
mapFolding/__init__.py,sha256=FmpYlbGIZ4Pkt5Qr49JRBWdPRX9be4dYNlEV1ZXkmKU,2620
|
|
2
|
+
mapFolding/basecamp.py,sha256=eU-9XQ9aOpgOcpVSTlbQ_XZEYsmfx1h6gESTgvP3RrI,3707
|
|
3
|
+
mapFolding/beDRY.py,sha256=_NswGMIkF77akOSEJQqbOQOMwwrAL0c9yJi5bTZUBzw,17027
|
|
4
|
+
mapFolding/oeis.py,sha256=ekXTb5P2GUkVgVsxWb23nukl8Pg97kdyU3-pePq7EQA,11393
|
|
5
|
+
mapFolding/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
mapFolding/theDao.py,sha256=64dlLhrdtNbZAXMbqcZhGAE0ZwgqYRt8nT1on46J-cc,12611
|
|
7
|
+
mapFolding/theSSOT.py,sha256=u7VXbqGasrTomxI771bQ7kURMpfn_ph6Y8ac8Rf70hw,5866
|
|
8
|
+
mapFolding/theSSOTdatatypes.py,sha256=-p9B5ikWPKqztnmDDg6NKAdys7qwiNU2c1oCbGXAf5Q,5714
|
|
9
|
+
mapFolding-0.5.1.dist-info/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
|
|
10
|
+
mapFolding-0.5.1.dist-info/METADATA,sha256=UJsh0vVsMCGhX3ORFIrrVCLSQDDGJeGC_QrUjJeKpB4,7718
|
|
11
|
+
mapFolding-0.5.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
12
|
+
mapFolding-0.5.1.dist-info/entry_points.txt,sha256=F3OUeZR1XDTpoH7k3wXuRb3KF_kXTTeYhu5AGK1SiOQ,146
|
|
13
|
+
mapFolding-0.5.1.dist-info/top_level.txt,sha256=aG3bjFBoxxuaV3Iu1wZAd241Ubs3cdaJtKYBQBDIjsg,11
|
|
14
|
+
mapFolding-0.5.1.dist-info/RECORD,,
|