mapFolding 0.2.2__py3-none-any.whl → 0.2.4__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 +1 -2
- mapFolding/babbage.py +10 -5
- mapFolding/beDRY.py +26 -15
- mapFolding/benchmarks/benchmarking.py +3 -2
- mapFolding/countInitialize.py +44 -0
- mapFolding/countParallel.py +49 -0
- mapFolding/countSequential.py +43 -0
- mapFolding/importSelector.py +12 -0
- mapFolding/inlineAfunction.py +124 -0
- mapFolding/lovelace.py +206 -138
- mapFolding/reference/flattened.py +376 -0
- mapFolding/startHere.py +7 -16
- mapFolding/theSSOT.py +14 -6
- {mapFolding-0.2.2.dist-info → mapFolding-0.2.4.dist-info}/METADATA +6 -4
- mapFolding-0.2.4.dist-info/RECORD +35 -0
- tests/__init__.py +1 -1
- tests/conftest.py +31 -6
- tests/pythons_idiotic_namespace.py +1 -0
- tests/test_other.py +193 -30
- tests/test_temporary.py +25 -0
- mapFolding/benchmarks/test_benchmarks.py +0 -74
- mapFolding-0.2.2.dist-info/RECORD +0 -28
- {mapFolding-0.2.2.dist-info → mapFolding-0.2.4.dist-info}/WHEEL +0 -0
- {mapFolding-0.2.2.dist-info → mapFolding-0.2.4.dist-info}/entry_points.txt +0 -0
- {mapFolding-0.2.2.dist-info → mapFolding-0.2.4.dist-info}/top_level.txt +0 -0
mapFolding/lovelace.py
CHANGED
|
@@ -1,145 +1,213 @@
|
|
|
1
|
-
"""
|
|
2
|
-
The algorithm for counting folds.
|
|
3
|
-
|
|
4
|
-
Starting from established data structures, the algorithm initializes some baseline values. The initialization uses a loop that is not used after the first fold is counted.
|
|
5
|
-
|
|
6
|
-
After initialization, the folds are either counted sequentially or counted with inefficiently divided parallel tasks.
|
|
7
|
-
|
|
8
|
-
All three of these actions--initialization, sequential counting, and parallel counting--use nearly identical logic. Without Numba, all of the logic is in one function with exactly one additional
|
|
9
|
-
conditional statement for initialization and exactly one additional conditional statement for parallel counting.
|
|
10
|
-
|
|
11
|
-
Numba's just-in-time (jit) compiler, especially super jit, is capable of radically increasing throughput and dramatically reducing the size of the compiled code, especially by ejecting unused code.
|
|
12
|
-
|
|
13
|
-
The complexity of this module is due to me allegedly applying Numba's features. Allegedly.
|
|
14
|
-
|
|
15
|
-
(The flow starts with the last function.)
|
|
16
|
-
"""
|
|
17
1
|
from mapFolding import indexMy, indexThe, indexTrack
|
|
18
|
-
from numpy import integer
|
|
19
|
-
from numpy.typing import NDArray
|
|
20
|
-
from typing import Any, Tuple, Optional
|
|
21
2
|
import numba
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
@numba.jit(parallel=False,
|
|
32
|
-
def
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
3
|
+
|
|
4
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
5
|
+
def activeGapIncrement(my):
|
|
6
|
+
my[indexMy.gap1ndex.value] += 1
|
|
7
|
+
|
|
8
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
9
|
+
def activeLeafGreaterThan0Condition(my):
|
|
10
|
+
return my[indexMy.leaf1ndex.value] > 0
|
|
11
|
+
|
|
12
|
+
@numba.jit((numba.int64[::1],numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
13
|
+
def activeLeafGreaterThanLeavesTotalCondition(my, the):
|
|
14
|
+
return my[indexMy.leaf1ndex.value] > the[indexThe.leavesTotal.value]
|
|
15
|
+
|
|
16
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
17
|
+
def activeLeafIsTheFirstLeafCondition(my):
|
|
18
|
+
return my[indexMy.leaf1ndex.value] <= 1
|
|
19
|
+
|
|
20
|
+
@numba.jit((numba.int64[::1],numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
21
|
+
def allDimensionsAreUnconstrained(my, the):
|
|
22
|
+
return my[indexMy.dimensionsUnconstrained.value] == the[indexThe.dimensionsTotal.value]
|
|
23
|
+
|
|
24
|
+
@numba.jit((numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
25
|
+
def backtrack(my, track):
|
|
26
|
+
my[indexMy.leaf1ndex.value] -= 1
|
|
27
|
+
track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]
|
|
28
|
+
track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]
|
|
29
|
+
|
|
30
|
+
@numba.jit((numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
31
|
+
def backtrackCondition(my, track):
|
|
32
|
+
return my[indexMy.leaf1ndex.value] > 0 and my[indexMy.gap1ndex.value] == track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
|
|
33
|
+
|
|
34
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
35
|
+
def gap1ndexCeilingIncrement(my):
|
|
36
|
+
my[indexMy.gap1ndexCeiling.value] += 1
|
|
37
|
+
|
|
38
|
+
@numba.jit((numba.int64[::1],numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
39
|
+
def countGaps(gapsWhere, my, track):
|
|
40
|
+
gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.leafConnectee.value]
|
|
41
|
+
if track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] == 0:
|
|
42
|
+
gap1ndexCeilingIncrement(my=my)
|
|
43
|
+
track[indexTrack.countDimensionsGapped.value, my[indexMy.leafConnectee.value]] += 1
|
|
44
|
+
|
|
45
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
46
|
+
def dimension1ndexIncrement(my):
|
|
47
|
+
my[indexMy.dimension1ndex.value] += 1
|
|
48
|
+
|
|
49
|
+
@numba.jit((numba.int64[:,:,::1], numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
50
|
+
def dimensionsUnconstrainedCondition(connectionGraph, my):
|
|
51
|
+
return connectionGraph[my[indexMy.dimension1ndex.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]] == my[indexMy.leaf1ndex.value]
|
|
52
|
+
|
|
53
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
54
|
+
def dimensionsUnconstrainedIncrement(my):
|
|
55
|
+
my[indexMy.dimensionsUnconstrained.value] += 1
|
|
56
|
+
|
|
57
|
+
@numba.jit((numba.int64[::1],numba.int64[::1],numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
58
|
+
def filterCommonGaps(gapsWhere, my, the, track):
|
|
59
|
+
gapsWhere[my[indexMy.gap1ndex.value]] = gapsWhere[my[indexMy.indexMiniGap.value]]
|
|
60
|
+
if track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] == the[indexThe.dimensionsTotal.value] - my[indexMy.dimensionsUnconstrained.value]:
|
|
61
|
+
activeGapIncrement(my=my)
|
|
62
|
+
track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] = 0
|
|
63
|
+
|
|
64
|
+
@numba.jit((numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
65
|
+
def findGapsInitializeVariables(my, track):
|
|
66
|
+
my[indexMy.dimensionsUnconstrained.value] = 0
|
|
67
|
+
my[indexMy.gap1ndexCeiling.value] = track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
|
|
68
|
+
my[indexMy.dimension1ndex.value] = 1
|
|
69
|
+
|
|
70
|
+
@numba.jit((numba.int64[::1],numba.int64[::1],numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
71
|
+
def foldsSubTotalIncrement(foldsSubTotals, my, the):
|
|
72
|
+
foldsSubTotals[my[indexMy.taskIndex.value]] += the[indexThe.leavesTotal.value]
|
|
73
|
+
|
|
74
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
75
|
+
def indexMiniGapIncrement(my):
|
|
76
|
+
my[indexMy.indexMiniGap.value] += 1
|
|
77
|
+
|
|
78
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
79
|
+
def indexMiniGapInitialization(my):
|
|
80
|
+
my[indexMy.indexMiniGap.value] = my[indexMy.gap1ndex.value]
|
|
81
|
+
|
|
82
|
+
@numba.jit((numba.int64[::1],numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
83
|
+
def insertUnconstrainedLeaf(gapsWhere, my):
|
|
84
|
+
my[indexMy.indexLeaf.value] = 0
|
|
85
|
+
while my[indexMy.indexLeaf.value] < my[indexMy.leaf1ndex.value]:
|
|
86
|
+
gapsWhere[my[indexMy.gap1ndexCeiling.value]] = my[indexMy.indexLeaf.value]
|
|
87
|
+
my[indexMy.gap1ndexCeiling.value] += 1
|
|
88
|
+
my[indexMy.indexLeaf.value] += 1
|
|
89
|
+
|
|
90
|
+
@numba.jit((numba.int64[:,::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
91
|
+
def leafBelowSentinelIs1Condition(track):
|
|
92
|
+
return track[indexTrack.leafBelow.value, 0] == 1
|
|
93
|
+
|
|
94
|
+
@numba.jit((numba.int64[:,:,::1], numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
95
|
+
def leafConnecteeInitialization(connectionGraph, my):
|
|
96
|
+
my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.dimension1ndex.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]]
|
|
97
|
+
|
|
98
|
+
@numba.jit((numba.int64[:,:,::1], numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
99
|
+
def leafConnecteeUpdate(connectionGraph, my, track):
|
|
100
|
+
my[indexMy.leafConnectee.value] = connectionGraph[my[indexMy.dimension1ndex.value], my[indexMy.leaf1ndex.value], track[indexTrack.leafBelow.value, my[indexMy.leafConnectee.value]]]
|
|
101
|
+
|
|
102
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
103
|
+
def loopingLeavesConnectedToActiveLeaf(my):
|
|
104
|
+
return my[indexMy.leafConnectee.value] != my[indexMy.leaf1ndex.value]
|
|
105
|
+
|
|
106
|
+
@numba.jit((numba.int64[::1],numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
107
|
+
def loopingTheDimensions(my, the):
|
|
108
|
+
return my[indexMy.dimension1ndex.value] <= the[indexThe.dimensionsTotal.value]
|
|
109
|
+
|
|
110
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
111
|
+
def loopingToActiveGapCeiling(my):
|
|
112
|
+
return my[indexMy.indexMiniGap.value] < my[indexMy.gap1ndexCeiling.value]
|
|
113
|
+
|
|
114
|
+
@numba.jit((numba.int64[::1],numba.int64[::1],numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
115
|
+
def placeLeaf(gapsWhere, my, track):
|
|
116
|
+
my[indexMy.gap1ndex.value] -= 1
|
|
117
|
+
track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]] = gapsWhere[my[indexMy.gap1ndex.value]]
|
|
118
|
+
track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]] = track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]]
|
|
119
|
+
track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
|
|
120
|
+
track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
|
|
121
|
+
track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value]] = my[indexMy.gap1ndex.value]
|
|
122
|
+
my[indexMy.leaf1ndex.value] += 1
|
|
123
|
+
|
|
124
|
+
@numba.jit((numba.int64[::1],), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
125
|
+
def placeLeafCondition(my):
|
|
126
|
+
return my[indexMy.leaf1ndex.value] > 0
|
|
127
|
+
|
|
128
|
+
@numba.jit((numba.int64[::1],numba.int64[::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
129
|
+
def thereAreComputationDivisionsYouMightSkip(my, the):
|
|
130
|
+
return my[indexMy.leaf1ndex.value] != the[indexThe.taskDivisions.value] or my[indexMy.leafConnectee.value] % the[indexThe.taskDivisions.value] == my[indexMy.taskIndex.value]
|
|
131
|
+
|
|
132
|
+
@numba.jit((numba.int64[:,:,::1], numba.int64[::1], numba.int64[::1], numba.int64[::1], numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
133
|
+
def countInitialize(connectionGraph, gapsWhere, my, the, track):
|
|
134
|
+
while activeLeafGreaterThan0Condition(my=my):
|
|
135
|
+
if activeLeafIsTheFirstLeafCondition(my=my) or leafBelowSentinelIs1Condition(track=track):
|
|
136
|
+
findGapsInitializeVariables(my=my, track=track)
|
|
137
|
+
while loopingTheDimensions(my=my, the=the):
|
|
138
|
+
if dimensionsUnconstrainedCondition(connectionGraph=connectionGraph, my=my):
|
|
139
|
+
dimensionsUnconstrainedIncrement(my=my)
|
|
140
|
+
else:
|
|
141
|
+
leafConnecteeInitialization(connectionGraph=connectionGraph, my=my)
|
|
142
|
+
while loopingLeavesConnectedToActiveLeaf(my=my):
|
|
143
|
+
countGaps(gapsWhere=gapsWhere, my=my, track=track)
|
|
144
|
+
leafConnecteeUpdate(connectionGraph=connectionGraph, my=my, track=track)
|
|
145
|
+
dimension1ndexIncrement(my=my)
|
|
146
|
+
if allDimensionsAreUnconstrained(my=my, the=the):
|
|
147
|
+
insertUnconstrainedLeaf(gapsWhere=gapsWhere, my=my)
|
|
148
|
+
indexMiniGapInitialization(my=my)
|
|
149
|
+
while loopingToActiveGapCeiling(my=my):
|
|
150
|
+
filterCommonGaps(gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
151
|
+
indexMiniGapIncrement(my=my)
|
|
152
|
+
if placeLeafCondition(my=my):
|
|
153
|
+
placeLeaf(gapsWhere=gapsWhere, my=my, track=track)
|
|
43
154
|
if my[indexMy.gap1ndex.value] > 0:
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if my[indexMy.leaf1ndex.value] > the[indexThe.leavesTotal.value]:
|
|
53
|
-
foldsTotal[my[indexMy.taskIndex.value]] += the[indexThe.leavesTotal.value]
|
|
155
|
+
return
|
|
156
|
+
|
|
157
|
+
@numba.jit((numba.int64[:,:,::1], numba.int64[::1], numba.int64[::1], numba.int64[::1], numba.int64[::1], numba.int64[:,::1]), parallel=False, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
158
|
+
def countSequential(connectionGraph, foldsSubTotals, gapsWhere, my, the, track):
|
|
159
|
+
while activeLeafGreaterThan0Condition(my=my):
|
|
160
|
+
if activeLeafIsTheFirstLeafCondition(my=my) or leafBelowSentinelIs1Condition(track=track):
|
|
161
|
+
if activeLeafGreaterThanLeavesTotalCondition(my=my, the=the):
|
|
162
|
+
foldsSubTotalIncrement(foldsSubTotals=foldsSubTotals, my=my, the=the)
|
|
54
163
|
else:
|
|
55
|
-
my
|
|
56
|
-
my
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if connectionGraph[my[indexMy.dimension1ndex.value], my[indexMy.leaf1ndex.value], my[indexMy.leaf1ndex.value]] == my[indexMy.leaf1ndex.value]:
|
|
60
|
-
my[indexMy.dimensionsUnconstrained.value] += 1
|
|
164
|
+
findGapsInitializeVariables(my=my, track=track)
|
|
165
|
+
while loopingTheDimensions(my=my, the=the):
|
|
166
|
+
if dimensionsUnconstrainedCondition(connectionGraph=connectionGraph, my=my):
|
|
167
|
+
dimensionsUnconstrainedIncrement(my=my)
|
|
61
168
|
else:
|
|
62
|
-
|
|
63
|
-
while my
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
my[indexMy.indexLeaf.value] += 1
|
|
79
|
-
my[indexMy.indexMiniGap.value] = my[indexMy.gap1ndex.value]
|
|
80
|
-
while my[indexMy.indexMiniGap.value] < my[indexMy.gap1ndexCeiling.value]:
|
|
81
|
-
gapsWhere[my[indexMy.gap1ndex.value]] = gapsWhere[my[indexMy.indexMiniGap.value]]
|
|
82
|
-
if track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] == the[indexThe.dimensionsTotal.value] - my[indexMy.dimensionsUnconstrained.value]:
|
|
83
|
-
my[indexMy.gap1ndex.value] += 1
|
|
84
|
-
track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] = 0
|
|
85
|
-
my[indexMy.indexMiniGap.value] += 1
|
|
86
|
-
while my[indexMy.leaf1ndex.value] > 0 and my[indexMy.gap1ndex.value] == track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]:
|
|
87
|
-
my[indexMy.leaf1ndex.value] -= 1
|
|
88
|
-
track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]
|
|
89
|
-
track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]
|
|
90
|
-
if my[indexMy.leaf1ndex.value] > 0:
|
|
91
|
-
my[indexMy.gap1ndex.value] -= 1
|
|
92
|
-
track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]] = gapsWhere[my[indexMy.gap1ndex.value]]
|
|
93
|
-
track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]] = track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]]
|
|
94
|
-
track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
|
|
95
|
-
track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = my[indexMy.leaf1ndex.value]
|
|
96
|
-
track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value]] = my[indexMy.gap1ndex.value]
|
|
97
|
-
my[indexMy.leaf1ndex.value] += 1
|
|
98
|
-
# NOTE This check and break should be absent from the code that does the counting
|
|
99
|
-
if initializationConditionUnconstrainedLeaf(my, initializeUnconstrainedLeaf):
|
|
100
|
-
break
|
|
101
|
-
return foldsTotal, my, gapsWhere, track
|
|
102
|
-
|
|
103
|
-
@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)
|
|
104
|
-
def doTaskIndices(connectionGraph: NDArray[integer[Any]], foldsTotal: NDArray[integer[Any]], my: NDArray[integer[Any]], gapsWhere: NDArray[integer[Any]], the: NDArray[integer[Any]], track: NDArray[integer[Any]]) -> NDArray[integer[Any]]:
|
|
105
|
-
"""This is the only function with the `parallel=True` option.
|
|
106
|
-
Make a copy of the initialized state because all task divisions can start from this baseline.
|
|
107
|
-
Run the counting algorithm but with conditional execution of a few lines of code, so each task has an incomplete count that does not overlap with other tasks."""
|
|
108
|
-
stateFoldsSubTotal = foldsTotal.copy()
|
|
109
|
-
stateMy = my.copy()
|
|
110
|
-
statePotentialGaps = gapsWhere.copy()
|
|
111
|
-
stateTrack = track.copy()
|
|
112
|
-
|
|
169
|
+
leafConnecteeInitialization(connectionGraph=connectionGraph, my=my)
|
|
170
|
+
while loopingLeavesConnectedToActiveLeaf(my=my):
|
|
171
|
+
countGaps(gapsWhere=gapsWhere, my=my, track=track)
|
|
172
|
+
leafConnecteeUpdate(connectionGraph=connectionGraph, my=my, track=track)
|
|
173
|
+
dimension1ndexIncrement(my=my)
|
|
174
|
+
indexMiniGapInitialization(my=my)
|
|
175
|
+
while loopingToActiveGapCeiling(my=my):
|
|
176
|
+
filterCommonGaps(gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
177
|
+
indexMiniGapIncrement(my=my)
|
|
178
|
+
while backtrackCondition(my=my, track=track):
|
|
179
|
+
backtrack(my=my, track=track)
|
|
180
|
+
if placeLeafCondition(my=my):
|
|
181
|
+
placeLeaf(gapsWhere=gapsWhere, my=my, track=track)
|
|
182
|
+
|
|
183
|
+
@numba.jit((numba.int64[:,:,::1], numba.int64[::1], numba.int64[::1],numba.int64[::1],numba.int64[::1],numba.int64[:,::1]), parallel=True, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
|
|
184
|
+
def countParallel(connectionGraph, foldsSubTotals, gapsWherePARALLEL, myPARALLEL, the, trackPARALLEL):
|
|
113
185
|
for indexSherpa in numba.prange(the[indexThe.taskDivisions.value]):
|
|
114
|
-
|
|
186
|
+
gapsWhere = gapsWherePARALLEL.copy()
|
|
187
|
+
my = myPARALLEL.copy()
|
|
115
188
|
my[indexMy.taskIndex.value] = indexSherpa
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
# Call the function that will branch to sequential or parallel counting
|
|
142
|
-
foldsTotal = countFoldsCompileBranch(connectionGraph, foldsTotal, my, gapsWhere, the, track, obviousFlagForNumba)
|
|
143
|
-
|
|
144
|
-
# Return an `int` integer
|
|
145
|
-
return numpy.sum(foldsTotal).item()
|
|
189
|
+
track = trackPARALLEL.copy()
|
|
190
|
+
while activeLeafGreaterThan0Condition(my=my):
|
|
191
|
+
if activeLeafIsTheFirstLeafCondition(my=my) or leafBelowSentinelIs1Condition(track=track):
|
|
192
|
+
if activeLeafGreaterThanLeavesTotalCondition(my=my, the=the):
|
|
193
|
+
foldsSubTotalIncrement(foldsSubTotals=foldsSubTotals, my=my, the=the)
|
|
194
|
+
else:
|
|
195
|
+
findGapsInitializeVariables(my=my, track=track)
|
|
196
|
+
while loopingTheDimensions(my=my, the=the):
|
|
197
|
+
if dimensionsUnconstrainedCondition(connectionGraph=connectionGraph, my=my):
|
|
198
|
+
dimensionsUnconstrainedIncrement(my=my)
|
|
199
|
+
else:
|
|
200
|
+
leafConnecteeInitialization(connectionGraph=connectionGraph, my=my)
|
|
201
|
+
while loopingLeavesConnectedToActiveLeaf(my=my):
|
|
202
|
+
if thereAreComputationDivisionsYouMightSkip(my=my, the=the):
|
|
203
|
+
countGaps(gapsWhere=gapsWhere, my=my, track=track)
|
|
204
|
+
leafConnecteeUpdate(connectionGraph=connectionGraph, my=my, track=track)
|
|
205
|
+
dimension1ndexIncrement(my=my)
|
|
206
|
+
indexMiniGapInitialization(my=my)
|
|
207
|
+
while loopingToActiveGapCeiling(my=my):
|
|
208
|
+
filterCommonGaps(gapsWhere=gapsWhere, my=my, the=the, track=track)
|
|
209
|
+
indexMiniGapIncrement(my=my)
|
|
210
|
+
while backtrackCondition(my=my, track=track):
|
|
211
|
+
backtrack(my=my, track=track)
|
|
212
|
+
if placeLeafCondition(my=my):
|
|
213
|
+
placeLeaf(gapsWhere=gapsWhere, my=my, track=track)
|