mapFolding 0.3.12__py3-none-any.whl → 0.4.0__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.
Files changed (45) hide show
  1. mapFolding/__init__.py +40 -38
  2. mapFolding/basecamp.py +50 -50
  3. mapFolding/beDRY.py +336 -336
  4. mapFolding/oeis.py +262 -262
  5. mapFolding/reference/flattened.py +294 -293
  6. mapFolding/reference/hunterNumba.py +126 -126
  7. mapFolding/reference/irvineJavaPort.py +99 -99
  8. mapFolding/reference/jax.py +153 -153
  9. mapFolding/reference/lunnan.py +148 -148
  10. mapFolding/reference/lunnanNumpy.py +115 -115
  11. mapFolding/reference/lunnanWhile.py +114 -114
  12. mapFolding/reference/rotatedEntryPoint.py +183 -183
  13. mapFolding/reference/total_countPlus1vsPlusN.py +203 -203
  14. mapFolding/someAssemblyRequired/__init__.py +2 -1
  15. mapFolding/someAssemblyRequired/getLLVMforNoReason.py +12 -12
  16. mapFolding/someAssemblyRequired/makeJob.py +48 -48
  17. mapFolding/someAssemblyRequired/synthesizeModuleJAX.py +17 -17
  18. mapFolding/someAssemblyRequired/synthesizeNumba.py +343 -633
  19. mapFolding/someAssemblyRequired/synthesizeNumbaGeneralized.py +371 -0
  20. mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +150 -0
  21. mapFolding/someAssemblyRequired/synthesizeNumbaModules.py +75 -0
  22. mapFolding/syntheticModules/__init__.py +0 -0
  23. mapFolding/syntheticModules/numba_countInitialize.py +3 -3
  24. mapFolding/syntheticModules/numba_countParallel.py +3 -3
  25. mapFolding/syntheticModules/numba_countSequential.py +3 -3
  26. mapFolding/syntheticModules/numba_doTheNeedful.py +6 -6
  27. mapFolding/theDao.py +165 -165
  28. mapFolding/theSSOT.py +176 -172
  29. mapFolding/theSSOTnumba.py +90 -74
  30. mapFolding-0.4.0.dist-info/METADATA +122 -0
  31. mapFolding-0.4.0.dist-info/RECORD +41 -0
  32. tests/conftest.py +238 -128
  33. tests/test_oeis.py +80 -80
  34. tests/test_other.py +137 -224
  35. tests/test_tasks.py +21 -21
  36. tests/test_types.py +2 -2
  37. mapFolding/someAssemblyRequired/synthesizeNumbaHardcoding.py +0 -188
  38. mapFolding-0.3.12.dist-info/METADATA +0 -155
  39. mapFolding-0.3.12.dist-info/RECORD +0 -40
  40. tests/conftest_tmpRegistry.py +0 -62
  41. tests/conftest_uniformTests.py +0 -53
  42. {mapFolding-0.3.12.dist-info → mapFolding-0.4.0.dist-info}/LICENSE +0 -0
  43. {mapFolding-0.3.12.dist-info → mapFolding-0.4.0.dist-info}/WHEEL +0 -0
  44. {mapFolding-0.3.12.dist-info → mapFolding-0.4.0.dist-info}/entry_points.txt +0 -0
  45. {mapFolding-0.3.12.dist-info → mapFolding-0.4.0.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
- computationState,
4
- EnumIndices,
5
- getDispatcherCallable,
6
- getPathPackage,
7
- indexMy,
8
- indexTrack,
9
- myPackageNameIs,
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
- hackSSOTdatatype,
15
- hackSSOTdtype,
16
- setDatatypeElephino,
17
- setDatatypeFoldsTotal,
18
- setDatatypeLeavesTotal,
19
- setDatatypeModule,
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
- getAlgorithmCallable,
25
- getAlgorithmSource,
26
- getPathJobRootDEFAULT,
27
- getPathSyntheticModules,
28
- moduleOfSyntheticModules,
29
- Z0Z_getDatatypeModuleScalar,
30
- Z0Z_getDecoratorCallable,
31
- Z0Z_setDatatypeModuleScalar,
32
- Z0Z_setDecoratorCallable,
33
- Z0Z_identifierCountFolds,
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,
34
35
  )
35
36
 
36
37
  # Parameters for the prima donna
37
38
  from mapFolding.theSSOT import (
38
- ParametersNumba,
39
- parametersNumbaDEFAULT,
40
- parametersNumbaFailEarly,
41
- parametersNumbaParallelDEFAULT,
42
- parametersNumbaSuperJit,
43
- parametersNumbaSuperJitParallel,
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
- FREAKOUT,
50
+ FREAKOUT,
49
51
  )
50
52
 
51
53
  from mapFolding.beDRY import (
52
- getFilenameFoldsTotal,
53
- getPathFilenameFoldsTotal,
54
- outfitCountFolds,
55
- saveFoldsTotal,
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
- 'clearOEIScache',
63
- 'countFolds',
64
- 'getOEISids',
65
- 'oeisIDfor_n',
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
- , 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
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