mapFolding 0.11.2__tar.gz → 0.11.4__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.
Files changed (64) hide show
  1. {mapfolding-0.11.2 → mapfolding-0.11.4}/PKG-INFO +1 -4
  2. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/__init__.py +0 -13
  3. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/basecamp.py +2 -3
  4. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/beDRY.py +2 -145
  5. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/datatypes.py +0 -3
  6. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/oeis.py +0 -3
  7. mapfolding-0.11.4/mapFolding/someAssemblyRequired/RecipeJob.py +89 -0
  8. mapfolding-0.11.2/mapFolding/someAssemblyRequired/Z0Z_makeSomeModules.py → mapfolding-0.11.4/mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py +109 -114
  9. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/someAssemblyRequired/__init__.py +4 -30
  10. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/someAssemblyRequired/_toolIfThis.py +7 -8
  11. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/someAssemblyRequired/_toolkitContainers.py +9 -129
  12. mapfolding-0.11.4/mapFolding/someAssemblyRequired/infoBooth.py +20 -0
  13. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +17 -18
  14. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/someAssemblyRequired/toolkitNumba.py +4 -46
  15. mapfolding-0.11.4/mapFolding/someAssemblyRequired/transformationTools.py +127 -0
  16. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/theSSOT.py +9 -4
  17. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding.egg-info/PKG-INFO +1 -4
  18. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding.egg-info/SOURCES.txt +2 -5
  19. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding.egg-info/requires.txt +0 -3
  20. {mapfolding-0.11.2 → mapfolding-0.11.4}/pyproject.toml +1 -4
  21. {mapfolding-0.11.2 → mapfolding-0.11.4}/tests/conftest.py +2 -77
  22. {mapfolding-0.11.2 → mapfolding-0.11.4}/tests/test_computations.py +11 -18
  23. {mapfolding-0.11.2 → mapfolding-0.11.4}/tests/test_tasks.py +2 -1
  24. mapfolding-0.11.2/mapFolding/infoBooth.py +0 -96
  25. mapfolding-0.11.2/mapFolding/someAssemblyRequired/RecipeJob.py +0 -196
  26. mapfolding-0.11.2/mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +0 -315
  27. mapfolding-0.11.2/mapFolding/someAssemblyRequired/transformationTools.py +0 -297
  28. mapfolding-0.11.2/mapFolding/syntheticModules/numbaCount.py +0 -202
  29. mapfolding-0.11.2/mapFolding/theDao.py +0 -243
  30. {mapfolding-0.11.2 → mapfolding-0.11.4}/LICENSE +0 -0
  31. {mapfolding-0.11.2 → mapfolding-0.11.4}/README.md +0 -0
  32. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/daoOfMapFolding.py +0 -0
  33. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/dataBaskets.py +0 -0
  34. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/filesystemToolkit.py +0 -0
  35. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/py.typed +0 -0
  36. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/reference/__init__.py +0 -0
  37. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/reference/flattened.py +0 -0
  38. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/reference/hunterNumba.py +0 -0
  39. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/reference/irvineJavaPort.py +0 -0
  40. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/reference/jaxCount.py +0 -0
  41. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/reference/jobsCompleted/[2x19]/p2x19.py +0 -0
  42. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/reference/jobsCompleted/__init__.py +0 -0
  43. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/reference/jobsCompleted/p2x19/p2x19.py +0 -0
  44. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/reference/lunnonNumpy.py +0 -0
  45. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/reference/lunnonWhile.py +0 -0
  46. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/reference/rotatedEntryPoint.py +0 -0
  47. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
  48. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/someAssemblyRequired/getLLVMforNoReason.py +0 -0
  49. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/syntheticModules/__init__.py +0 -0
  50. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/syntheticModules/countParallel.py +0 -0
  51. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/syntheticModules/daoOfMapFolding.py +0 -0
  52. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/syntheticModules/dataPacking.py +0 -0
  53. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/syntheticModules/initializeCount.py +0 -0
  54. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/syntheticModules/theorem2.py +0 -0
  55. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/syntheticModules/theorem2Numba.py +0 -0
  56. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding/syntheticModules/theorem2Trimmed.py +0 -0
  57. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding.egg-info/dependency_links.txt +0 -0
  58. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding.egg-info/entry_points.txt +0 -0
  59. {mapfolding-0.11.2 → mapfolding-0.11.4}/mapFolding.egg-info/top_level.txt +0 -0
  60. {mapfolding-0.11.2 → mapfolding-0.11.4}/setup.cfg +0 -0
  61. {mapfolding-0.11.2 → mapfolding-0.11.4}/tests/__init__.py +0 -0
  62. {mapfolding-0.11.2 → mapfolding-0.11.4}/tests/test_filesystem.py +0 -0
  63. {mapfolding-0.11.2 → mapfolding-0.11.4}/tests/test_oeis.py +0 -0
  64. {mapfolding-0.11.2 → mapfolding-0.11.4}/tests/test_other.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mapFolding
3
- Version: 0.11.2
3
+ Version: 0.11.4
4
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
@@ -33,8 +33,6 @@ Description-Content-Type: text/markdown
33
33
  License-File: LICENSE
34
34
  Requires-Dist: astToolkit
35
35
  Requires-Dist: autoflake
36
- Requires-Dist: cytoolz
37
- Requires-Dist: more_itertools
38
36
  Requires-Dist: numba_progress
39
37
  Requires-Dist: numba
40
38
  Requires-Dist: numpy
@@ -42,7 +40,6 @@ Requires-Dist: platformdirs
42
40
  Requires-Dist: python_minifier
43
41
  Requires-Dist: sympy
44
42
  Requires-Dist: tomli
45
- Requires-Dist: typeshed_client
46
43
  Requires-Dist: Z0Z_tools
47
44
  Provides-Extra: testing
48
45
  Requires-Dist: mypy; extra == "testing"
@@ -33,29 +33,16 @@ from mapFolding.datatypes import (
33
33
  from mapFolding.theSSOT import PackageSettings as PackageSettings, packageSettings as packageSettings
34
34
 
35
35
  from mapFolding.beDRY import (
36
- ComputationState as ComputationState,
37
36
  getConnectionGraph as getConnectionGraph,
38
37
  getLeavesTotal as getLeavesTotal,
39
38
  getTaskDivisions as getTaskDivisions,
40
39
  makeDataContainer as makeDataContainer,
41
- outfitCountFolds as outfitCountFolds,
42
40
  setProcessorLimit as setProcessorLimit,
43
41
  validateListDimensions as validateListDimensions,
44
42
  )
45
43
 
46
44
  from mapFolding.dataBaskets import MapFoldingState as MapFoldingState
47
45
 
48
- from mapFolding.infoBooth import (
49
- PackageInformation as PackageInformation,
50
- raiseIfNoneGitHubIssueNumber3 as raiseIfNoneGitHubIssueNumber3,
51
- The as The,
52
- )
53
-
54
- from mapFolding.theDao import (
55
- countInitialize as countInitialize,
56
- doTheNeedful as doTheNeedful,
57
- )
58
-
59
46
  from mapFolding.filesystemToolkit import (
60
47
  getFilenameFoldsTotal as getFilenameFoldsTotal,
61
48
  getPathFilenameFoldsTotal as getPathFilenameFoldsTotal,
@@ -12,10 +12,10 @@ appropriate algorithm implementation, and optional persistence of results.
12
12
  from collections.abc import Sequence
13
13
  from mapFolding import (
14
14
  getPathFilenameFoldsTotal,
15
+ packageSettings,
15
16
  saveFoldsTotal,
16
17
  saveFoldsTotalFAILearly,
17
18
  setProcessorLimit,
18
- The,
19
19
  validateListDimensions,
20
20
  )
21
21
  from os import PathLike
@@ -102,8 +102,7 @@ def countFolds(listDimensions: Sequence[int] | None = None
102
102
  # task division instructions ===============================================
103
103
 
104
104
  if computationDivisions:
105
- # NOTE `The.concurrencyPackage`
106
- concurrencyLimit: int = setProcessorLimit(CPUlimit, The.concurrencyPackage)
105
+ concurrencyLimit: int = setProcessorLimit(CPUlimit, packageSettings.concurrencyPackage)
107
106
  from mapFolding.beDRY import getLeavesTotal, getTaskDivisions
108
107
  leavesTotal: int = getLeavesTotal(mapShape)
109
108
  taskDivisions = getTaskDivisions(computationDivisions, concurrencyLimit, leavesTotal)
@@ -208,150 +208,6 @@ def makeDataContainer(shape: int | tuple[int, ...], datatype: type[NumPyIntegerT
208
208
  """
209
209
  return numpy.zeros(shape, dtype=datatype)
210
210
 
211
-
212
- @dataclasses.dataclass
213
- class ComputationState:
214
- """
215
- Represents the complete state of a map folding computation.
216
-
217
- This dataclass encapsulates all the information required to compute the number of possible ways to fold a map,
218
- including the map dimensions, leaf connections, computation progress, and fold counting. It serves as the central
219
- data structure that flows through the entire computational algorithm.
220
-
221
- Fields are categorized into:
222
- 1. Input parameters (`mapShape`, `leavesTotal`, etc.).
223
- 2. Core computational structures (`connectionGraph`, etc.).
224
- 3. Tracking variables for the folding algorithm state.
225
- 4. Result accumulation fields (`foldsTotal`, `groupsOfFolds`).
226
- """
227
- # NOTE Python is anti-DRY, again, `DatatypeLeavesTotal` metadata needs to match the type
228
- mapShape: tuple[DatatypeLeavesTotal, ...] = dataclasses.field(init=True, metadata={'elementConstructor': 'DatatypeLeavesTotal'})
229
- """Dimensions of the map to be folded, as a tuple of integers."""
230
-
231
- leavesTotal: DatatypeLeavesTotal
232
- """Total number of leaves (unit squares) in the map, equal to the product of all dimensions."""
233
-
234
- taskDivisions: DatatypeLeavesTotal
235
- """Number of parallel tasks to divide the computation into. Zero means sequential computation."""
236
-
237
- concurrencyLimit: DatatypeElephino
238
- """Maximum number of concurrent processes to use during computation."""
239
-
240
- connectionGraph: Array3D = dataclasses.field(init=False, metadata={'dtype': Array3D.__args__[1].__args__[0]}) # pyright: ignore[reportUnknownMemberType, reportAttributeAccessIssue]
241
- """3D array encoding the connections between leaves in all dimensions."""
242
-
243
- dimensionsTotal: DatatypeLeavesTotal = dataclasses.field(init=False)
244
- """Total number of dimensions in the map shape."""
245
-
246
- # I am using `dataclasses.field` metadata and `typeAlias.__args__[1].__args__[0]` to make the code more DRY. https://github.com/hunterhogan/mapFolding/issues/9
247
- countDimensionsGapped: Array1DLeavesTotal = dataclasses.field(default=None, init=True, metadata={'dtype': Array1DLeavesTotal.__args__[1].__args__[0]}) # pyright: ignore[reportAssignmentType, reportAttributeAccessIssue, reportUnknownMemberType]
248
- """Tracks how many dimensions are gapped for each leaf."""
249
-
250
- dimensionsUnconstrained: DatatypeLeavesTotal = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType, reportAttributeAccessIssue, reportUnknownMemberType]
251
- """Number of dimensions that are not constrained in the current folding state."""
252
-
253
- gapRangeStart: Array1DElephino = dataclasses.field(default=None, init=True, metadata={'dtype': Array1DElephino.__args__[1].__args__[0]}) # pyright: ignore[reportAssignmentType, reportAttributeAccessIssue, reportUnknownMemberType]
254
- """Starting index for the gap range for each leaf."""
255
-
256
- gapsWhere: Array1DLeavesTotal = dataclasses.field(default=None, init=True, metadata={'dtype': Array1DLeavesTotal.__args__[1].__args__[0]}) # pyright: ignore[reportAssignmentType, reportAttributeAccessIssue, reportUnknownMemberType]
257
- """Tracks where gaps occur in the folding pattern."""
258
-
259
- leafAbove: Array1DLeavesTotal = dataclasses.field(default=None, init=True, metadata={'dtype': Array1DLeavesTotal.__args__[1].__args__[0]}) # pyright: ignore[reportAssignmentType, reportAttributeAccessIssue, reportUnknownMemberType]
260
- """For each leaf, stores the index of the leaf above it in the folding pattern."""
261
-
262
- leafBelow: Array1DLeavesTotal = dataclasses.field(default=None, init=True, metadata={'dtype': Array1DLeavesTotal.__args__[1].__args__[0]}) # pyright: ignore[reportAssignmentType, reportAttributeAccessIssue, reportUnknownMemberType]
263
- """For each leaf, stores the index of the leaf below it in the folding pattern."""
264
-
265
- foldGroups: Array1DFoldsTotal = dataclasses.field(default=None, init=True, metadata={'dtype': Array1DFoldsTotal.__args__[1].__args__[0]}) # pyright: ignore[reportAssignmentType, reportAttributeAccessIssue, reportUnknownMemberType]
266
- """Accumulator for fold groups across parallel tasks."""
267
-
268
- foldsTotal: DatatypeFoldsTotal = DatatypeFoldsTotal(0)
269
- """The final computed total number of distinct folding patterns."""
270
-
271
- gap1ndex: DatatypeElephino = DatatypeElephino(0)
272
- """Current index into gaps array during algorithm execution."""
273
-
274
- gap1ndexCeiling: DatatypeElephino = DatatypeElephino(0)
275
- """Upper limit for gap index during the current algorithm phase."""
276
-
277
- groupsOfFolds: DatatypeFoldsTotal = dataclasses.field(default=DatatypeFoldsTotal(0), metadata={'theCountingIdentifier': True})
278
- """Accumulator for the number of fold groups found during computation."""
279
-
280
- indexDimension: DatatypeLeavesTotal = DatatypeLeavesTotal(0)
281
- """Current dimension being processed during algorithm execution."""
282
-
283
- indexLeaf: DatatypeLeavesTotal = DatatypeLeavesTotal(0)
284
- """Current leaf index during iteration."""
285
-
286
- indexMiniGap: DatatypeElephino = DatatypeElephino(0)
287
- """Index used when filtering common gaps."""
288
-
289
- leaf1ndex: DatatypeLeavesTotal = DatatypeLeavesTotal(1)
290
- """Active leaf being processed in the folding algorithm. Starts at 1, not 0."""
291
-
292
- leafConnectee: DatatypeLeavesTotal = DatatypeLeavesTotal(0)
293
- """Leaf that is being connected to the active leaf."""
294
-
295
- taskIndex: DatatypeLeavesTotal = DatatypeLeavesTotal(0)
296
- """Index of the current parallel task when using task divisions."""
297
-
298
- def __post_init__(self) -> None:
299
- from mapFolding.beDRY import getConnectionGraph, makeDataContainer
300
- self.dimensionsTotal = DatatypeLeavesTotal(len(self.mapShape))
301
- leavesTotalAsInt = int(self.leavesTotal)
302
- self.connectionGraph = getConnectionGraph(self.mapShape, leavesTotalAsInt, self.__dataclass_fields__['connectionGraph'].metadata['dtype'])
303
-
304
- if self.dimensionsUnconstrained is None: self.dimensionsUnconstrained = DatatypeLeavesTotal(int(self.dimensionsTotal)) # pyright: ignore[reportUnnecessaryComparison]
305
-
306
- if self.foldGroups is None: # pyright: ignore[reportUnnecessaryComparison]
307
- self.foldGroups = makeDataContainer(max(2, int(self.taskDivisions) + 1), self.__dataclass_fields__['foldGroups'].metadata['dtype'])
308
- self.foldGroups[-1] = self.leavesTotal
309
-
310
- # Dataclasses, Default factories, and arguments in `ComputationState` https://github.com/hunterhogan/mapFolding/issues/12
311
- if self.gapsWhere is None: self.gapsWhere = makeDataContainer(leavesTotalAsInt * leavesTotalAsInt + 1, self.__dataclass_fields__['gapsWhere'].metadata['dtype']) # pyright: ignore[reportUnnecessaryComparison]
312
-
313
- if self.countDimensionsGapped is None: self.countDimensionsGapped = makeDataContainer(leavesTotalAsInt + 1, self.__dataclass_fields__['countDimensionsGapped'].metadata['dtype']) # pyright: ignore[reportUnnecessaryComparison]
314
- if self.gapRangeStart is None: self.gapRangeStart = makeDataContainer(leavesTotalAsInt + 1, self.__dataclass_fields__['gapRangeStart'].metadata['dtype']) # pyright: ignore[reportUnnecessaryComparison]
315
- if self.leafAbove is None: self.leafAbove = makeDataContainer(leavesTotalAsInt + 1, self.__dataclass_fields__['leafAbove'].metadata['dtype']) # pyright: ignore[reportUnnecessaryComparison]
316
- if self.leafBelow is None: self.leafBelow = makeDataContainer(leavesTotalAsInt + 1, self.__dataclass_fields__['leafBelow'].metadata['dtype']) # pyright: ignore[reportUnnecessaryComparison]
317
-
318
- # Automatic, or not, calculation in dataclass `ComputationState` https://github.com/hunterhogan/mapFolding/issues/14
319
- def getFoldsTotal(self) -> None:
320
- self.foldsTotal = DatatypeFoldsTotal(self.foldGroups[0:-1].sum() * self.leavesTotal)
321
-
322
- def outfitCountFolds(mapShape: tuple[int, ...], computationDivisions: int | str | None = None, concurrencyLimit: int = 1) -> ComputationState:
323
- """
324
- Initialize a `ComputationState` with validated parameters for map folding calculation.
325
-
326
- This function serves as the central initialization point for creating a properly configured `ComputationState`
327
- object, ensuring consistent calculation of the fundamental parameters (`leavesTotal` and `taskDivisions`) across the
328
- entire package.
329
-
330
- Parameters
331
- ----------
332
- mapShape
333
- A tuple of integers representing the dimensions of the map.
334
- computationDivisions: None
335
- Controls how to divide the computation into parallel tasks. I know it is annoying, but please see
336
- `countFolds` for details, so that you and I both know you have the most accurate information.
337
- concurrencyLimit: 1
338
- Maximum number of concurrent processes to use during computation.
339
-
340
- Returns
341
- -------
342
- computationStateInitialized
343
- A fully initialized `ComputationState` object that's ready for computation.
344
-
345
- Notes
346
- -----
347
- This function maintains the Single Source of Truth principle for `leavesTotal` and `taskDivisions` calculation,
348
- ensuring these values are derived consistently throughout the package.
349
- """
350
- leavesTotal = getLeavesTotal(mapShape)
351
- taskDivisions = getTaskDivisions(computationDivisions, concurrencyLimit, leavesTotal)
352
- computationStateInitialized = ComputationState(mapShape, leavesTotal, taskDivisions, concurrencyLimit)
353
- return computationStateInitialized
354
-
355
211
  def setProcessorLimit(CPUlimit: Any | None, concurrencyPackage: str | None = None) -> int:
356
212
  """
357
213
  Whether and how to limit the CPU usage.
@@ -392,7 +248,8 @@ def setProcessorLimit(CPUlimit: Any | None, concurrencyPackage: str | None = Non
392
248
 
393
249
  match concurrencyPackage:
394
250
  case 'multiprocessing' | None:
395
- # When to use multiprocessing.set_start_method https://github.com/hunterhogan/mapFolding/issues/6
251
+ # When to use multiprocessing.set_start_method
252
+ # https://github.com/hunterhogan/mapFolding/issues/6
396
253
  concurrencyLimit: int = defineConcurrencyLimit(CPUlimit)
397
254
  case 'numba':
398
255
  from numba import get_num_threads, set_num_threads
@@ -1,9 +1,6 @@
1
1
  from numpy import dtype, uint8 as numpy_uint8, uint16 as numpy_uint16, uint64 as numpy_uint64, integer, ndarray
2
2
  from typing import Any, TypeAlias, TypeVar
3
3
 
4
- # =============================================================================
5
- # Flexible Data Structure System Needs Enhanced Paradigm https://github.com/hunterhogan/mapFolding/issues/9
6
-
7
4
  NumPyIntegerType = TypeVar('NumPyIntegerType', bound=integer[Any], covariant=True)
8
5
 
9
6
  DatatypeLeavesTotal: TypeAlias = int
@@ -144,9 +144,6 @@ def _parseBFileOEIS(OEISbFile: str, oeisID: str) -> dict[int, int]:
144
144
  invalid.
145
145
  """
146
146
  bFileLines: list[str] = OEISbFile.strip().splitlines()
147
- # if not bFileLines.pop(0).startswith(f"# {oeisID}"):
148
- # warnings.warn(f"Content does not match sequence {oeisID}")
149
- # return {-1: -1}
150
147
 
151
148
  OEISsequence: dict[int, int] = {}
152
149
  for line in bFileLines:
@@ -0,0 +1,89 @@
1
+ from astToolkit import parseLogicalPath2astModule, str_nameDOTname
2
+ from mapFolding import getPathFilenameFoldsTotal, getPathRootJobDEFAULT, MapFoldingState, packageSettings
3
+ from mapFolding import DatatypeElephino as TheDatatypeElephino, DatatypeFoldsTotal as TheDatatypeFoldsTotal, DatatypeLeavesTotal as TheDatatypeLeavesTotal
4
+ from mapFolding.someAssemblyRequired import dataclassInstanceIdentifierHardcoded, ShatteredDataclass
5
+ from mapFolding.someAssemblyRequired.transformationTools import shatter_dataclassesDOTdataclass
6
+ from pathlib import Path, PurePosixPath
7
+ from typing import TypeAlias
8
+ import dataclasses
9
+
10
+ @dataclasses.dataclass
11
+ class RecipeJobTheorem2Numba:
12
+ state: MapFoldingState
13
+ # TODO create function to calculate `foldsTotalEstimated`
14
+ foldsTotalEstimated: int = 0
15
+ shatteredDataclass: ShatteredDataclass = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType]
16
+
17
+ # ========================================
18
+ # Source
19
+ source_astModule = parseLogicalPath2astModule('mapFolding.syntheticModules.theorem2Numba')
20
+ sourceCountCallable: str = 'count'
21
+
22
+ sourceLogicalPathModuleDataclass: str_nameDOTname = 'mapFolding.dataBaskets'
23
+ sourceDataclassIdentifier: str = 'MapFoldingState'
24
+ sourceDataclassInstance: str = dataclassInstanceIdentifierHardcoded
25
+
26
+ sourcePathPackage: PurePosixPath | None = PurePosixPath(packageSettings.pathPackage)
27
+ sourcePackageIdentifier: str | None = packageSettings.packageName
28
+
29
+ # ========================================
30
+ # Filesystem (names of physical objects)
31
+ pathPackage: PurePosixPath | None = None
32
+ pathModule: PurePosixPath | None = PurePosixPath(getPathRootJobDEFAULT())
33
+ """ `pathModule` will override `pathPackage` and `logicalPathRoot`."""
34
+ fileExtension: str = packageSettings.fileExtension
35
+ pathFilenameFoldsTotal: PurePosixPath = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType]
36
+
37
+ # ========================================
38
+ # Logical identifiers (as opposed to physical identifiers)
39
+ packageIdentifier: str | None = None
40
+ logicalPathRoot: str_nameDOTname | None = None
41
+ """ `logicalPathRoot` likely corresponds to a physical filesystem directory."""
42
+ moduleIdentifier: str = dataclasses.field(default=None, init=True) # pyright: ignore[reportAssignmentType]
43
+ countCallable: str = sourceCountCallable
44
+ dataclassIdentifier: str | None = sourceDataclassIdentifier
45
+ dataclassInstance: str | None = sourceDataclassInstance
46
+ logicalPathModuleDataclass: str_nameDOTname | None = sourceLogicalPathModuleDataclass
47
+
48
+ # ========================================
49
+ # Datatypes
50
+ DatatypeFoldsTotal: TypeAlias = TheDatatypeFoldsTotal
51
+ DatatypeElephino: TypeAlias = TheDatatypeElephino
52
+ DatatypeLeavesTotal: TypeAlias = TheDatatypeLeavesTotal
53
+
54
+ def _makePathFilename(self,
55
+ pathRoot: PurePosixPath | None = None,
56
+ logicalPathINFIX: str_nameDOTname | None = None,
57
+ filenameStem: str | None = None,
58
+ fileExtension: str | None = None,
59
+ ) -> PurePosixPath:
60
+ if pathRoot is None:
61
+ pathRoot = self.pathPackage or PurePosixPath(Path.cwd())
62
+ if logicalPathINFIX:
63
+ whyIsThisStillAThing: list[str] = logicalPathINFIX.split('.')
64
+ pathRoot = pathRoot.joinpath(*whyIsThisStillAThing)
65
+ if filenameStem is None:
66
+ filenameStem = self.moduleIdentifier
67
+ if fileExtension is None:
68
+ fileExtension = self.fileExtension
69
+ filename: str = filenameStem + fileExtension
70
+ return pathRoot.joinpath(filename)
71
+
72
+ @property
73
+ def pathFilenameModule(self) -> PurePosixPath:
74
+ if self.pathModule is None:
75
+ return self._makePathFilename()
76
+ else:
77
+ return self._makePathFilename(pathRoot=self.pathModule, logicalPathINFIX=None)
78
+
79
+ def __post_init__(self):
80
+ pathFilenameFoldsTotal = PurePosixPath(getPathFilenameFoldsTotal(self.state.mapShape))
81
+
82
+ if self.moduleIdentifier is None: # pyright: ignore[reportUnnecessaryComparison]
83
+ self.moduleIdentifier = pathFilenameFoldsTotal.stem
84
+
85
+ if self.pathFilenameFoldsTotal is None: # pyright: ignore[reportUnnecessaryComparison]
86
+ self.pathFilenameFoldsTotal = pathFilenameFoldsTotal
87
+
88
+ if self.shatteredDataclass is None and self.logicalPathModuleDataclass and self.dataclassIdentifier and self.dataclassInstance: # pyright: ignore[reportUnnecessaryComparison]
89
+ self.shatteredDataclass = shatter_dataclassesDOTdataclass(self.logicalPathModuleDataclass, self.dataclassIdentifier, self.dataclassInstance)