mapFolding 0.7.0__py3-none-any.whl → 0.8.0__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 (39) hide show
  1. mapFolding/__init__.py +1 -1
  2. mapFolding/basecamp.py +2 -2
  3. mapFolding/beDRY.py +88 -85
  4. mapFolding/filesystem.py +37 -29
  5. mapFolding/noHomeYet.py +2 -2
  6. mapFolding/oeis.py +2 -2
  7. mapFolding/someAssemblyRequired/Z0Z_workbench.py +347 -31
  8. mapFolding/someAssemblyRequired/__init__.py +4 -3
  9. mapFolding/someAssemblyRequired/getLLVMforNoReason.py +0 -1
  10. mapFolding/someAssemblyRequired/ingredientsNumba.py +87 -2
  11. mapFolding/someAssemblyRequired/synthesizeDataConverters.py +34 -52
  12. mapFolding/someAssemblyRequired/{synthesizeNumbaJob.py → synthesizeNumbaJobVESTIGIAL.py} +18 -21
  13. mapFolding/someAssemblyRequired/transformationTools.py +547 -209
  14. mapFolding/syntheticModules/numbaCount_doTheNeedful.py +197 -12
  15. mapFolding/theDao.py +57 -39
  16. mapFolding/theSSOT.py +59 -59
  17. {mapfolding-0.7.0.dist-info → mapfolding-0.8.0.dist-info}/METADATA +6 -7
  18. mapfolding-0.8.0.dist-info/RECORD +41 -0
  19. {mapfolding-0.7.0.dist-info → mapfolding-0.8.0.dist-info}/WHEEL +1 -1
  20. tests/conftest.py +2 -3
  21. tests/test_computations.py +9 -5
  22. tests/test_filesystem.py +0 -2
  23. tests/test_other.py +2 -3
  24. tests/test_tasks.py +7 -5
  25. mapFolding/someAssemblyRequired/synthesizeCountingFunctions.py +0 -7
  26. mapFolding/someAssemblyRequired/synthesizeNumba.py +0 -91
  27. mapFolding/someAssemblyRequired/synthesizeNumbaModules.py +0 -91
  28. mapFolding/someAssemblyRequired/whatWillBe.py +0 -311
  29. mapFolding/syntheticModules/__init__.py +0 -0
  30. mapFolding/syntheticModules/dataNamespaceFlattened.py +0 -30
  31. mapFolding/syntheticModules/numbaCount.py +0 -90
  32. mapFolding/syntheticModules/numbaCountSequential.py +0 -110
  33. mapFolding/syntheticModules/numba_doTheNeedful.py +0 -12
  34. mapfolding-0.7.0.dist-info/RECORD +0 -50
  35. /mapFolding/syntheticModules/{numbaCountExample.py → numbaCountHistoricalExample.py} +0 -0
  36. /mapFolding/syntheticModules/{numba_doTheNeedfulExample.py → numba_doTheNeedfulHistoricalExample.py} +0 -0
  37. {mapfolding-0.7.0.dist-info → mapfolding-0.8.0.dist-info}/LICENSE +0 -0
  38. {mapfolding-0.7.0.dist-info → mapfolding-0.8.0.dist-info}/entry_points.txt +0 -0
  39. {mapfolding-0.7.0.dist-info → mapfolding-0.8.0.dist-info}/top_level.txt +0 -0
@@ -2,8 +2,9 @@
2
2
  from collections.abc import Sequence
3
3
  from typing import Any, cast, TYPE_CHECKING
4
4
  from mapFolding.filesystem import getFilenameFoldsTotal, getPathFilenameFoldsTotal
5
- from mapFolding.someAssemblyRequired import ( ifThis, Make, NodeReplacer, Then, LedgerOfImports, )
6
- from mapFolding.theSSOT import ( ComputationState, FREAKOUT, getPathJobRootDEFAULT, )
5
+ from mapFolding.someAssemblyRequired import ( ifThis, Make, NodeReplacer, Then, )
6
+ from mapFolding.someAssemblyRequired.transformationTools import LedgerOfImports
7
+ from mapFolding.theSSOT import ( ComputationState, raiseIfNoneGitHubIssueNumber3, getPathJobRootDEFAULT, )
7
8
  from os import PathLike
8
9
  from pathlib import Path
9
10
  from types import ModuleType
@@ -16,8 +17,8 @@ import inspect
16
17
  import numpy
17
18
  if TYPE_CHECKING:
18
19
  from mapFolding.someAssemblyRequired.synthesizeDataConverters import makeStateJob
19
- from mapFolding.someAssemblyRequired.synthesizeNumba import thisIsNumbaDotJit, decorateCallableWithNumba
20
- from mapFolding.someAssemblyRequired.whatWillBe import ParametersNumba, Z0Z_getDatatypeModuleScalar, Z0Z_getDecoratorCallable, Z0Z_setDatatypeModuleScalar, Z0Z_setDecoratorCallable, parametersNumbaDEFAULT
20
+ from mapFolding.someAssemblyRequired.ingredientsNumba import thisIsNumbaDotJit, decorateCallableWithNumba
21
+ from mapFolding.someAssemblyRequired.ingredientsNumba import ParametersNumba, parametersNumbaDEFAULT
21
22
 
22
23
  def Z0Z_gamma(FunctionDefTarget: ast.FunctionDef, astAssignee: ast.Name, statement: ast.Assign | ast.stmt, identifier: str, arrayTarget: numpy.ndarray[tuple[int, ...], numpy.dtype[numpy.integer[Any]]], allImports: LedgerOfImports) -> tuple[ast.FunctionDef, LedgerOfImports]:
23
24
  arrayType = type(arrayTarget)
@@ -53,7 +54,7 @@ def insertArrayIn_body(FunctionDefTarget: ast.FunctionDef, identifier: str, arra
53
54
 
54
55
  def findAndReplaceTrackArrayIn_body(FunctionDefTarget: ast.FunctionDef, identifier: str, arrayTarget: numpy.ndarray[tuple[int, ...], numpy.dtype[numpy.integer[Any]]], allImports: LedgerOfImports) -> tuple[ast.FunctionDef, LedgerOfImports]:
55
56
  for statement in FunctionDefTarget.body.copy():
56
- if ifThis.isUnpackingAnArray(identifier)(statement):
57
+ if True:
57
58
  indexAsStr: str = ast.unparse(statement.value.slice) # type: ignore
58
59
  arraySlice: numpy.ndarray[Any, numpy.dtype[numpy.integer[Any]]] = arrayTarget[eval(indexAsStr)]
59
60
  astAssignee: ast.Name = cast(ast.Name, statement.targets[0]) # type: ignore
@@ -62,10 +63,10 @@ def findAndReplaceTrackArrayIn_body(FunctionDefTarget: ast.FunctionDef, identifi
62
63
 
63
64
  def findAndReplaceArraySubscriptIn_body(FunctionDefTarget: ast.FunctionDef, identifier: str, arrayTarget: numpy.ndarray[tuple[int, ...], numpy.dtype[numpy.integer[Any]]], allImports: LedgerOfImports) -> tuple[ast.FunctionDef, LedgerOfImports]:
64
65
  # parameter: I define moduleConstructor
65
- moduleConstructor = Z0Z_getDatatypeModuleScalar()
66
+ moduleConstructor = 'numba'
66
67
 
67
68
  for statement in FunctionDefTarget.body.copy():
68
- if ifThis.isUnpackingAnArray(identifier)(statement):
69
+ if True:
69
70
  indexAsStr: str = ast.unparse(statement.value.slice) # type: ignore
70
71
  arraySlice: numpy.ndarray[Any, numpy.dtype[numpy.integer[Any]]] = arrayTarget[eval(indexAsStr)]
71
72
  astAssignee: ast.Name = cast(ast.Name, statement.targets[0]) # type: ignore
@@ -83,7 +84,7 @@ def findAndReplaceArraySubscriptIn_body(FunctionDefTarget: ast.FunctionDef, iden
83
84
  def removeAssignmentFrom_body(FunctionDefTarget: ast.FunctionDef, identifier: str) -> ast.FunctionDef:
84
85
  FunctionDefSherpa: ast.AST | Sequence[ast.AST] | None = NodeReplacer(ifThis.isAnyAssignmentTo(identifier), Then.removeThis).visit(FunctionDefTarget)
85
86
  if not FunctionDefSherpa:
86
- raise FREAKOUT("Dude, where's my function?")
87
+ raise raiseIfNoneGitHubIssueNumber3("Dude, where's my function?")
87
88
  else:
88
89
  FunctionDefTarget = cast(ast.FunctionDef, FunctionDefSherpa)
89
90
  ast.fix_missing_locations(FunctionDefTarget)
@@ -91,7 +92,7 @@ def removeAssignmentFrom_body(FunctionDefTarget: ast.FunctionDef, identifier: st
91
92
 
92
93
  def findAndReplaceAnnAssignIn_body(FunctionDefTarget: ast.FunctionDef, allImports: LedgerOfImports) -> tuple[ast.FunctionDef, LedgerOfImports]:
93
94
  """Unlike most of the other functions, this is generic: it tries to turn an annotation into a construction call."""
94
- moduleConstructor: str = Z0Z_getDatatypeModuleScalar()
95
+ moduleConstructor: str = 'numba'
95
96
  for stmt in FunctionDefTarget.body.copy():
96
97
  if isinstance(stmt, ast.AnnAssign):
97
98
  if isinstance(stmt.target, ast.Name) and isinstance(stmt.value, ast.Constant):
@@ -141,7 +142,7 @@ def insertReturnStatementIn_body(FunctionDefTarget: ast.FunctionDef, arrayTarget
141
142
 
142
143
  datatype: str = 'Z0Z_identifierCountFolds'
143
144
  FunctionDefTarget.returns = ast.Name(id=datatype, ctx=ast.Load())
144
- datatypeModuleScalar: str = Z0Z_getDatatypeModuleScalar()
145
+ datatypeModuleScalar: str = 'numba'
145
146
  allImports.addImportFromStr(datatypeModuleScalar, datatype)
146
147
 
147
148
  FunctionDefTarget.body.append(returnStatement)
@@ -297,13 +298,13 @@ def writeJobNumba(mapShape: Sequence[int], algorithmSource: ModuleType, callable
297
298
 
298
299
  if not callableTarget:
299
300
  if len(setFunctionDef) == 1:
300
- FunctionDefTarget: ast.FunctionDef | None = setFunctionDef.pop()
301
+ FunctionDefTarget = setFunctionDef.pop()
301
302
  callableTarget = FunctionDefTarget.name
302
303
  else:
303
304
  raise ValueError(f"I did not receive a `callableTarget` and {algorithmSource.__name__=} has more than one callable: {setFunctionDef}. Please select one.")
304
305
  else:
305
306
  listFunctionDefTarget: list[ast.FunctionDef] = [statement for statement in setFunctionDef if statement.name == callableTarget]
306
- FunctionDefTarget = listFunctionDefTarget[0] if listFunctionDefTarget else None
307
+ FunctionDefTarget = listFunctionDefTarget[0] if listFunctionDefTarget else None # type: ignore
307
308
  if not FunctionDefTarget: raise ValueError(f"I received `{callableTarget=}` and {algorithmSource.__name__=}, but I could not find that function in that source.")
308
309
 
309
310
  # NOTE `allImports` is a complementary container to `FunctionDefTarget`; the `FunctionDefTarget` cannot track its own imports very well.
@@ -323,7 +324,7 @@ def writeJobNumba(mapShape: Sequence[int], algorithmSource: ModuleType, callable
323
324
  FunctionDefTarget.args.args.remove(pirateScowl)
324
325
 
325
326
  identifierCounter = 'Z0Z_identifierCountFolds'
326
- astExprIncrementCounter = ast.Expr(value = Make.astCall(Make.nameDOTname(identifierCounter, 'update'), args=[ast.Constant(value=1)], list_astKeywords=[]))
327
+ astExprIncrementCounter = ast.Expr(value = Make.astCall(Make.nameDOTname(identifierCounter, 'update'), listArguments=[ast.Constant(value=1)], list_astKeywords=[]))
327
328
  FunctionDefTarget= cast(ast.FunctionDef, NodeReplacer(ifThis.isAugAssignTo(identifierCounter), Then.replaceWith(astExprIncrementCounter)).visit(FunctionDefTarget))
328
329
  ast.fix_missing_locations(FunctionDefTarget)
329
330
 
@@ -344,7 +345,7 @@ def writeJobNumba(mapShape: Sequence[int], algorithmSource: ModuleType, callable
344
345
 
345
346
  # TODO create function for assigning value to `totalEstimated`
346
347
  totalEstimated: int = Z0Z_totalEstimated
347
- astLauncher: ast.Module = makeLauncherTqdmJobNumba(FunctionDefTarget.name, pathFilenameFoldsTotal, totalEstimated, stateJob.foldGroups[-1])
348
+ astLauncher = makeLauncherTqdmJobNumba(FunctionDefTarget.name, pathFilenameFoldsTotal, totalEstimated, stateJob.foldGroups[-1])
348
349
 
349
350
  allImports.addImportFromStr('numba_progress', 'ProgressBar')
350
351
  allImports.addImportFromStr('numba_progress', 'ProgressBarType')
@@ -361,10 +362,9 @@ def writeJobNumba(mapShape: Sequence[int], algorithmSource: ModuleType, callable
361
362
 
362
363
  FunctionDefTarget, allImports = findAndReplaceAnnAssignIn_body(FunctionDefTarget, allImports)
363
364
  # NOTE add the perfect decorator
364
- FunctionDefTarget, allImports = decorateCallableWithNumba(FunctionDefTarget, allImports, parametersNumba)
365
365
  if thisIsNumbaDotJit(FunctionDefTarget.decorator_list[0]):
366
366
  astCall: ast.Call = cast(ast.Call, FunctionDefTarget.decorator_list[0])
367
- astCall.func = ast.Name(id=Z0Z_getDecoratorCallable(), ctx=ast.Load())
367
+ astCall.func = ast.Name(id='jit', ctx=ast.Load())
368
368
  FunctionDefTarget.decorator_list[0] = astCall
369
369
 
370
370
  # NOTE add imports, make str, remove unused imports
@@ -400,8 +400,8 @@ if __name__ == '__main__':
400
400
  }
401
401
 
402
402
  totalEstimated: int = dictionaryEstimates.get(tuple(mapShape), 10**8)
403
- from mapFolding.syntheticModules import numbaCount
404
- algorithmSource: ModuleType = numbaCount
403
+ from mapFolding.syntheticModules import numbaCount_doTheNeedful
404
+ algorithmSource: ModuleType = numbaCount_doTheNeedful
405
405
 
406
406
  callableTarget = 'countSequential'
407
407
 
@@ -411,7 +411,4 @@ if __name__ == '__main__':
411
411
 
412
412
  pathFilenameWriteJob = None
413
413
 
414
- Z0Z_setDatatypeModuleScalar('numba')
415
- Z0Z_setDecoratorCallable('jit')
416
-
417
414
  writeJobNumba(mapShape, algorithmSource, callableTarget, parametersNumba, pathFilenameWriteJob, Z0Z_totalEstimated=totalEstimated)