mapFolding 0.2.6__py3-none-any.whl → 0.3.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 (39) hide show
  1. {mapFolding-0.2.6.dist-info → mapFolding-0.3.0.dist-info}/METADATA +23 -7
  2. mapFolding-0.3.0.dist-info/RECORD +20 -0
  3. mapFolding-0.3.0.dist-info/top_level.txt +3 -0
  4. someAssemblyRequired/__init__.py +3 -0
  5. someAssemblyRequired/countInitialize.py +45 -0
  6. someAssemblyRequired/countParallel.py +52 -0
  7. someAssemblyRequired/countSequential.py +59 -0
  8. mapFolding/someAssemblyRequired/inlineAfunction.py → someAssemblyRequired/synthesizeModules.py +76 -41
  9. mapFolding/__init__.py +0 -12
  10. mapFolding/babbage.py +0 -35
  11. mapFolding/beDRY.py +0 -319
  12. mapFolding/importSelector.py +0 -7
  13. mapFolding/lovelace.py +0 -213
  14. mapFolding/oeis.py +0 -323
  15. mapFolding/someAssemblyRequired/jobsAndTasks.py +0 -47
  16. mapFolding/someAssemblyRequired/makeNuitkaSource.py +0 -99
  17. mapFolding/someAssemblyRequired/makeNumbaJob.py +0 -144
  18. mapFolding/startHere.py +0 -50
  19. mapFolding/theSSOT.py +0 -76
  20. mapFolding-0.2.6.dist-info/RECORD +0 -33
  21. mapFolding-0.2.6.dist-info/top_level.txt +0 -2
  22. tests/__init__.py +0 -1
  23. tests/conftest.py +0 -343
  24. tests/pythons_idiotic_namespace.py +0 -1
  25. tests/test_oeis.py +0 -194
  26. tests/test_other.py +0 -282
  27. tests/test_tasks.py +0 -31
  28. {mapFolding/benchmarks → benchmarks}/benchmarking.py +0 -0
  29. {mapFolding-0.2.6.dist-info → mapFolding-0.3.0.dist-info}/WHEEL +0 -0
  30. {mapFolding-0.2.6.dist-info → mapFolding-0.3.0.dist-info}/entry_points.txt +0 -0
  31. {mapFolding/reference → reference}/flattened.py +0 -0
  32. {mapFolding/reference → reference}/hunterNumba.py +0 -0
  33. {mapFolding/reference → reference}/irvineJavaPort.py +0 -0
  34. {mapFolding/reference → reference}/jax.py +0 -0
  35. {mapFolding/reference → reference}/lunnan.py +0 -0
  36. {mapFolding/reference → reference}/lunnanNumpy.py +0 -0
  37. {mapFolding/reference → reference}/lunnanWhile.py +0 -0
  38. {mapFolding/reference → reference}/rotatedEntryPoint.py +0 -0
  39. {mapFolding/reference → reference}/total_countPlus1vsPlusN.py +0 -0
mapFolding/beDRY.py DELETED
@@ -1,319 +0,0 @@
1
- """A relatively stable API for oft-needed functionality."""
2
- from mapFolding import dtypeDefault, dtypeLarge, dtypeSmall, pathJobDEFAULT
3
- from mapFolding import indexMy, indexTrack, computationState
4
- from mapFolding import intInnit, defineConcurrencyLimit, oopsieKwargsie
5
- from numpy import integer
6
- from numpy.typing import NDArray
7
- from typing import Any, List, Optional, Sequence, Type, Union
8
- import numba
9
- import numpy
10
- import os
11
- import pathlib
12
- import sys
13
-
14
- def getFilenameFoldsTotal(listDimensions: Sequence[int]) -> str:
15
- return str(sorted(listDimensions)).replace(', ', 'x').replace('[', 'p').replace(']', '') + '.foldsTotal'
16
-
17
- def getLeavesTotal(listDimensions: Sequence[int]) -> int:
18
- """
19
- How many leaves are in the map.
20
-
21
- Parameters:
22
- listDimensions: A list of integers representing dimensions.
23
-
24
- Returns:
25
- productDimensions: The product of all positive integer dimensions.
26
- """
27
- listNonNegative = parseDimensions(listDimensions, 'listDimensions')
28
- listPositive = [dimension for dimension in listNonNegative if dimension > 0]
29
-
30
- if not listPositive:
31
- return 0
32
- else:
33
- productDimensions = 1
34
- for dimension in listPositive:
35
- if dimension > sys.maxsize // productDimensions:
36
- raise OverflowError(f"I received {dimension=} in {listDimensions=}, but the product of the dimensions exceeds the maximum size of an integer on this system.")
37
- productDimensions *= dimension
38
-
39
- return productDimensions
40
-
41
- def getPathFilenameFoldsTotal(listDimensions: Sequence[int], pathishWriteFoldsTotal: Optional[Union[str, os.PathLike[str]]] = None) -> pathlib.Path:
42
- pathFilenameFoldsTotal = pathlib.Path(pathishWriteFoldsTotal) if pathishWriteFoldsTotal is not None else pathJobDEFAULT
43
- if pathFilenameFoldsTotal.is_dir():
44
- filenameFoldsTotalDEFAULT = getFilenameFoldsTotal(listDimensions)
45
- pathFilenameFoldsTotal = pathFilenameFoldsTotal / filenameFoldsTotalDEFAULT
46
- pathFilenameFoldsTotal.parent.mkdir(parents=True, exist_ok=True)
47
- return pathFilenameFoldsTotal
48
-
49
- def getTaskDivisions(computationDivisions: Optional[Union[int, str]], concurrencyLimit: int, CPUlimit: Optional[Union[bool, float, int]], listDimensions: Sequence[int]):
50
- """
51
- Determines whether or how to divide the computation into tasks.
52
-
53
- Parameters
54
- ----------
55
- computationDivisions (None):
56
- Specifies how to divide computations:
57
- - None: no division of the computation into tasks; sets task divisions to 0
58
- - int: direct set the number of task divisions; cannot exceed the map's total leaves
59
- - "maximum": divides into `leavesTotal`-many `taskDivisions`
60
- - "cpu": limits the divisions to the number of available CPUs, i.e. `concurrencyLimit`
61
- concurrencyLimit:
62
- Maximum number of concurrent tasks allowed
63
- listDimensions: for error reporting
64
- CPUlimit: for error reporting
65
-
66
- Returns
67
- -------
68
- taskDivisions:
69
-
70
- Raises
71
- ------
72
- ValueError
73
- If computationDivisions is an unsupported type or if resulting task divisions exceed total leaves
74
-
75
- Notes
76
- -----
77
- Task divisions cannot exceed total leaves to prevent duplicate counting of folds.
78
- """
79
- if not computationDivisions:
80
- return 0
81
- else:
82
- leavesTotal = getLeavesTotal(listDimensions)
83
- if isinstance(computationDivisions, int):
84
- taskDivisions = computationDivisions
85
- elif isinstance(computationDivisions, str):
86
- computationDivisions = computationDivisions.lower()
87
- if computationDivisions == "maximum":
88
- taskDivisions = leavesTotal
89
- elif computationDivisions == "cpu":
90
- taskDivisions = min(concurrencyLimit, leavesTotal)
91
- else:
92
- raise ValueError(f"I received {computationDivisions} for the parameter, `computationDivisions`, but the so-called programmer didn't implement code for that.")
93
-
94
- if taskDivisions > leavesTotal:
95
- raise ValueError(f"Problem: `taskDivisions`, ({taskDivisions}), is greater than `leavesTotal`, ({leavesTotal}), which will cause duplicate counting of the folds.\n\nChallenge: you cannot directly set `taskDivisions` or `leavesTotal`. They are derived from parameters that may or may not still be named `computationDivisions`, `CPUlimit` , and `listDimensions` and from dubious-quality Python code.\n\nFor those parameters, I received {computationDivisions=}, {CPUlimit=}, and {listDimensions=}.\n\nPotential solutions: get a different hobby or set `computationDivisions` to a different value.")
96
-
97
- return taskDivisions
98
-
99
- def makeConnectionGraph(listDimensions: Sequence[int], **keywordArguments: Optional[Type]) -> NDArray[integer[Any]]:
100
- """
101
- Constructs a multi-dimensional connection graph representing the connections between the leaves of a map with the given dimensions.
102
- Also called a Cartesian product decomposition or dimensional product mapping.
103
-
104
- Parameters
105
- listDimensions: A sequence of integers representing the dimensions of the map.
106
-
107
- Returns
108
- connectionGraph: A 3D numpy array with shape of (dimensionsTotal, leavesTotal + 1, leavesTotal + 1).
109
- """
110
- datatype = keywordArguments.get('datatype', dtypeDefault)
111
- mapShape = validateListDimensions(listDimensions)
112
- leavesTotal = getLeavesTotal(mapShape)
113
- arrayDimensions = numpy.array(mapShape, dtype=datatype)
114
- dimensionsTotal = len(arrayDimensions)
115
-
116
- # Step 1: find the cumulative product of the map's dimensions
117
- cumulativeProduct = numpy.multiply.accumulate([1] + mapShape, dtype=datatype)
118
-
119
- # Step 2: create a coordinate system
120
- coordinateSystem = numpy.zeros((dimensionsTotal, leavesTotal + 1), dtype=datatype)
121
-
122
- for indexDimension in range(dimensionsTotal):
123
- for leaf1ndex in range(1, leavesTotal + 1):
124
- coordinateSystem[indexDimension, leaf1ndex] = (
125
- ((leaf1ndex - 1) // cumulativeProduct[indexDimension]) %
126
- arrayDimensions[indexDimension] + 1
127
- )
128
-
129
- # Step 3: create and fill the connection graph
130
- connectionGraph = numpy.zeros((dimensionsTotal, leavesTotal + 1, leavesTotal + 1), dtype=datatype)
131
-
132
- for indexDimension in range(dimensionsTotal):
133
- for activeLeaf1ndex in range(1, leavesTotal + 1):
134
- for connectee1ndex in range(1, activeLeaf1ndex + 1):
135
- # Base coordinate conditions
136
- isFirstCoord = coordinateSystem[indexDimension, connectee1ndex] == 1
137
- isLastCoord = coordinateSystem[indexDimension, connectee1ndex] == arrayDimensions[indexDimension]
138
- exceedsActive = connectee1ndex + cumulativeProduct[indexDimension] > activeLeaf1ndex
139
-
140
- # Parity check
141
- isEvenParity = (coordinateSystem[indexDimension, activeLeaf1ndex] & 1) == \
142
- (coordinateSystem[indexDimension, connectee1ndex] & 1)
143
-
144
- # Determine connection value
145
- if (isEvenParity and isFirstCoord) or (not isEvenParity and (isLastCoord or exceedsActive)):
146
- connectionGraph[indexDimension, activeLeaf1ndex, connectee1ndex] = connectee1ndex
147
- elif isEvenParity and not isFirstCoord:
148
- connectionGraph[indexDimension, activeLeaf1ndex, connectee1ndex] = connectee1ndex - cumulativeProduct[indexDimension]
149
- elif not isEvenParity and not (isLastCoord or exceedsActive):
150
- connectionGraph[indexDimension, activeLeaf1ndex, connectee1ndex] = connectee1ndex + cumulativeProduct[indexDimension]
151
-
152
- return connectionGraph
153
-
154
- def makeDataContainer(shape, datatype: Optional[Type] = None):
155
- """Create a container, probably numpy.ndarray, with the given shape and datatype."""
156
- if datatype is None:
157
- datatype = dtypeDefault
158
- return numpy.zeros(shape, dtype=datatype)
159
-
160
- def outfitCountFolds(listDimensions: Sequence[int], computationDivisions: Optional[Union[int, str]] = None, CPUlimit: Optional[Union[bool, float, int]] = None, **keywordArguments: Optional[Type[Any]]) -> computationState:
161
- """
162
- Initializes and configures the computation state for map folding computations.
163
-
164
- Parameters
165
- ----------
166
- listDimensions:
167
- The dimensions of the map to be folded
168
- computationDivisions (None):
169
- Specifies how to divide computations:
170
- - None: no division of the computation into tasks; sets task divisions to 0
171
- - int: direct set the number of task divisions; cannot exceed the map's total leaves
172
- - "maximum": divides into `leavesTotal`-many `taskDivisions`
173
- - "cpu": limits the divisions to the number of available CPUs, i.e. `concurrencyLimit`
174
- CPUlimit (None):
175
- Whether and how to limit the CPU usage. See notes for details.
176
-
177
- Returns
178
- -------
179
- computationState
180
- An initialized computation state containing:
181
- - connectionGraph: Graph representing connections in the map
182
- - foldsSubTotals: Array tracking total folds
183
- - mapShape: Validated and sorted dimensions of the map
184
- - my: Array for internal state tracking
185
- - gapsWhere: Array tracking gap positions
186
- - the: Static settings and metadata
187
- - track: Array for tracking computation progress
188
-
189
- Limits on CPU usage `CPUlimit`:
190
- - `False`, `None`, or `0`: No limits on CPU usage; uses all available CPUs. All other values will potentially limit CPU usage.
191
- - `True`: Yes, limit the CPU usage; limits to 1 CPU.
192
- - Integer `>= 1`: Limits usage to the specified number of CPUs.
193
- - Decimal value (`float`) between 0 and 1: Fraction of total CPUs to use.
194
- - Decimal value (`float`) between -1 and 0: Fraction of CPUs to *not* use.
195
- - Integer `<= -1`: Subtract the absolute value from total CPUs.
196
- """
197
- datatypeDefault = keywordArguments.get('datatypeDefault', dtypeDefault)
198
- datatypeLarge = keywordArguments.get('datatypeLarge', dtypeLarge)
199
- datatypeSmall = keywordArguments.get('datatypeSmall', dtypeSmall)
200
-
201
- my = makeDataContainer(len(indexMy), datatypeDefault)
202
-
203
- mapShape = tuple(sorted(validateListDimensions(listDimensions)))
204
- concurrencyLimit = setCPUlimit(CPUlimit)
205
- my[indexMy.taskDivisions] = getTaskDivisions(computationDivisions, concurrencyLimit, CPUlimit, mapShape)
206
-
207
- foldGroups = makeDataContainer(max(my[indexMy.taskDivisions] + 1, 2), datatypeLarge)
208
- foldGroups[-1] = leavesTotal = getLeavesTotal(mapShape)
209
-
210
- my[indexMy.dimensionsTotal] = len(mapShape)
211
- my[indexMy.leaf1ndex] = 1
212
- stateInitialized = computationState(
213
- connectionGraph = makeConnectionGraph(mapShape, datatype=datatypeSmall),
214
- foldGroups = foldGroups,
215
- mapShape = mapShape,
216
- my = my,
217
- gapsWhere = makeDataContainer(int(leavesTotal) * int(leavesTotal) + 1, datatypeSmall),
218
- track = makeDataContainer((len(indexTrack), leavesTotal + 1), datatypeDefault)
219
- )
220
-
221
-
222
- return stateInitialized
223
-
224
- def parseDimensions(dimensions: Sequence[int], parameterName: str = 'listDimensions') -> List[int]:
225
- """
226
- Parse and validate dimensions are non-negative integers.
227
-
228
- Parameters:
229
- dimensions: Sequence of integers representing dimensions
230
- parameterName ('listDimensions'): Name of the parameter for error messages. Defaults to 'listDimensions'
231
- Returns:
232
- listNonNegative: List of validated non-negative integers
233
- Raises:
234
- ValueError: If any dimension is negative or if the list is empty
235
- TypeError: If any element cannot be converted to integer (raised by intInnit)
236
- """
237
- listValidated = intInnit(dimensions, parameterName)
238
- listNonNegative = []
239
- for dimension in listValidated:
240
- if dimension < 0:
241
- raise ValueError(f"Dimension {dimension} must be non-negative")
242
- listNonNegative.append(dimension)
243
-
244
- return listNonNegative
245
-
246
- def saveFoldsTotal(pathFilename: Union[str, os.PathLike[str]], foldsTotal: int) -> None:
247
- """
248
- Save foldsTotal with multiple fallback mechanisms.
249
-
250
- Parameters:
251
- pathFilename: Target save location
252
- foldsTotal: Critical computed value to save
253
- """
254
- try:
255
- pathFilenameFoldsTotal = pathlib.Path(pathFilename)
256
- pathFilenameFoldsTotal.parent.mkdir(parents=True, exist_ok=True)
257
- pathFilenameFoldsTotal.write_text(str(foldsTotal))
258
- except Exception as ERRORmessage:
259
- try:
260
- print(f"\nfoldsTotal foldsTotal foldsTotal foldsTotal foldsTotal\n\n{foldsTotal=}\n\nfoldsTotal foldsTotal foldsTotal foldsTotal foldsTotal\n")
261
- print(ERRORmessage)
262
- print(f"\nfoldsTotal foldsTotal foldsTotal foldsTotal foldsTotal\n\n{foldsTotal=}\n\nfoldsTotal foldsTotal foldsTotal foldsTotal foldsTotal\n")
263
- randomnessPlanB = (int(str(foldsTotal).strip()[-1]) + 1) * ['YO_']
264
- filenameInfixUnique = ''.join(randomnessPlanB)
265
- pathFilenamePlanB = os.path.join(os.getcwd(), 'foldsTotal' + filenameInfixUnique + '.txt')
266
- writeStreamFallback = open(pathFilenamePlanB, 'w')
267
- writeStreamFallback.write(str(foldsTotal))
268
- writeStreamFallback.close()
269
- print(str(pathFilenamePlanB))
270
- except:
271
- print(foldsTotal)
272
-
273
- def setCPUlimit(CPUlimit: Union[bool, float, int, None]) -> int:
274
- """Sets CPU limit for Numba concurrent operations. Note that it can only affect Numba-jitted functions that have not yet been imported.
275
-
276
- Parameters:
277
- CPUlimit: whether and how to limit the CPU usage. See notes for details.
278
- Returns:
279
- concurrencyLimit: The actual concurrency limit that was set
280
- Raises:
281
- TypeError: If CPUlimit is not of the expected types
282
-
283
- Limits on CPU usage `CPUlimit`:
284
- - `False`, `None`, or `0`: No limits on CPU usage; uses all available CPUs. All other values will potentially limit CPU usage.
285
- - `True`: Yes, limit the CPU usage; limits to 1 CPU.
286
- - Integer `>= 1`: Limits usage to the specified number of CPUs.
287
- - Decimal value (`float`) between 0 and 1: Fraction of total CPUs to use.
288
- - Decimal value (`float`) between -1 and 0: Fraction of CPUs to *not* use.
289
- - Integer `<= -1`: Subtract the absolute value from total CPUs.
290
- """
291
- if not (CPUlimit is None or isinstance(CPUlimit, (bool, int, float))):
292
- CPUlimit = oopsieKwargsie(CPUlimit)
293
-
294
- concurrencyLimit = defineConcurrencyLimit(CPUlimit)
295
- numba.set_num_threads(concurrencyLimit)
296
-
297
- return concurrencyLimit
298
-
299
- def validateListDimensions(listDimensions: Sequence[int]) -> List[int]:
300
- """
301
- Validates and sorts a sequence of at least two positive dimensions.
302
-
303
- Parameters:
304
- listDimensions: A sequence of integer dimensions to be validated.
305
-
306
- Returns:
307
- dimensionsValidSorted: A list, with at least two elements, of only positive integers.
308
-
309
- Raises:
310
- ValueError: If the input listDimensions is None.
311
- NotImplementedError: If the resulting list of positive dimensions has fewer than two elements.
312
- """
313
- if not listDimensions:
314
- raise ValueError(f"listDimensions is a required parameter.")
315
- listNonNegative = parseDimensions(listDimensions, 'listDimensions')
316
- dimensionsValid = [dimension for dimension in listNonNegative if dimension > 0]
317
- if len(dimensionsValid) < 2:
318
- raise NotImplementedError(f"This function requires listDimensions, {listDimensions}, to have at least two dimensions greater than 0. You may want to look at https://oeis.org/.")
319
- return sorted(dimensionsValid)
@@ -1,7 +0,0 @@
1
- from mapFolding.lovelace import countSequential
2
- from mapFolding.lovelace import countParallel
3
- from mapFolding.lovelace import countInitialize
4
-
5
- # from mapFolding.someAssemblyRequired.countSequential import countSequential
6
- # from mapFolding.someAssemblyRequired.countParallel import countParallel
7
- # from mapFolding.someAssemblyRequired.countInitialize import countInitialize
mapFolding/lovelace.py DELETED
@@ -1,213 +0,0 @@
1
- from mapFolding import indexMy, indexTrack
2
- import numba
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(foldGroups, my):
14
- return my[indexMy.leaf1ndex.value] > foldGroups[-1] # leavesTotal
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):
22
- return my[indexMy.dimensionsUnconstrained.value] == my[indexMy.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.indexDimension.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.indexDimension.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, track):
59
- gapsWhere[my[indexMy.gap1ndex.value]] = gapsWhere[my[indexMy.indexMiniGap.value]]
60
- if track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] == my[indexMy.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.indexDimension.value] = 0
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(foldGroups, my):
72
- foldGroups[my[indexMy.taskIndex.value]] += 1
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.indexDimension.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.indexDimension.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):
108
- return my[indexMy.indexDimension.value] < my[indexMy.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):
130
- return my[indexMy.leaf1ndex.value] != my[indexMy.taskDivisions.value] or my[indexMy.leafConnectee.value] % my[indexMy.taskDivisions.value] == my[indexMy.taskIndex.value]
131
-
132
- @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)
133
- def countInitialize(connectionGraph, gapsWhere, my, 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):
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):
147
- insertUnconstrainedLeaf(gapsWhere=gapsWhere, my=my)
148
- indexMiniGapInitialization(my=my)
149
- while loopingToActiveGapCeiling(my=my):
150
- filterCommonGaps(gapsWhere=gapsWhere, my=my, track=track)
151
- indexMiniGapIncrement(my=my)
152
- if placeLeafCondition(my=my):
153
- placeLeaf(gapsWhere=gapsWhere, my=my, track=track)
154
- if my[indexMy.gap1ndex.value] > 0:
155
- return
156
-
157
- @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)
158
- def countSequential(connectionGraph, foldGroups, gapsWhere, my, track):
159
- while activeLeafGreaterThan0Condition(my=my):
160
- if activeLeafIsTheFirstLeafCondition(my=my) or leafBelowSentinelIs1Condition(track=track):
161
- if activeLeafGreaterThanLeavesTotalCondition(foldGroups=foldGroups, my=my):
162
- foldsSubTotalIncrement(foldGroups=foldGroups, my=my)
163
- else:
164
- findGapsInitializeVariables(my=my, track=track)
165
- while loopingTheDimensions(my=my):
166
- if dimensionsUnconstrainedCondition(connectionGraph=connectionGraph, my=my):
167
- dimensionsUnconstrainedIncrement(my=my)
168
- else:
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, 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]), parallel=True, boundscheck=False, error_model='numpy', fastmath=True, looplift=False, nogil=True, nopython=True)
184
- def countParallel(connectionGraph, foldGroups, gapsWherePARALLEL, myPARALLEL, trackPARALLEL):
185
- for indexSherpa in numba.prange(myPARALLEL[indexMy.taskDivisions.value]):
186
- gapsWhere = gapsWherePARALLEL.copy()
187
- my = myPARALLEL.copy()
188
- my[indexMy.taskIndex.value] = indexSherpa
189
- track = trackPARALLEL.copy()
190
- while activeLeafGreaterThan0Condition(my=my):
191
- if activeLeafIsTheFirstLeafCondition(my=my) or leafBelowSentinelIs1Condition(track=track):
192
- if activeLeafGreaterThanLeavesTotalCondition(foldGroups=foldGroups, my=my):
193
- foldsSubTotalIncrement(foldGroups=foldGroups, my=my)
194
- else:
195
- findGapsInitializeVariables(my=my, track=track)
196
- while loopingTheDimensions(my=my):
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):
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, 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)