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.
Files changed (37) hide show
  1. mapFolding/__init__.py +46 -20
  2. mapFolding/_theSSOT.py +81 -0
  3. mapFolding/_theTypes.py +148 -0
  4. mapFolding/basecamp.py +62 -47
  5. mapFolding/beDRY.py +100 -73
  6. mapFolding/dataBaskets.py +226 -31
  7. mapFolding/filesystemToolkit.py +161 -107
  8. mapFolding/oeis.py +388 -174
  9. mapFolding/reference/flattened.py +1 -1
  10. mapFolding/someAssemblyRequired/RecipeJob.py +146 -20
  11. mapFolding/someAssemblyRequired/__init__.py +60 -38
  12. mapFolding/someAssemblyRequired/_toolIfThis.py +125 -35
  13. mapFolding/someAssemblyRequired/_toolkitContainers.py +125 -44
  14. mapFolding/someAssemblyRequired/getLLVMforNoReason.py +35 -26
  15. mapFolding/someAssemblyRequired/infoBooth.py +37 -2
  16. mapFolding/someAssemblyRequired/makeAllModules.py +785 -0
  17. mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +161 -74
  18. mapFolding/someAssemblyRequired/toolkitNumba.py +218 -36
  19. mapFolding/someAssemblyRequired/transformationTools.py +125 -58
  20. mapfolding-0.12.3.dist-info/METADATA +163 -0
  21. mapfolding-0.12.3.dist-info/RECORD +53 -0
  22. {mapfolding-0.12.1.dist-info → mapfolding-0.12.3.dist-info}/WHEEL +1 -1
  23. tests/__init__.py +28 -44
  24. tests/conftest.py +66 -61
  25. tests/test_computations.py +64 -89
  26. tests/test_filesystem.py +25 -1
  27. tests/test_oeis.py +37 -7
  28. tests/test_other.py +29 -2
  29. tests/test_tasks.py +30 -2
  30. mapFolding/datatypes.py +0 -18
  31. mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py +0 -433
  32. mapFolding/theSSOT.py +0 -34
  33. mapfolding-0.12.1.dist-info/METADATA +0 -184
  34. mapfolding-0.12.1.dist-info/RECORD +0 -53
  35. {mapfolding-0.12.1.dist-info → mapfolding-0.12.3.dist-info}/entry_points.txt +0 -0
  36. {mapfolding-0.12.1.dist-info → mapfolding-0.12.3.dist-info}/licenses/LICENSE +0 -0
  37. {mapfolding-0.12.1.dist-info → mapfolding-0.12.3.dist-info}/top_level.txt +0 -0
@@ -1,88 +1,26 @@
1
- """
2
- Core Algorithm and Module Generation Testing
3
-
4
- This module provides tests for validating algorithm correctness and testing
5
- code generation functionality. It's designed not only to test the package's
6
- functionality but also to serve as a template for users testing their own
7
- custom implementations.
8
-
9
- ## Key Testing Categories
10
-
11
- 1. Algorithm Validation Tests
12
- - `test_algorithmSourceParallel` - Tests the source algorithm in parallel mode
13
- - `test_algorithmSourceSequential` - Tests the source algorithm in sequential mode
14
- - `test_aOFn_calculate_value` - Tests OEIS sequence value calculations
15
-
16
- 2. Synthetic Module Tests
17
- - `test_syntheticParallel` - Tests generated Numba-optimized code in parallel mode
18
- - `test_syntheticSequential` - Tests generated Numba-optimized code in sequential mode
19
-
20
- 3. Job Testing
21
- - `test_writeJobNumba` - Tests job-specific module generation and execution
22
-
23
- ## How to Test Your Custom Implementations
24
-
25
- ### Testing Custom Recipes (RecipeSynthesizeFlow):
26
-
27
- 1. Copy the `syntheticDispatcherFixture` from conftest.py
28
- 2. Modify it to use your custom recipe configuration
29
- 3. Copy and adapt `test_syntheticParallel` and `test_syntheticSequential`
30
-
31
- Example:
32
-
33
- ```python
34
- @pytest.fixture
35
- def myCustomRecipeFixture(useThisDispatcher, pathTmpTesting):
36
- # Create your custom recipe configuration
37
- myRecipe = RecipeSynthesizeFlow(
38
- pathPackage=PurePosixPath(pathTmpTesting.absolute()),
39
- # Add your custom configuration
40
- )
41
-
42
- # Generate the module
43
- makeNumbaFlow(myRecipe)
44
-
45
- # Import and patch the dispatcher
46
- # ... (similar to syntheticDispatcherFixture)
1
+ """Core computational verification and algorithm validation tests.
47
2
 
48
- return customDispatcher
3
+ This module validates the mathematical correctness of map folding computations and
4
+ serves as the primary testing ground for new computational approaches. It's the most
5
+ important module for users who create custom folding algorithms or modify existing ones.
49
6
 
50
- def test_myCustomRecipeParallel(myCustomRecipeFixture, listDimensionsTestParallelization):
51
- # Test with the standardized validation utility
52
- standardizedEqualToCallableReturn(
53
- getFoldsTotalKnown(tuple(listDimensionsTestParallelization)),
54
- countFolds,
55
- listDimensionsTestParallelization,
56
- None,
57
- 'maximum'
58
- )
59
- ```
7
+ The tests here verify that different computational flows produce identical results,
8
+ ensuring mathematical consistency across implementation strategies. This is critical
9
+ for maintaining confidence in results as the codebase evolves and new optimization
10
+ techniques are added.
60
11
 
61
- ### Testing Custom Jobs (RecipeJob):
12
+ Key Testing Areas:
13
+ - Flow control validation across different algorithmic approaches
14
+ - OEIS sequence value verification against known mathematical results
15
+ - Code generation and execution for dynamically created computational modules
16
+ - Numerical accuracy and consistency checks
62
17
 
63
- 1. Copy and adapt `test_writeJobNumba`
64
- 2. Modify it to use your custom job configuration
18
+ For users implementing new computational methods: use the `test_flowControl` pattern
19
+ as a template. It demonstrates how to validate that your algorithm produces results
20
+ consistent with the established mathematical foundation.
65
21
 
66
- Example:
67
-
68
- ```python
69
- def test_myCustomJob(oneTestCuzTestsOverwritingTests, pathFilenameTmpTesting):
70
- # Create your custom job configuration
71
- myJob = RecipeJob(
72
- state=makeInitializedComputationState(validateListDimensions(oneTestCuzTestsOverwritingTests)),
73
- # Add your custom configuration
74
- )
75
-
76
- spices = SpicesJobNumba()
77
- # Customize spices if needed
78
-
79
- # Generate and test the job
80
- makeJobNumba(myJob, spices)
81
- # Test execution similar to test_writeJobNumba
82
- ```
83
-
84
- All tests leverage standardized utilities like `standardizedEqualToCallableReturn`
85
- that provide consistent, informative error messages and simplify test validation.
22
+ The `test_writeJobNumba` function shows how to test dynamically generated code,
23
+ which is useful if you're working with the code synthesis features of the package.
86
24
  """
87
25
 
88
26
  from mapFolding import countFolds, getFoldsTotalKnown, oeisIDfor_n
@@ -91,7 +29,7 @@ from mapFolding.oeis import settingsOEIS
91
29
  from mapFolding.someAssemblyRequired.RecipeJob import RecipeJobTheorem2Numba
92
30
  from mapFolding.syntheticModules.initializeCount import initializeGroupsOfFolds
93
31
  from pathlib import Path, PurePosixPath
94
- from tests.conftest import standardizedEqualToCallableReturn, registrarRecordsTmpObject
32
+ from tests.conftest import registrarRecordsTmpObject, standardizedEqualToCallableReturn
95
33
  from typing import Literal
96
34
  import importlib.util
97
35
  import multiprocessing
@@ -100,20 +38,55 @@ import pytest
100
38
  if __name__ == '__main__':
101
39
  multiprocessing.set_start_method('spawn')
102
40
 
103
- # TODO test synthesis
104
-
105
41
  @pytest.mark.parametrize('flow', ['daoOfMapFolding', 'theorem2', 'theorem2Trimmed', 'theorem2numba'])
106
- def test_flowControl(mapShapeTestCountFolds: tuple[int, ...], flow: Literal['daoOfMapFolding'] | Literal['theorem2'] | Literal['theorem2numba']) -> None:
42
+ def test_flowControl(mapShapeTestCountFolds: tuple[int, ...], flow: Literal['daoOfMapFolding', 'theorem2', 'theorem2numba']) -> None:
43
+ """Validate that different computational flows produce identical results.
44
+
45
+ This is the primary test for ensuring mathematical consistency across different
46
+ algorithmic implementations. When adding a new computational approach, include
47
+ it in the parametrized flow list to verify it produces correct results.
48
+
49
+ The test compares the output of each flow against known correct values from
50
+ OEIS sequences, ensuring that optimization techniques don't compromise accuracy.
51
+ """
107
52
  standardizedEqualToCallableReturn(getFoldsTotalKnown(mapShapeTestCountFolds), countFolds, None, None, None, None, mapShapeTestCountFolds, None, None, flow)
108
53
 
109
54
  def test_aOFn_calculate_value(oeisID: str) -> None:
55
+ """Verify OEIS sequence value calculations against known reference values.
56
+
57
+ (AI generated docstring)
58
+
59
+ Tests the `oeisIDfor_n` function by comparing its calculated output against
60
+ known correct values from the OEIS database. This ensures that sequence
61
+ value computations remain mathematically accurate across code changes.
62
+
63
+ The test iterates through validation test cases defined in `settingsOEIS`
64
+ for the given OEIS sequence identifier, verifying that each computed value
65
+ matches its corresponding known reference value.
66
+
67
+ Parameters
68
+ ----------
69
+ oeisID : str
70
+ The OEIS sequence identifier to test calculations for.
71
+
72
+ """
110
73
  for n in settingsOEIS[oeisID]['valuesTestValidation']:
111
74
  standardizedEqualToCallableReturn(settingsOEIS[oeisID]['valuesKnown'][n], oeisIDfor_n, oeisID, n)
112
75
 
113
76
  @pytest.mark.parametrize('pathFilenameTmpTesting', ['.py'], indirect=True)
114
77
  def test_writeJobNumba(oneTestCuzTestsOverwritingTests: tuple[int, ...], pathFilenameTmpTesting: Path) -> None:
115
- from mapFolding.someAssemblyRequired.toolkitNumba import SpicesJobNumba
116
- from mapFolding.someAssemblyRequired.makeJobTheorem2Numba import makeJobNumba
78
+ """Test dynamic code generation and execution for computational modules.
79
+
80
+ This test validates the package's ability to generate, compile, and execute
81
+ optimized computational code at runtime. It's essential for users working with
82
+ the code synthesis features or implementing custom optimization strategies.
83
+
84
+ The test creates a complete computational module, executes it, and verifies
85
+ that the generated code produces mathematically correct results. This pattern
86
+ can be adapted for testing other dynamically generated computational approaches.
87
+ """
88
+ from mapFolding.someAssemblyRequired.makeJobTheorem2Numba import makeJobNumba # noqa: PLC0415
89
+ from mapFolding.someAssemblyRequired.toolkitNumba import SpicesJobNumba # noqa: PLC0415
117
90
  mapShape = oneTestCuzTestsOverwritingTests
118
91
  state = MapFoldingState(mapShape)
119
92
  state = initializeGroupsOfFolds(state)
@@ -131,12 +104,14 @@ def test_writeJobNumba(oneTestCuzTestsOverwritingTests: tuple[int, ...], pathFil
131
104
 
132
105
  Don_Lapre_Road_to_Self_Improvement = importlib.util.spec_from_file_location("__main__", pathFilenameModule)
133
106
  if Don_Lapre_Road_to_Self_Improvement is None:
134
- raise ImportError(f"Failed to create module specification from {pathFilenameModule}")
107
+ msg = f"Failed to create module specification from {pathFilenameModule}"
108
+ raise ImportError(msg)
135
109
  if Don_Lapre_Road_to_Self_Improvement.loader is None:
136
- raise ImportError(f"Failed to get loader for module {pathFilenameModule}")
110
+ msg = f"Failed to get loader for module {pathFilenameModule}"
111
+ raise ImportError(msg)
137
112
  module = importlib.util.module_from_spec(Don_Lapre_Road_to_Self_Improvement)
138
113
 
139
114
  module.__name__ = "__main__"
140
115
  Don_Lapre_Road_to_Self_Improvement.loader.exec_module(module)
141
116
 
142
- standardizedEqualToCallableReturn(str(getFoldsTotalKnown(oneTestCuzTestsOverwritingTests)), pathFilenameFoldsTotal.read_text().strip)
117
+ standardizedEqualToCallableReturn(str(getFoldsTotalKnown(oneTestCuzTestsOverwritingTests)), pathFilenameFoldsTotal.read_text(encoding="utf-8").strip)
tests/test_filesystem.py CHANGED
@@ -1,5 +1,29 @@
1
+ """File system operations and path management validation.
2
+
3
+ This module tests the package's interaction with the file system, ensuring that
4
+ results are correctly saved, paths are properly constructed, and fallback mechanisms
5
+ work when file operations fail. These tests are essential for maintaining data
6
+ integrity during long-running computations.
7
+
8
+ The file system abstraction allows the package to work consistently across different
9
+ operating systems and storage configurations. These tests verify that abstraction
10
+ works correctly and handles edge cases gracefully.
11
+
12
+ Key Testing Areas:
13
+ - Filename generation following consistent naming conventions
14
+ - Path construction and directory creation
15
+ - Fallback file creation when primary save operations fail
16
+ - Cross-platform path handling
17
+
18
+ Most users won't need to modify these tests unless they're changing how the package
19
+ stores computational results or adding new file formats.
20
+ """
21
+
1
22
  from contextlib import redirect_stdout
2
- from mapFolding import validateListDimensions, getPathRootJobDEFAULT, getPathFilenameFoldsTotal, saveFoldsTotal, getFilenameFoldsTotal
23
+ from mapFolding import (
24
+ getFilenameFoldsTotal, getPathFilenameFoldsTotal, getPathRootJobDEFAULT, saveFoldsTotal,
25
+ validateListDimensions,
26
+ )
3
27
  from pathlib import Path
4
28
  import io
5
29
  import pytest
tests/test_oeis.py CHANGED
@@ -1,5 +1,34 @@
1
+ """OEIS (Online Encyclopedia of Integer Sequences) integration testing.
2
+
3
+ This module validates the package's integration with OEIS, ensuring that sequence
4
+ identification, value retrieval, and caching mechanisms work correctly. The OEIS
5
+ connection provides the mathematical foundation that validates computational results
6
+ against established mathematical knowledge.
7
+
8
+ These tests verify both the technical aspects of OEIS integration (network requests,
9
+ caching, error handling) and the mathematical correctness of sequence identification
10
+ and value mapping.
11
+
12
+ Key Testing Areas:
13
+ - OEIS sequence ID validation and normalization
14
+ - Network request handling and error recovery
15
+ - Local caching of sequence data for offline operation
16
+ - Command-line interface for OEIS sequence queries
17
+ - Mathematical consistency between local computations and OEIS values
18
+
19
+ The caching tests are particularly important for users working in environments with
20
+ limited network access, as they ensure the package can operate effectively offline
21
+ once sequence data has been retrieved.
22
+
23
+ Network error handling tests verify graceful degradation when OEIS is unavailable,
24
+ which is crucial for maintaining package reliability in production environments.
25
+ """
26
+
1
27
  from contextlib import redirect_stdout
2
- from mapFolding.oeis import oeisIDfor_n, getOEISids, clearOEIScache, getOEISidValues, OEIS_for_n, oeisIDsImplemented, settingsOEIS, validateOEISid
28
+ from mapFolding.oeis import (
29
+ clearOEIScache, getOEISids, getOEISidValues, OEIS_for_n, oeisIDfor_n, oeisIDsImplemented,
30
+ settingsOEIS, validateOEISid,
31
+ )
3
32
  from pathlib import Path
4
33
  from tests.conftest import standardizedEqualToCallableReturn, standardizedSystemExit
5
34
  from typing import Any, NoReturn
@@ -58,13 +87,14 @@ def test_clearOEIScache(mock_unlink: unittest.mock.MagicMock, mock_exists: unitt
58
87
  mock_exists.assert_called_once()
59
88
  mock_unlink.assert_not_called()
60
89
 
61
- def testNetworkError(monkeypatch: pytest.MonkeyPatch, pathCacheTesting: Path) -> None:
62
- """Test network error handling."""
63
- def mockUrlopen(*args: Any, **kwargs: Any) -> NoReturn:
64
- raise URLError("Network error")
90
+ # Monkey tests
91
+ # def testNetworkError(monkeypatch: pytest.MonkeyPatch, pathCacheTesting: Path) -> None:
92
+ # """Test network error handling."""
93
+ # def mockUrlopen(*args: Any, **kwargs: Any) -> NoReturn:
94
+ # raise URLError("Network error")
65
95
 
66
- monkeypatch.setattr(urllib.request, 'urlopen', mockUrlopen)
67
- standardizedEqualToCallableReturn(URLError, getOEISidValues, next(iter(settingsOEIS)))
96
+ # monkeypatch.setattr(urllib.request, 'urlopen', mockUrlopen)
97
+ # standardizedEqualToCallableReturn(URLError, getOEISidValues, next(iter(settingsOEIS)))
68
98
 
69
99
  # ===== Command Line Interface Tests =====
70
100
  def testHelpText() -> None:
tests/test_other.py CHANGED
@@ -1,9 +1,36 @@
1
+ """Foundational utilities and data validation testing.
2
+
3
+ This module tests the core utility functions that support the mathematical
4
+ computations but aren't specific to any particular algorithm. These are the
5
+ building blocks that ensure data integrity and proper parameter handling
6
+ throughout the package.
7
+
8
+ The tests here validate fundamental operations like dimension validation,
9
+ processor limit configuration, and basic mathematical utilities. These
10
+ functions form the foundation that other modules build upon.
11
+
12
+ Key Testing Areas:
13
+ - Input validation and sanitization for map dimensions
14
+ - Processor limit configuration for parallel computations
15
+ - Mathematical utility functions from helper modules
16
+ - Edge case handling for boundary conditions
17
+ - Type system validation and error propagation
18
+
19
+ For users extending the package: these tests demonstrate proper input validation
20
+ patterns and show how to handle edge cases gracefully. The parametrized tests
21
+ provide examples of comprehensive boundary testing that you can adapt for your
22
+ own functions.
23
+
24
+ The integration with external utility modules (hunterMakesPy) shows how to test
25
+ dependencies while maintaining clear separation of concerns.
26
+ """
27
+
1
28
  from collections.abc import Callable
29
+ from hunterMakesPy import intInnit
30
+ from hunterMakesPy.pytestForYourUse import PytestFor_intInnit, PytestFor_oopsieKwargsie
2
31
  from mapFolding import getLeavesTotal, setProcessorLimit, validateListDimensions
3
32
  from tests.conftest import standardizedEqualToCallableReturn
4
33
  from typing import Any, Literal
5
- from Z0Z_tools import intInnit
6
- from Z0Z_tools.pytestForYourUse import PytestFor_intInnit, PytestFor_oopsieKwargsie
7
34
  import multiprocessing
8
35
  import numba
9
36
  import pytest
tests/test_tasks.py CHANGED
@@ -1,8 +1,36 @@
1
+ """Parallel processing and task distribution validation.
2
+
3
+ This module tests the package's parallel processing capabilities, ensuring that
4
+ computations can be effectively distributed across multiple processors while
5
+ maintaining mathematical accuracy. These tests are crucial for performance
6
+ optimization and scalability.
7
+
8
+ The task distribution system allows large computational problems to be broken
9
+ down into smaller chunks that can be processed concurrently. These tests verify
10
+ that the distribution logic works correctly and that results remain consistent
11
+ regardless of how the work is divided.
12
+
13
+ Key Testing Areas:
14
+ - Task division strategies for different computational approaches
15
+ - Processor limit configuration and enforcement
16
+ - Parallel execution consistency and correctness
17
+ - Resource management and concurrency control
18
+ - Error handling in multi-process environments
19
+
20
+ For users working with large-scale computations: these tests demonstrate how to
21
+ configure and validate parallel processing setups. The concurrency limit tests
22
+ show how to balance performance with system resource constraints.
23
+
24
+ The multiprocessing configuration (spawn method) is essential for cross-platform
25
+ compatibility and proper resource isolation between test processes.
26
+ """
27
+
1
28
  from collections.abc import Callable
2
- from mapFolding import countFolds, getTaskDivisions, setProcessorLimit, validateListDimensions, getLeavesTotal, getFoldsTotalKnown
29
+ from hunterMakesPy.pytestForYourUse import PytestFor_defineConcurrencyLimit
30
+ from mapFolding import (
31
+ countFolds, getFoldsTotalKnown, getLeavesTotal, getTaskDivisions, setProcessorLimit, validateListDimensions)
3
32
  from tests.conftest import standardizedEqualToCallableReturn
4
33
  from typing import Literal
5
- from Z0Z_tools.pytestForYourUse import PytestFor_defineConcurrencyLimit
6
34
  import multiprocessing
7
35
  import pytest
8
36
 
mapFolding/datatypes.py DELETED
@@ -1,18 +0,0 @@
1
- from numpy import dtype, uint8 as numpy_uint8, uint16 as numpy_uint16, uint64 as numpy_uint64, integer, ndarray
2
- from typing import Any, TypeAlias, TypeVar
3
-
4
- NumPyIntegerType = TypeVar('NumPyIntegerType', bound=integer[Any], covariant=True)
5
-
6
- DatatypeLeavesTotal: TypeAlias = int
7
- NumPyLeavesTotal: TypeAlias = numpy_uint8
8
-
9
- DatatypeElephino: TypeAlias = int
10
- NumPyElephino: TypeAlias = numpy_uint16
11
-
12
- DatatypeFoldsTotal: TypeAlias = int
13
- NumPyFoldsTotal: TypeAlias = numpy_uint64
14
-
15
- Array3D: TypeAlias = ndarray[tuple[int, int, int], dtype[NumPyLeavesTotal]]
16
- Array1DLeavesTotal: TypeAlias = ndarray[tuple[int], dtype[NumPyLeavesTotal]]
17
- Array1DElephino: TypeAlias = ndarray[tuple[int], dtype[NumPyElephino]]
18
- Array1DFoldsTotal: TypeAlias = ndarray[tuple[int], dtype[NumPyFoldsTotal]]