mapFolding 0.4.1__py3-none-any.whl → 0.4.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.
- mapFolding/__init__.py +2 -1
- mapFolding/basecamp.py +1 -1
- mapFolding/beDRY.py +120 -113
- mapFolding/oeis.py +18 -17
- mapFolding/someAssemblyRequired/synthesizeNumba.py +41 -48
- mapFolding/someAssemblyRequired/synthesizeNumbaGeneralized.py +83 -12
- mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +12 -23
- mapFolding/someAssemblyRequired/synthesizeNumbaModules.py +82 -30
- mapFolding/syntheticModules/numbaCount.py +158 -0
- mapFolding/syntheticModules/numba_doTheNeedful.py +5 -12
- mapFolding/theDao.py +76 -73
- mapFolding/theSSOT.py +50 -189
- mapFolding/theSSOTdatatypes.py +168 -0
- {mapFolding-0.4.1.dist-info → mapFolding-0.4.3.dist-info}/METADATA +1 -1
- mapFolding-0.4.3.dist-info/RECORD +40 -0
- tests/conftest.py +30 -31
- tests/test_computations.py +27 -63
- tests/test_oeis.py +7 -10
- mapFolding/syntheticModules/numba_countInitialize.py +0 -52
- mapFolding/syntheticModules/numba_countParallel.py +0 -65
- mapFolding/syntheticModules/numba_countSequential.py +0 -67
- mapFolding/theSSOTnumba.py +0 -132
- mapFolding-0.4.1.dist-info/RECORD +0 -42
- {mapFolding-0.4.1.dist-info → mapFolding-0.4.3.dist-info}/LICENSE +0 -0
- {mapFolding-0.4.1.dist-info → mapFolding-0.4.3.dist-info}/WHEEL +0 -0
- {mapFolding-0.4.1.dist-info → mapFolding-0.4.3.dist-info}/entry_points.txt +0 -0
- {mapFolding-0.4.1.dist-info → mapFolding-0.4.3.dist-info}/top_level.txt +0 -0
tests/test_computations.py
CHANGED
|
@@ -13,67 +13,31 @@ def test_aOFn_calculate_value(oeisID: str) -> None:
|
|
|
13
13
|
for n in settingsOEIS[oeisID]['valuesTestValidation']:
|
|
14
14
|
standardizedEqualTo(settingsOEIS[oeisID]['valuesKnown'][n], oeisIDfor_n, oeisID, n)
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# the _logical_ import must be in the logical path of the package
|
|
42
|
-
# fuck python
|
|
43
|
-
# """
|
|
44
|
-
# listCallablesInlineHARDCODED: List[str] = ['countInitialize', 'countParallel', 'countSequential']
|
|
45
|
-
# listCallablesInline = listCallablesInlineHARDCODED
|
|
46
|
-
# callableDispatcher = True
|
|
47
|
-
# algorithmSource = None
|
|
48
|
-
# relativePathWrite = None
|
|
49
|
-
# # relativePathWrite = pathTmpTesting.absolute().relative_to(getPathPackage(), walk_up=True)
|
|
50
|
-
# formatFilenameWrite = "pytest_{callableTarget}"
|
|
51
|
-
# listSynthesizedModules: List[youOughtaKnow] = makeFlowNumbaOptimized(listCallablesInline, callableDispatcher, algorithmSource, relativePathWrite, formatFilenameWrite)
|
|
52
|
-
# for stuff in listSynthesizedModules:
|
|
53
|
-
# registrarRecordsTmpObject(stuff.pathFilenameForMe)
|
|
54
|
-
# if stuff.callableSynthesized not in listCallablesInline:
|
|
55
|
-
# dispatcherSynthetic: youOughtaKnow = stuff
|
|
56
|
-
# if not dispatcherSynthetic: raise FREAKOUT
|
|
57
|
-
# # dispatcherSynthetic: youOughtaKnow = next(filter(lambda x: x.callableSynthesized not in listCallablesInline, listSynthesizedModules))
|
|
58
|
-
|
|
59
|
-
# # Import the synthetic dispatcher module to get the callable
|
|
60
|
-
# dispatcherSpec = importlib.util.spec_from_file_location(
|
|
61
|
-
# dispatcherSynthetic.callableSynthesized,
|
|
62
|
-
# dispatcherSynthetic.pathFilenameForMe
|
|
63
|
-
# )
|
|
64
|
-
# if dispatcherSpec is None:
|
|
65
|
-
# raise ImportError(f"Failed to create module specification from {dispatcherSynthetic.pathFilenameForMe}")
|
|
66
|
-
# if dispatcherSpec.loader is None:
|
|
67
|
-
# raise ImportError(f"Failed to get loader for module {dispatcherSynthetic.pathFilenameForMe}")
|
|
68
|
-
|
|
69
|
-
# dispatcherModule = importlib.util.module_from_spec(dispatcherSpec)
|
|
70
|
-
# dispatcherSpec.loader.exec_module(dispatcherModule)
|
|
71
|
-
# callableDispatcherSynthetic = getattr(dispatcherModule, dispatcherSynthetic.callableSynthesized)
|
|
72
|
-
|
|
73
|
-
# useThisDispatcher(callableDispatcherSynthetic)
|
|
74
|
-
|
|
75
|
-
# def test_syntheticSequential(listDimensionsTestCountFolds: List[int], foldsTotalKnown: Dict[Tuple[int, ...], int]):
|
|
76
|
-
# standardizedEqualTo(foldsTotalKnown[tuple(listDimensionsTestCountFolds)], countFolds, listDimensionsTestCountFolds)
|
|
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')
|
|
77
41
|
|
|
78
|
-
|
|
79
|
-
|
|
42
|
+
def test_syntheticSequential(syntheticDispatcherFixture, listDimensionsTestCountFolds: List[int], foldsTotalKnown: Dict[Tuple[int, ...], int]):
|
|
43
|
+
standardizedEqualTo(foldsTotalKnown[tuple(listDimensionsTestCountFolds)], countFolds, listDimensionsTestCountFolds)
|
tests/test_oeis.py
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
from contextlib import redirect_stdout
|
|
2
|
-
from datetime import datetime, timedelta
|
|
3
|
-
from mapFolding.oeis import _getFilenameOEISbFile, _getOEISidValues, _parseBFileOEIS, _validateOEISid, _getOEISidInformation
|
|
4
2
|
from tests.conftest import *
|
|
5
3
|
from urllib.error import URLError
|
|
6
4
|
import io
|
|
7
|
-
import os
|
|
8
5
|
import pathlib
|
|
9
6
|
import pytest
|
|
10
7
|
import random
|
|
@@ -16,18 +13,18 @@ import urllib.request
|
|
|
16
13
|
|
|
17
14
|
@pytest.mark.parametrize("badID", ["A999999", " A999999 ", "A999999extra"])
|
|
18
15
|
def test__validateOEISid_invalid_id(badID: str) -> None:
|
|
19
|
-
standardizedEqualTo(KeyError,
|
|
16
|
+
standardizedEqualTo(KeyError, validateOEISid, badID)
|
|
20
17
|
|
|
21
18
|
def test__validateOEISid_partially_valid(oeisID_1random: str) -> None:
|
|
22
|
-
standardizedEqualTo(KeyError,
|
|
19
|
+
standardizedEqualTo(KeyError, validateOEISid, f"{oeisID_1random}extra")
|
|
23
20
|
|
|
24
21
|
def test__validateOEISid_valid_id(oeisID: str) -> None:
|
|
25
|
-
standardizedEqualTo(oeisID,
|
|
22
|
+
standardizedEqualTo(oeisID, validateOEISid, oeisID)
|
|
26
23
|
|
|
27
24
|
def test__validateOEISid_valid_id_case_insensitive(oeisID: str) -> None:
|
|
28
|
-
standardizedEqualTo(oeisID.upper(),
|
|
29
|
-
standardizedEqualTo(oeisID.upper(),
|
|
30
|
-
standardizedEqualTo(oeisID.upper(),
|
|
25
|
+
standardizedEqualTo(oeisID.upper(), validateOEISid, oeisID.lower())
|
|
26
|
+
standardizedEqualTo(oeisID.upper(), validateOEISid, oeisID.upper())
|
|
27
|
+
standardizedEqualTo(oeisID.upper(), validateOEISid, oeisID.swapcase())
|
|
31
28
|
|
|
32
29
|
parameters_test_aOFn_invalid_n = [
|
|
33
30
|
# (2, "ok"), # test the test template
|
|
@@ -68,7 +65,7 @@ def testNetworkError(monkeypatch: pytest.MonkeyPatch, pathCacheTesting: pathlib.
|
|
|
68
65
|
raise URLError("Network error")
|
|
69
66
|
|
|
70
67
|
monkeypatch.setattr(urllib.request, 'urlopen', mockUrlopen)
|
|
71
|
-
standardizedEqualTo(URLError,
|
|
68
|
+
standardizedEqualTo(URLError, getOEISidValues, next(iter(settingsOEIS)))
|
|
72
69
|
|
|
73
70
|
# ===== Command Line Interface Tests =====
|
|
74
71
|
def testHelpText() -> None:
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
from mapFolding import indexMy
|
|
2
|
-
from mapFolding import indexTrack
|
|
3
|
-
from numba import jit
|
|
4
|
-
from numba import uint8
|
|
5
|
-
from numpy import ndarray
|
|
6
|
-
from numpy import integer
|
|
7
|
-
from numpy import dtype
|
|
8
|
-
from typing import Tuple
|
|
9
|
-
from typing import Any
|
|
10
|
-
|
|
11
|
-
@jit((uint8[:, :, ::1], uint8[::1], uint8[::1], uint8[:, ::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)
|
|
12
|
-
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:
|
|
13
|
-
while my[indexMy.leaf1ndex.value]:
|
|
14
|
-
if my[indexMy.leaf1ndex.value] <= 1 or track[indexTrack.leafBelow.value, 0] == 1:
|
|
15
|
-
my[indexMy.dimensionsUnconstrained.value] = my[indexMy.dimensionsTotal.value]
|
|
16
|
-
my[indexMy.gap1ndexCeiling.value] = track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
|
|
17
|
-
my[indexMy.indexDimension.value] = 0
|
|
18
|
-
while my[indexMy.indexDimension.value] < my[indexMy.dimensionsTotal.value]:
|
|
19
|
-
if connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]] == my[indexMy.leaf1ndex.value]:
|
|
20
|
-
my[indexMy.dimensionsUnconstrained.value] -= 1
|
|
21
|
-
else:
|
|
22
|
-
my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]]
|
|
23
|
-
while my[indexMy.leafConnectee.value] != my[indexMy.leaf1ndex.value]:
|
|
24
|
-
gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.leafConnectee.value]
|
|
25
|
-
if track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] == 0:
|
|
26
|
-
my[indexMy.gap1ndexCeiling.value] += 1
|
|
27
|
-
track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] += 1
|
|
28
|
-
my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], track[indexTrack.leafBelow.value, my[indexMy.leafConnectee.value]]]
|
|
29
|
-
my[indexMy.indexDimension.value] += 1
|
|
30
|
-
if not my[indexMy.dimensionsUnconstrained.value]:
|
|
31
|
-
my[indexMy.indexLeaf.value] = 0
|
|
32
|
-
while my[indexMy.indexLeaf.value] < my[indexMy.leaf1ndex.value]:
|
|
33
|
-
gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.indexLeaf.value]
|
|
34
|
-
my[indexMy.gap1ndexCeiling.value] += 1
|
|
35
|
-
my[indexMy.indexLeaf.value] += 1
|
|
36
|
-
my[indexMy.indexMiniGap.value] = my[indexMy.gap1ndex.value]
|
|
37
|
-
while my[indexMy.indexMiniGap.value] < my[indexMy.gap1ndexCeiling.value]:
|
|
38
|
-
gapsWhere[my[indexMy.gap1ndex.value]] = gapsWhere[my[indexMy.indexMiniGap.value]]
|
|
39
|
-
if track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] == my[indexMy.dimensionsUnconstrained.value]:
|
|
40
|
-
my[indexMy.gap1ndex.value] += 1
|
|
41
|
-
track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] = 0
|
|
42
|
-
my[indexMy.indexMiniGap.value] += 1
|
|
43
|
-
if my[indexMy.leaf1ndex.value]:
|
|
44
|
-
my[indexMy.gap1ndex.value] -= 1
|
|
45
|
-
track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]] = gapsWhere[my[indexMy.gap1ndex.value]]
|
|
46
|
-
track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]] = track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]]
|
|
47
|
-
track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
|
|
48
|
-
track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
|
|
49
|
-
track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value]] = my[indexMy.gap1ndex.value]
|
|
50
|
-
my[indexMy.leaf1ndex.value] += 1
|
|
51
|
-
if my[indexMy.gap1ndex.value] > 0:
|
|
52
|
-
return
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
from mapFolding import indexMy
|
|
2
|
-
from mapFolding import indexTrack
|
|
3
|
-
from numba import jit
|
|
4
|
-
from numba import uint8
|
|
5
|
-
from numba import int64
|
|
6
|
-
from numba import prange
|
|
7
|
-
from numpy import ndarray
|
|
8
|
-
from numpy import integer
|
|
9
|
-
from numpy import dtype
|
|
10
|
-
from typing import Tuple
|
|
11
|
-
from typing import Any
|
|
12
|
-
|
|
13
|
-
@jit((uint8[:, :, ::1], int64[::1], uint8[::1], uint8[::1], uint8[:, ::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)
|
|
14
|
-
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:
|
|
15
|
-
gapsWherePARALLEL = gapsWhere.copy()
|
|
16
|
-
myPARALLEL = my.copy()
|
|
17
|
-
trackPARALLEL = track.copy()
|
|
18
|
-
taskDivisionsPrange = myPARALLEL[indexMy.taskDivisions.value]
|
|
19
|
-
for indexSherpa in prange(taskDivisionsPrange):
|
|
20
|
-
groupsOfFolds: int = 0
|
|
21
|
-
gapsWhere = gapsWherePARALLEL.copy()
|
|
22
|
-
my = myPARALLEL.copy()
|
|
23
|
-
track = trackPARALLEL.copy()
|
|
24
|
-
my[indexMy.taskIndex.value] = indexSherpa
|
|
25
|
-
while my[indexMy.leaf1ndex.value]:
|
|
26
|
-
if my[indexMy.leaf1ndex.value] <= 1 or track[indexTrack.leafBelow.value, 0] == 1:
|
|
27
|
-
if my[indexMy.leaf1ndex.value] > foldGroups[-1]:
|
|
28
|
-
groupsOfFolds += 1
|
|
29
|
-
else:
|
|
30
|
-
my[indexMy.dimensionsUnconstrained.value] = my[indexMy.dimensionsTotal.value]
|
|
31
|
-
my[indexMy.gap1ndexCeiling.value] = track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
|
|
32
|
-
my[indexMy.indexDimension.value] = 0
|
|
33
|
-
while my[indexMy.indexDimension.value] < my[indexMy.dimensionsTotal.value]:
|
|
34
|
-
if connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]] == my[indexMy.leaf1ndex.value]:
|
|
35
|
-
my[indexMy.dimensionsUnconstrained.value] -= 1
|
|
36
|
-
else:
|
|
37
|
-
my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]]
|
|
38
|
-
while my[indexMy.leafConnectee.value] != my[indexMy.leaf1ndex.value]:
|
|
39
|
-
if my[indexMy.leaf1ndex.value] != my[indexMy.taskDivisions.value] or my[indexMy.leafConnectee.value] % my[indexMy.taskDivisions.value] == my[indexMy.taskIndex.value]:
|
|
40
|
-
gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.leafConnectee.value]
|
|
41
|
-
if track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] == 0:
|
|
42
|
-
my[indexMy.gap1ndexCeiling.value] += 1
|
|
43
|
-
track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] += 1
|
|
44
|
-
my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.indexDimension.value], my[indexMy.leaf1ndex.value], track[indexTrack.leafBelow.value, my[indexMy.leafConnectee.value]]]
|
|
45
|
-
my[indexMy.indexDimension.value] += 1
|
|
46
|
-
my[indexMy.indexMiniGap.value] = my[indexMy.gap1ndex.value]
|
|
47
|
-
while my[indexMy.indexMiniGap.value] < my[indexMy.gap1ndexCeiling.value]:
|
|
48
|
-
gapsWhere[my[indexMy.gap1ndex.value]] = gapsWhere[my[indexMy.indexMiniGap.value]]
|
|
49
|
-
if track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] == my[indexMy.dimensionsUnconstrained.value]:
|
|
50
|
-
my[indexMy.gap1ndex.value] += 1
|
|
51
|
-
track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] = 0
|
|
52
|
-
my[indexMy.indexMiniGap.value] += 1
|
|
53
|
-
while my[indexMy.leaf1ndex.value] and my[indexMy.gap1ndex.value] == track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]:
|
|
54
|
-
my[indexMy.leaf1ndex.value] -= 1
|
|
55
|
-
track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]
|
|
56
|
-
track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]
|
|
57
|
-
if my[indexMy.leaf1ndex.value]:
|
|
58
|
-
my[indexMy.gap1ndex.value] -= 1
|
|
59
|
-
track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]] = gapsWhere[my[indexMy.gap1ndex.value]]
|
|
60
|
-
track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]] = track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]]
|
|
61
|
-
track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
|
|
62
|
-
track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
|
|
63
|
-
track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value]] = my[indexMy.gap1ndex.value]
|
|
64
|
-
my[indexMy.leaf1ndex.value] += 1
|
|
65
|
-
foldGroups[my[indexMy.taskIndex.value]] = groupsOfFolds
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
from mapFolding import indexMy
|
|
2
|
-
from mapFolding import indexTrack
|
|
3
|
-
from numba import jit
|
|
4
|
-
from numba import uint8
|
|
5
|
-
from numba import int64
|
|
6
|
-
from numpy import ndarray
|
|
7
|
-
from numpy import integer
|
|
8
|
-
from numpy import dtype
|
|
9
|
-
from typing import Tuple
|
|
10
|
-
from typing import Any
|
|
11
|
-
|
|
12
|
-
@jit((uint8[:, :, ::1], int64[::1], uint8[::1], uint8[::1], uint8[:, ::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)
|
|
13
|
-
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:
|
|
14
|
-
leafBelow = track[indexTrack.leafBelow.value]
|
|
15
|
-
gapRangeStart = track[indexTrack.gapRangeStart.value]
|
|
16
|
-
countDimensionsGapped = track[indexTrack.countDimensionsGapped.value]
|
|
17
|
-
leafAbove = track[indexTrack.leafAbove.value]
|
|
18
|
-
leaf1ndex = my[indexMy.leaf1ndex.value]
|
|
19
|
-
dimensionsUnconstrained = my[indexMy.dimensionsUnconstrained.value]
|
|
20
|
-
dimensionsTotal = my[indexMy.dimensionsTotal.value]
|
|
21
|
-
gap1ndexCeiling = my[indexMy.gap1ndexCeiling.value]
|
|
22
|
-
indexDimension = my[indexMy.indexDimension.value]
|
|
23
|
-
leafConnectee = my[indexMy.leafConnectee.value]
|
|
24
|
-
indexMiniGap = my[indexMy.indexMiniGap.value]
|
|
25
|
-
gap1ndex = my[indexMy.gap1ndex.value]
|
|
26
|
-
taskIndex = my[indexMy.taskIndex.value]
|
|
27
|
-
groupsOfFolds: int = 0
|
|
28
|
-
while leaf1ndex:
|
|
29
|
-
if leaf1ndex <= 1 or leafBelow[0] == 1:
|
|
30
|
-
if leaf1ndex > foldGroups[-1]:
|
|
31
|
-
groupsOfFolds += 1
|
|
32
|
-
else:
|
|
33
|
-
dimensionsUnconstrained = dimensionsTotal
|
|
34
|
-
gap1ndexCeiling = gapRangeStart[leaf1ndex - 1]
|
|
35
|
-
indexDimension = 0
|
|
36
|
-
while indexDimension < dimensionsTotal:
|
|
37
|
-
if connectionGraph[indexDimension, leaf1ndex, leaf1ndex] == leaf1ndex:
|
|
38
|
-
dimensionsUnconstrained -= 1
|
|
39
|
-
else:
|
|
40
|
-
leafConnectee = connectionGraph[indexDimension, leaf1ndex, leaf1ndex]
|
|
41
|
-
while leafConnectee != leaf1ndex:
|
|
42
|
-
gapsWhere[gap1ndexCeiling] = leafConnectee
|
|
43
|
-
if countDimensionsGapped[leafConnectee] == 0:
|
|
44
|
-
gap1ndexCeiling += 1
|
|
45
|
-
countDimensionsGapped[leafConnectee] += 1
|
|
46
|
-
leafConnectee = connectionGraph[indexDimension, leaf1ndex, leafBelow[leafConnectee]]
|
|
47
|
-
indexDimension += 1
|
|
48
|
-
indexMiniGap = gap1ndex
|
|
49
|
-
while indexMiniGap < gap1ndexCeiling:
|
|
50
|
-
gapsWhere[gap1ndex] = gapsWhere[indexMiniGap]
|
|
51
|
-
if countDimensionsGapped[gapsWhere[indexMiniGap]] == dimensionsUnconstrained:
|
|
52
|
-
gap1ndex += 1
|
|
53
|
-
countDimensionsGapped[gapsWhere[indexMiniGap]] = 0
|
|
54
|
-
indexMiniGap += 1
|
|
55
|
-
while leaf1ndex and gap1ndex == gapRangeStart[leaf1ndex - 1]:
|
|
56
|
-
leaf1ndex -= 1
|
|
57
|
-
leafBelow[leafAbove[leaf1ndex]] = leafBelow[leaf1ndex]
|
|
58
|
-
leafAbove[leafBelow[leaf1ndex]] = leafAbove[leaf1ndex]
|
|
59
|
-
if leaf1ndex:
|
|
60
|
-
gap1ndex -= 1
|
|
61
|
-
leafAbove[leaf1ndex] = gapsWhere[gap1ndex]
|
|
62
|
-
leafBelow[leaf1ndex] = leafBelow[leafAbove[leaf1ndex]]
|
|
63
|
-
leafBelow[leafAbove[leaf1ndex]] = leaf1ndex
|
|
64
|
-
leafAbove[leafBelow[leaf1ndex]] = leaf1ndex
|
|
65
|
-
gapRangeStart[leaf1ndex] = gap1ndex
|
|
66
|
-
leaf1ndex += 1
|
|
67
|
-
foldGroups[taskIndex] = groupsOfFolds
|
mapFolding/theSSOTnumba.py
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"""I have so much truth, I need two files to contain it all!"""
|
|
2
|
-
"""TODO learn how to use this efficiently and effectively to solve problems, be DRY, and have SSOT."""
|
|
3
|
-
from typing import Final, TYPE_CHECKING, Dict, Any, Union, Callable, Tuple, Any
|
|
4
|
-
import numba
|
|
5
|
-
import numba.core.compiler
|
|
6
|
-
try:
|
|
7
|
-
from typing import NotRequired
|
|
8
|
-
except ImportError:
|
|
9
|
-
from typing_extensions import NotRequired
|
|
10
|
-
|
|
11
|
-
if TYPE_CHECKING:
|
|
12
|
-
from typing import TypedDict
|
|
13
|
-
else:
|
|
14
|
-
TypedDict = dict
|
|
15
|
-
|
|
16
|
-
"""
|
|
17
|
-
Old notes that are not entirely accurate.
|
|
18
|
-
|
|
19
|
-
| **Option** | **Description** | **Why** | **Size** | **But** |
|
|
20
|
-
| ----------------------- | --------------------------------------------------- | --------------------- | --------------- | ------------------------ |
|
|
21
|
-
| `_dbg_extend_lifetimes` | Debug option to extend object lifetimes | Debugging | | |
|
|
22
|
-
| `_dbg_optnone` | Disable optimization for debugging | Debugging | | |
|
|
23
|
-
| `debug` | Enable debug mode with additional checks | Debugging | | |
|
|
24
|
-
| `no_rewrites` | Disable AST rewrites optimization | Debugging | | |
|
|
25
|
-
| `boundscheck` | Enable array bounds checking (slows execution) | Error checking | Larger | Slower |
|
|
26
|
-
| `error_model` | Divide by zero: kill or chill? | Error checking | ? | |
|
|
27
|
-
| `_nrt` | Enable No Runtime type checking | Startup speed | Smaller | No type protection |
|
|
28
|
-
| `fastmath` | Reduce float potential precision | Float speed | Smaller | Discriminatory, untested |
|
|
29
|
-
| `forceinline` | Force function inlining | Reduce function calls | Likely larger | |
|
|
30
|
-
| `forceobj` | Force object mode compilation | Inclusiveness | Larger | Slower execution |
|
|
31
|
-
| `inline` | Algorithmically choose inlining | Speed | Slightly larger | |
|
|
32
|
-
| `looplift` | Enable loop lifting optimization | Speed (if applicable) | Larger | Exclusionary |
|
|
33
|
-
| `no_cfunc_wrapper` | Disable C function wrapper generation | Size | Smaller | Exclusionary |
|
|
34
|
-
| `no_cpython_wrapper` | Disable Python C-API wrapper generation | Size | Smallest | Exclusionary |
|
|
35
|
-
|
|
36
|
-
"""
|
|
37
|
-
# NOTE Deepseek removed forceinline=True, inline='always'
|
|
38
|
-
# TODO try to implement all possible parameters, but use `NotRequired` for the more esoteric ones
|
|
39
|
-
class ParametersNumba(TypedDict):
|
|
40
|
-
_dbg_extend_lifetimes: NotRequired[bool]
|
|
41
|
-
_dbg_optnone: NotRequired[bool]
|
|
42
|
-
_nrt: NotRequired[bool]
|
|
43
|
-
boundscheck: NotRequired[bool]
|
|
44
|
-
cache: bool
|
|
45
|
-
debug: NotRequired[bool]
|
|
46
|
-
error_model: str
|
|
47
|
-
fastmath: bool
|
|
48
|
-
forceinline: bool
|
|
49
|
-
forceobj: NotRequired[bool]
|
|
50
|
-
inline: str
|
|
51
|
-
locals: NotRequired[Dict[str, Any]]
|
|
52
|
-
looplift: bool
|
|
53
|
-
no_cfunc_wrapper: bool
|
|
54
|
-
no_cpython_wrapper: bool
|
|
55
|
-
no_rewrites: NotRequired[bool]
|
|
56
|
-
nogil: NotRequired[bool]
|
|
57
|
-
nopython: bool
|
|
58
|
-
parallel: bool
|
|
59
|
-
pipeline_class: NotRequired[numba.core.compiler.CompilerBase]
|
|
60
|
-
signature_or_function: NotRequired[Union[Any, Callable, str, Tuple]]
|
|
61
|
-
target: NotRequired[str]
|
|
62
|
-
|
|
63
|
-
parametersNumbaFailEarly: Final[ParametersNumba] = {
|
|
64
|
-
'_nrt': True,
|
|
65
|
-
'boundscheck': True,
|
|
66
|
-
'cache': True,
|
|
67
|
-
'error_model': 'python',
|
|
68
|
-
'fastmath': False,
|
|
69
|
-
'forceinline': True,
|
|
70
|
-
'inline': 'always',
|
|
71
|
-
'looplift': False,
|
|
72
|
-
'no_cfunc_wrapper': False,
|
|
73
|
-
'no_cpython_wrapper': False,
|
|
74
|
-
'nopython': True,
|
|
75
|
-
'parallel': False,
|
|
76
|
-
}
|
|
77
|
-
"""For a production function: speed is irrelevant, error discovery is paramount, must be compatible with anything downstream."""
|
|
78
|
-
|
|
79
|
-
parametersNumbaDEFAULT: Final[ParametersNumba] = {
|
|
80
|
-
'_nrt': True,
|
|
81
|
-
'boundscheck': False,
|
|
82
|
-
'cache': True,
|
|
83
|
-
'error_model': 'numpy',
|
|
84
|
-
'fastmath': True,
|
|
85
|
-
'forceinline': True,
|
|
86
|
-
'inline': 'always',
|
|
87
|
-
'looplift': False,
|
|
88
|
-
'no_cfunc_wrapper': False,
|
|
89
|
-
'no_cpython_wrapper': False,
|
|
90
|
-
'nopython': True,
|
|
91
|
-
'parallel': False,
|
|
92
|
-
}
|
|
93
|
-
"""Middle of the road: fast, lean, but will talk to non-jitted functions."""
|
|
94
|
-
|
|
95
|
-
parametersNumbaParallelDEFAULT: Final[ParametersNumba] = {
|
|
96
|
-
**parametersNumbaDEFAULT,
|
|
97
|
-
'_nrt': True,
|
|
98
|
-
'parallel': True,
|
|
99
|
-
}
|
|
100
|
-
"""Middle of the road: fast, lean, but will talk to non-jitted functions."""
|
|
101
|
-
|
|
102
|
-
parametersNumbaSuperJit: Final[ParametersNumba] = {
|
|
103
|
-
**parametersNumbaDEFAULT,
|
|
104
|
-
'no_cfunc_wrapper': True,
|
|
105
|
-
'no_cpython_wrapper': True,
|
|
106
|
-
}
|
|
107
|
-
"""Speed, no helmet, no talking to non-jitted functions."""
|
|
108
|
-
|
|
109
|
-
parametersNumbaSuperJitParallel: Final[ParametersNumba] = {
|
|
110
|
-
**parametersNumbaSuperJit,
|
|
111
|
-
'_nrt': True,
|
|
112
|
-
'parallel': True,
|
|
113
|
-
}
|
|
114
|
-
"""Speed, no helmet, concurrency, no talking to non-jitted functions.
|
|
115
|
-
Claude says, "The NRT is Numba's memory management system that handles memory allocation and deallocation for array operations. Because of array copying, you need to have NRT enabled." IDK which AI assistant autocompleted this, but, "The NRT is a bit slower than the default memory management system, but it's necessary for certain operations."
|
|
116
|
-
"""
|
|
117
|
-
|
|
118
|
-
parametersNumbaMinimum: Final[ParametersNumba] = {
|
|
119
|
-
'_nrt': True,
|
|
120
|
-
'boundscheck': True,
|
|
121
|
-
'cache': True,
|
|
122
|
-
'error_model': 'numpy',
|
|
123
|
-
'fastmath': True,
|
|
124
|
-
'forceinline': False,
|
|
125
|
-
'inline': 'always',
|
|
126
|
-
'looplift': False,
|
|
127
|
-
'no_cfunc_wrapper': False,
|
|
128
|
-
'no_cpython_wrapper': False,
|
|
129
|
-
'nopython': False,
|
|
130
|
-
'forceobj': True,
|
|
131
|
-
'parallel': False,
|
|
132
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
mapFolding/__init__.py,sha256=_YjoypHXmWLmEWwhFVgKO83Uf28ksesT9F73oJoAIPE,1323
|
|
2
|
-
mapFolding/basecamp.py,sha256=v0VCF_Zgm_XBHcz4bqblsxfHwAxZKgenW6um77quWLk,3751
|
|
3
|
-
mapFolding/beDRY.py,sha256=XVtLraG9VnC4yG2HkaFwZRh2td4ZHMjTQvnbcD_W130,17133
|
|
4
|
-
mapFolding/oeis.py,sha256=3hv71o8bhckjY0nsSY5JTJ2LrpJcuhZ9j3mP6LWLIQc,11124
|
|
5
|
-
mapFolding/theDao.py,sha256=SmyTbP1iwRAnpuq2ngdJKooXUA1_PR0VRHQ4fcJskMY,12713
|
|
6
|
-
mapFolding/theSSOT.py,sha256=QrEMPREjEbt1H8HcrM2Nm_hv7JsFWRG3lHdUU0Jrv-w,10238
|
|
7
|
-
mapFolding/theSSOTnumba.py,sha256=zGq2zlZZeuxiNSO2Fs_AqV6UhybJAJuDw-2lMVvDS2w,5133
|
|
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=mPCjp4N-dOJRC4TvZGkqAqFKDWEPhWH9v0Cq5AWHlBA,17279
|
|
22
|
-
mapFolding/someAssemblyRequired/synthesizeNumbaGeneralized.py,sha256=k8IaCT74ZPhHyra0MbCRdt_5k0Ov3vJgXlN5tbLVnf4,13998
|
|
23
|
-
mapFolding/someAssemblyRequired/synthesizeNumbaJob.py,sha256=2sKZgc5kyyz2KaoApcazj_37UgBqAkxORFeROWWU5tk,9038
|
|
24
|
-
mapFolding/someAssemblyRequired/synthesizeNumbaModules.py,sha256=_iRXjMASB_BnYJeH8Rt7FlC-GE7lkZ1Hy292XTaUCu4,3785
|
|
25
|
-
mapFolding/syntheticModules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
-
mapFolding/syntheticModules/numba_countInitialize.py,sha256=geHketfekZTgu5gbc8E3SShPmbW3gDybg5PCBpXdsa8,4274
|
|
27
|
-
mapFolding/syntheticModules/numba_countParallel.py,sha256=kOI5PU90AExPvlWwU0BHVVFjlHlmUFp1KdtlmthQ71E,5517
|
|
28
|
-
mapFolding/syntheticModules/numba_countSequential.py,sha256=zFFRv9oLtOih9TpbtARpVAPt-NfZxh0ygXuj-wfPjUg,3732
|
|
29
|
-
mapFolding/syntheticModules/numba_doTheNeedful.py,sha256=6WuXKDMVa_C56dLlmXNvFl04MlU8-WVasqbAaxsgI-o,1368
|
|
30
|
-
tests/__init__.py,sha256=eg9smg-6VblOr0kisM40CpGnuDtU2JgEEWGDTFVOlW8,57
|
|
31
|
-
tests/conftest.py,sha256=7Ims3QcOzqBXu_k0kX9bt6PieC-OoIpc7OGxzdT2ELc,11826
|
|
32
|
-
tests/test_computations.py,sha256=qBha4IggMfr6ZH06W3M66enTA6PWsx8vkDp5eqYFM9M,4765
|
|
33
|
-
tests/test_oeis.py,sha256=31kdO1vnu2Lon43vM-YJVS4g40Ic03DWNER-cJcpxX4,4916
|
|
34
|
-
tests/test_other.py,sha256=u0vINT5EyVsXTNTR2DZIMpWCg4FH471jjHLRzC2JX7U,8351
|
|
35
|
-
tests/test_tasks.py,sha256=iq6_dh43JQkC2vAWXua0Xe915BKFGbvRJAkmbco854A,2389
|
|
36
|
-
tests/test_types.py,sha256=58tmPG9WOeGGAQbdQK_h_7t4SnENnZugH4WXlI8-L-M,171
|
|
37
|
-
mapFolding-0.4.1.dist-info/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
|
|
38
|
-
mapFolding-0.4.1.dist-info/METADATA,sha256=iJiWfEzXVheLtyLLWT2BNis5xsisnhllS17hnPwiRws,7633
|
|
39
|
-
mapFolding-0.4.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
40
|
-
mapFolding-0.4.1.dist-info/entry_points.txt,sha256=F3OUeZR1XDTpoH7k3wXuRb3KF_kXTTeYhu5AGK1SiOQ,146
|
|
41
|
-
mapFolding-0.4.1.dist-info/top_level.txt,sha256=1gP2vFaqPwHujGwb3UjtMlLEGN-943VSYFR7V4gDqW8,17
|
|
42
|
-
mapFolding-0.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|