mapFolding 0.16.1__tar.gz → 0.16.2__tar.gz
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-0.16.1/mapFolding.egg-info → mapfolding-0.16.2}/PKG-INFO +1 -1
- {mapfolding-0.16.1 → mapfolding-0.16.2}/easyRun/A000682.py +1 -1
- {mapfolding-0.16.1 → mapfolding-0.16.2}/easyRun/A005316.py +2 -3
- {mapfolding-0.16.1 → mapfolding-0.16.2}/easyRun/NOTcountingFolds.py +3 -3
- {mapfolding-0.16.1 → mapfolding-0.16.2}/easyRun/meanders.py +17 -19
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/algorithms/matrixMeanders.py +15 -28
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/algorithms/matrixMeandersBeDry.py +34 -116
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/algorithms/matrixMeandersNumPy.py +117 -70
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/algorithms/matrixMeandersPandas.py +113 -130
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/algorithms/oeisIDbyFormula.py +23 -12
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/algorithms/zCuzDocStoopidoeisIDbyFormula.py +26 -12
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/basecamp.py +140 -242
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/dataBaskets.py +14 -30
- mapfolding-0.16.2/mapFolding/reference/A000682facts.py +797 -0
- mapfolding-0.16.2/mapFolding/reference/A005316facts.py +1020 -0
- mapfolding-0.16.2/mapFolding/reference/matrixMeandersAnalysis/signatures.py +2030 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/A007822/A007822rawMaterials.py +2 -2
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/A007822/makeA007822AsynchronousModules.py +83 -21
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/A007822/makeA007822Modules.py +13 -12
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +2 -2
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/makingModules_count.py +88 -80
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/makingModules_doTheNeedful.py +11 -7
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/mapFolding/makeMapFoldingModules.py +3 -3
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/meanders/makeMeandersModules.py +7 -8
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/toolkitMakeModules.py +9 -9
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/transformationTools.py +8 -8
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/A007822/algorithm.py +1 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/A007822/asynchronous.py +6 -4
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/A007822/asynchronousAnnex.py +1 -1
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/A007822/asynchronousAnnexNumba.py +2 -17
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/A007822/asynchronousNumba.py +35 -8
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/A007822/asynchronousTheorem2.py +15 -3
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/A007822/asynchronousTrimmed.py +12 -3
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/A007822/theorem2.py +6 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/A007822/theorem2Numba.py +28 -3
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/A007822/theorem2Trimmed.py +7 -1
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/daoOfMapFoldingNumba.py +2 -4
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/dataPacking.py +3 -5
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/meanders/bigInt.py +24 -34
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/theorem2.py +6 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/theorem2Numba.py +9 -4
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/theorem2Trimmed.py +6 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/tests/test_computations.py +1 -1
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/zCuzDocStoopid/makeDocstrings.py +2 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2/mapFolding.egg-info}/PKG-INFO +1 -1
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding.egg-info/SOURCES.txt +1 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/pyproject.toml +1 -1
- mapfolding-0.16.1/mapFolding/reference/A000682facts.py +0 -1276
- mapfolding-0.16.1/mapFolding/reference/A005316facts.py +0 -985
- {mapfolding-0.16.1 → mapfolding-0.16.2}/LICENSE +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/README.md +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/easyRun/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/easyRun/countFolds.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/_dataPacking.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/_theSSOT.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/_theTypes.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/algorithms/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/algorithms/daoOfMapFolding.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/beDRY.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/filesystemToolkit.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/oeis.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/py.typed +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/flattened.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/hunterNumba.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/irvineJavaPort.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/jaxCount.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/jobsCompleted/[2x19]/p2x19.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/jobsCompleted/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/jobsCompleted/p2x19/p2x19.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/lunnonNumpy.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/lunnonWhile.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/matrixMeandersAnalysis/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/matrixMeandersAnalysis/prefixNotationNotes.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/A005316JavaPort.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/A005316imperative.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/A005316intOptimized.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/A005316optimized128bit.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/A005316primitiveOptimized.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/A005316redis.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/A005316write2disk.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/matrixMeanders64retired.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/matrixMeandersBaseline.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/matrixMeandersBaselineAnnex.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/matrixMeandersBaselineV2.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/matrixMeandersNumPyV1finalForm.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/matrixMeandersSimpleQueue.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/meandersDumpingGround/matrixMeandersSlicePop.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/rotatedEntryPoint.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/A007822/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/RecipeJob.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/_toolIfThis.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/_toolkitContainers.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/getLLVMforNoReason.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/infoBooth.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/mapFolding/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/meanders/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/someAssemblyRequired/toolkitNumba.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/A007822/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/A007822/algorithmNumba.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/A007822/initializeState.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/countParallelNumba.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/dataPackingA007822.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/initializeState.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/syntheticModules/meanders/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/tests/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/tests/conftest.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/tests/test_filesystem.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/tests/test_oeis.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/tests/test_other.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/tests/test_tasks.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding/zCuzDocStoopid/__init__.py +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding.egg-info/dependency_links.txt +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding.egg-info/entry_points.txt +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding.egg-info/requires.txt +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/mapFolding.egg-info/top_level.txt +0 -0
- {mapfolding-0.16.1 → mapfolding-0.16.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mapFolding
|
|
3
|
-
Version: 0.16.
|
|
3
|
+
Version: 0.16.2
|
|
4
4
|
Summary: Map folding, meanders, stamp folding, semi-meanders. Experiment with algorithm transformations, and analyze computational states.
|
|
5
5
|
Author-email: Hunter Hogan <HunterHogan@pm.me>
|
|
6
6
|
License: CC-BY-NC-4.0
|
|
@@ -21,5 +21,5 @@ if __name__ == "__main__":
|
|
|
21
21
|
|
|
22
22
|
r"""
|
|
23
23
|
deactivate && C:\apps\mapFolding\.vtail\Scripts\activate.bat && title good && cls
|
|
24
|
-
title running && py
|
|
24
|
+
title running && start "running" /B /HIGH /wait py -X faulthandler=0 -X tracemalloc=0 -X frozen_modules=on easyRun\A000682.py && title I'm done || title Error
|
|
25
25
|
"""
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# ruff: noqa
|
|
2
2
|
# pyright: basic
|
|
3
|
-
from mapFolding.basecamp import
|
|
3
|
+
from mapFolding.basecamp import NOTcountingFolds
|
|
4
4
|
import warnings
|
|
5
5
|
|
|
6
6
|
warnings.filterwarnings("ignore", category=FutureWarning)
|
|
7
7
|
|
|
8
8
|
n=25
|
|
9
|
-
print(A005316
|
|
9
|
+
print(NOTcountingFolds('A005316', n))
|
|
10
10
|
|
|
11
11
|
from mapFolding import dictionaryOEIS
|
|
12
12
|
|
|
@@ -16,6 +16,5 @@ if n < dictionaryOEIS['A005316']['valueUnknown']:
|
|
|
16
16
|
|
|
17
17
|
r"""
|
|
18
18
|
deactivate && C:\apps\mapFolding\.vtail\Scripts\activate.bat && title good && cls
|
|
19
|
-
title running && py Z0Z_A005316.py && title I'm done || title Error
|
|
20
19
|
|
|
21
20
|
"""
|
|
@@ -22,13 +22,13 @@ if __name__ == '__main__':
|
|
|
22
22
|
|
|
23
23
|
oeisID = 'A007822'
|
|
24
24
|
|
|
25
|
-
flow = 'asynchronousTrimmed'
|
|
26
25
|
flow = 'asynchronous'
|
|
27
|
-
flow = 'asynchronousNumba'
|
|
28
26
|
flow = 'algorithm'
|
|
27
|
+
flow = 'asynchronousNumba'
|
|
29
28
|
flow = 'theorem2Numba'
|
|
29
|
+
flow = 'asynchronousTrimmed'
|
|
30
30
|
|
|
31
|
-
for n in range(
|
|
31
|
+
for n in range(3,9):
|
|
32
32
|
|
|
33
33
|
timeStart = time.perf_counter()
|
|
34
34
|
countTotal = NOTcountingFolds(oeisID, n, flow, CPUlimit)
|
|
@@ -24,38 +24,36 @@ if __name__ == '__main__':
|
|
|
24
24
|
if sys.version_info >= (3, 14):
|
|
25
25
|
warnings.filterwarnings("ignore", category=FutureWarning)
|
|
26
26
|
|
|
27
|
-
flow = 'matrixPandas'
|
|
28
27
|
flow = 'matrixMeanders'
|
|
28
|
+
flow = 'matrixPandas'
|
|
29
29
|
flow = 'matrixNumPy'
|
|
30
30
|
|
|
31
31
|
for oeisID in [
|
|
32
|
-
'A005316',
|
|
32
|
+
# 'A005316',
|
|
33
33
|
'A000682',
|
|
34
34
|
]:
|
|
35
35
|
sys.stdout.write(f"\n{oeisID}\n")
|
|
36
36
|
|
|
37
37
|
"""TODO Identifiers. improve
|
|
38
|
-
|
|
38
|
+
"generate up to four targets."
|
|
39
|
+
1. Adding a new loop.
|
|
40
|
+
2. Dragging up a loop end.
|
|
41
|
+
3. Dragging down a loop end.
|
|
42
|
+
4. Connect ends across the line.
|
|
39
43
|
|
|
40
|
-
ReidemeisterMove?
|
|
41
44
|
flipTheExtra_0b1AsUfunc: what is extra?
|
|
42
|
-
|
|
43
|
-
"strand" is an interesting word.
|
|
44
45
|
"""
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
# for n in range(28,33):
|
|
55
|
-
# for n in range(2, 28):
|
|
56
|
-
# for n in range(2, 10):
|
|
57
|
-
for n in range(1, 6):
|
|
47
|
+
nList: list[int] = []
|
|
48
|
+
nList.extend(range(2, 10))
|
|
49
|
+
# nList.extend(range(2, 28))
|
|
50
|
+
nList.extend(range(28,33))
|
|
51
|
+
# nList.extend(range(33,38))
|
|
52
|
+
# nList.extend(range(38,43))
|
|
53
|
+
# nList.extend(range(43,45))
|
|
54
|
+
# nList.extend(range(47,57))
|
|
58
55
|
|
|
56
|
+
for n in nList:
|
|
59
57
|
gc.collect()
|
|
60
58
|
timeStart = time.perf_counter()
|
|
61
59
|
countTotal = NOTcountingFolds(oeisID, n, flow)
|
|
@@ -66,6 +64,6 @@ if __name__ == '__main__':
|
|
|
66
64
|
|
|
67
65
|
r"""
|
|
68
66
|
deactivate && C:\apps\mapFolding\.vtail\Scripts\activate.bat && title good && cls
|
|
69
|
-
title running && py
|
|
67
|
+
title running && start "meanders" /B /HIGH /wait py -X faulthandler=0 -X tracemalloc=0 -X frozen_modules=on easyRun\meanders.py && title I'm done || title Error
|
|
70
68
|
|
|
71
69
|
"""
|
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
from mapFolding.algorithms.matrixMeandersBeDry import walkDyckPath
|
|
2
2
|
from mapFolding.dataBaskets import MatrixMeandersState
|
|
3
3
|
|
|
4
|
-
def outfitDictionaryBitGroups(state: MatrixMeandersState) -> dict[tuple[int, int], int]:
|
|
5
|
-
"""Outfit `dictionaryBitGroups` so it may manage the computations for one iteration of the transfer matrix.
|
|
6
|
-
|
|
7
|
-
Parameters
|
|
8
|
-
----------
|
|
9
|
-
state : MatrixMeandersState
|
|
10
|
-
The current state of the computation, including `dictionaryMeanders`.
|
|
11
|
-
|
|
12
|
-
Returns
|
|
13
|
-
-------
|
|
14
|
-
dictionaryBitGroups : dict[tuple[int, int], int]
|
|
15
|
-
A dictionary of `(bitsAlpha, bitsZulu)` to `crossings`.
|
|
16
|
-
"""
|
|
17
|
-
state.bitWidth = max(state.dictionaryMeanders.keys()).bit_length()
|
|
18
|
-
return {(arcCode & state.locatorBits, (arcCode >> 1) & state.locatorBits): crossings
|
|
19
|
-
for arcCode, crossings in state.dictionaryMeanders.items()}
|
|
20
|
-
|
|
21
4
|
def count(state: MatrixMeandersState) -> MatrixMeandersState:
|
|
22
5
|
"""Count meanders with matrix transfer algorithm using Python `int` (*int*eger) contained in a Python `dict` (*dict*ionary).
|
|
23
6
|
|
|
@@ -31,18 +14,22 @@ def count(state: MatrixMeandersState) -> MatrixMeandersState:
|
|
|
31
14
|
The matrix transfer algorithm is sophisticated, but this implementation is straightforward: compute each index one at a time,
|
|
32
15
|
compute each `arcCode` one at a time, and compute each type of analysis one at a time.
|
|
33
16
|
"""
|
|
34
|
-
|
|
17
|
+
dictionaryArcCodeToCrossings: dict[int, int] = {}
|
|
35
18
|
|
|
36
|
-
while state.
|
|
37
|
-
state.
|
|
19
|
+
while state.boundary > 0:
|
|
20
|
+
state.boundary -= 1
|
|
21
|
+
state.bitWidth = max(state.dictionaryMeanders.keys()).bit_length()
|
|
38
22
|
|
|
39
|
-
|
|
23
|
+
dictionaryArcCodeToCrossings = state.dictionaryMeanders.copy()
|
|
40
24
|
state.dictionaryMeanders = {}
|
|
41
25
|
|
|
42
|
-
for
|
|
26
|
+
for arcCode, crossings in dictionaryArcCodeToCrossings.items():
|
|
27
|
+
bitsAlpha: int = arcCode & state.locatorBits
|
|
28
|
+
bitsZulu: int = (arcCode >> 1) & state.locatorBits
|
|
43
29
|
bitsAlphaHasArcs: bool = bitsAlpha > 1
|
|
44
30
|
bitsZuluHasArcs: bool = bitsZulu > 1
|
|
45
|
-
bitsAlphaIsEven =
|
|
31
|
+
bitsAlphaIsEven: int = bitsAlpha & 1 ^ 1
|
|
32
|
+
bitsZuluIsEven: int = bitsZulu & 1 ^ 1
|
|
46
33
|
|
|
47
34
|
arcCodeAnalysis = ((bitsAlpha | (bitsZulu << 1)) << 2) | 3
|
|
48
35
|
# simple
|
|
@@ -50,27 +37,27 @@ def count(state: MatrixMeandersState) -> MatrixMeandersState:
|
|
|
50
37
|
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
51
38
|
|
|
52
39
|
if bitsAlphaHasArcs:
|
|
53
|
-
arcCodeAnalysis = (bitsAlpha >> 2) | (bitsZulu << 3) | (
|
|
40
|
+
arcCodeAnalysis = (bitsAlpha >> 2) | (bitsZulu << 3) | (bitsAlphaIsEven << 1)
|
|
54
41
|
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
55
42
|
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
56
43
|
|
|
57
44
|
if bitsZuluHasArcs:
|
|
58
|
-
arcCodeAnalysis = (bitsZulu >> 1) | (bitsAlpha << 2) |
|
|
45
|
+
arcCodeAnalysis = (bitsZulu >> 1) | (bitsAlpha << 2) | bitsZuluIsEven
|
|
59
46
|
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
60
47
|
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
61
48
|
|
|
62
49
|
if bitsAlphaHasArcs and bitsZuluHasArcs and (bitsAlphaIsEven or bitsZuluIsEven):
|
|
63
50
|
# aligned
|
|
64
51
|
if bitsAlphaIsEven and not bitsZuluIsEven:
|
|
65
|
-
bitsAlpha ^= walkDyckPath(bitsAlpha)
|
|
52
|
+
bitsAlpha ^= walkDyckPath(bitsAlpha)
|
|
66
53
|
elif bitsZuluIsEven and not bitsAlphaIsEven:
|
|
67
|
-
bitsZulu ^= walkDyckPath(bitsZulu)
|
|
54
|
+
bitsZulu ^= walkDyckPath(bitsZulu)
|
|
68
55
|
|
|
69
56
|
arcCodeAnalysis: int = ((bitsZulu >> 2) << 1) | (bitsAlpha >> 2)
|
|
70
57
|
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
71
58
|
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
72
59
|
|
|
73
|
-
|
|
60
|
+
dictionaryArcCodeToCrossings = {}
|
|
74
61
|
|
|
75
62
|
return state
|
|
76
63
|
|
|
@@ -2,12 +2,8 @@
|
|
|
2
2
|
from functools import cache
|
|
3
3
|
from hunterMakesPy import raiseIfNone
|
|
4
4
|
from mapFolding.dataBaskets import MatrixMeandersNumPyState
|
|
5
|
-
from mapFolding.reference.A000682facts import
|
|
6
|
-
from mapFolding.reference.A005316facts import
|
|
7
|
-
A005316_n_k_buckets, bucketsIf_k_EVEN_by_nLess_k, bucketsIf_k_ODD_by_nLess_k)
|
|
8
|
-
from math import exp, log
|
|
9
|
-
from typing import Any, NamedTuple
|
|
10
|
-
import math
|
|
5
|
+
from mapFolding.reference.A000682facts import A000682_n_boundary_buckets
|
|
6
|
+
from mapFolding.reference.A005316facts import A005316_n_boundary_buckets
|
|
11
7
|
import numpy
|
|
12
8
|
import pandas
|
|
13
9
|
|
|
@@ -22,14 +18,7 @@ import pandas
|
|
|
22
18
|
- Convert duplicate code to procedures.
|
|
23
19
|
"""
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
"""keys for dictionaries."""
|
|
27
|
-
|
|
28
|
-
oeisID: str
|
|
29
|
-
kIsOdd: bool
|
|
30
|
-
nLess_kIsOdd: bool
|
|
31
|
-
|
|
32
|
-
def areIntegersWide(state: MatrixMeandersNumPyState, *, dataframe: pandas.DataFrame | None = None, array: numpy.ndarray[tuple[int, ...], numpy.dtype[numpy.integer[Any]]] | None = None, fixedSizeMAXIMUMarcCode: bool = False) -> bool:
|
|
21
|
+
def areIntegersWide(state: MatrixMeandersNumPyState, *, dataframe: pandas.DataFrame | None = None, fixedSizeMAXIMUMarcCode: bool = False) -> bool:
|
|
33
22
|
"""Check if the largest values are wider than the maximum limits.
|
|
34
23
|
|
|
35
24
|
Parameters
|
|
@@ -58,19 +47,16 @@ def areIntegersWide(state: MatrixMeandersNumPyState, *, dataframe: pandas.DataFr
|
|
|
58
47
|
|
|
59
48
|
If you start with small values in `dictionaryMeanders`, however, then the flow goes to the function with fixed size
|
|
60
49
|
integers and usually stays there until `crossings` is huge, which is near the end of the computation. If you cast
|
|
61
|
-
`MAXIMUMarcCode` into a 64-bit unsigned integer, however, then around `state.
|
|
50
|
+
`MAXIMUMarcCode` into a 64-bit unsigned integer, however, then around `state.boundary == 28`, the bit width of
|
|
62
51
|
`MAXIMUMarcCode` might exceed the limit. That will cause the flow to go to the function that does not have fixed size
|
|
63
52
|
integers for a few iterations before returning to the function with fixed size integers.
|
|
64
53
|
"""
|
|
65
54
|
if dataframe is not None:
|
|
66
55
|
arcCodeWidest = int(dataframe['analyzed'].max()).bit_length()
|
|
67
56
|
crossingsWidest = int(dataframe['crossings'].max()).bit_length()
|
|
68
|
-
elif array is not None:
|
|
69
|
-
arcCodeWidest = int(array[state.slicerArcCode].max()).bit_length()
|
|
70
|
-
crossingsWidest = int(array[state.slicerCrossings].max()).bit_length()
|
|
71
57
|
elif not state.dictionaryMeanders:
|
|
72
|
-
arcCodeWidest = int(state.
|
|
73
|
-
crossingsWidest = int(state.
|
|
58
|
+
arcCodeWidest = int(state.arrayArcCodes.max()).bit_length()
|
|
59
|
+
crossingsWidest = int(state.arrayCrossings.max()).bit_length()
|
|
74
60
|
else:
|
|
75
61
|
arcCodeWidest: int = max(state.dictionaryMeanders.keys()).bit_length()
|
|
76
62
|
crossingsWidest: int = max(state.dictionaryMeanders.values()).bit_length()
|
|
@@ -106,8 +92,14 @@ arrayFlipped : numpy.ndarray[tuple[int], numpy.dtype[numpy.unsignedinteger[Any]]
|
|
|
106
92
|
An array with the same shape as `arrayTarget` but with one bit flipped in each element.
|
|
107
93
|
"""
|
|
108
94
|
|
|
109
|
-
def getBucketsTotal(state: MatrixMeandersNumPyState, safetyMultiplicand: float = 1.2) -> int:
|
|
110
|
-
"""Estimate the total number of non-unique arcCode that will be computed from the existing arcCode.
|
|
95
|
+
def getBucketsTotal(state: MatrixMeandersNumPyState, safetyMultiplicand: float = 1.2) -> int: # noqa: ARG001
|
|
96
|
+
"""Under renovation: Estimate the total number of non-unique arcCode that will be computed from the existing arcCode.
|
|
97
|
+
|
|
98
|
+
Warning
|
|
99
|
+
-------
|
|
100
|
+
Because `matrixMeandersPandas` does not store anything in `state.arrayArcCodes`, if `matrixMeandersPandas` requests
|
|
101
|
+
bucketsTotal for a value not in the dictionary, the returned value will be 0. But `matrixMeandersPandas` should have a safety
|
|
102
|
+
check that will allocate more space.
|
|
111
103
|
|
|
112
104
|
Notes
|
|
113
105
|
-----
|
|
@@ -117,7 +109,7 @@ def getBucketsTotal(state: MatrixMeandersNumPyState, safetyMultiplicand: float =
|
|
|
117
109
|
- The starting quantity of `arcCode`.
|
|
118
110
|
- The value(s) of the starting `arcCode`.
|
|
119
111
|
- n
|
|
120
|
-
-
|
|
112
|
+
- boundary
|
|
121
113
|
- Whether this bucketsTotal is increasing, as compared to all of the prior bucketsTotal.
|
|
122
114
|
- If increasing, is it exponential or logarithmic?
|
|
123
115
|
- The maximum value.
|
|
@@ -126,104 +118,29 @@ def getBucketsTotal(state: MatrixMeandersNumPyState, safetyMultiplicand: float =
|
|
|
126
118
|
|
|
127
119
|
Figure out an intelligent flow for so many factors.
|
|
128
120
|
"""
|
|
129
|
-
theDictionary: dict[str, dict[int, dict[int, int]]] = {'A005316':
|
|
130
|
-
bucketsTotal: int = theDictionary.get(state.oeisID, {}).get(state.n, {}).get(state.
|
|
131
|
-
if bucketsTotal
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
dictionaryExponentialCoefficients: dict[ImaKey, float] = {
|
|
135
|
-
(ImaKey(oeisID='', kIsOdd=False, nLess_kIsOdd=True)): 0.834,
|
|
136
|
-
(ImaKey(oeisID='', kIsOdd=False, nLess_kIsOdd=False)): 1.5803,
|
|
137
|
-
(ImaKey(oeisID='', kIsOdd=True, nLess_kIsOdd=True)): 1.556,
|
|
138
|
-
(ImaKey(oeisID='', kIsOdd=True, nLess_kIsOdd=False)): 1.8047,
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
logarithmicOffsets: dict[ImaKey, float] ={
|
|
142
|
-
(ImaKey('A000682', kIsOdd=False, nLess_kIsOdd=False)): 0.0,
|
|
143
|
-
|
|
144
|
-
(ImaKey('A000682', kIsOdd=False, nLess_kIsOdd=True)): -0.07302547148212568,
|
|
145
|
-
(ImaKey('A000682', kIsOdd=True, nLess_kIsOdd=False)): -0.00595307513938792,
|
|
146
|
-
(ImaKey('A000682', kIsOdd=True, nLess_kIsOdd=True)): -0.012201222865243722,
|
|
147
|
-
(ImaKey('A005316', kIsOdd=False, nLess_kIsOdd=False)): -0.6392728422078733,
|
|
148
|
-
(ImaKey('A005316', kIsOdd=False, nLess_kIsOdd=True)): -0.6904925299923548,
|
|
149
|
-
(ImaKey('A005316', kIsOdd=True, nLess_kIsOdd=False)): 0.0,
|
|
150
|
-
(ImaKey('A005316', kIsOdd=True, nLess_kIsOdd=True)): 0.0,
|
|
151
|
-
}
|
|
121
|
+
theDictionary: dict[str, dict[int, dict[int, int]]] = {'A005316': A005316_n_boundary_buckets, 'A000682': A000682_n_boundary_buckets}
|
|
122
|
+
bucketsTotal: int = theDictionary.get(state.oeisID, {}).get(state.n, {}).get(state.boundary, 0)
|
|
123
|
+
if bucketsTotal <= 0:
|
|
124
|
+
bucketsTotal = int(3.55 * len(state.arrayArcCodes))
|
|
152
125
|
|
|
153
|
-
|
|
154
|
-
'intercept': -166.1750299793178,
|
|
155
|
-
'log(n)': 1259.0051001675547,
|
|
156
|
-
'log(k)': -396.4306071056408,
|
|
157
|
-
'log(nLess_k)': -854.3309503739766,
|
|
158
|
-
'k/n': 716.530410654819,
|
|
159
|
-
'(k/n)^2': -2527.035113444166,
|
|
160
|
-
'normalized k': -882.7054406339189,
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
bucketsTotalMaximumBy_kOfMatrix: dict[int, int] = {1:3, 2:12, 3:40, 4:125, 5:392, 6:1254, 7:4087, 8:13623, 9:46181, 10:159137, 11:555469, 12:1961369, 13:6991893, 14:25134208}
|
|
164
|
-
|
|
165
|
-
xCommon = 1.57
|
|
166
|
-
|
|
167
|
-
nLess_k: int = state.n - state.kOfMatrix
|
|
168
|
-
kIsOdd: bool = bool(state.kOfMatrix & 1)
|
|
169
|
-
nLess_kIsOdd: bool = bool(nLess_k & 1)
|
|
170
|
-
kIsEven: bool = not kIsOdd
|
|
171
|
-
|
|
172
|
-
bucketsTotalAtMaximum: bool = state.kOfMatrix <= ((state.n - 1 - (state.kOfMatrix % 2)) // 3)
|
|
173
|
-
bucketsTotalGrowsExponentially: bool = state.kOfMatrix > nLess_k
|
|
174
|
-
bucketsTotalGrowsLogarithmically: bool = state.kOfMatrix > ((state.n - (state.n % 3)) // 3)
|
|
175
|
-
|
|
176
|
-
if bucketsTotalAtMaximum:
|
|
177
|
-
if state.kOfMatrix in bucketsTotalMaximumBy_kOfMatrix:
|
|
178
|
-
bucketsTotal = bucketsTotalMaximumBy_kOfMatrix[state.kOfMatrix]
|
|
179
|
-
else:
|
|
180
|
-
c = 0.95037
|
|
181
|
-
r = 3.3591258254
|
|
182
|
-
if kIsOdd:
|
|
183
|
-
c = 0.92444
|
|
184
|
-
r = 3.35776
|
|
185
|
-
bucketsTotal = int(c * r**state.kOfMatrix * safetyMultiplicand)
|
|
186
|
-
|
|
187
|
-
elif state.kOfMatrix <= max(bucketsTotalMaximumBy_kOfMatrix.keys()):
|
|
188
|
-
# If `kOfMatrix` is low, use maximum bucketsTotal. 1. Can't underestimate. 2. Skip computation that can underestimate.
|
|
189
|
-
# 3. The potential difference in memory use is relatively small.
|
|
190
|
-
bucketsTotal = bucketsTotalMaximumBy_kOfMatrix[state.kOfMatrix]
|
|
126
|
+
return bucketsTotal
|
|
191
127
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
# If I already know bucketsTotal.
|
|
195
|
-
bucketsTotal = bucketsIf_k_ODD_by_nLess_k[nLess_k]
|
|
196
|
-
elif (state.oeisID == 'A005316') and kIsEven and (nLess_k in bucketsIf_k_EVEN_by_nLess_k):
|
|
197
|
-
# If I already know bucketsTotal.
|
|
198
|
-
bucketsTotal = bucketsIf_k_EVEN_by_nLess_k[nLess_k]
|
|
199
|
-
else: # I estimate bucketsTotal during exponential growth.
|
|
200
|
-
xInstant: int = math.ceil(nLess_k / 2)
|
|
201
|
-
A000682adjustStartingArcCode: float = 0.25
|
|
202
|
-
startingConditionsCoefficient: float = dictionaryExponentialCoefficients[ImaKey('', kIsOdd, nLess_kIsOdd)]
|
|
203
|
-
if kIsOdd and nLess_kIsOdd:
|
|
204
|
-
A000682adjustStartingArcCode = 0.0
|
|
205
|
-
if state.oeisID == 'A000682': # NOTE Net effect is between `*= n` and `*= n * 2.2` if n=46.
|
|
206
|
-
startingConditionsCoefficient *= state.n * (((state.n // 2) + 2) ** A000682adjustStartingArcCode)
|
|
207
|
-
bucketsTotal = int(startingConditionsCoefficient * math.exp(xCommon * xInstant))
|
|
128
|
+
def getSignaturesTotal(state: MatrixMeandersNumPyState) -> int:
|
|
129
|
+
"""Get the total number of signatures for the current `n` and `boundary`.
|
|
208
130
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
+ logarithmicParameters['log(k)'] * log(state.kOfMatrix)
|
|
214
|
-
+ logarithmicParameters['log(nLess_k)'] * log(nLess_k)
|
|
215
|
-
+ logarithmicParameters['k/n'] * (state.kOfMatrix / state.n)
|
|
216
|
-
+ logarithmicParameters['(k/n)^2'] * (state.kOfMatrix / state.n)**2
|
|
217
|
-
+ logarithmicParameters['normalized k'] * nLess_k / state.n
|
|
218
|
-
+ logarithmicOffsets[ImaKey(state.oeisID, kIsOdd, nLess_kIsOdd)]
|
|
219
|
-
)
|
|
131
|
+
Parameters
|
|
132
|
+
----------
|
|
133
|
+
state : MatrixMeandersState
|
|
134
|
+
The current state of the computation.
|
|
220
135
|
|
|
221
|
-
|
|
136
|
+
Returns
|
|
137
|
+
-------
|
|
138
|
+
signaturesTotal : int
|
|
139
|
+
The total number of signatures for the current `n` and `boundary`.
|
|
222
140
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return bucketsTotal
|
|
141
|
+
"""
|
|
142
|
+
from mapFolding.reference.matrixMeandersAnalysis.signatures import signatures # noqa: PLC0415
|
|
143
|
+
return signatures[state.oeisID].get(state.n, {}).get(state.boundary, int(3.55 * len(state.arrayArcCodes)))
|
|
227
144
|
|
|
228
145
|
@cache
|
|
229
146
|
def walkDyckPath(intWithExtra_0b1: int) -> int:
|
|
@@ -262,3 +179,4 @@ def walkDyckPath(intWithExtra_0b1: int) -> int:
|
|
|
262
179
|
if findTheExtra_0b1 < 0:
|
|
263
180
|
break
|
|
264
181
|
return flipExtra_0b1_Here
|
|
182
|
+
|