mapFolding 0.13.0__py3-none-any.whl → 0.14.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.
- mapFolding/_oeisFormulas/A000136.py +4 -0
- mapFolding/_oeisFormulas/A000560.py +4 -0
- mapFolding/_oeisFormulas/A000682.py +17 -0
- mapFolding/_oeisFormulas/A005315.py +4 -0
- mapFolding/_oeisFormulas/A005316.py +10 -0
- mapFolding/_oeisFormulas/A223094.py +7 -0
- mapFolding/_oeisFormulas/A259702.py +4 -0
- mapFolding/_oeisFormulas/A301620.py +6 -0
- mapFolding/_oeisFormulas/Z0Z_aOFn.py +19 -0
- mapFolding/_oeisFormulas/Z0Z_oeisMeanders.py +53 -0
- mapFolding/_oeisFormulas/__init__.py +1 -0
- mapFolding/_oeisFormulas/matrixMeanders.py +65 -0
- mapFolding/_oeisFormulas/matrixMeandersAnnex.py +84 -0
- mapFolding/_theSSOT.py +68 -26
- mapFolding/basecamp.py +2 -2
- mapFolding/beDRY.py +1 -1
- mapFolding/oeis.py +56 -167
- mapFolding/reference/A005316JavaPort.py +134 -0
- mapFolding/reference/A005316imperative.py +101 -0
- mapFolding/reference/A005316intOptimized.py +122 -0
- mapFolding/reference/A005316optimized128bit.py +79 -0
- mapFolding/reference/A005316primitiveOptimized.py +97 -0
- mapFolding/reference/A005316redis.py +118 -0
- mapFolding/reference/A005316write2disk.py +169 -0
- mapFolding/reference/irvineJavaPort.py +4 -8
- mapFolding/reference/matrixMeandersBaseline.py +65 -0
- mapFolding/reference/matrixMeandersBaselineAnnex.py +84 -0
- mapFolding/someAssemblyRequired/RecipeJob.py +3 -4
- mapFolding/someAssemblyRequired/_toolkitContainers.py +3 -3
- mapFolding/someAssemblyRequired/makeAllModules.py +2 -2
- mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +109 -141
- mapFolding/someAssemblyRequired/toolkitNumba.py +9 -7
- mapFolding/tests/conftest.py +13 -13
- mapFolding/tests/test_computations.py +4 -4
- mapFolding/tests/test_oeis.py +7 -14
- mapfolding-0.14.0.dist-info/METADATA +78 -0
- mapfolding-0.14.0.dist-info/RECORD +76 -0
- mapfolding-0.13.0.dist-info/METADATA +0 -154
- mapfolding-0.13.0.dist-info/RECORD +0 -54
- {mapfolding-0.13.0.dist-info → mapfolding-0.14.0.dist-info}/WHEEL +0 -0
- {mapfolding-0.13.0.dist-info → mapfolding-0.14.0.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.13.0.dist-info → mapfolding-0.14.0.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.13.0.dist-info → mapfolding-0.14.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
from typing import NamedTuple
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
class limitLocators(NamedTuple):
|
|
5
|
+
curveLocationsMAXIMUM: int
|
|
6
|
+
bifurcationEvenLocator: int
|
|
7
|
+
bifurcationOddLocator: int
|
|
8
|
+
|
|
9
|
+
curveMaximum: dict[int, limitLocators] = {
|
|
10
|
+
0: limitLocators(16, 0x2a, 0x15),
|
|
11
|
+
1: limitLocators(64, 0xaa, 0x55),
|
|
12
|
+
2: limitLocators(256, 0x2aa, 0x155),
|
|
13
|
+
3: limitLocators(1024, 0xaaa, 0x555),
|
|
14
|
+
4: limitLocators(4096, 0x2aaa, 0x1555),
|
|
15
|
+
5: limitLocators(16384, 0xaaaa, 0x5555),
|
|
16
|
+
6: limitLocators(65536, 0x2aaaa, 0x15555),
|
|
17
|
+
7: limitLocators(262144, 0xaaaaa, 0x55555),
|
|
18
|
+
8: limitLocators(1048576, 0x2aaaaa, 0x155555),
|
|
19
|
+
9: limitLocators(4194304, 0xaaaaaa, 0x555555),
|
|
20
|
+
10: limitLocators(16777216, 0x2aaaaaa, 0x1555555),
|
|
21
|
+
11: limitLocators(67108864, 0xaaaaaaa, 0x5555555),
|
|
22
|
+
12: limitLocators(268435456, 0x2aaaaaaa, 0x15555555),
|
|
23
|
+
13: limitLocators(1073741824, 0xaaaaaaaa, 0x55555555),
|
|
24
|
+
14: limitLocators(4294967296, 0x2aaaaaaaa, 0x155555555),
|
|
25
|
+
15: limitLocators(17179869184, 0xaaaaaaaaa, 0x555555555),
|
|
26
|
+
16: limitLocators(68719476736, 0x2aaaaaaaaa, 0x1555555555),
|
|
27
|
+
17: limitLocators(274877906944, 0xaaaaaaaaaa, 0x5555555555),
|
|
28
|
+
18: limitLocators(1099511627776, 0x2aaaaaaaaaa, 0x15555555555),
|
|
29
|
+
19: limitLocators(4398046511104, 0xaaaaaaaaaaa, 0x55555555555),
|
|
30
|
+
20: limitLocators(17592186044416, 0x2aaaaaaaaaaa, 0x155555555555),
|
|
31
|
+
21: limitLocators(70368744177664, 0xaaaaaaaaaaaa, 0x555555555555),
|
|
32
|
+
22: limitLocators(281474976710656, 0x2aaaaaaaaaaaa, 0x1555555555555),
|
|
33
|
+
23: limitLocators(1125899906842624, 0xaaaaaaaaaaaaa, 0x5555555555555),
|
|
34
|
+
24: limitLocators(4503599627370496, 0x2aaaaaaaaaaaaa, 0x15555555555555),
|
|
35
|
+
25: limitLocators(18014398509481984, 0xaaaaaaaaaaaaaa, 0x55555555555555),
|
|
36
|
+
26: limitLocators(72057594037927936, 0x2aaaaaaaaaaaaaa, 0x155555555555555),
|
|
37
|
+
27: limitLocators(288230376151711744, 0xaaaaaaaaaaaaaaa, 0x555555555555555),
|
|
38
|
+
28: limitLocators(1152921504606846976, 0x2aaaaaaaaaaaaaaa, 0x1555555555555555),
|
|
39
|
+
29: limitLocators(4611686018427387904, 0xaaaaaaaaaaaaaaaa, 0x5555555555555555),
|
|
40
|
+
30: limitLocators(18446744073709551616, 0x2aaaaaaaaaaaaaaaa, 0x15555555555555555),
|
|
41
|
+
31: limitLocators(73786976294838206464, 0xaaaaaaaaaaaaaaaaa, 0x55555555555555555),
|
|
42
|
+
32: limitLocators(295147905179352825856, 0x2aaaaaaaaaaaaaaaaa, 0x155555555555555555),
|
|
43
|
+
33: limitLocators(1180591620717411303424, 0xaaaaaaaaaaaaaaaaaa, 0x555555555555555555),
|
|
44
|
+
34: limitLocators(4722366482869645213696, 0x2aaaaaaaaaaaaaaaaaa, 0x1555555555555555555),
|
|
45
|
+
35: limitLocators(18889465931478580854784, 0xaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555),
|
|
46
|
+
36: limitLocators(75557863725914323419136, 0x2aaaaaaaaaaaaaaaaaaa, 0x15555555555555555555),
|
|
47
|
+
37: limitLocators(302231454903657293676544, 0xaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555),
|
|
48
|
+
38: limitLocators(1208925819614629174706176, 0x2aaaaaaaaaaaaaaaaaaaa, 0x155555555555555555555),
|
|
49
|
+
39: limitLocators(4835703278458516698824704, 0xaaaaaaaaaaaaaaaaaaaaa, 0x555555555555555555555),
|
|
50
|
+
40: limitLocators(19342813113834066795298816, 0x2aaaaaaaaaaaaaaaaaaaaa, 0x1555555555555555555555),
|
|
51
|
+
41: limitLocators(77371252455336267181195264, 0xaaaaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555555),
|
|
52
|
+
42: limitLocators(309485009821345068724781056, 0x2aaaaaaaaaaaaaaaaaaaaaa, 0x15555555555555555555555),
|
|
53
|
+
43: limitLocators(1237940039285380274899124224, 0xaaaaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555555),
|
|
54
|
+
44: limitLocators(4951760157141521099596496896, 0x2aaaaaaaaaaaaaaaaaaaaaaa, 0x155555555555555555555555),
|
|
55
|
+
45: limitLocators(19807040628566084398385987584, 0xaaaaaaaaaaaaaaaaaaaaaaaa, 0x555555555555555555555555),
|
|
56
|
+
46: limitLocators(79228162514264337593543950336, 0x2aaaaaaaaaaaaaaaaaaaaaaaa, 0x1555555555555555555555555),
|
|
57
|
+
47: limitLocators(316912650057057350374175801344, 0xaaaaaaaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555555555),
|
|
58
|
+
48: limitLocators(1267650600228229401496703205376, 0x2aaaaaaaaaaaaaaaaaaaaaaaaa, 0x15555555555555555555555555),
|
|
59
|
+
49: limitLocators(5070602400912917605986812821504, 0xaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555555555),
|
|
60
|
+
50: limitLocators(20282409603651670423947251286016, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaa, 0x155555555555555555555555555),
|
|
61
|
+
51: limitLocators(81129638414606681695789005144064, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x555555555555555555555555555),
|
|
62
|
+
52: limitLocators(324518553658426726783156020576256, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x1555555555555555555555555555),
|
|
63
|
+
53: limitLocators(1298074214633706907132624082305024, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555555555555),
|
|
64
|
+
54: limitLocators(5192296858534827628530496329220096, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x15555555555555555555555555555),
|
|
65
|
+
55: limitLocators(20769187434139310514121985316880384, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555555555555),
|
|
66
|
+
56: limitLocators(83076749736557242056487941267521536, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x155555555555555555555555555555),
|
|
67
|
+
57: limitLocators(332306998946228968225951765070086144, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x555555555555555555555555555555),
|
|
68
|
+
58: limitLocators(1329227995784915872903807060280344576, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x1555555555555555555555555555555),
|
|
69
|
+
59: limitLocators(5316911983139663491615228241121378304, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555555555555555),
|
|
70
|
+
60: limitLocators(21267647932558653966460912964485513216, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x15555555555555555555555555555555),
|
|
71
|
+
61: limitLocators(85070591730234615865843651857942052864, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555555555555555),
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
def makeCurveMaximum() -> None:
|
|
75
|
+
sys.stdout.write("curveMaximum: dict[int, limitLocators] = {\n")
|
|
76
|
+
for n in range(62):
|
|
77
|
+
curveLocationsMAXIMUM = 1 << (2 * n + 4)
|
|
78
|
+
bifurcationOddLocator = int('01' * ((curveLocationsMAXIMUM.bit_length() + 1) // 2), 2)
|
|
79
|
+
sys.stdout.write(f"{n}: limitLocators({curveLocationsMAXIMUM}, {hex(bifurcationOddLocator << 1)}, {hex(bifurcationOddLocator)}),\n")
|
|
80
|
+
sys.stdout.write("}\n")
|
|
81
|
+
|
|
82
|
+
if __name__ == '__main__':
|
|
83
|
+
makeCurveMaximum()
|
|
84
|
+
|
|
@@ -9,7 +9,6 @@ from mapFolding import (
|
|
|
9
9
|
from mapFolding.someAssemblyRequired import dataclassInstanceIdentifierDEFAULT, ShatteredDataclass
|
|
10
10
|
from mapFolding.someAssemblyRequired.transformationTools import shatter_dataclassesDOTdataclass
|
|
11
11
|
from pathlib import Path, PurePosixPath
|
|
12
|
-
from typing import TypeAlias
|
|
13
12
|
import dataclasses
|
|
14
13
|
|
|
15
14
|
@dataclasses.dataclass
|
|
@@ -134,11 +133,11 @@ class RecipeJobTheorem2:
|
|
|
134
133
|
"""Logical path to target dataclass module."""
|
|
135
134
|
|
|
136
135
|
# Datatypes ------------------------------------------
|
|
137
|
-
DatatypeFoldsTotal
|
|
136
|
+
type DatatypeFoldsTotal = TheDatatypeFoldsTotal
|
|
138
137
|
"""Type alias for datatype linked to the magnitude of `foldsTotal`."""
|
|
139
|
-
DatatypeElephino
|
|
138
|
+
type DatatypeElephino = TheDatatypeElephino
|
|
140
139
|
"""Type alias for intermediate computation datatype."""
|
|
141
|
-
DatatypeLeavesTotal
|
|
140
|
+
type DatatypeLeavesTotal = TheDatatypeLeavesTotal
|
|
142
141
|
"""Type alias for datatype linked to the magnitude of `leavesTotal`."""
|
|
143
142
|
|
|
144
143
|
def _makePathFilename(self, pathRoot: PurePosixPath | None = None, logicalPathINFIX: identifierDotAttribute | None = None, filenameStem: str | None = None, fileExtension: str | None = None) -> PurePosixPath:
|
|
@@ -217,10 +217,10 @@ class DeReConstructField2ast:
|
|
|
217
217
|
self.ast_keyword_field__field = Make.keyword(self.name, self.astName)
|
|
218
218
|
self.ast_nameDOTname = Make.Attribute(Make.Name(dataclassesDOTdataclassInstanceIdentifier), self.name)
|
|
219
219
|
|
|
220
|
-
self.astAnnotation =
|
|
220
|
+
self.astAnnotation = cast('ast.Name', raiseIfNone(NodeTourist(
|
|
221
221
|
findThis = Be.AnnAssign.targetIs(IfThis.isNameIdentifier(self.name))
|
|
222
|
-
, doThat = Then.extractIt(
|
|
223
|
-
).captureLastMatch(dataclassClassDef))
|
|
222
|
+
, doThat = Then.extractIt(DOT.annotation)
|
|
223
|
+
).captureLastMatch(dataclassClassDef)))
|
|
224
224
|
|
|
225
225
|
self.ast_argAnnotated = Make.arg(self.name, self.astAnnotation)
|
|
226
226
|
|
|
@@ -299,7 +299,7 @@ def makeDaoOfMapFolding(astModule: ast.Module, moduleIdentifier: str, callableId
|
|
|
299
299
|
ingredientsFunctionDispatcher.imports.update(shatteredDataclass.imports)
|
|
300
300
|
targetCallableIdentifier = ingredientsFunction.astFunctionDef.name
|
|
301
301
|
ingredientsFunctionDispatcher = unpackDataclassCallFunctionRepackDataclass(ingredientsFunctionDispatcher, targetCallableIdentifier, shatteredDataclass)
|
|
302
|
-
astTuple: ast.Tuple = cast('ast.Tuple', raiseIfNone(NodeTourist
|
|
302
|
+
astTuple: ast.Tuple = cast('ast.Tuple', raiseIfNone(NodeTourist(Be.Return.valueIs(Be.Tuple)
|
|
303
303
|
, doThat=Then.extractIt(DOT.value)).captureLastMatch(ingredientsFunction.astFunctionDef)))
|
|
304
304
|
astTuple.ctx = ast.Store()
|
|
305
305
|
|
|
@@ -743,7 +743,7 @@ def makeUnRePackDataclass(astImportFrom: ast.ImportFrom) -> None:
|
|
|
743
743
|
targetCallableIdentifier = astImportFrom.names[0].name
|
|
744
744
|
ingredientsFunction = raiseIfNone(unpackDataclassCallFunctionRepackDataclass(ingredientsFunction, targetCallableIdentifier, shatteredDataclass))
|
|
745
745
|
targetFunctionDef: ast.FunctionDef = raiseIfNone(extractFunctionDef(parseLogicalPath2astModule(raiseIfNone(astImportFrom.module)), targetCallableIdentifier))
|
|
746
|
-
astTuple: ast.Tuple = cast('ast.Tuple', raiseIfNone(NodeTourist
|
|
746
|
+
astTuple: ast.Tuple = cast('ast.Tuple', raiseIfNone(NodeTourist(Be.Return.valueIs(Be.Tuple)
|
|
747
747
|
, doThat=Then.extractIt(DOT.value)).captureLastMatch(targetFunctionDef)))
|
|
748
748
|
astTuple.ctx = ast.Store()
|
|
749
749
|
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
"""codon.
|
|
2
2
|
|
|
3
|
-
https://docs.exaloop.io/start/install/
|
|
3
|
+
https://docs.exaloop.io/start/install/
|
|
4
|
+
"""
|
|
4
5
|
|
|
5
6
|
from astToolkit import (
|
|
6
|
-
Be, DOT, extractFunctionDef, Grab,
|
|
7
|
-
|
|
8
|
-
from astToolkit.transformationTools import write_astModule
|
|
7
|
+
Be, DOT, extractFunctionDef, Grab, identifierDotAttribute, IngredientsFunction, IngredientsModule, Make, NodeChanger,
|
|
8
|
+
NodeTourist, Then)
|
|
9
|
+
from astToolkit.transformationTools import removeUnusedParameters, write_astModule
|
|
9
10
|
from hunterMakesPy import autoDecodingRLE, raiseIfNone
|
|
10
|
-
from mapFolding import getPathFilenameFoldsTotal, MapFoldingState
|
|
11
|
+
from mapFolding import DatatypeLeavesTotal, getPathFilenameFoldsTotal, MapFoldingState
|
|
11
12
|
from mapFolding.someAssemblyRequired import IfThis
|
|
12
13
|
from mapFolding.someAssemblyRequired.RecipeJob import RecipeJobTheorem2
|
|
13
14
|
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds
|
|
14
15
|
from pathlib import Path, PurePosixPath
|
|
15
|
-
from typing import cast, NamedTuple
|
|
16
|
+
from typing import cast, NamedTuple, TYPE_CHECKING
|
|
16
17
|
import ast
|
|
17
18
|
import subprocess
|
|
18
19
|
import sys
|
|
19
20
|
|
|
21
|
+
if TYPE_CHECKING:
|
|
22
|
+
from io import TextIOBase
|
|
23
|
+
|
|
20
24
|
class DatatypeConfiguration(NamedTuple):
|
|
21
25
|
"""Configuration for mapping framework datatypes to compiled datatypes.
|
|
22
26
|
|
|
23
27
|
This configuration class defines how abstract datatypes used in the map folding framework should be replaced with compiled
|
|
24
|
-
datatypes during code generation. Each configuration specifies the source module, target type name, and optional import
|
|
25
|
-
|
|
28
|
+
datatypes during code generation. Each configuration specifies the source module, target type name, and optional import alias
|
|
29
|
+
for the transformation.
|
|
26
30
|
|
|
27
31
|
Attributes
|
|
28
32
|
----------
|
|
@@ -44,34 +48,39 @@ class DatatypeConfiguration(NamedTuple):
|
|
|
44
48
|
# TODO replace with dynamic system. Probably use `Final` in the dataclass.
|
|
45
49
|
listIdentifiersStaticValuesHARDCODED: list[str] = ['dimensionsTotal', 'leavesTotal']
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
DatatypeConfiguration(datatypeIdentifier='
|
|
51
|
+
# TODO Dynamically calculate the bitwidth of each datatype.
|
|
52
|
+
listDatatypeConfigurations: list[DatatypeConfiguration] = [
|
|
53
|
+
DatatypeConfiguration(datatypeIdentifier='DatatypeLeavesTotal', typeModule='numpy', typeIdentifier='uint8', type_asname='DatatypeLeavesTotal'),
|
|
54
|
+
DatatypeConfiguration(datatypeIdentifier='DatatypeElephino', typeModule='numpy', typeIdentifier='uint8', type_asname='DatatypeElephino'),
|
|
50
55
|
DatatypeConfiguration(datatypeIdentifier='DatatypeFoldsTotal', typeModule='numpy', typeIdentifier='int64', type_asname='DatatypeFoldsTotal'),
|
|
51
56
|
]
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
DatatypeConfiguration(datatypeIdentifier='Array1DLeavesTotal', typeModule='numpy', typeIdentifier='
|
|
55
|
-
DatatypeConfiguration(datatypeIdentifier='Array1DElephino', typeModule='numpy', typeIdentifier='
|
|
56
|
-
DatatypeConfiguration(datatypeIdentifier='Array3D', typeModule='numpy', typeIdentifier='
|
|
58
|
+
listNumPy_dtype: list[DatatypeConfiguration] = [
|
|
59
|
+
DatatypeConfiguration(datatypeIdentifier='Array1DLeavesTotal', typeModule='numpy', typeIdentifier='uint8', type_asname='Array1DLeavesTotal'),
|
|
60
|
+
DatatypeConfiguration(datatypeIdentifier='Array1DElephino', typeModule='numpy', typeIdentifier='uint8', type_asname='Array1DElephino'),
|
|
61
|
+
DatatypeConfiguration(datatypeIdentifier='Array3D', typeModule='numpy', typeIdentifier='uint8', type_asname='Array3D'),
|
|
57
62
|
]
|
|
58
63
|
|
|
59
|
-
def
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
def _addWriteFoldsTotal(ingredientsFunction: IngredientsFunction, job: RecipeJobTheorem2) -> IngredientsFunction:
|
|
65
|
+
NodeChanger(Be.Return, Then.removeIt).visit(ingredientsFunction.astFunctionDef)
|
|
66
|
+
ingredientsFunction.astFunctionDef.returns = Make.Constant(None)
|
|
67
|
+
|
|
68
|
+
writeFoldsTotal = Make.Expr(Make.Call(Make.Attribute(
|
|
69
|
+
Make.Call(Make.Name('open'), listParameters=[Make.Constant(str(job.pathFilenameFoldsTotal.as_posix())), Make.Constant('w')])
|
|
70
|
+
, 'write'), listParameters=[Make.Call(Make.Name('str'), listParameters=[
|
|
71
|
+
Make.Mult().join([job.shatteredDataclass.countingVariableName, Make.Constant(job.state.leavesTotal * 2)])])]))
|
|
72
|
+
|
|
73
|
+
NodeChanger(IfThis.isAllOf(Be.AugAssign.targetIs(IfThis.isNameIdentifier(job.shatteredDataclass.countingVariableName.id))
|
|
74
|
+
, Be.AugAssign.opIs(Be.Mult), Be.AugAssign.valueIs(Be.Constant))
|
|
75
|
+
, doThat=Then.replaceWith(writeFoldsTotal)
|
|
76
|
+
).visit(ingredientsFunction.astFunctionDef)
|
|
77
|
+
|
|
78
|
+
return ingredientsFunction
|
|
67
79
|
|
|
68
|
-
|
|
80
|
+
def _datatypeDefinitions(ingredientsFunction: IngredientsFunction, ingredientsModule: IngredientsModule) -> tuple[IngredientsFunction, IngredientsModule]:
|
|
81
|
+
for datatypeConfig in [*listDatatypeConfigurations, *listNumPy_dtype]:
|
|
69
82
|
ingredientsFunction.imports.removeImportFrom(datatypeConfig.typeModule, None, datatypeConfig.datatypeIdentifier)
|
|
70
83
|
ingredientsFunction.imports.addImportFrom_asStr(datatypeConfig.typeModule, datatypeConfig.typeIdentifier, datatypeConfig.type_asname)
|
|
71
|
-
continue
|
|
72
|
-
ingredientsModule.appendPrologue(statement=Make.Assign([Make.Name(datatypeConfig.datatypeIdentifier, ast.Store())]
|
|
73
|
-
, value=Make.Name(datatypeConfig.typeIdentifier)
|
|
74
|
-
))
|
|
75
84
|
|
|
76
85
|
ingredientsFunction.imports.removeImportFromModule('mapFolding.dataBaskets')
|
|
77
86
|
|
|
@@ -82,111 +91,66 @@ def _pythonCode2expr(string: str) -> ast.expr:
|
|
|
82
91
|
return raiseIfNone(NodeTourist(Be.Expr, Then.extractIt(DOT.value)).captureLastMatch(ast.parse(string)))
|
|
83
92
|
|
|
84
93
|
def _variableCompatibility(ingredientsFunction: IngredientsFunction, job: RecipeJobTheorem2) -> IngredientsFunction:
|
|
94
|
+
# On some assignment or comparison values, add a type constructor to ensure compatibility.
|
|
95
|
+
# On some values-as-indexer, add a type constructor to ensure indexing-method compatibility.
|
|
85
96
|
for ast_arg in job.shatteredDataclass.list_argAnnotated4ArgumentsSpecification:
|
|
86
97
|
identifier = ast_arg.arg
|
|
87
98
|
annotation = raiseIfNone(ast_arg.annotation)
|
|
88
99
|
|
|
89
|
-
# `identifier` in Augmented Assignment.
|
|
90
|
-
NodeChanger(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
and Be.Assign.valueIs(Be.Constant)(node)
|
|
97
|
-
, doThat=lambda node: Grab.valueAttribute(Then.replaceWith(Make.Call(annotation, listParameters=[node.value])))(node)
|
|
100
|
+
# `identifier` in Augmented Assignment, or in Assignments and value is Constant.
|
|
101
|
+
NodeChanger(findThis=IfThis.isAnyOf(
|
|
102
|
+
Be.AugAssign.targetIs(IfThis.isNestedNameIdentifier(identifier))
|
|
103
|
+
, IfThis.isAllOf(IfThis.isAssignAndTargets0Is(IfThis.isNameIdentifier(identifier))
|
|
104
|
+
, Be.Assign.valueIs(Be.Constant))
|
|
105
|
+
)
|
|
106
|
+
, doThat=lambda node, annotation=annotation: Grab.valueAttribute(Then.replaceWith(Make.Call(annotation, listParameters=[node.value])))(node)
|
|
98
107
|
).visit(ingredientsFunction.astFunctionDef)
|
|
99
108
|
|
|
100
109
|
# `identifier` - 1.
|
|
101
110
|
NodeChanger(Be.BinOp.leftIs(IfThis.isNestedNameIdentifier(identifier))
|
|
102
|
-
, doThat=lambda node: Grab.rightAttribute(Then.replaceWith(Make.Call(annotation, listParameters=[node.right])))(node)
|
|
111
|
+
, doThat=lambda node, annotation=annotation: Grab.rightAttribute(Then.replaceWith(Make.Call(annotation, listParameters=[node.right])))(node)
|
|
103
112
|
).visit(ingredientsFunction.astFunctionDef)
|
|
104
113
|
|
|
105
114
|
# `identifier` in Comparison.
|
|
106
115
|
NodeChanger(Be.Compare.leftIs(IfThis.isNestedNameIdentifier(identifier))
|
|
107
|
-
, doThat=lambda node: Grab.comparatorsAttribute(lambda at: Then.replaceWith([Make.Call(annotation, listParameters=[node.comparators[0]])])(at[0]))(node)
|
|
116
|
+
, doThat=lambda node, annotation=annotation: Grab.comparatorsAttribute(lambda at, annotation=annotation: Then.replaceWith([Make.Call(annotation, listParameters=[node.comparators[0]])])(at[0]))(node)
|
|
108
117
|
).visit(ingredientsFunction.astFunctionDef)
|
|
109
118
|
|
|
110
119
|
# `identifier` has exactly one index value.
|
|
111
|
-
NodeChanger(
|
|
112
|
-
|
|
113
|
-
and not Be.Subscript.sliceIs(Be.Tuple)(node)
|
|
120
|
+
NodeChanger(IfThis.isAllOf(Be.Subscript.valueIs(IfThis.isNestedNameIdentifier(identifier))
|
|
121
|
+
, lambda node: not Be.Subscript.sliceIs(Be.Tuple)(node))
|
|
114
122
|
, doThat=lambda node: Grab.sliceAttribute(Then.replaceWith(Make.Call(Make.Name('int'), listParameters=[node.slice])))(node)
|
|
115
123
|
).visit(ingredientsFunction.astFunctionDef)
|
|
116
124
|
|
|
117
125
|
# `identifier` has multiple index values.
|
|
118
|
-
NodeChanger(
|
|
119
|
-
|
|
120
|
-
and Be.Subscript.sliceIs(Be.Tuple)(node)
|
|
126
|
+
NodeChanger(IfThis.isAllOf(Be.Subscript.valueIs(IfThis.isNestedNameIdentifier(identifier))
|
|
127
|
+
, Be.Subscript.sliceIs(Be.Tuple))
|
|
121
128
|
, doThat=lambda node: Grab.sliceAttribute(Grab.eltsAttribute(
|
|
122
129
|
Then.replaceWith([
|
|
123
|
-
Make.Call(Make.Name('int'), listParameters=[cast(ast.Tuple, node.slice).elts[index]])
|
|
124
|
-
for index in range(len(cast(ast.Tuple, node.slice).elts))
|
|
125
|
-
])
|
|
126
|
-
))(node)
|
|
130
|
+
Make.Call(Make.Name('int'), listParameters=[cast('ast.Tuple', node.slice).elts[index]])
|
|
131
|
+
for index in range(len(cast('ast.Tuple', node.slice).elts))])))(node)
|
|
127
132
|
).visit(ingredientsFunction.astFunctionDef)
|
|
128
133
|
|
|
129
134
|
return ingredientsFunction
|
|
130
135
|
|
|
131
|
-
def
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
job : RecipeJobTheorem2
|
|
144
|
-
Recipe containing concrete values for parameters and field metadata.
|
|
145
|
-
|
|
146
|
-
Returns
|
|
147
|
-
-------
|
|
148
|
-
modifiedFunction : IngredientsFunction
|
|
149
|
-
The modified function with parameters converted to initialized variables.
|
|
150
|
-
|
|
151
|
-
"""
|
|
152
|
-
ingredientsFunction.imports.update(job.shatteredDataclass.imports)
|
|
153
|
-
|
|
154
|
-
list_argCuzMyBrainRefusesToThink: list[ast.arg] = ingredientsFunction.astFunctionDef.args.args + ingredientsFunction.astFunctionDef.args.posonlyargs + ingredientsFunction.astFunctionDef.args.kwonlyargs
|
|
155
|
-
list_arg_arg: list[str] = [ast_arg.arg for ast_arg in list_argCuzMyBrainRefusesToThink]
|
|
156
|
-
listName: list[ast.Name] = []
|
|
157
|
-
NodeTourist(Be.Name, Then.appendTo(listName)).visit(ingredientsFunction.astFunctionDef)
|
|
158
|
-
listIdentifiers: list[str] = [astName.id for astName in listName]
|
|
159
|
-
listIdentifiersNotUsed: list[str] = list(set(list_arg_arg) - set(listIdentifiers))
|
|
160
|
-
|
|
161
|
-
for ast_arg in list_argCuzMyBrainRefusesToThink:
|
|
162
|
-
if ast_arg.arg in job.shatteredDataclass.field2AnnAssign:
|
|
163
|
-
if ast_arg.arg in listIdentifiersNotUsed:
|
|
164
|
-
pass
|
|
165
|
-
else:
|
|
166
|
-
Ima___Assign, elementConstructor = job.shatteredDataclass.Z0Z_field2AnnAssign[ast_arg.arg]
|
|
167
|
-
match elementConstructor:
|
|
168
|
-
case 'scalar':
|
|
169
|
-
cast('ast.Constant', cast('ast.Call', Ima___Assign.value).args[0]).value = int(job.state.__dict__[ast_arg.arg])
|
|
170
|
-
case 'array':
|
|
171
|
-
dataAsStrRLE: str = autoDecodingRLE(job.state.__dict__[ast_arg.arg], assumeAddSpaces=True)
|
|
172
|
-
dataAs_ast_expr: ast.expr = _pythonCode2expr(dataAsStrRLE)
|
|
173
|
-
cast('ast.Call', Ima___Assign.value).args = [dataAs_ast_expr]
|
|
174
|
-
case _:
|
|
175
|
-
pass
|
|
176
|
-
|
|
177
|
-
ingredientsFunction.astFunctionDef.body.insert(0, Ima___Assign)
|
|
178
|
-
|
|
179
|
-
NodeChanger(IfThis.is_argIdentifier(ast_arg.arg), Then.removeIt).visit(ingredientsFunction.astFunctionDef)
|
|
180
|
-
|
|
181
|
-
ast.fix_missing_locations(ingredientsFunction.astFunctionDef)
|
|
182
|
-
return ingredientsFunction
|
|
136
|
+
def _move_arg2body(identifier: str, job: RecipeJobTheorem2) -> ast.AnnAssign | ast.Assign:
|
|
137
|
+
Ima___Assign, elementConstructor = job.shatteredDataclass.Z0Z_field2AnnAssign[identifier]
|
|
138
|
+
match elementConstructor:
|
|
139
|
+
case 'scalar':
|
|
140
|
+
cast('ast.Constant', cast('ast.Call', Ima___Assign.value).args[0]).value = int(job.state.__dict__[identifier])
|
|
141
|
+
case 'array':
|
|
142
|
+
dataAsStrRLE: str = autoDecodingRLE(job.state.__dict__[identifier], assumeAddSpaces=True)
|
|
143
|
+
dataAs_ast_expr: ast.expr = _pythonCode2expr(dataAsStrRLE)
|
|
144
|
+
cast('ast.Call', Ima___Assign.value).args = [dataAs_ast_expr]
|
|
145
|
+
case _:
|
|
146
|
+
pass
|
|
147
|
+
return Ima___Assign
|
|
183
148
|
|
|
184
149
|
def makeJob(job: RecipeJobTheorem2) -> None:
|
|
185
150
|
"""Generate an optimized module for map folding calculations.
|
|
186
151
|
|
|
187
|
-
This function orchestrates the complete code transformation assembly line to convert
|
|
188
|
-
|
|
189
|
-
module.
|
|
152
|
+
This function orchestrates the complete code transformation assembly line to convert a generic map folding algorithm into a
|
|
153
|
+
highly optimized, specialized computation module.
|
|
190
154
|
|
|
191
155
|
Parameters
|
|
192
156
|
----------
|
|
@@ -204,53 +168,57 @@ def makeJob(job: RecipeJobTheorem2) -> None:
|
|
|
204
168
|
, Then.replaceWith(Make.Constant(int(job.state.__dict__[identifier])))
|
|
205
169
|
).visit(ingredientsCount.astFunctionDef)
|
|
206
170
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
print('\\nmap {job.state.mapShape} =', foldsTotal)
|
|
211
|
-
writeStream = open('{job.pathFilenameFoldsTotal.as_posix()}', 'w')
|
|
212
|
-
writeStream.write(str(foldsTotal))
|
|
213
|
-
writeStream.close()
|
|
214
|
-
"""
|
|
215
|
-
ingredientsModule = IngredientsModule(launcher=ast.parse(linesLaunch))
|
|
216
|
-
|
|
217
|
-
# TODO think about `groupsOfFolds *= DatatypeFoldsTotal({2 * job.state.leavesTotal}); return groupsOfFolds`
|
|
218
|
-
NodeChanger(Be.Return
|
|
219
|
-
, Then.replaceWith(Make.Return(job.shatteredDataclass.countingVariableName))).visit(ingredientsCount.astFunctionDef)
|
|
220
|
-
groupsOfFolds2foldsTotal = NodeChanger[ast.AugAssign, hasDOTvalue](
|
|
221
|
-
findThis=(lambda node: Be.AugAssign.targetIs(IfThis.isNameIdentifier(job.shatteredDataclass.countingVariableName.id))(node)
|
|
222
|
-
and Be.AugAssign.opIs(Be.Mult)(node)
|
|
223
|
-
and Be.AugAssign.valueIs(Be.Constant)(node)
|
|
224
|
-
)
|
|
225
|
-
, doThat=lambda node: Grab.valueAttribute(Then.replaceWith(Make.Constant(job.state.leavesTotal * ast.literal_eval(node.value))))(node)
|
|
226
|
-
)
|
|
227
|
-
groupsOfFolds2foldsTotal.visit(ingredientsCount.astFunctionDef)
|
|
171
|
+
ingredientsCount.imports.update(job.shatteredDataclass.imports)
|
|
172
|
+
ingredientsCount = removeUnusedParameters(ingredientsCount)
|
|
173
|
+
NodeChanger(Be.arg, lambda removeIt: ingredientsCount.astFunctionDef.body.insert(0, _move_arg2body(removeIt.arg, job))).visit(ingredientsCount.astFunctionDef)
|
|
228
174
|
|
|
229
|
-
|
|
230
|
-
ingredientsCount
|
|
175
|
+
ingredientsCount = _addWriteFoldsTotal(ingredientsCount, job)
|
|
176
|
+
ingredientsCount = _variableCompatibility(ingredientsCount, job)
|
|
231
177
|
|
|
232
|
-
|
|
178
|
+
ingredientsModule = IngredientsModule(launcher=Make.Module([
|
|
179
|
+
Make.If(Make.Compare(Make.Name('__name__'), [Make.Eq()], [Make.Constant('__main__')])
|
|
180
|
+
, body=[Make.Expr(Make.Call(Make.Name(job.countCallable)))])]))
|
|
233
181
|
|
|
234
182
|
ingredientsCount, ingredientsModule = _datatypeDefinitions(ingredientsCount, ingredientsModule)
|
|
235
|
-
# NOTE Reminder, `returns = None` means "type information is null"; the identifier for the return was removed by `_datatypeDefinitions`.
|
|
236
|
-
ingredientsCount.astFunctionDef.returns = None
|
|
237
|
-
|
|
238
|
-
ingredientsCount = _variableCompatibility(ingredientsCount, job)
|
|
239
183
|
|
|
240
184
|
ingredientsModule.appendIngredientsFunction(ingredientsCount)
|
|
241
|
-
write_astModule(ingredientsModule, pathFilename=job.pathFilenameModule, packageName=job.packageIdentifier)
|
|
242
185
|
|
|
243
186
|
if sys.platform == 'linux':
|
|
244
|
-
|
|
245
|
-
|
|
187
|
+
buildCommand: list[str] = ['codon', 'build', '--exe', '--release',
|
|
188
|
+
'--fast-math', '--enable-unsafe-fp-math', '--disable-exceptions',
|
|
189
|
+
'--mcpu=native',
|
|
190
|
+
'-o', str(job.pathFilenameModule.with_suffix('')),
|
|
191
|
+
'-']
|
|
192
|
+
streamText = subprocess.Popen(buildCommand, stdin=subprocess.PIPE, text=True)
|
|
193
|
+
if streamText.stdin is not None:
|
|
194
|
+
write_astModule(ingredientsModule, pathFilename=cast('TextIOBase', streamText.stdin), packageName=job.packageIdentifier)
|
|
195
|
+
streamText.stdin.close()
|
|
196
|
+
streamText.wait()
|
|
197
|
+
subprocess.run(['/usr/bin/strip', str(job.pathFilenameModule.with_suffix(''))], check=False)
|
|
198
|
+
sys.stdout.write(f"sudo systemd-run --unit={job.moduleIdentifier} --nice=-10 --property=CPUAffinity=0 {job.pathFilenameModule.with_suffix('')}\n")
|
|
199
|
+
else:
|
|
200
|
+
write_astModule(ingredientsModule, pathFilename=job.pathFilenameModule, packageName=job.packageIdentifier)
|
|
201
|
+
|
|
202
|
+
def fromMapShape(mapShape: tuple[DatatypeLeavesTotal, ...]) -> None:
|
|
203
|
+
"""Create a binary executable for a map-folding job from map dimensions.
|
|
204
|
+
|
|
205
|
+
This function initializes a map folding computation state from the given map shape, sets up the necessary file paths, and
|
|
206
|
+
generates an optimized executable for the specific map configuration.
|
|
246
207
|
|
|
247
|
-
|
|
248
|
-
|
|
208
|
+
Parameters
|
|
209
|
+
----------
|
|
210
|
+
mapShape : tuple[DatatypeLeavesTotal, ...]
|
|
211
|
+
Dimensions of the map as a tuple where each element represents the size
|
|
212
|
+
along one axis.
|
|
249
213
|
|
|
250
|
-
|
|
251
|
-
state = initializeGroupsOfFolds(MapFoldingState(
|
|
252
|
-
pathModule = PurePosixPath(
|
|
253
|
-
# TODO put `pathFilenameFoldsTotal` in wsl.
|
|
214
|
+
"""
|
|
215
|
+
state = initializeGroupsOfFolds(MapFoldingState(mapShape))
|
|
216
|
+
pathModule = PurePosixPath(Path.home(), 'mapFolding', 'jobs')
|
|
254
217
|
pathFilenameFoldsTotal = PurePosixPath(getPathFilenameFoldsTotal(state.mapShape, pathModule))
|
|
255
218
|
aJob = RecipeJobTheorem2(state, pathModule=pathModule, pathFilenameFoldsTotal=pathFilenameFoldsTotal)
|
|
256
219
|
makeJob(aJob)
|
|
220
|
+
|
|
221
|
+
if __name__ == '__main__':
|
|
222
|
+
mapShape = (2, 21)
|
|
223
|
+
fromMapShape(mapShape)
|
|
224
|
+
|
|
@@ -26,7 +26,9 @@ system to produce standalone modules optimized for specific map dimensions and c
|
|
|
26
26
|
"""
|
|
27
27
|
|
|
28
28
|
from astToolkit import identifierDotAttribute, IngredientsFunction, Make
|
|
29
|
-
from
|
|
29
|
+
from collections.abc import Callable
|
|
30
|
+
from numba.core.compiler import CompilerBase as numbaCompilerBase
|
|
31
|
+
from typing import Any, Final, NotRequired, TYPE_CHECKING, TypedDict
|
|
30
32
|
import ast
|
|
31
33
|
import dataclasses
|
|
32
34
|
import warnings
|
|
@@ -69,7 +71,7 @@ class ParametersNumba(TypedDict):
|
|
|
69
71
|
forceinline: NotRequired[bool]
|
|
70
72
|
forceobj: NotRequired[bool]
|
|
71
73
|
inline: NotRequired[str]
|
|
72
|
-
|
|
74
|
+
locals: NotRequired[dict[str, Any]]
|
|
73
75
|
looplift: NotRequired[bool]
|
|
74
76
|
no_cfunc_wrapper: NotRequired[bool]
|
|
75
77
|
no_cpython_wrapper: NotRequired[bool]
|
|
@@ -77,8 +79,8 @@ class ParametersNumba(TypedDict):
|
|
|
77
79
|
nogil: NotRequired[bool]
|
|
78
80
|
nopython: NotRequired[bool]
|
|
79
81
|
parallel: NotRequired[bool]
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
pipeline_class: NotRequired[type[numbaCompilerBase]]
|
|
83
|
+
signature_or_function: NotRequired[Any | Callable[..., Any] | str | tuple[Any, ...]]
|
|
82
84
|
target: NotRequired[str]
|
|
83
85
|
|
|
84
86
|
parametersNumbaDefault: Final[ParametersNumba] = { '_nrt': True, 'boundscheck': False, 'cache': True, 'error_model': 'numpy', 'fastmath': True, 'forceinline': True, 'inline': 'always', 'looplift': False, 'no_cfunc_wrapper': False, 'no_cpython_wrapper': False, 'nopython': True, 'parallel': False }
|
|
@@ -257,10 +259,10 @@ def decorateCallableWithNumba(ingredientsFunction: IngredientsFunction, paramete
|
|
|
257
259
|
|
|
258
260
|
if ingredientsFunction.astFunctionDef.returns and isinstance(ingredientsFunction.astFunctionDef.returns, ast.Name):
|
|
259
261
|
theReturn: ast.Name = ingredientsFunction.astFunctionDef.returns
|
|
260
|
-
list_argsDecorator = [
|
|
261
|
-
, list_arg4signature_or_function if list_arg4signature_or_function else [], [] )
|
|
262
|
+
list_argsDecorator = [Make.Call(Make.Name(theReturn.id)
|
|
263
|
+
, list_arg4signature_or_function if list_arg4signature_or_function else [], [] )]
|
|
262
264
|
elif list_arg4signature_or_function:
|
|
263
|
-
list_argsDecorator = [
|
|
265
|
+
list_argsDecorator = [Make.Tuple(list_arg4signature_or_function)]
|
|
264
266
|
|
|
265
267
|
ingredientsFunction.astFunctionDef = Z0Z_UnhandledDecorators(ingredientsFunction.astFunctionDef)
|
|
266
268
|
if parametersNumba is None:
|
mapFolding/tests/conftest.py
CHANGED
|
@@ -24,8 +24,8 @@ research domain.
|
|
|
24
24
|
"""
|
|
25
25
|
|
|
26
26
|
from collections.abc import Callable, Generator, Sequence
|
|
27
|
-
from mapFolding import getLeavesTotal, makeDataContainer,
|
|
28
|
-
from mapFolding.oeis import
|
|
27
|
+
from mapFolding import _theSSOT, getLeavesTotal, makeDataContainer, packageSettings, validateListDimensions
|
|
28
|
+
from mapFolding.oeis import dictionaryOEIS, oeisIDsImplemented
|
|
29
29
|
from pathlib import Path
|
|
30
30
|
from typing import Any
|
|
31
31
|
import numpy
|
|
@@ -149,10 +149,10 @@ def pathCacheTesting(path_tmpTesting: Path) -> Generator[Path, Any, None]:
|
|
|
149
149
|
Context manager that provides the temporary cache path and restores original.
|
|
150
150
|
|
|
151
151
|
"""
|
|
152
|
-
pathCacheOriginal =
|
|
153
|
-
|
|
152
|
+
pathCacheOriginal = _theSSOT.pathCache
|
|
153
|
+
_theSSOT.pathCache = path_tmpTesting
|
|
154
154
|
yield path_tmpTesting
|
|
155
|
-
|
|
155
|
+
_theSSOT.pathCache = pathCacheOriginal
|
|
156
156
|
|
|
157
157
|
@pytest.fixture
|
|
158
158
|
def pathFilenameFoldsTotalTesting(path_tmpTesting: Path) -> Path:
|
|
@@ -212,10 +212,10 @@ def oneTestCuzTestsOverwritingTests(oeisID_1random: str) -> tuple[int, ...]:
|
|
|
212
212
|
|
|
213
213
|
"""
|
|
214
214
|
while True:
|
|
215
|
-
n = random.choice(
|
|
215
|
+
n = random.choice(dictionaryOEIS[oeisID_1random]['valuesTestValidation'])
|
|
216
216
|
if n < 2:
|
|
217
217
|
continue
|
|
218
|
-
listDimensionsCandidate = list(
|
|
218
|
+
listDimensionsCandidate = list(dictionaryOEIS[oeisID_1random]['getMapShape'](n))
|
|
219
219
|
|
|
220
220
|
try:
|
|
221
221
|
return validateListDimensions(listDimensionsCandidate)
|
|
@@ -238,10 +238,10 @@ def mapShapeTestCountFolds(oeisID: str) -> tuple[int, ...]:
|
|
|
238
238
|
|
|
239
239
|
"""
|
|
240
240
|
while True:
|
|
241
|
-
n = random.choice(
|
|
241
|
+
n = random.choice(dictionaryOEIS[oeisID]['valuesTestValidation'])
|
|
242
242
|
if n < 2:
|
|
243
243
|
continue
|
|
244
|
-
listDimensionsCandidate = list(
|
|
244
|
+
listDimensionsCandidate = list(dictionaryOEIS[oeisID]['getMapShape'](n))
|
|
245
245
|
|
|
246
246
|
try:
|
|
247
247
|
return validateListDimensions(listDimensionsCandidate)
|
|
@@ -266,10 +266,10 @@ def mapShapeTestFunctionality(oeisID_1random: str) -> tuple[int, ...]:
|
|
|
266
266
|
|
|
267
267
|
"""
|
|
268
268
|
while True:
|
|
269
|
-
n = random.choice(
|
|
269
|
+
n = random.choice(dictionaryOEIS[oeisID_1random]['valuesTestValidation'])
|
|
270
270
|
if n < 2:
|
|
271
271
|
continue
|
|
272
|
-
listDimensionsCandidate = list(
|
|
272
|
+
listDimensionsCandidate = list(dictionaryOEIS[oeisID_1random]['getMapShape'](n))
|
|
273
273
|
|
|
274
274
|
try:
|
|
275
275
|
return validateListDimensions(listDimensionsCandidate)
|
|
@@ -291,8 +291,8 @@ def mapShapeTestParallelization(oeisID: str) -> tuple[int, ...]:
|
|
|
291
291
|
Map dimensions suitable for testing parallelization features.
|
|
292
292
|
|
|
293
293
|
"""
|
|
294
|
-
n = random.choice(
|
|
295
|
-
return
|
|
294
|
+
n = random.choice(dictionaryOEIS[oeisID]['valuesTestParallelization'])
|
|
295
|
+
return dictionaryOEIS[oeisID]['getMapShape'](n)
|
|
296
296
|
|
|
297
297
|
@pytest.fixture
|
|
298
298
|
def mockBenchmarkTimer() -> Generator[unittest.mock.MagicMock | unittest.mock.AsyncMock, Any, None]:
|
|
@@ -27,9 +27,9 @@ which is useful if you're working with the code synthesis features of the packag
|
|
|
27
27
|
|
|
28
28
|
from mapFolding import countFolds, getFoldsTotalKnown, oeisIDfor_n
|
|
29
29
|
from mapFolding.dataBaskets import MapFoldingState
|
|
30
|
-
from mapFolding.oeis import
|
|
31
|
-
from mapFolding.someAssemblyRequired.RecipeJob import RecipeJobTheorem2
|
|
30
|
+
from mapFolding.oeis import dictionaryOEIS
|
|
32
31
|
from mapFolding.someAssemblyRequired.makeAllModules import parametersNumbaLight
|
|
32
|
+
from mapFolding.someAssemblyRequired.RecipeJob import RecipeJobTheorem2
|
|
33
33
|
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds
|
|
34
34
|
from mapFolding.tests.conftest import registrarRecordsTemporaryFilesystemObject, standardizedEqualToCallableReturn
|
|
35
35
|
from pathlib import Path, PurePosixPath
|
|
@@ -83,8 +83,8 @@ def test_aOFn_calculate_value(oeisID: str) -> None:
|
|
|
83
83
|
The OEIS sequence identifier to test calculations for.
|
|
84
84
|
|
|
85
85
|
"""
|
|
86
|
-
for n in
|
|
87
|
-
standardizedEqualToCallableReturn(
|
|
86
|
+
for n in dictionaryOEIS[oeisID]['valuesTestValidation']:
|
|
87
|
+
standardizedEqualToCallableReturn(dictionaryOEIS[oeisID]['valuesKnown'][n], oeisIDfor_n, oeisID, n)
|
|
88
88
|
|
|
89
89
|
@pytest.mark.parametrize('pathFilename_tmpTesting', ['.py'], indirect=True)
|
|
90
90
|
def test_writeJobNumba(oneTestCuzTestsOverwritingTests: tuple[int, ...], pathFilename_tmpTesting: Path) -> None:
|