mapFolding 0.2.0__py3-none-any.whl → 0.2.2__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 -9
- mapFolding/babbage.py +19 -1
- mapFolding/beDRY.py +121 -70
- mapFolding/lovelace.py +41 -17
- mapFolding/oeis.py +59 -35
- mapFolding/reference/hunterNumba.py +44 -44
- mapFolding/reference/lunnan.py +5 -5
- mapFolding/reference/lunnanNumpy.py +4 -4
- mapFolding/reference/lunnanWhile.py +5 -5
- mapFolding/reference/rotatedEntryPoint.py +68 -68
- mapFolding/reference/total_countPlus1vsPlusN.py +211 -0
- mapFolding/startHere.py +37 -23
- mapFolding/theSSOT.py +6 -1
- {mapFolding-0.2.0.dist-info → mapFolding-0.2.2.dist-info}/METADATA +9 -46
- mapFolding-0.2.2.dist-info/RECORD +28 -0
- tests/conftest.py +95 -37
- tests/test_oeis.py +25 -26
- tests/test_other.py +43 -9
- tests/test_tasks.py +19 -6
- mapFolding/importPackages.py +0 -5
- mapFolding-0.2.0.dist-info/RECORD +0 -28
- {mapFolding-0.2.0.dist-info → mapFolding-0.2.2.dist-info}/WHEEL +0 -0
- {mapFolding-0.2.0.dist-info → mapFolding-0.2.2.dist-info}/entry_points.txt +0 -0
- {mapFolding-0.2.0.dist-info → mapFolding-0.2.2.dist-info}/top_level.txt +0 -0
|
@@ -46,15 +46,15 @@ def countFolds(listDimensions: List[int]) -> int:
|
|
|
46
46
|
|
|
47
47
|
"""Step for... for... for...: fill the connection graph"""
|
|
48
48
|
for dimension1ndex in range(1, dimensionsTotal + 1):
|
|
49
|
-
for
|
|
50
|
-
for
|
|
51
|
-
connectionGraph[dimension1ndex,
|
|
52
|
-
else ((
|
|
53
|
-
else
|
|
54
|
-
if (coordinateSystem[dimension1ndex,
|
|
55
|
-
else (
|
|
56
|
-
or
|
|
57
|
-
else
|
|
49
|
+
for leaf1ndex in range(1, leavesTotal + 1):
|
|
50
|
+
for leafConnectee in range(1, leaf1ndex + 1):
|
|
51
|
+
connectionGraph[dimension1ndex, leaf1ndex, leafConnectee] = (0 if leafConnectee == 0
|
|
52
|
+
else ((leafConnectee if coordinateSystem[dimension1ndex, leafConnectee] == 1
|
|
53
|
+
else leafConnectee - cumulativeProduct[dimension1ndex - 1])
|
|
54
|
+
if (coordinateSystem[dimension1ndex, leaf1ndex] & 1) == (coordinateSystem[dimension1ndex, leafConnectee] & 1)
|
|
55
|
+
else (leafConnectee if coordinateSystem[dimension1ndex, leafConnectee] == listDimensions[dimension1ndex-1]
|
|
56
|
+
or leafConnectee + cumulativeProduct[dimension1ndex - 1] > leaf1ndex
|
|
57
|
+
else leafConnectee + cumulativeProduct[dimension1ndex - 1])))
|
|
58
58
|
|
|
59
59
|
"""Indices of array `track` (to "track" the execution state), which is a collection of one-dimensional arrays each of length `leavesTotal + 1`."""
|
|
60
60
|
leafAbove = numba.literally(0)
|
|
@@ -66,67 +66,67 @@ def countFolds(listDimensions: List[int]) -> int:
|
|
|
66
66
|
gapsWhere = numpy.zeros(integerLarge(integerLarge(leavesTotal) * integerLarge(leavesTotal) + 1), dtype=dtypeMaximum)
|
|
67
67
|
|
|
68
68
|
foldsTotal = integerLarge(0)
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
leaf1ndex = integerSmall(1)
|
|
70
|
+
gap1ndex = integerSmall(0)
|
|
71
71
|
|
|
72
|
-
while
|
|
73
|
-
if
|
|
74
|
-
if
|
|
72
|
+
while leaf1ndex > 0:
|
|
73
|
+
if leaf1ndex <= 1 or track[leafBelow, 0] == 1:
|
|
74
|
+
if leaf1ndex > leavesTotal:
|
|
75
75
|
foldsTotal += leavesTotal
|
|
76
76
|
else:
|
|
77
77
|
dimensionsUnconstrained = integerSmall(0)
|
|
78
|
-
"""Track possible gaps for
|
|
79
|
-
gap1ndexCeiling = track[gapRangeStart,
|
|
78
|
+
"""Track possible gaps for leaf1ndex in each section"""
|
|
79
|
+
gap1ndexCeiling = track[gapRangeStart, leaf1ndex - 1]
|
|
80
80
|
|
|
81
|
-
"""Count possible gaps for
|
|
81
|
+
"""Count possible gaps for leaf1ndex in each section"""
|
|
82
82
|
dimension1ndex = integerSmall(1)
|
|
83
83
|
while dimension1ndex <= dimensionsTotal:
|
|
84
|
-
if connectionGraph[dimension1ndex,
|
|
84
|
+
if connectionGraph[dimension1ndex, leaf1ndex, leaf1ndex] == leaf1ndex:
|
|
85
85
|
dimensionsUnconstrained += 1
|
|
86
86
|
else:
|
|
87
|
-
|
|
88
|
-
while
|
|
89
|
-
gapsWhere[gap1ndexCeiling] =
|
|
90
|
-
if track[countDimensionsGapped,
|
|
87
|
+
leafConnectee = connectionGraph[dimension1ndex, leaf1ndex, leaf1ndex]
|
|
88
|
+
while leafConnectee != leaf1ndex:
|
|
89
|
+
gapsWhere[gap1ndexCeiling] = leafConnectee
|
|
90
|
+
if track[countDimensionsGapped, leafConnectee] == 0:
|
|
91
91
|
gap1ndexCeiling += 1
|
|
92
|
-
track[countDimensionsGapped,
|
|
93
|
-
|
|
92
|
+
track[countDimensionsGapped, leafConnectee] += 1
|
|
93
|
+
leafConnectee = connectionGraph[dimension1ndex, leaf1ndex, track[leafBelow, leafConnectee]]
|
|
94
94
|
dimension1ndex += 1
|
|
95
95
|
|
|
96
|
-
"""If
|
|
96
|
+
"""If leaf1ndex is unconstrained in all sections, it can be inserted anywhere"""
|
|
97
97
|
if dimensionsUnconstrained == dimensionsTotal:
|
|
98
|
-
|
|
99
|
-
while
|
|
100
|
-
gapsWhere[gap1ndexCeiling] =
|
|
98
|
+
indexLeaf = integerSmall(0)
|
|
99
|
+
while indexLeaf < leaf1ndex:
|
|
100
|
+
gapsWhere[gap1ndexCeiling] = indexLeaf
|
|
101
101
|
gap1ndexCeiling += 1
|
|
102
|
-
|
|
102
|
+
indexLeaf += 1
|
|
103
103
|
|
|
104
104
|
"""Filter gaps that are common to all sections"""
|
|
105
|
-
indexMiniGap =
|
|
105
|
+
indexMiniGap = gap1ndex
|
|
106
106
|
while indexMiniGap < gap1ndexCeiling:
|
|
107
|
-
gapsWhere[
|
|
107
|
+
gapsWhere[gap1ndex] = gapsWhere[indexMiniGap]
|
|
108
108
|
if track[countDimensionsGapped, gapsWhere[indexMiniGap]] == dimensionsTotal - dimensionsUnconstrained:
|
|
109
|
-
|
|
109
|
+
gap1ndex += 1
|
|
110
110
|
"""Reset track[countDimensionsGapped] for next iteration"""
|
|
111
111
|
track[countDimensionsGapped, gapsWhere[indexMiniGap]] = 0
|
|
112
112
|
indexMiniGap += 1
|
|
113
113
|
|
|
114
114
|
"""Recursive backtracking steps"""
|
|
115
|
-
while
|
|
116
|
-
|
|
117
|
-
track[leafBelow, track[leafAbove,
|
|
118
|
-
track[leafAbove, track[leafBelow,
|
|
115
|
+
while leaf1ndex > 0 and gap1ndex == track[gapRangeStart, leaf1ndex - 1]:
|
|
116
|
+
leaf1ndex -= 1
|
|
117
|
+
track[leafBelow, track[leafAbove, leaf1ndex]] = track[leafBelow, leaf1ndex]
|
|
118
|
+
track[leafAbove, track[leafBelow, leaf1ndex]] = track[leafAbove, leaf1ndex]
|
|
119
119
|
|
|
120
120
|
"""Place leaf in valid position"""
|
|
121
|
-
if
|
|
122
|
-
|
|
123
|
-
track[leafAbove,
|
|
124
|
-
track[leafBelow,
|
|
125
|
-
track[leafBelow, track[leafAbove,
|
|
126
|
-
track[leafAbove, track[leafBelow,
|
|
121
|
+
if leaf1ndex > 0:
|
|
122
|
+
gap1ndex -= 1
|
|
123
|
+
track[leafAbove, leaf1ndex] = gapsWhere[gap1ndex]
|
|
124
|
+
track[leafBelow, leaf1ndex] = track[leafBelow, track[leafAbove, leaf1ndex]]
|
|
125
|
+
track[leafBelow, track[leafAbove, leaf1ndex]] = leaf1ndex
|
|
126
|
+
track[leafAbove, track[leafBelow, leaf1ndex]] = leaf1ndex
|
|
127
127
|
"""Save current gap index"""
|
|
128
|
-
track[gapRangeStart,
|
|
128
|
+
track[gapRangeStart, leaf1ndex] = gap1ndex
|
|
129
129
|
"""Move to next leaf"""
|
|
130
|
-
|
|
130
|
+
leaf1ndex += 1
|
|
131
131
|
|
|
132
132
|
return int(foldsTotal)
|
mapFolding/reference/lunnan.py
CHANGED
|
@@ -9,11 +9,11 @@ def foldings(p, job=None):
|
|
|
9
9
|
p.insert(0, None) # NOTE mimics Atlas `array` type
|
|
10
10
|
|
|
11
11
|
if job is None:
|
|
12
|
-
global
|
|
13
|
-
|
|
12
|
+
global G
|
|
13
|
+
G = 0
|
|
14
14
|
def job(A, B):
|
|
15
|
-
global
|
|
16
|
-
|
|
15
|
+
global G
|
|
16
|
+
G = G + 1
|
|
17
17
|
return foldings(p, job)
|
|
18
18
|
# perform job (A, B) on each folding of a p[1] x ... x p[d] map,
|
|
19
19
|
# where A and B are the above and below vectors. p[d + 1] < 0 terminates p;
|
|
@@ -150,4 +150,4 @@ def foldings(p, job=None):
|
|
|
150
150
|
else:
|
|
151
151
|
break
|
|
152
152
|
|
|
153
|
-
return
|
|
153
|
+
return G #if job.__closure__ else None
|
|
@@ -13,7 +13,7 @@ def foldings(p: List[int]) -> int:
|
|
|
13
13
|
p: A list of integers representing the dimensions of the map.
|
|
14
14
|
|
|
15
15
|
Returns:
|
|
16
|
-
|
|
16
|
+
G: The number of distinct foldings for the given map dimensions.
|
|
17
17
|
|
|
18
18
|
NOTE If there are fewer than two dimensions, any dimensions are not positive, or any dimensions are not integers, the output will be unreliable.
|
|
19
19
|
"""
|
|
@@ -65,14 +65,14 @@ def foldings(p: List[int]) -> int:
|
|
|
65
65
|
# P[i] = p[1] x ... x p[i], C[i][m] = i-th co-ordinate of leaf m,
|
|
66
66
|
# D[i][l][m] = leaf connected to m in section i when inserting l;
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
G: int = 0
|
|
69
69
|
l: int = 1
|
|
70
70
|
|
|
71
71
|
# kick off with null folding
|
|
72
72
|
while l > 0:
|
|
73
73
|
if l <= 1 or B[0] == 1: # NOTE This statement is part of a significant divergence from the 1971 paper. As a result, this version is greater than one order of magnitude faster.
|
|
74
74
|
if l > n:
|
|
75
|
-
|
|
75
|
+
G = G + n # NOTE Due to `B[0] == 1`, this implementation increments the counted foldings in batches of `n`-many foldings, rather than immediately incrementing when a folding is found, i.e. `G = G + 1`
|
|
76
76
|
else:
|
|
77
77
|
dd: int = 0
|
|
78
78
|
gg: int = gapter[l - 1]
|
|
@@ -120,4 +120,4 @@ def foldings(p: List[int]) -> int:
|
|
|
120
120
|
A[B[l]] = l
|
|
121
121
|
gapter[l] = g
|
|
122
122
|
l = l + 1
|
|
123
|
-
return
|
|
123
|
+
return G
|
|
@@ -12,7 +12,7 @@ def foldings(p: Sequence[int]) -> int:
|
|
|
12
12
|
p: An array of integers representing the dimensions of the map.
|
|
13
13
|
|
|
14
14
|
Returns:
|
|
15
|
-
|
|
15
|
+
G: The number of distinct foldings for the given map dimensions.
|
|
16
16
|
|
|
17
17
|
NOTE If there are fewer than two dimensions, any dimensions are not positive, or any dimensions are not integers, the output will be unreliable.
|
|
18
18
|
"""
|
|
@@ -29,7 +29,7 @@ def foldings(p: Sequence[int]) -> int:
|
|
|
29
29
|
B = [0] * (n + 1)
|
|
30
30
|
count = [0] * (n + 1)
|
|
31
31
|
gapter = [0] * (n + 1)
|
|
32
|
-
gap = [0] * (n * n + 1)
|
|
32
|
+
gap = [0] * (n * n + 1)
|
|
33
33
|
|
|
34
34
|
# B[m] is the leaf below leaf m in the current folding,
|
|
35
35
|
# A[m] the leaf above. count[m] is the no. of sections in which
|
|
@@ -64,13 +64,13 @@ def foldings(p: Sequence[int]) -> int:
|
|
|
64
64
|
# P[i] = p[1] x ... x p[i], C[i][m] = i-th co-ordinate of leaf m,
|
|
65
65
|
# D[i][l][m] = leaf connected to m in section i when inserting l;
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
G: int = 0
|
|
68
68
|
l: int = 1
|
|
69
69
|
|
|
70
70
|
# kick off with null folding
|
|
71
71
|
while l > 0:
|
|
72
72
|
if l > n:
|
|
73
|
-
|
|
73
|
+
G = G + 1
|
|
74
74
|
else:
|
|
75
75
|
dd: int = 0
|
|
76
76
|
gg: int = gapter[l - 1]
|
|
@@ -118,4 +118,4 @@ def foldings(p: Sequence[int]) -> int:
|
|
|
118
118
|
A[B[l]] = l
|
|
119
119
|
gapter[l] = g
|
|
120
120
|
l = l + 1
|
|
121
|
-
return
|
|
121
|
+
return G
|
|
@@ -21,11 +21,11 @@ gapter = gapRangeStart = 3
|
|
|
21
21
|
|
|
22
22
|
# Indices of array `my`, which holds dynamic, small, unsigned, integer values.
|
|
23
23
|
tricky = [
|
|
24
|
-
(
|
|
25
|
-
(
|
|
24
|
+
(leaf1ndex := 0),
|
|
25
|
+
(gap1ndex := 1),
|
|
26
26
|
(unconstrainedLeaf := 2),
|
|
27
27
|
(gap1ndexCeiling := 3),
|
|
28
|
-
(
|
|
28
|
+
(leafConnectee := 4),
|
|
29
29
|
(taskIndex := 5),
|
|
30
30
|
(dimension1ndex := 6),
|
|
31
31
|
(foldingsSubtotal := 7),
|
|
@@ -76,7 +76,7 @@ def countFoldings(TEMPLATEtrack: NDArray,
|
|
|
76
76
|
):
|
|
77
77
|
|
|
78
78
|
TEMPLATEmy = numpy.zeros(COUNTindicesDynamic, dtype=numpy.int64)
|
|
79
|
-
TEMPLATEmy[
|
|
79
|
+
TEMPLATEmy[leaf1ndex] = 1
|
|
80
80
|
|
|
81
81
|
taskDivisions = 0
|
|
82
82
|
# taskDivisions = the[leavesTotal]
|
|
@@ -87,61 +87,61 @@ def countFoldings(TEMPLATEtrack: NDArray,
|
|
|
87
87
|
my: NDArray) -> tuple[NDArray, NDArray, NDArray]:
|
|
88
88
|
foldingsTotal = 0
|
|
89
89
|
while True:
|
|
90
|
-
if my[
|
|
91
|
-
if my[
|
|
90
|
+
if my[leaf1ndex] <= 1 or track[leafBelow][0] == 1:
|
|
91
|
+
if my[leaf1ndex] > the[leavesTotal]:
|
|
92
92
|
foldingsTotal += the[leavesTotal]
|
|
93
93
|
else:
|
|
94
94
|
my[unconstrainedLeaf] = 0
|
|
95
|
-
my[gap1ndexCeiling] = track[gapRangeStart][my[
|
|
96
|
-
my[
|
|
95
|
+
my[gap1ndexCeiling] = track[gapRangeStart][my[leaf1ndex] - 1]
|
|
96
|
+
my[gap1ndex] = my[gap1ndexCeiling]
|
|
97
97
|
|
|
98
98
|
for PREPAREdimension1ndex in range(1, the[dimensionsPlus1]):
|
|
99
|
-
if connectionGraph[PREPAREdimension1ndex][my[
|
|
99
|
+
if connectionGraph[PREPAREdimension1ndex][my[leaf1ndex]][my[leaf1ndex]] == my[leaf1ndex]:
|
|
100
100
|
my[unconstrainedLeaf] += 1
|
|
101
101
|
else:
|
|
102
|
-
my[
|
|
103
|
-
while my[
|
|
102
|
+
my[leafConnectee] = connectionGraph[PREPAREdimension1ndex][my[leaf1ndex]][my[leaf1ndex]]
|
|
103
|
+
while my[leafConnectee] != my[leaf1ndex]:
|
|
104
104
|
|
|
105
|
-
if my[
|
|
105
|
+
if my[leafConnectee] != my[leaf1ndex]:
|
|
106
106
|
my[dimension1ndex] = PREPAREdimension1ndex
|
|
107
107
|
return track, gapsWhere, my
|
|
108
108
|
|
|
109
|
-
if my[
|
|
110
|
-
gapsWhere[my[gap1ndexCeiling]] = my[
|
|
111
|
-
if track[countDimensionsGapped][my[
|
|
109
|
+
if my[leaf1ndex] != the[leavesTotal]:
|
|
110
|
+
gapsWhere[my[gap1ndexCeiling]] = my[leafConnectee]
|
|
111
|
+
if track[countDimensionsGapped][my[leafConnectee]] == 0:
|
|
112
112
|
my[gap1ndexCeiling] += 1
|
|
113
|
-
track[countDimensionsGapped][my[
|
|
113
|
+
track[countDimensionsGapped][my[leafConnectee]] += 1
|
|
114
114
|
else:
|
|
115
115
|
print("else")
|
|
116
116
|
my[dimension1ndex] = PREPAREdimension1ndex
|
|
117
117
|
return track, gapsWhere, my
|
|
118
|
-
# PREPAREmy[
|
|
119
|
-
my[
|
|
118
|
+
# PREPAREmy[leafConnectee] % the[leavesTotal] == PREPAREmy[taskIndex]
|
|
119
|
+
my[leafConnectee] = connectionGraph[dimension1ndex][my[leaf1ndex]][track[leafBelow][my[leafConnectee]]]
|
|
120
120
|
|
|
121
121
|
if my[unconstrainedLeaf] == the[dimensionsTotal]:
|
|
122
|
-
for
|
|
123
|
-
gapsWhere[my[gap1ndexCeiling]] =
|
|
122
|
+
for indexLeaf in range(my[leaf1ndex]):
|
|
123
|
+
gapsWhere[my[gap1ndexCeiling]] = indexLeaf
|
|
124
124
|
my[gap1ndexCeiling] += 1
|
|
125
125
|
|
|
126
|
-
for indexMiniGap in range(my[
|
|
127
|
-
gapsWhere[my[
|
|
126
|
+
for indexMiniGap in range(my[gap1ndex], my[gap1ndexCeiling]):
|
|
127
|
+
gapsWhere[my[gap1ndex]] = gapsWhere[indexMiniGap]
|
|
128
128
|
if track[countDimensionsGapped][gapsWhere[indexMiniGap]] == the[dimensionsTotal] - my[unconstrainedLeaf]:
|
|
129
|
-
my[
|
|
129
|
+
my[gap1ndex] += 1
|
|
130
130
|
track[countDimensionsGapped][gapsWhere[indexMiniGap]] = 0
|
|
131
131
|
|
|
132
|
-
while my[
|
|
133
|
-
my[
|
|
134
|
-
track[leafBelow][track[leafAbove][my[
|
|
135
|
-
track[leafAbove][track[leafBelow][my[
|
|
132
|
+
while my[leaf1ndex] > 0 and my[gap1ndex] == track[gapRangeStart][my[leaf1ndex] - 1]:
|
|
133
|
+
my[leaf1ndex] -= 1
|
|
134
|
+
track[leafBelow][track[leafAbove][my[leaf1ndex]]] = track[leafBelow][my[leaf1ndex]]
|
|
135
|
+
track[leafAbove][track[leafBelow][my[leaf1ndex]]] = track[leafAbove][my[leaf1ndex]]
|
|
136
136
|
|
|
137
|
-
if my[
|
|
138
|
-
my[
|
|
139
|
-
track[leafAbove][my[
|
|
140
|
-
track[leafBelow][my[
|
|
141
|
-
track[leafBelow][track[leafAbove][my[
|
|
142
|
-
track[leafAbove][track[leafBelow][my[
|
|
143
|
-
track[gapRangeStart][my[
|
|
144
|
-
my[
|
|
137
|
+
if my[leaf1ndex] > 0:
|
|
138
|
+
my[gap1ndex] -= 1
|
|
139
|
+
track[leafAbove][my[leaf1ndex]] = gapsWhere[my[gap1ndex]]
|
|
140
|
+
track[leafBelow][my[leaf1ndex]] = track[leafBelow][track[leafAbove][my[leaf1ndex]]]
|
|
141
|
+
track[leafBelow][track[leafAbove][my[leaf1ndex]]] = my[leaf1ndex]
|
|
142
|
+
track[leafAbove][track[leafBelow][my[leaf1ndex]]] = my[leaf1ndex]
|
|
143
|
+
track[gapRangeStart][my[leaf1ndex]] = my[gap1ndex]
|
|
144
|
+
my[leaf1ndex] += 1
|
|
145
145
|
|
|
146
146
|
RETURNtrack, RETURNgapsWhere, RETURNmy = prepareWork(TEMPLATEtrack.copy(), TEMPLATEgapsWhere.copy(), TEMPLATEmy.copy())
|
|
147
147
|
|
|
@@ -166,44 +166,44 @@ def doWork(track: NDArray,
|
|
|
166
166
|
thisIsNotTheFirstPass = False
|
|
167
167
|
|
|
168
168
|
while papasGotABrandNewBag:
|
|
169
|
-
if my[
|
|
169
|
+
if my[leaf1ndex] <= 1 or track[leafBelow][0] == 1 or if_activeLeaf1ndex_LTE_1_or_leafBelow_index_0_equals_1 == True:
|
|
170
170
|
if_activeLeaf1ndex_LTE_1_or_leafBelow_index_0_equals_1 = False
|
|
171
|
-
if my[
|
|
171
|
+
if my[leaf1ndex] > the[leavesTotal] and thisIsNotTheFirstPass:
|
|
172
172
|
my[foldingsSubtotal] += the[leavesTotal]
|
|
173
173
|
else:
|
|
174
174
|
if thisIsNotTheFirstPass:
|
|
175
175
|
my[unconstrainedLeaf] = 0
|
|
176
|
-
my[gap1ndexCeiling] = track[gapRangeStart][my[
|
|
177
|
-
my[
|
|
176
|
+
my[gap1ndexCeiling] = track[gapRangeStart][my[leaf1ndex] - 1]
|
|
177
|
+
my[gap1ndex] = my[gap1ndexCeiling]
|
|
178
178
|
|
|
179
179
|
for_dimension1ndex_in_range_1_to_dimensionsPlus1 = True
|
|
180
180
|
while for_dimension1ndex_in_range_1_to_dimensionsPlus1 == True:
|
|
181
181
|
for_dimension1ndex_in_range_1_to_dimensionsPlus1 = False
|
|
182
|
-
if connectionGraph[my[dimension1ndex]][my[
|
|
182
|
+
if connectionGraph[my[dimension1ndex]][my[leaf1ndex]][my[leaf1ndex]] == my[leaf1ndex] and thisIsNotTheFirstPass:
|
|
183
183
|
my[unconstrainedLeaf] += 1
|
|
184
184
|
else:
|
|
185
185
|
if thisIsNotTheFirstPass:
|
|
186
|
-
my[
|
|
187
|
-
if my[
|
|
186
|
+
my[leafConnectee] = connectionGraph[my[dimension1ndex]][my[leaf1ndex]][my[leaf1ndex]]
|
|
187
|
+
if my[leafConnectee] != my[leaf1ndex]:
|
|
188
188
|
while_leaf1ndexConnectee_notEquals_activeLeaf1ndex = True
|
|
189
189
|
|
|
190
190
|
while while_leaf1ndexConnectee_notEquals_activeLeaf1ndex == True:
|
|
191
191
|
while_leaf1ndexConnectee_notEquals_activeLeaf1ndex = False
|
|
192
192
|
thisIsNotTheFirstPass = True
|
|
193
|
-
if taskDivisions==0 or my[
|
|
193
|
+
if taskDivisions==0 or my[leaf1ndex] != taskDivisions:
|
|
194
194
|
myTask = True
|
|
195
195
|
else:
|
|
196
|
-
modulo = my[
|
|
196
|
+
modulo = my[leafConnectee] % the[leavesTotal]
|
|
197
197
|
if modulo == my[taskIndex]: myTask = True
|
|
198
198
|
else:
|
|
199
199
|
myTask = False
|
|
200
200
|
if myTask:
|
|
201
|
-
gapsWhere[my[gap1ndexCeiling]] = my[
|
|
202
|
-
if track[countDimensionsGapped][my[
|
|
201
|
+
gapsWhere[my[gap1ndexCeiling]] = my[leafConnectee]
|
|
202
|
+
if track[countDimensionsGapped][my[leafConnectee]] == 0:
|
|
203
203
|
my[gap1ndexCeiling] += 1
|
|
204
|
-
track[countDimensionsGapped][my[
|
|
205
|
-
my[
|
|
206
|
-
if my[
|
|
204
|
+
track[countDimensionsGapped][my[leafConnectee]] += 1
|
|
205
|
+
my[leafConnectee] = connectionGraph[my[dimension1ndex]][my[leaf1ndex]][track[leafBelow][my[leafConnectee]]]
|
|
206
|
+
if my[leafConnectee] != my[leaf1ndex]:
|
|
207
207
|
while_leaf1ndexConnectee_notEquals_activeLeaf1ndex = True
|
|
208
208
|
my[dimension1ndex] += 1
|
|
209
209
|
if my[dimension1ndex] < the[dimensionsPlus1]:
|
|
@@ -212,29 +212,29 @@ def doWork(track: NDArray,
|
|
|
212
212
|
my[dimension1ndex] = 1
|
|
213
213
|
|
|
214
214
|
if my[unconstrainedLeaf] == the[dimensionsTotal]:
|
|
215
|
-
for leaf1ndex in range(my[
|
|
215
|
+
for leaf1ndex in range(my[leaf1ndex]):
|
|
216
216
|
gapsWhere[my[gap1ndexCeiling]] = leaf1ndex
|
|
217
217
|
my[gap1ndexCeiling] += 1
|
|
218
218
|
|
|
219
|
-
for indexMiniGap in range(my[
|
|
220
|
-
gapsWhere[my[
|
|
219
|
+
for indexMiniGap in range(my[gap1ndex], my[gap1ndexCeiling]):
|
|
220
|
+
gapsWhere[my[gap1ndex]] = gapsWhere[indexMiniGap]
|
|
221
221
|
if track[countDimensionsGapped][gapsWhere[indexMiniGap]] == the[dimensionsTotal] - my[unconstrainedLeaf]:
|
|
222
|
-
my[
|
|
222
|
+
my[gap1ndex] += 1
|
|
223
223
|
track[countDimensionsGapped][gapsWhere[indexMiniGap]] = 0
|
|
224
224
|
|
|
225
|
-
while my[
|
|
226
|
-
my[
|
|
227
|
-
track[leafBelow][track[leafAbove][my[
|
|
228
|
-
track[leafAbove][track[leafBelow][my[
|
|
229
|
-
|
|
230
|
-
if my[
|
|
231
|
-
my[
|
|
232
|
-
track[leafAbove][my[
|
|
233
|
-
track[leafBelow][my[
|
|
234
|
-
track[leafBelow][track[leafAbove][my[
|
|
235
|
-
track[leafAbove][track[leafBelow][my[
|
|
236
|
-
track[gapRangeStart][my[
|
|
237
|
-
my[
|
|
238
|
-
|
|
239
|
-
if my[
|
|
225
|
+
while my[leaf1ndex] > 0 and my[gap1ndex] == track[gapRangeStart][my[leaf1ndex] - 1]:
|
|
226
|
+
my[leaf1ndex] -= 1
|
|
227
|
+
track[leafBelow][track[leafAbove][my[leaf1ndex]]] = track[leafBelow][my[leaf1ndex]]
|
|
228
|
+
track[leafAbove][track[leafBelow][my[leaf1ndex]]] = track[leafAbove][my[leaf1ndex]]
|
|
229
|
+
|
|
230
|
+
if my[leaf1ndex] > 0:
|
|
231
|
+
my[gap1ndex] -= 1
|
|
232
|
+
track[leafAbove][my[leaf1ndex]] = gapsWhere[my[gap1ndex]]
|
|
233
|
+
track[leafBelow][my[leaf1ndex]] = track[leafBelow][track[leafAbove][my[leaf1ndex]]]
|
|
234
|
+
track[leafBelow][track[leafAbove][my[leaf1ndex]]] = my[leaf1ndex]
|
|
235
|
+
track[leafAbove][track[leafBelow][my[leaf1ndex]]] = my[leaf1ndex]
|
|
236
|
+
track[gapRangeStart][my[leaf1ndex]] = my[gap1ndex]
|
|
237
|
+
my[leaf1ndex] += 1
|
|
238
|
+
|
|
239
|
+
if my[leaf1ndex] <= 0:
|
|
240
240
|
return my[foldingsSubtotal]
|