mapFolding 0.12.2__tar.gz → 0.12.3__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.12.2 → mapfolding-0.12.3}/PKG-INFO +7 -11
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/__init__.py +4 -2
- mapfolding-0.12.3/mapFolding/_theSSOT.py +81 -0
- mapfolding-0.12.2/mapFolding/datatypes.py → mapfolding-0.12.3/mapFolding/_theTypes.py +25 -3
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/basecamp.py +39 -34
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/beDRY.py +79 -54
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/dataBaskets.py +117 -74
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/filesystemToolkit.py +140 -91
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/oeis.py +242 -144
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/reference/flattened.py +1 -1
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/someAssemblyRequired/RecipeJob.py +68 -53
- mapfolding-0.12.3/mapFolding/someAssemblyRequired/__init__.py +85 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/someAssemblyRequired/_toolIfThis.py +82 -54
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/someAssemblyRequired/_toolkitContainers.py +19 -16
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/someAssemblyRequired/getLLVMforNoReason.py +35 -26
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/someAssemblyRequired/makeAllModules.py +348 -275
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +81 -57
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/someAssemblyRequired/toolkitNumba.py +80 -50
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/someAssemblyRequired/transformationTools.py +63 -40
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding.egg-info/PKG-INFO +7 -11
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding.egg-info/SOURCES.txt +1 -1
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding.egg-info/requires.txt +6 -9
- {mapfolding-0.12.2 → mapfolding-0.12.3}/pyproject.toml +16 -15
- {mapfolding-0.12.2 → mapfolding-0.12.3}/tests/test_computations.py +26 -8
- {mapfolding-0.12.2 → mapfolding-0.12.3}/tests/test_oeis.py +8 -7
- {mapfolding-0.12.2 → mapfolding-0.12.3}/tests/test_other.py +3 -3
- {mapfolding-0.12.2 → mapfolding-0.12.3}/tests/test_tasks.py +2 -4
- mapfolding-0.12.2/mapFolding/_theSSOT.py +0 -137
- mapfolding-0.12.2/mapFolding/someAssemblyRequired/__init__.py +0 -60
- {mapfolding-0.12.2 → mapfolding-0.12.3}/LICENSE +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/README.md +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/daoOfMapFolding.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/py.typed +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/reference/__init__.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/reference/hunterNumba.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/reference/irvineJavaPort.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/reference/jaxCount.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/reference/jobsCompleted/[2x19]/p2x19.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/reference/jobsCompleted/__init__.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/reference/jobsCompleted/p2x19/p2x19.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/reference/lunnonNumpy.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/reference/lunnonWhile.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/reference/rotatedEntryPoint.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/someAssemblyRequired/infoBooth.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/syntheticModules/__init__.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/syntheticModules/countParallel.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/syntheticModules/daoOfMapFolding.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/syntheticModules/dataPacking.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/syntheticModules/initializeCount.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/syntheticModules/theorem2.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/syntheticModules/theorem2Numba.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding/syntheticModules/theorem2Trimmed.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding.egg-info/dependency_links.txt +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding.egg-info/entry_points.txt +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/mapFolding.egg-info/top_level.txt +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/setup.cfg +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/tests/__init__.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/tests/conftest.py +0 -0
- {mapfolding-0.12.2 → mapfolding-0.12.3}/tests/test_filesystem.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mapFolding
|
|
3
|
-
Version: 0.12.
|
|
4
|
-
Summary: Map folding algorithm with code transformation framework for optimizing numerical computations
|
|
3
|
+
Version: 0.12.3
|
|
4
|
+
Summary: Map folding algorithm with code transformation framework for optimizing numerical computations.
|
|
5
5
|
Author-email: Hunter Hogan <HunterHogan@pm.me>
|
|
6
6
|
License: CC-BY-NC-4.0
|
|
7
7
|
Project-URL: Donate, https://www.patreon.com/integrated
|
|
@@ -29,25 +29,21 @@ Classifier: Typing :: Typed
|
|
|
29
29
|
Requires-Python: >=3.12
|
|
30
30
|
Description-Content-Type: text/markdown
|
|
31
31
|
License-File: LICENSE
|
|
32
|
-
Requires-Dist: Z0Z_tools
|
|
33
32
|
Requires-Dist: astToolkit>=0.5.0
|
|
34
|
-
Requires-Dist:
|
|
33
|
+
Requires-Dist: hunterMakesPy
|
|
35
34
|
Requires-Dist: numba
|
|
36
35
|
Requires-Dist: numba_progress
|
|
37
36
|
Requires-Dist: numpy
|
|
38
37
|
Requires-Dist: platformdirs
|
|
39
|
-
|
|
40
|
-
Requires-Dist:
|
|
41
|
-
Requires-Dist:
|
|
38
|
+
Provides-Extra: development
|
|
39
|
+
Requires-Dist: mypy; extra == "development"
|
|
40
|
+
Requires-Dist: pyupgrade; extra == "development"
|
|
41
|
+
Requires-Dist: setuptools-scm; extra == "development"
|
|
42
42
|
Provides-Extra: testing
|
|
43
|
-
Requires-Dist: mypy; extra == "testing"
|
|
44
43
|
Requires-Dist: pytest; extra == "testing"
|
|
45
44
|
Requires-Dist: pytest-cov; extra == "testing"
|
|
46
45
|
Requires-Dist: pytest-env; extra == "testing"
|
|
47
46
|
Requires-Dist: pytest-xdist; extra == "testing"
|
|
48
|
-
Requires-Dist: pyupgrade; extra == "testing"
|
|
49
|
-
Requires-Dist: ruff; extra == "testing"
|
|
50
|
-
Requires-Dist: setuptools-scm; extra == "testing"
|
|
51
47
|
Dynamic: license-file
|
|
52
48
|
|
|
53
49
|
# mapFolding
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""Computational toolkit for analyzing multi-dimensional map folding patterns.
|
|
2
2
|
|
|
3
|
+
(AI generated docstring)
|
|
4
|
+
|
|
3
5
|
The mapFolding package provides a complete implementation of Lunnon's 1971 algorithm
|
|
4
6
|
for counting distinct folding patterns in multi-dimensional maps. This toolkit
|
|
5
7
|
transforms the complex combinatorial mathematics of map folding into accessible
|
|
@@ -40,7 +42,7 @@ For practitioners: The robust result persistence and type safety ensure
|
|
|
40
42
|
reliable completion of complex analytical tasks.
|
|
41
43
|
"""
|
|
42
44
|
|
|
43
|
-
from mapFolding.
|
|
45
|
+
from mapFolding._theTypes import (
|
|
44
46
|
Array1DElephino as Array1DElephino,
|
|
45
47
|
Array1DFoldsTotal as Array1DFoldsTotal,
|
|
46
48
|
Array1DLeavesTotal as Array1DLeavesTotal,
|
|
@@ -54,7 +56,7 @@ from mapFolding.datatypes import (
|
|
|
54
56
|
NumPyLeavesTotal as NumPyLeavesTotal,
|
|
55
57
|
)
|
|
56
58
|
|
|
57
|
-
from mapFolding._theSSOT import
|
|
59
|
+
from mapFolding._theSSOT import packageSettings as packageSettings
|
|
58
60
|
|
|
59
61
|
from mapFolding.beDRY import (
|
|
60
62
|
getConnectionGraph as getConnectionGraph,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Foundation layer for the map folding computational ecosystem.
|
|
3
|
+
|
|
4
|
+
(AI generated docstring)
|
|
5
|
+
|
|
6
|
+
This module establishes the fundamental configuration infrastructure that underpins
|
|
7
|
+
all map folding operations. Map folding, as defined by Lunnon's 1971 algorithm,
|
|
8
|
+
requires precise coordination of computational resources, type systems, and data
|
|
9
|
+
flow management to solve the complex combinatorial problem of counting distinct
|
|
10
|
+
folding patterns across multi-dimensional maps.
|
|
11
|
+
|
|
12
|
+
The Single Source Of Truth (SSOT) principle governs this foundation, ensuring that
|
|
13
|
+
package identity, filesystem locations, and concurrency configuration remain
|
|
14
|
+
consistent across all computational phases. During packaging, static metadata is
|
|
15
|
+
resolved from pyproject.toml. During installation, filesystem-dependent paths are
|
|
16
|
+
dynamically discovered. During runtime, the `packageSettings` instance provides
|
|
17
|
+
unified access to all configuration values, enabling the sophisticated computational
|
|
18
|
+
framework that follows.
|
|
19
|
+
|
|
20
|
+
This configuration foundation supports the type system definition, core utility
|
|
21
|
+
functions, computational state management, result persistence, and ultimately the
|
|
22
|
+
main computational interface that users interact with to solve map folding problems.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from hunterMakesPy import PackageSettings
|
|
26
|
+
import dataclasses
|
|
27
|
+
|
|
28
|
+
packageNameHARDCODED = "mapFolding"
|
|
29
|
+
"""Hardcoded package name used as fallback when dynamic resolution fails."""
|
|
30
|
+
|
|
31
|
+
concurrencyPackageHARDCODED = 'multiprocessing'
|
|
32
|
+
"""Default package identifier for concurrent execution operations."""
|
|
33
|
+
|
|
34
|
+
@dataclasses.dataclass
|
|
35
|
+
class mapFoldingPackageSettings(PackageSettings):
|
|
36
|
+
"""Centralized configuration container for all package-wide settings.
|
|
37
|
+
|
|
38
|
+
(AI generated docstring)
|
|
39
|
+
|
|
40
|
+
This dataclass serves as the single source of truth for package configuration,
|
|
41
|
+
providing both static and dynamically-resolved values needed throughout the
|
|
42
|
+
package lifecycle. The metadata on each field indicates when that value is
|
|
43
|
+
determined - either during packaging or at installation/runtime.
|
|
44
|
+
|
|
45
|
+
The design supports different evaluation phases to optimize performance and
|
|
46
|
+
reliability. Packaging-time values can be determined during package creation,
|
|
47
|
+
while installing-time values require filesystem access or module introspection.
|
|
48
|
+
|
|
49
|
+
Attributes
|
|
50
|
+
----------
|
|
51
|
+
fileExtension : str = '.py'
|
|
52
|
+
Standard file extension for Python modules in this package.
|
|
53
|
+
packageName : str
|
|
54
|
+
Canonical name of the package as defined in project configuration.
|
|
55
|
+
pathPackage : Path
|
|
56
|
+
Absolute filesystem path to the installed package directory.
|
|
57
|
+
concurrencyPackage : str | None = None
|
|
58
|
+
Package identifier for concurrent execution operations.
|
|
59
|
+
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
concurrencyPackage: str | None = None
|
|
63
|
+
"""
|
|
64
|
+
Package identifier for concurrent execution operations.
|
|
65
|
+
|
|
66
|
+
(AI generated docstring)
|
|
67
|
+
|
|
68
|
+
Specifies which Python package should be used for parallel processing
|
|
69
|
+
in computationally intensive operations. When None, the default concurrency
|
|
70
|
+
package specified in the module constants is used. Accepted values include
|
|
71
|
+
'multiprocessing' for standard parallel processing and 'numba' for
|
|
72
|
+
specialized numerical computations.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
concurrencyPackage = concurrencyPackageHARDCODED
|
|
76
|
+
"""Active concurrency package configuration for the current session."""
|
|
77
|
+
|
|
78
|
+
packageSettings = mapFoldingPackageSettings(
|
|
79
|
+
identifierPackageFALLBACK=packageNameHARDCODED
|
|
80
|
+
, concurrencyPackage=concurrencyPackage)
|
|
81
|
+
"""Global package settings."""
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Type system architecture for map folding computational domains.
|
|
3
3
|
|
|
4
|
+
(AI generated docstring)
|
|
5
|
+
|
|
4
6
|
Building upon the configuration foundation, this module defines the complete type
|
|
5
7
|
hierarchy that ensures type safety and semantic clarity throughout the map folding
|
|
6
8
|
computational framework. The type system recognizes three distinct computational
|
|
@@ -20,15 +22,15 @@ complex multi-dimensional folding patterns. The array types built from these
|
|
|
20
22
|
base types provide the structured data containers that computational state
|
|
21
23
|
management depends upon.
|
|
22
24
|
"""
|
|
23
|
-
from numpy import
|
|
24
|
-
dtype, integer, ndarray, uint8 as numpy_uint8, uint16 as numpy_uint16, uint64 as numpy_uint64,
|
|
25
|
-
)
|
|
25
|
+
from numpy import dtype, integer, ndarray, uint8 as numpy_uint8, uint16 as numpy_uint16, uint64 as numpy_uint64
|
|
26
26
|
from typing import Any, TypeAlias, TypeVar
|
|
27
27
|
|
|
28
28
|
NumPyIntegerType = TypeVar('NumPyIntegerType', bound=integer[Any], covariant=True)
|
|
29
29
|
"""
|
|
30
30
|
Generic type variable for NumPy integer types used in computational operations.
|
|
31
31
|
|
|
32
|
+
(AI generated docstring)
|
|
33
|
+
|
|
32
34
|
This type variable enables generic programming with NumPy integer types while
|
|
33
35
|
maintaining type safety. It supports covariant relationships between different
|
|
34
36
|
NumPy integer types and their array containers.
|
|
@@ -38,6 +40,8 @@ DatatypeLeavesTotal: TypeAlias = int
|
|
|
38
40
|
"""
|
|
39
41
|
Python type for leaf-related counts and indices in map folding computations.
|
|
40
42
|
|
|
43
|
+
(AI generated docstring)
|
|
44
|
+
|
|
41
45
|
Represents quantities related to individual map sections (leaves), including
|
|
42
46
|
total leaf counts, leaf indices, and dimensional parameters. Uses standard
|
|
43
47
|
Python integers for compatibility with general computations while enabling
|
|
@@ -48,6 +52,8 @@ NumPyLeavesTotal: TypeAlias = numpy_uint8
|
|
|
48
52
|
"""
|
|
49
53
|
NumPy type for efficient leaf-related computations and array operations.
|
|
50
54
|
|
|
55
|
+
(AI generated docstring)
|
|
56
|
+
|
|
51
57
|
Corresponds to `DatatypeLeavesTotal` but optimized for NumPy operations.
|
|
52
58
|
Uses 8-bit unsigned integers since leaf counts in practical map folding
|
|
53
59
|
scenarios typically remain small (under 256).
|
|
@@ -57,6 +63,8 @@ DatatypeElephino: TypeAlias = int
|
|
|
57
63
|
"""
|
|
58
64
|
Python type for internal computational indices and intermediate values.
|
|
59
65
|
|
|
66
|
+
(AI generated docstring)
|
|
67
|
+
|
|
60
68
|
Used for temporary variables, gap indices, and other internal computational
|
|
61
69
|
state that doesn't directly correspond to leaves or final fold counts. The
|
|
62
70
|
name follows the package convention for internal computational domains.
|
|
@@ -66,6 +74,8 @@ NumPyElephino: TypeAlias = numpy_uint16
|
|
|
66
74
|
"""
|
|
67
75
|
NumPy type for internal computational operations requiring moderate value ranges.
|
|
68
76
|
|
|
77
|
+
(AI generated docstring)
|
|
78
|
+
|
|
69
79
|
Corresponds to `DatatypeElephino` with 16-bit unsigned integer storage,
|
|
70
80
|
providing sufficient range for internal computations while maintaining
|
|
71
81
|
memory efficiency in array operations.
|
|
@@ -75,6 +85,8 @@ DatatypeFoldsTotal: TypeAlias = int
|
|
|
75
85
|
"""
|
|
76
86
|
Python type for final fold counts and pattern totals.
|
|
77
87
|
|
|
88
|
+
(AI generated docstring)
|
|
89
|
+
|
|
78
90
|
Represents the ultimate results of map folding computations - the total number
|
|
79
91
|
of distinct folding patterns possible for a given map configuration. These
|
|
80
92
|
values can grow exponentially with map size, requiring flexible integer types.
|
|
@@ -84,6 +96,8 @@ NumPyFoldsTotal: TypeAlias = numpy_uint64
|
|
|
84
96
|
"""
|
|
85
97
|
NumPy type for large fold count computations and high-precision results.
|
|
86
98
|
|
|
99
|
+
(AI generated docstring)
|
|
100
|
+
|
|
87
101
|
Corresponds to `DatatypeFoldsTotal` using 64-bit unsigned integers to
|
|
88
102
|
accommodate the exponentially large values that can result from map folding
|
|
89
103
|
computations on even moderately-sized maps.
|
|
@@ -93,6 +107,8 @@ Array3D: TypeAlias = ndarray[tuple[int, int, int], dtype[NumPyLeavesTotal]]
|
|
|
93
107
|
"""
|
|
94
108
|
Three-dimensional NumPy array type for connection graph representations.
|
|
95
109
|
|
|
110
|
+
(AI generated docstring)
|
|
111
|
+
|
|
96
112
|
Used to store the connectivity relationships between map leaves in a
|
|
97
113
|
3D array structure. The array uses `NumPyLeavesTotal` element type since
|
|
98
114
|
the stored values represent leaf indices and connection states.
|
|
@@ -102,6 +118,8 @@ Array1DLeavesTotal: TypeAlias = ndarray[tuple[int], dtype[NumPyLeavesTotal]]
|
|
|
102
118
|
"""
|
|
103
119
|
One-dimensional NumPy array type for leaf-related data sequences.
|
|
104
120
|
|
|
121
|
+
(AI generated docstring)
|
|
122
|
+
|
|
105
123
|
Stores sequences of leaf counts, indices, or related values in efficient
|
|
106
124
|
array format. Common uses include leaf sequences, gap locations, and
|
|
107
125
|
dimensional data where each element relates to the leaves domain.
|
|
@@ -111,6 +129,8 @@ Array1DElephino: TypeAlias = ndarray[tuple[int], dtype[NumPyElephino]]
|
|
|
111
129
|
"""
|
|
112
130
|
One-dimensional NumPy array type for internal computational sequences.
|
|
113
131
|
|
|
132
|
+
(AI generated docstring)
|
|
133
|
+
|
|
114
134
|
Used for storing sequences of internal computational values such as
|
|
115
135
|
gap range starts, temporary indices, and other intermediate results
|
|
116
136
|
that require the elephino computational domain's value range.
|
|
@@ -120,6 +140,8 @@ Array1DFoldsTotal: TypeAlias = ndarray[tuple[int], dtype[NumPyFoldsTotal]]
|
|
|
120
140
|
"""
|
|
121
141
|
One-dimensional NumPy array type for sequences of fold count results.
|
|
122
142
|
|
|
143
|
+
(AI generated docstring)
|
|
144
|
+
|
|
123
145
|
Stores sequences of fold totals and pattern counts, using the large
|
|
124
146
|
integer type to accommodate the potentially enormous values that
|
|
125
147
|
result from complex map folding computations.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Unified interface for map folding computation orchestration.
|
|
3
3
|
|
|
4
|
+
(AI generated docstring)
|
|
5
|
+
|
|
4
6
|
This module represents the culmination of the computational ecosystem, providing
|
|
5
7
|
the primary entry point where users interact with the complete map folding analysis
|
|
6
8
|
system. It orchestrates all preceding layers: the configuration foundation,
|
|
@@ -23,13 +25,13 @@ consistent, reliable, and efficiently computed folding pattern counts.
|
|
|
23
25
|
|
|
24
26
|
from collections.abc import Sequence
|
|
25
27
|
from mapFolding import (
|
|
26
|
-
getPathFilenameFoldsTotal, packageSettings, saveFoldsTotal, saveFoldsTotalFAILearly,
|
|
27
|
-
|
|
28
|
-
)
|
|
28
|
+
getPathFilenameFoldsTotal, packageSettings, saveFoldsTotal, saveFoldsTotalFAILearly, setProcessorLimit,
|
|
29
|
+
validateListDimensions)
|
|
29
30
|
from os import PathLike
|
|
30
31
|
from pathlib import PurePath
|
|
32
|
+
import contextlib
|
|
31
33
|
|
|
32
|
-
def countFolds(listDimensions: Sequence[int] | None = None
|
|
34
|
+
def countFolds(listDimensions: Sequence[int] | None = None # noqa: C901
|
|
33
35
|
, pathLikeWriteFoldsTotal: PathLike[str] | PurePath | None = None
|
|
34
36
|
, computationDivisions: int | str | None = None
|
|
35
37
|
, CPUlimit: int | float | bool | None = None
|
|
@@ -42,6 +44,8 @@ def countFolds(listDimensions: Sequence[int] | None = None
|
|
|
42
44
|
"""
|
|
43
45
|
Count the total number of possible foldings for a given map dimensions.
|
|
44
46
|
|
|
47
|
+
(AI generated docstring)
|
|
48
|
+
|
|
45
49
|
This function serves as the main public interface to the map folding algorithm, handling all parameter validation,
|
|
46
50
|
computation state management, and result persistence in a user-friendly way.
|
|
47
51
|
|
|
@@ -86,32 +90,33 @@ def countFolds(listDimensions: Sequence[int] | None = None
|
|
|
86
90
|
computation time. If logicalCores >= `leavesTotal`, it will probably be faster. If logicalCores <= 2 * `leavesTotal`, it
|
|
87
91
|
will almost certainly be slower for all map dimensions.
|
|
88
92
|
"""
|
|
89
|
-
# mapShape
|
|
93
|
+
# mapShape ---------------------------------------------------------------------
|
|
90
94
|
|
|
91
95
|
if mapShape:
|
|
92
96
|
pass
|
|
93
97
|
else:
|
|
94
98
|
if oeisID and oeis_n:
|
|
95
|
-
from mapFolding.oeis import settingsOEIS
|
|
96
|
-
|
|
99
|
+
from mapFolding.oeis import settingsOEIS # noqa: PLC0415
|
|
100
|
+
with contextlib.suppress(KeyError):
|
|
97
101
|
mapShape = settingsOEIS[oeisID]['getMapShape'](oeis_n)
|
|
98
|
-
except KeyError:
|
|
99
|
-
pass
|
|
100
102
|
if not mapShape and listDimensions:
|
|
101
103
|
mapShape = validateListDimensions(listDimensions)
|
|
102
104
|
|
|
103
105
|
if mapShape is None:
|
|
104
|
-
|
|
106
|
+
message = (
|
|
107
|
+
f"""I received these values:
|
|
105
108
|
`{listDimensions = }`,
|
|
106
109
|
`{mapShape = }`,
|
|
107
110
|
`{oeisID = }` and `{oeis_n = }`,
|
|
108
|
-
but I was unable to select a map for which to count the folds."""
|
|
111
|
+
but I was unable to select a map for which to count the folds."""
|
|
112
|
+
)
|
|
113
|
+
raise ValueError(message)
|
|
109
114
|
|
|
110
|
-
# task division instructions
|
|
115
|
+
# task division instructions -----------------------------------------------------
|
|
111
116
|
|
|
112
117
|
if computationDivisions:
|
|
113
118
|
concurrencyLimit: int = setProcessorLimit(CPUlimit, packageSettings.concurrencyPackage)
|
|
114
|
-
from mapFolding.beDRY import getLeavesTotal, getTaskDivisions
|
|
119
|
+
from mapFolding.beDRY import getLeavesTotal, getTaskDivisions # noqa: PLC0415
|
|
115
120
|
leavesTotal: int = getLeavesTotal(mapShape)
|
|
116
121
|
taskDivisions = getTaskDivisions(computationDivisions, concurrencyLimit, leavesTotal)
|
|
117
122
|
del leavesTotal
|
|
@@ -119,7 +124,7 @@ def countFolds(listDimensions: Sequence[int] | None = None
|
|
|
119
124
|
concurrencyLimit = 1
|
|
120
125
|
taskDivisions = 0
|
|
121
126
|
|
|
122
|
-
# memorialization instructions
|
|
127
|
+
# memorialization instructions ---------------------------------------------
|
|
123
128
|
|
|
124
129
|
if pathLikeWriteFoldsTotal is not None:
|
|
125
130
|
pathFilenameFoldsTotal = getPathFilenameFoldsTotal(mapShape, pathLikeWriteFoldsTotal)
|
|
@@ -127,70 +132,70 @@ def countFolds(listDimensions: Sequence[int] | None = None
|
|
|
127
132
|
else:
|
|
128
133
|
pathFilenameFoldsTotal = None
|
|
129
134
|
|
|
130
|
-
# Flow control until I can figure out a good way
|
|
135
|
+
# Flow control until I can figure out a good way ---------------------------------
|
|
131
136
|
|
|
132
137
|
if flow == 'daoOfMapFolding':
|
|
133
|
-
from mapFolding.dataBaskets import MapFoldingState
|
|
138
|
+
from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
|
|
134
139
|
mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
|
|
135
140
|
|
|
136
|
-
from mapFolding.daoOfMapFolding import doTheNeedful
|
|
141
|
+
from mapFolding.daoOfMapFolding import doTheNeedful # noqa: PLC0415
|
|
137
142
|
mapFoldingState = doTheNeedful(mapFoldingState)
|
|
138
143
|
foldsTotal = mapFoldingState.foldsTotal
|
|
139
144
|
|
|
140
|
-
elif flow == 'theorem2' and any(dimension > 2 for dimension in mapShape):
|
|
141
|
-
from mapFolding.dataBaskets import MapFoldingState
|
|
145
|
+
elif flow == 'theorem2' and any(dimension > 2 for dimension in mapShape): # noqa: PLR2004
|
|
146
|
+
from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
|
|
142
147
|
mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
|
|
143
148
|
|
|
144
|
-
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds
|
|
149
|
+
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds # noqa: PLC0415
|
|
145
150
|
mapFoldingState = initializeGroupsOfFolds(mapFoldingState)
|
|
146
151
|
|
|
147
|
-
from mapFolding.syntheticModules.theorem2 import count
|
|
152
|
+
from mapFolding.syntheticModules.theorem2 import count # noqa: PLC0415
|
|
148
153
|
mapFoldingState = count(mapFoldingState)
|
|
149
154
|
|
|
150
155
|
foldsTotal = mapFoldingState.foldsTotal
|
|
151
156
|
|
|
152
|
-
elif flow == 'theorem2Trimmed' and any(dimension > 2 for dimension in mapShape):
|
|
153
|
-
from mapFolding.dataBaskets import MapFoldingState
|
|
157
|
+
elif flow == 'theorem2Trimmed' and any(dimension > 2 for dimension in mapShape): # noqa: PLR2004
|
|
158
|
+
from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
|
|
154
159
|
mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
|
|
155
160
|
|
|
156
|
-
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds
|
|
161
|
+
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds # noqa: PLC0415
|
|
157
162
|
mapFoldingState = initializeGroupsOfFolds(mapFoldingState)
|
|
158
163
|
|
|
159
|
-
from mapFolding.syntheticModules.theorem2Trimmed import count
|
|
164
|
+
from mapFolding.syntheticModules.theorem2Trimmed import count # noqa: PLC0415
|
|
160
165
|
mapFoldingState = count(mapFoldingState)
|
|
161
166
|
|
|
162
167
|
foldsTotal = mapFoldingState.foldsTotal
|
|
163
168
|
|
|
164
|
-
elif (flow == 'theorem2Numba' or taskDivisions == 0) and any(dimension > 2 for dimension in mapShape):
|
|
165
|
-
from mapFolding.dataBaskets import MapFoldingState
|
|
169
|
+
elif (flow == 'theorem2Numba' or taskDivisions == 0) and any(dimension > 2 for dimension in mapShape): # noqa: PLR2004
|
|
170
|
+
from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
|
|
166
171
|
mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
|
|
167
172
|
|
|
168
|
-
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds
|
|
173
|
+
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds # noqa: PLC0415
|
|
169
174
|
mapFoldingState = initializeGroupsOfFolds(mapFoldingState)
|
|
170
175
|
|
|
171
|
-
from mapFolding.syntheticModules.dataPacking import sequential
|
|
176
|
+
from mapFolding.syntheticModules.dataPacking import sequential # noqa: PLC0415
|
|
172
177
|
mapFoldingState = sequential(mapFoldingState)
|
|
173
178
|
|
|
174
179
|
foldsTotal = mapFoldingState.foldsTotal
|
|
175
180
|
|
|
176
181
|
elif taskDivisions > 1:
|
|
177
|
-
from mapFolding.dataBaskets import ParallelMapFoldingState
|
|
182
|
+
from mapFolding.dataBaskets import ParallelMapFoldingState # noqa: PLC0415
|
|
178
183
|
parallelMapFoldingState: ParallelMapFoldingState = ParallelMapFoldingState(mapShape, taskDivisions=taskDivisions)
|
|
179
184
|
|
|
180
|
-
from mapFolding.syntheticModules.countParallel import doTheNeedful
|
|
185
|
+
from mapFolding.syntheticModules.countParallel import doTheNeedful # noqa: PLC0415
|
|
181
186
|
|
|
182
187
|
# `listStatesParallel` exists in case you want to research the parallel computation.
|
|
183
188
|
foldsTotal, listStatesParallel = doTheNeedful(parallelMapFoldingState, concurrencyLimit) # pyright: ignore[reportUnusedVariable]
|
|
184
189
|
|
|
185
190
|
else:
|
|
186
|
-
from mapFolding.dataBaskets import MapFoldingState
|
|
191
|
+
from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
|
|
187
192
|
mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
|
|
188
193
|
|
|
189
|
-
from mapFolding.syntheticModules.daoOfMapFolding import doTheNeedful
|
|
194
|
+
from mapFolding.syntheticModules.daoOfMapFolding import doTheNeedful # noqa: PLC0415
|
|
190
195
|
mapFoldingState = doTheNeedful(mapFoldingState)
|
|
191
196
|
foldsTotal = mapFoldingState.foldsTotal
|
|
192
197
|
|
|
193
|
-
# Follow memorialization instructions
|
|
198
|
+
# Follow memorialization instructions ---------------------------------------------
|
|
194
199
|
|
|
195
200
|
if pathFilenameFoldsTotal is not None:
|
|
196
201
|
saveFoldsTotal(pathFilenameFoldsTotal, foldsTotal)
|