mapFolding 0.3.8__py3-none-any.whl → 0.3.10__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 (48) hide show
  1. mapFolding/__init__.py +56 -0
  2. mapFolding/basecamp.py +55 -0
  3. mapFolding/beDRY.py +376 -0
  4. mapFolding/oeis.py +339 -0
  5. mapFolding/someAssemblyRequired/__init__.py +2 -0
  6. {someAssemblyRequired → mapFolding/someAssemblyRequired}/makeJob.py +4 -5
  7. mapFolding/someAssemblyRequired/synthesizeJobNumba.py +383 -0
  8. mapFolding/someAssemblyRequired/synthesizeModuleJAX.py +29 -0
  9. {someAssemblyRequired → mapFolding/someAssemblyRequired}/synthesizeModulesNumba.py +186 -99
  10. syntheticModules/numbaInitialize.py → mapFolding/syntheticModules/numba_countInitialize.py +6 -9
  11. syntheticModules/numbaParallel.py → mapFolding/syntheticModules/numba_countParallel.py +4 -4
  12. syntheticModules/numbaSequential.py → mapFolding/syntheticModules/numba_countSequential.py +5 -5
  13. mapFolding/syntheticModules/numba_doTheNeedful.py +30 -0
  14. mapFolding/theDao.py +213 -0
  15. mapFolding/theSSOT.py +251 -0
  16. mapFolding/theSSOTnumba.py +115 -0
  17. mapFolding-0.3.10.dist-info/LICENSE +407 -0
  18. {mapFolding-0.3.8.dist-info → mapFolding-0.3.10.dist-info}/METADATA +9 -11
  19. mapFolding-0.3.10.dist-info/RECORD +40 -0
  20. mapFolding-0.3.10.dist-info/top_level.txt +2 -0
  21. tests/__init__.py +1 -0
  22. tests/conftest.py +183 -0
  23. tests/conftest_tmpRegistry.py +62 -0
  24. tests/conftest_uniformTests.py +53 -0
  25. tests/test_oeis.py +141 -0
  26. tests/test_other.py +259 -0
  27. tests/test_tasks.py +44 -0
  28. tests/test_types.py +5 -0
  29. benchmarks/benchmarking.py +0 -67
  30. citations/constants.py +0 -3
  31. citations/updateCitation.py +0 -354
  32. mapFolding-0.3.8.dist-info/RECORD +0 -26
  33. mapFolding-0.3.8.dist-info/top_level.txt +0 -5
  34. someAssemblyRequired/__init__.py +0 -1
  35. someAssemblyRequired/synthesizeModuleJobNumba.py +0 -212
  36. syntheticModules/__init__.py +0 -3
  37. {reference → mapFolding/reference}/flattened.py +0 -0
  38. {reference → mapFolding/reference}/hunterNumba.py +0 -0
  39. {reference → mapFolding/reference}/irvineJavaPort.py +0 -0
  40. {reference → mapFolding/reference}/jax.py +0 -0
  41. {reference → mapFolding/reference}/lunnan.py +0 -0
  42. {reference → mapFolding/reference}/lunnanNumpy.py +0 -0
  43. {reference → mapFolding/reference}/lunnanWhile.py +0 -0
  44. {reference → mapFolding/reference}/rotatedEntryPoint.py +0 -0
  45. {reference → mapFolding/reference}/total_countPlus1vsPlusN.py +0 -0
  46. {someAssemblyRequired → mapFolding/someAssemblyRequired}/getLLVMforNoReason.py +0 -0
  47. {mapFolding-0.3.8.dist-info → mapFolding-0.3.10.dist-info}/WHEEL +0 -0
  48. {mapFolding-0.3.8.dist-info → mapFolding-0.3.10.dist-info}/entry_points.txt +0 -0
tests/test_other.py ADDED
@@ -0,0 +1,259 @@
1
+ from contextlib import redirect_stdout
2
+ from tests.conftest import *
3
+ from typing import Dict, List, Optional, Any, Tuple, Literal, Callable, Generator
4
+ from Z0Z_tools import intInnit
5
+ import io
6
+ import itertools
7
+ import numba
8
+ import numpy
9
+ import pathlib
10
+ import pytest
11
+ import random
12
+ import sys
13
+
14
+ @pytest.mark.parametrize("listDimensions,expected_intInnit,expected_parseListDimensions,expected_validateListDimensions,expected_getLeavesTotal", [
15
+ (None, ValueError, ValueError, ValueError, ValueError), # None instead of list
16
+ (['a'], ValueError, ValueError, ValueError, ValueError), # string
17
+ ([-4, 2], [-4, 2], ValueError, ValueError, ValueError), # negative
18
+ ([-3], [-3], ValueError, ValueError, ValueError), # negative
19
+ ([0, 0], [0, 0], [0, 0], NotImplementedError, 0), # no positive dimensions
20
+ ([0, 5, 6], [0, 5, 6], [0, 5, 6], [5, 6], 30), # zeros ignored
21
+ ([0], [0], [0], NotImplementedError, 0), # edge case
22
+ ([1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], 120), # sequential
23
+ ([1, sys.maxsize], [1, sys.maxsize], [1, sys.maxsize], [1, sys.maxsize], sys.maxsize), # maxint
24
+ ([7.5], ValueError, ValueError, ValueError, ValueError), # float
25
+ ([1] * 1000, [1] * 1000, [1] * 1000, [1] * 1000, 1), # long list
26
+ ([11], [11], [11], NotImplementedError, 11), # single dimension
27
+ ([13, 0, 17], [13, 0, 17], [13, 0, 17], [13, 17], 221), # zeros handled
28
+ ([2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 2], 16), # repeated dimensions
29
+ ([2, 3, 4], [2, 3, 4], [2, 3, 4], [2, 3, 4], 24),
30
+ ([2, 3], [2, 3], [2, 3], [2, 3], 6),
31
+ ([2] * 11, [2] * 11, [2] * 11, [2] * 11, 2048), # power of 2
32
+ ([3, 2], [3, 2], [3, 2], [2, 3], 6), # return value is the input when valid
33
+ ([3] * 5, [3] * 5, [3] * 5, [3, 3, 3, 3, 3], 243), # power of 3
34
+ ([None], TypeError, TypeError, TypeError, TypeError), # None
35
+ ([True], TypeError, TypeError, TypeError, TypeError), # bool
36
+ ([[17, 39]], TypeError, TypeError, TypeError, TypeError), # nested
37
+ ([], ValueError, ValueError, ValueError, ValueError), # empty
38
+ ([complex(1,1)], ValueError, ValueError, ValueError, ValueError), # complex number
39
+ ([float('inf')], ValueError, ValueError, ValueError, ValueError), # infinity
40
+ ([float('nan')], ValueError, ValueError, ValueError, ValueError), # NaN
41
+ ([sys.maxsize - 1, 1], [sys.maxsize - 1, 1], [sys.maxsize - 1, 1], [1, sys.maxsize - 1], sys.maxsize - 1), # near maxint
42
+ ([sys.maxsize // 2, sys.maxsize // 2, 2], [sys.maxsize // 2, sys.maxsize // 2, 2], [sys.maxsize // 2, sys.maxsize // 2, 2], [2, sys.maxsize // 2, sys.maxsize // 2], OverflowError), # overflow protection
43
+ ([sys.maxsize, sys.maxsize], [sys.maxsize, sys.maxsize], [sys.maxsize, sys.maxsize], [sys.maxsize, sys.maxsize], OverflowError), # overflow protection
44
+ (range(3, 7), [3, 4, 5, 6], [3, 4, 5, 6], [3, 4, 5, 6], 360), # range sequence type
45
+ (tuple([3, 5, 7]), [3, 5, 7], [3, 5, 7], [3, 5, 7], 105), # tuple sequence type
46
+ ])
47
+ def test_listDimensionsAsParameter(listDimensions: None | List[str] | List[int] | List[float] | List[None] | List[bool] | List[List[int]] | List[complex] | range | tuple[int, ...], expected_intInnit: type[ValueError] | List[int] | type[TypeError], expected_parseListDimensions: type[ValueError] | List[int] | type[TypeError], expected_validateListDimensions: type[ValueError] | type[NotImplementedError] | List[int] | type[TypeError], expected_getLeavesTotal: type[ValueError] | int | type[TypeError] | type[OverflowError]) -> None:
48
+ """Test both validateListDimensions and getLeavesTotal with the same inputs."""
49
+ standardizedEqualTo(expected_intInnit, intInnit, listDimensions)
50
+ standardizedEqualTo(expected_parseListDimensions, parseDimensions, listDimensions)
51
+ standardizedEqualTo(expected_validateListDimensions, validateListDimensions, listDimensions)
52
+ standardizedEqualTo(expected_getLeavesTotal, getLeavesTotal, listDimensions)
53
+
54
+ def test_getLeavesTotal_edge_cases() -> None:
55
+ """Test edge cases for getLeavesTotal."""
56
+ # Order independence
57
+ standardizedEqualTo(getLeavesTotal([2, 3, 4]), getLeavesTotal, [4, 2, 3])
58
+
59
+ # Immutability
60
+ listOriginal = [2, 3]
61
+ standardizedEqualTo(6, getLeavesTotal, listOriginal)
62
+ standardizedEqualTo([2, 3], lambda x: x, listOriginal) # Check that the list wasn't modified
63
+
64
+ # TODO fix this mock
65
+ # @pytest.mark.parametrize("foldsValue,writeFoldsTarget", [
66
+ # (756839, "foldsTotalTest.txt"), # Direct file
67
+ # (2640919, "foldsTotalTest.txt"), # Direct file
68
+ # (7715177, None), # Directory, will use default filename
69
+ # ])
70
+ # def test_countFolds_writeFoldsTotal(
71
+ # listDimensionsTestFunctionality: List[int],
72
+ # pathTempTesting: pathlib.Path,
73
+ # mockFoldingFunction: Callable[..., Callable[..., None]],
74
+ # mockDispatcher: Callable[[Callable[..., None]], Any],
75
+ # foldsValue: int,
76
+ # writeFoldsTarget: Optional[str]
77
+ # ) -> None:
78
+ # """Test writing folds total to either a file or directory."""
79
+ # # For directory case, use the directory path directly
80
+ # if writeFoldsTarget is None:
81
+ # pathWriteTarget = pathTempTesting
82
+ # filenameFoldsTotalExpected = getFilenameFoldsTotal(listDimensionsTestFunctionality)
83
+ # else:
84
+ # pathWriteTarget = pathTempTesting / writeFoldsTarget
85
+ # filenameFoldsTotalExpected = writeFoldsTarget
86
+
87
+ # foldsTotalExpected = foldsValue * getLeavesTotal(listDimensionsTestFunctionality)
88
+ # mock_countFolds = mockFoldingFunction(foldsValue, listDimensionsTestFunctionality)
89
+
90
+ # with mockDispatcher(mock_countFolds):
91
+ # returned = countFolds(listDimensionsTestFunctionality, pathLikeWriteFoldsTotal=pathWriteTarget)
92
+
93
+ # standardizedEqualTo(str(foldsTotalExpected), lambda: (pathTempTesting / filenameFoldsTotalExpected).read_text())
94
+
95
+ @pytest.mark.parametrize("nameOfTest,callablePytest", PytestFor_intInnit())
96
+ def testIntInnit(nameOfTest: str, callablePytest: Callable[[], None]) -> None:
97
+ callablePytest()
98
+
99
+ @pytest.mark.parametrize("nameOfTest,callablePytest", PytestFor_oopsieKwargsie())
100
+ def testOopsieKwargsie(nameOfTest: str, callablePytest: Callable[[], None]) -> None:
101
+ callablePytest()
102
+
103
+ @pytest.mark.parametrize("CPUlimit, expectedLimit", [
104
+ (None, numba.get_num_threads()),
105
+ (False, numba.get_num_threads()),
106
+ (True, 1),
107
+ (4, 4),
108
+ (0.5, max(1, numba.get_num_threads() // 2)),
109
+ (-0.5, max(1, numba.get_num_threads() // 2)),
110
+ (-2, max(1, numba.get_num_threads() - 2)),
111
+ (0, numba.get_num_threads()),
112
+ (1, 1),
113
+ ])
114
+ def test_setCPUlimit(CPUlimit: None | float | bool | Literal[4] | Literal[-2] | Literal[0] | Literal[1], expectedLimit: Any | int) -> None:
115
+ standardizedEqualTo(expectedLimit, setCPUlimit, CPUlimit)
116
+
117
+ def test_makeConnectionGraph_nonNegative(listDimensionsTestFunctionality: List[int]) -> None:
118
+ connectionGraph = makeConnectionGraph(listDimensionsTestFunctionality)
119
+ assert numpy.all(connectionGraph >= 0), "All values in the connection graph should be non-negative."
120
+
121
+ # @pytest.mark.parametrize("datatype", ['int16', 'uint64'])
122
+ # def test_makeConnectionGraph_datatype(listDimensionsTestFunctionality: List[int], datatype) -> None:
123
+ # connectionGraph = makeConnectionGraph(listDimensionsTestFunctionality, datatype=datatype)
124
+ # assert connectionGraph.dtype == datatype, f"Expected datatype {datatype}, but got {connectionGraph.dtype}."
125
+
126
+ """5 parameters
127
+ listDimensionsTestFunctionality
128
+
129
+ computationDivisions
130
+ None
131
+ random: int, first included: 2, first excluded: leavesTotal
132
+ maximum
133
+ cpu
134
+
135
+ CPUlimit
136
+ None
137
+ True
138
+ False
139
+ 0
140
+ 1
141
+ -1
142
+ random: 0 < float < 1
143
+ random: -1 < float < 0
144
+ random: int, first included: 2, first excluded: (min(leavesTotal, 16) - 1)
145
+ random: int, first included: -1 * (min(leavesTotal, 16) - 1), first excluded: -1
146
+
147
+ datatypeMedium
148
+ None
149
+ numpy.int64
150
+ numpy.intc
151
+ numpy.uint16
152
+
153
+ datatypeLarge
154
+ None
155
+ numpy.int64
156
+ numpy.intp
157
+ numpy.uint32
158
+
159
+ """
160
+
161
+ @pytest.fixture
162
+ def parameterIterator() -> Callable[[List[int]], Generator[Dict[str, Any], None, None]]:
163
+ """Generate random combinations of parameters for outfitCountFolds testing."""
164
+ parameterSets: Dict[str, List[Any]] = {
165
+ 'computationDivisions': [
166
+ None,
167
+ 'maximum',
168
+ 'cpu',
169
+ ],
170
+ 'CPUlimit': [
171
+ None, True, False, 0, 1, -1,
172
+ ],
173
+ 'datatypeMedium': [
174
+ None,
175
+ numpy.int64,
176
+ numpy.intc,
177
+ numpy.uint16
178
+ ],
179
+ 'datatypeLarge': [
180
+ None,
181
+ numpy.int64,
182
+ numpy.intp,
183
+ numpy.uint32
184
+ ]
185
+ }
186
+
187
+ def makeParametersDynamic(listDimensions: List[int]) -> Dict[str, List[Any]]:
188
+ """Add context-dependent parameter values."""
189
+ parametersDynamic = parameterSets.copy()
190
+ leavesTotal = getLeavesTotal(listDimensions)
191
+ concurrencyLimit = min(leavesTotal, 16)
192
+
193
+ # Add dynamic computationDivisions values
194
+ dynamicDivisions = [random.randint(2, leavesTotal-1) for iterator in range(3)]
195
+ parametersDynamic['computationDivisions'] = parametersDynamic['computationDivisions'] + dynamicDivisions
196
+
197
+ # Add dynamic CPUlimit values
198
+ parameterDynamicCPU = [
199
+ random.random(), # 0 to 1
200
+ -random.random(), # -1 to 0
201
+ ]
202
+ parameterDynamicCPU.extend(
203
+ [random.randint(2, concurrencyLimit-1) for iterator in range(2)]
204
+ )
205
+ parameterDynamicCPU.extend(
206
+ [random.randint(-concurrencyLimit+1, -2) for iterator in range(2)]
207
+ )
208
+ parametersDynamic['CPUlimit'] = parametersDynamic['CPUlimit'] + parameterDynamicCPU
209
+
210
+ return parametersDynamic
211
+
212
+ def generateCombinations(listDimensions: List[int]) -> Generator[Dict[str, Any], None, None]:
213
+ parametersDynamic = makeParametersDynamic(listDimensions)
214
+ parameterKeys = list(parametersDynamic.keys())
215
+ parameterValues = [parametersDynamic[key] for key in parameterKeys]
216
+
217
+ # Shuffle each parameter list
218
+ for valueList in parameterValues:
219
+ random.shuffle(valueList)
220
+
221
+ # Use zip_longest to iterate, filling with None when shorter lists are exhausted
222
+ for combination in itertools.zip_longest(*parameterValues, fillvalue=None):
223
+ yield dict(zip(parameterKeys, combination))
224
+
225
+ return generateCombinations
226
+
227
+ # TODO refactor due to changes
228
+ # def test_pathJobDEFAULT_colab() -> None:
229
+ # """Test that pathJobDEFAULT is set correctly when running in Google Colab."""
230
+ # # Mock sys.modules to simulate running in Colab
231
+ # with unittest.mock.patch.dict('sys.modules', {'google.colab': unittest.mock.MagicMock()}):
232
+ # # Force reload of theSSOT to trigger Colab path logic
233
+ # import importlib
234
+ # import mapFolding.theSSOT
235
+ # importlib.reload(mapFolding.theSSOT)
236
+
237
+ # # Check that path was set to Colab-specific value
238
+ # assert mapFolding.theSSOT.pathJobDEFAULT == pathlib.Path("/content/drive/MyDrive") / "jobs"
239
+
240
+ # # Reload one more time to restore original state
241
+ # importlib.reload(mapFolding.theSSOT)
242
+
243
+ def test_saveFoldsTotal_fallback(pathTempTesting: pathlib.Path) -> None:
244
+ foldsTotal = 123
245
+ pathFilename = pathTempTesting / "foldsTotal.txt"
246
+ with unittest.mock.patch("pathlib.Path.write_text", side_effect=OSError("Simulated write failure")):
247
+ with unittest.mock.patch("os.getcwd", return_value=str(pathTempTesting)):
248
+ capturedOutput = io.StringIO()
249
+ with redirect_stdout(capturedOutput):
250
+ saveFoldsTotal(pathFilename, foldsTotal)
251
+ fallbackFiles = list(pathTempTesting.glob("foldsTotalYO_*.txt"))
252
+ assert len(fallbackFiles) == 1, "Fallback file was not created upon write failure."
253
+
254
+ def test_makeDataContainer_default_datatype() -> None:
255
+ """Test that makeDataContainer uses dtypeLargeDEFAULT when no datatype is specified."""
256
+ testShape = (3, 4)
257
+ container = makeDataContainer(testShape)
258
+ assert container.dtype == hackSSOTdtype('dtypeFoldsTotal'), f"Expected datatype but got {container.dtype}"
259
+ assert container.shape == testShape, f"Expected shape {testShape}, but got {container.shape}"
tests/test_tasks.py ADDED
@@ -0,0 +1,44 @@
1
+ from tests.conftest import *
2
+ import pytest
3
+ from typing import List, Dict, Literal, Tuple, Any
4
+
5
+ # TODO add a test. `C` = number of logical cores available. `n = C + 1`. Ensure that `[2,n]` is computed correctly.
6
+ # Or, probably smarter: limit the number of cores, then run a test with C+1.
7
+
8
+ def test_algorithmSourceParallel(listDimensionsTestParallelization: List[int], foldsTotalKnown: Dict[Tuple[int, ...], int], useAlgorithmDirectly: None) -> None:
9
+ standardizedEqualTo(foldsTotalKnown[tuple(listDimensionsTestParallelization)], countFolds, listDimensionsTestParallelization, None, 'maximum')
10
+
11
+ def test_countFoldsComputationDivisionsInvalid(listDimensionsTestFunctionality: List[int]) -> None:
12
+ standardizedEqualTo(ValueError, countFolds, listDimensionsTestFunctionality, None, {"wrong": "value"})
13
+
14
+ def test_countFoldsComputationDivisionsMaximum(listDimensionsTestParallelization: List[int], foldsTotalKnown: Dict[Tuple[int, ...], int]) -> None:
15
+ standardizedEqualTo(foldsTotalKnown[tuple(listDimensionsTestParallelization)], countFolds, listDimensionsTestParallelization, None, 'maximum')
16
+
17
+ @pytest.mark.parametrize("nameOfTest,callablePytest", PytestFor_defineConcurrencyLimit())
18
+ def test_defineConcurrencyLimit(nameOfTest: str, callablePytest: Callable[[], None]) -> None:
19
+ callablePytest()
20
+
21
+ # @pytest.mark.parametrize("CPUlimitParameter", [{"invalid": True}, ["weird"]])
22
+ # def test_countFolds_cpuLimitOopsie(listDimensionsTestFunctionality: List[int], CPUlimitParameter: Dict[str, bool] | List[str]) -> None:
23
+ # standardizedEqualTo((AttributeError or ValueError), countFolds, listDimensionsTestFunctionality, None, 'cpu', CPUlimitParameter)
24
+
25
+ @pytest.mark.parametrize("computationDivisions, concurrencyLimit, listDimensions, expectedTaskDivisions", [
26
+ (None, 4, [9, 11], 0),
27
+ ("maximum", 4, [7, 11], 77),
28
+ ("cpu", 4, [3, 7], 4),
29
+ (["invalid"], 4, [19, 23], ValueError),
30
+ (20, 4, [3,5], ValueError)
31
+ ])
32
+ def test_getTaskDivisions(computationDivisions: None | List[str] | Literal['maximum'] | Literal['cpu'] | Literal[20], concurrencyLimit: Literal[4], listDimensions: List[int], expectedTaskDivisions: type[ValueError] | Literal[0] | Literal[77] | Literal[4]) -> None:
33
+ standardizedEqualTo(expectedTaskDivisions, getTaskDivisions, computationDivisions, concurrencyLimit, None, listDimensions)
34
+
35
+ @pytest.mark.parametrize("expected,parameter", [
36
+ (2, "2"), # string
37
+ (ValueError, [4]), # list
38
+ (ValueError, (2,)), # tuple
39
+ (ValueError, {2}), # set
40
+ (ValueError, {"cores": 2}), # dict
41
+ ])
42
+ def test_setCPUlimitMalformedParameter(expected: type[ValueError] | Literal[2], parameter: List[int] | Tuple[int] | set[int] | Dict[str, int] | Literal['2']) -> None:
43
+ """Test that invalid CPUlimit types are properly handled."""
44
+ standardizedEqualTo(expected, setCPUlimit, parameter)
tests/test_types.py ADDED
@@ -0,0 +1,5 @@
1
+ """Type checking tests for mapFolding package."""
2
+
3
+ def test_static_typing() -> None:
4
+ """This is a placeholder. pytest-mypy will run type checking automatically."""
5
+ pass
@@ -1,67 +0,0 @@
1
- """An incompetent benchmarking module for mapFolding."""
2
- from typing import Callable
3
- import multiprocessing
4
- import numpy
5
- import pathlib
6
- import time
7
-
8
- pathRecordedBenchmarks = pathlib.Path('mapFolding/benchmarks/marks')
9
- pathRecordedBenchmarks.mkdir(parents=True, exist_ok=True)
10
- pathFilenameRecordedBenchmarks = pathRecordedBenchmarks / "benchmarks.npy"
11
-
12
- def recordBenchmarks():
13
- """Decorator to benchmark a function."""
14
- def AzeemTheWrapper(functionTarget: Callable):
15
- def djZeph(*arguments, **keywordArguments):
16
- timeStart = time.perf_counter_ns()
17
- returnValueTarget = functionTarget(*arguments, **keywordArguments)
18
- timeElapsed = (time.perf_counter_ns() - timeStart) / 1e9
19
-
20
- # Extract mapShape from arguments
21
- mapShape = keywordArguments['mapShape']
22
- # mapShape = tuple(arguments)[2]
23
- # leavesTotal = tuple(arguments[3])[4]
24
-
25
- # Store benchmark data in single file
26
- benchmarkEntry = numpy.array([(timeElapsed, mapShape)], dtype=[('time', 'f8'), ('mapShape', 'O')])
27
- # benchmarkEntry = numpy.array([(timeElapsed, leavesTotal)], dtype=[('time', 'f8'), ('leaves', 'O')])
28
-
29
- if pathFilenameRecordedBenchmarks.exists():
30
- arrayExisting = numpy.load(str(pathFilenameRecordedBenchmarks), allow_pickle=True)
31
- arrayBenchmark = numpy.concatenate([arrayExisting, benchmarkEntry])
32
- else:
33
- arrayBenchmark = benchmarkEntry
34
-
35
- numpy.save(str(pathFilenameRecordedBenchmarks), arrayBenchmark)
36
- return returnValueTarget
37
-
38
- return djZeph
39
- return AzeemTheWrapper
40
-
41
- def runBenchmarks(benchmarkIterations: int = 30) -> None:
42
- """Run benchmark iterations.
43
-
44
- Parameters:
45
- benchmarkIterations (30): Number of benchmark iterations to run
46
- """
47
- # TODO warmUp (False): Whether to perform one warm-up iteration
48
-
49
- import itertools
50
- from tqdm.auto import tqdm
51
- from mapFolding.oeis import settingsOEIS, oeisIDfor_n
52
- from concurrent.futures import ProcessPoolExecutor, as_completed
53
- max_workers = 6
54
-
55
- listParametersOEIS = [(oeisIdentifier, dimensionValue) for oeisIdentifier, settings in settingsOEIS.items() for dimensionValue in settings['valuesBenchmark']]
56
- # for (oeisIdentifier, dimensionValue), iterationIndex in tqdm(itertools.product(listParametersOEIS, range(benchmarkIterations)), total=len(listParametersOEIS) * benchmarkIterations):
57
- # oeisIDfor_n(oeisIdentifier, dimensionValue)
58
- listCartesianProduct = list(itertools.product(listParametersOEIS, range(benchmarkIterations)))
59
- with ProcessPoolExecutor(max_workers) as concurrencyManager:
60
- listConcurrency = [concurrencyManager.submit(oeisIDfor_n, *parameters[0]) for parameters in listCartesianProduct]
61
- for _complete in tqdm(as_completed(listConcurrency), total=len(listCartesianProduct)):
62
- pass
63
-
64
- if __name__ == '__main__':
65
- multiprocessing.set_start_method('spawn')
66
- pathFilenameRecordedBenchmarks.unlink(missing_ok=True)
67
- runBenchmarks(30)
citations/constants.py DELETED
@@ -1,3 +0,0 @@
1
- GITHUB_API_VERSION_HEADER = {
2
- "X-GitHub-Api-Version": "2022-11-28"
3
- }