mapFolding 0.2.3__tar.gz → 0.2.4__tar.gz
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-0.2.3 → mapfolding-0.2.4}/PKG-INFO +3 -1
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/babbage.py +9 -4
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/beDRY.py +0 -3
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/benchmarks/benchmarking.py +3 -2
- mapfolding-0.2.4/mapFolding/countInitialize.py +44 -0
- mapfolding-0.2.4/mapFolding/countParallel.py +49 -0
- mapfolding-0.2.4/mapFolding/countSequential.py +43 -0
- mapfolding-0.2.4/mapFolding/importSelector.py +12 -0
- mapfolding-0.2.4/mapFolding/inlineAfunction.py +124 -0
- mapfolding-0.2.4/mapFolding/lovelace.py +213 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/startHere.py +0 -11
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/theSSOT.py +13 -5
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding.egg-info/PKG-INFO +3 -1
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding.egg-info/SOURCES.txt +7 -2
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding.egg-info/requires.txt +2 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/pyproject.toml +2 -2
- {mapfolding-0.2.3 → mapfolding-0.2.4}/tests/conftest.py +8 -1
- {mapfolding-0.2.3 → mapfolding-0.2.4}/tests/test_other.py +164 -94
- mapfolding-0.2.4/tests/test_temporary.py +25 -0
- mapfolding-0.2.3/mapFolding/benchmarks/test_benchmarks.py +0 -74
- mapfolding-0.2.3/mapFolding/lovelace.py +0 -217
- {mapfolding-0.2.3 → mapfolding-0.2.4}/README.md +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/JAX/lunnanJAX.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/JAX/taskJAX.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/__init__.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/oeis.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/reference/flattened.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/reference/hunterNumba.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/reference/irvineJavaPort.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/reference/lunnan.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/reference/lunnanNumpy.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/reference/lunnanWhile.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/reference/rotatedEntryPoint.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding.egg-info/dependency_links.txt +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding.egg-info/entry_points.txt +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/mapFolding.egg-info/top_level.txt +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/setup.cfg +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/tests/__init__.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/tests/pythons_idiotic_namespace.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/tests/test_oeis.py +0 -0
- {mapfolding-0.2.3 → mapfolding-0.2.4}/tests/test_tasks.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: mapFolding
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Algorithm(s) for counting distinct ways to fold a map (or a strip of stamps)
|
|
5
5
|
Author-email: Hunter Hogan <HunterHogan@pm.me>
|
|
6
6
|
Project-URL: homepage, https://github.com/hunterhogan/mapFolding
|
|
@@ -22,6 +22,8 @@ Requires-Dist: pytest; extra == "testing"
|
|
|
22
22
|
Requires-Dist: pytest-cov; extra == "testing"
|
|
23
23
|
Requires-Dist: pytest-env; extra == "testing"
|
|
24
24
|
Requires-Dist: pytest-xdist; extra == "testing"
|
|
25
|
+
Requires-Dist: pytest-order; extra == "testing"
|
|
26
|
+
Requires-Dist: pytest-dependency; extra == "testing"
|
|
25
27
|
|
|
26
28
|
# Algorithm(s) for counting distinct ways to fold a map (or a strip of stamps)
|
|
27
29
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from mapFolding.
|
|
1
|
+
from mapFolding.importSelector import countSequential, countParallel, countInitialize
|
|
2
|
+
from mapFolding import indexThe
|
|
2
3
|
from numpy import integer
|
|
3
4
|
from numpy.typing import NDArray
|
|
4
5
|
from typing import Any, Tuple
|
|
@@ -25,6 +26,10 @@ def _countFolds(connectionGraph: NDArray[integer[Any]], foldsSubTotals: NDArray[
|
|
|
25
26
|
- and just a few dozen-jillion other things.
|
|
26
27
|
|
|
27
28
|
"""
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
# print("babbage")
|
|
30
|
+
countInitialize(connectionGraph=connectionGraph, gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
31
|
+
|
|
32
|
+
if the[indexThe.taskDivisions.value] > 0:
|
|
33
|
+
countParallel(connectionGraph=connectionGraph, foldsSubTotals=foldsSubTotals, gapsWherePARALLEL=gapsWhere, myPARALLEL=my, the=the, trackPARALLEL=track)
|
|
34
|
+
else:
|
|
35
|
+
countSequential(connectionGraph=connectionGraph, foldsSubTotals=foldsSubTotals, gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
@@ -230,9 +230,6 @@ def parseDimensions(dimensions: Sequence[int], parameterName: str = 'unnamed par
|
|
|
230
230
|
raise ValueError(f"Dimension {dimension} must be non-negative")
|
|
231
231
|
listNonNegative.append(dimension)
|
|
232
232
|
|
|
233
|
-
if not listNonNegative:
|
|
234
|
-
raise ValueError("At least one dimension must be non-negative")
|
|
235
|
-
|
|
236
233
|
return listNonNegative
|
|
237
234
|
|
|
238
235
|
def setCPUlimit(CPUlimit: Union[bool, float, int, None]) -> int:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
"""An incompetent benchmarking module for mapFolding."""
|
|
2
2
|
from typing import Callable
|
|
3
|
+
import multiprocessing
|
|
3
4
|
import numpy
|
|
4
5
|
import pathlib
|
|
5
6
|
import time
|
|
@@ -57,7 +58,7 @@ def runBenchmarks(benchmarkIterations: int = 30) -> None:
|
|
|
57
58
|
listCartesianProduct = list(itertools.product(listParametersOEIS, range(benchmarkIterations)))
|
|
58
59
|
with ProcessPoolExecutor(max_workers) as concurrencyManager:
|
|
59
60
|
listConcurrency = [concurrencyManager.submit(oeisIDfor_n, *parameters[0]) for parameters in listCartesianProduct]
|
|
60
|
-
for
|
|
61
|
+
for _complete in tqdm(as_completed(listConcurrency), total=len(listCartesianProduct)):
|
|
61
62
|
pass
|
|
62
63
|
|
|
63
64
|
if __name__ == '__main__':
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import numba
|
|
2
|
+
|
|
3
|
+
@numba.jit((numba.int64[:, :, ::1], numba.int64[::1], numba.int64[::1], numba.int64[::1], numba.int64[:, ::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
4
|
+
def countInitialize(connectionGraph, gapsWhere, my, the, track):
|
|
5
|
+
while my[6] > 0:
|
|
6
|
+
if my[6] <= 1 or track[1, 0] == 1:
|
|
7
|
+
my[1] = 0
|
|
8
|
+
my[3] = track[3, my[6] - 1]
|
|
9
|
+
my[0] = 1
|
|
10
|
+
while my[0] <= the[0]:
|
|
11
|
+
if connectionGraph[my[0], my[6], my[6]] == my[6]:
|
|
12
|
+
my[1] += 1
|
|
13
|
+
else:
|
|
14
|
+
my[7] = connectionGraph[my[0], my[6], my[6]]
|
|
15
|
+
while my[7] != my[6]:
|
|
16
|
+
gapsWhere[my[3]] = my[7]
|
|
17
|
+
if track[2, my[7]] == 0:
|
|
18
|
+
my[3] += 1
|
|
19
|
+
track[2, my[7]] += 1
|
|
20
|
+
my[7] = connectionGraph[my[0], my[6], track[1, my[7]]]
|
|
21
|
+
my[0] += 1
|
|
22
|
+
if my[1] == the[0]:
|
|
23
|
+
my[4] = 0
|
|
24
|
+
while my[4] < my[6]:
|
|
25
|
+
gapsWhere[my[3]] = my[4]
|
|
26
|
+
my[3] += 1
|
|
27
|
+
my[4] += 1
|
|
28
|
+
my[5] = my[2]
|
|
29
|
+
while my[5] < my[3]:
|
|
30
|
+
gapsWhere[my[2]] = gapsWhere[my[5]]
|
|
31
|
+
if track[2, gapsWhere[my[5]]] == the[0] - my[1]:
|
|
32
|
+
my[2] += 1
|
|
33
|
+
track[2, gapsWhere[my[5]]] = 0
|
|
34
|
+
my[5] += 1
|
|
35
|
+
if my[6] > 0:
|
|
36
|
+
my[2] -= 1
|
|
37
|
+
track[0, my[6]] = gapsWhere[my[2]]
|
|
38
|
+
track[1, my[6]] = track[1, track[0, my[6]]]
|
|
39
|
+
track[1, track[0, my[6]]] = my[6]
|
|
40
|
+
track[0, track[1, my[6]]] = my[6]
|
|
41
|
+
track[3, my[6]] = my[2]
|
|
42
|
+
my[6] += 1
|
|
43
|
+
if my[2] > 0:
|
|
44
|
+
return
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import numba
|
|
2
|
+
|
|
3
|
+
@numba.jit((numba.int64[:, :, ::1], numba.int64[::1], numba.int64[::1], numba.int64[::1], numba.int64[::1], numba.int64[:, ::1]), parallel=True, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
4
|
+
def countParallel(connectionGraph, foldsSubTotals, gapsWherePARALLEL, myPARALLEL, the, trackPARALLEL):
|
|
5
|
+
for indexSherpa in numba.prange(the[2]):
|
|
6
|
+
gapsWhere = gapsWherePARALLEL.copy()
|
|
7
|
+
my = myPARALLEL.copy()
|
|
8
|
+
my[8] = indexSherpa
|
|
9
|
+
track = trackPARALLEL.copy()
|
|
10
|
+
while my[6] > 0:
|
|
11
|
+
if my[6] <= 1 or track[1, 0] == 1:
|
|
12
|
+
if my[6] > the[1]:
|
|
13
|
+
foldsSubTotals[my[8]] += the[1]
|
|
14
|
+
else:
|
|
15
|
+
my[1] = 0
|
|
16
|
+
my[3] = track[3, my[6] - 1]
|
|
17
|
+
my[0] = 1
|
|
18
|
+
while my[0] <= the[0]:
|
|
19
|
+
if connectionGraph[my[0], my[6], my[6]] == my[6]:
|
|
20
|
+
my[1] += 1
|
|
21
|
+
else:
|
|
22
|
+
my[7] = connectionGraph[my[0], my[6], my[6]]
|
|
23
|
+
while my[7] != my[6]:
|
|
24
|
+
if my[6] != the[2] or my[7] % the[2] == my[8]:
|
|
25
|
+
gapsWhere[my[3]] = my[7]
|
|
26
|
+
if track[2, my[7]] == 0:
|
|
27
|
+
my[3] += 1
|
|
28
|
+
track[2, my[7]] += 1
|
|
29
|
+
my[7] = connectionGraph[my[0], my[6], track[1, my[7]]]
|
|
30
|
+
my[0] += 1
|
|
31
|
+
my[5] = my[2]
|
|
32
|
+
while my[5] < my[3]:
|
|
33
|
+
gapsWhere[my[2]] = gapsWhere[my[5]]
|
|
34
|
+
if track[2, gapsWhere[my[5]]] == the[0] - my[1]:
|
|
35
|
+
my[2] += 1
|
|
36
|
+
track[2, gapsWhere[my[5]]] = 0
|
|
37
|
+
my[5] += 1
|
|
38
|
+
while my[6] > 0 and my[2] == track[3, my[6] - 1]:
|
|
39
|
+
my[6] -= 1
|
|
40
|
+
track[1, track[0, my[6]]] = track[1, my[6]]
|
|
41
|
+
track[0, track[1, my[6]]] = track[0, my[6]]
|
|
42
|
+
if my[6] > 0:
|
|
43
|
+
my[2] -= 1
|
|
44
|
+
track[0, my[6]] = gapsWhere[my[2]]
|
|
45
|
+
track[1, my[6]] = track[1, track[0, my[6]]]
|
|
46
|
+
track[1, track[0, my[6]]] = my[6]
|
|
47
|
+
track[0, track[1, my[6]]] = my[6]
|
|
48
|
+
track[3, my[6]] = my[2]
|
|
49
|
+
my[6] += 1
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import numba
|
|
2
|
+
|
|
3
|
+
@numba.jit((numba.int64[:, :, ::1], numba.int64[::1], numba.int64[::1], numba.int64[::1], numba.int64[::1], numba.int64[:, ::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
4
|
+
def countSequential(connectionGraph, foldsSubTotals, gapsWhere, my, the, track):
|
|
5
|
+
while my[6] > 0:
|
|
6
|
+
if my[6] <= 1 or track[1, 0] == 1:
|
|
7
|
+
if my[6] > the[1]:
|
|
8
|
+
foldsSubTotals[my[8]] += the[1]
|
|
9
|
+
else:
|
|
10
|
+
my[1] = 0
|
|
11
|
+
my[3] = track[3, my[6] - 1]
|
|
12
|
+
my[0] = 1
|
|
13
|
+
while my[0] <= the[0]:
|
|
14
|
+
if connectionGraph[my[0], my[6], my[6]] == my[6]:
|
|
15
|
+
my[1] += 1
|
|
16
|
+
else:
|
|
17
|
+
my[7] = connectionGraph[my[0], my[6], my[6]]
|
|
18
|
+
while my[7] != my[6]:
|
|
19
|
+
gapsWhere[my[3]] = my[7]
|
|
20
|
+
if track[2, my[7]] == 0:
|
|
21
|
+
my[3] += 1
|
|
22
|
+
track[2, my[7]] += 1
|
|
23
|
+
my[7] = connectionGraph[my[0], my[6], track[1, my[7]]]
|
|
24
|
+
my[0] += 1
|
|
25
|
+
my[5] = my[2]
|
|
26
|
+
while my[5] < my[3]:
|
|
27
|
+
gapsWhere[my[2]] = gapsWhere[my[5]]
|
|
28
|
+
if track[2, gapsWhere[my[5]]] == the[0] - my[1]:
|
|
29
|
+
my[2] += 1
|
|
30
|
+
track[2, gapsWhere[my[5]]] = 0
|
|
31
|
+
my[5] += 1
|
|
32
|
+
while my[6] > 0 and my[2] == track[3, my[6] - 1]:
|
|
33
|
+
my[6] -= 1
|
|
34
|
+
track[1, track[0, my[6]]] = track[1, my[6]]
|
|
35
|
+
track[0, track[1, my[6]]] = track[0, my[6]]
|
|
36
|
+
if my[6] > 0:
|
|
37
|
+
my[2] -= 1
|
|
38
|
+
track[0, my[6]] = gapsWhere[my[2]]
|
|
39
|
+
track[1, my[6]] = track[1, track[0, my[6]]]
|
|
40
|
+
track[1, track[0, my[6]]] = my[6]
|
|
41
|
+
track[0, track[1, my[6]]] = my[6]
|
|
42
|
+
track[3, my[6]] = my[2]
|
|
43
|
+
my[6] += 1
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# useLovelace = True
|
|
2
|
+
useLovelace = False
|
|
3
|
+
|
|
4
|
+
if useLovelace:
|
|
5
|
+
from mapFolding.lovelace import countSequential
|
|
6
|
+
from mapFolding.lovelace import countParallel
|
|
7
|
+
from mapFolding.lovelace import countInitialize
|
|
8
|
+
|
|
9
|
+
else:
|
|
10
|
+
from mapFolding.countSequential import countSequential
|
|
11
|
+
from mapFolding.countParallel import countParallel
|
|
12
|
+
from mapFolding.countInitialize import countInitialize
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
from mapFolding import indexMy, indexThe, indexTrack
|
|
2
|
+
import ast
|
|
3
|
+
import pathlib
|
|
4
|
+
|
|
5
|
+
dictionaryEnumValues = {}
|
|
6
|
+
for enumIndex in [indexMy, indexThe, indexTrack]:
|
|
7
|
+
for memberName, memberValue in enumIndex._member_map_.items():
|
|
8
|
+
dictionaryEnumValues[f"{enumIndex.__name__}.{memberName}.value"] = memberValue.value
|
|
9
|
+
|
|
10
|
+
class RecursiveInliner(ast.NodeTransformer):
|
|
11
|
+
def __init__(self, dictionaryFunctions, dictionaryEnumValues):
|
|
12
|
+
self.dictionaryFunctions = dictionaryFunctions
|
|
13
|
+
self.dictionaryEnumValues = dictionaryEnumValues
|
|
14
|
+
self.processed = set() # Track processed functions to avoid infinite recursion
|
|
15
|
+
|
|
16
|
+
def inline_function_body(self, functionName):
|
|
17
|
+
if functionName in self.processed:
|
|
18
|
+
return None
|
|
19
|
+
|
|
20
|
+
self.processed.add(functionName)
|
|
21
|
+
inlineDefinition = self.dictionaryFunctions[functionName]
|
|
22
|
+
# Recursively process the function body
|
|
23
|
+
for node in ast.walk(inlineDefinition):
|
|
24
|
+
self.visit(node)
|
|
25
|
+
return inlineDefinition
|
|
26
|
+
|
|
27
|
+
def visit_Attribute(self, node):
|
|
28
|
+
# Substitute enum identifiers (e.g., indexMy.leaf1ndex.value)
|
|
29
|
+
if isinstance(node.value, ast.Attribute) and isinstance(node.value.value, ast.Name):
|
|
30
|
+
enumPath = f"{node.value.value.id}.{node.value.attr}.{node.attr}"
|
|
31
|
+
if enumPath in self.dictionaryEnumValues:
|
|
32
|
+
return ast.Constant(value=self.dictionaryEnumValues[enumPath])
|
|
33
|
+
return self.generic_visit(node)
|
|
34
|
+
|
|
35
|
+
def visit_Call(self, node):
|
|
36
|
+
callNode = self.generic_visit(node)
|
|
37
|
+
if isinstance(callNode, ast.Call) and isinstance(callNode.func, ast.Name) and callNode.func.id in self.dictionaryFunctions:
|
|
38
|
+
inlineDefinition = self.inline_function_body(callNode.func.id)
|
|
39
|
+
if inlineDefinition and inlineDefinition.body:
|
|
40
|
+
lastStmt = inlineDefinition.body[-1]
|
|
41
|
+
if isinstance(lastStmt, ast.Return) and lastStmt.value is not None:
|
|
42
|
+
return self.visit(lastStmt.value)
|
|
43
|
+
elif isinstance(lastStmt, ast.Expr) and lastStmt.value is not None:
|
|
44
|
+
return self.visit(lastStmt.value)
|
|
45
|
+
return None
|
|
46
|
+
return callNode
|
|
47
|
+
|
|
48
|
+
def visit_Expr(self, node):
|
|
49
|
+
if isinstance(node.value, ast.Call):
|
|
50
|
+
if isinstance(node.value.func, ast.Name) and node.value.func.id in self.dictionaryFunctions:
|
|
51
|
+
inlineDefinition = self.inline_function_body(node.value.func.id)
|
|
52
|
+
if inlineDefinition:
|
|
53
|
+
return [self.visit(stmt) for stmt in inlineDefinition.body]
|
|
54
|
+
return self.generic_visit(node)
|
|
55
|
+
|
|
56
|
+
def find_required_imports(node):
|
|
57
|
+
"""Find all modules that need to be imported based on AST analysis."""
|
|
58
|
+
requiredImports = set()
|
|
59
|
+
|
|
60
|
+
class ImportFinder(ast.NodeVisitor):
|
|
61
|
+
def visit_Name(self, node):
|
|
62
|
+
# Common modules we might need
|
|
63
|
+
if node.id in {'numba'}:
|
|
64
|
+
requiredImports.add(node.id)
|
|
65
|
+
self.generic_visit(node)
|
|
66
|
+
|
|
67
|
+
def visit_Decorator(self, node):
|
|
68
|
+
if isinstance(node, ast.Call) and isinstance(node.func, ast.Name):
|
|
69
|
+
if node.func.id == 'jit':
|
|
70
|
+
requiredImports.add('numba')
|
|
71
|
+
self.generic_visit(node)
|
|
72
|
+
|
|
73
|
+
ImportFinder().visit(node)
|
|
74
|
+
return requiredImports
|
|
75
|
+
|
|
76
|
+
def generate_imports(requiredImports):
|
|
77
|
+
"""Generate import statements based on required modules."""
|
|
78
|
+
importStatements = []
|
|
79
|
+
|
|
80
|
+
# Map of module names to their import statements
|
|
81
|
+
importMapping = {
|
|
82
|
+
'numba': 'import numba',
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
for moduleName in sorted(requiredImports):
|
|
86
|
+
if moduleName in importMapping:
|
|
87
|
+
importStatements.append(importMapping[moduleName])
|
|
88
|
+
|
|
89
|
+
return '\n'.join(importStatements)
|
|
90
|
+
|
|
91
|
+
def inline_functions(sourceCode, targetFunctionName, dictionaryEnumValues):
|
|
92
|
+
dictionaryParsed = ast.parse(sourceCode)
|
|
93
|
+
dictionaryFunctions = {
|
|
94
|
+
element.name: element
|
|
95
|
+
for element in dictionaryParsed.body
|
|
96
|
+
if isinstance(element, ast.FunctionDef)
|
|
97
|
+
}
|
|
98
|
+
nodeTarget = dictionaryFunctions[targetFunctionName]
|
|
99
|
+
nodeInliner = RecursiveInliner(dictionaryFunctions, dictionaryEnumValues)
|
|
100
|
+
nodeInlined = nodeInliner.visit(nodeTarget)
|
|
101
|
+
ast.fix_missing_locations(nodeInlined)
|
|
102
|
+
|
|
103
|
+
# Generate imports
|
|
104
|
+
requiredImports = find_required_imports(nodeInlined)
|
|
105
|
+
importStatements = generate_imports(requiredImports)
|
|
106
|
+
|
|
107
|
+
# Combine imports with inlined code
|
|
108
|
+
inlinedCode = importStatements + '\n\n' + ast.unparse(ast.Module(body=[nodeInlined], type_ignores=[]))
|
|
109
|
+
return inlinedCode
|
|
110
|
+
|
|
111
|
+
pathFilenameSource = pathlib.Path("/apps/mapFolding/mapFolding/lovelace.py")
|
|
112
|
+
codeSource = pathFilenameSource.read_text()
|
|
113
|
+
|
|
114
|
+
listCallables = [
|
|
115
|
+
'countSequential',
|
|
116
|
+
'countParallel',
|
|
117
|
+
'countInitialize',
|
|
118
|
+
]
|
|
119
|
+
listPathFilenamesDestination = []
|
|
120
|
+
for callableTarget in listCallables:
|
|
121
|
+
pathFilenameDestination = pathFilenameSource.with_stem(callableTarget)
|
|
122
|
+
codeInlined = inline_functions(codeSource, callableTarget, dictionaryEnumValues)
|
|
123
|
+
pathFilenameDestination.write_text(codeInlined)
|
|
124
|
+
listPathFilenamesDestination.append(pathFilenameDestination)
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
from mapFolding import indexMy, indexThe, indexTrack
|
|
2
|
+
import numba
|
|
3
|
+
|
|
4
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
5
|
+
def activeGapIncrement(my):
|
|
6
|
+
my[indexMy.gap1ndex.value] += 1
|
|
7
|
+
|
|
8
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
9
|
+
def activeLeafGreaterThan0Condition(my):
|
|
10
|
+
return my[indexMy.leaf1ndex.value] > 0
|
|
11
|
+
|
|
12
|
+
@numba.jit((numba.int64[::1],numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
13
|
+
def activeLeafGreaterThanLeavesTotalCondition(my, the):
|
|
14
|
+
return my[indexMy.leaf1ndex.value] > the[indexThe.leavesTotal.value]
|
|
15
|
+
|
|
16
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
17
|
+
def activeLeafIsTheFirstLeafCondition(my):
|
|
18
|
+
return my[indexMy.leaf1ndex.value] <= 1
|
|
19
|
+
|
|
20
|
+
@numba.jit((numba.int64[::1],numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
21
|
+
def allDimensionsAreUnconstrained(my, the):
|
|
22
|
+
return my[indexMy.dimensionsUnconstrained.value] == the[indexThe.dimensionsTotal.value]
|
|
23
|
+
|
|
24
|
+
@numba.jit((numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
25
|
+
def backtrack(my, track):
|
|
26
|
+
my[indexMy.leaf1ndex.value] -= 1
|
|
27
|
+
track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]
|
|
28
|
+
track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]
|
|
29
|
+
|
|
30
|
+
@numba.jit((numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
31
|
+
def backtrackCondition(my, track):
|
|
32
|
+
return my[indexMy.leaf1ndex.value] > 0 and my[indexMy.gap1ndex.value] == track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
|
|
33
|
+
|
|
34
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
35
|
+
def gap1ndexCeilingIncrement(my):
|
|
36
|
+
my[indexMy.gap1ndexCeiling.value] += 1
|
|
37
|
+
|
|
38
|
+
@numba.jit((numba.int64[::1],numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
39
|
+
def countGaps(gapsWhere, my, track):
|
|
40
|
+
gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.leafConnectee.value]
|
|
41
|
+
if track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] == 0:
|
|
42
|
+
gap1ndexCeilingIncrement(my=my)
|
|
43
|
+
track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] += 1
|
|
44
|
+
|
|
45
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
46
|
+
def dimension1ndexIncrement(my):
|
|
47
|
+
my[indexMy.dimension1ndex.value] += 1
|
|
48
|
+
|
|
49
|
+
@numba.jit((numba.int64[:,:,::1], numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
50
|
+
def dimensionsUnconstrainedCondition(connectionGraph, my):
|
|
51
|
+
return connectionGraph[my[indexMy.dimension1ndex.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]] == my[indexMy.leaf1ndex.value]
|
|
52
|
+
|
|
53
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
54
|
+
def dimensionsUnconstrainedIncrement(my):
|
|
55
|
+
my[indexMy.dimensionsUnconstrained.value] += 1
|
|
56
|
+
|
|
57
|
+
@numba.jit((numba.int64[::1],numba.int64[::1],numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
58
|
+
def filterCommonGaps(gapsWhere, my, the, track):
|
|
59
|
+
gapsWhere[my[indexMy.gap1ndex.value]] = gapsWhere[my[indexMy.indexMiniGap.value]]
|
|
60
|
+
if track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] == the[indexThe.dimensionsTotal.value] - my[indexMy.dimensionsUnconstrained.value]:
|
|
61
|
+
activeGapIncrement(my=my)
|
|
62
|
+
track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] = 0
|
|
63
|
+
|
|
64
|
+
@numba.jit((numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
65
|
+
def findGapsInitializeVariables(my, track):
|
|
66
|
+
my[indexMy.dimensionsUnconstrained.value] = 0
|
|
67
|
+
my[indexMy.gap1ndexCeiling.value] = track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
|
|
68
|
+
my[indexMy.dimension1ndex.value] = 1
|
|
69
|
+
|
|
70
|
+
@numba.jit((numba.int64[::1],numba.int64[::1],numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
71
|
+
def foldsSubTotalIncrement(foldsSubTotals, my, the):
|
|
72
|
+
foldsSubTotals[my[indexMy.taskIndex.value]] += the[indexThe.leavesTotal.value]
|
|
73
|
+
|
|
74
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
75
|
+
def indexMiniGapIncrement(my):
|
|
76
|
+
my[indexMy.indexMiniGap.value] += 1
|
|
77
|
+
|
|
78
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
79
|
+
def indexMiniGapInitialization(my):
|
|
80
|
+
my[indexMy.indexMiniGap.value] = my[indexMy.gap1ndex.value]
|
|
81
|
+
|
|
82
|
+
@numba.jit((numba.int64[::1],numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
83
|
+
def insertUnconstrainedLeaf(gapsWhere, my):
|
|
84
|
+
my[indexMy.indexLeaf.value] = 0
|
|
85
|
+
while my[indexMy.indexLeaf.value] < my[indexMy.leaf1ndex.value]:
|
|
86
|
+
gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.indexLeaf.value]
|
|
87
|
+
my[indexMy.gap1ndexCeiling.value] += 1
|
|
88
|
+
my[indexMy.indexLeaf.value] += 1
|
|
89
|
+
|
|
90
|
+
@numba.jit((numba.int64[:,::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
91
|
+
def leafBelowSentinelIs1Condition(track):
|
|
92
|
+
return track[indexTrack.leafBelow.value, 0] == 1
|
|
93
|
+
|
|
94
|
+
@numba.jit((numba.int64[:,:,::1], numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
95
|
+
def leafConnecteeInitialization(connectionGraph, my):
|
|
96
|
+
my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.dimension1ndex.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]]
|
|
97
|
+
|
|
98
|
+
@numba.jit((numba.int64[:,:,::1], numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
99
|
+
def leafConnecteeUpdate(connectionGraph, my, track):
|
|
100
|
+
my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.dimension1ndex.value], my[indexMy.leaf1ndex.value], track[indexTrack.leafBelow.value, my[indexMy.leafConnectee.value]]]
|
|
101
|
+
|
|
102
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
103
|
+
def loopingLeavesConnectedToActiveLeaf(my):
|
|
104
|
+
return my[indexMy.leafConnectee.value] != my[indexMy.leaf1ndex.value]
|
|
105
|
+
|
|
106
|
+
@numba.jit((numba.int64[::1],numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
107
|
+
def loopingTheDimensions(my, the):
|
|
108
|
+
return my[indexMy.dimension1ndex.value] <= the[indexThe.dimensionsTotal.value]
|
|
109
|
+
|
|
110
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
111
|
+
def loopingToActiveGapCeiling(my):
|
|
112
|
+
return my[indexMy.indexMiniGap.value] < my[indexMy.gap1ndexCeiling.value]
|
|
113
|
+
|
|
114
|
+
@numba.jit((numba.int64[::1],numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
115
|
+
def placeLeaf(gapsWhere, my, track):
|
|
116
|
+
my[indexMy.gap1ndex.value] -= 1
|
|
117
|
+
track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]] = gapsWhere[my[indexMy.gap1ndex.value]]
|
|
118
|
+
track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]] = track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]]
|
|
119
|
+
track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
|
|
120
|
+
track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
|
|
121
|
+
track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value]] = my[indexMy.gap1ndex.value]
|
|
122
|
+
my[indexMy.leaf1ndex.value] += 1
|
|
123
|
+
|
|
124
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
125
|
+
def placeLeafCondition(my):
|
|
126
|
+
return my[indexMy.leaf1ndex.value] > 0
|
|
127
|
+
|
|
128
|
+
@numba.jit((numba.int64[::1],numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
129
|
+
def thereAreComputationDivisionsYouMightSkip(my, the):
|
|
130
|
+
return my[indexMy.leaf1ndex.value] != the[indexThe.taskDivisions.value] or my[indexMy.leafConnectee.value] % the[indexThe.taskDivisions.value] == my[indexMy.taskIndex.value]
|
|
131
|
+
|
|
132
|
+
@numba.jit((numba.int64[:,:,::1], numba.int64[::1], numba.int64[::1], numba.int64[::1], numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
133
|
+
def countInitialize(connectionGraph, gapsWhere, my, the, track):
|
|
134
|
+
while activeLeafGreaterThan0Condition(my=my):
|
|
135
|
+
if activeLeafIsTheFirstLeafCondition(my=my) or leafBelowSentinelIs1Condition(track=track):
|
|
136
|
+
findGapsInitializeVariables(my=my, track=track)
|
|
137
|
+
while loopingTheDimensions(my=my, the=the):
|
|
138
|
+
if dimensionsUnconstrainedCondition(connectionGraph=connectionGraph, my=my):
|
|
139
|
+
dimensionsUnconstrainedIncrement(my=my)
|
|
140
|
+
else:
|
|
141
|
+
leafConnecteeInitialization(connectionGraph=connectionGraph, my=my)
|
|
142
|
+
while loopingLeavesConnectedToActiveLeaf(my=my):
|
|
143
|
+
countGaps(gapsWhere=gapsWhere, my=my, track=track)
|
|
144
|
+
leafConnecteeUpdate(connectionGraph=connectionGraph, my=my, track=track)
|
|
145
|
+
dimension1ndexIncrement(my=my)
|
|
146
|
+
if allDimensionsAreUnconstrained(my=my, the=the):
|
|
147
|
+
insertUnconstrainedLeaf(gapsWhere=gapsWhere, my=my)
|
|
148
|
+
indexMiniGapInitialization(my=my)
|
|
149
|
+
while loopingToActiveGapCeiling(my=my):
|
|
150
|
+
filterCommonGaps(gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
151
|
+
indexMiniGapIncrement(my=my)
|
|
152
|
+
if placeLeafCondition(my=my):
|
|
153
|
+
placeLeaf(gapsWhere=gapsWhere, my=my, track=track)
|
|
154
|
+
if my[indexMy.gap1ndex.value] > 0:
|
|
155
|
+
return
|
|
156
|
+
|
|
157
|
+
@numba.jit((numba.int64[:,:,::1], numba.int64[::1], numba.int64[::1], numba.int64[::1], numba.int64[::1], numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
158
|
+
def countSequential(connectionGraph, foldsSubTotals, gapsWhere, my, the, track):
|
|
159
|
+
while activeLeafGreaterThan0Condition(my=my):
|
|
160
|
+
if activeLeafIsTheFirstLeafCondition(my=my) or leafBelowSentinelIs1Condition(track=track):
|
|
161
|
+
if activeLeafGreaterThanLeavesTotalCondition(my=my, the=the):
|
|
162
|
+
foldsSubTotalIncrement(foldsSubTotals=foldsSubTotals, my=my, the=the)
|
|
163
|
+
else:
|
|
164
|
+
findGapsInitializeVariables(my=my, track=track)
|
|
165
|
+
while loopingTheDimensions(my=my, the=the):
|
|
166
|
+
if dimensionsUnconstrainedCondition(connectionGraph=connectionGraph, my=my):
|
|
167
|
+
dimensionsUnconstrainedIncrement(my=my)
|
|
168
|
+
else:
|
|
169
|
+
leafConnecteeInitialization(connectionGraph=connectionGraph, my=my)
|
|
170
|
+
while loopingLeavesConnectedToActiveLeaf(my=my):
|
|
171
|
+
countGaps(gapsWhere=gapsWhere, my=my, track=track)
|
|
172
|
+
leafConnecteeUpdate(connectionGraph=connectionGraph, my=my, track=track)
|
|
173
|
+
dimension1ndexIncrement(my=my)
|
|
174
|
+
indexMiniGapInitialization(my=my)
|
|
175
|
+
while loopingToActiveGapCeiling(my=my):
|
|
176
|
+
filterCommonGaps(gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
177
|
+
indexMiniGapIncrement(my=my)
|
|
178
|
+
while backtrackCondition(my=my, track=track):
|
|
179
|
+
backtrack(my=my, track=track)
|
|
180
|
+
if placeLeafCondition(my=my):
|
|
181
|
+
placeLeaf(gapsWhere=gapsWhere, my=my, track=track)
|
|
182
|
+
|
|
183
|
+
@numba.jit((numba.int64[:,:,::1], numba.int64[::1], numba.int64[::1],numba.int64[::1],numba.int64[::1],numba.int64[:,::1]), parallel=True, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
184
|
+
def countParallel(connectionGraph, foldsSubTotals, gapsWherePARALLEL, myPARALLEL, the, trackPARALLEL):
|
|
185
|
+
for indexSherpa in numba.prange(the[indexThe.taskDivisions.value]):
|
|
186
|
+
gapsWhere = gapsWherePARALLEL.copy()
|
|
187
|
+
my = myPARALLEL.copy()
|
|
188
|
+
my[indexMy.taskIndex.value] = indexSherpa
|
|
189
|
+
track = trackPARALLEL.copy()
|
|
190
|
+
while activeLeafGreaterThan0Condition(my=my):
|
|
191
|
+
if activeLeafIsTheFirstLeafCondition(my=my) or leafBelowSentinelIs1Condition(track=track):
|
|
192
|
+
if activeLeafGreaterThanLeavesTotalCondition(my=my, the=the):
|
|
193
|
+
foldsSubTotalIncrement(foldsSubTotals=foldsSubTotals, my=my, the=the)
|
|
194
|
+
else:
|
|
195
|
+
findGapsInitializeVariables(my=my, track=track)
|
|
196
|
+
while loopingTheDimensions(my=my, the=the):
|
|
197
|
+
if dimensionsUnconstrainedCondition(connectionGraph=connectionGraph, my=my):
|
|
198
|
+
dimensionsUnconstrainedIncrement(my=my)
|
|
199
|
+
else:
|
|
200
|
+
leafConnecteeInitialization(connectionGraph=connectionGraph, my=my)
|
|
201
|
+
while loopingLeavesConnectedToActiveLeaf(my=my):
|
|
202
|
+
if thereAreComputationDivisionsYouMightSkip(my=my, the=the):
|
|
203
|
+
countGaps(gapsWhere=gapsWhere, my=my, track=track)
|
|
204
|
+
leafConnecteeUpdate(connectionGraph=connectionGraph, my=my, track=track)
|
|
205
|
+
dimension1ndexIncrement(my=my)
|
|
206
|
+
indexMiniGapInitialization(my=my)
|
|
207
|
+
while loopingToActiveGapCeiling(my=my):
|
|
208
|
+
filterCommonGaps(gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
209
|
+
indexMiniGapIncrement(my=my)
|
|
210
|
+
while backtrackCondition(my=my, track=track):
|
|
211
|
+
backtrack(my=my, track=track)
|
|
212
|
+
if placeLeafCondition(my=my):
|
|
213
|
+
placeLeaf(gapsWhere=gapsWhere, my=my, track=track)
|
|
@@ -44,10 +44,8 @@ def countFolds(listDimensions: Sequence[int], writeFoldsTotal: Optional[Union[st
|
|
|
44
44
|
pathFilenameFoldsTotal = pathFilenameFoldsTotal / filenameFoldsTotalDEFAULT
|
|
45
45
|
pathFilenameFoldsTotal.parent.mkdir(parents=True, exist_ok=True)
|
|
46
46
|
|
|
47
|
-
# NOTE Don't import a module with a numba.jit function until you want the function to compile and to freeze all settings for that function.
|
|
48
47
|
from mapFolding.babbage import _countFolds
|
|
49
48
|
_countFolds(**stateUniversal)
|
|
50
|
-
# foldsSubTotals = benchmarkSherpa(**stateUniversal)
|
|
51
49
|
|
|
52
50
|
foldsTotal = stateUniversal['foldsSubTotals'].sum().item()
|
|
53
51
|
|
|
@@ -59,12 +57,3 @@ def countFolds(listDimensions: Sequence[int], writeFoldsTotal: Optional[Union[st
|
|
|
59
57
|
print(f"\nfoldsTotal foldsTotal foldsTotal foldsTotal foldsTotal\n\n{foldsTotal=}\n\nfoldsTotal foldsTotal foldsTotal foldsTotal foldsTotal")
|
|
60
58
|
|
|
61
59
|
return foldsTotal
|
|
62
|
-
|
|
63
|
-
# from numpy import integer
|
|
64
|
-
# from numpy.typing import NDArray
|
|
65
|
-
# from typing import Any, Tuple
|
|
66
|
-
# from mapFolding.benchmarks.benchmarking import recordBenchmarks
|
|
67
|
-
# @recordBenchmarks()
|
|
68
|
-
# def benchmarkSherpa(connectionGraph: NDArray[integer[Any]], foldsSubTotals: NDArray[integer[Any]], gapsWhere: NDArray[integer[Any]], mapShape: Tuple[int, ...], my: NDArray[integer[Any]], the: NDArray[integer[Any]], track: NDArray[integer[Any]]):
|
|
69
|
-
# from mapFolding.babbage import _countFolds
|
|
70
|
-
# return _countFolds(connectionGraph, foldsSubTotals, gapsWhere, mapShape, my, the, track)
|
|
@@ -5,9 +5,17 @@ import numpy.typing
|
|
|
5
5
|
import pathlib
|
|
6
6
|
import sys
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
datatypeModule = 'numpy'
|
|
9
|
+
|
|
10
|
+
datatypeLarge = 'int64'
|
|
11
|
+
datatypeDefault = datatypeLarge
|
|
12
|
+
datatypeSmall = datatypeDefault
|
|
13
|
+
|
|
14
|
+
make_dtype = lambda _datatype: eval(f"{datatypeModule}.{_datatype}")
|
|
15
|
+
|
|
16
|
+
dtypeLarge = make_dtype(datatypeLarge)
|
|
17
|
+
dtypeDefault = make_dtype(datatypeDefault)
|
|
18
|
+
dtypeSmall = make_dtype(datatypeSmall)
|
|
11
19
|
|
|
12
20
|
try:
|
|
13
21
|
_pathModule = pathlib.Path(__file__).parent
|
|
@@ -59,9 +67,9 @@ class indexTrack(EnumIndices):
|
|
|
59
67
|
|
|
60
68
|
class computationState(TypedDict):
|
|
61
69
|
connectionGraph: numpy.typing.NDArray[numpy.integer[Any]]
|
|
62
|
-
foldsSubTotals: numpy.
|
|
70
|
+
foldsSubTotals: numpy.typing.NDArray[numpy.integer[Any]]
|
|
71
|
+
gapsWhere: numpy.typing.NDArray[numpy.integer[Any]]
|
|
63
72
|
mapShape: Tuple[int, ...]
|
|
64
73
|
my: numpy.typing.NDArray[numpy.integer[Any]]
|
|
65
|
-
gapsWhere: numpy.typing.NDArray[numpy.integer[Any]]
|
|
66
74
|
the: numpy.typing.NDArray[numpy.integer[Any]]
|
|
67
75
|
track: numpy.typing.NDArray[numpy.integer[Any]]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: mapFolding
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Algorithm(s) for counting distinct ways to fold a map (or a strip of stamps)
|
|
5
5
|
Author-email: Hunter Hogan <HunterHogan@pm.me>
|
|
6
6
|
Project-URL: homepage, https://github.com/hunterhogan/mapFolding
|
|
@@ -22,6 +22,8 @@ Requires-Dist: pytest; extra == "testing"
|
|
|
22
22
|
Requires-Dist: pytest-cov; extra == "testing"
|
|
23
23
|
Requires-Dist: pytest-env; extra == "testing"
|
|
24
24
|
Requires-Dist: pytest-xdist; extra == "testing"
|
|
25
|
+
Requires-Dist: pytest-order; extra == "testing"
|
|
26
|
+
Requires-Dist: pytest-dependency; extra == "testing"
|
|
25
27
|
|
|
26
28
|
# Algorithm(s) for counting distinct ways to fold a map (or a strip of stamps)
|
|
27
29
|
|
|
@@ -3,6 +3,11 @@ pyproject.toml
|
|
|
3
3
|
mapFolding/__init__.py
|
|
4
4
|
mapFolding/babbage.py
|
|
5
5
|
mapFolding/beDRY.py
|
|
6
|
+
mapFolding/countInitialize.py
|
|
7
|
+
mapFolding/countParallel.py
|
|
8
|
+
mapFolding/countSequential.py
|
|
9
|
+
mapFolding/importSelector.py
|
|
10
|
+
mapFolding/inlineAfunction.py
|
|
6
11
|
mapFolding/lovelace.py
|
|
7
12
|
mapFolding/oeis.py
|
|
8
13
|
mapFolding/startHere.py
|
|
@@ -16,7 +21,6 @@ mapFolding.egg-info/top_level.txt
|
|
|
16
21
|
mapFolding/JAX/lunnanJAX.py
|
|
17
22
|
mapFolding/JAX/taskJAX.py
|
|
18
23
|
mapFolding/benchmarks/benchmarking.py
|
|
19
|
-
mapFolding/benchmarks/test_benchmarks.py
|
|
20
24
|
mapFolding/reference/flattened.py
|
|
21
25
|
mapFolding/reference/hunterNumba.py
|
|
22
26
|
mapFolding/reference/irvineJavaPort.py
|
|
@@ -30,4 +34,5 @@ tests/conftest.py
|
|
|
30
34
|
tests/pythons_idiotic_namespace.py
|
|
31
35
|
tests/test_oeis.py
|
|
32
36
|
tests/test_other.py
|
|
33
|
-
tests/test_tasks.py
|
|
37
|
+
tests/test_tasks.py
|
|
38
|
+
tests/test_temporary.py
|