mapFolding 0.15.3__py3-none-any.whl → 0.16.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/__init__.py +22 -20
- mapFolding/_theSSOT.py +56 -62
- mapFolding/_theTypes.py +66 -4
- mapFolding/algorithms/__init__.py +1 -0
- mapFolding/{daoOfMapFolding.py → algorithms/daoOfMapFolding.py} +1 -2
- mapFolding/algorithms/getBucketsTotal.py +137 -0
- mapFolding/algorithms/matrixMeanders.py +519 -0
- mapFolding/algorithms/oeisIDbyFormula.py +347 -0
- mapFolding/algorithms/zCuzDocStoopidoeisIDbyFormula.py +84 -0
- mapFolding/basecamp.py +151 -14
- mapFolding/dataBaskets.py +74 -0
- mapFolding/oeis.py +43 -56
- mapFolding/reference/A000682facts.py +662 -0
- mapFolding/reference/A005316facts.py +62 -0
- mapFolding/reference/matrixMeandersAnalysis/__init__.py +1 -0
- mapFolding/reference/matrixMeandersAnalysis/evenEven.py +144 -0
- mapFolding/reference/matrixMeandersAnalysis/oddEven.py +54 -0
- mapFolding/{_oeisFormulas/matrixMeanders64.py → reference/meandersDumpingGround/matrixMeanders64retired.py} +37 -29
- mapFolding/someAssemblyRequired/A007822/A007822rawMaterials.py +55 -0
- mapFolding/someAssemblyRequired/A007822/__init__.py +0 -0
- mapFolding/someAssemblyRequired/A007822/makeA007822AsynchronousModules.py +185 -0
- mapFolding/someAssemblyRequired/A007822/makeA007822Modules.py +71 -0
- mapFolding/someAssemblyRequired/RecipeJob.py +2 -2
- mapFolding/someAssemblyRequired/__init__.py +9 -2
- mapFolding/someAssemblyRequired/_toolIfThis.py +4 -3
- mapFolding/someAssemblyRequired/_toolkitContainers.py +8 -8
- mapFolding/someAssemblyRequired/infoBooth.py +27 -30
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +1 -1
- mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +5 -2
- mapFolding/someAssemblyRequired/makingModules_count.py +301 -0
- mapFolding/someAssemblyRequired/makingModules_doTheNeedful.py +120 -0
- mapFolding/someAssemblyRequired/mapFolding/__init__.py +0 -0
- mapFolding/someAssemblyRequired/mapFolding/makeMapFoldingModules.py +220 -0
- mapFolding/someAssemblyRequired/toolkitMakeModules.py +152 -0
- mapFolding/someAssemblyRequired/toolkitNumba.py +1 -1
- mapFolding/someAssemblyRequired/transformationTools.py +1 -0
- mapFolding/syntheticModules/A007822/__init__.py +1 -0
- mapFolding/syntheticModules/A007822/asynchronous.py +148 -0
- mapFolding/syntheticModules/A007822/asynchronousAnnex.py +68 -0
- mapFolding/syntheticModules/A007822/asynchronousTheorem2.py +53 -0
- mapFolding/syntheticModules/A007822/asynchronousTrimmed.py +47 -0
- mapFolding/syntheticModules/dataPackingA007822.py +1 -1
- mapFolding/tests/conftest.py +28 -9
- mapFolding/tests/test_computations.py +32 -10
- mapFolding/tests/test_oeis.py +2 -20
- mapFolding/trim_memory.py +62 -0
- mapFolding/zCuzDocStoopid/__init__.py +1 -0
- mapFolding/zCuzDocStoopid/makeDocstrings.py +63 -0
- {mapfolding-0.15.3.dist-info → mapfolding-0.16.0.dist-info}/METADATA +9 -2
- mapfolding-0.16.0.dist-info/RECORD +100 -0
- {mapfolding-0.15.3.dist-info → mapfolding-0.16.0.dist-info}/entry_points.txt +0 -1
- mapFolding/_oeisFormulas/A000136.py +0 -4
- mapFolding/_oeisFormulas/A000560.py +0 -4
- mapFolding/_oeisFormulas/A000682.py +0 -85
- mapFolding/_oeisFormulas/A001010.py +0 -19
- mapFolding/_oeisFormulas/A001011.py +0 -5
- mapFolding/_oeisFormulas/A005315.py +0 -4
- mapFolding/_oeisFormulas/A005316.py +0 -10
- mapFolding/_oeisFormulas/A223094.py +0 -7
- mapFolding/_oeisFormulas/A259702.py +0 -4
- mapFolding/_oeisFormulas/A301620.py +0 -6
- mapFolding/_oeisFormulas/Z0Z_aOFn.py +0 -34
- mapFolding/_oeisFormulas/Z0Z_notes.py +0 -16
- mapFolding/_oeisFormulas/Z0Z_oeisMeanders.py +0 -74
- mapFolding/_oeisFormulas/Z0Z_symmetry.py +0 -131
- mapFolding/_oeisFormulas/__init__.py +0 -1
- mapFolding/_oeisFormulas/matrixMeanders.py +0 -134
- mapFolding/_oeisFormulas/matrixMeandersAnnex.py +0 -84
- mapFolding/someAssemblyRequired/A007822rawMaterials.py +0 -46
- mapFolding/someAssemblyRequired/makeAllModules.py +0 -764
- mapfolding-0.15.3.dist-info/RECORD +0 -92
- /mapFolding/reference/{A005316JavaPort.py → meandersDumpingGround/A005316JavaPort.py} +0 -0
- /mapFolding/reference/{A005316imperative.py → meandersDumpingGround/A005316imperative.py} +0 -0
- /mapFolding/reference/{A005316intOptimized.py → meandersDumpingGround/A005316intOptimized.py} +0 -0
- /mapFolding/reference/{A005316optimized128bit.py → meandersDumpingGround/A005316optimized128bit.py} +0 -0
- /mapFolding/reference/{A005316primitiveOptimized.py → meandersDumpingGround/A005316primitiveOptimized.py} +0 -0
- /mapFolding/reference/{A005316redis.py → meandersDumpingGround/A005316redis.py} +0 -0
- /mapFolding/reference/{A005316write2disk.py → meandersDumpingGround/A005316write2disk.py} +0 -0
- /mapFolding/reference/{matrixMeandersBaseline.py → meandersDumpingGround/matrixMeandersBaseline.py} +0 -0
- /mapFolding/reference/{matrixMeandersBaselineAnnex.py → meandersDumpingGround/matrixMeandersBaselineAnnex.py} +0 -0
- /mapFolding/reference/{matrixMeandersBaselineV2.py → meandersDumpingGround/matrixMeandersBaselineV2.py} +0 -0
- /mapFolding/reference/{matrixMeandersSimpleQueue.py → meandersDumpingGround/matrixMeandersSimpleQueue.py} +0 -0
- /mapFolding/reference/{matrixMeandersSlicePop.py → meandersDumpingGround/matrixMeandersSlicePop.py} +0 -0
- /mapFolding/syntheticModules/{algorithmA007822.py → A007822/algorithm.py} +0 -0
- /mapFolding/syntheticModules/{algorithmA007822Numba.py → A007822/algorithmNumba.py} +0 -0
- /mapFolding/syntheticModules/{initializeStateA007822.py → A007822/initializeState.py} +0 -0
- /mapFolding/syntheticModules/{theorem2A007822.py → A007822/theorem2.py} +0 -0
- /mapFolding/syntheticModules/{theorem2A007822Numba.py → A007822/theorem2Numba.py} +0 -0
- /mapFolding/syntheticModules/{theorem2A007822Trimmed.py → A007822/theorem2Trimmed.py} +0 -0
- {mapfolding-0.15.3.dist-info → mapfolding-0.16.0.dist-info}/WHEEL +0 -0
- {mapfolding-0.15.3.dist-info → mapfolding-0.16.0.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.15.3.dist-info → mapfolding-0.16.0.dist-info}/top_level.txt +0 -0
mapFolding/dataBaskets.py
CHANGED
|
@@ -24,6 +24,7 @@ from mapFolding import (
|
|
|
24
24
|
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal,
|
|
25
25
|
getConnectionGraph, getLeavesTotal, makeDataContainer)
|
|
26
26
|
import dataclasses
|
|
27
|
+
import numpy
|
|
27
28
|
|
|
28
29
|
@dataclasses.dataclass
|
|
29
30
|
class MapFoldingState:
|
|
@@ -268,3 +269,76 @@ class LeafSequenceState(MapFoldingState):
|
|
|
268
269
|
if self.leafSequence is None: # pyright: ignore[reportUnnecessaryComparison]
|
|
269
270
|
self.leafSequence = makeDataContainer(groupsOfFoldsKnown, self.__dataclass_fields__['leafSequence'].metadata['dtype'])
|
|
270
271
|
self.leafSequence[self.groupsOfFolds] = self.leaf1ndex
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
@dataclasses.dataclass
|
|
275
|
+
class MatrixMeandersState:
|
|
276
|
+
"""State."""
|
|
277
|
+
|
|
278
|
+
n: int
|
|
279
|
+
oeisID: str
|
|
280
|
+
kOfMatrix: int
|
|
281
|
+
dictionaryCurveLocations: dict[int, int]
|
|
282
|
+
|
|
283
|
+
datatypeCurveLocations: type = numpy.uint64
|
|
284
|
+
datatypeDistinctCrossings: type = numpy.uint64
|
|
285
|
+
|
|
286
|
+
bitWidthCurveLocationsMaximum: int | None = None
|
|
287
|
+
bitWidthDistinctCrossingsMaximum: int | None = None
|
|
288
|
+
|
|
289
|
+
bitWidth: int = 0
|
|
290
|
+
indexStartAnalyzed: int = 0
|
|
291
|
+
|
|
292
|
+
def __post_init__(self) -> None:
|
|
293
|
+
"""Post init."""
|
|
294
|
+
if self.bitWidthCurveLocationsMaximum is None:
|
|
295
|
+
_bitWidthOfFixedSizeInteger: int = numpy.dtype(self.datatypeCurveLocations).itemsize * 8 # bits
|
|
296
|
+
|
|
297
|
+
_offsetNecessary: int = 3 # For example, `groupZulu << 3`.
|
|
298
|
+
_offsetSafety: int = 1 # I don't have mathematical proof of how many extra bits I need.
|
|
299
|
+
_offset: int = _offsetNecessary + _offsetSafety
|
|
300
|
+
|
|
301
|
+
self.bitWidthCurveLocationsMaximum = _bitWidthOfFixedSizeInteger - _offset
|
|
302
|
+
|
|
303
|
+
del _bitWidthOfFixedSizeInteger, _offsetNecessary, _offsetSafety, _offset
|
|
304
|
+
|
|
305
|
+
if self.bitWidthDistinctCrossingsMaximum is None:
|
|
306
|
+
_bitWidthOfFixedSizeInteger: int = numpy.dtype(self.datatypeDistinctCrossings).itemsize * 8 # bits
|
|
307
|
+
|
|
308
|
+
_offsetNecessary: int = 0 # I don't know of any.
|
|
309
|
+
_offsetEstimation: int = 3 # See reference directory.
|
|
310
|
+
_offsetSafety: int = 1
|
|
311
|
+
_offset: int = _offsetNecessary + _offsetEstimation + _offsetSafety
|
|
312
|
+
|
|
313
|
+
self.bitWidthDistinctCrossingsMaximum = _bitWidthOfFixedSizeInteger - _offset
|
|
314
|
+
|
|
315
|
+
del _bitWidthOfFixedSizeInteger, _offsetNecessary, _offsetEstimation, _offsetSafety, _offset
|
|
316
|
+
|
|
317
|
+
@property
|
|
318
|
+
def MAXIMUMcurveLocations(self) -> int:
|
|
319
|
+
"""Compute the maximum value of `curveLocations` for the current iteration of the transfer matrix."""
|
|
320
|
+
return 1 << (2 * self.kOfMatrix + 4)
|
|
321
|
+
|
|
322
|
+
@property
|
|
323
|
+
def locatorGroupAlpha(self) -> int:
|
|
324
|
+
"""Compute an odd-parity bit-mask with `bitWidth` bits.
|
|
325
|
+
|
|
326
|
+
Notes
|
|
327
|
+
-----
|
|
328
|
+
In binary, `locatorGroupAlpha` has alternating 0s and 1s and ends with a 1, such as '101', '0101', and '10101'. The last
|
|
329
|
+
digit is in the 1's column, but programmers usually call it the "least significant bit" (LSB). If we count the columns
|
|
330
|
+
from the right, the 1's column is column 1, the 2's column is column 2, the 4's column is column 3, and so on. When
|
|
331
|
+
counting this way, `locatorGroupAlpha` has 1s in the columns with odd index numbers. Mathematicians and programmers,
|
|
332
|
+
therefore, tend to call `locatorGroupAlpha` something like the "odd bit-mask", the "odd-parity numbers", or simply "odd
|
|
333
|
+
mask" or "odd numbers". In addition to "odd" being inherently ambiguous in this context, this algorithm also segregates
|
|
334
|
+
odd numbers from even numbers, so I avoid using "odd" and "even" in the names of these bit-masks.
|
|
335
|
+
|
|
336
|
+
"""
|
|
337
|
+
return sum(1 << one for one in range(0, self.bitWidth, 2))
|
|
338
|
+
|
|
339
|
+
@property
|
|
340
|
+
def locatorGroupZulu(self) -> int:
|
|
341
|
+
"""Compute an even-parity bit-mask with `bitWidth` bits."""
|
|
342
|
+
return sum(1 << one for one in range(1, self.bitWidth, 2))
|
|
343
|
+
|
|
344
|
+
|
mapFolding/oeis.py
CHANGED
|
@@ -24,41 +24,20 @@ redundant computation, or extending mathematical knowledge, this integration
|
|
|
24
24
|
completes the journey from configuration foundation to mathematical discovery.
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
|
-
from collections.abc import Callable
|
|
28
27
|
from datetime import datetime, timedelta, UTC
|
|
29
28
|
from hunterMakesPy import writeStringToHere
|
|
30
29
|
from itertools import chain
|
|
31
|
-
from mapFolding import countFolds
|
|
32
|
-
from mapFolding._theSSOT import
|
|
30
|
+
from mapFolding import countFolds, MetadataOEISidMapFolding, MetadataOEISidMeanders, packageSettings
|
|
31
|
+
from mapFolding._theSSOT import pathCache
|
|
33
32
|
from pathlib import Path
|
|
34
|
-
from typing import Final
|
|
33
|
+
from typing import Final
|
|
35
34
|
from urllib.request import urlopen
|
|
36
35
|
import argparse
|
|
37
36
|
import sys
|
|
38
37
|
import time
|
|
39
38
|
import warnings
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
"""Settings for an implemented OEIS sequence."""
|
|
43
|
-
|
|
44
|
-
description: str
|
|
45
|
-
"""The OEIS.org description of the integer sequence."""
|
|
46
|
-
getMapShape: Callable[[int], tuple[int, ...]]
|
|
47
|
-
"""Function to convert the OEIS sequence index, 'n', to its `mapShape` tuple."""
|
|
48
|
-
offset: int
|
|
49
|
-
"""The starting index, 'n', of the sequence, typically 0 or 1."""
|
|
50
|
-
valuesBenchmark: list[int]
|
|
51
|
-
"""List of index values, 'n', to use when benchmarking the algorithm performance."""
|
|
52
|
-
valuesKnown: dict[int, int]
|
|
53
|
-
"""Dictionary of sequence indices, 'n', to their known values, `foldsTotal`."""
|
|
54
|
-
valuesTestParallelization: list[int]
|
|
55
|
-
"""List of index values, 'n', to use when testing parallelization performance."""
|
|
56
|
-
valuesTestValidation: list[int]
|
|
57
|
-
"""List of index values, 'n', to use when testing validation performance."""
|
|
58
|
-
valueUnknown: int
|
|
59
|
-
"""The smallest value of 'n' for for which `foldsTotal` is unknown."""
|
|
60
|
-
|
|
61
|
-
oeisIDsImplemented: Final[list[str]] = sorted([oeisID.upper().strip() for oeisID in settingsOEISManuallySelected])
|
|
40
|
+
oeisIDsImplemented: Final[list[str]] = sorted([oeisID.upper().strip() for oeisID in packageSettings.OEISidMapFoldingManuallySet])
|
|
62
41
|
"""Directly implemented OEIS IDs; standardized, e.g., 'A001415'."""
|
|
63
42
|
|
|
64
43
|
def _standardizeOEISid(oeisID: str) -> str:
|
|
@@ -134,13 +113,7 @@ def _parseBFileOEIS(OEISbFile: str) -> dict[int, int]:
|
|
|
134
113
|
return OEISsequence
|
|
135
114
|
|
|
136
115
|
def _getOEISofficial(pathFilenameCache: Path, url: str) -> None | str:
|
|
137
|
-
"""Retrieve OEIS
|
|
138
|
-
|
|
139
|
-
(AI generated docstring)
|
|
140
|
-
|
|
141
|
-
This function implements a caching strategy that prioritizes local cached data when it exists and
|
|
142
|
-
has not expired. Fresh data is retrieved from the OEIS website when the cache is stale or missing,
|
|
143
|
-
and the cache is updated for future use.
|
|
116
|
+
"""Retrieve OEIS ID data from oeis.org or local cache.
|
|
144
117
|
|
|
145
118
|
Parameters
|
|
146
119
|
----------
|
|
@@ -154,16 +127,11 @@ def _getOEISofficial(pathFilenameCache: Path, url: str) -> None | str:
|
|
|
154
127
|
oeisInformation : str | None
|
|
155
128
|
The retrieved OEIS sequence information as a string, or `None` if retrieval failed.
|
|
156
129
|
|
|
157
|
-
Notes
|
|
158
|
-
-----
|
|
159
|
-
Cache expiration is controlled by the module-level `cacheDays` variable. The function validates
|
|
160
|
-
URL schemes and issues warnings for failed retrievals.
|
|
161
|
-
|
|
162
130
|
"""
|
|
163
131
|
tryCache: bool = False
|
|
164
132
|
if pathFilenameCache.exists():
|
|
165
133
|
fileAge: timedelta = datetime.now(tz=UTC) - datetime.fromtimestamp(pathFilenameCache.stat().st_mtime, tz=UTC)
|
|
166
|
-
tryCache = fileAge < timedelta(days=cacheDays)
|
|
134
|
+
tryCache = fileAge < timedelta(days=packageSettings.cacheDays)
|
|
167
135
|
|
|
168
136
|
oeisInformation: str | None = None
|
|
169
137
|
if tryCache:
|
|
@@ -176,7 +144,8 @@ def _getOEISofficial(pathFilenameCache: Path, url: str) -> None | str:
|
|
|
176
144
|
if not url.startswith(("http:", "https:")):
|
|
177
145
|
message = "URL must start with 'http:' or 'https:'"
|
|
178
146
|
raise ValueError(message)
|
|
179
|
-
|
|
147
|
+
|
|
148
|
+
with urlopen(url) as response: # noqa: S310
|
|
180
149
|
oeisInformationRaw = response.read().decode('utf-8')
|
|
181
150
|
oeisInformation = str(oeisInformationRaw)
|
|
182
151
|
writeStringToHere(oeisInformation, pathFilenameCache)
|
|
@@ -279,7 +248,7 @@ def getOEISidInformation(oeisID: str) -> tuple[str, int]:
|
|
|
279
248
|
description: str = ' '.join(listDescriptionDeconstructed)
|
|
280
249
|
return description, offset
|
|
281
250
|
|
|
282
|
-
def _makeDictionaryOEIS() -> dict[str,
|
|
251
|
+
def _makeDictionaryOEIS() -> dict[str, MetadataOEISidMapFolding]:
|
|
283
252
|
"""Construct the comprehensive settings dictionary for all implemented OEIS sequences.
|
|
284
253
|
|
|
285
254
|
(AI generated docstring)
|
|
@@ -302,23 +271,23 @@ def _makeDictionaryOEIS() -> dict[str, MetadataOEISid]:
|
|
|
302
271
|
objects, containing all metadata and known values needed for computation and validation.
|
|
303
272
|
|
|
304
273
|
"""
|
|
305
|
-
dictionaryOEIS: dict[str,
|
|
274
|
+
dictionaryOEIS: dict[str, MetadataOEISidMapFolding] = {}
|
|
306
275
|
for oeisID in oeisIDsImplemented:
|
|
307
276
|
valuesKnownSherpa: dict[int, int] = getOEISidValues(oeisID)
|
|
308
277
|
descriptionSherpa, offsetSherpa = getOEISidInformation(oeisID)
|
|
309
|
-
dictionaryOEIS[oeisID] =
|
|
278
|
+
dictionaryOEIS[oeisID] = MetadataOEISidMapFolding(
|
|
310
279
|
description=descriptionSherpa,
|
|
311
280
|
offset=offsetSherpa,
|
|
312
|
-
getMapShape=
|
|
313
|
-
valuesBenchmark=
|
|
314
|
-
valuesTestParallelization=
|
|
315
|
-
valuesTestValidation=
|
|
281
|
+
getMapShape=packageSettings.OEISidMapFoldingManuallySet[oeisID]['getMapShape'],
|
|
282
|
+
valuesBenchmark=packageSettings.OEISidMapFoldingManuallySet[oeisID]['valuesBenchmark'],
|
|
283
|
+
valuesTestParallelization=packageSettings.OEISidMapFoldingManuallySet[oeisID]['valuesTestParallelization'],
|
|
284
|
+
valuesTestValidation=packageSettings.OEISidMapFoldingManuallySet[oeisID]['valuesTestValidation'] + list(range(offsetSherpa, 2)),
|
|
316
285
|
valuesKnown=valuesKnownSherpa,
|
|
317
286
|
valueUnknown=max(valuesKnownSherpa.keys(), default=0) + 1
|
|
318
287
|
)
|
|
319
288
|
return dictionaryOEIS
|
|
320
289
|
|
|
321
|
-
|
|
290
|
+
dictionaryOEISMapFolding: dict[str, MetadataOEISidMapFolding] = _makeDictionaryOEIS()
|
|
322
291
|
"""Metadata for each OEIS sequence ID."""
|
|
323
292
|
|
|
324
293
|
def makeDictionaryFoldsTotalKnown() -> dict[tuple[int, ...], int]:
|
|
@@ -332,7 +301,7 @@ def makeDictionaryFoldsTotalKnown() -> dict[tuple[int, ...], int]:
|
|
|
332
301
|
|
|
333
302
|
"""
|
|
334
303
|
return dict(chain.from_iterable(zip(map(oeisIDmetadata['getMapShape'], oeisIDmetadata['valuesKnown'].keys())
|
|
335
|
-
, oeisIDmetadata['valuesKnown'].values(), strict=True) for oeisID, oeisIDmetadata in
|
|
304
|
+
, oeisIDmetadata['valuesKnown'].values(), strict=True) for oeisID, oeisIDmetadata in dictionaryOEISMapFolding.items() if oeisID != 'A007822'))
|
|
336
305
|
|
|
337
306
|
def getFoldsTotalKnown(mapShape: tuple[int, ...]) -> int:
|
|
338
307
|
"""Retrieve the known total number of distinct folding patterns for a given map shape.
|
|
@@ -378,7 +347,7 @@ def _formatHelpText() -> str:
|
|
|
378
347
|
|
|
379
348
|
"""
|
|
380
349
|
exampleOEISid: str = oeisIDsImplemented[0]
|
|
381
|
-
exampleN: int =
|
|
350
|
+
exampleN: int = dictionaryOEISMapFolding[exampleOEISid]['valuesTestValidation'][-1]
|
|
382
351
|
|
|
383
352
|
return (
|
|
384
353
|
"\nAvailable OEIS sequences:\n"
|
|
@@ -406,7 +375,7 @@ def _formatOEISsequenceInfo() -> str:
|
|
|
406
375
|
|
|
407
376
|
"""
|
|
408
377
|
return "\n".join(
|
|
409
|
-
f" {oeisID}: {
|
|
378
|
+
f" {oeisID}: {dictionaryOEISMapFolding[oeisID]['description']}"
|
|
410
379
|
for oeisID in oeisIDsImplemented
|
|
411
380
|
)
|
|
412
381
|
|
|
@@ -441,17 +410,18 @@ def oeisIDfor_n(oeisID: str, n: int) -> int:
|
|
|
441
410
|
message = f"I received `{n = }` in the form of `{type(n) = }`, but it must be non-negative integer in the form of `{int}`."
|
|
442
411
|
raise ValueError(message)
|
|
443
412
|
|
|
444
|
-
mapShape =
|
|
413
|
+
mapShape = dictionaryOEISMapFolding[oeisID]['getMapShape'](n)
|
|
445
414
|
|
|
446
415
|
if n <= 1 or len(mapShape) < 2:
|
|
447
|
-
offset: int =
|
|
416
|
+
offset: int = dictionaryOEISMapFolding[oeisID]['offset']
|
|
448
417
|
if n < offset:
|
|
449
418
|
message = f"OEIS sequence {oeisID} is not defined at {n = }."
|
|
450
419
|
raise ArithmeticError(message)
|
|
451
|
-
foldsTotal: int =
|
|
452
|
-
|
|
420
|
+
foldsTotal: int = dictionaryOEISMapFolding[oeisID]['valuesKnown'][n]
|
|
421
|
+
else:
|
|
422
|
+
foldsTotal = countFolds(oeisID=oeisID, oeis_n=n)
|
|
453
423
|
|
|
454
|
-
return
|
|
424
|
+
return foldsTotal
|
|
455
425
|
|
|
456
426
|
def OEIS_for_n() -> None:
|
|
457
427
|
"""Command-line interface for calculating OEIS sequence values.
|
|
@@ -513,7 +483,7 @@ def clearOEIScache() -> None:
|
|
|
513
483
|
if not pathCache.exists():
|
|
514
484
|
print(f"Cache directory, {pathCache}, not found - nothing to clear.") # noqa: T201
|
|
515
485
|
return
|
|
516
|
-
for oeisID in
|
|
486
|
+
for oeisID in dictionaryOEISMapFolding:
|
|
517
487
|
( pathCache / f"{oeisID}.txt" ).unlink(missing_ok=True)
|
|
518
488
|
( pathCache / _getFilenameOEISbFile(oeisID) ).unlink(missing_ok=True)
|
|
519
489
|
print(f"Cache cleared from {pathCache}") # noqa: T201
|
|
@@ -534,5 +504,22 @@ def getOEISids() -> None:
|
|
|
534
504
|
"""
|
|
535
505
|
print(_formatHelpText()) # noqa: T201
|
|
536
506
|
|
|
507
|
+
def _makeDictionaryOEISMeanders() -> dict[str, MetadataOEISidMeanders]:
|
|
508
|
+
dictionary: dict[str, MetadataOEISidMeanders] = {}
|
|
509
|
+
for oeisID in packageSettings.OEISidMeandersManuallySet:
|
|
510
|
+
valuesKnownSherpa: dict[int, int] = getOEISidValues(oeisID)
|
|
511
|
+
descriptionSherpa, offsetSherpa = getOEISidInformation(oeisID)
|
|
512
|
+
dictionary[oeisID] = MetadataOEISidMeanders(
|
|
513
|
+
description=descriptionSherpa,
|
|
514
|
+
offset=offsetSherpa,
|
|
515
|
+
valuesKnown=valuesKnownSherpa,
|
|
516
|
+
valuesTestValidation=packageSettings.OEISidMeandersManuallySet[oeisID]['valuesTestValidation'],
|
|
517
|
+
valueUnknown=max(valuesKnownSherpa.keys(), default=0) + 1,
|
|
518
|
+
)
|
|
519
|
+
return dictionary
|
|
520
|
+
|
|
521
|
+
dictionaryOEISMeanders: dict[str, MetadataOEISidMeanders] = _makeDictionaryOEISMeanders()
|
|
522
|
+
|
|
537
523
|
if __name__ == "__main__":
|
|
538
524
|
getOEISids()
|
|
525
|
+
|