mapFolding 0.12.0__py3-none-any.whl → 0.12.2__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.
Files changed (34) hide show
  1. mapFolding/__init__.py +42 -18
  2. mapFolding/_theSSOT.py +137 -0
  3. mapFolding/basecamp.py +28 -18
  4. mapFolding/beDRY.py +21 -19
  5. mapFolding/dataBaskets.py +170 -18
  6. mapFolding/datatypes.py +109 -1
  7. mapFolding/filesystemToolkit.py +38 -33
  8. mapFolding/oeis.py +209 -93
  9. mapFolding/someAssemblyRequired/RecipeJob.py +120 -9
  10. mapFolding/someAssemblyRequired/__init__.py +35 -38
  11. mapFolding/someAssemblyRequired/_toolIfThis.py +80 -18
  12. mapFolding/someAssemblyRequired/_toolkitContainers.py +123 -45
  13. mapFolding/someAssemblyRequired/infoBooth.py +37 -2
  14. mapFolding/someAssemblyRequired/makeAllModules.py +712 -0
  15. mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +111 -48
  16. mapFolding/someAssemblyRequired/toolkitNumba.py +171 -19
  17. mapFolding/someAssemblyRequired/transformationTools.py +93 -49
  18. mapfolding-0.12.2.dist-info/METADATA +167 -0
  19. mapfolding-0.12.2.dist-info/RECORD +53 -0
  20. {mapfolding-0.12.0.dist-info → mapfolding-0.12.2.dist-info}/WHEEL +1 -1
  21. tests/__init__.py +28 -44
  22. tests/conftest.py +66 -61
  23. tests/test_computations.py +39 -82
  24. tests/test_filesystem.py +25 -1
  25. tests/test_oeis.py +30 -1
  26. tests/test_other.py +27 -0
  27. tests/test_tasks.py +31 -1
  28. mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py +0 -433
  29. mapFolding/theSSOT.py +0 -34
  30. mapfolding-0.12.0.dist-info/METADATA +0 -184
  31. mapfolding-0.12.0.dist-info/RECORD +0 -53
  32. {mapfolding-0.12.0.dist-info → mapfolding-0.12.2.dist-info}/entry_points.txt +0 -0
  33. {mapfolding-0.12.0.dist-info → mapfolding-0.12.2.dist-info}/licenses/LICENSE +0 -0
  34. {mapfolding-0.12.0.dist-info → mapfolding-0.12.2.dist-info}/top_level.txt +0 -0
mapFolding/datatypes.py CHANGED
@@ -1,18 +1,126 @@
1
- from numpy import dtype, uint8 as numpy_uint8, uint16 as numpy_uint16, uint64 as numpy_uint64, integer, ndarray
1
+ """
2
+ Type system architecture for map folding computational domains.
3
+
4
+ Building upon the configuration foundation, this module defines the complete type
5
+ hierarchy that ensures type safety and semantic clarity throughout the map folding
6
+ computational framework. The type system recognizes three distinct computational
7
+ domains, each with specific data characteristics and performance requirements
8
+ that emerge from Lunnon's algorithm implementation.
9
+
10
+ The Leaves domain handles map sections, their indices, and dimensional parameters.
11
+ The Elephino domain manages internal computational state, gap calculations, and
12
+ temporary indices used during the recursive folding analysis. The Folds domain
13
+ represents final pattern counts and computation results. Each domain employs both
14
+ Python types for general computation and NumPy types for performance-critical
15
+ array operations.
16
+
17
+ This dual-type strategy enables the core utility functions to operate with type
18
+ safety while maintaining the computational efficiency required for analyzing
19
+ complex multi-dimensional folding patterns. The array types built from these
20
+ base types provide the structured data containers that computational state
21
+ management depends upon.
22
+ """
23
+ from numpy import (
24
+ dtype, integer, ndarray, uint8 as numpy_uint8, uint16 as numpy_uint16, uint64 as numpy_uint64,
25
+ )
2
26
  from typing import Any, TypeAlias, TypeVar
3
27
 
4
28
  NumPyIntegerType = TypeVar('NumPyIntegerType', bound=integer[Any], covariant=True)
29
+ """
30
+ Generic type variable for NumPy integer types used in computational operations.
31
+
32
+ This type variable enables generic programming with NumPy integer types while
33
+ maintaining type safety. It supports covariant relationships between different
34
+ NumPy integer types and their array containers.
35
+ """
5
36
 
6
37
  DatatypeLeavesTotal: TypeAlias = int
38
+ """
39
+ Python type for leaf-related counts and indices in map folding computations.
40
+
41
+ Represents quantities related to individual map sections (leaves), including
42
+ total leaf counts, leaf indices, and dimensional parameters. Uses standard
43
+ Python integers for compatibility with general computations while enabling
44
+ conversion to NumPy types when performance optimization is needed.
45
+ """
46
+
7
47
  NumPyLeavesTotal: TypeAlias = numpy_uint8
48
+ """
49
+ NumPy type for efficient leaf-related computations and array operations.
50
+
51
+ Corresponds to `DatatypeLeavesTotal` but optimized for NumPy operations.
52
+ Uses 8-bit unsigned integers since leaf counts in practical map folding
53
+ scenarios typically remain small (under 256).
54
+ """
8
55
 
9
56
  DatatypeElephino: TypeAlias = int
57
+ """
58
+ Python type for internal computational indices and intermediate values.
59
+
60
+ Used for temporary variables, gap indices, and other internal computational
61
+ state that doesn't directly correspond to leaves or final fold counts. The
62
+ name follows the package convention for internal computational domains.
63
+ """
64
+
10
65
  NumPyElephino: TypeAlias = numpy_uint16
66
+ """
67
+ NumPy type for internal computational operations requiring moderate value ranges.
68
+
69
+ Corresponds to `DatatypeElephino` with 16-bit unsigned integer storage,
70
+ providing sufficient range for internal computations while maintaining
71
+ memory efficiency in array operations.
72
+ """
11
73
 
12
74
  DatatypeFoldsTotal: TypeAlias = int
75
+ """
76
+ Python type for final fold counts and pattern totals.
77
+
78
+ Represents the ultimate results of map folding computations - the total number
79
+ of distinct folding patterns possible for a given map configuration. These
80
+ values can grow exponentially with map size, requiring flexible integer types.
81
+ """
82
+
13
83
  NumPyFoldsTotal: TypeAlias = numpy_uint64
84
+ """
85
+ NumPy type for large fold count computations and high-precision results.
86
+
87
+ Corresponds to `DatatypeFoldsTotal` using 64-bit unsigned integers to
88
+ accommodate the exponentially large values that can result from map folding
89
+ computations on even moderately-sized maps.
90
+ """
14
91
 
15
92
  Array3D: TypeAlias = ndarray[tuple[int, int, int], dtype[NumPyLeavesTotal]]
93
+ """
94
+ Three-dimensional NumPy array type for connection graph representations.
95
+
96
+ Used to store the connectivity relationships between map leaves in a
97
+ 3D array structure. The array uses `NumPyLeavesTotal` element type since
98
+ the stored values represent leaf indices and connection states.
99
+ """
100
+
16
101
  Array1DLeavesTotal: TypeAlias = ndarray[tuple[int], dtype[NumPyLeavesTotal]]
102
+ """
103
+ One-dimensional NumPy array type for leaf-related data sequences.
104
+
105
+ Stores sequences of leaf counts, indices, or related values in efficient
106
+ array format. Common uses include leaf sequences, gap locations, and
107
+ dimensional data where each element relates to the leaves domain.
108
+ """
109
+
17
110
  Array1DElephino: TypeAlias = ndarray[tuple[int], dtype[NumPyElephino]]
111
+ """
112
+ One-dimensional NumPy array type for internal computational sequences.
113
+
114
+ Used for storing sequences of internal computational values such as
115
+ gap range starts, temporary indices, and other intermediate results
116
+ that require the elephino computational domain's value range.
117
+ """
118
+
18
119
  Array1DFoldsTotal: TypeAlias = ndarray[tuple[int], dtype[NumPyFoldsTotal]]
120
+ """
121
+ One-dimensional NumPy array type for sequences of fold count results.
122
+
123
+ Stores sequences of fold totals and pattern counts, using the large
124
+ integer type to accommodate the potentially enormous values that
125
+ result from complex map folding computations.
126
+ """
@@ -1,26 +1,24 @@
1
1
  """
2
- Filesystem utilities for managing map folding computation results.
3
-
4
- This module provides functions for standardized handling of files related to the mapFolding package, with a focus on
5
- saving, retrieving, and naming computation results. It implements consistent naming conventions and path resolution
6
- strategies to ensure that:
7
-
8
- 1. Computation results are stored in a predictable location.
9
- 2. Filenames follow a consistent pattern based on map dimensions.
10
- 3. Results can be reliably retrieved for future reference.
11
- 4. The system handles file operations safely with appropriate error handling.
12
-
13
- The module serves as the standardized interface between the computational components of the package and the filesystem,
14
- abstracting away the details of file operations and path management. It provides robust fallback mechanisms to preserve
15
- computation results even in the face of filesystem errors, which is critical for long-running computations that may take
16
- days to complete.
17
-
18
- The functions here adhere to a consistent approach to path handling:
19
- - Cross-platform compatibility through the use of `pathlib`.
20
- - Default locations determined intelligently based on the runtime environment.
21
- - Progressive fallback strategies for saving critical computation results.
22
- - Preemptive filesystem validation to detect issues before computation begins.
2
+ Persistent storage infrastructure for map folding computation results.
3
+
4
+ As computational state management orchestrates the complex recursive analysis,
5
+ this module ensures that the valuable results of potentially multi-day computations
6
+ are safely preserved and reliably retrievable. Map folding problems can require
7
+ extensive computational time, making robust result persistence critical for
8
+ practical research and application.
9
+
10
+ The storage system provides standardized filename generation, platform-independent
11
+ path resolution, and multiple fallback strategies to prevent data loss. Special
12
+ attention is given to environments like Google Colab and cross-platform deployment
13
+ scenarios. The storage patterns integrate with the configuration foundation to
14
+ provide consistent behavior across different installation contexts.
15
+
16
+ This persistence layer serves as the crucial bridge between the computational
17
+ framework and the user interface, ensuring that computation results are available
18
+ for the main interface to retrieve, validate, and present to users seeking
19
+ solutions to their map folding challenges.
23
20
  """
21
+
24
22
  from mapFolding import packageSettings
25
23
  from os import PathLike
26
24
  from pathlib import Path, PurePath
@@ -58,10 +56,9 @@ def getPathFilenameFoldsTotal(mapShape: tuple[int, ...], pathLikeWriteFoldsTotal
58
56
 
59
57
  This function resolves paths for storing computation results, handling different input types including directories,
60
58
  absolute paths, or relative paths. It ensures that all parent directories exist in the resulting path.
61
-
62
59
  Parameters:
63
- mapShape: List of dimensions for the map folding problem.
64
- pathLikeWriteFoldsTotal (getPathJobRootDEFAULT): Path, filename, or relative path and filename. If None, uses
60
+ mapShape: A sequence of integers representing the map dimensions.
61
+ pathLikeWriteFoldsTotal (getPathRootJobDEFAULT): Path, filename, or relative path and filename. If None, uses
65
62
  default path. If a directory, appends standardized filename.
66
63
 
67
64
  Returns:
@@ -109,11 +106,19 @@ def getPathRootJobDEFAULT() -> Path:
109
106
 
110
107
  def _saveFoldsTotal(pathFilename: PathLike[str] | PurePath, foldsTotal: int) -> None:
111
108
  """
112
- Standardized function to save a `foldsTotal` value to a file.
109
+ Internal function to save a `foldsTotal` value to a file.
110
+
111
+ This function provides the core file writing functionality used by the public `saveFoldsTotal` function. It handles
112
+ the basic operations of creating parent directories and writing the integer value as text to the specified file
113
+ location.
113
114
 
114
115
  Parameters:
115
- pathFilename: Path where the `foldsTotal` value should be saved
116
- foldsTotal: The integer value to save
116
+ pathFilename: Path where the `foldsTotal` value should be saved.
117
+ foldsTotal: The integer value to save.
118
+
119
+ Notes:
120
+ This is an internal function that doesn't include error handling or fallback mechanisms. Use `saveFoldsTotal`
121
+ for production code that requires robust error handling.
117
122
  """
118
123
  pathFilenameFoldsTotal = Path(pathFilename)
119
124
  pathFilenameFoldsTotal.parent.mkdir(parents=True, exist_ok=True)
@@ -125,16 +130,16 @@ def saveFoldsTotal(pathFilename: PathLike[str] | PurePath, foldsTotal: int) -> N
125
130
 
126
131
  This function attempts to save the computed `foldsTotal` value to the specified location, with backup strategies in
127
132
  case the primary save attempt fails. The robustness is critical since these computations may take days to complete.
128
-
129
133
  Parameters:
130
- pathFilename: Target save location for the `foldsTotal` value
131
- foldsTotal: The computed value to save
132
-
134
+ pathFilename: Target save location for the `foldsTotal` value.
135
+ foldsTotal: The computed value to save.
133
136
  Notes:
134
137
  If the primary save fails, the function will attempt alternative save methods:
135
138
  1. Print the value prominently to `stdout`.
136
139
  2. Create a fallback file in the current working directory.
137
140
  3. As a last resort, simply print the value.
141
+
142
+ The fallback filename includes a unique identifier based on the value itself to prevent conflicts.
138
143
  """
139
144
  try:
140
145
  _saveFoldsTotal(pathFilename, foldsTotal)
@@ -172,10 +177,10 @@ def saveFoldsTotalFAILearly(pathFilename: PathLike[str] | PurePath) -> None:
172
177
  Raises:
173
178
  FileExistsError: If the target file already exists.
174
179
  FileNotFoundError: If parent directories don't exist or if write tests fail.
175
-
176
180
  Notes:
177
181
  This function helps prevent a situation where a computation runs for hours or days only to discover at the end
178
- that results cannot be saved.
182
+ that results cannot be saved. The test value used is a large integer that exercises both the writing and
183
+ reading mechanisms thoroughly.
179
184
  """
180
185
  if Path(pathFilename).exists():
181
186
  raise FileExistsError(f"`{pathFilename = }` exists: a battle of overwriting might cause tears.")