mapFolding 0.12.1__py3-none-any.whl → 0.12.3__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 +46 -20
- mapFolding/_theSSOT.py +81 -0
- mapFolding/_theTypes.py +148 -0
- mapFolding/basecamp.py +62 -47
- mapFolding/beDRY.py +100 -73
- mapFolding/dataBaskets.py +226 -31
- mapFolding/filesystemToolkit.py +161 -107
- mapFolding/oeis.py +388 -174
- mapFolding/reference/flattened.py +1 -1
- mapFolding/someAssemblyRequired/RecipeJob.py +146 -20
- mapFolding/someAssemblyRequired/__init__.py +60 -38
- mapFolding/someAssemblyRequired/_toolIfThis.py +125 -35
- mapFolding/someAssemblyRequired/_toolkitContainers.py +125 -44
- mapFolding/someAssemblyRequired/getLLVMforNoReason.py +35 -26
- mapFolding/someAssemblyRequired/infoBooth.py +37 -2
- mapFolding/someAssemblyRequired/makeAllModules.py +785 -0
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +161 -74
- mapFolding/someAssemblyRequired/toolkitNumba.py +218 -36
- mapFolding/someAssemblyRequired/transformationTools.py +125 -58
- mapfolding-0.12.3.dist-info/METADATA +163 -0
- mapfolding-0.12.3.dist-info/RECORD +53 -0
- {mapfolding-0.12.1.dist-info → mapfolding-0.12.3.dist-info}/WHEEL +1 -1
- tests/__init__.py +28 -44
- tests/conftest.py +66 -61
- tests/test_computations.py +64 -89
- tests/test_filesystem.py +25 -1
- tests/test_oeis.py +37 -7
- tests/test_other.py +29 -2
- tests/test_tasks.py +30 -2
- mapFolding/datatypes.py +0 -18
- mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py +0 -433
- mapFolding/theSSOT.py +0 -34
- mapfolding-0.12.1.dist-info/METADATA +0 -184
- mapfolding-0.12.1.dist-info/RECORD +0 -53
- {mapfolding-0.12.1.dist-info → mapfolding-0.12.3.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.12.1.dist-info → mapfolding-0.12.3.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.12.1.dist-info → mapfolding-0.12.3.dist-info}/top_level.txt +0 -0
mapFolding/__init__.py
CHANGED
|
@@ -1,22 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
"""Computational toolkit for analyzing multi-dimensional map folding patterns.
|
|
2
|
+
|
|
3
|
+
(AI generated docstring)
|
|
4
|
+
|
|
5
|
+
The mapFolding package provides a complete implementation of Lunnon's 1971 algorithm
|
|
6
|
+
for counting distinct folding patterns in multi-dimensional maps. This toolkit
|
|
7
|
+
transforms the complex combinatorial mathematics of map folding into accessible
|
|
8
|
+
computational tools, enabling researchers and practitioners to analyze folding
|
|
9
|
+
patterns across dimensions from simple 2D strips to complex multi-dimensional
|
|
10
|
+
hypercubes.
|
|
11
|
+
|
|
12
|
+
The package architecture follows Domain-Driven Design principles, organizing
|
|
13
|
+
functionality around mathematical concepts rather than implementation details.
|
|
14
|
+
The computational framework integrates type safety, persistent result storage,
|
|
15
|
+
and mathematical validation through OEIS sequence integration.
|
|
16
|
+
|
|
17
|
+
Core Transformation Tools:
|
|
18
|
+
countFolds: Primary interface for computing folding pattern counts
|
|
19
|
+
MapFoldingState: Computational state management for recursive analysis
|
|
20
|
+
Connection graph generation: Mathematical foundation for folding relationships
|
|
21
|
+
Task division utilities: Experimental parallel computation options
|
|
22
|
+
OEIS integration: Mathematical validation and sequence discovery
|
|
23
|
+
|
|
24
|
+
Primary Use Cases:
|
|
25
|
+
Mathematical research into folding pattern properties and relationships
|
|
26
|
+
Educational exploration of combinatorial mathematics concepts
|
|
27
|
+
Computational validation of theoretical results
|
|
28
|
+
Extension of known mathematical sequences through new discoveries
|
|
29
|
+
|
|
30
|
+
The package handles the full spectrum of map folding analysis, from simple
|
|
31
|
+
educational examples to research-grade computations requiring multi-day processing
|
|
32
|
+
time. Results integrate seamlessly with the mathematical community through
|
|
33
|
+
comprehensive OEIS connectivity and standardized result persistence.
|
|
34
|
+
|
|
35
|
+
For researchers: The computational foundation supports both replication of
|
|
36
|
+
established results and discovery of new mathematical relationships.
|
|
37
|
+
|
|
38
|
+
For educators: The clear interfaces and type safety enable confident exploration
|
|
39
|
+
of combinatorial concepts without computational complexity barriers.
|
|
40
|
+
|
|
41
|
+
For practitioners: The robust result persistence and type safety ensure
|
|
42
|
+
reliable completion of complex analytical tasks.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
from mapFolding._theTypes import (
|
|
20
46
|
Array1DElephino as Array1DElephino,
|
|
21
47
|
Array1DFoldsTotal as Array1DFoldsTotal,
|
|
22
48
|
Array1DLeavesTotal as Array1DLeavesTotal,
|
|
@@ -30,7 +56,7 @@ from mapFolding.datatypes import (
|
|
|
30
56
|
NumPyLeavesTotal as NumPyLeavesTotal,
|
|
31
57
|
)
|
|
32
58
|
|
|
33
|
-
from mapFolding.
|
|
59
|
+
from mapFolding._theSSOT import packageSettings as packageSettings
|
|
34
60
|
|
|
35
61
|
from mapFolding.beDRY import (
|
|
36
62
|
getConnectionGraph as getConnectionGraph,
|
mapFolding/_theSSOT.py
ADDED
|
@@ -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."""
|
mapFolding/_theTypes.py
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Type system architecture for map folding computational domains.
|
|
3
|
+
|
|
4
|
+
(AI generated docstring)
|
|
5
|
+
|
|
6
|
+
Building upon the configuration foundation, this module defines the complete type
|
|
7
|
+
hierarchy that ensures type safety and semantic clarity throughout the map folding
|
|
8
|
+
computational framework. The type system recognizes three distinct computational
|
|
9
|
+
domains, each with specific data characteristics and performance requirements
|
|
10
|
+
that emerge from Lunnon's algorithm implementation.
|
|
11
|
+
|
|
12
|
+
The Leaves domain handles map sections, their indices, and dimensional parameters.
|
|
13
|
+
The Elephino domain manages internal computational state, gap calculations, and
|
|
14
|
+
temporary indices used during the recursive folding analysis. The Folds domain
|
|
15
|
+
represents final pattern counts and computation results. Each domain employs both
|
|
16
|
+
Python types for general computation and NumPy types for performance-critical
|
|
17
|
+
array operations.
|
|
18
|
+
|
|
19
|
+
This dual-type strategy enables the core utility functions to operate with type
|
|
20
|
+
safety while maintaining the computational efficiency required for analyzing
|
|
21
|
+
complex multi-dimensional folding patterns. The array types built from these
|
|
22
|
+
base types provide the structured data containers that computational state
|
|
23
|
+
management depends upon.
|
|
24
|
+
"""
|
|
25
|
+
from numpy import dtype, integer, ndarray, uint8 as numpy_uint8, uint16 as numpy_uint16, uint64 as numpy_uint64
|
|
26
|
+
from typing import Any, TypeAlias, TypeVar
|
|
27
|
+
|
|
28
|
+
NumPyIntegerType = TypeVar('NumPyIntegerType', bound=integer[Any], covariant=True)
|
|
29
|
+
"""
|
|
30
|
+
Generic type variable for NumPy integer types used in computational operations.
|
|
31
|
+
|
|
32
|
+
(AI generated docstring)
|
|
33
|
+
|
|
34
|
+
This type variable enables generic programming with NumPy integer types while
|
|
35
|
+
maintaining type safety. It supports covariant relationships between different
|
|
36
|
+
NumPy integer types and their array containers.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
DatatypeLeavesTotal: TypeAlias = int
|
|
40
|
+
"""
|
|
41
|
+
Python type for leaf-related counts and indices in map folding computations.
|
|
42
|
+
|
|
43
|
+
(AI generated docstring)
|
|
44
|
+
|
|
45
|
+
Represents quantities related to individual map sections (leaves), including
|
|
46
|
+
total leaf counts, leaf indices, and dimensional parameters. Uses standard
|
|
47
|
+
Python integers for compatibility with general computations while enabling
|
|
48
|
+
conversion to NumPy types when performance optimization is needed.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
NumPyLeavesTotal: TypeAlias = numpy_uint8
|
|
52
|
+
"""
|
|
53
|
+
NumPy type for efficient leaf-related computations and array operations.
|
|
54
|
+
|
|
55
|
+
(AI generated docstring)
|
|
56
|
+
|
|
57
|
+
Corresponds to `DatatypeLeavesTotal` but optimized for NumPy operations.
|
|
58
|
+
Uses 8-bit unsigned integers since leaf counts in practical map folding
|
|
59
|
+
scenarios typically remain small (under 256).
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
DatatypeElephino: TypeAlias = int
|
|
63
|
+
"""
|
|
64
|
+
Python type for internal computational indices and intermediate values.
|
|
65
|
+
|
|
66
|
+
(AI generated docstring)
|
|
67
|
+
|
|
68
|
+
Used for temporary variables, gap indices, and other internal computational
|
|
69
|
+
state that doesn't directly correspond to leaves or final fold counts. The
|
|
70
|
+
name follows the package convention for internal computational domains.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
NumPyElephino: TypeAlias = numpy_uint16
|
|
74
|
+
"""
|
|
75
|
+
NumPy type for internal computational operations requiring moderate value ranges.
|
|
76
|
+
|
|
77
|
+
(AI generated docstring)
|
|
78
|
+
|
|
79
|
+
Corresponds to `DatatypeElephino` with 16-bit unsigned integer storage,
|
|
80
|
+
providing sufficient range for internal computations while maintaining
|
|
81
|
+
memory efficiency in array operations.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
DatatypeFoldsTotal: TypeAlias = int
|
|
85
|
+
"""
|
|
86
|
+
Python type for final fold counts and pattern totals.
|
|
87
|
+
|
|
88
|
+
(AI generated docstring)
|
|
89
|
+
|
|
90
|
+
Represents the ultimate results of map folding computations - the total number
|
|
91
|
+
of distinct folding patterns possible for a given map configuration. These
|
|
92
|
+
values can grow exponentially with map size, requiring flexible integer types.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
NumPyFoldsTotal: TypeAlias = numpy_uint64
|
|
96
|
+
"""
|
|
97
|
+
NumPy type for large fold count computations and high-precision results.
|
|
98
|
+
|
|
99
|
+
(AI generated docstring)
|
|
100
|
+
|
|
101
|
+
Corresponds to `DatatypeFoldsTotal` using 64-bit unsigned integers to
|
|
102
|
+
accommodate the exponentially large values that can result from map folding
|
|
103
|
+
computations on even moderately-sized maps.
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
Array3D: TypeAlias = ndarray[tuple[int, int, int], dtype[NumPyLeavesTotal]]
|
|
107
|
+
"""
|
|
108
|
+
Three-dimensional NumPy array type for connection graph representations.
|
|
109
|
+
|
|
110
|
+
(AI generated docstring)
|
|
111
|
+
|
|
112
|
+
Used to store the connectivity relationships between map leaves in a
|
|
113
|
+
3D array structure. The array uses `NumPyLeavesTotal` element type since
|
|
114
|
+
the stored values represent leaf indices and connection states.
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
Array1DLeavesTotal: TypeAlias = ndarray[tuple[int], dtype[NumPyLeavesTotal]]
|
|
118
|
+
"""
|
|
119
|
+
One-dimensional NumPy array type for leaf-related data sequences.
|
|
120
|
+
|
|
121
|
+
(AI generated docstring)
|
|
122
|
+
|
|
123
|
+
Stores sequences of leaf counts, indices, or related values in efficient
|
|
124
|
+
array format. Common uses include leaf sequences, gap locations, and
|
|
125
|
+
dimensional data where each element relates to the leaves domain.
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
Array1DElephino: TypeAlias = ndarray[tuple[int], dtype[NumPyElephino]]
|
|
129
|
+
"""
|
|
130
|
+
One-dimensional NumPy array type for internal computational sequences.
|
|
131
|
+
|
|
132
|
+
(AI generated docstring)
|
|
133
|
+
|
|
134
|
+
Used for storing sequences of internal computational values such as
|
|
135
|
+
gap range starts, temporary indices, and other intermediate results
|
|
136
|
+
that require the elephino computational domain's value range.
|
|
137
|
+
"""
|
|
138
|
+
|
|
139
|
+
Array1DFoldsTotal: TypeAlias = ndarray[tuple[int], dtype[NumPyFoldsTotal]]
|
|
140
|
+
"""
|
|
141
|
+
One-dimensional NumPy array type for sequences of fold count results.
|
|
142
|
+
|
|
143
|
+
(AI generated docstring)
|
|
144
|
+
|
|
145
|
+
Stores sequences of fold totals and pattern counts, using the large
|
|
146
|
+
integer type to accommodate the potentially enormous values that
|
|
147
|
+
result from complex map folding computations.
|
|
148
|
+
"""
|
mapFolding/basecamp.py
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
Unified interface for map folding computation orchestration.
|
|
3
|
+
|
|
4
|
+
(AI generated docstring)
|
|
5
|
+
|
|
6
|
+
This module represents the culmination of the computational ecosystem, providing
|
|
7
|
+
the primary entry point where users interact with the complete map folding analysis
|
|
8
|
+
system. It orchestrates all preceding layers: the configuration foundation,
|
|
9
|
+
type system, core utilities, state management, and persistent storage to deliver
|
|
10
|
+
a seamless computational experience.
|
|
11
|
+
|
|
12
|
+
The interface handles multiple computation flows including sequential algorithms,
|
|
13
|
+
experimental task division strategies, and various mathematical theorem implementations.
|
|
14
|
+
It provides flexible parameter validation, computation method selection, task
|
|
15
|
+
division management, processor utilization control, and automatic result persistence.
|
|
16
|
+
Integration with OEIS sequences enables research validation and mathematical
|
|
17
|
+
verification of computed results.
|
|
18
|
+
|
|
19
|
+
Through this unified interface, researchers and practitioners can access the full
|
|
20
|
+
power of Lunnon's algorithm implementation while the underlying computational
|
|
21
|
+
complexity remains elegantly abstracted. The interface ensures that whether
|
|
22
|
+
solving simple 2D problems or complex multi-dimensional challenges, users receive
|
|
23
|
+
consistent, reliable, and efficiently computed folding pattern counts.
|
|
10
24
|
"""
|
|
11
25
|
|
|
12
26
|
from collections.abc import Sequence
|
|
13
27
|
from mapFolding import (
|
|
14
|
-
getPathFilenameFoldsTotal,
|
|
15
|
-
|
|
16
|
-
saveFoldsTotal,
|
|
17
|
-
saveFoldsTotalFAILearly,
|
|
18
|
-
setProcessorLimit,
|
|
19
|
-
validateListDimensions,
|
|
20
|
-
)
|
|
28
|
+
getPathFilenameFoldsTotal, packageSettings, saveFoldsTotal, saveFoldsTotalFAILearly, setProcessorLimit,
|
|
29
|
+
validateListDimensions)
|
|
21
30
|
from os import PathLike
|
|
22
31
|
from pathlib import PurePath
|
|
32
|
+
import contextlib
|
|
23
33
|
|
|
24
|
-
def countFolds(listDimensions: Sequence[int] | None = None
|
|
34
|
+
def countFolds(listDimensions: Sequence[int] | None = None # noqa: C901
|
|
25
35
|
, pathLikeWriteFoldsTotal: PathLike[str] | PurePath | None = None
|
|
26
36
|
, computationDivisions: int | str | None = None
|
|
27
37
|
, CPUlimit: int | float | bool | None = None
|
|
@@ -34,6 +44,8 @@ def countFolds(listDimensions: Sequence[int] | None = None
|
|
|
34
44
|
"""
|
|
35
45
|
Count the total number of possible foldings for a given map dimensions.
|
|
36
46
|
|
|
47
|
+
(AI generated docstring)
|
|
48
|
+
|
|
37
49
|
This function serves as the main public interface to the map folding algorithm, handling all parameter validation,
|
|
38
50
|
computation state management, and result persistence in a user-friendly way.
|
|
39
51
|
|
|
@@ -78,32 +90,33 @@ def countFolds(listDimensions: Sequence[int] | None = None
|
|
|
78
90
|
computation time. If logicalCores >= `leavesTotal`, it will probably be faster. If logicalCores <= 2 * `leavesTotal`, it
|
|
79
91
|
will almost certainly be slower for all map dimensions.
|
|
80
92
|
"""
|
|
81
|
-
# mapShape
|
|
93
|
+
# mapShape ---------------------------------------------------------------------
|
|
82
94
|
|
|
83
95
|
if mapShape:
|
|
84
96
|
pass
|
|
85
97
|
else:
|
|
86
98
|
if oeisID and oeis_n:
|
|
87
|
-
from mapFolding.oeis import settingsOEIS
|
|
88
|
-
|
|
99
|
+
from mapFolding.oeis import settingsOEIS # noqa: PLC0415
|
|
100
|
+
with contextlib.suppress(KeyError):
|
|
89
101
|
mapShape = settingsOEIS[oeisID]['getMapShape'](oeis_n)
|
|
90
|
-
except KeyError:
|
|
91
|
-
pass
|
|
92
102
|
if not mapShape and listDimensions:
|
|
93
103
|
mapShape = validateListDimensions(listDimensions)
|
|
94
104
|
|
|
95
105
|
if mapShape is None:
|
|
96
|
-
|
|
106
|
+
message = (
|
|
107
|
+
f"""I received these values:
|
|
97
108
|
`{listDimensions = }`,
|
|
98
109
|
`{mapShape = }`,
|
|
99
110
|
`{oeisID = }` and `{oeis_n = }`,
|
|
100
|
-
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)
|
|
101
114
|
|
|
102
|
-
# task division instructions
|
|
115
|
+
# task division instructions -----------------------------------------------------
|
|
103
116
|
|
|
104
117
|
if computationDivisions:
|
|
105
118
|
concurrencyLimit: int = setProcessorLimit(CPUlimit, packageSettings.concurrencyPackage)
|
|
106
|
-
from mapFolding.beDRY import getLeavesTotal, getTaskDivisions
|
|
119
|
+
from mapFolding.beDRY import getLeavesTotal, getTaskDivisions # noqa: PLC0415
|
|
107
120
|
leavesTotal: int = getLeavesTotal(mapShape)
|
|
108
121
|
taskDivisions = getTaskDivisions(computationDivisions, concurrencyLimit, leavesTotal)
|
|
109
122
|
del leavesTotal
|
|
@@ -111,7 +124,7 @@ def countFolds(listDimensions: Sequence[int] | None = None
|
|
|
111
124
|
concurrencyLimit = 1
|
|
112
125
|
taskDivisions = 0
|
|
113
126
|
|
|
114
|
-
# memorialization instructions
|
|
127
|
+
# memorialization instructions ---------------------------------------------
|
|
115
128
|
|
|
116
129
|
if pathLikeWriteFoldsTotal is not None:
|
|
117
130
|
pathFilenameFoldsTotal = getPathFilenameFoldsTotal(mapShape, pathLikeWriteFoldsTotal)
|
|
@@ -119,68 +132,70 @@ def countFolds(listDimensions: Sequence[int] | None = None
|
|
|
119
132
|
else:
|
|
120
133
|
pathFilenameFoldsTotal = None
|
|
121
134
|
|
|
122
|
-
# Flow control until I can figure out a good way
|
|
135
|
+
# Flow control until I can figure out a good way ---------------------------------
|
|
123
136
|
|
|
124
137
|
if flow == 'daoOfMapFolding':
|
|
125
|
-
from mapFolding.dataBaskets import MapFoldingState
|
|
138
|
+
from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
|
|
126
139
|
mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
|
|
127
140
|
|
|
128
|
-
from mapFolding.daoOfMapFolding import doTheNeedful
|
|
141
|
+
from mapFolding.daoOfMapFolding import doTheNeedful # noqa: PLC0415
|
|
129
142
|
mapFoldingState = doTheNeedful(mapFoldingState)
|
|
130
143
|
foldsTotal = mapFoldingState.foldsTotal
|
|
131
144
|
|
|
132
|
-
elif flow == 'theorem2' and any(
|
|
133
|
-
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
|
|
134
147
|
mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
|
|
135
148
|
|
|
136
|
-
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds
|
|
149
|
+
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds # noqa: PLC0415
|
|
137
150
|
mapFoldingState = initializeGroupsOfFolds(mapFoldingState)
|
|
138
151
|
|
|
139
|
-
from mapFolding.syntheticModules.theorem2 import count
|
|
152
|
+
from mapFolding.syntheticModules.theorem2 import count # noqa: PLC0415
|
|
140
153
|
mapFoldingState = count(mapFoldingState)
|
|
141
154
|
|
|
142
155
|
foldsTotal = mapFoldingState.foldsTotal
|
|
143
156
|
|
|
144
|
-
elif flow == 'theorem2Trimmed' and any(
|
|
145
|
-
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
|
|
146
159
|
mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
|
|
147
160
|
|
|
148
|
-
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds
|
|
161
|
+
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds # noqa: PLC0415
|
|
149
162
|
mapFoldingState = initializeGroupsOfFolds(mapFoldingState)
|
|
150
163
|
|
|
151
|
-
from mapFolding.syntheticModules.theorem2Trimmed import count
|
|
164
|
+
from mapFolding.syntheticModules.theorem2Trimmed import count # noqa: PLC0415
|
|
152
165
|
mapFoldingState = count(mapFoldingState)
|
|
153
166
|
|
|
154
167
|
foldsTotal = mapFoldingState.foldsTotal
|
|
155
168
|
|
|
156
|
-
elif (flow == 'theorem2Numba' or taskDivisions == 0) and any(
|
|
157
|
-
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
|
|
158
171
|
mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
|
|
159
172
|
|
|
160
|
-
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds
|
|
173
|
+
from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds # noqa: PLC0415
|
|
161
174
|
mapFoldingState = initializeGroupsOfFolds(mapFoldingState)
|
|
162
175
|
|
|
163
|
-
from mapFolding.syntheticModules.dataPacking import sequential
|
|
176
|
+
from mapFolding.syntheticModules.dataPacking import sequential # noqa: PLC0415
|
|
164
177
|
mapFoldingState = sequential(mapFoldingState)
|
|
165
178
|
|
|
166
179
|
foldsTotal = mapFoldingState.foldsTotal
|
|
167
180
|
|
|
168
181
|
elif taskDivisions > 1:
|
|
169
|
-
from mapFolding.dataBaskets import ParallelMapFoldingState
|
|
182
|
+
from mapFolding.dataBaskets import ParallelMapFoldingState # noqa: PLC0415
|
|
170
183
|
parallelMapFoldingState: ParallelMapFoldingState = ParallelMapFoldingState(mapShape, taskDivisions=taskDivisions)
|
|
171
184
|
|
|
172
|
-
from mapFolding.syntheticModules.countParallel import doTheNeedful
|
|
173
|
-
|
|
185
|
+
from mapFolding.syntheticModules.countParallel import doTheNeedful # noqa: PLC0415
|
|
186
|
+
|
|
187
|
+
# `listStatesParallel` exists in case you want to research the parallel computation.
|
|
188
|
+
foldsTotal, listStatesParallel = doTheNeedful(parallelMapFoldingState, concurrencyLimit) # pyright: ignore[reportUnusedVariable]
|
|
174
189
|
|
|
175
190
|
else:
|
|
176
|
-
from mapFolding.dataBaskets import MapFoldingState
|
|
191
|
+
from mapFolding.dataBaskets import MapFoldingState # noqa: PLC0415
|
|
177
192
|
mapFoldingState: MapFoldingState = MapFoldingState(mapShape)
|
|
178
193
|
|
|
179
|
-
from mapFolding.syntheticModules.daoOfMapFolding import doTheNeedful
|
|
194
|
+
from mapFolding.syntheticModules.daoOfMapFolding import doTheNeedful # noqa: PLC0415
|
|
180
195
|
mapFoldingState = doTheNeedful(mapFoldingState)
|
|
181
196
|
foldsTotal = mapFoldingState.foldsTotal
|
|
182
197
|
|
|
183
|
-
# Follow memorialization instructions
|
|
198
|
+
# Follow memorialization instructions ---------------------------------------------
|
|
184
199
|
|
|
185
200
|
if pathFilenameFoldsTotal is not None:
|
|
186
201
|
saveFoldsTotal(pathFilenameFoldsTotal, foldsTotal)
|