mapFolding 0.3.12__py3-none-any.whl → 0.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mapFolding/__init__.py +40 -38
- mapFolding/basecamp.py +50 -50
- mapFolding/beDRY.py +336 -336
- mapFolding/oeis.py +262 -262
- mapFolding/reference/flattened.py +294 -293
- mapFolding/reference/hunterNumba.py +126 -126
- mapFolding/reference/irvineJavaPort.py +99 -99
- mapFolding/reference/jax.py +153 -153
- mapFolding/reference/lunnan.py +148 -148
- mapFolding/reference/lunnanNumpy.py +115 -115
- mapFolding/reference/lunnanWhile.py +114 -114
- mapFolding/reference/rotatedEntryPoint.py +183 -183
- mapFolding/reference/total_countPlus1vsPlusN.py +203 -203
- mapFolding/someAssemblyRequired/__init__.py +5 -1
- mapFolding/someAssemblyRequired/getLLVMforNoReason.py +12 -12
- mapFolding/someAssemblyRequired/makeJob.py +46 -52
- mapFolding/someAssemblyRequired/synthesizeModuleJAX.py +17 -17
- mapFolding/someAssemblyRequired/synthesizeNumba.py +343 -633
- mapFolding/someAssemblyRequired/synthesizeNumbaGeneralized.py +325 -0
- mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +173 -0
- mapFolding/someAssemblyRequired/synthesizeNumbaModules.py +77 -0
- mapFolding/syntheticModules/__init__.py +0 -0
- mapFolding/syntheticModules/numba_countInitialize.py +4 -4
- mapFolding/syntheticModules/numba_countParallel.py +4 -4
- mapFolding/syntheticModules/numba_countSequential.py +4 -4
- mapFolding/syntheticModules/numba_doTheNeedful.py +7 -7
- mapFolding/theDao.py +165 -165
- mapFolding/theSSOT.py +177 -173
- mapFolding/theSSOTnumba.py +90 -74
- mapFolding-0.4.1.dist-info/METADATA +154 -0
- mapFolding-0.4.1.dist-info/RECORD +42 -0
- tests/conftest.py +253 -129
- tests/test_computations.py +79 -0
- tests/test_oeis.py +76 -85
- tests/test_other.py +136 -224
- tests/test_tasks.py +19 -23
- tests/test_types.py +2 -2
- mapFolding/someAssemblyRequired/synthesizeNumbaHardcoding.py +0 -188
- mapFolding-0.3.12.dist-info/METADATA +0 -155
- mapFolding-0.3.12.dist-info/RECORD +0 -40
- tests/conftest_tmpRegistry.py +0 -62
- tests/conftest_uniformTests.py +0 -53
- {mapFolding-0.3.12.dist-info → mapFolding-0.4.1.dist-info}/LICENSE +0 -0
- {mapFolding-0.3.12.dist-info → mapFolding-0.4.1.dist-info}/WHEEL +0 -0
- {mapFolding-0.3.12.dist-info → mapFolding-0.4.1.dist-info}/entry_points.txt +0 -0
- {mapFolding-0.3.12.dist-info → mapFolding-0.4.1.dist-info}/top_level.txt +0 -0
mapFolding/__init__.py
CHANGED
|
@@ -1,66 +1,68 @@
|
|
|
1
1
|
# fundamentals
|
|
2
2
|
from mapFolding.theSSOT import (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
computationState,
|
|
4
|
+
EnumIndices,
|
|
5
|
+
getDispatcherCallable,
|
|
6
|
+
getPathPackage,
|
|
7
|
+
indexMy,
|
|
8
|
+
indexTrack,
|
|
9
|
+
myPackageNameIs,
|
|
10
10
|
)
|
|
11
11
|
|
|
12
12
|
# Datatype management
|
|
13
13
|
from mapFolding.theSSOT import (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
hackSSOTdatatype,
|
|
15
|
+
hackSSOTdtype,
|
|
16
|
+
setDatatypeElephino,
|
|
17
|
+
setDatatypeFoldsTotal,
|
|
18
|
+
setDatatypeLeavesTotal,
|
|
19
|
+
setDatatypeModule,
|
|
20
20
|
)
|
|
21
21
|
|
|
22
22
|
# Synthesize modules
|
|
23
23
|
from mapFolding.theSSOT import (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
formatModuleNameDEFAULT,
|
|
25
|
+
getAlgorithmDispatcher,
|
|
26
|
+
getAlgorithmSource,
|
|
27
|
+
getPathJobRootDEFAULT,
|
|
28
|
+
getPathSyntheticModules,
|
|
29
|
+
moduleOfSyntheticModules,
|
|
30
|
+
Z0Z_getDatatypeModuleScalar,
|
|
31
|
+
Z0Z_getDecoratorCallable,
|
|
32
|
+
Z0Z_setDatatypeModuleScalar,
|
|
33
|
+
Z0Z_setDecoratorCallable,
|
|
34
|
+
Z0Z_identifierCountFolds,
|
|
34
35
|
)
|
|
35
36
|
|
|
36
37
|
# Parameters for the prima donna
|
|
37
38
|
from mapFolding.theSSOT import (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
ParametersNumba,
|
|
40
|
+
parametersNumbaDEFAULT,
|
|
41
|
+
parametersNumbaFailEarly,
|
|
42
|
+
parametersNumbaMinimum,
|
|
43
|
+
parametersNumbaParallelDEFAULT,
|
|
44
|
+
parametersNumbaSuperJit,
|
|
45
|
+
parametersNumbaSuperJitParallel,
|
|
44
46
|
)
|
|
45
47
|
|
|
46
48
|
# Coping
|
|
47
49
|
from mapFolding.theSSOT import (
|
|
48
|
-
|
|
50
|
+
FREAKOUT,
|
|
49
51
|
)
|
|
50
52
|
|
|
51
53
|
from mapFolding.beDRY import (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
getFilenameFoldsTotal,
|
|
55
|
+
getPathFilenameFoldsTotal,
|
|
56
|
+
outfitCountFolds,
|
|
57
|
+
saveFoldsTotal,
|
|
56
58
|
)
|
|
57
59
|
|
|
58
60
|
from mapFolding.basecamp import countFolds
|
|
59
61
|
from mapFolding.oeis import clearOEIScache, getOEISids, oeisIDfor_n
|
|
60
62
|
|
|
61
63
|
__all__ = [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
'clearOEIScache',
|
|
65
|
+
'countFolds',
|
|
66
|
+
'getOEISids',
|
|
67
|
+
'oeisIDfor_n',
|
|
66
68
|
]
|
mapFolding/basecamp.py
CHANGED
|
@@ -3,53 +3,53 @@ from typing import Optional, Sequence, Union
|
|
|
3
3
|
import os
|
|
4
4
|
|
|
5
5
|
def countFolds(listDimensions: Sequence[int]
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
6
|
+
, pathLikeWriteFoldsTotal: Optional[Union[str, os.PathLike[str]]] = None
|
|
7
|
+
, computationDivisions: Optional[Union[int, str]] = None
|
|
8
|
+
, CPUlimit: Optional[Union[int, float, bool]] = None
|
|
9
|
+
, **keywordArguments: Optional[Union[str, bool]]
|
|
10
|
+
) -> int:
|
|
11
|
+
"""Count the total number of possible foldings for a given map dimensions.
|
|
12
|
+
|
|
13
|
+
Parameters:
|
|
14
|
+
listDimensions: List of integers representing the dimensions of the map to be folded.
|
|
15
|
+
pathLikeWriteFoldsTotal (None): Path, filename, or pathFilename to write the total fold count to.
|
|
16
|
+
If a directory is provided, creates a file with a default name based on map dimensions.
|
|
17
|
+
computationDivisions (None):
|
|
18
|
+
Whether and how to divide the computational work. See notes for details.
|
|
19
|
+
CPUlimit (None): This is only relevant if there are `computationDivisions`: whether and how to limit the CPU usage. See notes for details.
|
|
20
|
+
**keywordArguments: Datatype management.
|
|
21
|
+
Returns:
|
|
22
|
+
foldsTotal: Total number of distinct ways to fold a map of the given dimensions.
|
|
23
|
+
|
|
24
|
+
Computation divisions:
|
|
25
|
+
- None: no division of the computation into tasks; sets task divisions to 0
|
|
26
|
+
- int: direct set the number of task divisions; cannot exceed the map's total leaves
|
|
27
|
+
- "maximum": divides into `leavesTotal`-many `taskDivisions`
|
|
28
|
+
- "cpu": limits the divisions to the number of available CPUs, i.e. `concurrencyLimit`
|
|
29
|
+
|
|
30
|
+
Limits on CPU usage `CPUlimit`:
|
|
31
|
+
- `False`, `None`, or `0`: No limits on CPU usage; uses all available CPUs. All other values will potentially limit CPU usage.
|
|
32
|
+
- `True`: Yes, limit the CPU usage; limits to 1 CPU.
|
|
33
|
+
- Integer `>= 1`: Limits usage to the specified number of CPUs.
|
|
34
|
+
- Decimal value (`float`) between 0 and 1: Fraction of total CPUs to use.
|
|
35
|
+
- Decimal value (`float`) between -1 and 0: Fraction of CPUs to *not* use.
|
|
36
|
+
- Integer `<= -1`: Subtract the absolute value from total CPUs.
|
|
37
|
+
|
|
38
|
+
N.B.: You probably don't want to divide the computation into tasks.
|
|
39
|
+
If you want to compute a large `foldsTotal`, dividing the computation into tasks is usually a bad idea. Dividing the algorithm into tasks is inherently inefficient: efficient division into tasks means there would be no overlap in the work performed by each task. When dividing this algorithm, the amount of overlap is between 50% and 90% by all tasks: at least 50% of the work done by every task must be done by _all_ tasks. If you improve the computation time, it will only change by -10 to -50% depending on (at the very least) the ratio of the map dimensions and the number of leaves. If an undivided computation would take 10 hours on your computer, for example, the computation will still take at least 5 hours but you might reduce the time to 9 hours. Most of the time, however, you will increase the computation time. If logicalCores >= leavesTotal, it will probably be faster. If logicalCores <= 2 * leavesTotal, it will almost certainly be slower for all map dimensions.
|
|
40
|
+
"""
|
|
41
|
+
stateUniversal: computationState = outfitCountFolds(listDimensions, computationDivisions=computationDivisions, CPUlimit=CPUlimit, **keywordArguments)
|
|
42
|
+
|
|
43
|
+
pathFilenameFoldsTotal = None
|
|
44
|
+
if pathLikeWriteFoldsTotal is not None:
|
|
45
|
+
pathFilenameFoldsTotal = getPathFilenameFoldsTotal(stateUniversal['mapShape'], pathLikeWriteFoldsTotal)
|
|
46
|
+
|
|
47
|
+
dispatcher = getDispatcherCallable()
|
|
48
|
+
dispatcher(**stateUniversal)
|
|
49
|
+
|
|
50
|
+
foldsTotal = int(stateUniversal['foldGroups'][0:-1].sum() * stateUniversal['foldGroups'][-1])
|
|
51
|
+
|
|
52
|
+
if pathFilenameFoldsTotal is not None:
|
|
53
|
+
saveFoldsTotal(pathFilenameFoldsTotal, foldsTotal)
|
|
54
|
+
|
|
55
|
+
return foldsTotal
|