mapFolding 0.2.2__tar.gz → 0.2.3__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.2 → mapfolding-0.2.3}/PKG-INFO +4 -4
- {mapfolding-0.2.2 → mapfolding-0.2.3}/README.md +3 -3
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/__init__.py +1 -2
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/babbage.py +2 -2
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/beDRY.py +26 -12
- mapfolding-0.2.3/mapFolding/lovelace.py +217 -0
- mapfolding-0.2.3/mapFolding/reference/flattened.py +376 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/startHere.py +10 -8
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/theSSOT.py +2 -2
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding.egg-info/PKG-INFO +4 -4
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding.egg-info/SOURCES.txt +2 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/pyproject.toml +2 -2
- mapfolding-0.2.3/tests/__init__.py +1 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/tests/conftest.py +24 -6
- mapfolding-0.2.3/tests/pythons_idiotic_namespace.py +1 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/tests/test_other.py +108 -15
- mapfolding-0.2.2/mapFolding/lovelace.py +0 -145
- mapfolding-0.2.2/tests/__init__.py +0 -1
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/JAX/lunnanJAX.py +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/JAX/taskJAX.py +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/benchmarks/benchmarking.py +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/benchmarks/test_benchmarks.py +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/oeis.py +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/reference/hunterNumba.py +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/reference/irvineJavaPort.py +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/reference/lunnan.py +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/reference/lunnanNumpy.py +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/reference/lunnanWhile.py +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/reference/rotatedEntryPoint.py +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding.egg-info/dependency_links.txt +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding.egg-info/entry_points.txt +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding.egg-info/requires.txt +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/mapFolding.egg-info/top_level.txt +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/setup.cfg +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/tests/test_oeis.py +0 -0
- {mapfolding-0.2.2 → mapfolding-0.2.3}/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.3
|
|
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
|
|
@@ -25,7 +25,7 @@ Requires-Dist: pytest-xdist; extra == "testing"
|
|
|
25
25
|
|
|
26
26
|
# Algorithm(s) for counting distinct ways to fold a map (or a strip of stamps)
|
|
27
27
|
|
|
28
|
-
`mapFolding.countFolds()`
|
|
28
|
+
The function `mapFolding.countFolds()` counts distinct ways to fold maps and strips of stamps. The function accepts two or more dimensions:
|
|
29
29
|
|
|
30
30
|
```python
|
|
31
31
|
from mapFolding import countFolds
|
|
@@ -34,12 +34,12 @@ foldsTotal = countFolds( [2,10] )
|
|
|
34
34
|
|
|
35
35
|
The directory [mapFolding/reference](https://github.com/hunterhogan/mapFolding/blob/main/mapFolding/reference) has
|
|
36
36
|
|
|
37
|
-
- a verbatim transcription of
|
|
37
|
+
- a verbatim transcription of Lunnon's "procedure" published in 1971 by _The Computer Journal_,
|
|
38
38
|
- multiple referential versions of the procedure with explanatory comments including
|
|
39
39
|
- [hunterNumba.py](https://github.com/hunterhogan/mapFolding/blob/main/mapFolding/reference), a one-size-fits-all, self-contained, reasonably fast, contemporary algorithm that is nevertheless infected by _noobaceae ignorancium_, and
|
|
40
40
|
- miscellaneous notes.
|
|
41
41
|
|
|
42
|
-
[](https://github.com/hunterhogan/mapFolding/actions/workflows/unittests.yml)
|
|
42
|
+
[](https://github.com/hunterhogan/mapFolding/actions/workflows/unittests.yml) [](https://pypi.org/project/mapFolding/)    
|
|
43
43
|
|
|
44
44
|
## Simple, easy usage based on OEIS IDs
|
|
45
45
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Algorithm(s) for counting distinct ways to fold a map (or a strip of stamps)
|
|
2
2
|
|
|
3
|
-
`mapFolding.countFolds()`
|
|
3
|
+
The function `mapFolding.countFolds()` counts distinct ways to fold maps and strips of stamps. The function accepts two or more dimensions:
|
|
4
4
|
|
|
5
5
|
```python
|
|
6
6
|
from mapFolding import countFolds
|
|
@@ -9,12 +9,12 @@ foldsTotal = countFolds( [2,10] )
|
|
|
9
9
|
|
|
10
10
|
The directory [mapFolding/reference](https://github.com/hunterhogan/mapFolding/blob/main/mapFolding/reference) has
|
|
11
11
|
|
|
12
|
-
- a verbatim transcription of
|
|
12
|
+
- a verbatim transcription of Lunnon's "procedure" published in 1971 by _The Computer Journal_,
|
|
13
13
|
- multiple referential versions of the procedure with explanatory comments including
|
|
14
14
|
- [hunterNumba.py](https://github.com/hunterhogan/mapFolding/blob/main/mapFolding/reference), a one-size-fits-all, self-contained, reasonably fast, contemporary algorithm that is nevertheless infected by _noobaceae ignorancium_, and
|
|
15
15
|
- miscellaneous notes.
|
|
16
16
|
|
|
17
|
-
[](https://github.com/hunterhogan/mapFolding/actions/workflows/unittests.yml)
|
|
17
|
+
[](https://github.com/hunterhogan/mapFolding/actions/workflows/unittests.yml) [](https://pypi.org/project/mapFolding/)    
|
|
18
18
|
|
|
19
19
|
## Simple, easy usage based on OEIS IDs
|
|
20
20
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from .theSSOT import *
|
|
2
2
|
from Z0Z_tools import defineConcurrencyLimit, intInnit, oopsieKwargsie
|
|
3
|
-
from .beDRY import
|
|
4
|
-
from .beDRY import getLeavesTotal, parseDimensions, validateListDimensions
|
|
3
|
+
from .beDRY import getFilenameFoldsTotal, outfitCountFolds
|
|
5
4
|
from .startHere import countFolds
|
|
6
5
|
from .oeis import oeisIDfor_n, getOEISids, clearOEIScache
|
|
7
6
|
|
|
@@ -6,7 +6,7 @@ import numba
|
|
|
6
6
|
import numpy
|
|
7
7
|
|
|
8
8
|
@numba.jit(cache=True)
|
|
9
|
-
def _countFolds(connectionGraph: NDArray[integer[Any]],
|
|
9
|
+
def _countFolds(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]]):
|
|
10
10
|
"""
|
|
11
11
|
What in tarnation is this stupid module and function?
|
|
12
12
|
|
|
@@ -27,4 +27,4 @@ def _countFolds(connectionGraph: NDArray[integer[Any]], foldsTotal: NDArray[inte
|
|
|
27
27
|
"""
|
|
28
28
|
# TODO learn if I really must change this jitted function to get the super jit to recompile
|
|
29
29
|
# print('babbage')
|
|
30
|
-
|
|
30
|
+
countFoldsCompiled(connectionGraph=connectionGraph, foldsSubTotals=foldsSubTotals, gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"""A relatively stable API for oft-needed functionality."""
|
|
2
|
-
from mapFolding import
|
|
2
|
+
from mapFolding import dtypeDefault, dtypeLarge
|
|
3
3
|
from mapFolding import indexMy, indexThe, indexTrack, computationState
|
|
4
|
-
from mapFolding import
|
|
4
|
+
from mapFolding import intInnit, defineConcurrencyLimit, oopsieKwargsie
|
|
5
|
+
from numpy import integer
|
|
6
|
+
from numpy.typing import NDArray
|
|
5
7
|
from typing import Any, List, Optional, Sequence, Type, Union
|
|
6
|
-
import numpy
|
|
7
8
|
import numba
|
|
8
|
-
|
|
9
|
-
from numpy import integer
|
|
9
|
+
import numpy
|
|
10
10
|
import sys
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
def getFilenameFoldsTotal(listDimensions: Sequence[int]) -> str:
|
|
13
|
+
return str(sorted(listDimensions)).replace(' ', '') + '.foldsTotal'
|
|
12
14
|
|
|
13
15
|
def getLeavesTotal(listDimensions: Sequence[int]) -> int:
|
|
14
16
|
"""
|
|
@@ -146,7 +148,7 @@ def makeDataContainer(shape, datatype: Optional[Type] = None):
|
|
|
146
148
|
datatype = dtypeDefault
|
|
147
149
|
return numpy.zeros(shape, dtype=datatype)
|
|
148
150
|
|
|
149
|
-
def
|
|
151
|
+
def outfitCountFolds(listDimensions: Sequence[int], computationDivisions: Optional[Union[int, str]] = None, CPUlimit: Optional[Union[bool, float, int]] = None, **keywordArguments: Optional[Type]) -> computationState:
|
|
150
152
|
"""
|
|
151
153
|
Initializes and configures the computation state for map folding computations.
|
|
152
154
|
|
|
@@ -155,21 +157,33 @@ def outfitFoldings(listDimensions: Sequence[int], computationDivisions: Optional
|
|
|
155
157
|
listDimensions:
|
|
156
158
|
The dimensions of the map to be folded
|
|
157
159
|
computationDivisions (None):
|
|
158
|
-
Specifies how to divide
|
|
160
|
+
Specifies how to divide computations:
|
|
161
|
+
- None: no division of the computation into tasks; sets task divisions to 0
|
|
162
|
+
- int: direct set the number of task divisions; cannot exceed the map's total leaves
|
|
163
|
+
- "maximum": divides into `leavesTotal`-many `taskDivisions`
|
|
164
|
+
- "cpu": limits the divisions to the number of available CPUs, i.e. `concurrencyLimit`
|
|
159
165
|
CPUlimit (None):
|
|
160
|
-
|
|
166
|
+
Whether and how to limit the CPU usage. See notes for details.
|
|
161
167
|
|
|
162
168
|
Returns
|
|
163
169
|
-------
|
|
164
170
|
computationState
|
|
165
171
|
An initialized computation state containing:
|
|
166
172
|
- connectionGraph: Graph representing connections in the map
|
|
167
|
-
-
|
|
173
|
+
- foldsSubTotals: Array tracking total folds
|
|
168
174
|
- mapShape: Validated and sorted dimensions of the map
|
|
169
175
|
- my: Array for internal state tracking
|
|
170
176
|
- gapsWhere: Array tracking gap positions
|
|
171
177
|
- the: Static settings and metadata
|
|
172
178
|
- track: Array for tracking computation progress
|
|
179
|
+
|
|
180
|
+
Limits on CPU usage `CPUlimit`:
|
|
181
|
+
- `False`, `None`, or `0`: No limits on CPU usage; uses all available CPUs. All other values will potentially limit CPU usage.
|
|
182
|
+
- `True`: Yes, limit the CPU usage; limits to 1 CPU.
|
|
183
|
+
- Integer `>= 1`: Limits usage to the specified number of CPUs.
|
|
184
|
+
- Decimal value (`float`) between 0 and 1: Fraction of total CPUs to use.
|
|
185
|
+
- Decimal value (`float`) between -1 and 0: Fraction of CPUs to *not* use.
|
|
186
|
+
- Integer `<= -1`: Subtract the absolute value from total CPUs.
|
|
173
187
|
"""
|
|
174
188
|
datatypeDefault = keywordArguments.get('datatypeDefault', dtypeDefault)
|
|
175
189
|
datatypeLarge = keywordArguments.get('datatypeLarge', dtypeLarge)
|
|
@@ -181,10 +195,10 @@ def outfitFoldings(listDimensions: Sequence[int], computationDivisions: Optional
|
|
|
181
195
|
the[indexThe.dimensionsTotal] = len(mapShape)
|
|
182
196
|
concurrencyLimit = setCPUlimit(CPUlimit)
|
|
183
197
|
the[indexThe.taskDivisions] = getTaskDivisions(computationDivisions, concurrencyLimit, CPUlimit, listDimensions)
|
|
184
|
-
|
|
198
|
+
|
|
185
199
|
stateInitialized = computationState(
|
|
186
200
|
connectionGraph = makeConnectionGraph(mapShape, datatype=datatypeDefault),
|
|
187
|
-
|
|
201
|
+
foldsSubTotals = makeDataContainer(the[indexThe.leavesTotal], datatypeLarge),
|
|
188
202
|
mapShape = mapShape,
|
|
189
203
|
my = makeDataContainer(len(indexMy), datatypeLarge),
|
|
190
204
|
gapsWhere = makeDataContainer(int(the[indexThe.leavesTotal]) * int(the[indexThe.leavesTotal]) + 1, datatypeDefault),
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
from mapFolding import indexMy, indexThe, indexTrack
|
|
2
|
+
from numpy import integer
|
|
3
|
+
from numpy.typing import NDArray
|
|
4
|
+
from typing import Any
|
|
5
|
+
import numba
|
|
6
|
+
import numpy
|
|
7
|
+
|
|
8
|
+
def activeGapIncrement(my: NDArray[integer[Any]]):
|
|
9
|
+
my[indexMy.gap1ndex.value] += 1
|
|
10
|
+
|
|
11
|
+
def activeLeafGreaterThan0Condition(my: NDArray[integer[Any]]):
|
|
12
|
+
return my[indexMy.leaf1ndex.value] > 0
|
|
13
|
+
|
|
14
|
+
def activeLeafGreaterThanLeavesTotalCondition(my: NDArray[integer[Any]], the: NDArray[integer[Any]]):
|
|
15
|
+
return my[indexMy.leaf1ndex.value] > the[indexThe.leavesTotal.value]
|
|
16
|
+
|
|
17
|
+
def activeLeafIsTheFirstLeafCondition(my: NDArray[integer[Any]]):
|
|
18
|
+
return my[indexMy.leaf1ndex.value] <= 1
|
|
19
|
+
|
|
20
|
+
def activeLeafNotEqualToTaskDivisionsCondition(my: NDArray[integer[Any]], the: NDArray[integer[Any]]):
|
|
21
|
+
return my[indexMy.leaf1ndex.value] != the[indexThe.taskDivisions.value]
|
|
22
|
+
|
|
23
|
+
def allDimensionsAreUnconstrained(my: NDArray[integer[Any]], the: NDArray[integer[Any]]):
|
|
24
|
+
return my[indexMy.dimensionsUnconstrained.value] == the[indexThe.dimensionsTotal.value]
|
|
25
|
+
|
|
26
|
+
def backtrack(my: NDArray[integer[Any]], track: NDArray[integer[Any]]):
|
|
27
|
+
my[indexMy.leaf1ndex.value] -= 1
|
|
28
|
+
track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]
|
|
29
|
+
track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]
|
|
30
|
+
|
|
31
|
+
def backtrackCondition(my: NDArray[integer[Any]], track: NDArray[integer[Any]]):
|
|
32
|
+
return my[indexMy.leaf1ndex.value] > 0 and my[indexMy.gap1ndex.value] == track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
|
|
33
|
+
|
|
34
|
+
def countGaps(gapsWhere: NDArray[integer[Any]], my: NDArray[integer[Any]], track: NDArray[integer[Any]]):
|
|
35
|
+
gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.leafConnectee.value]
|
|
36
|
+
if track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] == 0:
|
|
37
|
+
gap1ndexCeilingIncrement(my=my)
|
|
38
|
+
track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] += 1
|
|
39
|
+
|
|
40
|
+
def dimension1ndexIncrement(my: NDArray[integer[Any]]):
|
|
41
|
+
my[indexMy.dimension1ndex.value] += 1
|
|
42
|
+
|
|
43
|
+
def dimensionsUnconstrainedCondition(connectionGraph: NDArray[integer[Any]], my: NDArray[integer[Any]]):
|
|
44
|
+
return connectionGraph[my[indexMy.dimension1ndex.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]] == my[indexMy.leaf1ndex.value]
|
|
45
|
+
|
|
46
|
+
def dimensionsUnconstrainedIncrement(my: NDArray[integer[Any]]):
|
|
47
|
+
my[indexMy.dimensionsUnconstrained.value] += 1
|
|
48
|
+
|
|
49
|
+
def filterCommonGaps(gapsWhere: NDArray[integer[Any]], my: NDArray[integer[Any]], the: NDArray[integer[Any]], track: NDArray[integer[Any]]):
|
|
50
|
+
gapsWhere[my[indexMy.gap1ndex.value]] = gapsWhere[my[indexMy.indexMiniGap.value]]
|
|
51
|
+
if track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] == the[indexThe.dimensionsTotal.value] - my[indexMy.dimensionsUnconstrained.value]:
|
|
52
|
+
activeGapIncrement(my=my)
|
|
53
|
+
track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] = 0
|
|
54
|
+
|
|
55
|
+
def findGapsInitializeVariables(my: NDArray[integer[Any]], track: NDArray[integer[Any]]):
|
|
56
|
+
my[indexMy.dimensionsUnconstrained.value] = 0
|
|
57
|
+
my[indexMy.gap1ndexCeiling.value] = track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
|
|
58
|
+
my[indexMy.dimension1ndex.value] = 1
|
|
59
|
+
|
|
60
|
+
def foldsSubTotalIncrement(foldsSubTotals: NDArray[integer[Any]], my: NDArray[integer[Any]], the: NDArray[integer[Any]]):
|
|
61
|
+
foldsSubTotals[my[indexMy.taskIndex.value]] += the[indexThe.leavesTotal.value]
|
|
62
|
+
|
|
63
|
+
def gap1ndexCeilingIncrement(my: NDArray[integer[Any]]):
|
|
64
|
+
my[indexMy.gap1ndexCeiling.value] += 1
|
|
65
|
+
|
|
66
|
+
def indexMiniGapIncrement(my: NDArray[integer[Any]]):
|
|
67
|
+
my[indexMy.indexMiniGap.value] += 1
|
|
68
|
+
|
|
69
|
+
def indexMiniGapInitialization(my: NDArray[integer[Any]]):
|
|
70
|
+
my[indexMy.indexMiniGap.value] = my[indexMy.gap1ndex.value]
|
|
71
|
+
|
|
72
|
+
def insertUnconstrainedLeaf(gapsWhere: NDArray[integer[Any]], my: NDArray[integer[Any]]):
|
|
73
|
+
my[indexMy.indexLeaf.value] = 0
|
|
74
|
+
while my[indexMy.indexLeaf.value] < my[indexMy.leaf1ndex.value]:
|
|
75
|
+
gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.indexLeaf.value]
|
|
76
|
+
my[indexMy.gap1ndexCeiling.value] += 1
|
|
77
|
+
my[indexMy.indexLeaf.value] += 1
|
|
78
|
+
|
|
79
|
+
def leafBelowSentinelIs1Condition(track: NDArray[integer[Any]]):
|
|
80
|
+
return track[indexTrack.leafBelow.value, 0] == 1
|
|
81
|
+
|
|
82
|
+
def leafConnecteeInitialization(connectionGraph: NDArray[integer[Any]], my: NDArray[integer[Any]]):
|
|
83
|
+
my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.dimension1ndex.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]]
|
|
84
|
+
|
|
85
|
+
def leafConnecteeUpdate(connectionGraph: NDArray[integer[Any]], my: NDArray[integer[Any]], track: NDArray[integer[Any]]):
|
|
86
|
+
my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.dimension1ndex.value], my[indexMy.leaf1ndex.value], track[indexTrack.leafBelow.value, my[indexMy.leafConnectee.value]]]
|
|
87
|
+
|
|
88
|
+
def loopingLeavesConnectedToActiveLeaf(my: NDArray[integer[Any]]):
|
|
89
|
+
return my[indexMy.leafConnectee.value] != my[indexMy.leaf1ndex.value]
|
|
90
|
+
|
|
91
|
+
def loopingTheDimensions(my: NDArray[integer[Any]], the: NDArray[integer[Any]]):
|
|
92
|
+
return my[indexMy.dimension1ndex.value] <= the[indexThe.dimensionsTotal.value]
|
|
93
|
+
|
|
94
|
+
def loopingToActiveGapCeiling(my: NDArray[integer[Any]]):
|
|
95
|
+
return my[indexMy.indexMiniGap.value] < my[indexMy.gap1ndexCeiling.value]
|
|
96
|
+
|
|
97
|
+
def placeLeaf(gapsWhere: NDArray[integer[Any]], my: NDArray[integer[Any]], track: NDArray[integer[Any]]):
|
|
98
|
+
my[indexMy.gap1ndex.value] -= 1
|
|
99
|
+
track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]] = gapsWhere[my[indexMy.gap1ndex.value]]
|
|
100
|
+
track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]] = track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]]
|
|
101
|
+
track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
|
|
102
|
+
track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
|
|
103
|
+
track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value]] = my[indexMy.gap1ndex.value]
|
|
104
|
+
my[indexMy.leaf1ndex.value] += 1
|
|
105
|
+
|
|
106
|
+
def placeLeafCondition(my: NDArray[integer[Any]]):
|
|
107
|
+
return my[indexMy.leaf1ndex.value] > 0
|
|
108
|
+
|
|
109
|
+
def taskIndexCondition(my: NDArray[integer[Any]], the: NDArray[integer[Any]]):
|
|
110
|
+
return my[indexMy.leafConnectee.value] % the[indexThe.taskDivisions.value] == my[indexMy.taskIndex.value]
|
|
111
|
+
|
|
112
|
+
def thereAreComputationDivisionsYouMightSkip(my: NDArray[integer[Any]], the: NDArray[integer[Any]]):
|
|
113
|
+
if activeLeafNotEqualToTaskDivisionsCondition(my=my, the=the):
|
|
114
|
+
return True
|
|
115
|
+
if taskIndexCondition(my=my, the=the):
|
|
116
|
+
return True
|
|
117
|
+
return False
|
|
118
|
+
|
|
119
|
+
def initialize(connectionGraph: NDArray[integer[Any]], gapsWhere: NDArray[integer[Any]], my: NDArray[integer[Any]], the: NDArray[integer[Any]], track: NDArray[integer[Any]]):
|
|
120
|
+
while activeLeafGreaterThan0Condition(my=my):
|
|
121
|
+
if activeLeafIsTheFirstLeafCondition(my=my) or leafBelowSentinelIs1Condition(track=track):
|
|
122
|
+
findGapsInitializeVariables(my=my, track=track)
|
|
123
|
+
while loopingTheDimensions(my=my, the=the):
|
|
124
|
+
if dimensionsUnconstrainedCondition(connectionGraph=connectionGraph, my=my):
|
|
125
|
+
dimensionsUnconstrainedIncrement(my=my)
|
|
126
|
+
else:
|
|
127
|
+
leafConnecteeInitialization(connectionGraph=connectionGraph, my=my)
|
|
128
|
+
while loopingLeavesConnectedToActiveLeaf(my=my):
|
|
129
|
+
countGaps(gapsWhere=gapsWhere, my=my, track=track)
|
|
130
|
+
leafConnecteeUpdate(connectionGraph=connectionGraph, my=my, track=track)
|
|
131
|
+
dimension1ndexIncrement(my=my)
|
|
132
|
+
if allDimensionsAreUnconstrained(my=my, the=the):
|
|
133
|
+
insertUnconstrainedLeaf(gapsWhere=gapsWhere, my=my)
|
|
134
|
+
indexMiniGapInitialization(my=my)
|
|
135
|
+
while loopingToActiveGapCeiling(my=my):
|
|
136
|
+
filterCommonGaps(gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
137
|
+
indexMiniGapIncrement(my=my)
|
|
138
|
+
if placeLeafCondition(my=my):
|
|
139
|
+
placeLeaf(gapsWhere=gapsWhere, my=my, track=track)
|
|
140
|
+
if my[indexMy.gap1ndex.value] > 0:
|
|
141
|
+
break
|
|
142
|
+
|
|
143
|
+
def countParallel(connectionGraph: NDArray[integer[Any]], foldsSubTotals: NDArray[integer[Any]], gapsWhere: NDArray[integer[Any]], my: NDArray[integer[Any]], the: NDArray[integer[Any]], track: NDArray[integer[Any]]):
|
|
144
|
+
while activeLeafGreaterThan0Condition(my=my):
|
|
145
|
+
if activeLeafIsTheFirstLeafCondition(my=my) or leafBelowSentinelIs1Condition(track=track):
|
|
146
|
+
if activeLeafGreaterThanLeavesTotalCondition(my=my, the=the):
|
|
147
|
+
foldsSubTotalIncrement(foldsSubTotals=foldsSubTotals, my=my, the=the)
|
|
148
|
+
else:
|
|
149
|
+
findGapsInitializeVariables(my=my, track=track)
|
|
150
|
+
while loopingTheDimensions(my=my, the=the):
|
|
151
|
+
if dimensionsUnconstrainedCondition(connectionGraph=connectionGraph, my=my):
|
|
152
|
+
dimensionsUnconstrainedIncrement(my=my)
|
|
153
|
+
else:
|
|
154
|
+
leafConnecteeInitialization(connectionGraph=connectionGraph, my=my)
|
|
155
|
+
while loopingLeavesConnectedToActiveLeaf(my=my):
|
|
156
|
+
if thereAreComputationDivisionsYouMightSkip(my=my, the=the):
|
|
157
|
+
countGaps(gapsWhere=gapsWhere, my=my, track=track)
|
|
158
|
+
leafConnecteeUpdate(connectionGraph=connectionGraph, my=my, track=track)
|
|
159
|
+
dimension1ndexIncrement(my=my)
|
|
160
|
+
indexMiniGapInitialization(my=my)
|
|
161
|
+
while loopingToActiveGapCeiling(my=my):
|
|
162
|
+
filterCommonGaps(gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
163
|
+
indexMiniGapIncrement(my=my)
|
|
164
|
+
while backtrackCondition(my=my, track=track):
|
|
165
|
+
backtrack(my=my, track=track)
|
|
166
|
+
if placeLeafCondition(my=my):
|
|
167
|
+
placeLeaf(gapsWhere=gapsWhere, my=my, track=track)
|
|
168
|
+
|
|
169
|
+
def countSequential(connectionGraph: NDArray[integer[Any]], foldsSubTotals: NDArray[integer[Any]], gapsWhere: NDArray[integer[Any]], my: NDArray[integer[Any]], the: NDArray[integer[Any]], track: NDArray[integer[Any]]):
|
|
170
|
+
while activeLeafGreaterThan0Condition(my=my):
|
|
171
|
+
if activeLeafIsTheFirstLeafCondition(my=my) or leafBelowSentinelIs1Condition(track=track):
|
|
172
|
+
if activeLeafGreaterThanLeavesTotalCondition(my=my, the=the):
|
|
173
|
+
foldsSubTotalIncrement(foldsSubTotals=foldsSubTotals, my=my, the=the)
|
|
174
|
+
else:
|
|
175
|
+
findGapsInitializeVariables(my=my, track=track)
|
|
176
|
+
while loopingTheDimensions(my=my, the=the):
|
|
177
|
+
if dimensionsUnconstrainedCondition(connectionGraph=connectionGraph, my=my):
|
|
178
|
+
dimensionsUnconstrainedIncrement(my=my)
|
|
179
|
+
else:
|
|
180
|
+
leafConnecteeInitialization(connectionGraph=connectionGraph, my=my)
|
|
181
|
+
while loopingLeavesConnectedToActiveLeaf(my=my):
|
|
182
|
+
countGaps(gapsWhere=gapsWhere, my=my, track=track)
|
|
183
|
+
leafConnecteeUpdate(connectionGraph=connectionGraph, my=my, track=track)
|
|
184
|
+
dimension1ndexIncrement(my=my)
|
|
185
|
+
indexMiniGapInitialization(my=my)
|
|
186
|
+
while loopingToActiveGapCeiling(my=my):
|
|
187
|
+
filterCommonGaps(gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
188
|
+
indexMiniGapIncrement(my=my)
|
|
189
|
+
while backtrackCondition(my=my, track=track):
|
|
190
|
+
backtrack(my=my, track=track)
|
|
191
|
+
if placeLeafCondition(my=my):
|
|
192
|
+
placeLeaf(gapsWhere=gapsWhere, my=my, track=track)
|
|
193
|
+
|
|
194
|
+
@numba.jit(parallel=True, _nrt=True, boundscheck=False, error_model='numpy', fastmath=True, forceinline=True, looplift=False, no_cfunc_wrapper=True, no_cpython_wrapper=True, nogil=True, nopython=True)
|
|
195
|
+
def doTaskIndices(connectionGraph: NDArray[integer[Any]], foldsSubTotals: NDArray[integer[Any]], gapsWhere: NDArray[integer[Any]], my: NDArray[integer[Any]], the: NDArray[integer[Any]], track: NDArray[integer[Any]]):
|
|
196
|
+
|
|
197
|
+
stateGapsWhere = gapsWhere.copy()
|
|
198
|
+
stateMy = my.copy()
|
|
199
|
+
stateTrack = track.copy()
|
|
200
|
+
|
|
201
|
+
for indexSherpa in numba.prange(the[indexThe.taskDivisions.value]):
|
|
202
|
+
mySherpa = stateMy.copy()
|
|
203
|
+
mySherpa[indexMy.taskIndex.value] = indexSherpa
|
|
204
|
+
countParallel(connectionGraph=connectionGraph, foldsSubTotals=foldsSubTotals, gapsWhere=stateGapsWhere.copy(), my=mySherpa, the=the, track=stateTrack.copy())
|
|
205
|
+
|
|
206
|
+
return foldsSubTotals
|
|
207
|
+
|
|
208
|
+
def countFoldsCompiled(connectionGraph: NDArray[integer[Any]], foldsSubTotals: NDArray[integer[Any]], gapsWhere: NDArray[integer[Any]], my: NDArray[integer[Any]], the: NDArray[integer[Any]], track: NDArray[integer[Any]]):
|
|
209
|
+
|
|
210
|
+
initialize(connectionGraph=connectionGraph, gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
211
|
+
|
|
212
|
+
if the[indexThe.taskDivisions.value] > 0:
|
|
213
|
+
doTaskIndices(connectionGraph=connectionGraph, foldsSubTotals=foldsSubTotals, gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
214
|
+
else:
|
|
215
|
+
countSequential(connectionGraph=connectionGraph, foldsSubTotals=foldsSubTotals, gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
216
|
+
|
|
217
|
+
numba.jit_module(parallel=False, _nrt=True, boundscheck=False, error_model='numpy', fastmath=True, forceinline=True, looplift=False, no_cfunc_wrapper=True, no_cpython_wrapper=True, nogil=True, nopython=True)
|