mapFolding 0.8.5__py3-none-any.whl → 0.8.6__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 +6 -5
- mapFolding/oeis.py +38 -23
- mapFolding/someAssemblyRequired/_tool_Make.py +5 -4
- mapFolding/someAssemblyRequired/_toolboxContainers.py +57 -8
- mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +49 -11
- mapFolding/someAssemblyRequired/toolboxNumba.py +16 -10
- mapFolding/someAssemblyRequired/transformationTools.py +13 -5
- mapFolding/syntheticModules/numbaCount_doTheNeedful.py +0 -1
- mapFolding/theSSOT.py +0 -1
- {mapfolding-0.8.5.dist-info → mapfolding-0.8.6.dist-info}/METADATA +1 -1
- {mapfolding-0.8.5.dist-info → mapfolding-0.8.6.dist-info}/RECORD +17 -18
- tests/test_computations.py +1 -1
- tests/test_tasks.py +1 -1
- mapFolding/noHomeYet.py +0 -32
- {mapfolding-0.8.5.dist-info → mapfolding-0.8.6.dist-info}/WHEEL +0 -0
- {mapfolding-0.8.5.dist-info → mapfolding-0.8.6.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.8.5.dist-info → mapfolding-0.8.6.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.8.5.dist-info → mapfolding-0.8.6.dist-info}/top_level.txt +0 -0
mapFolding/__init__.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"""
|
|
2
|
-
Map folding enumeration and counting algorithms with optimization capabilities.
|
|
2
|
+
Map folding enumeration and counting algorithms with advanced optimization capabilities.
|
|
3
3
|
|
|
4
|
-
This package implements algorithms to count and enumerate the
|
|
4
|
+
This package implements algorithms to count and enumerate the distinct ways
|
|
5
5
|
a rectangular map can be folded, based on the mathematical problem described
|
|
6
6
|
in Lunnon's 1971 paper. It provides multiple layers of functionality, from
|
|
7
|
-
high-level user interfaces to
|
|
7
|
+
high-level user interfaces to sophisticated algorithmic optimizations and code
|
|
8
8
|
transformation tools.
|
|
9
9
|
|
|
10
10
|
Core modules:
|
|
@@ -29,9 +29,10 @@ Special directories:
|
|
|
29
29
|
- reference/jobsCompleted/: Contains successful computations for previously unknown values,
|
|
30
30
|
including first-ever calculations for 2x19 and 2x20 maps (OEIS A001415)
|
|
31
31
|
|
|
32
|
-
This package
|
|
32
|
+
This package balances algorithm readability and understandability with
|
|
33
33
|
high-performance computation capabilities, allowing users to compute map folding
|
|
34
|
-
totals for larger dimensions than previously feasible
|
|
34
|
+
totals for larger dimensions than previously feasible while also providing
|
|
35
|
+
a foundation for exploring advanced code transformation techniques.
|
|
35
36
|
"""
|
|
36
37
|
from mapFolding.basecamp import countFolds
|
|
37
38
|
from mapFolding.oeis import clearOEIScache, getOEISids, OEIS_for_n, oeisIDfor_n
|
mapFolding/oeis.py
CHANGED
|
@@ -2,26 +2,31 @@
|
|
|
2
2
|
Interface to The Online Encyclopedia of Integer Sequences (OEIS) for map folding sequences.
|
|
3
3
|
|
|
4
4
|
This module provides a comprehensive interface for accessing and utilizing integer sequences
|
|
5
|
-
from the OEIS that relate to map folding problems. It
|
|
5
|
+
from the OEIS that relate to map folding problems. It serves as the bridge between
|
|
6
|
+
mathematical sequence definitions and the computational algorithm, implementing:
|
|
6
7
|
|
|
7
|
-
1.
|
|
8
|
-
2.
|
|
9
|
-
3.
|
|
10
|
-
4.
|
|
8
|
+
1. Retrieval of sequence data from OEIS with local caching for performance optimization.
|
|
9
|
+
2. Mapping of sequence indices to corresponding map shapes based on sequence definitions.
|
|
10
|
+
3. Command-line and programmatic interfaces for sequence lookups and validation.
|
|
11
|
+
4. Computation of sequence terms not available in the OEIS database.
|
|
11
12
|
|
|
12
13
|
The module maintains a registry of implemented OEIS sequences (A001415-A001418, A195646)
|
|
13
|
-
with their metadata, known values, and functions
|
|
14
|
+
with their metadata, known values, and conversion functions between sequence indices and
|
|
14
15
|
map dimensions. This allows the package to validate results against established mathematical
|
|
15
|
-
literature
|
|
16
|
+
literature while also extending sequences beyond their currently known terms.
|
|
17
|
+
|
|
18
|
+
Each sequence is carefully mapped to its corresponding map folding problem, enabling
|
|
19
|
+
seamless integration between the mathematical definition in OEIS and the computational
|
|
20
|
+
implementation in the package.
|
|
16
21
|
"""
|
|
17
22
|
from collections.abc import Callable
|
|
18
23
|
from datetime import datetime, timedelta
|
|
24
|
+
from functools import cache
|
|
19
25
|
from mapFolding.theSSOT import The
|
|
20
26
|
from mapFolding.toolboxFilesystem import writeStringToHere
|
|
21
27
|
from pathlib import Path
|
|
22
28
|
from typing import Any, Final, TYPE_CHECKING
|
|
23
29
|
import argparse
|
|
24
|
-
import pathlib
|
|
25
30
|
import random
|
|
26
31
|
import sys
|
|
27
32
|
import time
|
|
@@ -36,9 +41,6 @@ else:
|
|
|
36
41
|
|
|
37
42
|
cacheDays = 30
|
|
38
43
|
|
|
39
|
-
"""
|
|
40
|
-
Section: make `settingsOEIS`"""
|
|
41
|
-
|
|
42
44
|
pathCache: Path = The.pathPackage / ".cache"
|
|
43
45
|
|
|
44
46
|
class SettingsOEIS(TypedDict):
|
|
@@ -159,7 +161,7 @@ def _parseBFileOEIS(OEISbFile: str, oeisID: str) -> dict[int, int]:
|
|
|
159
161
|
OEISsequence[n] = aOFn
|
|
160
162
|
return OEISsequence
|
|
161
163
|
|
|
162
|
-
def getOEISofficial(pathFilenameCache:
|
|
164
|
+
def getOEISofficial(pathFilenameCache: Path, url: str) -> None | str:
|
|
163
165
|
tryCache: bool = False
|
|
164
166
|
if pathFilenameCache.exists():
|
|
165
167
|
fileAge: timedelta = datetime.now() - datetime.fromtimestamp(pathFilenameCache.stat().st_mtime)
|
|
@@ -186,6 +188,7 @@ def getOEISidValues(oeisID: str) -> dict[int, int]:
|
|
|
186
188
|
"""
|
|
187
189
|
Retrieves the specified OEIS sequence as a dictionary mapping integer indices
|
|
188
190
|
to their corresponding values.
|
|
191
|
+
|
|
189
192
|
This function checks for a cached local copy of the sequence data, using it if
|
|
190
193
|
it has not expired. Otherwise, it fetches the sequence data from the OEIS
|
|
191
194
|
website and writes it to the cache. The parsed data is returned as a dictionary
|
|
@@ -195,7 +198,7 @@ def getOEISidValues(oeisID: str) -> dict[int, int]:
|
|
|
195
198
|
oeisID: The identifier of the OEIS sequence to retrieve.
|
|
196
199
|
Returns:
|
|
197
200
|
OEISsequence: A dictionary where each key is an integer index, `n`, and each
|
|
198
|
-
value is the corresponding
|
|
201
|
+
value is the corresponding `a(n)` from the OEIS entry.
|
|
199
202
|
Raises:
|
|
200
203
|
ValueError: If the cached or downloaded file format is invalid.
|
|
201
204
|
IOError: If there is an error reading from or writing to the local cache.
|
|
@@ -259,8 +262,23 @@ def makeSettingsOEIS() -> dict[str, SettingsOEIS]:
|
|
|
259
262
|
settingsOEIS: dict[str, SettingsOEIS] = makeSettingsOEIS()
|
|
260
263
|
"""All values and settings for `oeisIDsImplemented`."""
|
|
261
264
|
|
|
262
|
-
|
|
263
|
-
|
|
265
|
+
@cache
|
|
266
|
+
def makeDictionaryFoldsTotalKnown() -> dict[tuple[int, ...], int]:
|
|
267
|
+
"""Returns a dictionary mapping dimension tuples to their known folding totals."""
|
|
268
|
+
dictionaryMapDimensionsToFoldsTotalKnown: dict[tuple[int, ...], int] = {}
|
|
269
|
+
|
|
270
|
+
for settings in settingsOEIS.values():
|
|
271
|
+
sequence = settings['valuesKnown']
|
|
272
|
+
|
|
273
|
+
for n, foldingsTotal in sequence.items():
|
|
274
|
+
mapShape = settings['getMapShape'](n)
|
|
275
|
+
mapShape = tuple(sorted(mapShape))
|
|
276
|
+
dictionaryMapDimensionsToFoldsTotalKnown[mapShape] = foldingsTotal
|
|
277
|
+
return dictionaryMapDimensionsToFoldsTotalKnown
|
|
278
|
+
|
|
279
|
+
def getFoldsTotalKnown(mapShape: tuple[int, ...]) -> int:
|
|
280
|
+
lookupFoldsTotal = makeDictionaryFoldsTotalKnown()
|
|
281
|
+
return lookupFoldsTotal.get(tuple(mapShape), -1)
|
|
264
282
|
|
|
265
283
|
def _formatHelpText() -> str:
|
|
266
284
|
"""Format standardized help text for both CLI and interactive use."""
|
|
@@ -285,35 +303,32 @@ def _formatOEISsequenceInfo() -> str:
|
|
|
285
303
|
for oeisID in oeisIDsImplemented
|
|
286
304
|
)
|
|
287
305
|
|
|
288
|
-
"""
|
|
289
|
-
Section: public functions"""
|
|
290
|
-
|
|
291
306
|
def oeisIDfor_n(oeisID: str, n: int | Any) -> int:
|
|
292
307
|
"""
|
|
293
|
-
Calculate a(n) of a sequence from "The On-Line Encyclopedia of Integer Sequences" (OEIS).
|
|
308
|
+
Calculate `a(n)` of a sequence from "The On-Line Encyclopedia of Integer Sequences" (OEIS).
|
|
294
309
|
|
|
295
310
|
Parameters:
|
|
296
311
|
oeisID: The ID of the OEIS sequence.
|
|
297
312
|
n: A non-negative integer for which to calculate the sequence value.
|
|
298
313
|
|
|
299
314
|
Returns:
|
|
300
|
-
sequenceValue: a(n) of the OEIS sequence.
|
|
315
|
+
sequenceValue: `a(n)` of the OEIS sequence.
|
|
301
316
|
|
|
302
317
|
Raises:
|
|
303
|
-
ValueError: If n is negative.
|
|
318
|
+
ValueError: If `n` is negative.
|
|
304
319
|
KeyError: If the OEIS sequence ID is not directly implemented.
|
|
305
320
|
"""
|
|
306
321
|
oeisID = validateOEISid(oeisID)
|
|
307
322
|
|
|
308
323
|
if not isinstance(n, int) or n < 0:
|
|
309
|
-
raise ValueError("`n` must be non-negative integer
|
|
324
|
+
raise ValueError(f"I received `{n = }` in the form of `{type(n) = }`, but it must be non-negative integer in the form of `{int}`.")
|
|
310
325
|
|
|
311
326
|
mapShape: tuple[int, ...] = settingsOEIS[oeisID]['getMapShape'](n)
|
|
312
327
|
|
|
313
328
|
if n <= 1 or len(mapShape) < 2:
|
|
314
329
|
offset: int = settingsOEIS[oeisID]['offset']
|
|
315
330
|
if n < offset:
|
|
316
|
-
raise ArithmeticError(f"OEIS sequence {oeisID} is not defined at n=
|
|
331
|
+
raise ArithmeticError(f"OEIS sequence {oeisID} is not defined at {n = }.")
|
|
317
332
|
foldsTotal: int = settingsOEIS[oeisID]['valuesKnown'][n]
|
|
318
333
|
return foldsTotal
|
|
319
334
|
from mapFolding.basecamp import countFolds
|
|
@@ -6,6 +6,7 @@ from mapFolding.someAssemblyRequired import (
|
|
|
6
6
|
intORlist_ast_type_paramORstr_orNone,
|
|
7
7
|
intORstr_orNone,
|
|
8
8
|
list_ast_type_paramORstr_orNone,
|
|
9
|
+
str_nameDOTname,
|
|
9
10
|
)
|
|
10
11
|
from typing import Any
|
|
11
12
|
import ast
|
|
@@ -74,11 +75,11 @@ class Make:
|
|
|
74
75
|
def FunctionDef(name: ast_Identifier, argumentsSpecification:ast.arguments=ast.arguments(), body:list[ast.stmt]=[], decorator_list:list[ast.expr]=[], returns:ast.expr|None=None, **keywordArguments: intORlist_ast_type_paramORstr_orNone) -> ast.FunctionDef:
|
|
75
76
|
return ast.FunctionDef(name, argumentsSpecification, body, decorator_list, returns, **keywordArguments)
|
|
76
77
|
@staticmethod
|
|
77
|
-
def Import(
|
|
78
|
-
return ast.Import(names=[Make.alias(
|
|
78
|
+
def Import(moduleWithLogicalPath: str_nameDOTname, asname: ast_Identifier | None = None, **keywordArguments: int) -> ast.Import:
|
|
79
|
+
return ast.Import(names=[Make.alias(moduleWithLogicalPath, asname)], **keywordArguments)
|
|
79
80
|
@staticmethod
|
|
80
|
-
def ImportFrom(
|
|
81
|
-
return ast.ImportFrom(
|
|
81
|
+
def ImportFrom(moduleWithLogicalPath: str_nameDOTname, list_astAlias: list[ast.alias], **keywordArguments: int) -> ast.ImportFrom:
|
|
82
|
+
return ast.ImportFrom(moduleWithLogicalPath, list_astAlias, **keywordArguments)
|
|
82
83
|
@staticmethod
|
|
83
84
|
def keyword(keywordArgument: ast_Identifier, value: ast.expr, **keywordArguments: int) -> ast.keyword:
|
|
84
85
|
return ast.keyword(arg=keywordArgument, value=value, **keywordArguments)
|
|
@@ -10,6 +10,7 @@ from collections.abc import Sequence
|
|
|
10
10
|
from mapFolding.someAssemblyRequired import ImaAnnotationType, ast_Identifier, be, Make, parseLogicalPath2astModule, str_nameDOTname
|
|
11
11
|
from mapFolding.theSSOT import callableDispatcherHARDCODED, The
|
|
12
12
|
from pathlib import Path, PurePosixPath
|
|
13
|
+
from typing import Literal
|
|
13
14
|
from Z0Z_tools import updateExtendPolishDictionaryLists
|
|
14
15
|
import ast
|
|
15
16
|
import dataclasses
|
|
@@ -36,11 +37,45 @@ class LedgerOfImports:
|
|
|
36
37
|
for alias in astImport____.names:
|
|
37
38
|
self.dictionaryImportFrom[astImport____.module].append((alias.name, alias.asname))
|
|
38
39
|
|
|
39
|
-
def addImport_asStr(self,
|
|
40
|
-
self.listImport.append(
|
|
41
|
-
|
|
42
|
-
def addImportFrom_asStr(self,
|
|
43
|
-
|
|
40
|
+
def addImport_asStr(self, moduleWithLogicalPath: str_nameDOTname) -> None:
|
|
41
|
+
self.listImport.append(moduleWithLogicalPath)
|
|
42
|
+
|
|
43
|
+
# def addImportFrom_asStr(self, moduleWithLogicalPath: str_nameDOTname, name: ast_Identifier, asname: ast_Identifier | None = None) -> None:
|
|
44
|
+
# self.dictionaryImportFrom[moduleWithLogicalPath].append((name, asname))
|
|
45
|
+
|
|
46
|
+
def addImportFrom_asStr(self, moduleWithLogicalPath: str_nameDOTname, name: ast_Identifier, asname: ast_Identifier | None = None) -> None:
|
|
47
|
+
if moduleWithLogicalPath not in self.dictionaryImportFrom:
|
|
48
|
+
self.dictionaryImportFrom[moduleWithLogicalPath] = []
|
|
49
|
+
self.dictionaryImportFrom[moduleWithLogicalPath].append((name, asname))
|
|
50
|
+
|
|
51
|
+
def removeImportFromModule(self, moduleWithLogicalPath: str_nameDOTname) -> None:
|
|
52
|
+
self.removeImportFrom(moduleWithLogicalPath, None, None)
|
|
53
|
+
"""Remove all imports from a specific module."""
|
|
54
|
+
|
|
55
|
+
def removeImportFrom(self, moduleWithLogicalPath: str_nameDOTname, name: ast_Identifier | None, asname: ast_Identifier | None = None) -> None:
|
|
56
|
+
if moduleWithLogicalPath is None:
|
|
57
|
+
raise SyntaxError(f"I received `{moduleWithLogicalPath = }`, but it must be the name of a module.")
|
|
58
|
+
if moduleWithLogicalPath in self.dictionaryImportFrom:
|
|
59
|
+
"""
|
|
60
|
+
name, asname Meaning
|
|
61
|
+
ast_Identifier, ast_Identifier : remove exact matches
|
|
62
|
+
ast_Identifier, None : remove exact matches
|
|
63
|
+
None, ast_Identifier : remove all matches for asname and if entry_asname is None remove name == ast_Identifier
|
|
64
|
+
None, None : remove all matches for the module
|
|
65
|
+
"""
|
|
66
|
+
if name is None and asname is None:
|
|
67
|
+
# Remove all entries for the module
|
|
68
|
+
self.dictionaryImportFrom.pop(moduleWithLogicalPath)
|
|
69
|
+
else:
|
|
70
|
+
if name is None:
|
|
71
|
+
self.dictionaryImportFrom[moduleWithLogicalPath] = [(entry_name, entry_asname) for entry_name, entry_asname in self.dictionaryImportFrom[moduleWithLogicalPath]
|
|
72
|
+
if not (entry_asname == asname) and not (entry_asname is None and entry_name == asname)]
|
|
73
|
+
else:
|
|
74
|
+
# Remove exact matches for the module
|
|
75
|
+
self.dictionaryImportFrom[moduleWithLogicalPath] = [(entry_name, entry_asname) for entry_name, entry_asname in self.dictionaryImportFrom[moduleWithLogicalPath]
|
|
76
|
+
if not (entry_name == name and entry_asname == asname)]
|
|
77
|
+
if not self.dictionaryImportFrom[moduleWithLogicalPath]:
|
|
78
|
+
self.dictionaryImportFrom.pop(moduleWithLogicalPath)
|
|
44
79
|
|
|
45
80
|
def exportListModuleIdentifiers(self) -> list[ast_Identifier]:
|
|
46
81
|
listModuleIdentifiers: list[ast_Identifier] = list(self.dictionaryImportFrom.keys())
|
|
@@ -49,13 +84,14 @@ class LedgerOfImports:
|
|
|
49
84
|
|
|
50
85
|
def makeList_ast(self) -> list[ast.ImportFrom | ast.Import]:
|
|
51
86
|
listImportFrom: list[ast.ImportFrom] = []
|
|
52
|
-
for
|
|
87
|
+
for moduleWithLogicalPath, listOfNameTuples in sorted(self.dictionaryImportFrom.items()):
|
|
53
88
|
listOfNameTuples = sorted(list(set(listOfNameTuples)), key=lambda nameTuple: nameTuple[0])
|
|
54
89
|
list_alias: list[ast.alias] = []
|
|
55
90
|
for name, asname in listOfNameTuples:
|
|
56
91
|
list_alias.append(Make.alias(name, asname))
|
|
57
|
-
|
|
58
|
-
|
|
92
|
+
if list_alias:
|
|
93
|
+
listImportFrom.append(Make.ImportFrom(moduleWithLogicalPath, list_alias))
|
|
94
|
+
list_astImport: list[ast.Import] = [Make.Import(moduleWithLogicalPath) for moduleWithLogicalPath in sorted(set(self.listImport))]
|
|
59
95
|
return listImportFrom + list_astImport
|
|
60
96
|
|
|
61
97
|
def update(self, *fromLedger: 'LedgerOfImports') -> None:
|
|
@@ -158,6 +194,19 @@ class IngredientsModule:
|
|
|
158
194
|
else:
|
|
159
195
|
raise ValueError(f"I received `{type(allegedIngredientsFunction) = }`, but I can only accept `{IngredientsFunction}`.")
|
|
160
196
|
|
|
197
|
+
def removeImportFromModule(self, moduleWithLogicalPath: str_nameDOTname) -> None:
|
|
198
|
+
self.removeImportFrom(moduleWithLogicalPath, None, None)
|
|
199
|
+
"""Remove all imports from a specific module."""
|
|
200
|
+
|
|
201
|
+
def removeImportFrom(self, moduleWithLogicalPath: str_nameDOTname, name: ast_Identifier | None, asname: ast_Identifier | None = None) -> None:
|
|
202
|
+
"""
|
|
203
|
+
This method modifies all `LedgerOfImports` in this `IngredientsModule` and all `IngredientsFunction` in `listIngredientsFunctions`.
|
|
204
|
+
It is not a "blacklist", so the import from could be added after this modification.
|
|
205
|
+
"""
|
|
206
|
+
self.imports.removeImportFrom(moduleWithLogicalPath, name, asname)
|
|
207
|
+
for ingredientsFunction in self.listIngredientsFunctions:
|
|
208
|
+
ingredientsFunction.imports.removeImportFrom(moduleWithLogicalPath, name, asname)
|
|
209
|
+
|
|
161
210
|
@property
|
|
162
211
|
def list_astImportImportFrom(self) -> list[ast.Import | ast.ImportFrom]:
|
|
163
212
|
"""List of `ast.Import` and `ast.ImportFrom` statements."""
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"""Synthesize one file to compute `foldsTotal` of `mapShape`."""
|
|
2
2
|
from mapFolding.toolboxFilesystem import getPathFilenameFoldsTotal
|
|
3
|
-
from mapFolding.someAssemblyRequired import ast_Identifier, be, ifThis, Make, NodeChanger, Then, IngredientsFunction, IngredientsModule
|
|
3
|
+
from mapFolding.someAssemblyRequired import ast_Identifier, be, ifThis, Make, NodeChanger, Then, IngredientsFunction, IngredientsModule, LedgerOfImports
|
|
4
4
|
from mapFolding.someAssemblyRequired.toolboxNumba import RecipeJob, SpicesJobNumba, decorateCallableWithNumba
|
|
5
|
-
from mapFolding.someAssemblyRequired.transformationTools import astModuleToIngredientsFunction, write_astModule
|
|
5
|
+
from mapFolding.someAssemblyRequired.transformationTools import astModuleToIngredientsFunction, extractFunctionDef, write_astModule
|
|
6
6
|
from mapFolding.someAssemblyRequired.transformationTools import makeInitializedComputationState
|
|
7
|
-
from mapFolding.theSSOT import The
|
|
7
|
+
from mapFolding.theSSOT import The, raiseIfNoneGitHubIssueNumber3
|
|
8
|
+
from mapFolding.oeis import getFoldsTotalKnown
|
|
8
9
|
from typing import cast
|
|
9
10
|
from Z0Z_tools import autoDecodingRLE
|
|
10
11
|
from pathlib import PurePosixPath
|
|
@@ -27,7 +28,7 @@ if __name__ == '__main__':
|
|
|
27
28
|
with ProgressBar(total={job.foldsTotalEstimated}, update_interval=2) as statusUpdate:
|
|
28
29
|
{job.countCallable}(statusUpdate)
|
|
29
30
|
foldsTotal = statusUpdate.n * {job.state.leavesTotal}
|
|
30
|
-
print('
|
|
31
|
+
print('\\nmap {job.state.mapShape} =', foldsTotal)
|
|
31
32
|
writeStream = open('{job.pathFilenameFoldsTotal.as_posix()}', 'w')
|
|
32
33
|
writeStream.write(str(foldsTotal))
|
|
33
34
|
writeStream.close()
|
|
@@ -42,7 +43,7 @@ if __name__ == '__main__':
|
|
|
42
43
|
|
|
43
44
|
findThis = ifThis.isAugAssign_targetIs(ifThis.isName_Identifier(job.shatteredDataclass.countingVariableName.id))
|
|
44
45
|
doThat = Then.replaceWith(Make.Expr(Make.Call(Make.Attribute(Make.Name(spices.numbaProgressBarIdentifier),'update'),[Make.Constant(1)])))
|
|
45
|
-
countWithProgressBar = NodeChanger(findThis, doThat)
|
|
46
|
+
countWithProgressBar = NodeChanger(findThis, doThat) # type: ignore
|
|
46
47
|
countWithProgressBar.visit(ingredientsFunction.astFunctionDef)
|
|
47
48
|
|
|
48
49
|
ingredientsModule.appendLauncher(ast.parse(linesLaunch))
|
|
@@ -65,7 +66,6 @@ def move_arg2FunctionDefDOTbodyAndAssignInitialValues(ingredientsFunction: Ingre
|
|
|
65
66
|
case 'scalar':
|
|
66
67
|
ImaAnnAssign.value.args[0].value = int(job.state.__dict__[ast_arg.arg]) # type: ignore
|
|
67
68
|
case 'array':
|
|
68
|
-
# print(ast.dump(ImaAnnAssign))
|
|
69
69
|
dataAsStrRLE: str = autoDecodingRLE(job.state.__dict__[ast_arg.arg], addSpaces=True)
|
|
70
70
|
dataAs_astExpr: ast.expr = cast(ast.Expr, ast.parse(dataAsStrRLE).body[0]).value
|
|
71
71
|
ImaAnnAssign.value.args = [dataAs_astExpr] # type: ignore
|
|
@@ -89,7 +89,9 @@ def move_arg2FunctionDefDOTbodyAndAssignInitialValues(ingredientsFunction: Ingre
|
|
|
89
89
|
|
|
90
90
|
def makeJobNumba(job: RecipeJob, spices: SpicesJobNumba):
|
|
91
91
|
# get the raw ingredients: data and the algorithm
|
|
92
|
-
|
|
92
|
+
astFunctionDef = extractFunctionDef(job.source_astModule, job.countCallable)
|
|
93
|
+
if not astFunctionDef: raise raiseIfNoneGitHubIssueNumber3
|
|
94
|
+
ingredientsCount: IngredientsFunction = IngredientsFunction(astFunctionDef, LedgerOfImports())
|
|
93
95
|
|
|
94
96
|
# Change the return so you can dynamically determine which variables are not used
|
|
95
97
|
removeReturnStatement = NodeChanger(be.Return, Then.removeIt)
|
|
@@ -107,16 +109,51 @@ def makeJobNumba(job: RecipeJob, spices: SpicesJobNumba):
|
|
|
107
109
|
for identifier in list_IdentifiersStaticValues:
|
|
108
110
|
findThis = ifThis.isName_Identifier(identifier)
|
|
109
111
|
doThat = Then.replaceWith(Make.Constant(int(job.state.__dict__[identifier])))
|
|
110
|
-
NodeChanger(findThis, doThat).visit(ingredientsCount.astFunctionDef)
|
|
112
|
+
NodeChanger(findThis, doThat).visit(ingredientsCount.astFunctionDef) # type: ignore
|
|
111
113
|
|
|
112
114
|
# This launcher eliminates the use of one identifier, so run it now and you can dynamically determine which variables are not used
|
|
115
|
+
ingredientsModule = IngredientsModule()
|
|
113
116
|
if spices.useNumbaProgressBar:
|
|
114
|
-
ingredientsModule = IngredientsModule()
|
|
115
117
|
ingredientsModule, ingredientsCount = addLauncherNumbaProgress(ingredientsModule, ingredientsCount, job, spices)
|
|
116
118
|
spices.parametersNumba['nogil'] = True
|
|
117
119
|
|
|
118
120
|
ingredientsCount = move_arg2FunctionDefDOTbodyAndAssignInitialValues(ingredientsCount, job)
|
|
119
121
|
|
|
122
|
+
Z0Z_Identifier = 'DatatypeLeavesTotal'
|
|
123
|
+
Z0Z_type = 'uint8'
|
|
124
|
+
ingredientsModule.imports.addImportFrom_asStr('numba', Z0Z_type)
|
|
125
|
+
Z0Z_module = 'typing'
|
|
126
|
+
Z0Z_annotation = 'TypeAlias'
|
|
127
|
+
ingredientsModule.imports.addImportFrom_asStr(Z0Z_module, Z0Z_annotation)
|
|
128
|
+
Z0Z_statement = Make.AnnAssign(Make.Name(Z0Z_Identifier, ast.Store()), Make.Name(Z0Z_annotation), Make.Name(Z0Z_type))
|
|
129
|
+
ingredientsModule.appendPrologue(statement=Z0Z_statement)
|
|
130
|
+
|
|
131
|
+
Z0Z_Identifier = 'DatatypeElephino'
|
|
132
|
+
Z0Z_type = 'int16'
|
|
133
|
+
ingredientsModule.imports.addImportFrom_asStr('numba', Z0Z_type)
|
|
134
|
+
Z0Z_module = 'typing'
|
|
135
|
+
Z0Z_annotation = 'TypeAlias'
|
|
136
|
+
ingredientsModule.imports.addImportFrom_asStr(Z0Z_module, Z0Z_annotation)
|
|
137
|
+
Z0Z_statement = Make.AnnAssign(Make.Name(Z0Z_Identifier, ast.Store()), Make.Name(Z0Z_annotation), Make.Name(Z0Z_type))
|
|
138
|
+
ingredientsModule.appendPrologue(statement=Z0Z_statement)
|
|
139
|
+
|
|
140
|
+
ingredientsCount.imports.removeImportFromModule('mapFolding.theSSOT')
|
|
141
|
+
Z0Z_module = 'numpy'
|
|
142
|
+
Z0Z_asname = 'Array1DLeavesTotal'
|
|
143
|
+
ingredientsCount.imports.removeImportFrom(Z0Z_module, None, Z0Z_asname)
|
|
144
|
+
Z0Z_type_name = 'uint8'
|
|
145
|
+
ingredientsCount.imports.addImportFrom_asStr(Z0Z_module, Z0Z_type_name, Z0Z_asname)
|
|
146
|
+
Z0Z_asname = 'Array1DElephino'
|
|
147
|
+
ingredientsCount.imports.removeImportFrom(Z0Z_module, None, Z0Z_asname)
|
|
148
|
+
Z0Z_type_name = 'int16'
|
|
149
|
+
ingredientsCount.imports.addImportFrom_asStr(Z0Z_module, Z0Z_type_name, Z0Z_asname)
|
|
150
|
+
Z0Z_asname = 'Array3D'
|
|
151
|
+
ingredientsCount.imports.removeImportFrom(Z0Z_module, None, Z0Z_asname)
|
|
152
|
+
Z0Z_type_name = 'uint8'
|
|
153
|
+
ingredientsCount.imports.addImportFrom_asStr(Z0Z_module, Z0Z_type_name, Z0Z_asname)
|
|
154
|
+
|
|
155
|
+
from numpy import int16 as Array1DLeavesTotal, int16 as Array1DElephino, int16 as Array3D
|
|
156
|
+
|
|
120
157
|
ingredientsCount.astFunctionDef.decorator_list = [] # TODO low-priority, handle this more elegantly
|
|
121
158
|
# TODO when I add the function signature in numba style back to the decorator, the logic needs to handle `ProgressBarType:`
|
|
122
159
|
ingredientsCount = decorateCallableWithNumba(ingredientsCount, spices.parametersNumba)
|
|
@@ -149,10 +186,11 @@ def makeJobNumba(job: RecipeJob, spices: SpicesJobNumba):
|
|
|
149
186
|
"""
|
|
150
187
|
|
|
151
188
|
if __name__ == '__main__':
|
|
152
|
-
mapShape = (
|
|
189
|
+
mapShape = (6,6)
|
|
153
190
|
state = makeInitializedComputationState(mapShape)
|
|
191
|
+
foldsTotalEstimated = getFoldsTotalKnown(state.mapShape) // state.leavesTotal
|
|
154
192
|
pathModule = PurePosixPath(The.pathPackage, 'jobs')
|
|
155
193
|
pathFilenameFoldsTotal = PurePosixPath(getPathFilenameFoldsTotal(state.mapShape, pathModule))
|
|
156
|
-
aJob = RecipeJob(state, pathModule=pathModule, pathFilenameFoldsTotal=pathFilenameFoldsTotal)
|
|
194
|
+
aJob = RecipeJob(state, foldsTotalEstimated, pathModule=pathModule, pathFilenameFoldsTotal=pathFilenameFoldsTotal)
|
|
157
195
|
spices = SpicesJobNumba()
|
|
158
196
|
makeJobNumba(aJob, spices)
|
|
@@ -23,10 +23,11 @@ from collections.abc import Callable, Sequence
|
|
|
23
23
|
from mapFolding.toolboxFilesystem import getPathFilenameFoldsTotal, getPathRootJobDEFAULT
|
|
24
24
|
from mapFolding.someAssemblyRequired import IngredientsModule, LedgerOfImports, Make, NodeChanger, NodeTourist, RecipeSynthesizeFlow, Then, ast_Identifier, be, ifThis, parsePathFilename2astModule, str_nameDOTname, IngredientsFunction, ShatteredDataclass
|
|
25
25
|
from mapFolding.someAssemblyRequired.transformationTools import Z0Z_inlineThisFunctionWithTheseValues, Z0Z_lameFindReplace, Z0Z_makeDictionaryReplacementStatements, astModuleToIngredientsFunction, shatter_dataclassesDOTdataclass, write_astModule
|
|
26
|
-
from mapFolding.theSSOT import ComputationState
|
|
26
|
+
from mapFolding.theSSOT import ComputationState, DatatypeFoldsTotal as TheDatatypeFoldsTotal, DatatypeElephino as TheDatatypeElephino, DatatypeLeavesTotal as TheDatatypeLeavesTotal
|
|
27
|
+
|
|
27
28
|
from numba.core.compiler import CompilerBase as numbaCompilerBase
|
|
28
29
|
from pathlib import Path, PurePosixPath
|
|
29
|
-
from typing import Any, cast, Final, TYPE_CHECKING
|
|
30
|
+
from typing import Any, cast, Final, TYPE_CHECKING, TypeAlias
|
|
30
31
|
import ast
|
|
31
32
|
import dataclasses
|
|
32
33
|
|
|
@@ -78,8 +79,8 @@ parametersNumbaSuperJitParallel: Final[ParametersNumba] = { **parametersNumbaSup
|
|
|
78
79
|
"""Speed, no helmet, concurrency, no talking to non-jitted functions."""
|
|
79
80
|
parametersNumbaMinimum: Final[ParametersNumba] = { '_nrt': True, 'boundscheck': True, 'cache': True, 'error_model': 'numpy', 'fastmath': True, 'forceinline': False, 'inline': 'always', 'looplift': False, 'no_cfunc_wrapper': False, 'no_cpython_wrapper': False, 'nopython': False, 'forceobj': True, 'parallel': False, }
|
|
80
81
|
|
|
81
|
-
Z0Z_numbaDataTypeModule = 'numba'
|
|
82
|
-
Z0Z_decoratorCallable = 'jit'
|
|
82
|
+
Z0Z_numbaDataTypeModule: str_nameDOTname = 'numba'
|
|
83
|
+
Z0Z_decoratorCallable: ast_Identifier = 'jit'
|
|
83
84
|
|
|
84
85
|
def decorateCallableWithNumba(ingredientsFunction: IngredientsFunction, parametersNumba: ParametersNumba | None = None) -> IngredientsFunction:
|
|
85
86
|
def Z0Z_UnhandledDecorators(astCallable: ast.FunctionDef) -> ast.FunctionDef:
|
|
@@ -123,7 +124,6 @@ def decorateCallableWithNumba(ingredientsFunction: IngredientsFunction, paramete
|
|
|
123
124
|
|
|
124
125
|
list_arg4signature_or_function: list[ast.expr] = []
|
|
125
126
|
for parameter in ingredientsFunction.astFunctionDef.args.args:
|
|
126
|
-
# Efficient translation of Python scalar types to Numba types https://github.com/hunterhogan/mapFolding/issues/8
|
|
127
127
|
# For now, let Numba infer them.
|
|
128
128
|
continue
|
|
129
129
|
# signatureElement: ast.Subscript | ast.Name | None = makeSpecialSignatureForNumba(parameter)
|
|
@@ -142,8 +142,8 @@ def decorateCallableWithNumba(ingredientsFunction: IngredientsFunction, paramete
|
|
|
142
142
|
parametersNumba = parametersNumbaDefault
|
|
143
143
|
listDecoratorKeywords: list[ast.keyword] = [Make.keyword(parameterName, Make.Constant(parameterValue)) for parameterName, parameterValue in parametersNumba.items()]
|
|
144
144
|
|
|
145
|
-
decoratorModule
|
|
146
|
-
decoratorCallable
|
|
145
|
+
decoratorModule = Z0Z_numbaDataTypeModule
|
|
146
|
+
decoratorCallable = Z0Z_decoratorCallable
|
|
147
147
|
ingredientsFunction.imports.addImportFrom_asStr(decoratorModule, decoratorCallable)
|
|
148
148
|
# Leave this line in so that global edits will change it.
|
|
149
149
|
astDecorator: ast.Call = Make.Call(Make.Name(decoratorCallable), list_argsDecorator, listDecoratorKeywords)
|
|
@@ -197,6 +197,12 @@ class RecipeJob:
|
|
|
197
197
|
dataclassInstance: ast_Identifier | None = sourceDataclassInstance
|
|
198
198
|
logicalPathModuleDataclass: str_nameDOTname | None = sourceLogicalPathModuleDataclass
|
|
199
199
|
|
|
200
|
+
# ========================================
|
|
201
|
+
# Datatypes
|
|
202
|
+
DatatypeFoldsTotal: TypeAlias = TheDatatypeFoldsTotal
|
|
203
|
+
DatatypeElephino: TypeAlias = TheDatatypeElephino
|
|
204
|
+
DatatypeLeavesTotal: TypeAlias = TheDatatypeLeavesTotal
|
|
205
|
+
|
|
200
206
|
def _makePathFilename(self,
|
|
201
207
|
pathRoot: PurePosixPath | None = None,
|
|
202
208
|
logicalPathINFIX: str_nameDOTname | None = None,
|
|
@@ -225,13 +231,13 @@ class RecipeJob:
|
|
|
225
231
|
def __post_init__(self):
|
|
226
232
|
pathFilenameFoldsTotal = PurePosixPath(getPathFilenameFoldsTotal(self.state.mapShape))
|
|
227
233
|
|
|
228
|
-
if self.moduleIdentifier is None:
|
|
234
|
+
if self.moduleIdentifier is None: # type: ignore
|
|
229
235
|
self.moduleIdentifier = pathFilenameFoldsTotal.stem
|
|
230
236
|
|
|
231
|
-
if self.pathFilenameFoldsTotal is None:
|
|
237
|
+
if self.pathFilenameFoldsTotal is None: # type: ignore
|
|
232
238
|
self.pathFilenameFoldsTotal = pathFilenameFoldsTotal
|
|
233
239
|
|
|
234
|
-
if self.shatteredDataclass is None and self.logicalPathModuleDataclass and self.dataclassIdentifier and self.dataclassInstance:
|
|
240
|
+
if self.shatteredDataclass is None and self.logicalPathModuleDataclass and self.dataclassIdentifier and self.dataclassInstance: # type: ignore
|
|
235
241
|
self.shatteredDataclass = shatter_dataclassesDOTdataclass(self.logicalPathModuleDataclass, self.dataclassIdentifier, self.dataclassInstance)
|
|
236
242
|
|
|
237
243
|
# ========================================
|
|
@@ -219,14 +219,22 @@ class DeReConstructField2ast:
|
|
|
219
219
|
|
|
220
220
|
dtype = self.metadata.get('dtype', None)
|
|
221
221
|
if dtype:
|
|
222
|
+
moduleWithLogicalPath: str_nameDOTname = 'numpy'
|
|
223
|
+
annotation = 'ndarray'
|
|
224
|
+
self.ledger.addImportFrom_asStr(moduleWithLogicalPath, annotation)
|
|
222
225
|
constructor = 'array'
|
|
223
|
-
self.
|
|
224
|
-
|
|
225
|
-
|
|
226
|
+
self.ledger.addImportFrom_asStr(moduleWithLogicalPath, constructor)
|
|
227
|
+
dtypeIdentifier: ast_Identifier = dtype.__name__
|
|
228
|
+
dtype_asnameName: ast.Name = self.astAnnotation
|
|
229
|
+
# dtypeIdentifier_asname: ast_Identifier = moduleWithLogicalPath + '_' + dtypeIdentifier
|
|
230
|
+
self.ledger.addImportFrom_asStr(moduleWithLogicalPath, dtypeIdentifier, dtype_asnameName.id)
|
|
231
|
+
self.astAnnAssignConstructor = Make.AnnAssign(self.astName, Make.Name(annotation), Make.Call(Make.Name(constructor), list_astKeywords=[Make.keyword('dtype', dtype_asnameName)]))
|
|
232
|
+
# self.astAnnAssignConstructor = Make.AnnAssign(self.astName, Make.Name(annotation), Make.Call(Make.Name(constructor), list_astKeywords=[Make.keyword('dtype', Make.Name(dtypeIdentifier_asname))]))
|
|
233
|
+
# self.astAnnAssignConstructor = Make.AnnAssign(self.astName, self.astAnnotation, Make.Call(Make.Name(constructor), list_astKeywords=[Make.keyword('dtype', Make.Name(dtypeIdentifier_asname))]))
|
|
226
234
|
self.Z0Z_hack = (self.astAnnAssignConstructor, 'array')
|
|
227
235
|
elif be.Name(self.astAnnotation):
|
|
228
236
|
self.astAnnAssignConstructor = Make.AnnAssign(self.astName, self.astAnnotation, Make.Call(self.astAnnotation, [Make.Constant(-1)]))
|
|
229
|
-
self.ledger.addImportFrom_asStr(dataclassesDOTdataclassLogicalPathModule, self.astAnnotation.id)
|
|
237
|
+
# self.ledger.addImportFrom_asStr(dataclassesDOTdataclassLogicalPathModule, self.astAnnotation.id)
|
|
230
238
|
self.Z0Z_hack = (self.astAnnAssignConstructor, 'scalar')
|
|
231
239
|
elif be.Subscript(self.astAnnotation):
|
|
232
240
|
elementConstructor: ast_Identifier = self.metadata['elementConstructor']
|
|
@@ -289,7 +297,7 @@ def write_astModule(ingredients: IngredientsModule, pathFilename: PathLike[Any]
|
|
|
289
297
|
autoflake_additional_imports: list[str] = ingredients.imports.exportListModuleIdentifiers()
|
|
290
298
|
if packageName:
|
|
291
299
|
autoflake_additional_imports.append(packageName)
|
|
292
|
-
pythonSource = autoflake_fix_code(pythonSource, autoflake_additional_imports, expand_star_imports=False, remove_all_unused_imports=
|
|
300
|
+
pythonSource = autoflake_fix_code(pythonSource, autoflake_additional_imports, expand_star_imports=False, remove_all_unused_imports=True, remove_duplicate_keys = False, remove_unused_variables = False)
|
|
293
301
|
writeStringToHere(pythonSource, pathFilename)
|
|
294
302
|
|
|
295
303
|
# END of acceptable classes and functions ======================================================
|
|
@@ -2,7 +2,6 @@ from concurrent.futures import Future as ConcurrentFuture, ProcessPoolExecutor
|
|
|
2
2
|
from copy import deepcopy
|
|
3
3
|
from mapFolding.theSSOT import Array1DElephino, Array1DFoldsTotal, Array1DLeavesTotal, Array3D, ComputationState, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal
|
|
4
4
|
from numba import jit
|
|
5
|
-
from numpy import array, int16, int64
|
|
6
5
|
|
|
7
6
|
def countInitialize(state: ComputationState) -> ComputationState:
|
|
8
7
|
while state.leaf1ndex > 0:
|
mapFolding/theSSOT.py
CHANGED
|
@@ -112,7 +112,6 @@ def getPackageDispatcher() -> Callable[['ComputationState'], 'ComputationState']
|
|
|
112
112
|
return The.dispatcher
|
|
113
113
|
# =============================================================================
|
|
114
114
|
# Flexible Data Structure System Needs Enhanced Paradigm https://github.com/hunterhogan/mapFolding/issues/9
|
|
115
|
-
# Efficient translation of Python scalar types to Numba types https://github.com/hunterhogan/mapFolding/issues/8
|
|
116
115
|
|
|
117
116
|
numpyIntegerType = TypeVar('numpyIntegerType', bound=integer[Any], covariant=True)
|
|
118
117
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
mapFolding/__init__.py,sha256=
|
|
1
|
+
mapFolding/__init__.py,sha256=7eMsgeEpydLE6-pY7Ycp397RSkhAA04chz1PojEcK0Q,2319
|
|
2
2
|
mapFolding/basecamp.py,sha256=-__EJ2to84ssS4Fm0CAuQjRnghI9VA4cXZoWGYud1r0,4782
|
|
3
3
|
mapFolding/beDRY.py,sha256=2GPO4A8XcxoEJXB_3sro4ZFQ5gcU7ywc1-c8HLEvEv0,15280
|
|
4
|
-
mapFolding/
|
|
5
|
-
mapFolding/oeis.py,sha256=EzEnbRi_4qt8Na2tiMcvL23FXpcJEkXTwuXDYDFH_XI,12631
|
|
4
|
+
mapFolding/oeis.py,sha256=eorjDavo56uaeXIYVSXBH_ais4KKPEx4jpgBof1wcHw,13669
|
|
6
5
|
mapFolding/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
6
|
mapFolding/theDao.py,sha256=MVopt1LzhdIQYA97SEoq9bdzct6hbK0lEyPxBAAlVTc,9934
|
|
8
|
-
mapFolding/theSSOT.py,sha256=
|
|
7
|
+
mapFolding/theSSOT.py,sha256=FvHOBCR-wysuhfmyyjfWQiojV87K4PBdsE8lNH-yCYY,11865
|
|
9
8
|
mapFolding/toolboxFilesystem.py,sha256=WoqRjXqTXy5GYNmbfzWtzv1uufm7vYcgT4zJ9ffhRYY,9982
|
|
10
9
|
mapFolding/reference/__init__.py,sha256=UIEU8BJR_YDzjFQcLel3XtHzOCJiOUGlGiWzOzbvhik,2206
|
|
11
10
|
mapFolding/reference/flattened.py,sha256=QK1xG9SllqCoi68e86Hyl9d9ATUAAFNpTQI-3zmcp5I,16072
|
|
@@ -21,28 +20,28 @@ mapFolding/reference/jobsCompleted/[2x19]/p2x19.py,sha256=_tvYtfzMWVo2VtUbIAieos
|
|
|
21
20
|
mapFolding/reference/jobsCompleted/p2x19/p2x19.py,sha256=eZEw4Me4ocTt6VXoK2-Sbd5SowZtxRIbN9dZmc7OCVg,6395
|
|
22
21
|
mapFolding/someAssemblyRequired/__init__.py,sha256=c2GFI2HSId2_R_aoJWBID-P9AMF3zoHJzOc10XS6DHc,2669
|
|
23
22
|
mapFolding/someAssemblyRequired/_theTypes.py,sha256=SG82WTtQy83BmInlHZHY8Nh3Kp161NcEFSA6-UU5wuE,4623
|
|
24
|
-
mapFolding/someAssemblyRequired/_tool_Make.py,sha256=
|
|
23
|
+
mapFolding/someAssemblyRequired/_tool_Make.py,sha256=txVsebv1-z5_HShO7vtc9lCdab-uJCBtC0YwR4hLk78,7132
|
|
25
24
|
mapFolding/someAssemblyRequired/_tool_Then.py,sha256=QxuoBqj4iOeKWITjV3DcV8c25fLx3Q6mhUORD7-mCzc,2758
|
|
26
25
|
mapFolding/someAssemblyRequired/_toolboxAntecedents.py,sha256=GEAuniYRj6yOtrJO_6sGZMzsVARdejts8NXhR_0np_c,21914
|
|
27
|
-
mapFolding/someAssemblyRequired/_toolboxContainers.py,sha256=
|
|
26
|
+
mapFolding/someAssemblyRequired/_toolboxContainers.py,sha256=UQGTlaV30TMTngNDQE6txDkEeGgwjPz5JLOwCdCc5O0,20732
|
|
28
27
|
mapFolding/someAssemblyRequired/_toolboxPython.py,sha256=za30092eT00tj5ctqUCRrEuq5DGeJZN-vV9T4Dro-1w,3483
|
|
29
28
|
mapFolding/someAssemblyRequired/getLLVMforNoReason.py,sha256=9RPU6vK_eUg64GtVFI_nZnvUryXw8gfHJs9NyDYHIvg,2745
|
|
30
29
|
mapFolding/someAssemblyRequired/newInliner.py,sha256=Tm9PSzt66oIXPVrN9VdQwEYBba2iEOF5X3aEsOOF-FE,946
|
|
31
|
-
mapFolding/someAssemblyRequired/synthesizeNumbaJob.py,sha256=
|
|
32
|
-
mapFolding/someAssemblyRequired/toolboxNumba.py,sha256=
|
|
33
|
-
mapFolding/someAssemblyRequired/transformationTools.py,sha256=
|
|
30
|
+
mapFolding/someAssemblyRequired/synthesizeNumbaJob.py,sha256=z9v61yaUyJt0sNuClB7-5UMEXwdOHGK8RSobi0cPEBI,10705
|
|
31
|
+
mapFolding/someAssemblyRequired/toolboxNumba.py,sha256=ZCtckbHoeSbT1Kik5CcmAFwPX4Ay-4C-zRGOMVkc_fQ,22932
|
|
32
|
+
mapFolding/someAssemblyRequired/transformationTools.py,sha256=NkH8eiBtlDEJK5PGB9k1vDGcEb0GgmyNQIB27GfKRqs,20866
|
|
34
33
|
mapFolding/syntheticModules/__init__.py,sha256=evVFqhCGa-WZKDiLcnQWjs-Bj34eRnfSLqz_d7dFYZY,83
|
|
35
|
-
mapFolding/syntheticModules/numbaCount_doTheNeedful.py,sha256=
|
|
36
|
-
mapfolding-0.8.
|
|
34
|
+
mapFolding/syntheticModules/numbaCount_doTheNeedful.py,sha256=vSqV1WbyZ0mXg2TNgMR9EndiitVKM8GQa72ijOUCEZ8,15659
|
|
35
|
+
mapfolding-0.8.6.dist-info/licenses/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
|
|
37
36
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
37
|
tests/conftest.py,sha256=LfogHLu7PULSECwhLQgGCgqSvDMBc5b9RGWBls3YBrM,11364
|
|
39
|
-
tests/test_computations.py,sha256=
|
|
38
|
+
tests/test_computations.py,sha256=UOES0LNiCdIIwmD4NawyW3RwfH2-OGh6AxHgeFFptVk,3547
|
|
40
39
|
tests/test_filesystem.py,sha256=YEHNU6tUCTj9C65cKs3ETgt3OZTGVnNjxgu4aH6C9uU,3164
|
|
41
40
|
tests/test_oeis.py,sha256=uxvwmgbnylSDdsVJfuAT0LuYLbIVFwSgdLxHm-xUGBM,5043
|
|
42
41
|
tests/test_other.py,sha256=O05PFAK70Skf-k99Wcg4ASLpMpBH-WkELtk6MnynDx0,4293
|
|
43
|
-
tests/test_tasks.py,sha256=
|
|
44
|
-
mapfolding-0.8.
|
|
45
|
-
mapfolding-0.8.
|
|
46
|
-
mapfolding-0.8.
|
|
47
|
-
mapfolding-0.8.
|
|
48
|
-
mapfolding-0.8.
|
|
42
|
+
tests/test_tasks.py,sha256=q8YqFxVtI-fZ9qpklSlS04YAwfME2nivIrY-Y9jaGJI,2860
|
|
43
|
+
mapfolding-0.8.6.dist-info/METADATA,sha256=u3cXT3ks2oQv2yLxXXstcJwyGU3bHGMWD5UME299C1Q,9359
|
|
44
|
+
mapfolding-0.8.6.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
45
|
+
mapfolding-0.8.6.dist-info/entry_points.txt,sha256=F3OUeZR1XDTpoH7k3wXuRb3KF_kXTTeYhu5AGK1SiOQ,146
|
|
46
|
+
mapfolding-0.8.6.dist-info/top_level.txt,sha256=1gP2vFaqPwHujGwb3UjtMlLEGN-943VSYFR7V4gDqW8,17
|
|
47
|
+
mapfolding-0.8.6.dist-info/RECORD,,
|
tests/test_computations.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from mapFolding.basecamp import countFolds
|
|
2
2
|
from mapFolding.toolboxFilesystem import getPathFilenameFoldsTotal
|
|
3
3
|
from mapFolding.beDRY import validateListDimensions
|
|
4
|
-
from mapFolding.
|
|
4
|
+
from mapFolding.oeis import getFoldsTotalKnown
|
|
5
5
|
from mapFolding.oeis import settingsOEIS, oeisIDfor_n
|
|
6
6
|
from mapFolding.someAssemblyRequired.transformationTools import makeInitializedComputationState
|
|
7
7
|
from pathlib import Path, PurePosixPath
|
tests/test_tasks.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from collections.abc import Callable
|
|
2
2
|
from mapFolding.basecamp import countFolds
|
|
3
3
|
from mapFolding.beDRY import getTaskDivisions, setProcessorLimit, validateListDimensions, getLeavesTotal
|
|
4
|
-
from mapFolding.
|
|
4
|
+
from mapFolding.oeis import getFoldsTotalKnown
|
|
5
5
|
from tests.conftest import standardizedEqualToCallableReturn
|
|
6
6
|
from typing import Literal
|
|
7
7
|
from Z0Z_tools.pytestForYourUse import PytestFor_defineConcurrencyLimit
|
mapFolding/noHomeYet.py
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Interface for retrieving known map folding totals from OEIS (Online Encyclopedia of Integer Sequences).
|
|
3
|
-
|
|
4
|
-
This module provides utilities for accessing pre-computed map folding totals that are known
|
|
5
|
-
from mathematical literature and stored in the OEIS. The functions cache results for
|
|
6
|
-
performance and provide lookups based on map dimensions.
|
|
7
|
-
|
|
8
|
-
The main functions are:
|
|
9
|
-
- makeDictionaryFoldsTotalKnown: Creates a dictionary of known folding totals indexed by map dimensions
|
|
10
|
-
- getFoldsTotalKnown: Retrieves the folding total for a specific map shape, returning -1 if unknown
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
from functools import cache
|
|
14
|
-
from mapFolding.oeis import settingsOEIS
|
|
15
|
-
|
|
16
|
-
@cache
|
|
17
|
-
def makeDictionaryFoldsTotalKnown() -> dict[tuple[int, ...], int]:
|
|
18
|
-
"""Returns a dictionary mapping dimension tuples to their known folding totals."""
|
|
19
|
-
dictionaryMapDimensionsToFoldsTotalKnown: dict[tuple[int, ...], int] = {}
|
|
20
|
-
|
|
21
|
-
for settings in settingsOEIS.values():
|
|
22
|
-
sequence = settings['valuesKnown']
|
|
23
|
-
|
|
24
|
-
for n, foldingsTotal in sequence.items():
|
|
25
|
-
mapShape = settings['getMapShape'](n)
|
|
26
|
-
mapShape = tuple(sorted(mapShape))
|
|
27
|
-
dictionaryMapDimensionsToFoldsTotalKnown[mapShape] = foldingsTotal
|
|
28
|
-
return dictionaryMapDimensionsToFoldsTotalKnown
|
|
29
|
-
|
|
30
|
-
def getFoldsTotalKnown(mapShape: tuple[int, ...]) -> int:
|
|
31
|
-
lookupFoldsTotal = makeDictionaryFoldsTotalKnown()
|
|
32
|
-
return lookupFoldsTotal.get(tuple(mapShape), -1)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|