mapFolding 0.3.0__tar.gz → 0.3.1__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.3.0 → mapfolding-0.3.1}/PKG-INFO +1 -1
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/mapFolding.egg-info/PKG-INFO +1 -1
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/mapFolding.egg-info/SOURCES.txt +2 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/reference/flattened.py +7 -7
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/reference/hunterNumba.py +5 -5
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/reference/jax.py +6 -6
- mapfolding-0.3.1/mapFolding/someAssemblyRequired/getLLVMforNoReason.py +19 -0
- mapfolding-0.3.1/mapFolding/someAssemblyRequired/synthesizeJob.py +170 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/someAssemblyRequired/synthesizeModules.py +4 -4
- {mapfolding-0.3.0 → mapfolding-0.3.1}/pyproject.toml +1 -1
- {mapfolding-0.3.0 → mapfolding-0.3.1}/tests/test_other.py +2 -2
- {mapfolding-0.3.0 → mapfolding-0.3.1}/README.md +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/benchmarks/benchmarking.py +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/mapFolding.egg-info/dependency_links.txt +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/mapFolding.egg-info/entry_points.txt +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/mapFolding.egg-info/requires.txt +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/mapFolding.egg-info/top_level.txt +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/reference/irvineJavaPort.py +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/reference/lunnan.py +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/reference/lunnanNumpy.py +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/reference/lunnanWhile.py +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/reference/rotatedEntryPoint.py +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/someAssemblyRequired/__init__.py +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/someAssemblyRequired/countInitialize.py +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/someAssemblyRequired/countParallel.py +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/mapFolding/someAssemblyRequired/countSequential.py +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/setup.cfg +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/tests/test_oeis.py +0 -0
- {mapfolding-0.3.0 → mapfolding-0.3.1}/tests/test_tasks.py +0 -0
|
@@ -20,6 +20,8 @@ mapFolding/someAssemblyRequired/__init__.py
|
|
|
20
20
|
mapFolding/someAssemblyRequired/countInitialize.py
|
|
21
21
|
mapFolding/someAssemblyRequired/countParallel.py
|
|
22
22
|
mapFolding/someAssemblyRequired/countSequential.py
|
|
23
|
+
mapFolding/someAssemblyRequired/getLLVMforNoReason.py
|
|
24
|
+
mapFolding/someAssemblyRequired/synthesizeJob.py
|
|
23
25
|
mapFolding/someAssemblyRequired/synthesizeModules.py
|
|
24
26
|
tests/test_oeis.py
|
|
25
27
|
tests/test_other.py
|
|
@@ -236,7 +236,7 @@ class computationState(TypedDict):
|
|
|
236
236
|
track: NDArray[integer[Any]]
|
|
237
237
|
|
|
238
238
|
dtypeLarge = numpy.int64
|
|
239
|
-
|
|
239
|
+
dtypeMedium = dtypeLarge
|
|
240
240
|
|
|
241
241
|
def getLeavesTotal(listDimensions: Sequence[int]) -> int:
|
|
242
242
|
"""
|
|
@@ -284,7 +284,7 @@ def getTaskDivisions(computationDivisions: Optional[Union[int, str]], concurrenc
|
|
|
284
284
|
return taskDivisions
|
|
285
285
|
|
|
286
286
|
def makeConnectionGraph(listDimensions: Sequence[int], **keywordArguments: Optional[Type]) -> NDArray[integer[Any]]:
|
|
287
|
-
datatype = keywordArguments.get('datatype',
|
|
287
|
+
datatype = keywordArguments.get('datatype', dtypeMedium)
|
|
288
288
|
mapShape = validateListDimensions(listDimensions)
|
|
289
289
|
leavesTotal = getLeavesTotal(mapShape)
|
|
290
290
|
arrayDimensions = numpy.array(mapShape, dtype=datatype)
|
|
@@ -317,14 +317,14 @@ def makeConnectionGraph(listDimensions: Sequence[int], **keywordArguments: Optio
|
|
|
317
317
|
|
|
318
318
|
def makeDataContainer(shape, datatype: Optional[Type] = None):
|
|
319
319
|
if datatype is None:
|
|
320
|
-
datatype =
|
|
320
|
+
datatype = dtypeMedium
|
|
321
321
|
return numpy.zeros(shape, dtype=datatype)
|
|
322
322
|
|
|
323
323
|
def outfitFoldings(listDimensions: Sequence[int], computationDivisions: Optional[Union[int, str]] = None, CPUlimit: Optional[Union[bool, float, int]] = None, **keywordArguments: Optional[Type]) -> computationState:
|
|
324
|
-
|
|
324
|
+
datatypeMedium = keywordArguments.get('datatypeMedium', dtypeMedium)
|
|
325
325
|
datatypeLarge = keywordArguments.get('datatypeLarge', dtypeLarge)
|
|
326
326
|
|
|
327
|
-
the = makeDataContainer(len(indexThe),
|
|
327
|
+
the = makeDataContainer(len(indexThe), datatypeMedium)
|
|
328
328
|
|
|
329
329
|
mapShape = tuple(sorted(validateListDimensions(listDimensions)))
|
|
330
330
|
the[indexThe.leavesTotal] = getLeavesTotal(mapShape)
|
|
@@ -333,11 +333,11 @@ def outfitFoldings(listDimensions: Sequence[int], computationDivisions: Optional
|
|
|
333
333
|
the[indexThe.taskDivisions] = getTaskDivisions(computationDivisions, concurrencyLimit, CPUlimit, listDimensions)
|
|
334
334
|
|
|
335
335
|
stateInitialized = computationState(
|
|
336
|
-
connectionGraph = makeConnectionGraph(mapShape, datatype=
|
|
336
|
+
connectionGraph = makeConnectionGraph(mapShape, datatype=datatypeMedium),
|
|
337
337
|
foldsSubTotals = makeDataContainer(the[indexThe.leavesTotal], datatypeLarge),
|
|
338
338
|
mapShape = mapShape,
|
|
339
339
|
my = makeDataContainer(len(indexMy), datatypeLarge),
|
|
340
|
-
gapsWhere = makeDataContainer(int(the[indexThe.leavesTotal]) * int(the[indexThe.leavesTotal]) + 1,
|
|
340
|
+
gapsWhere = makeDataContainer(int(the[indexThe.leavesTotal]) * int(the[indexThe.leavesTotal]) + 1, datatypeMedium),
|
|
341
341
|
the = the,
|
|
342
342
|
track = makeDataContainer((len(indexTrack), the[indexThe.leavesTotal] + 1), datatypeLarge)
|
|
343
343
|
)
|
|
@@ -19,7 +19,7 @@ def countFolds(listDimensions: List[int]) -> int:
|
|
|
19
19
|
def integerLarge(value) -> numpy.uint64:
|
|
20
20
|
return numpy.uint64(value)
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
dtypeMedium = numpy.uint8
|
|
23
23
|
dtypeMaximum = numpy.uint16
|
|
24
24
|
|
|
25
25
|
leavesTotal = integerSmall(1)
|
|
@@ -30,19 +30,19 @@ def countFolds(listDimensions: List[int]) -> int:
|
|
|
30
30
|
"""How to build a leaf connection graph, also called a "Cartesian Product Decomposition"
|
|
31
31
|
or a "Dimensional Product Mapping", with sentinels:
|
|
32
32
|
Step 1: find the cumulative product of the map's dimensions"""
|
|
33
|
-
cumulativeProduct = numpy.ones(dimensionsTotal + 1, dtype=
|
|
33
|
+
cumulativeProduct = numpy.ones(dimensionsTotal + 1, dtype=dtypeMedium)
|
|
34
34
|
for dimension1ndex in range(1, dimensionsTotal + 1):
|
|
35
35
|
cumulativeProduct[dimension1ndex] = cumulativeProduct[dimension1ndex - 1] * listDimensions[dimension1ndex - 1]
|
|
36
36
|
|
|
37
37
|
"""Step 2: for each dimension, create a coordinate system """
|
|
38
38
|
"""coordinateSystem[dimension1ndex, leaf1ndex] holds the dimension1ndex-th coordinate of leaf leaf1ndex"""
|
|
39
|
-
coordinateSystem = numpy.zeros((dimensionsTotal + 1, leavesTotal + 1), dtype=
|
|
39
|
+
coordinateSystem = numpy.zeros((dimensionsTotal + 1, leavesTotal + 1), dtype=dtypeMedium)
|
|
40
40
|
for dimension1ndex in range(1, dimensionsTotal + 1):
|
|
41
41
|
for leaf1ndex in range(1, leavesTotal + 1):
|
|
42
42
|
coordinateSystem[dimension1ndex, leaf1ndex] = ((leaf1ndex - 1) // cumulativeProduct[dimension1ndex - 1]) % listDimensions[dimension1ndex - 1] + 1
|
|
43
43
|
|
|
44
44
|
"""Step 3: create a huge empty connection graph"""
|
|
45
|
-
connectionGraph = numpy.zeros((dimensionsTotal + 1, leavesTotal + 1, leavesTotal + 1), dtype=
|
|
45
|
+
connectionGraph = numpy.zeros((dimensionsTotal + 1, leavesTotal + 1, leavesTotal + 1), dtype=dtypeMedium)
|
|
46
46
|
|
|
47
47
|
"""Step for... for... for...: fill the connection graph"""
|
|
48
48
|
for dimension1ndex in range(1, dimensionsTotal + 1):
|
|
@@ -61,7 +61,7 @@ def countFolds(listDimensions: List[int]) -> int:
|
|
|
61
61
|
leafBelow = numba.literally(1)
|
|
62
62
|
countDimensionsGapped = numba.literally(2)
|
|
63
63
|
gapRangeStart = numba.literally(3)
|
|
64
|
-
track = numpy.zeros((4, leavesTotal + 1), dtype=
|
|
64
|
+
track = numpy.zeros((4, leavesTotal + 1), dtype=dtypeMedium)
|
|
65
65
|
|
|
66
66
|
gapsWhere = numpy.zeros(integerLarge(integerLarge(leavesTotal) * integerLarge(leavesTotal) + 1), dtype=dtypeMaximum)
|
|
67
67
|
|
|
@@ -5,7 +5,7 @@ from typing import List, Tuple
|
|
|
5
5
|
import jax
|
|
6
6
|
import jaxtyping
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
dtypeMedium = jax.numpy.uint32
|
|
9
9
|
dtypeMaximum = jax.numpy.uint32
|
|
10
10
|
|
|
11
11
|
def countFolds(listDimensions: List[int]) -> int:
|
|
@@ -15,7 +15,7 @@ def countFolds(listDimensions: List[int]) -> int:
|
|
|
15
15
|
d: int = len(listDimensions)
|
|
16
16
|
import numpy
|
|
17
17
|
D: numpy.ndarray = makeConnectionGraph(listDimensionsPositive)
|
|
18
|
-
connectionGraph = jax.numpy.asarray(D, dtype=
|
|
18
|
+
connectionGraph = jax.numpy.asarray(D, dtype=dtypeMedium)
|
|
19
19
|
del listDimensionsPositive
|
|
20
20
|
|
|
21
21
|
return foldingsJAX(n, d, connectionGraph)
|
|
@@ -191,10 +191,10 @@ def foldingsJAX(leavesTotal: jaxtyping.UInt32, dimensionsTotal: jaxtyping.UInt32
|
|
|
191
191
|
return (leafAbove, leafBelow, allValues[2], gapRangeStart, gapsWhere, allValues[5], activeLeaf1ndex, activeGap1ndex)
|
|
192
192
|
|
|
193
193
|
# Dynamic values
|
|
194
|
-
A = jax.numpy.zeros(leavesTotal + 1, dtype=
|
|
195
|
-
B = jax.numpy.zeros(leavesTotal + 1, dtype=
|
|
196
|
-
count = jax.numpy.zeros(leavesTotal + 1, dtype=
|
|
197
|
-
gapter = jax.numpy.zeros(leavesTotal + 1, dtype=
|
|
194
|
+
A = jax.numpy.zeros(leavesTotal + 1, dtype=dtypeMedium)
|
|
195
|
+
B = jax.numpy.zeros(leavesTotal + 1, dtype=dtypeMedium)
|
|
196
|
+
count = jax.numpy.zeros(leavesTotal + 1, dtype=dtypeMedium)
|
|
197
|
+
gapter = jax.numpy.zeros(leavesTotal + 1, dtype=dtypeMedium)
|
|
198
198
|
gap = jax.numpy.zeros(leavesTotal * leavesTotal + 1, dtype=dtypeMaximum)
|
|
199
199
|
|
|
200
200
|
foldingsTotal = jax.numpy.uint32(0)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import importlib
|
|
2
|
+
import importlib.util
|
|
3
|
+
import llvmlite.binding
|
|
4
|
+
import pathlib
|
|
5
|
+
|
|
6
|
+
def writeModuleLLVM(pathFilename: pathlib.Path, identifierCallable: str) -> pathlib.Path:
|
|
7
|
+
"""Import the generated module directly and get its LLVM IR."""
|
|
8
|
+
specTarget = importlib.util.spec_from_file_location("generatedModule", pathFilename)
|
|
9
|
+
if specTarget is None or specTarget.loader is None:
|
|
10
|
+
raise ImportError(f"Could not create module spec or loader for {pathFilename}")
|
|
11
|
+
moduleTarget = importlib.util.module_from_spec(specTarget)
|
|
12
|
+
specTarget.loader.exec_module(moduleTarget)
|
|
13
|
+
|
|
14
|
+
# Get LLVM IR and write to file
|
|
15
|
+
linesLLVM = moduleTarget.__dict__[identifierCallable].inspect_llvm()[()]
|
|
16
|
+
moduleLLVM = llvmlite.binding.module.parse_assembly(linesLLVM)
|
|
17
|
+
pathFilenameLLVM = pathFilename.with_suffix(".ll")
|
|
18
|
+
pathFilenameLLVM.write_text(str(moduleLLVM))
|
|
19
|
+
return pathFilenameLLVM
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
from mapFolding import getPathFilenameFoldsTotal, dtypeNumpyDefaults, thisSeemsVeryComplicated
|
|
2
|
+
from mapFolding import make_dtype, datatypeLarge, dtypeLarge, datatypeMedium, dtypeMedium, datatypeSmall, dtypeSmall
|
|
3
|
+
from mapFolding import outfitCountFolds, computationState, indexMy, indexTrack
|
|
4
|
+
from someAssemblyRequired import countInitialize, countSequential
|
|
5
|
+
from typing import Any, Optional, Sequence, Type
|
|
6
|
+
import more_itertools
|
|
7
|
+
import inspect
|
|
8
|
+
import numpy
|
|
9
|
+
import pathlib
|
|
10
|
+
import pickle
|
|
11
|
+
import python_minifier
|
|
12
|
+
|
|
13
|
+
identifierCallableLaunch = "goGoGadgetAbsurdity"
|
|
14
|
+
|
|
15
|
+
def makeStateJob(listDimensions: Sequence[int], **keywordArguments: Optional[Type[Any]]):
|
|
16
|
+
stateUniversal = outfitCountFolds(listDimensions, computationDivisions=None, CPUlimit=None, **keywordArguments)
|
|
17
|
+
countInitialize(stateUniversal['connectionGraph'], stateUniversal['gapsWhere'], stateUniversal['my'], stateUniversal['track'])
|
|
18
|
+
|
|
19
|
+
pathFilenameChopChop = getPathFilenameFoldsTotal(stateUniversal['mapShape'])
|
|
20
|
+
suffix = pathFilenameChopChop.suffix
|
|
21
|
+
pathJob = pathlib.Path(str(pathFilenameChopChop)[0:-len(suffix)])
|
|
22
|
+
pathJob.mkdir(parents=True, exist_ok=True)
|
|
23
|
+
pathFilenameJob = pathJob / 'stateJob.pkl'
|
|
24
|
+
|
|
25
|
+
pathFilenameJob.write_bytes(pickle.dumps(stateUniversal))
|
|
26
|
+
return pathFilenameJob
|
|
27
|
+
|
|
28
|
+
def convertNDArrayToStr(arrayTarget: numpy.ndarray, identifierName: str) -> str:
|
|
29
|
+
def process_nested_array(arraySlice):
|
|
30
|
+
if isinstance(arraySlice, numpy.ndarray) and arraySlice.ndim > 1:
|
|
31
|
+
return [process_nested_array(arraySlice[index]) for index in range(arraySlice.shape[0])]
|
|
32
|
+
elif isinstance(arraySlice, numpy.ndarray) and arraySlice.ndim == 1:
|
|
33
|
+
listWithRanges = []
|
|
34
|
+
for group in more_itertools.consecutive_groups(arraySlice.tolist()):
|
|
35
|
+
ImaSerious = list(group)
|
|
36
|
+
if len(ImaSerious) <= 4:
|
|
37
|
+
listWithRanges += ImaSerious
|
|
38
|
+
else:
|
|
39
|
+
ImaRange = [range(ImaSerious[0], ImaSerious[-1] + 1)]
|
|
40
|
+
listWithRanges += ImaRange
|
|
41
|
+
return listWithRanges
|
|
42
|
+
return arraySlice
|
|
43
|
+
|
|
44
|
+
arrayAsNestedLists = process_nested_array(arrayTarget)
|
|
45
|
+
|
|
46
|
+
stringMinimized = python_minifier.minify(str(arrayAsNestedLists))
|
|
47
|
+
commaZeroMaximum = arrayTarget.shape[-1] - 1
|
|
48
|
+
stringMinimized = stringMinimized.replace('[0' + ',0'*commaZeroMaximum + ']', '[0]*'+str(commaZeroMaximum+1))
|
|
49
|
+
for countZeros in range(commaZeroMaximum, 2, -1):
|
|
50
|
+
stringMinimized = stringMinimized.replace(',0'*countZeros + ']', ']+[0]*'+str(countZeros))
|
|
51
|
+
|
|
52
|
+
stringMinimized = stringMinimized.replace('range', '*range')
|
|
53
|
+
|
|
54
|
+
return f"{identifierName} = numpy.array({stringMinimized}, dtype=numpy.{arrayTarget.dtype})"
|
|
55
|
+
|
|
56
|
+
def writeModuleWithNumba(listDimensions, **keywordArguments: Optional[str]) -> pathlib.Path:
|
|
57
|
+
datatypeLargeAsStr = keywordArguments.get('datatypeLarge', thisSeemsVeryComplicated.datatypeLarge)
|
|
58
|
+
datatypeMediumAsStr = keywordArguments.get('datatypeMedium', thisSeemsVeryComplicated.datatypeMedium)
|
|
59
|
+
datatypeSmallAsStr = keywordArguments.get('datatypeSmall', thisSeemsVeryComplicated.datatypeSmall)
|
|
60
|
+
|
|
61
|
+
numpy_dtypeLarge = make_dtype(datatypeLargeAsStr) # type: ignore
|
|
62
|
+
numpy_dtypeMedium = make_dtype(datatypeMediumAsStr) # type: ignore
|
|
63
|
+
numpy_dtypeSmall = make_dtype(datatypeSmallAsStr) # type: ignore
|
|
64
|
+
|
|
65
|
+
pathFilenameJob = makeStateJob(listDimensions, dtypeLarge = numpy_dtypeLarge, dtypeMedium = numpy_dtypeMedium, dtypeSmall = numpy_dtypeSmall)
|
|
66
|
+
stateJob: computationState = pickle.loads(pathFilenameJob.read_bytes())
|
|
67
|
+
pathFilenameFoldsTotal = getPathFilenameFoldsTotal(stateJob['mapShape'], pathFilenameJob.parent)
|
|
68
|
+
|
|
69
|
+
codeSource = inspect.getsource(countSequential)
|
|
70
|
+
|
|
71
|
+
# forceinline=True might actually be useful
|
|
72
|
+
parametersNumba = f"numba.types.{datatypeLargeAsStr}(), \
|
|
73
|
+
cache=True, \
|
|
74
|
+
nopython=True, \
|
|
75
|
+
fastmath=True, \
|
|
76
|
+
forceinline=True, \
|
|
77
|
+
inline='always', \
|
|
78
|
+
looplift=False, \
|
|
79
|
+
_nrt=True, \
|
|
80
|
+
error_model='numpy', \
|
|
81
|
+
parallel=False, \
|
|
82
|
+
boundscheck=False, \
|
|
83
|
+
no_cfunc_wrapper=False, \
|
|
84
|
+
no_cpython_wrapper=False, \
|
|
85
|
+
"
|
|
86
|
+
# no_cfunc_wrapper=True, \
|
|
87
|
+
# no_cpython_wrapper=True, \
|
|
88
|
+
|
|
89
|
+
lineNumba = f"@numba.jit({parametersNumba})"
|
|
90
|
+
|
|
91
|
+
linesImport = "\n".join([
|
|
92
|
+
"import numpy"
|
|
93
|
+
, "import numba"
|
|
94
|
+
])
|
|
95
|
+
|
|
96
|
+
ImaIndent = ' '
|
|
97
|
+
linesDataDynamic = """"""
|
|
98
|
+
linesDataDynamic = "\n".join([linesDataDynamic
|
|
99
|
+
, ImaIndent + f"foldsTotal = numba.types.{datatypeLargeAsStr}(0)"
|
|
100
|
+
, ImaIndent + convertNDArrayToStr(stateJob['foldGroups'], 'foldGroups')
|
|
101
|
+
, ImaIndent + convertNDArrayToStr(stateJob['gapsWhere'], 'gapsWhere')
|
|
102
|
+
])
|
|
103
|
+
|
|
104
|
+
linesDataStatic = """"""
|
|
105
|
+
linesDataStatic = "\n".join([linesDataStatic
|
|
106
|
+
, ImaIndent + convertNDArrayToStr(stateJob['connectionGraph'], 'connectionGraph')
|
|
107
|
+
])
|
|
108
|
+
|
|
109
|
+
my = stateJob['my']
|
|
110
|
+
track = stateJob['track']
|
|
111
|
+
linesAlgorithm = """"""
|
|
112
|
+
for lineSource in codeSource.splitlines():
|
|
113
|
+
if lineSource.startswith(('#', 'import', 'from', '@numba.jit')):
|
|
114
|
+
continue
|
|
115
|
+
elif not lineSource:
|
|
116
|
+
continue
|
|
117
|
+
elif lineSource.startswith('def '):
|
|
118
|
+
lineSource = "\n".join([lineNumba
|
|
119
|
+
, f"def {identifierCallableLaunch}():"
|
|
120
|
+
, linesDataDynamic
|
|
121
|
+
, linesDataStatic
|
|
122
|
+
])
|
|
123
|
+
elif 'my[indexMy.' in lineSource:
|
|
124
|
+
# leaf1ndex = my[indexMy.leaf1ndex.value]
|
|
125
|
+
identifier, statement = lineSource.split('=')
|
|
126
|
+
lineSource = ImaIndent + identifier.strip() + '=' + str(eval(statement.strip()))
|
|
127
|
+
elif 'track[indexTrack.' in lineSource:
|
|
128
|
+
# leafAbove = track[indexTrack.leafAbove.value]
|
|
129
|
+
identifier, statement = lineSource.split('=')
|
|
130
|
+
lineSource = ImaIndent + convertNDArrayToStr(eval(statement.strip()), identifier.strip())
|
|
131
|
+
|
|
132
|
+
linesAlgorithm = "\n".join([linesAlgorithm
|
|
133
|
+
, lineSource
|
|
134
|
+
])
|
|
135
|
+
|
|
136
|
+
linesLaunch = """"""
|
|
137
|
+
linesLaunch = linesLaunch + f"""
|
|
138
|
+
if __name__ == '__main__':
|
|
139
|
+
import time
|
|
140
|
+
timeStart = time.perf_counter()
|
|
141
|
+
{identifierCallableLaunch}()
|
|
142
|
+
print(time.perf_counter() - timeStart)"""
|
|
143
|
+
|
|
144
|
+
linesWriteFoldsTotal = """"""
|
|
145
|
+
linesWriteFoldsTotal = "\n".join([linesWriteFoldsTotal
|
|
146
|
+
, " foldsTotal = foldGroups[0:-1].sum() * foldGroups[-1]"
|
|
147
|
+
, " print(foldsTotal)"
|
|
148
|
+
, " with numba.objmode():"
|
|
149
|
+
, f" open('{pathFilenameFoldsTotal.as_posix()}', 'w').write(str(foldsTotal))"
|
|
150
|
+
, " return foldsTotal"
|
|
151
|
+
])
|
|
152
|
+
|
|
153
|
+
linesAll = "\n".join([
|
|
154
|
+
linesImport
|
|
155
|
+
, linesAlgorithm
|
|
156
|
+
, linesWriteFoldsTotal
|
|
157
|
+
, linesLaunch
|
|
158
|
+
])
|
|
159
|
+
|
|
160
|
+
pathFilenameDestination = pathFilenameJob.with_stem(pathFilenameJob.parent.name).with_suffix(".py")
|
|
161
|
+
pathFilenameDestination.write_text(linesAll)
|
|
162
|
+
|
|
163
|
+
return pathFilenameDestination
|
|
164
|
+
|
|
165
|
+
if __name__ == '__main__':
|
|
166
|
+
listDimensions = [3,15]
|
|
167
|
+
datatypeLarge = 'int64'
|
|
168
|
+
datatypeMedium = 'uint8'
|
|
169
|
+
datatypeSmall = datatypeMedium
|
|
170
|
+
writeModuleWithNumba(listDimensions, datatypeLarge=datatypeLarge, datatypeMedium=datatypeMedium, datatypeSmall=datatypeSmall)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from mapFolding import indexMy, indexTrack, theDao,
|
|
1
|
+
from mapFolding import indexMy, indexTrack, theDao, datatypeMedium, datatypeLarge, datatypeSmall
|
|
2
2
|
import ast
|
|
3
3
|
import pathlib
|
|
4
4
|
import inspect
|
|
@@ -7,11 +7,11 @@ algorithmSource = theDao
|
|
|
7
7
|
|
|
8
8
|
dictionaryDecorators={
|
|
9
9
|
'countInitialize':
|
|
10
|
-
f'@numba.jit((numba.{datatypeSmall}[:,:,::1], numba.{
|
|
10
|
+
f'@numba.jit((numba.{datatypeSmall}[:,:,::1], numba.{datatypeMedium}[::1], numba.{datatypeSmall}[::1], numba.{datatypeMedium}[:,::1]), parallel=False, boundscheck=False, cache=True, error_model="numpy", fastmath=True, looplift=False, nogil=True, nopython=True)\n',
|
|
11
11
|
'countParallel':
|
|
12
|
-
f'@numba.jit((numba.{datatypeSmall}[:,:,::1], numba.{datatypeLarge}[::1], numba.{
|
|
12
|
+
f'@numba.jit((numba.{datatypeSmall}[:,:,::1], numba.{datatypeLarge}[::1], numba.{datatypeMedium}[::1], numba.{datatypeSmall}[::1], numba.{datatypeMedium}[:,::1]), parallel=True, boundscheck=False, cache=True, error_model="numpy", fastmath=True, looplift=False, nogil=True, nopython=True)\n',
|
|
13
13
|
'countSequential':
|
|
14
|
-
f'@numba.jit((numba.{datatypeSmall}[:,:,::1], numba.{datatypeLarge}[::1], numba.{
|
|
14
|
+
f'@numba.jit((numba.{datatypeSmall}[:,:,::1], numba.{datatypeLarge}[::1], numba.{datatypeMedium}[::1], numba.{datatypeSmall}[::1], numba.{datatypeMedium}[:,::1]), parallel=False, boundscheck=False, cache=True, error_model="numpy", fastmath=True, looplift=False, nogil=True, nopython=True)\n',
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
def getDictionaryEnumValues():
|
|
@@ -49,7 +49,7 @@ readme = { file = "README.md", content-type = "text/markdown" }
|
|
|
49
49
|
requires-python = ">=3.10,<3.14"
|
|
50
50
|
scripts = { getOEISids = "mapFolding.oeis:getOEISids", clearOEIScache = "mapFolding.oeis:clearOEIScache", OEIS_for_n = "mapFolding.oeis:OEIS_for_n" }
|
|
51
51
|
urls = { Homepage = "https://github.com/hunterhogan/mapFolding", Donate = "https://www.patreon.com/integrated" }
|
|
52
|
-
version = "0.3.
|
|
52
|
+
version = "0.3.1"
|
|
53
53
|
|
|
54
54
|
[tool.coverage]
|
|
55
55
|
report = { exclude_lines = [
|
|
@@ -146,7 +146,7 @@ CPUlimit
|
|
|
146
146
|
random: int, first included: 2, first excluded: (min(leavesTotal, 16) - 1)
|
|
147
147
|
random: int, first included: -1 * (min(leavesTotal, 16) - 1), first excluded: -1
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
datatypeMedium
|
|
150
150
|
None
|
|
151
151
|
numpy.int64
|
|
152
152
|
numpy.intc
|
|
@@ -172,7 +172,7 @@ def parameterIterator():
|
|
|
172
172
|
'CPUlimit': [
|
|
173
173
|
None, True, False, 0, 1, -1,
|
|
174
174
|
],
|
|
175
|
-
'
|
|
175
|
+
'datatypeMedium': [
|
|
176
176
|
None,
|
|
177
177
|
numpy.int64,
|
|
178
178
|
numpy.intc,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|