mapFolding 0.2.1__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 -0
- mapFolding/beDRY.py +41 -35
- mapFolding/oeis.py +37 -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 +2 -4
- mapFolding/theSSOT.py +6 -1
- {mapFolding-0.2.1.dist-info → mapFolding-0.2.2.dist-info}/METADATA +1 -1
- mapFolding-0.2.2.dist-info/RECORD +28 -0
- tests/conftest.py +95 -37
- tests/test_oeis.py +25 -26
- tests/test_other.py +41 -4
- tests/test_tasks.py +11 -1
- mapFolding/importPackages.py +0 -5
- mapFolding-0.2.1.dist-info/RECORD +0 -28
- {mapFolding-0.2.1.dist-info → mapFolding-0.2.2.dist-info}/WHEEL +0 -0
- {mapFolding-0.2.1.dist-info → mapFolding-0.2.2.dist-info}/entry_points.txt +0 -0
- {mapFolding-0.2.1.dist-info → mapFolding-0.2.2.dist-info}/top_level.txt +0 -0
tests/conftest.py
CHANGED
|
@@ -3,31 +3,33 @@ Other test modules must not import directly from the package being tested."""
|
|
|
3
3
|
|
|
4
4
|
# TODO learn how to run tests and coverage analysis without `env = ["NUMBA_DISABLE_JIT=1"]`
|
|
5
5
|
|
|
6
|
-
from typing import Any, Callable, Dict, Generator, List, Optional, Sequence, Tuple, Type, Union
|
|
6
|
+
from typing import Any, Callable, Dict, Generator, List, Optional, Sequence, Set, Tuple, Type, Union
|
|
7
7
|
import pathlib
|
|
8
8
|
import pytest
|
|
9
9
|
import random
|
|
10
|
+
import shutil
|
|
10
11
|
import unittest.mock
|
|
11
|
-
|
|
12
|
-
from
|
|
13
|
-
from
|
|
12
|
+
import uuid
|
|
13
|
+
from Z0Z_tools.pytest_parseParameters import makeTestSuiteConcurrencyLimit
|
|
14
|
+
from Z0Z_tools.pytest_parseParameters import makeTestSuiteIntInnit
|
|
15
|
+
from Z0Z_tools.pytest_parseParameters import makeTestSuiteOopsieKwargsie
|
|
16
|
+
from mapFolding import countFolds, pathJobDEFAULT, indexMy, indexThe, indexTrack
|
|
17
|
+
from mapFolding import defineConcurrencyLimit, intInnit, oopsieKwargsie
|
|
14
18
|
from mapFolding import getLeavesTotal, parseDimensions, validateListDimensions
|
|
15
|
-
from mapFolding
|
|
16
|
-
from mapFolding
|
|
17
|
-
from mapFolding.
|
|
19
|
+
from mapFolding import getTaskDivisions, makeConnectionGraph, outfitFoldings, setCPUlimit
|
|
20
|
+
from mapFolding import oeisIDfor_n, getOEISids, clearOEIScache
|
|
21
|
+
from mapFolding.beDRY import makeDataContainer
|
|
18
22
|
from mapFolding.oeis import OEIS_for_n
|
|
19
|
-
from mapFolding.oeis import
|
|
23
|
+
from mapFolding.oeis import _getFilenameOEISbFile
|
|
20
24
|
from mapFolding.oeis import _getOEISidValues
|
|
21
25
|
from mapFolding.oeis import _parseBFileOEIS
|
|
22
26
|
from mapFolding.oeis import _validateOEISid
|
|
23
|
-
from mapFolding.oeis import getOEISids
|
|
24
|
-
from mapFolding.oeis import oeisIDfor_n
|
|
25
27
|
from mapFolding.oeis import oeisIDsImplemented
|
|
26
28
|
from mapFolding.oeis import settingsOEIS
|
|
27
29
|
|
|
28
30
|
__all__ = [
|
|
29
31
|
'OEIS_for_n',
|
|
30
|
-
'
|
|
32
|
+
'_getFilenameOEISbFile',
|
|
31
33
|
'_getOEISidValues',
|
|
32
34
|
'_parseBFileOEIS',
|
|
33
35
|
'_validateOEISid',
|
|
@@ -37,14 +39,20 @@ __all__ = [
|
|
|
37
39
|
'expectSystemExit',
|
|
38
40
|
'getLeavesTotal',
|
|
39
41
|
'getOEISids',
|
|
42
|
+
'indexThe',
|
|
43
|
+
'getTaskDivisions',
|
|
40
44
|
'intInnit',
|
|
45
|
+
'makeConnectionGraph',
|
|
46
|
+
'makeDataContainer',
|
|
41
47
|
'makeTestSuiteConcurrencyLimit',
|
|
42
48
|
'makeTestSuiteIntInnit',
|
|
43
49
|
'makeTestSuiteOopsieKwargsie',
|
|
44
50
|
'oeisIDfor_n',
|
|
45
51
|
'oeisIDsImplemented',
|
|
46
52
|
'oopsieKwargsie',
|
|
53
|
+
'outfitFoldings',
|
|
47
54
|
'parseDimensions',
|
|
55
|
+
'setCPUlimit',
|
|
48
56
|
'settingsOEIS',
|
|
49
57
|
'standardCacheTest',
|
|
50
58
|
'standardComparison',
|
|
@@ -91,6 +99,75 @@ def makeDictionaryFoldsTotalKnown() -> Dict[Tuple[int,...], int]:
|
|
|
91
99
|
|
|
92
100
|
return dictionaryMapDimensionsToFoldsTotalKnown
|
|
93
101
|
|
|
102
|
+
"""
|
|
103
|
+
Section: temporary paths and pathFilenames"""
|
|
104
|
+
|
|
105
|
+
# SSOT for test data paths
|
|
106
|
+
pathDataSamples = pathlib.Path("tests/dataSamples")
|
|
107
|
+
pathTempRoot = pathDataSamples / "tmp"
|
|
108
|
+
|
|
109
|
+
# The registrar maintains the register of temp files
|
|
110
|
+
registerOfTempFiles: Set[pathlib.Path] = set()
|
|
111
|
+
|
|
112
|
+
def addTempFileToRegister(path: pathlib.Path) -> None:
|
|
113
|
+
"""The registrar adds a temp file to the register."""
|
|
114
|
+
registerOfTempFiles.add(path)
|
|
115
|
+
|
|
116
|
+
def cleanupTempFileRegister() -> None:
|
|
117
|
+
"""The registrar cleans up temp files in the register."""
|
|
118
|
+
for pathTemp in sorted(registerOfTempFiles, reverse=True):
|
|
119
|
+
try:
|
|
120
|
+
if pathTemp.is_file():
|
|
121
|
+
pathTemp.unlink(missing_ok=True)
|
|
122
|
+
elif pathTemp.is_dir():
|
|
123
|
+
shutil.rmtree(pathTemp, ignore_errors=True)
|
|
124
|
+
except Exception as ERRORmessage:
|
|
125
|
+
print(f"Warning: Failed to clean up {pathTemp}: {ERRORmessage}")
|
|
126
|
+
registerOfTempFiles.clear()
|
|
127
|
+
|
|
128
|
+
@pytest.fixture(scope="session", autouse=True)
|
|
129
|
+
def setupTeardownTestData() -> Generator[None, None, None]:
|
|
130
|
+
"""Auto-fixture to setup test data directories and cleanup after."""
|
|
131
|
+
pathDataSamples.mkdir(exist_ok=True)
|
|
132
|
+
pathTempRoot.mkdir(exist_ok=True)
|
|
133
|
+
yield
|
|
134
|
+
cleanupTempFileRegister()
|
|
135
|
+
|
|
136
|
+
@pytest.fixture
|
|
137
|
+
def pathTempTesting(request: pytest.FixtureRequest) -> pathlib.Path:
|
|
138
|
+
"""Create a unique temp directory for each test function."""
|
|
139
|
+
# Sanitize test name for filesystem compatibility
|
|
140
|
+
sanitizedName = request.node.name.replace('[', '_').replace(']', '_').replace('/', '_')
|
|
141
|
+
uniqueDirectory = f"{sanitizedName}_{uuid.uuid4()}"
|
|
142
|
+
pathTemp = pathTempRoot / uniqueDirectory
|
|
143
|
+
pathTemp.mkdir(parents=True, exist_ok=True)
|
|
144
|
+
|
|
145
|
+
addTempFileToRegister(pathTemp)
|
|
146
|
+
return pathTemp
|
|
147
|
+
|
|
148
|
+
@pytest.fixture
|
|
149
|
+
def pathCacheTesting(pathTempTesting: pathlib.Path) -> Generator[pathlib.Path, Any, None]:
|
|
150
|
+
"""Temporarily replace the OEIS cache directory with a test directory."""
|
|
151
|
+
from mapFolding import oeis as there_must_be_a_better_way
|
|
152
|
+
pathCacheOriginal = there_must_be_a_better_way._pathCache
|
|
153
|
+
there_must_be_a_better_way._pathCache = pathTempTesting
|
|
154
|
+
yield pathTempTesting
|
|
155
|
+
there_must_be_a_better_way._pathCache = pathCacheOriginal
|
|
156
|
+
|
|
157
|
+
@pytest.fixture
|
|
158
|
+
def pathFilenameBenchmarksTesting(pathTempTesting: pathlib.Path) -> Generator[pathlib.Path, Any, None]:
|
|
159
|
+
"""Temporarily replace the benchmarks directory with a test directory."""
|
|
160
|
+
from mapFolding.benchmarks import benchmarking
|
|
161
|
+
pathFilenameOriginal = benchmarking.pathFilenameRecordedBenchmarks
|
|
162
|
+
pathFilenameTest = pathTempTesting / "benchmarks.npy"
|
|
163
|
+
benchmarking.pathFilenameRecordedBenchmarks = pathFilenameTest
|
|
164
|
+
yield pathFilenameTest
|
|
165
|
+
benchmarking.pathFilenameRecordedBenchmarks = pathFilenameOriginal
|
|
166
|
+
|
|
167
|
+
@pytest.fixture
|
|
168
|
+
def pathFilenameFoldsTotalTesting(pathTempTesting: pathlib.Path) -> pathlib.Path:
|
|
169
|
+
return pathTempTesting.joinpath("foldsTotalTest.txt")
|
|
170
|
+
|
|
94
171
|
"""
|
|
95
172
|
Section: Fixtures"""
|
|
96
173
|
|
|
@@ -150,28 +227,15 @@ def oeisID_1random() -> str:
|
|
|
150
227
|
"""Return one random valid OEIS ID."""
|
|
151
228
|
return random.choice(oeisIDsImplemented)
|
|
152
229
|
|
|
153
|
-
@pytest.fixture
|
|
154
|
-
def pathCacheTesting(tmp_path: pathlib.Path) -> Generator[pathlib.Path, Any, None]:
|
|
155
|
-
"""Temporarily replace the OEIS cache directory with a test directory."""
|
|
156
|
-
from mapFolding import oeis as there_must_be_a_better_way
|
|
157
|
-
pathCacheOriginal = there_must_be_a_better_way._pathCache
|
|
158
|
-
there_must_be_a_better_way._pathCache = tmp_path
|
|
159
|
-
yield tmp_path
|
|
160
|
-
there_must_be_a_better_way._pathCache = pathCacheOriginal
|
|
161
|
-
|
|
162
|
-
@pytest.fixture
|
|
163
|
-
def pathBenchmarksTesting(tmp_path: pathlib.Path) -> Generator[pathlib.Path, Any, None]:
|
|
164
|
-
"""Temporarily replace the benchmarks directory with a test directory."""
|
|
165
|
-
from mapFolding.benchmarks import benchmarking
|
|
166
|
-
pathOriginal = benchmarking.pathFilenameRecordedBenchmarks
|
|
167
|
-
pathTest = tmp_path / "benchmarks.npy"
|
|
168
|
-
benchmarking.pathFilenameRecordedBenchmarks = pathTest
|
|
169
|
-
yield pathTest
|
|
170
|
-
benchmarking.pathFilenameRecordedBenchmarks = pathOriginal
|
|
171
|
-
|
|
172
230
|
"""
|
|
173
231
|
Section: Standardized test structures"""
|
|
174
232
|
|
|
233
|
+
def formatTestMessage(expected: Any, actual: Any, functionName: str, *arguments: Any) -> str:
|
|
234
|
+
"""Format assertion message for any test comparison."""
|
|
235
|
+
return (f"\nTesting: `{functionName}({', '.join(str(parameter) for parameter in arguments)})`\n"
|
|
236
|
+
f"Expected: {expected}\n"
|
|
237
|
+
f"Got: {actual}")
|
|
238
|
+
|
|
175
239
|
def standardComparison(expected: Any, functionTarget: Callable, *arguments: Any) -> None:
|
|
176
240
|
"""Template for tests expecting an error."""
|
|
177
241
|
if type(expected) == Type[Exception]:
|
|
@@ -217,12 +281,6 @@ def expectSystemExit(expected: Union[str, int, Sequence[int]], functionTarget: C
|
|
|
217
281
|
assert exitCode == expected, \
|
|
218
282
|
f"Expected exit code {expected} but got {exitCode}"
|
|
219
283
|
|
|
220
|
-
def formatTestMessage(expected: Any, actual: Any, functionName: str, *arguments: Any) -> str:
|
|
221
|
-
"""Format assertion message for any test comparison."""
|
|
222
|
-
return (f"\nTesting: `{functionName}({', '.join(str(parameter) for parameter in arguments)})`\n"
|
|
223
|
-
f"Expected: {expected}\n"
|
|
224
|
-
f"Got: {actual}")
|
|
225
|
-
|
|
226
284
|
def standardCacheTest(
|
|
227
285
|
expected: Any,
|
|
228
286
|
setupCacheFile: Optional[Callable[[pathlib.Path, str], None]],
|
|
@@ -237,7 +295,7 @@ def standardCacheTest(
|
|
|
237
295
|
oeisID: OEIS ID to test
|
|
238
296
|
pathCache: Temporary cache directory path
|
|
239
297
|
"""
|
|
240
|
-
pathFilenameCache = pathCache /
|
|
298
|
+
pathFilenameCache = pathCache / _getFilenameOEISbFile(oeisID)
|
|
241
299
|
|
|
242
300
|
# Setup cache file if provided
|
|
243
301
|
if setupCacheFile:
|
tests/test_oeis.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
from .conftest import *
|
|
1
|
+
from tests.conftest import *
|
|
2
2
|
from contextlib import redirect_stdout
|
|
3
3
|
from datetime import datetime, timedelta
|
|
4
|
+
from typing import Optional, Tuple, Union
|
|
4
5
|
import io
|
|
5
6
|
import os
|
|
6
7
|
import pathlib
|
|
@@ -62,29 +63,27 @@ def test_clearOEIScache(mock_unlink: unittest.mock.MagicMock, mock_exists: unitt
|
|
|
62
63
|
mock_exists.assert_called_once()
|
|
63
64
|
mock_unlink.assert_not_called()
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
standardCacheTest(settingsOEIS[oeisID_1random]['valuesKnown'], None, oeisID_1random, pathCacheTesting)
|
|
66
|
+
@pytest.mark.parametrize("scenarioCache", ["miss", "expired", "invalid"])
|
|
67
|
+
def testCacheScenarios(pathCacheTesting: pathlib.Path, oeisID_1random: str, scenarioCache: str) -> None:
|
|
68
|
+
"""Test cache scenarios: missing file, expired file, and invalid file."""
|
|
69
69
|
|
|
70
|
-
def
|
|
71
|
-
"""Test expired cache scenario."""
|
|
72
|
-
def setupExpiredCache(pathCache: pathlib.Path, oeisID: str) -> None:
|
|
70
|
+
def setupCacheExpired(pathCache: pathlib.Path, oeisID: str) -> None:
|
|
73
71
|
pathCache.write_text("# Old cache content")
|
|
74
72
|
oldModificationTime = datetime.now() - timedelta(days=30)
|
|
75
73
|
os.utime(pathCache, times=(oldModificationTime.timestamp(), oldModificationTime.timestamp()))
|
|
76
74
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def testInvalidCache(pathCacheTesting: pathlib.Path, oeisID_1random: str):
|
|
80
|
-
"""Test invalid cache content scenario."""
|
|
81
|
-
def setupInvalidCache(pathCache: pathlib.Path, oeisID: str) -> None:
|
|
75
|
+
def setupCacheInvalid(pathCache: pathlib.Path, oeisID: str) -> None:
|
|
82
76
|
pathCache.write_text("Invalid content")
|
|
83
77
|
|
|
84
|
-
|
|
78
|
+
if scenarioCache == "miss":
|
|
79
|
+
standardCacheTest(settingsOEIS[oeisID_1random]['valuesKnown'], None, oeisID_1random, pathCacheTesting)
|
|
80
|
+
elif scenarioCache == "expired":
|
|
81
|
+
standardCacheTest(settingsOEIS[oeisID_1random]['valuesKnown'], setupCacheExpired, oeisID_1random, pathCacheTesting)
|
|
82
|
+
else:
|
|
83
|
+
standardCacheTest(settingsOEIS[oeisID_1random]['valuesKnown'], setupCacheInvalid, oeisID_1random, pathCacheTesting)
|
|
85
84
|
|
|
86
85
|
def testInvalidFileContent(pathCacheTesting: pathlib.Path, oeisID_1random: str):
|
|
87
|
-
pathFilenameCache = pathCacheTesting /
|
|
86
|
+
pathFilenameCache = pathCacheTesting / _getFilenameOEISbFile(oeisID=oeisID_1random)
|
|
88
87
|
|
|
89
88
|
# Write invalid content to cache
|
|
90
89
|
pathFilenameCache.write_text("# A999999\n1 1\n2 2\n")
|
|
@@ -100,25 +99,17 @@ def testInvalidFileContent(pathCacheTesting: pathlib.Path, oeisID_1random: str):
|
|
|
100
99
|
# Verify cache now contains correct sequence ID
|
|
101
100
|
assert f"# {oeisID_1random}" in pathFilenameCache.read_text()
|
|
102
101
|
|
|
103
|
-
def testNetworkError(monkeypatch: pytest.MonkeyPatch, pathCacheTesting: pathlib.Path):
|
|
104
|
-
def mockUrlopen(*args, **kwargs):
|
|
105
|
-
raise urllib.error.URLError("Network error")
|
|
106
|
-
|
|
107
|
-
monkeypatch.setattr(urllib.request, 'urlopen', mockUrlopen)
|
|
108
|
-
with pytest.raises(urllib.error.URLError):
|
|
109
|
-
_getOEISidValues(next(iter(settingsOEIS)))
|
|
110
|
-
|
|
111
102
|
def testParseContentErrors():
|
|
112
103
|
"""Test invalid content parsing."""
|
|
113
104
|
standardComparison(ValueError, _parseBFileOEIS, "Invalid content\n1 2\n", 'A001415')
|
|
114
105
|
|
|
115
106
|
def testExtraComments(pathCacheTesting: pathlib.Path, oeisID_1random: str):
|
|
116
|
-
pathFilenameCache = pathCacheTesting /
|
|
107
|
+
pathFilenameCache = pathCacheTesting / _getFilenameOEISbFile(oeisID=oeisID_1random)
|
|
117
108
|
|
|
118
109
|
# Write content with extra comment lines
|
|
119
110
|
contentWithExtraComments = f"""# {oeisID_1random}
|
|
120
|
-
#
|
|
121
|
-
#
|
|
111
|
+
# Normal place for comment line 1
|
|
112
|
+
# Abnormal comment line
|
|
122
113
|
1 2
|
|
123
114
|
2 4
|
|
124
115
|
3 6
|
|
@@ -133,6 +124,14 @@ def testExtraComments(pathCacheTesting: pathlib.Path, oeisID_1random: str):
|
|
|
133
124
|
standardComparison(8, lambda d: d[4], OEISsequence) # Value after mid-sequence comment
|
|
134
125
|
standardComparison(10, lambda d: d[5], OEISsequence) # Last value
|
|
135
126
|
|
|
127
|
+
def testNetworkError(monkeypatch: pytest.MonkeyPatch, pathCacheTesting: pathlib.Path):
|
|
128
|
+
"""Test network error handling."""
|
|
129
|
+
def mockUrlopen(*args, **kwargs):
|
|
130
|
+
raise urllib.error.URLError("Network error")
|
|
131
|
+
|
|
132
|
+
monkeypatch.setattr(urllib.request, 'urlopen', mockUrlopen)
|
|
133
|
+
standardComparison(urllib.error.URLError, _getOEISidValues, next(iter(settingsOEIS)))
|
|
134
|
+
|
|
136
135
|
# ===== Command Line Interface Tests =====
|
|
137
136
|
def testHelpText():
|
|
138
137
|
"""Test that help text is complete and examples are valid."""
|
tests/test_other.py
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import List
|
|
1
3
|
from .conftest import *
|
|
2
4
|
import pytest
|
|
3
5
|
import sys
|
|
4
|
-
|
|
6
|
+
import unittest.mock
|
|
7
|
+
import numpy
|
|
8
|
+
import numba
|
|
9
|
+
|
|
10
|
+
# TODO test `outfitFoldings`; no negative values in arrays; compare datatypes to the typeddict; commpare the connection graph to making a graPH
|
|
5
11
|
|
|
6
12
|
@pytest.mark.parametrize("listDimensions,expected_intInnit,expected_parseListDimensions,expected_validateListDimensions,expected_getLeavesTotal", [
|
|
7
13
|
(None, ValueError, ValueError, ValueError, ValueError), # None instead of list
|
|
@@ -53,7 +59,19 @@ def test_getLeavesTotal_edge_cases() -> None:
|
|
|
53
59
|
standardComparison(6, getLeavesTotal, listOriginal)
|
|
54
60
|
standardComparison([2, 3], lambda x: x, listOriginal) # Check that the list wasn't modified
|
|
55
61
|
|
|
56
|
-
|
|
62
|
+
def test_countFolds_writeFoldsTotal_file(listDimensionsTestFunctionality: List[int], pathFilenameFoldsTotalTesting: Path) -> None:
|
|
63
|
+
with unittest.mock.patch("mapFolding.babbage._countFolds", return_value=12345):
|
|
64
|
+
standardComparison(12345, countFolds, listDimensionsTestFunctionality, pathFilenameFoldsTotalTesting)
|
|
65
|
+
standardComparison("12345", lambda: pathFilenameFoldsTotalTesting.read_text())
|
|
66
|
+
|
|
67
|
+
def test_countFolds_writeFoldsTotal_directory(listDimensionsTestFunctionality: List[int], pathTempTesting: Path) -> None:
|
|
68
|
+
with unittest.mock.patch("mapFolding.babbage._countFolds", return_value=67890):
|
|
69
|
+
returned = countFolds(listDimensionsTestFunctionality, writeFoldsTotal=pathTempTesting)
|
|
70
|
+
standardComparison(67890, lambda: returned)
|
|
71
|
+
# Construct expected filename from sorted dimensions
|
|
72
|
+
expectedName = str(sorted(listDimensionsTestFunctionality)).replace(' ', '') + '.foldsTotal'
|
|
73
|
+
standardComparison("67890", lambda: (pathTempTesting / expectedName).read_text())
|
|
74
|
+
|
|
57
75
|
def test_intInnit() -> None:
|
|
58
76
|
"""Test integer parsing using the test suite generator."""
|
|
59
77
|
for testName, testFunction in makeTestSuiteIntInnit(intInnit).items():
|
|
@@ -64,5 +82,24 @@ def test_oopsieKwargsie() -> None:
|
|
|
64
82
|
for testName, testFunction in makeTestSuiteOopsieKwargsie(oopsieKwargsie).items():
|
|
65
83
|
testFunction()
|
|
66
84
|
|
|
67
|
-
|
|
68
|
-
|
|
85
|
+
# TODO mock CPU counts?
|
|
86
|
+
# @pytest.mark.parametrize("CPUlimit, expectedLimit", [
|
|
87
|
+
# (None, numba.config.NUMBA_DEFAULT_NUM_THREADS),
|
|
88
|
+
# (False, numba.config.NUMBA_DEFAULT_NUM_THREADS),
|
|
89
|
+
# (True, 1),
|
|
90
|
+
# (4, 4),
|
|
91
|
+
# (0.5, max(1, numba.config.NUMBA_DEFAULT_NUM_THREADS // 2)),
|
|
92
|
+
# (-0.5, max(1, numba.config.NUMBA_DEFAULT_NUM_THREADS // 2)),
|
|
93
|
+
# (-2, max(1, numba.config.NUMBA_DEFAULT_NUM_THREADS - 2)),
|
|
94
|
+
# ])
|
|
95
|
+
# def test_setCPUlimit(CPUlimit, expectedLimit) -> None:
|
|
96
|
+
# standardComparison(expectedLimit, setCPUlimit, CPUlimit)
|
|
97
|
+
|
|
98
|
+
def test_makeConnectionGraph_nonNegative(listDimensionsTestFunctionality: List[int]) -> None:
|
|
99
|
+
connectionGraph = makeConnectionGraph(listDimensionsTestFunctionality)
|
|
100
|
+
assert numpy.all(connectionGraph >= 0), "All values in the connection graph should be non-negative."
|
|
101
|
+
|
|
102
|
+
@pytest.mark.parametrize("datatype", [numpy.int16, numpy.uint64])
|
|
103
|
+
def test_makeConnectionGraph_datatype(listDimensionsTestFunctionality: List[int], datatype) -> None:
|
|
104
|
+
connectionGraph = makeConnectionGraph(listDimensionsTestFunctionality, datatype=datatype)
|
|
105
|
+
assert connectionGraph.dtype == datatype, f"Expected datatype {datatype}, but got {connectionGraph.dtype}."
|
tests/test_tasks.py
CHANGED
|
@@ -3,6 +3,7 @@ import pytest
|
|
|
3
3
|
from typing import List, Dict, Tuple
|
|
4
4
|
|
|
5
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.
|
|
6
7
|
|
|
7
8
|
def test_countFolds_computationDivisions(listDimensionsTest_countFolds: List[int], foldsTotalKnown: Dict[Tuple[int, ...], int]) -> None:
|
|
8
9
|
standardComparison(foldsTotalKnown[tuple(listDimensionsTest_countFolds)], countFolds, listDimensionsTest_countFolds, None, 'maximum')
|
|
@@ -14,8 +15,17 @@ def test_defineConcurrencyLimit() -> None:
|
|
|
14
15
|
|
|
15
16
|
@pytest.mark.parametrize("CPUlimitParameter", [{"invalid": True}, ["weird"]])
|
|
16
17
|
def test_countFolds_cpuLimitOopsie(listDimensionsTestFunctionality: List[int], CPUlimitParameter: Dict[str, bool] | List[str]) -> None:
|
|
17
|
-
# This forces CPUlimit = oopsieKwargsie(cpuLimitValue).
|
|
18
18
|
standardComparison(ValueError, countFolds, listDimensionsTestFunctionality, None, 'cpu', CPUlimitParameter)
|
|
19
19
|
|
|
20
20
|
def test_countFolds_invalid_computationDivisions(listDimensionsTestFunctionality: List[int]) -> None:
|
|
21
21
|
standardComparison(ValueError, countFolds, listDimensionsTestFunctionality, None, {"wrong": "value"})
|
|
22
|
+
|
|
23
|
+
@pytest.mark.parametrize("computationDivisions, concurrencyLimit, listDimensions, expectedTaskDivisions", [
|
|
24
|
+
(None, 4, [9, 11], 0),
|
|
25
|
+
("maximum", 4, [7, 11], 77),
|
|
26
|
+
("cpu", 4, [3, 7], 4),
|
|
27
|
+
(["invalid"], 4, [19, 23], ValueError),
|
|
28
|
+
(20, 4, [3,5], ValueError)
|
|
29
|
+
])
|
|
30
|
+
def test_getTaskDivisions(computationDivisions, concurrencyLimit, listDimensions, expectedTaskDivisions) -> None:
|
|
31
|
+
standardComparison(expectedTaskDivisions, getTaskDivisions, computationDivisions, concurrencyLimit, None, listDimensions)
|
mapFolding/importPackages.py
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"""Experiment"""
|
|
2
|
-
from Z0Z_tools import defineConcurrencyLimit, intInnit, oopsieKwargsie
|
|
3
|
-
from Z0Z_tools.pytest_parseParameters import makeTestSuiteConcurrencyLimit
|
|
4
|
-
from Z0Z_tools.pytest_parseParameters import makeTestSuiteIntInnit
|
|
5
|
-
from Z0Z_tools.pytest_parseParameters import makeTestSuiteOopsieKwargsie
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
mapFolding/__init__.py,sha256=3kQQWyOBriVg9wO5btGE1Cq3lNqJz6CudrkOxVWcsy8,368
|
|
2
|
-
mapFolding/babbage.py,sha256=3D1qcntoiJm2tqgbiCAMc7GpGA0SZTdGORNEnensyxk,1882
|
|
3
|
-
mapFolding/beDRY.py,sha256=QACsmdskZplzMpYGUu7DSTSCE7x5JFApEyUqvUh0H0c,12613
|
|
4
|
-
mapFolding/importPackages.py,sha256=Pno5VXaNiyJKG2Jtj4sB_h6EG50IJ7tQKyivVoKFMxo,303
|
|
5
|
-
mapFolding/lovelace.py,sha256=qcyGpVEPP3n0r-RNrSUgPRP3yZJfBEfmok7jYMm1OI0,11473
|
|
6
|
-
mapFolding/oeis.py,sha256=c8oCAcWgLvwC-bBZzGty8yth1vWtT8lWcKQeCiNGYgw,12078
|
|
7
|
-
mapFolding/startHere.py,sha256=Z73A2bm35XygF6bpz710S8G2tVRdU_5-nO-nDgTaDhM,5068
|
|
8
|
-
mapFolding/theSSOT.py,sha256=-t23-gPLPNWWBEeSi1mKkNCeeQA4y1AA_oPKC7tZwe4,1970
|
|
9
|
-
mapFolding/JAX/lunnanJAX.py,sha256=xMZloN47q-MVfjdYOM1hi9qR4OnLq7qALmGLMraevQs,14819
|
|
10
|
-
mapFolding/JAX/taskJAX.py,sha256=yJNeH0rL6EhJ6ppnATHF0Zf81CDMC10bnPnimVxE1hc,20037
|
|
11
|
-
mapFolding/benchmarks/benchmarking.py,sha256=kv85F6V9pGhZvTOImArOuxyg5rywA_T6JLH_qFXM8BM,3018
|
|
12
|
-
mapFolding/benchmarks/test_benchmarks.py,sha256=c4ANeR3jgqpKXFoxDeZkmAHxSuenMwsjmrhKJ1_XPqY,3659
|
|
13
|
-
mapFolding/reference/hunterNumba.py,sha256=jV0dBjhLcnJjUHWRxLV_xvPIUP_GRLRKVeDhOtM9Wp4,7475
|
|
14
|
-
mapFolding/reference/irvineJavaPort.py,sha256=Sj-63Z-OsGuDoEBXuxyjRrNmmyl0d7Yz_XuY7I47Oyg,4250
|
|
15
|
-
mapFolding/reference/lunnan.py,sha256=SwjpOr1ROg-yZaZuiL7XjXhuvBxu_K4gQoPAWKUjJk4,5037
|
|
16
|
-
mapFolding/reference/lunnanNumpy.py,sha256=bDQsBZUQcqJ9bTdnMF7HgtPcgpIodctujkm_lpq9NZ4,4653
|
|
17
|
-
mapFolding/reference/lunnanWhile.py,sha256=p8_zLdMc6ujTYIu_yn-hbzOuLTQHvo0ENciIDmKayDU,4067
|
|
18
|
-
mapFolding/reference/rotatedEntryPoint.py,sha256=6WVvEcGwDgRPa7dDs7ODAHUJjHDZDIDN6CXH8fFVFmA,12105
|
|
19
|
-
tests/__init__.py,sha256=PGYVr7r23gATgcvZ3Sfph9D_g1MVvhgzMNWXBs_9tmY,52
|
|
20
|
-
tests/conftest.py,sha256=ur6l5nDnWju7zOEMXqoNGYHY-Hf9GApOm4VT9pXtMtY,10594
|
|
21
|
-
tests/test_oeis.py,sha256=h-NhWRoarl3v6qoB0RpnaUPuMGrQpWyfmsL0FXsGauU,7972
|
|
22
|
-
tests/test_other.py,sha256=3Qc6fA39q5u_U0JhFUB9mdBd5_XcVC7IP9DwlNuG9p8,4716
|
|
23
|
-
tests/test_tasks.py,sha256=Hn4N8OVVfDeNjL7ad5ELKKDgdOn8sDBj6IebPGpLIlE,1254
|
|
24
|
-
mapFolding-0.2.1.dist-info/METADATA,sha256=r7QVig9M5_DReHsPG_wyyRNJe0UkggfUotMf8tfoF7I,5914
|
|
25
|
-
mapFolding-0.2.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
26
|
-
mapFolding-0.2.1.dist-info/entry_points.txt,sha256=F3OUeZR1XDTpoH7k3wXuRb3KF_kXTTeYhu5AGK1SiOQ,146
|
|
27
|
-
mapFolding-0.2.1.dist-info/top_level.txt,sha256=1gP2vFaqPwHujGwb3UjtMlLEGN-943VSYFR7V4gDqW8,17
|
|
28
|
-
mapFolding-0.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|