mapFolding 0.3.12__py3-none-any.whl → 0.4.1__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 (46) hide show
  1. mapFolding/__init__.py +40 -38
  2. mapFolding/basecamp.py +50 -50
  3. mapFolding/beDRY.py +336 -336
  4. mapFolding/oeis.py +262 -262
  5. mapFolding/reference/flattened.py +294 -293
  6. mapFolding/reference/hunterNumba.py +126 -126
  7. mapFolding/reference/irvineJavaPort.py +99 -99
  8. mapFolding/reference/jax.py +153 -153
  9. mapFolding/reference/lunnan.py +148 -148
  10. mapFolding/reference/lunnanNumpy.py +115 -115
  11. mapFolding/reference/lunnanWhile.py +114 -114
  12. mapFolding/reference/rotatedEntryPoint.py +183 -183
  13. mapFolding/reference/total_countPlus1vsPlusN.py +203 -203
  14. mapFolding/someAssemblyRequired/__init__.py +5 -1
  15. mapFolding/someAssemblyRequired/getLLVMforNoReason.py +12 -12
  16. mapFolding/someAssemblyRequired/makeJob.py +46 -52
  17. mapFolding/someAssemblyRequired/synthesizeModuleJAX.py +17 -17
  18. mapFolding/someAssemblyRequired/synthesizeNumba.py +343 -633
  19. mapFolding/someAssemblyRequired/synthesizeNumbaGeneralized.py +325 -0
  20. mapFolding/someAssemblyRequired/synthesizeNumbaJob.py +173 -0
  21. mapFolding/someAssemblyRequired/synthesizeNumbaModules.py +77 -0
  22. mapFolding/syntheticModules/__init__.py +0 -0
  23. mapFolding/syntheticModules/numba_countInitialize.py +4 -4
  24. mapFolding/syntheticModules/numba_countParallel.py +4 -4
  25. mapFolding/syntheticModules/numba_countSequential.py +4 -4
  26. mapFolding/syntheticModules/numba_doTheNeedful.py +7 -7
  27. mapFolding/theDao.py +165 -165
  28. mapFolding/theSSOT.py +177 -173
  29. mapFolding/theSSOTnumba.py +90 -74
  30. mapFolding-0.4.1.dist-info/METADATA +154 -0
  31. mapFolding-0.4.1.dist-info/RECORD +42 -0
  32. tests/conftest.py +253 -129
  33. tests/test_computations.py +79 -0
  34. tests/test_oeis.py +76 -85
  35. tests/test_other.py +136 -224
  36. tests/test_tasks.py +19 -23
  37. tests/test_types.py +2 -2
  38. mapFolding/someAssemblyRequired/synthesizeNumbaHardcoding.py +0 -188
  39. mapFolding-0.3.12.dist-info/METADATA +0 -155
  40. mapFolding-0.3.12.dist-info/RECORD +0 -40
  41. tests/conftest_tmpRegistry.py +0 -62
  42. tests/conftest_uniformTests.py +0 -53
  43. {mapFolding-0.3.12.dist-info → mapFolding-0.4.1.dist-info}/LICENSE +0 -0
  44. {mapFolding-0.3.12.dist-info → mapFolding-0.4.1.dist-info}/WHEEL +0 -0
  45. {mapFolding-0.3.12.dist-info → mapFolding-0.4.1.dist-info}/entry_points.txt +0 -0
  46. {mapFolding-0.3.12.dist-info → mapFolding-0.4.1.dist-info}/top_level.txt +0 -0
mapFolding/theSSOT.py CHANGED
@@ -2,7 +2,7 @@ from collections import defaultdict
2
2
  from mapFolding.theSSOTnumba import *
3
3
  from numpy import dtype, integer, ndarray
4
4
  from types import ModuleType
5
- from typing import Any, Callable, Dict, Final, Optional, Tuple, Type, TYPE_CHECKING, cast
5
+ from typing import Any, Callable, cast, Dict, Final, Optional, Tuple, Type, TYPE_CHECKING
6
6
  import enum
7
7
  import numba
8
8
  import numpy
@@ -11,14 +11,14 @@ import pathlib
11
11
  import sys
12
12
 
13
13
  try:
14
- from typing import NotRequired
14
+ from typing import NotRequired
15
15
  except ImportError:
16
- from typing_extensions import NotRequired
16
+ from typing_extensions import NotRequired
17
17
 
18
18
  if TYPE_CHECKING:
19
- from typing import TypedDict
19
+ from typing import TypedDict
20
20
  else:
21
- TypedDict = dict
21
+ TypedDict = dict
22
22
 
23
23
  """I have hobbled together:
24
24
  TypedDict, Enum, defaultdict, and lookup dictionaries to make DIY immutability and delayed realization/instantiation.
@@ -39,102 +39,104 @@ And, I almost certainly want to change the semiotics from "authority" (of truth)
39
39
  Here, "power" is a direct analogy to https://hunterthinks.com/opinion/a-hohfeldian-primer.
40
40
  """
41
41
 
42
+ "delay realization/instantiation until a concrete value is desired"
43
+
44
+ "moment of truth: when the value is needed, not when the value is defined"
45
+
46
+ """What is a (not too complicated, integer) datatype?
47
+ - ecosystem/module
48
+ - must apathy|value|list of values
49
+ - mustn't apathy|value|list of values
50
+ - bit width
51
+ - bits maximum apathy|value
52
+ - bits minimum apathy|value
53
+ - magnitude maximum apathy|value
54
+ - ?magnitude minimum apathy|value
55
+ - signedness apathy|non-negative|non-positive|both
56
+ """
57
+
42
58
  myPackageNameIs = "mapFolding"
43
59
 
44
60
  moduleOfSyntheticModules = "syntheticModules"
61
+ formatModuleNameDEFAULT = "numba_{callableTarget}"
45
62
 
46
63
  def getPathPackage() -> pathlib.Path:
47
- import importlib, inspect
48
- pathPackage = pathlib.Path(inspect.getfile(importlib.import_module(myPackageNameIs)))
49
- if pathPackage.is_file():
50
- pathPackage = pathPackage.parent
51
- return pathPackage
64
+ import importlib, inspect
65
+ pathPackage = pathlib.Path(inspect.getfile(importlib.import_module(myPackageNameIs)))
66
+ if pathPackage.is_file():
67
+ pathPackage = pathPackage.parent
68
+ return pathPackage
52
69
 
53
70
  def getPathJobRootDEFAULT() -> pathlib.Path:
54
- if 'google.colab' in sys.modules:
55
- pathJobDEFAULT = pathlib.Path("/content/drive/MyDrive") / "jobs"
56
- else:
57
- pathJobDEFAULT = getPathPackage() / "jobs"
58
- return pathJobDEFAULT
71
+ if 'google.colab' in sys.modules:
72
+ pathJobDEFAULT = pathlib.Path("/content/drive/MyDrive") / "jobs"
73
+ else:
74
+ pathJobDEFAULT = getPathPackage() / "jobs"
75
+ return pathJobDEFAULT
59
76
 
60
77
  def getPathSyntheticModules() -> pathlib.Path:
61
- pathSyntheticModules = getPathPackage() / moduleOfSyntheticModules
62
- return pathSyntheticModules
78
+ pathSyntheticModules = getPathPackage() / moduleOfSyntheticModules
79
+ return pathSyntheticModules
63
80
 
64
81
  def getAlgorithmSource() -> ModuleType:
65
- from mapFolding import theDao
66
- return theDao
82
+ from mapFolding import theDao
83
+ return theDao
67
84
 
68
- def getAlgorithmCallable() -> Callable[..., None]:
69
- algorithmSource = getAlgorithmSource()
70
- return cast(Callable[..., None], algorithmSource.doTheNeedful)
85
+ def getAlgorithmDispatcher() -> Callable[..., None]:
86
+ algorithmSource = getAlgorithmSource()
87
+ return cast(Callable[..., None], algorithmSource.doTheNeedful) # 'doTheNeedful' is duplicated and there is not a SSOT for it
71
88
 
72
89
  def getDispatcherCallable() -> Callable[..., None]:
73
- from mapFolding.syntheticModules import numba_doTheNeedful
74
- return cast(Callable[..., None], numba_doTheNeedful.doTheNeedful)
90
+ from mapFolding.syntheticModules import numba_doTheNeedful
91
+ return cast(Callable[..., None], numba_doTheNeedful.doTheNeedful)
75
92
 
76
93
  # NOTE I want this _concept_, not necessarily this method, to be well implemented and usable everywhere: Python, Numba, Jax, CUDA, idc
77
94
  class computationState(TypedDict):
78
- connectionGraph: ndarray[Tuple[int, int, int], dtype[integer[Any]]]
79
- foldGroups: ndarray[Tuple[int] , dtype[integer[Any]]]
80
- gapsWhere: ndarray[Tuple[int] , dtype[integer[Any]]]
81
- mapShape: ndarray[Tuple[int] , dtype[integer[Any]]]
82
- my: ndarray[Tuple[int] , dtype[integer[Any]]]
83
- track: ndarray[Tuple[int, int] , dtype[integer[Any]]]
95
+ connectionGraph: ndarray[Tuple[int, int, int], dtype[integer[Any]]]
96
+ foldGroups: ndarray[Tuple[int] , dtype[integer[Any]]]
97
+ gapsWhere: ndarray[Tuple[int] , dtype[integer[Any]]]
98
+ mapShape: ndarray[Tuple[int] , dtype[integer[Any]]]
99
+ my: ndarray[Tuple[int] , dtype[integer[Any]]]
100
+ track: ndarray[Tuple[int, int] , dtype[integer[Any]]]
84
101
 
85
102
  @enum.verify(enum.CONTINUOUS, enum.UNIQUE) if sys.version_info >= (3, 11) else lambda x: x
86
103
  class EnumIndices(enum.IntEnum):
87
- """Base class for index enums."""
88
- @staticmethod
89
- def _generate_next_value_(name: str, start: int, count: int, last_values: list[Any]) -> int:
90
- """0-indexed."""
91
- return count
104
+ """Base class for index enums."""
105
+ @staticmethod
106
+ def _generate_next_value_(name: str, start: int, count: int, last_values: list[Any]) -> int:
107
+ """0-indexed."""
108
+ return count
92
109
 
93
- def __index__(self) -> int:
94
- """Adapt enum to the ultra-rare event of indexing a NumPy 'ndarray', which is not the
95
- same as `array.array`. See NumPy.org; I think it will be very popular someday."""
96
- return self.value
110
+ def __index__(self) -> int:
111
+ """Adapt enum to the ultra-rare event of indexing a NumPy 'ndarray', which is not the
112
+ same as `array.array`. See NumPy.org; I think it will be very popular someday."""
113
+ return self.value
97
114
 
98
115
  class indexMy(EnumIndices):
99
- """Indices for scalar values."""
100
- dimensionsTotal = enum.auto()
101
- dimensionsUnconstrained = enum.auto()
102
- gap1ndex = enum.auto()
103
- gap1ndexCeiling = enum.auto()
104
- indexDimension = enum.auto()
105
- indexLeaf = enum.auto()
106
- indexMiniGap = enum.auto()
107
- leaf1ndex = enum.auto()
108
- leafConnectee = enum.auto()
109
- taskDivisions = enum.auto()
110
- taskIndex = enum.auto()
116
+ """Indices for scalar values."""
117
+ dimensionsTotal = enum.auto()
118
+ dimensionsUnconstrained = enum.auto()
119
+ gap1ndex = enum.auto()
120
+ gap1ndexCeiling = enum.auto()
121
+ indexDimension = enum.auto()
122
+ indexLeaf = enum.auto()
123
+ indexMiniGap = enum.auto()
124
+ leaf1ndex = enum.auto()
125
+ leafConnectee = enum.auto()
126
+ taskDivisions = enum.auto()
127
+ taskIndex = enum.auto()
111
128
 
112
129
  class indexTrack(EnumIndices):
113
- """Indices for state tracking array."""
114
- leafAbove = enum.auto()
115
- leafBelow = enum.auto()
116
- countDimensionsGapped = enum.auto()
117
- gapRangeStart = enum.auto()
118
-
119
- "delay realization/instantiation until a concrete value is desired"
120
- "moment of truth: when the value is needed, not when the value is defined"
121
-
122
- """What is a (not too complicated, integer) datatype?
123
- - ecosystem/module
124
- - must apathy|value|list of values
125
- - mustn't apathy|value|list of values
126
- - bit width
127
- - bits maximum apathy|value
128
- - bits minimum apathy|value
129
- - magnitude maximum apathy|value
130
- - ?magnitude minimum apathy|value
131
- - signedness apathy|non-negative|non-positive|both
132
- """
130
+ """Indices for state tracking array."""
131
+ leafAbove = enum.auto()
132
+ leafBelow = enum.auto()
133
+ countDimensionsGapped = enum.auto()
134
+ gapRangeStart = enum.auto()
133
135
 
134
136
  _datatypeDefault: Final[Dict[str, str]] = {
135
- 'elephino': 'uint8',
136
- 'foldsTotal': 'int64',
137
- 'leavesTotal': 'uint8',
137
+ 'elephino': 'uint8',
138
+ 'foldsTotal': 'int64',
139
+ 'leavesTotal': 'uint8',
138
140
  }
139
141
  _datatypeModule = ''
140
142
  _datatypeModuleDEFAULT: Final[str] = 'numpy'
@@ -142,134 +144,136 @@ _datatypeModuleDEFAULT: Final[str] = 'numpy'
142
144
  _datatype: Dict[str, str] = defaultdict(str)
143
145
 
144
146
  def reportDatatypeLimit(identifier: str, datatype: str, sourGrapes: Optional[bool] = False) -> str:
145
- global _datatype
146
- if not _datatype[identifier]:
147
- _datatype[identifier] = datatype
148
- elif _datatype[identifier] == datatype:
149
- pass
150
- elif sourGrapes:
151
- raise Exception(f"Datatype is '{_datatype[identifier]}' not '{datatype}', so you can take your ball and go home.")
152
- return _datatype[identifier]
147
+ global _datatype
148
+ if not _datatype[identifier]:
149
+ _datatype[identifier] = datatype
150
+ elif _datatype[identifier] == datatype:
151
+ pass
152
+ elif sourGrapes:
153
+ raise Exception(f"Datatype is '{_datatype[identifier]}' not '{datatype}', so you can take your ball and go home.")
154
+ return _datatype[identifier]
153
155
 
154
156
  def setDatatypeModule(datatypeModule: str, sourGrapes: Optional[bool] = False) -> str:
155
- global _datatypeModule
156
- if not _datatypeModule:
157
- _datatypeModule = datatypeModule
158
- elif _datatypeModule == datatypeModule:
159
- pass
160
- elif sourGrapes:
161
- raise Exception(f"Datatype module is '{_datatypeModule}' not '{datatypeModule}', so you can take your ball and go home.")
162
- return _datatypeModule
157
+ global _datatypeModule
158
+ if not _datatypeModule:
159
+ _datatypeModule = datatypeModule
160
+ elif _datatypeModule == datatypeModule:
161
+ pass
162
+ elif sourGrapes:
163
+ raise Exception(f"Datatype module is '{_datatypeModule}' not '{datatypeModule}', so you can take your ball and go home.")
164
+ return _datatypeModule
163
165
 
164
166
  def setDatatypeElephino(datatype: str, sourGrapes: Optional[bool] = False) -> str:
165
- return reportDatatypeLimit('elephino', datatype, sourGrapes)
167
+ return reportDatatypeLimit('elephino', datatype, sourGrapes)
166
168
 
167
169
  def setDatatypeFoldsTotal(datatype: str, sourGrapes: Optional[bool] = False) -> str:
168
- return reportDatatypeLimit('foldsTotal', datatype, sourGrapes)
170
+ return reportDatatypeLimit('foldsTotal', datatype, sourGrapes)
169
171
 
170
172
  def setDatatypeLeavesTotal(datatype: str, sourGrapes: Optional[bool] = False) -> str:
171
- return reportDatatypeLimit('leavesTotal', datatype, sourGrapes)
173
+ return reportDatatypeLimit('leavesTotal', datatype, sourGrapes)
172
174
 
173
175
  def _get_datatype(identifier: str) -> str:
174
- global _datatype
175
- if not _datatype[identifier]:
176
- if identifier in indexMy._member_names_:
177
- _datatype[identifier] = _datatypeDefault.get(identifier) or _get_datatype('elephino')
178
- elif identifier in indexTrack._member_names_:
179
- _datatype[identifier] = _datatypeDefault.get(identifier) or _get_datatype('elephino')
180
- else:
181
- _datatype[identifier] = _datatypeDefault.get(identifier) or _get_datatype('foldsTotal')
182
- return _datatype[identifier]
176
+ global _datatype
177
+ if not _datatype[identifier]:
178
+ if identifier in indexMy._member_names_:
179
+ _datatype[identifier] = _datatypeDefault.get(identifier) or _get_datatype('elephino')
180
+ elif identifier in indexTrack._member_names_:
181
+ _datatype[identifier] = _datatypeDefault.get(identifier) or _get_datatype('elephino')
182
+ else:
183
+ _datatype[identifier] = _datatypeDefault.get(identifier) or _get_datatype('foldsTotal')
184
+ return _datatype[identifier]
183
185
 
184
186
  def _getDatatypeModule() -> str:
185
- global _datatypeModule
186
- if not _datatypeModule:
187
- _datatypeModule = _datatypeModuleDEFAULT
188
- return _datatypeModule
187
+ global _datatypeModule
188
+ if not _datatypeModule:
189
+ _datatypeModule = _datatypeModuleDEFAULT
190
+ return _datatypeModule
189
191
 
190
192
  def setInStone(identifier: str) -> Type[Any]:
191
- datatypeModule = _getDatatypeModule()
192
- datatypeStr = _get_datatype(identifier)
193
- return cast(Type[Any], getattr(eval(datatypeModule), datatypeStr))
193
+ datatypeModule = _getDatatypeModule()
194
+ datatypeStr = _get_datatype(identifier)
195
+ return cast(Type[Any], getattr(eval(datatypeModule), datatypeStr))
194
196
 
195
197
  def hackSSOTdtype(identifier: str) -> Type[Any]:
196
- _hackSSOTdtype={
197
- 'connectionGraph': 'dtypeLeavesTotal',
198
- 'dtypeElephino': 'dtypeElephino',
199
- 'dtypeFoldsTotal': 'dtypeFoldsTotal',
200
- 'dtypeLeavesTotal': 'dtypeLeavesTotal',
201
- 'foldGroups': 'dtypeFoldsTotal',
202
- 'gapsWhere': 'dtypeLeavesTotal',
203
- 'mapShape': 'dtypeLeavesTotal',
204
- 'my': 'dtypeElephino',
205
- 'track': 'dtypeElephino',
206
- }
207
- RubeGoldBerg = _hackSSOTdtype[identifier]
208
- if RubeGoldBerg == 'dtypeElephino':
209
- return setInStone('elephino')
210
- elif RubeGoldBerg == 'dtypeFoldsTotal':
211
- return setInStone('foldsTotal')
212
- elif RubeGoldBerg == 'dtypeLeavesTotal':
213
- return setInStone('leavesTotal')
214
- raise Exception("Dude, you forgot to set a value in `hackSSOTdtype`.")
198
+ _hackSSOTdtype={
199
+ 'connectionGraph': 'dtypeLeavesTotal',
200
+ 'dtypeElephino': 'dtypeElephino',
201
+ 'dtypeFoldsTotal': 'dtypeFoldsTotal',
202
+ 'dtypeLeavesTotal': 'dtypeLeavesTotal',
203
+ 'foldGroups': 'dtypeFoldsTotal',
204
+ 'gapsWhere': 'dtypeLeavesTotal',
205
+ 'mapShape': 'dtypeLeavesTotal',
206
+ 'my': 'dtypeElephino',
207
+ 'track': 'dtypeElephino',
208
+ }
209
+ RubeGoldBerg = _hackSSOTdtype[identifier]
210
+ if RubeGoldBerg == 'dtypeElephino':
211
+ return setInStone('elephino')
212
+ elif RubeGoldBerg == 'dtypeFoldsTotal':
213
+ return setInStone('foldsTotal')
214
+ elif RubeGoldBerg == 'dtypeLeavesTotal':
215
+ return setInStone('leavesTotal')
216
+ raise Exception("Dude, you forgot to set a value in `hackSSOTdtype`.")
215
217
 
216
218
  def hackSSOTdatatype(identifier: str) -> str:
217
- _hackSSOTdatatype={
218
- 'connectionGraph': 'datatypeLeavesTotal',
219
- 'countDimensionsGapped': 'datatypeLeavesTotal',
220
- 'datatypeElephino': 'datatypeElephino',
221
- 'datatypeFoldsTotal': 'datatypeFoldsTotal',
222
- 'datatypeLeavesTotal': 'datatypeLeavesTotal',
223
- 'dimensionsTotal': 'datatypeLeavesTotal',
224
- 'dimensionsUnconstrained': 'datatypeLeavesTotal',
225
- 'foldGroups': 'datatypeFoldsTotal',
226
- 'gap1ndex': 'datatypeLeavesTotal',
227
- 'gap1ndexCeiling': 'datatypeElephino',
228
- 'gapRangeStart': 'datatypeElephino',
229
- 'gapsWhere': 'datatypeLeavesTotal',
230
- 'groupsOfFolds': 'datatypeFoldsTotal',
231
- 'indexDimension': 'datatypeLeavesTotal',
232
- 'indexLeaf': 'datatypeLeavesTotal',
233
- 'indexMiniGap': 'datatypeElephino',
234
- 'leaf1ndex': 'datatypeLeavesTotal',
235
- 'leafAbove': 'datatypeLeavesTotal',
236
- 'leafBelow': 'datatypeLeavesTotal',
237
- 'leafConnectee': 'datatypeLeavesTotal',
238
- 'mapShape': 'datatypeLeavesTotal',
239
- 'my': 'datatypeElephino',
240
- 'taskDivisions': 'datatypeLeavesTotal',
241
- 'taskIndex': 'datatypeLeavesTotal',
242
- 'track': 'datatypeElephino',
243
- }
244
- RubeGoldBerg = _hackSSOTdatatype[identifier]
245
- if RubeGoldBerg == 'datatypeElephino':
246
- return _get_datatype('elephino')
247
- elif RubeGoldBerg == 'datatypeFoldsTotal':
248
- return _get_datatype('foldsTotal')
249
- elif RubeGoldBerg == 'datatypeLeavesTotal':
250
- return _get_datatype('leavesTotal')
251
- raise Exception("Dude, you forgot to set a value in `hackSSOTdatatype`.")
219
+ _hackSSOTdatatype={
220
+ 'connectionGraph': 'datatypeLeavesTotal',
221
+ 'countDimensionsGapped': 'datatypeLeavesTotal',
222
+ 'datatypeElephino': 'datatypeElephino',
223
+ 'datatypeFoldsTotal': 'datatypeFoldsTotal',
224
+ 'datatypeLeavesTotal': 'datatypeLeavesTotal',
225
+ 'dimensionsTotal': 'datatypeLeavesTotal',
226
+ 'dimensionsUnconstrained': 'datatypeLeavesTotal',
227
+ 'foldGroups': 'datatypeFoldsTotal',
228
+ 'gap1ndex': 'datatypeLeavesTotal',
229
+ 'gap1ndexCeiling': 'datatypeElephino',
230
+ 'gapRangeStart': 'datatypeElephino',
231
+ 'gapsWhere': 'datatypeLeavesTotal',
232
+ 'groupsOfFolds': 'datatypeFoldsTotal',
233
+ 'indexDimension': 'datatypeLeavesTotal',
234
+ 'indexLeaf': 'datatypeLeavesTotal',
235
+ 'indexMiniGap': 'datatypeElephino',
236
+ 'leaf1ndex': 'datatypeLeavesTotal',
237
+ 'leafAbove': 'datatypeLeavesTotal',
238
+ 'leafBelow': 'datatypeLeavesTotal',
239
+ 'leafConnectee': 'datatypeLeavesTotal',
240
+ 'mapShape': 'datatypeLeavesTotal',
241
+ 'my': 'datatypeElephino',
242
+ 'taskDivisions': 'datatypeLeavesTotal',
243
+ 'taskIndex': 'datatypeLeavesTotal',
244
+ 'track': 'datatypeElephino',
245
+ }
246
+ RubeGoldBerg = _hackSSOTdatatype[identifier]
247
+ if RubeGoldBerg == 'datatypeElephino':
248
+ return _get_datatype('elephino')
249
+ elif RubeGoldBerg == 'datatypeFoldsTotal':
250
+ return _get_datatype('foldsTotal')
251
+ elif RubeGoldBerg == 'datatypeLeavesTotal':
252
+ return _get_datatype('leavesTotal')
253
+ raise Exception("Dude, you forgot to set a value in `hackSSOTdatatype`.")
252
254
 
253
255
  _datatypeModuleScalar = 'numba'
254
256
  _decoratorCallable = 'jit'
255
257
  def Z0Z_getDatatypeModuleScalar() -> str:
256
- return _datatypeModuleScalar
258
+ return _datatypeModuleScalar
257
259
 
258
260
  def Z0Z_setDatatypeModuleScalar(moduleName: str) -> str:
259
- global _datatypeModuleScalar
260
- _datatypeModuleScalar = moduleName
261
- return _datatypeModuleScalar
261
+ global _datatypeModuleScalar
262
+ _datatypeModuleScalar = moduleName
263
+ return _datatypeModuleScalar
262
264
 
263
265
  def Z0Z_getDecoratorCallable() -> str:
264
- return _decoratorCallable
266
+ return _decoratorCallable
265
267
 
266
268
  def Z0Z_setDecoratorCallable(decoratorName: str) -> str:
267
- global _decoratorCallable
268
- _decoratorCallable = decoratorName
269
- return _decoratorCallable
269
+ global _decoratorCallable
270
+ _decoratorCallable = decoratorName
271
+ return _decoratorCallable
270
272
 
271
273
  class FREAKOUT(Exception):
272
- pass
274
+ pass
273
275
 
274
- # This identifier is declared in theDao.py. Two sources of truth is better than 900.
276
+ # The following identifier is declared in theDao.py.
277
+ # TODO Learn how to assign theDao.py the power to set this truth
278
+ # while using theSSOT.py as the SSOT.
275
279
  Z0Z_identifierCountFolds = 'groupsOfFolds'
@@ -4,113 +4,129 @@ from typing import Final, TYPE_CHECKING, Dict, Any, Union, Callable, Tuple, Any
4
4
  import numba
5
5
  import numba.core.compiler
6
6
  try:
7
- from typing import NotRequired
7
+ from typing import NotRequired
8
8
  except ImportError:
9
- from typing_extensions import NotRequired
9
+ from typing_extensions import NotRequired
10
10
 
11
11
  if TYPE_CHECKING:
12
- from typing import TypedDict
12
+ from typing import TypedDict
13
13
  else:
14
- TypedDict = dict
14
+ TypedDict = dict
15
15
 
16
16
  """
17
17
  Old notes that are not entirely accurate.
18
18
 
19
- | **Option** | **Description** | **Why** | **Size** | **But** |
19
+ | **Option** | **Description** | **Why** | **Size** | **But** |
20
20
  | ----------------------- | --------------------------------------------------- | --------------------- | --------------- | ------------------------ |
21
- | `_dbg_extend_lifetimes` | Debug option to extend object lifetimes | Debugging | | |
22
- | `_dbg_optnone` | Disable optimization for debugging | Debugging | | |
23
- | `debug` | Enable debug mode with additional checks | Debugging | | |
24
- | `no_rewrites` | Disable AST rewrites optimization | Debugging | | |
25
- | `boundscheck` | Enable array bounds checking (slows execution) | Error checking | Larger | Slower |
26
- | `error_model` | Divide by zero: kill or chill? | Error checking | ? | |
27
- | `_nrt` | Enable No Runtime type checking | Startup speed | Smaller | No type protection |
28
- | `fastmath` | Reduce float potential precision | Float speed | Smaller | Discriminatory, untested |
29
- | `forceinline` | Force function inlining | Reduce function calls | Likely larger | |
30
- | `forceobj` | Force object mode compilation | Inclusiveness | Larger | Slower execution |
31
- | `inline` | Algorithmically choose inlining | Speed | Slightly larger | |
32
- | `looplift` | Enable loop lifting optimization | Speed (if applicable) | Larger | Exclusionary |
33
- | `no_cfunc_wrapper` | Disable C function wrapper generation | Size | Smaller | Exclusionary |
34
- | `no_cpython_wrapper` | Disable Python C-API wrapper generation | Size | Smallest | Exclusionary |
21
+ | `_dbg_extend_lifetimes` | Debug option to extend object lifetimes | Debugging | | |
22
+ | `_dbg_optnone` | Disable optimization for debugging | Debugging | | |
23
+ | `debug` | Enable debug mode with additional checks | Debugging | | |
24
+ | `no_rewrites` | Disable AST rewrites optimization | Debugging | | |
25
+ | `boundscheck` | Enable array bounds checking (slows execution) | Error checking | Larger | Slower |
26
+ | `error_model` | Divide by zero: kill or chill? | Error checking | ? | |
27
+ | `_nrt` | Enable No Runtime type checking | Startup speed | Smaller | No type protection |
28
+ | `fastmath` | Reduce float potential precision | Float speed | Smaller | Discriminatory, untested |
29
+ | `forceinline` | Force function inlining | Reduce function calls | Likely larger | |
30
+ | `forceobj` | Force object mode compilation | Inclusiveness | Larger | Slower execution |
31
+ | `inline` | Algorithmically choose inlining | Speed | Slightly larger | |
32
+ | `looplift` | Enable loop lifting optimization | Speed (if applicable) | Larger | Exclusionary |
33
+ | `no_cfunc_wrapper` | Disable C function wrapper generation | Size | Smaller | Exclusionary |
34
+ | `no_cpython_wrapper` | Disable Python C-API wrapper generation | Size | Smallest | Exclusionary |
35
35
 
36
36
  """
37
37
  # NOTE Deepseek removed forceinline=True, inline='always'
38
38
  # TODO try to implement all possible parameters, but use `NotRequired` for the more esoteric ones
39
39
  class ParametersNumba(TypedDict):
40
- _dbg_extend_lifetimes: NotRequired[bool]
41
- _dbg_optnone: NotRequired[bool]
42
- _nrt: NotRequired[bool]
43
- boundscheck: NotRequired[bool]
44
- cache: bool
45
- debug: NotRequired[bool]
46
- error_model: str
47
- fastmath: bool
48
- forceinline: bool
49
- forceobj: NotRequired[bool]
50
- inline: str
51
- locals: NotRequired[Dict[str, Any]]
52
- looplift: bool
53
- no_cfunc_wrapper: bool
54
- no_cpython_wrapper: bool
55
- no_rewrites: NotRequired[bool]
56
- nogil: NotRequired[bool]
57
- nopython: bool
58
- parallel: bool
59
- pipeline_class: NotRequired[numba.core.compiler.CompilerBase]
60
- signature_or_function: NotRequired[Union[Any, Callable, str, Tuple]]
61
- target: NotRequired[str]
40
+ _dbg_extend_lifetimes: NotRequired[bool]
41
+ _dbg_optnone: NotRequired[bool]
42
+ _nrt: NotRequired[bool]
43
+ boundscheck: NotRequired[bool]
44
+ cache: bool
45
+ debug: NotRequired[bool]
46
+ error_model: str
47
+ fastmath: bool
48
+ forceinline: bool
49
+ forceobj: NotRequired[bool]
50
+ inline: str
51
+ locals: NotRequired[Dict[str, Any]]
52
+ looplift: bool
53
+ no_cfunc_wrapper: bool
54
+ no_cpython_wrapper: bool
55
+ no_rewrites: NotRequired[bool]
56
+ nogil: NotRequired[bool]
57
+ nopython: bool
58
+ parallel: bool
59
+ pipeline_class: NotRequired[numba.core.compiler.CompilerBase]
60
+ signature_or_function: NotRequired[Union[Any, Callable, str, Tuple]]
61
+ target: NotRequired[str]
62
62
 
63
63
  parametersNumbaFailEarly: Final[ParametersNumba] = {
64
- '_nrt': True,
65
- 'boundscheck': True,
66
- 'cache': True,
67
- 'error_model': 'python',
68
- 'fastmath': False,
69
- 'forceinline': True,
70
- 'inline': 'always',
71
- 'looplift': False,
72
- 'no_cfunc_wrapper': False,
73
- 'no_cpython_wrapper': False,
74
- 'nopython': True,
75
- 'parallel': False,
64
+ '_nrt': True,
65
+ 'boundscheck': True,
66
+ 'cache': True,
67
+ 'error_model': 'python',
68
+ 'fastmath': False,
69
+ 'forceinline': True,
70
+ 'inline': 'always',
71
+ 'looplift': False,
72
+ 'no_cfunc_wrapper': False,
73
+ 'no_cpython_wrapper': False,
74
+ 'nopython': True,
75
+ 'parallel': False,
76
76
  }
77
77
  """For a production function: speed is irrelevant, error discovery is paramount, must be compatible with anything downstream."""
78
78
 
79
79
  parametersNumbaDEFAULT: Final[ParametersNumba] = {
80
- '_nrt': True,
81
- 'boundscheck': False,
82
- 'cache': True,
83
- 'error_model': 'numpy',
84
- 'fastmath': True,
85
- 'forceinline': True,
86
- 'inline': 'always',
87
- 'looplift': False,
88
- 'no_cfunc_wrapper': False,
89
- 'no_cpython_wrapper': False,
90
- 'nopython': True,
91
- 'parallel': False,
80
+ '_nrt': True,
81
+ 'boundscheck': False,
82
+ 'cache': True,
83
+ 'error_model': 'numpy',
84
+ 'fastmath': True,
85
+ 'forceinline': True,
86
+ 'inline': 'always',
87
+ 'looplift': False,
88
+ 'no_cfunc_wrapper': False,
89
+ 'no_cpython_wrapper': False,
90
+ 'nopython': True,
91
+ 'parallel': False,
92
92
  }
93
93
  """Middle of the road: fast, lean, but will talk to non-jitted functions."""
94
94
 
95
95
  parametersNumbaParallelDEFAULT: Final[ParametersNumba] = {
96
- **parametersNumbaDEFAULT,
97
- '_nrt': True,
98
- 'parallel': True,
96
+ **parametersNumbaDEFAULT,
97
+ '_nrt': True,
98
+ 'parallel': True,
99
99
  }
100
100
  """Middle of the road: fast, lean, but will talk to non-jitted functions."""
101
101
 
102
102
  parametersNumbaSuperJit: Final[ParametersNumba] = {
103
- **parametersNumbaDEFAULT,
104
- 'no_cfunc_wrapper': True,
105
- 'no_cpython_wrapper': True,
103
+ **parametersNumbaDEFAULT,
104
+ 'no_cfunc_wrapper': True,
105
+ 'no_cpython_wrapper': True,
106
106
  }
107
107
  """Speed, no helmet, no talking to non-jitted functions."""
108
108
 
109
109
  parametersNumbaSuperJitParallel: Final[ParametersNumba] = {
110
- **parametersNumbaSuperJit,
111
- '_nrt': True,
112
- 'parallel': True,
110
+ **parametersNumbaSuperJit,
111
+ '_nrt': True,
112
+ 'parallel': True,
113
113
  }
114
114
  """Speed, no helmet, concurrency, no talking to non-jitted functions.
115
115
  Claude says, "The NRT is Numba's memory management system that handles memory allocation and deallocation for array operations. Because of array copying, you need to have NRT enabled." IDK which AI assistant autocompleted this, but, "The NRT is a bit slower than the default memory management system, but it's necessary for certain operations."
116
116
  """
117
+
118
+ parametersNumbaMinimum: Final[ParametersNumba] = {
119
+ '_nrt': True,
120
+ 'boundscheck': True,
121
+ 'cache': True,
122
+ 'error_model': 'numpy',
123
+ 'fastmath': True,
124
+ 'forceinline': False,
125
+ 'inline': 'always',
126
+ 'looplift': False,
127
+ 'no_cfunc_wrapper': False,
128
+ 'no_cpython_wrapper': False,
129
+ 'nopython': False,
130
+ 'forceobj': True,
131
+ 'parallel': False,
132
+ }