mapFolding 0.3.11__tar.gz → 0.4.0__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.4.0/PKG-INFO +122 -0
- mapfolding-0.4.0/README.md +82 -0
- mapfolding-0.4.0/mapFolding/__init__.py +68 -0
- mapfolding-0.4.0/mapFolding/basecamp.py +55 -0
- mapfolding-0.4.0/mapFolding/beDRY.py +376 -0
- mapfolding-0.4.0/mapFolding/oeis.py +339 -0
- mapfolding-0.4.0/mapFolding/reference/flattened.py +377 -0
- mapfolding-0.4.0/mapFolding/reference/hunterNumba.py +132 -0
- mapfolding-0.4.0/mapFolding/reference/irvineJavaPort.py +120 -0
- mapfolding-0.4.0/mapFolding/reference/jax.py +208 -0
- mapfolding-0.4.0/mapFolding/reference/lunnan.py +153 -0
- mapfolding-0.4.0/mapFolding/reference/lunnanNumpy.py +123 -0
- mapfolding-0.4.0/mapFolding/reference/lunnanWhile.py +121 -0
- mapfolding-0.4.0/mapFolding/reference/rotatedEntryPoint.py +240 -0
- mapfolding-0.4.0/mapFolding/reference/total_countPlus1vsPlusN.py +211 -0
- mapfolding-0.4.0/mapFolding/someAssemblyRequired/__init__.py +2 -0
- mapfolding-0.4.0/mapFolding/someAssemblyRequired/getLLVMforNoReason.py +19 -0
- mapfolding-0.4.0/mapFolding/someAssemblyRequired/makeJob.py +61 -0
- mapfolding-0.4.0/mapFolding/someAssemblyRequired/synthesizeModuleJAX.py +29 -0
- mapfolding-0.4.0/mapFolding/someAssemblyRequired/synthesizeNumba.py +347 -0
- mapfolding-0.4.0/mapFolding/someAssemblyRequired/synthesizeNumbaGeneralized.py +371 -0
- mapfolding-0.4.0/mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +150 -0
- mapfolding-0.4.0/mapFolding/someAssemblyRequired/synthesizeNumbaModules.py +75 -0
- mapfolding-0.4.0/mapFolding/syntheticModules/__init__.py +0 -0
- {mapfolding-0.3.11 → mapfolding-0.4.0}/mapFolding/syntheticModules/numba_countInitialize.py +2 -2
- {mapfolding-0.3.11 → mapfolding-0.4.0}/mapFolding/syntheticModules/numba_countParallel.py +3 -3
- {mapfolding-0.3.11 → mapfolding-0.4.0}/mapFolding/syntheticModules/numba_countSequential.py +28 -28
- {mapfolding-0.3.11 → mapfolding-0.4.0}/mapFolding/syntheticModules/numba_doTheNeedful.py +6 -6
- mapfolding-0.4.0/mapFolding/theDao.py +229 -0
- mapfolding-0.4.0/mapFolding/theSSOT.py +279 -0
- mapfolding-0.4.0/mapFolding/theSSOTnumba.py +132 -0
- mapfolding-0.4.0/mapFolding.egg-info/PKG-INFO +122 -0
- {mapfolding-0.3.11 → mapfolding-0.4.0}/mapFolding.egg-info/SOURCES.txt +4 -2
- {mapfolding-0.3.11 → mapfolding-0.4.0}/mapFolding.egg-info/requires.txt +4 -3
- {mapfolding-0.3.11 → mapfolding-0.4.0}/mapFolding.egg-info/top_level.txt +1 -0
- {mapfolding-0.3.11 → mapfolding-0.4.0}/pyproject.toml +11 -12
- mapfolding-0.4.0/tests/conftest.py +293 -0
- mapfolding-0.4.0/tests/test_oeis.py +141 -0
- mapfolding-0.4.0/tests/test_other.py +172 -0
- {mapfolding-0.3.11 → mapfolding-0.4.0}/tests/test_tasks.py +21 -21
- mapfolding-0.4.0/tests/test_types.py +5 -0
- mapfolding-0.3.11/PKG-INFO +0 -155
- mapfolding-0.3.11/README.md +0 -115
- mapfolding-0.3.11/mapFolding/__init__.py +0 -56
- mapfolding-0.3.11/mapFolding/basecamp.py +0 -55
- mapfolding-0.3.11/mapFolding/beDRY.py +0 -376
- mapfolding-0.3.11/mapFolding/oeis.py +0 -339
- mapfolding-0.3.11/mapFolding/reference/flattened.py +0 -376
- mapfolding-0.3.11/mapFolding/reference/hunterNumba.py +0 -132
- mapfolding-0.3.11/mapFolding/reference/irvineJavaPort.py +0 -120
- mapfolding-0.3.11/mapFolding/reference/jax.py +0 -208
- mapfolding-0.3.11/mapFolding/reference/lunnan.py +0 -153
- mapfolding-0.3.11/mapFolding/reference/lunnanNumpy.py +0 -123
- mapfolding-0.3.11/mapFolding/reference/lunnanWhile.py +0 -121
- mapfolding-0.3.11/mapFolding/reference/rotatedEntryPoint.py +0 -240
- mapfolding-0.3.11/mapFolding/reference/total_countPlus1vsPlusN.py +0 -211
- mapfolding-0.3.11/mapFolding/someAssemblyRequired/__init__.py +0 -1
- mapfolding-0.3.11/mapFolding/someAssemblyRequired/getLLVMforNoReason.py +0 -19
- mapfolding-0.3.11/mapFolding/someAssemblyRequired/makeJob.py +0 -61
- mapfolding-0.3.11/mapFolding/someAssemblyRequired/synthesizeModuleJAX.py +0 -29
- mapfolding-0.3.11/mapFolding/someAssemblyRequired/synthesizeNumba.py +0 -805
- mapfolding-0.3.11/mapFolding/theDao.py +0 -230
- mapfolding-0.3.11/mapFolding/theSSOT.py +0 -251
- mapfolding-0.3.11/mapFolding/theSSOTnumba.py +0 -116
- mapfolding-0.3.11/mapFolding.egg-info/PKG-INFO +0 -155
- mapfolding-0.3.11/tests/conftest.py +0 -183
- mapfolding-0.3.11/tests/conftest_tmpRegistry.py +0 -62
- mapfolding-0.3.11/tests/conftest_uniformTests.py +0 -53
- mapfolding-0.3.11/tests/test_oeis.py +0 -141
- mapfolding-0.3.11/tests/test_other.py +0 -259
- mapfolding-0.3.11/tests/test_types.py +0 -5
- {mapfolding-0.3.11 → mapfolding-0.4.0}/LICENSE +0 -0
- {mapfolding-0.3.11 → mapfolding-0.4.0}/mapFolding.egg-info/dependency_links.txt +0 -0
- {mapfolding-0.3.11 → mapfolding-0.4.0}/mapFolding.egg-info/entry_points.txt +0 -0
- {mapfolding-0.3.11 → mapfolding-0.4.0}/setup.cfg +0 -0
- {mapfolding-0.3.11 → mapfolding-0.4.0}/tests/__init__.py +0 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: mapFolding
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Count distinct ways to fold a map (or a strip of stamps)
|
|
5
|
+
Author-email: Hunter Hogan <HunterHogan@pm.me>
|
|
6
|
+
License: CC-BY-NC-4.0
|
|
7
|
+
Project-URL: Donate, https://www.patreon.com/integrated
|
|
8
|
+
Project-URL: Homepage, https://github.com/hunterhogan/mapFolding
|
|
9
|
+
Project-URL: Repository, https://github.com/hunterhogan/mapFolding.git
|
|
10
|
+
Keywords: A001415,A001416,A001417,A001418,A195646,folding,map folding,OEIS,stamp folding
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
15
|
+
Classifier: Intended Audience :: Other Audience
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Natural Language :: English
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: numba
|
|
26
|
+
Requires-Dist: numpy
|
|
27
|
+
Requires-Dist: Z0Z_tools
|
|
28
|
+
Provides-Extra: synthesizemodules
|
|
29
|
+
Requires-Dist: autoflake; extra == "synthesizemodules"
|
|
30
|
+
Requires-Dist: more_itertools; extra == "synthesizemodules"
|
|
31
|
+
Requires-Dist: python_minifier; extra == "synthesizemodules"
|
|
32
|
+
Provides-Extra: testing
|
|
33
|
+
Requires-Dist: mypy; extra == "testing"
|
|
34
|
+
Requires-Dist: pytest-cov; extra == "testing"
|
|
35
|
+
Requires-Dist: pytest-env; extra == "testing"
|
|
36
|
+
Requires-Dist: pytest-mypy; extra == "testing"
|
|
37
|
+
Requires-Dist: pytest-xdist; extra == "testing"
|
|
38
|
+
Requires-Dist: pytest; extra == "testing"
|
|
39
|
+
Requires-Dist: updateCitation; extra == "testing"
|
|
40
|
+
|
|
41
|
+
# mapFolding: Algorithms for enumerating distinct map/stamp folding patterns 🗺️
|
|
42
|
+
|
|
43
|
+
[](https://pypi.org/project/mapFolding/)
|
|
44
|
+
[](https://youtu.be/g6f_miE91mk&t=4)
|
|
45
|
+
[](https://github.com/hunterhogan/mapFolding/actions/workflows/pythonTests.yml)
|
|
46
|
+

|
|
47
|
+
[](https://creativecommons.org/licenses/by-nc/4.0/)
|
|
48
|
+

|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Quick start
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
pip install mapFolding
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`OEIS_for_n` will run a computation from the command line.
|
|
60
|
+
|
|
61
|
+
```cmd
|
|
62
|
+
(mapFolding) C:\apps\mapFolding> OEIS_for_n A001418 5
|
|
63
|
+
186086600 distinct folding patterns.
|
|
64
|
+
Time elapsed: 1.605 seconds
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Use `mapFolding.oeisIDfor_n()` to compute a(n) for an OEIS ID.
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from mapFolding import oeisIDfor_n
|
|
71
|
+
foldsTotal = oeisIDfor_n( 'A001418', 4 )
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Features
|
|
77
|
+
|
|
78
|
+
### 1. Simple, easy usage based on OEIS IDs
|
|
79
|
+
|
|
80
|
+
`mapFolding` directly implements some IDs from [_The On-Line Encyclopedia of Integer Sequences_](https://oeis.org/) ([BibTex](https://github.com/hunterhogan/mapFolding/blob/main/citations/oeis.bibtex) citation).
|
|
81
|
+
|
|
82
|
+
Use `getOEISids` to get the most up-to-date list of available OEIS IDs.
|
|
83
|
+
|
|
84
|
+
```cmd
|
|
85
|
+
(mapFolding) C:\apps\mapFolding> getOEISids
|
|
86
|
+
|
|
87
|
+
Available OEIS sequences:
|
|
88
|
+
A001415: Number of ways of folding a 2 X n strip of stamps.
|
|
89
|
+
A001416: Number of ways of folding a 3 X n strip of stamps.
|
|
90
|
+
A001417: Number of ways of folding a 2 X 2 X ... X 2 n-dimensional map.
|
|
91
|
+
A001418: Number of ways of folding an n X n sheet of stamps.
|
|
92
|
+
A195646: Number of ways of folding a 3 X 3 X ... X 3 n-dimensional map.
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 2. **Algorithm Zoo** 🦒
|
|
96
|
+
|
|
97
|
+
- **Lunnon’s 1971 Algorithm**: A painstakingly debugged version of [the original typo-riddled code](https://github.com/hunterhogan/mapFolding/blob/mapFolding/reference/foldings.txt)
|
|
98
|
+
- The /reference directory.
|
|
99
|
+
- **Numba-JIT Accelerated**: Up to 1000× faster than pure Python ([benchmarks](https://github.com/hunterhogan/mapFolding/blob/mapFolding/notes/Speed%20highlights.md))
|
|
100
|
+
|
|
101
|
+
### 3. **For Researchers** 🔬
|
|
102
|
+
|
|
103
|
+
- Change multiple minute settings, such as the bit width of the data types.
|
|
104
|
+
- Transform the algorithm using AST
|
|
105
|
+
- Create hyper-optimized modules to compute a specific map.
|
|
106
|
+
|
|
107
|
+
## Map-folding Video
|
|
108
|
+
|
|
109
|
+
~~This caused my neurosis:~~ I enjoyed the following video, which is what introduced me to map folding.
|
|
110
|
+
|
|
111
|
+
"How Many Ways Can You Fold a Map?" by Physics for the Birds, 2024 November 13 ([BibTex](https://github.com/hunterhogan/mapFolding/blob/main/citations/Physics_for_the_Birds.bibtex) citation)
|
|
112
|
+
|
|
113
|
+
[](https://www.youtube.com/watch?v=sfH9uIY3ln4)
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## My recovery
|
|
118
|
+
|
|
119
|
+
[](https://HunterThinks.com/support)
|
|
120
|
+
[](https://www.youtube.com/@HunterHogan)
|
|
121
|
+
|
|
122
|
+
[](https://creativecommons.org/licenses/by-nc/4.0/)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# mapFolding: Algorithms for enumerating distinct map/stamp folding patterns 🗺️
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/mapFolding/)
|
|
4
|
+
[](https://youtu.be/g6f_miE91mk&t=4)
|
|
5
|
+
[](https://github.com/hunterhogan/mapFolding/actions/workflows/pythonTests.yml)
|
|
6
|
+

|
|
7
|
+
[](https://creativecommons.org/licenses/by-nc/4.0/)
|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
pip install mapFolding
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`OEIS_for_n` will run a computation from the command line.
|
|
20
|
+
|
|
21
|
+
```cmd
|
|
22
|
+
(mapFolding) C:\apps\mapFolding> OEIS_for_n A001418 5
|
|
23
|
+
186086600 distinct folding patterns.
|
|
24
|
+
Time elapsed: 1.605 seconds
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Use `mapFolding.oeisIDfor_n()` to compute a(n) for an OEIS ID.
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from mapFolding import oeisIDfor_n
|
|
31
|
+
foldsTotal = oeisIDfor_n( 'A001418', 4 )
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
### 1. Simple, easy usage based on OEIS IDs
|
|
39
|
+
|
|
40
|
+
`mapFolding` directly implements some IDs from [_The On-Line Encyclopedia of Integer Sequences_](https://oeis.org/) ([BibTex](https://github.com/hunterhogan/mapFolding/blob/main/citations/oeis.bibtex) citation).
|
|
41
|
+
|
|
42
|
+
Use `getOEISids` to get the most up-to-date list of available OEIS IDs.
|
|
43
|
+
|
|
44
|
+
```cmd
|
|
45
|
+
(mapFolding) C:\apps\mapFolding> getOEISids
|
|
46
|
+
|
|
47
|
+
Available OEIS sequences:
|
|
48
|
+
A001415: Number of ways of folding a 2 X n strip of stamps.
|
|
49
|
+
A001416: Number of ways of folding a 3 X n strip of stamps.
|
|
50
|
+
A001417: Number of ways of folding a 2 X 2 X ... X 2 n-dimensional map.
|
|
51
|
+
A001418: Number of ways of folding an n X n sheet of stamps.
|
|
52
|
+
A195646: Number of ways of folding a 3 X 3 X ... X 3 n-dimensional map.
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 2. **Algorithm Zoo** 🦒
|
|
56
|
+
|
|
57
|
+
- **Lunnon’s 1971 Algorithm**: A painstakingly debugged version of [the original typo-riddled code](https://github.com/hunterhogan/mapFolding/blob/mapFolding/reference/foldings.txt)
|
|
58
|
+
- The /reference directory.
|
|
59
|
+
- **Numba-JIT Accelerated**: Up to 1000× faster than pure Python ([benchmarks](https://github.com/hunterhogan/mapFolding/blob/mapFolding/notes/Speed%20highlights.md))
|
|
60
|
+
|
|
61
|
+
### 3. **For Researchers** 🔬
|
|
62
|
+
|
|
63
|
+
- Change multiple minute settings, such as the bit width of the data types.
|
|
64
|
+
- Transform the algorithm using AST
|
|
65
|
+
- Create hyper-optimized modules to compute a specific map.
|
|
66
|
+
|
|
67
|
+
## Map-folding Video
|
|
68
|
+
|
|
69
|
+
~~This caused my neurosis:~~ I enjoyed the following video, which is what introduced me to map folding.
|
|
70
|
+
|
|
71
|
+
"How Many Ways Can You Fold a Map?" by Physics for the Birds, 2024 November 13 ([BibTex](https://github.com/hunterhogan/mapFolding/blob/main/citations/Physics_for_the_Birds.bibtex) citation)
|
|
72
|
+
|
|
73
|
+
[](https://www.youtube.com/watch?v=sfH9uIY3ln4)
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## My recovery
|
|
78
|
+
|
|
79
|
+
[](https://HunterThinks.com/support)
|
|
80
|
+
[](https://www.youtube.com/@HunterHogan)
|
|
81
|
+
|
|
82
|
+
[](https://creativecommons.org/licenses/by-nc/4.0/)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# fundamentals
|
|
2
|
+
from mapFolding.theSSOT import (
|
|
3
|
+
computationState,
|
|
4
|
+
EnumIndices,
|
|
5
|
+
getDispatcherCallable,
|
|
6
|
+
getPathPackage,
|
|
7
|
+
indexMy,
|
|
8
|
+
indexTrack,
|
|
9
|
+
myPackageNameIs,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
# Datatype management
|
|
13
|
+
from mapFolding.theSSOT import (
|
|
14
|
+
hackSSOTdatatype,
|
|
15
|
+
hackSSOTdtype,
|
|
16
|
+
setDatatypeElephino,
|
|
17
|
+
setDatatypeFoldsTotal,
|
|
18
|
+
setDatatypeLeavesTotal,
|
|
19
|
+
setDatatypeModule,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# Synthesize modules
|
|
23
|
+
from mapFolding.theSSOT import (
|
|
24
|
+
formatModuleNameDEFAULT,
|
|
25
|
+
getAlgorithmCallable,
|
|
26
|
+
getAlgorithmSource,
|
|
27
|
+
getPathJobRootDEFAULT,
|
|
28
|
+
getPathSyntheticModules,
|
|
29
|
+
moduleOfSyntheticModules,
|
|
30
|
+
Z0Z_getDatatypeModuleScalar,
|
|
31
|
+
Z0Z_getDecoratorCallable,
|
|
32
|
+
Z0Z_setDatatypeModuleScalar,
|
|
33
|
+
Z0Z_setDecoratorCallable,
|
|
34
|
+
Z0Z_identifierCountFolds,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# Parameters for the prima donna
|
|
38
|
+
from mapFolding.theSSOT import (
|
|
39
|
+
ParametersNumba,
|
|
40
|
+
parametersNumbaDEFAULT,
|
|
41
|
+
parametersNumbaFailEarly,
|
|
42
|
+
parametersNumbaMinimum,
|
|
43
|
+
parametersNumbaParallelDEFAULT,
|
|
44
|
+
parametersNumbaSuperJit,
|
|
45
|
+
parametersNumbaSuperJitParallel,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
# Coping
|
|
49
|
+
from mapFolding.theSSOT import (
|
|
50
|
+
FREAKOUT,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
from mapFolding.beDRY import (
|
|
54
|
+
getFilenameFoldsTotal,
|
|
55
|
+
getPathFilenameFoldsTotal,
|
|
56
|
+
outfitCountFolds,
|
|
57
|
+
saveFoldsTotal,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
from mapFolding.basecamp import countFolds
|
|
61
|
+
from mapFolding.oeis import clearOEIScache, getOEISids, oeisIDfor_n
|
|
62
|
+
|
|
63
|
+
__all__ = [
|
|
64
|
+
'clearOEIScache',
|
|
65
|
+
'countFolds',
|
|
66
|
+
'getOEISids',
|
|
67
|
+
'oeisIDfor_n',
|
|
68
|
+
]
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from mapFolding import computationState, getDispatcherCallable, getPathFilenameFoldsTotal, outfitCountFolds, saveFoldsTotal
|
|
2
|
+
from typing import Optional, Sequence, Union
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
def countFolds(listDimensions: Sequence[int]
|
|
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
|