mapFolding 0.5.0__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 +5 -5
- mapFolding/beDRY.py +5 -5
- mapFolding/oeis.py +26 -25
- mapFolding/theSSOT.py +3 -15
- mapFolding/theSSOTdatatypes.py +10 -20
- {mapFolding-0.5.0.dist-info → mapFolding-0.5.1.dist-info}/METADATA +2 -1
- mapFolding-0.5.1.dist-info/RECORD +14 -0
- {mapFolding-0.5.0.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 -56
- mapFolding/someAssemblyRequired/synthesizeModuleJAX.py +0 -27
- mapFolding/someAssemblyRequired/synthesizeNumba.py +0 -345
- mapFolding/someAssemblyRequired/synthesizeNumbaGeneralized.py +0 -397
- mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +0 -155
- mapFolding/someAssemblyRequired/synthesizeNumbaModules.py +0 -123
- mapFolding/syntheticModules/numbaCount.py +0 -158
- mapFolding/syntheticModules/numba_doTheNeedful.py +0 -13
- mapFolding-0.5.0.dist-info/RECORD +0 -39
- tests/__init__.py +0 -1
- tests/conftest.py +0 -335
- tests/test_computations.py +0 -42
- tests/test_oeis.py +0 -128
- tests/test_other.py +0 -175
- tests/test_tasks.py +0 -40
- /mapFolding/{syntheticModules/__init__.py → py.typed} +0 -0
- {mapFolding-0.5.0.dist-info → mapFolding-0.5.1.dist-info}/LICENSE +0 -0
- {mapFolding-0.5.0.dist-info → mapFolding-0.5.1.dist-info}/WHEEL +0 -0
- {mapFolding-0.5.0.dist-info → mapFolding-0.5.1.dist-info}/entry_points.txt +0 -0
mapFolding/__init__.py
CHANGED
|
@@ -1,69 +1,104 @@
|
|
|
1
|
+
from collections import defaultdict
|
|
2
|
+
from types import ModuleType
|
|
3
|
+
import importlib
|
|
4
|
+
|
|
5
|
+
_dictionaryListsImportFrom: dict[str, list[str]] = defaultdict(list)
|
|
6
|
+
|
|
7
|
+
def __getattr__(name: str):
|
|
8
|
+
if name not in _mapSymbolToModule:
|
|
9
|
+
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
moduleAsStr: str = _mapSymbolToModule[name]
|
|
13
|
+
module: ModuleType = importlib.import_module(moduleAsStr)
|
|
14
|
+
blankSymbol = getattr(module, name)
|
|
15
|
+
except (ImportError, ModuleNotFoundError, AttributeError):
|
|
16
|
+
raise
|
|
17
|
+
|
|
18
|
+
# The need to inject into globals tells us that the symbol has not actually been imported
|
|
19
|
+
globals()[name] = blankSymbol
|
|
20
|
+
return blankSymbol
|
|
21
|
+
|
|
22
|
+
_dictionaryListsImportFrom['mapFolding.basecamp'].extend([
|
|
23
|
+
'countFolds',
|
|
24
|
+
])
|
|
25
|
+
|
|
26
|
+
_dictionaryListsImportFrom['mapFolding.beDRY'].extend([
|
|
27
|
+
'getFilenameFoldsTotal',
|
|
28
|
+
'getPathFilenameFoldsTotal',
|
|
29
|
+
'outfitCountFolds',
|
|
30
|
+
'saveFoldsTotal',
|
|
31
|
+
])
|
|
32
|
+
|
|
33
|
+
_dictionaryListsImportFrom['mapFolding.oeis'].extend([
|
|
34
|
+
'clearOEIScache',
|
|
35
|
+
'getOEISids',
|
|
36
|
+
'oeisIDfor_n',
|
|
37
|
+
])
|
|
38
|
+
|
|
1
39
|
# fundamentals
|
|
2
|
-
|
|
3
|
-
computationState,
|
|
4
|
-
EnumIndices,
|
|
5
|
-
getDispatcherCallable,
|
|
6
|
-
getPathPackage,
|
|
7
|
-
indexMy,
|
|
8
|
-
indexTrack,
|
|
9
|
-
myPackageNameIs,
|
|
10
|
-
)
|
|
40
|
+
_dictionaryListsImportFrom['mapFolding.theSSOT'].extend([
|
|
41
|
+
'computationState',
|
|
42
|
+
'EnumIndices',
|
|
43
|
+
'getDispatcherCallable',
|
|
44
|
+
'getPathPackage',
|
|
45
|
+
'indexMy',
|
|
46
|
+
'indexTrack',
|
|
47
|
+
'myPackageNameIs',
|
|
48
|
+
])
|
|
11
49
|
|
|
12
50
|
# Datatype management
|
|
13
|
-
|
|
14
|
-
getDatatypeModule,
|
|
15
|
-
hackSSOTdatatype,
|
|
16
|
-
hackSSOTdtype,
|
|
17
|
-
setDatatypeElephino,
|
|
18
|
-
setDatatypeFoldsTotal,
|
|
19
|
-
setDatatypeLeavesTotal,
|
|
20
|
-
setDatatypeModule,
|
|
21
|
-
)
|
|
51
|
+
_dictionaryListsImportFrom['mapFolding.theSSOT'].extend([
|
|
52
|
+
'getDatatypeModule',
|
|
53
|
+
'hackSSOTdatatype',
|
|
54
|
+
'hackSSOTdtype',
|
|
55
|
+
'setDatatypeElephino',
|
|
56
|
+
'setDatatypeFoldsTotal',
|
|
57
|
+
'setDatatypeLeavesTotal',
|
|
58
|
+
'setDatatypeModule',
|
|
59
|
+
])
|
|
22
60
|
|
|
23
61
|
# Synthesize modules
|
|
24
|
-
|
|
25
|
-
formatFilenameModuleDEFAULT,
|
|
26
|
-
getAlgorithmDispatcher,
|
|
27
|
-
getAlgorithmSource,
|
|
28
|
-
getPathJobRootDEFAULT,
|
|
29
|
-
getPathSyntheticModules,
|
|
30
|
-
moduleOfSyntheticModules,
|
|
31
|
-
Z0Z_getDatatypeModuleScalar,
|
|
32
|
-
Z0Z_getDecoratorCallable,
|
|
33
|
-
Z0Z_setDatatypeModuleScalar,
|
|
34
|
-
Z0Z_setDecoratorCallable,
|
|
35
|
-
Z0Z_identifierCountFolds,
|
|
36
|
-
)
|
|
62
|
+
_dictionaryListsImportFrom['mapFolding.theSSOT'].extend([
|
|
63
|
+
'formatFilenameModuleDEFAULT',
|
|
64
|
+
'getAlgorithmDispatcher',
|
|
65
|
+
'getAlgorithmSource',
|
|
66
|
+
'getPathJobRootDEFAULT',
|
|
67
|
+
'getPathSyntheticModules',
|
|
68
|
+
'moduleOfSyntheticModules',
|
|
69
|
+
'Z0Z_getDatatypeModuleScalar',
|
|
70
|
+
'Z0Z_getDecoratorCallable',
|
|
71
|
+
'Z0Z_setDatatypeModuleScalar',
|
|
72
|
+
'Z0Z_setDecoratorCallable',
|
|
73
|
+
'Z0Z_identifierCountFolds',
|
|
74
|
+
])
|
|
37
75
|
|
|
38
76
|
# Parameters for the prima donna
|
|
39
|
-
|
|
40
|
-
ParametersNumba,
|
|
41
|
-
parametersNumbaDEFAULT,
|
|
42
|
-
parametersNumbaFailEarly,
|
|
43
|
-
parametersNumbaMinimum,
|
|
44
|
-
parametersNumbaParallelDEFAULT,
|
|
45
|
-
parametersNumbaSuperJit,
|
|
46
|
-
parametersNumbaSuperJitParallel,
|
|
47
|
-
)
|
|
77
|
+
_dictionaryListsImportFrom['mapFolding.theSSOT'].extend([
|
|
78
|
+
'ParametersNumba',
|
|
79
|
+
'parametersNumbaDEFAULT',
|
|
80
|
+
'parametersNumbaFailEarly',
|
|
81
|
+
'parametersNumbaMinimum',
|
|
82
|
+
'parametersNumbaParallelDEFAULT',
|
|
83
|
+
'parametersNumbaSuperJit',
|
|
84
|
+
'parametersNumbaSuperJitParallel',
|
|
85
|
+
])
|
|
48
86
|
|
|
49
87
|
# Coping
|
|
50
|
-
|
|
51
|
-
FREAKOUT,
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
from mapFolding.beDRY import (
|
|
55
|
-
getFilenameFoldsTotal,
|
|
56
|
-
getPathFilenameFoldsTotal,
|
|
57
|
-
outfitCountFolds,
|
|
58
|
-
saveFoldsTotal,
|
|
59
|
-
)
|
|
88
|
+
_dictionaryListsImportFrom['mapFolding.theSSOT'].extend([
|
|
89
|
+
'FREAKOUT',
|
|
90
|
+
])
|
|
60
91
|
|
|
61
|
-
|
|
62
|
-
|
|
92
|
+
_mapSymbolToModule: dict[str, str] = {}
|
|
93
|
+
for moduleAsStr, listSymbolsAsStr in _dictionaryListsImportFrom.items():
|
|
94
|
+
for symbolAsStr in listSymbolsAsStr:
|
|
95
|
+
_mapSymbolToModule[symbolAsStr] = moduleAsStr
|
|
63
96
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
97
|
+
from typing import TYPE_CHECKING
|
|
98
|
+
if TYPE_CHECKING:
|
|
99
|
+
from basecamp import *
|
|
100
|
+
from beDRY import *
|
|
101
|
+
from oeis import *
|
|
102
|
+
from theDao import *
|
|
103
|
+
from theSSOT import *
|
|
104
|
+
from theSSOTdatatypes import *
|
mapFolding/basecamp.py
CHANGED
|
@@ -3,11 +3,11 @@ from mapFolding import computationState, getDispatcherCallable, getPathFilenameF
|
|
|
3
3
|
from os import PathLike
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
|
|
6
|
-
def countFolds(listDimensions: Sequence[int]
|
|
7
|
-
pathLikeWriteFoldsTotal: str | PathLike[str] | None = None
|
|
8
|
-
computationDivisions: int | str | None = None
|
|
9
|
-
CPUlimit: int | float | bool | None = None
|
|
10
|
-
**keywordArguments: str | bool
|
|
6
|
+
def countFolds(listDimensions: Sequence[int]
|
|
7
|
+
, pathLikeWriteFoldsTotal: str | PathLike[str] | None = None
|
|
8
|
+
, computationDivisions: int | str | None = None
|
|
9
|
+
, CPUlimit: int | float | bool | None = None
|
|
10
|
+
, **keywordArguments: str | bool
|
|
11
11
|
) -> int:
|
|
12
12
|
"""Count the total number of possible foldings for a given map dimensions.
|
|
13
13
|
|
mapFolding/beDRY.py
CHANGED
|
@@ -13,7 +13,7 @@ from mapFolding import (
|
|
|
13
13
|
setDatatypeModule,
|
|
14
14
|
)
|
|
15
15
|
from collections.abc import Sequence
|
|
16
|
-
from numba import get_num_threads, set_num_threads
|
|
16
|
+
from numba import get_num_threads, set_num_threads # type: ignore
|
|
17
17
|
from numpy import dtype, integer, ndarray
|
|
18
18
|
from numpy.typing import DTypeLike, NDArray
|
|
19
19
|
from pathlib import Path
|
|
@@ -139,7 +139,7 @@ def getTaskDivisions(computationDivisions: int | str | None, concurrencyLimit: i
|
|
|
139
139
|
pass
|
|
140
140
|
elif isinstance(computationDivisions, int):
|
|
141
141
|
taskDivisions = computationDivisions
|
|
142
|
-
elif isinstance(computationDivisions, str):
|
|
142
|
+
elif isinstance(computationDivisions, str): # type: ignore 'Unnecessary isinstance call; "str" is always an instance of "str", so sayeth Pylance'. Yeah, well "User is not always an instance of "correct input" so sayeth the programmer.
|
|
143
143
|
computationDivisions = computationDivisions.lower()
|
|
144
144
|
if computationDivisions == 'maximum':
|
|
145
145
|
taskDivisions = leavesTotal
|
|
@@ -298,8 +298,8 @@ def parseDimensions(dimensions: Sequence[int], parameterName: str = 'listDimensi
|
|
|
298
298
|
ValueError: If any dimension is negative or if the list is empty.
|
|
299
299
|
TypeError: If any element cannot be converted to integer (raised by `intInnit`).
|
|
300
300
|
"""
|
|
301
|
-
listValidated = intInnit(dimensions, parameterName)
|
|
302
|
-
listNonNegative = []
|
|
301
|
+
listValidated: list[int] = intInnit(dimensions, parameterName)
|
|
302
|
+
listNonNegative: list[int] = []
|
|
303
303
|
for dimension in listValidated:
|
|
304
304
|
if dimension < 0:
|
|
305
305
|
raise ValueError(f"Dimension {dimension} must be non-negative")
|
|
@@ -357,7 +357,7 @@ def setCPUlimit(CPUlimit: Any | None) -> int:
|
|
|
357
357
|
|
|
358
358
|
concurrencyLimit = int(defineConcurrencyLimit(CPUlimit))
|
|
359
359
|
set_num_threads(concurrencyLimit)
|
|
360
|
-
concurrencyLimit = get_num_threads()
|
|
360
|
+
concurrencyLimit: int = get_num_threads()
|
|
361
361
|
|
|
362
362
|
return concurrencyLimit
|
|
363
363
|
|
mapFolding/oeis.py
CHANGED
|
@@ -5,6 +5,7 @@ from mapFolding import countFolds, getPathPackage
|
|
|
5
5
|
from typing import Any, Final, TYPE_CHECKING
|
|
6
6
|
import argparse
|
|
7
7
|
import pathlib
|
|
8
|
+
from pathlib import Path
|
|
8
9
|
import random
|
|
9
10
|
import sys
|
|
10
11
|
import time
|
|
@@ -22,7 +23,7 @@ cacheDays = 7
|
|
|
22
23
|
"""
|
|
23
24
|
Section: make `settingsOEIS`"""
|
|
24
25
|
|
|
25
|
-
_pathCache = getPathPackage() / ".cache"
|
|
26
|
+
_pathCache: Path = getPathPackage() / ".cache"
|
|
26
27
|
|
|
27
28
|
class SettingsOEIS(TypedDict):
|
|
28
29
|
description: str
|
|
@@ -91,7 +92,7 @@ def validateOEISid(oeisIDcandidate: str) -> str:
|
|
|
91
92
|
if oeisIDcandidate in oeisIDsImplemented:
|
|
92
93
|
return oeisIDcandidate
|
|
93
94
|
else:
|
|
94
|
-
oeisIDcleaned = str(oeisIDcandidate).upper().strip()
|
|
95
|
+
oeisIDcleaned: str = str(oeisIDcandidate).upper().strip()
|
|
95
96
|
if oeisIDcleaned in oeisIDsImplemented:
|
|
96
97
|
return oeisIDcleaned
|
|
97
98
|
else:
|
|
@@ -123,12 +124,12 @@ def _parseBFileOEIS(OEISbFile: str, oeisID: str) -> dict[int, int]:
|
|
|
123
124
|
ValueError: If the first line of the file does not indicate the expected
|
|
124
125
|
sequence ID or if the content format is invalid.
|
|
125
126
|
"""
|
|
126
|
-
bFileLines = OEISbFile.strip().splitlines()
|
|
127
|
+
bFileLines: list[str] = OEISbFile.strip().splitlines()
|
|
127
128
|
if not bFileLines.pop(0).startswith(f"# {oeisID}"):
|
|
128
129
|
warnings.warn(f"Content does not match sequence {oeisID}")
|
|
129
130
|
return {-1: -1}
|
|
130
131
|
|
|
131
|
-
OEISsequence = {}
|
|
132
|
+
OEISsequence: dict[int, int] = {}
|
|
132
133
|
for line in bFileLines:
|
|
133
134
|
if line.startswith('#'):
|
|
134
135
|
continue
|
|
@@ -139,10 +140,10 @@ def _parseBFileOEIS(OEISbFile: str, oeisID: str) -> dict[int, int]:
|
|
|
139
140
|
def getOEISofficial(pathFilenameCache: pathlib.Path, url: str) -> None | str:
|
|
140
141
|
tryCache = False
|
|
141
142
|
if pathFilenameCache.exists():
|
|
142
|
-
fileAge = datetime.now() - datetime.fromtimestamp(pathFilenameCache.stat().st_mtime)
|
|
143
|
-
tryCache = fileAge < timedelta(days=cacheDays)
|
|
143
|
+
fileAge: timedelta = datetime.now() - datetime.fromtimestamp(pathFilenameCache.stat().st_mtime)
|
|
144
|
+
tryCache: bool = fileAge < timedelta(days=cacheDays)
|
|
144
145
|
|
|
145
|
-
oeisInformation = None
|
|
146
|
+
oeisInformation: str | None = None
|
|
146
147
|
if tryCache:
|
|
147
148
|
try:
|
|
148
149
|
oeisInformation = pathFilenameCache.read_text()
|
|
@@ -179,10 +180,10 @@ def getOEISidValues(oeisID: str) -> dict[int, int]:
|
|
|
179
180
|
IOError: If there is an error reading from or writing to the local cache.
|
|
180
181
|
"""
|
|
181
182
|
|
|
182
|
-
pathFilenameCache = _pathCache / getFilenameOEISbFile(oeisID)
|
|
183
|
-
url = f"https://oeis.org/{oeisID}/{getFilenameOEISbFile(oeisID)}"
|
|
183
|
+
pathFilenameCache: Path = _pathCache / getFilenameOEISbFile(oeisID)
|
|
184
|
+
url: str = f"https://oeis.org/{oeisID}/{getFilenameOEISbFile(oeisID)}"
|
|
184
185
|
|
|
185
|
-
oeisInformation = getOEISofficial(pathFilenameCache, url)
|
|
186
|
+
oeisInformation: None | str = getOEISofficial(pathFilenameCache, url)
|
|
186
187
|
|
|
187
188
|
if oeisInformation:
|
|
188
189
|
return _parseBFileOEIS(oeisInformation, oeisID)
|
|
@@ -190,15 +191,15 @@ def getOEISidValues(oeisID: str) -> dict[int, int]:
|
|
|
190
191
|
|
|
191
192
|
def getOEISidInformation(oeisID: str) -> tuple[str, int]:
|
|
192
193
|
oeisID = validateOEISid(oeisID)
|
|
193
|
-
pathFilenameCache = _pathCache / f"{oeisID}.txt"
|
|
194
|
-
url = f"https://oeis.org/search?q=id:{oeisID}&fmt=text"
|
|
194
|
+
pathFilenameCache: Path = _pathCache / f"{oeisID}.txt"
|
|
195
|
+
url: str = f"https://oeis.org/search?q=id:{oeisID}&fmt=text"
|
|
195
196
|
|
|
196
|
-
oeisInformation = getOEISofficial(pathFilenameCache, url)
|
|
197
|
+
oeisInformation: None | str = getOEISofficial(pathFilenameCache, url)
|
|
197
198
|
|
|
198
199
|
if not oeisInformation:
|
|
199
200
|
return "Not found", -1
|
|
200
201
|
|
|
201
|
-
description_parts = []
|
|
202
|
+
description_parts: list[str] = []
|
|
202
203
|
offset = None
|
|
203
204
|
for line in oeisInformation.splitlines():
|
|
204
205
|
if line.startswith('%N'):
|
|
@@ -207,9 +208,9 @@ def getOEISidInformation(oeisID: str) -> tuple[str, int]:
|
|
|
207
208
|
desc_part = ' '.join(parts[2:])
|
|
208
209
|
description_parts.append(desc_part)
|
|
209
210
|
elif line.startswith('%O'):
|
|
210
|
-
parts = line.split()
|
|
211
|
+
parts: list[str] = line.split()
|
|
211
212
|
if parts[1] == oeisID:
|
|
212
|
-
offset_str = parts[2].split(',')[0]
|
|
213
|
+
offset_str: str = parts[2].split(',')[0]
|
|
213
214
|
offset = int(offset_str)
|
|
214
215
|
if not description_parts:
|
|
215
216
|
warnings.warn(f"No description found for {oeisID}")
|
|
@@ -217,13 +218,13 @@ def getOEISidInformation(oeisID: str) -> tuple[str, int]:
|
|
|
217
218
|
if offset is None:
|
|
218
219
|
warnings.warn(f"No offset found for {oeisID}")
|
|
219
220
|
offset = -1
|
|
220
|
-
description = ' '.join(description_parts)
|
|
221
|
+
description: str = ' '.join(description_parts)
|
|
221
222
|
return description, offset
|
|
222
223
|
|
|
223
224
|
def makeSettingsOEIS() -> dict[str, SettingsOEIS]:
|
|
224
|
-
settingsTarget = {}
|
|
225
|
+
settingsTarget: dict[str, SettingsOEIS] = {}
|
|
225
226
|
for oeisID in oeisIDsImplemented:
|
|
226
|
-
valuesKnownSherpa = getOEISidValues(oeisID)
|
|
227
|
+
valuesKnownSherpa: dict[int, int] = getOEISidValues(oeisID)
|
|
227
228
|
descriptionSherpa, offsetSherpa = getOEISidInformation(oeisID)
|
|
228
229
|
settingsTarget[oeisID] = SettingsOEIS(
|
|
229
230
|
description=descriptionSherpa,
|
|
@@ -245,8 +246,8 @@ Section: private functions"""
|
|
|
245
246
|
|
|
246
247
|
def _formatHelpText() -> str:
|
|
247
248
|
"""Format standardized help text for both CLI and interactive use."""
|
|
248
|
-
exampleOEISid = oeisIDsImplemented[0]
|
|
249
|
-
exampleN = settingsOEIS[exampleOEISid]['valuesTestValidation'][-1]
|
|
249
|
+
exampleOEISid: str = oeisIDsImplemented[0]
|
|
250
|
+
exampleN: int = settingsOEIS[exampleOEISid]['valuesTestValidation'][-1]
|
|
250
251
|
|
|
251
252
|
return (
|
|
252
253
|
"\nAvailable OEIS sequences:\n"
|
|
@@ -269,7 +270,7 @@ def _formatOEISsequenceInfo() -> str:
|
|
|
269
270
|
"""
|
|
270
271
|
Section: public functions"""
|
|
271
272
|
|
|
272
|
-
def oeisIDfor_n(oeisID: str, n: int) -> int:
|
|
273
|
+
def oeisIDfor_n(oeisID: str, n: int | Any) -> int:
|
|
273
274
|
"""
|
|
274
275
|
Calculate a(n) of a sequence from "The On-Line Encyclopedia of Integer Sequences" (OEIS).
|
|
275
276
|
|
|
@@ -292,10 +293,10 @@ def oeisIDfor_n(oeisID: str, n: int) -> int:
|
|
|
292
293
|
listDimensions: list[int] = settingsOEIS[oeisID]['getMapShape'](n)
|
|
293
294
|
|
|
294
295
|
if n <= 1 or len(listDimensions) < 2:
|
|
295
|
-
offset = settingsOEIS[oeisID]['offset']
|
|
296
|
+
offset: int = settingsOEIS[oeisID]['offset']
|
|
296
297
|
if n < offset:
|
|
297
298
|
raise ArithmeticError(f"OEIS sequence {oeisID} is not defined at n={n}.")
|
|
298
|
-
foldsTotal = settingsOEIS[oeisID]['valuesKnown'][n]
|
|
299
|
+
foldsTotal: int = settingsOEIS[oeisID]['valuesKnown'][n]
|
|
299
300
|
return foldsTotal
|
|
300
301
|
|
|
301
302
|
return countFolds(listDimensions)
|
|
@@ -320,7 +321,7 @@ def OEIS_for_n() -> None:
|
|
|
320
321
|
print(f"Error: {ERRORmessage}", file=sys.stderr)
|
|
321
322
|
sys.exit(1)
|
|
322
323
|
|
|
323
|
-
timeElapsed = time.perf_counter() - timeStart
|
|
324
|
+
timeElapsed: float = time.perf_counter() - timeStart
|
|
324
325
|
print(f"Time elapsed: {timeElapsed:.3f} seconds")
|
|
325
326
|
|
|
326
327
|
def clearOEIScache() -> None:
|
mapFolding/theSSOT.py
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
from collections.abc import Callable
|
|
2
|
-
from mapFolding.theSSOTdatatypes import
|
|
3
|
-
EnumIndices,
|
|
4
|
-
indexMy,
|
|
5
|
-
indexTrack,
|
|
6
|
-
reportDatatypeLimit,
|
|
7
|
-
setDatatypeModule,
|
|
8
|
-
setDatatypeElephino,
|
|
9
|
-
setDatatypeFoldsTotal,
|
|
10
|
-
setDatatypeLeavesTotal,
|
|
11
|
-
getDatatypeModule,
|
|
12
|
-
setInStone,
|
|
13
|
-
hackSSOTdtype,
|
|
14
|
-
hackSSOTdatatype,
|
|
15
|
-
)
|
|
2
|
+
from mapFolding.theSSOTdatatypes import *
|
|
16
3
|
from numba.core.compiler import CompilerBase as numbaCompilerBase
|
|
17
4
|
from numpy import dtype, integer, ndarray
|
|
18
5
|
from pathlib import Path
|
|
@@ -45,6 +32,7 @@ myPackageNameIs = "mapFolding"
|
|
|
45
32
|
moduleOfSyntheticModules = "syntheticModules"
|
|
46
33
|
# TODO I'm not sure if this is the right tool for the job.
|
|
47
34
|
formatFilenameModuleDEFAULT = "numba_{callableTarget}.py"
|
|
35
|
+
# TODO figure out how to implement this
|
|
48
36
|
dispatcherCallableNameDEFAULT = "doTheNeedful"
|
|
49
37
|
|
|
50
38
|
def getPathPackage() -> Path:
|
|
@@ -133,7 +121,7 @@ class ParametersNumba(TypedDict):
|
|
|
133
121
|
nopython: bool
|
|
134
122
|
parallel: bool
|
|
135
123
|
pipeline_class: NotRequired[type[numbaCompilerBase]]
|
|
136
|
-
signature_or_function: NotRequired[Any | Callable | str | tuple]
|
|
124
|
+
signature_or_function: NotRequired[Any | Callable[..., Any] | str | tuple[Any, ...]]
|
|
137
125
|
target: NotRequired[str]
|
|
138
126
|
|
|
139
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,18 +1,8 @@
|
|
|
1
1
|
from collections import defaultdict
|
|
2
|
-
from typing import Any, cast, Final
|
|
2
|
+
from typing import Any, cast, Final
|
|
3
3
|
import enum
|
|
4
|
-
import numba
|
|
5
|
-
import numpy
|
|
6
|
-
|
|
7
|
-
try:
|
|
8
|
-
from typing import NotRequired
|
|
9
|
-
except Exception:
|
|
10
|
-
from typing_extensions import NotRequired # type: ignore
|
|
11
|
-
|
|
12
|
-
if TYPE_CHECKING:
|
|
13
|
-
from typing import TypedDict
|
|
14
|
-
else:
|
|
15
|
-
TypedDict = dict
|
|
4
|
+
import numba # type: ignore
|
|
5
|
+
import numpy # type: ignore
|
|
16
6
|
|
|
17
7
|
class EnumIndices(enum.IntEnum):
|
|
18
8
|
@staticmethod
|
|
@@ -51,7 +41,7 @@ _datatypeDefault: Final[dict[str, str]] = {
|
|
|
51
41
|
'foldsTotal': 'int64',
|
|
52
42
|
'leavesTotal': 'uint16',
|
|
53
43
|
}
|
|
54
|
-
_datatypeModule = ''
|
|
44
|
+
_datatypeModule: str = ''
|
|
55
45
|
_datatypeModuleDEFAULT: Final[str] = 'numpy'
|
|
56
46
|
|
|
57
47
|
_datatype: dict[str, str] = defaultdict(str)
|
|
@@ -103,12 +93,12 @@ def getDatatypeModule() -> str:
|
|
|
103
93
|
return _datatypeModule
|
|
104
94
|
|
|
105
95
|
def setInStone(identifier: str) -> type[Any]:
|
|
106
|
-
datatypeModule = getDatatypeModule()
|
|
107
|
-
datatypeStr = _get_datatype(identifier)
|
|
96
|
+
datatypeModule: str = getDatatypeModule()
|
|
97
|
+
datatypeStr: str = _get_datatype(identifier)
|
|
108
98
|
return cast(type[Any], getattr(eval(datatypeModule), datatypeStr))
|
|
109
99
|
|
|
110
100
|
def hackSSOTdtype(identifier: str) -> type[Any]:
|
|
111
|
-
_hackSSOTdtype={
|
|
101
|
+
_hackSSOTdtype: dict[str, str]={
|
|
112
102
|
'connectionGraph': 'dtypeLeavesTotal',
|
|
113
103
|
'dtypeElephino': 'dtypeElephino',
|
|
114
104
|
'dtypeFoldsTotal': 'dtypeFoldsTotal',
|
|
@@ -119,7 +109,7 @@ def hackSSOTdtype(identifier: str) -> type[Any]:
|
|
|
119
109
|
'my': 'dtypeElephino',
|
|
120
110
|
'track': 'dtypeElephino',
|
|
121
111
|
}
|
|
122
|
-
RubeGoldBerg = _hackSSOTdtype[identifier]
|
|
112
|
+
RubeGoldBerg: str = _hackSSOTdtype[identifier]
|
|
123
113
|
if RubeGoldBerg == 'dtypeElephino':
|
|
124
114
|
return setInStone('elephino')
|
|
125
115
|
elif RubeGoldBerg == 'dtypeFoldsTotal':
|
|
@@ -129,7 +119,7 @@ def hackSSOTdtype(identifier: str) -> type[Any]:
|
|
|
129
119
|
raise Exception("Dude, you forgot to set a value in `hackSSOTdtype`.")
|
|
130
120
|
|
|
131
121
|
def hackSSOTdatatype(identifier: str) -> str:
|
|
132
|
-
_hackSSOTdatatype={
|
|
122
|
+
_hackSSOTdatatype: dict[str, str]={
|
|
133
123
|
'connectionGraph': 'datatypeLeavesTotal',
|
|
134
124
|
'countDimensionsGapped': 'datatypeLeavesTotal',
|
|
135
125
|
'datatypeElephino': 'datatypeElephino',
|
|
@@ -156,7 +146,7 @@ def hackSSOTdatatype(identifier: str) -> str:
|
|
|
156
146
|
'taskIndex': 'datatypeLeavesTotal',
|
|
157
147
|
'track': 'datatypeElephino',
|
|
158
148
|
}
|
|
159
|
-
RubeGoldBerg = _hackSSOTdatatype[identifier]
|
|
149
|
+
RubeGoldBerg: str = _hackSSOTdatatype[identifier]
|
|
160
150
|
if RubeGoldBerg == 'datatypeElephino':
|
|
161
151
|
return _get_datatype('elephino')
|
|
162
152
|
elif RubeGoldBerg == 'datatypeFoldsTotal':
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: mapFolding
|
|
3
|
-
Version: 0.5.
|
|
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,6 +33,7 @@ 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"
|
|
@@ -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,,
|