mapFolding 0.2.5__tar.gz → 0.2.7__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 (40) hide show
  1. {mapfolding-0.2.5 → mapfolding-0.2.7}/PKG-INFO +21 -7
  2. {mapfolding-0.2.5 → mapfolding-0.2.7}/README.md +1 -1
  3. {mapfolding-0.2.5 → mapfolding-0.2.7/mapFolding}/mapFolding.egg-info/PKG-INFO +21 -7
  4. {mapfolding-0.2.5 → mapfolding-0.2.7/mapFolding}/mapFolding.egg-info/SOURCES.txt +6 -17
  5. {mapfolding-0.2.5 → mapfolding-0.2.7/mapFolding}/mapFolding.egg-info/requires.txt +3 -3
  6. mapfolding-0.2.7/mapFolding/mapFolding.egg-info/top_level.txt +4 -0
  7. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/someAssemblyRequired/inlineAfunction.py +3 -3
  8. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/someAssemblyRequired/jobsAndTasks.py +5 -6
  9. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/someAssemblyRequired/makeNumbaJob.py +57 -31
  10. mapfolding-0.2.7/pyproject.toml +75 -0
  11. {mapfolding-0.2.5 → mapfolding-0.2.7}/tests/test_other.py +24 -11
  12. {mapfolding-0.2.5 → mapfolding-0.2.7}/tests/test_tasks.py +7 -8
  13. mapfolding-0.2.5/mapFolding/__init__.py +0 -12
  14. mapfolding-0.2.5/mapFolding/babbage.py +0 -35
  15. mapfolding-0.2.5/mapFolding/beDRY.py +0 -325
  16. mapfolding-0.2.5/mapFolding/importSelector.py +0 -7
  17. mapfolding-0.2.5/mapFolding/lovelace.py +0 -213
  18. mapfolding-0.2.5/mapFolding/oeis.py +0 -323
  19. mapfolding-0.2.5/mapFolding/startHere.py +0 -50
  20. mapfolding-0.2.5/mapFolding/theSSOT.py +0 -75
  21. mapfolding-0.2.5/mapFolding.egg-info/top_level.txt +0 -3
  22. mapfolding-0.2.5/pyproject.toml +0 -46
  23. mapfolding-0.2.5/tests/__init__.py +0 -1
  24. mapfolding-0.2.5/tests/conftest.py +0 -345
  25. mapfolding-0.2.5/tests/pythons_idiotic_namespace.py +0 -1
  26. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/benchmarks/benchmarking.py +0 -0
  27. {mapfolding-0.2.5 → mapfolding-0.2.7/mapFolding}/mapFolding.egg-info/dependency_links.txt +0 -0
  28. {mapfolding-0.2.5 → mapfolding-0.2.7/mapFolding}/mapFolding.egg-info/entry_points.txt +0 -0
  29. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/reference/flattened.py +0 -0
  30. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/reference/hunterNumba.py +0 -0
  31. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/reference/irvineJavaPort.py +0 -0
  32. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/reference/jax.py +0 -0
  33. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/reference/lunnan.py +0 -0
  34. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/reference/lunnanNumpy.py +0 -0
  35. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/reference/lunnanWhile.py +0 -0
  36. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/reference/rotatedEntryPoint.py +0 -0
  37. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
  38. {mapfolding-0.2.5 → mapfolding-0.2.7}/mapFolding/someAssemblyRequired/makeNuitkaSource.py +0 -0
  39. {mapfolding-0.2.5 → mapfolding-0.2.7}/setup.cfg +0 -0
  40. {mapfolding-0.2.5 → mapfolding-0.2.7}/tests/test_oeis.py +0 -0
@@ -1,18 +1,32 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mapFolding
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: Count distinct ways to fold a map (or a strip of stamps)
5
5
  Author-email: Hunter Hogan <HunterHogan@pm.me>
6
- Project-URL: homepage, https://github.com/hunterhogan/mapFolding
7
- Requires-Python: <3.13,>=3.10
6
+ License: CC-BY-NC-4.0
7
+ Project-URL: Homepage, https://github.com/hunterhogan/mapFolding
8
+ Project-URL: Donate, https://www.patreon.com/integrated
9
+ Keywords: A001415,A001416,A001417,A001418,A195646,folding,map folding,OEIS,stamp folding
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Education
13
+ Classifier: Intended Audience :: End Users/Desktop
14
+ Classifier: Intended Audience :: Other Audience
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Natural Language :: English
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: <3.14,>=3.10
8
22
  Description-Content-Type: text/markdown
9
23
  Requires-Dist: numba
10
24
  Requires-Dist: numpy
11
- Requires-Dist: Z0Z-tools
25
+ Requires-Dist: Z0Z_tools
12
26
  Provides-Extra: benchmark
13
- Requires-Dist: pandas; extra == "benchmark"
14
- Requires-Dist: jupyter; extra == "benchmark"
15
27
  Requires-Dist: ipywidgets; extra == "benchmark"
28
+ Requires-Dist: jupyter; extra == "benchmark"
29
+ Requires-Dist: pandas; extra == "benchmark"
16
30
  Requires-Dist: tqdm; extra == "benchmark"
17
31
  Provides-Extra: testing
18
32
  Requires-Dist: pytest; extra == "testing"
@@ -40,7 +54,7 @@ The directory [mapFolding/reference](https://github.com/hunterhogan/mapFolding/b
40
54
 
41
55
  ## Simple, easy usage based on OEIS IDs
42
56
 
43
- `mapFolding` directly implements some IDs from _The On-Line Encyclopedia of Integer Sequences_.
57
+ `mapFolding` directly implements some IDs from _The On-Line Encyclopedia of Integer Sequences_ ([BibTex](https://github.com/hunterhogan/mapFolding/blob/main/mapFolding/citations/oeis.bibtex) citation).
44
58
 
45
59
  ### Usage: command line
46
60
 
@@ -18,7 +18,7 @@ The directory [mapFolding/reference](https://github.com/hunterhogan/mapFolding/b
18
18
 
19
19
  ## Simple, easy usage based on OEIS IDs
20
20
 
21
- `mapFolding` directly implements some IDs from _The On-Line Encyclopedia of Integer Sequences_.
21
+ `mapFolding` directly implements some IDs from _The On-Line Encyclopedia of Integer Sequences_ ([BibTex](https://github.com/hunterhogan/mapFolding/blob/main/mapFolding/citations/oeis.bibtex) citation).
22
22
 
23
23
  ### Usage: command line
24
24
 
@@ -1,18 +1,32 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mapFolding
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: Count distinct ways to fold a map (or a strip of stamps)
5
5
  Author-email: Hunter Hogan <HunterHogan@pm.me>
6
- Project-URL: homepage, https://github.com/hunterhogan/mapFolding
7
- Requires-Python: <3.13,>=3.10
6
+ License: CC-BY-NC-4.0
7
+ Project-URL: Homepage, https://github.com/hunterhogan/mapFolding
8
+ Project-URL: Donate, https://www.patreon.com/integrated
9
+ Keywords: A001415,A001416,A001417,A001418,A195646,folding,map folding,OEIS,stamp folding
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Education
13
+ Classifier: Intended Audience :: End Users/Desktop
14
+ Classifier: Intended Audience :: Other Audience
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Natural Language :: English
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: <3.14,>=3.10
8
22
  Description-Content-Type: text/markdown
9
23
  Requires-Dist: numba
10
24
  Requires-Dist: numpy
11
- Requires-Dist: Z0Z-tools
25
+ Requires-Dist: Z0Z_tools
12
26
  Provides-Extra: benchmark
13
- Requires-Dist: pandas; extra == "benchmark"
14
- Requires-Dist: jupyter; extra == "benchmark"
15
27
  Requires-Dist: ipywidgets; extra == "benchmark"
28
+ Requires-Dist: jupyter; extra == "benchmark"
29
+ Requires-Dist: pandas; extra == "benchmark"
16
30
  Requires-Dist: tqdm; extra == "benchmark"
17
31
  Provides-Extra: testing
18
32
  Requires-Dist: pytest; extra == "testing"
@@ -40,7 +54,7 @@ The directory [mapFolding/reference](https://github.com/hunterhogan/mapFolding/b
40
54
 
41
55
  ## Simple, easy usage based on OEIS IDs
42
56
 
43
- `mapFolding` directly implements some IDs from _The On-Line Encyclopedia of Integer Sequences_.
57
+ `mapFolding` directly implements some IDs from _The On-Line Encyclopedia of Integer Sequences_ ([BibTex](https://github.com/hunterhogan/mapFolding/blob/main/mapFolding/citations/oeis.bibtex) citation).
44
58
 
45
59
  ### Usage: command line
46
60
 
@@ -1,20 +1,12 @@
1
1
  README.md
2
2
  pyproject.toml
3
- mapFolding/__init__.py
4
- mapFolding/babbage.py
5
- mapFolding/beDRY.py
6
- mapFolding/importSelector.py
7
- mapFolding/lovelace.py
8
- mapFolding/oeis.py
9
- mapFolding/startHere.py
10
- mapFolding/theSSOT.py
11
- mapFolding.egg-info/PKG-INFO
12
- mapFolding.egg-info/SOURCES.txt
13
- mapFolding.egg-info/dependency_links.txt
14
- mapFolding.egg-info/entry_points.txt
15
- mapFolding.egg-info/requires.txt
16
- mapFolding.egg-info/top_level.txt
17
3
  mapFolding/benchmarks/benchmarking.py
4
+ mapFolding/mapFolding.egg-info/PKG-INFO
5
+ mapFolding/mapFolding.egg-info/SOURCES.txt
6
+ mapFolding/mapFolding.egg-info/dependency_links.txt
7
+ mapFolding/mapFolding.egg-info/entry_points.txt
8
+ mapFolding/mapFolding.egg-info/requires.txt
9
+ mapFolding/mapFolding.egg-info/top_level.txt
18
10
  mapFolding/reference/flattened.py
19
11
  mapFolding/reference/hunterNumba.py
20
12
  mapFolding/reference/irvineJavaPort.py
@@ -28,9 +20,6 @@ mapFolding/someAssemblyRequired/inlineAfunction.py
28
20
  mapFolding/someAssemblyRequired/jobsAndTasks.py
29
21
  mapFolding/someAssemblyRequired/makeNuitkaSource.py
30
22
  mapFolding/someAssemblyRequired/makeNumbaJob.py
31
- tests/__init__.py
32
- tests/conftest.py
33
- tests/pythons_idiotic_namespace.py
34
23
  tests/test_oeis.py
35
24
  tests/test_other.py
36
25
  tests/test_tasks.py
@@ -1,11 +1,11 @@
1
1
  numba
2
2
  numpy
3
- Z0Z-tools
3
+ Z0Z_tools
4
4
 
5
5
  [benchmark]
6
- pandas
7
- jupyter
8
6
  ipywidgets
7
+ jupyter
8
+ pandas
9
9
  tqdm
10
10
 
11
11
  [testing]
@@ -0,0 +1,4 @@
1
+ benchmarks
2
+ citations
3
+ reference
4
+ someAssemblyRequired
@@ -1,11 +1,11 @@
1
- from mapFolding import indexMy, indexThe, indexTrack
1
+ from mapFolding import indexMy, indexTrack
2
2
  import ast
3
3
  import copy
4
4
  import pathlib
5
5
 
6
6
  def getDictionaryEnumValues():
7
7
  dictionaryEnumValues = {}
8
- for enumIndex in [indexMy, indexThe, indexTrack]:
8
+ for enumIndex in [indexMy, indexTrack]:
9
9
  for memberName, memberValue in enumIndex._member_map_.items():
10
10
  dictionaryEnumValues[f"{enumIndex.__name__}.{memberName}.value"] = memberValue.value
11
11
  return dictionaryEnumValues
@@ -125,7 +125,7 @@ def Z0Z_inlineMapFolding():
125
125
 
126
126
  listPathFilenamesDestination: list[pathlib.Path] = []
127
127
  for callableTarget in listCallables:
128
- pathFilenameDestination = pathFilenameSource.with_stem(callableTarget)
128
+ pathFilenameDestination = pathFilenameSource.parent / "someAssemblyRequired" / pathFilenameSource.with_stem(callableTarget).name
129
129
  codeInlined = inlineFunctions(codeSource, callableTarget, dictionaryEnumValues)
130
130
  pathFilenameDestination.write_text(codeInlined)
131
131
  listPathFilenamesDestination.append(pathFilenameDestination)
@@ -1,10 +1,10 @@
1
- from typing import Any, Optional, Sequence, Type, Union
1
+ from typing import Any, Optional, Sequence, Type
2
2
 
3
3
  def Z0Z_makeJob(listDimensions: Sequence[int], **keywordArguments: Optional[Type[Any]]):
4
4
  from mapFolding import outfitCountFolds
5
5
  stateUniversal = outfitCountFolds(listDimensions, computationDivisions=None, CPUlimit=None, **keywordArguments)
6
- from mapFolding.countInitialize import countInitialize
7
- countInitialize(stateUniversal['connectionGraph'], stateUniversal['gapsWhere'], stateUniversal['my'], stateUniversal['the'], stateUniversal['track'])
6
+ from mapFolding.someAssemblyRequired.countInitializeNoNumba import countInitialize
7
+ countInitialize(stateUniversal['connectionGraph'], stateUniversal['gapsWhere'], stateUniversal['my'], stateUniversal['track'])
8
8
  from mapFolding import getPathFilenameFoldsTotal
9
9
  pathFilenameChopChop = getPathFilenameFoldsTotal(stateUniversal['mapShape'])
10
10
  import pathlib
@@ -35,11 +35,10 @@ def runJob(pathFilename):
35
35
  gapsWhere: numpy.ndarray = stateJob['gapsWhere']
36
36
  my: numpy.ndarray = stateJob['my']
37
37
  pathFilenameFoldsTotal: Final[Path] = stateJob['pathFilenameFoldsTotal']
38
- the: Final[numpy.ndarray] = stateJob['the']
39
38
  track: numpy.ndarray = stateJob['track']
40
39
 
41
- from mapFolding.countSequentialNoNumba import countSequential
42
- countSequential(connectionGraph, foldsSubTotals, gapsWhere, my, the, track)
40
+ from mapFolding.someAssemblyRequired.countSequentialNoNumba import countSequential
41
+ countSequential(connectionGraph, foldsSubTotals, gapsWhere, my, track)
43
42
 
44
43
  print(foldsSubTotals.sum().item())
45
44
  Path(pathFilenameFoldsTotal).parent.mkdir(parents=True, exist_ok=True)
@@ -1,9 +1,12 @@
1
1
  """Create a python module hardcoded to compute a map's foldsTotal.
2
- NumPy ndarray.
3
- Numba optimized.
4
- Absolutely no other imports.
2
+ - NumPy ndarray.
3
+ - Numba optimized.
4
+ - Absolutely no other imports.
5
+
6
+ Can create LLVM IR from the module: of unknown utility.
5
7
  """
6
- from mapFolding import datatypeLarge, dtypeLarge, dtypeDefault
8
+ # from mapFolding import dtypeDefault, dtypeSmall
9
+ from mapFolding import make_dtype, datatypeLarge, dtypeLarge
7
10
  from mapFolding.someAssemblyRequired.inlineAfunction import Z0Z_inlineMapFolding
8
11
  from mapFolding.someAssemblyRequired.jobsAndTasks import Z0Z_makeJob
9
12
  import importlib
@@ -11,30 +14,51 @@ import llvmlite.binding
11
14
  import numpy
12
15
  import pathlib
13
16
  import pickle
17
+ import python_minifier
14
18
 
15
- listDimensions = [3,7]
19
+ listDimensions = [5,5]
16
20
 
17
21
  # NOTE this overwrites files
18
22
  Z0Z_inlineMapFolding()
19
23
 
20
24
  identifierCallableLaunch = "goGoGadgetAbsurdity"
21
25
 
22
- def archivistFormatsArrayToCode(arrayTarget: numpy.ndarray, identifierName: str) -> str:
23
- """Format numpy array into a code string that recreates the array."""
24
- arrayAsTypeStr = numpy.array2string(arrayTarget, threshold=10000, max_line_width=200, separator=',')
25
- return f"{identifierName} = numpy.array({arrayAsTypeStr}, dtype=numpy.{arrayTarget.dtype})"
26
+ def convertNDArrayToStr(arrayTarget: numpy.ndarray, identifierName: str) -> str:
27
+ arrayAsTypeStr = numpy.array2string(arrayTarget, threshold=100000, max_line_width=200, separator=',')
28
+ stringMinimized = python_minifier.minify(arrayAsTypeStr)
29
+ commaZeroMaximum = arrayTarget.shape[-1] - 1
30
+ stringMinimized = stringMinimized.replace('[0' + ',0'*commaZeroMaximum + ']', '[0]*'+str(commaZeroMaximum+1))
31
+ for countZeros in range(commaZeroMaximum, 2, -1):
32
+ stringMinimized = stringMinimized.replace(',0'*countZeros + ']', ']+[0]*'+str(countZeros))
33
+ return f"{identifierName} = numpy.array({stringMinimized}, dtype=numpy.{arrayTarget.dtype})"
26
34
 
27
35
  def writeModuleWithNumba(listDimensions):
28
36
  numpy_dtypeLarge = dtypeLarge
29
- numpy_dtypeDefault = dtypeDefault
30
-
31
- parametersNumba = f"numba.types.{datatypeLarge}(), cache=True, parallel=False, boundscheck=False, \
32
- error_model='numpy', fastmath=True, nogil=True, nopython=True, _nrt=True, forceinline=True, \
33
- inline=True, looplift=True, no_cfunc_wrapper=False, no_cpython_wrapper=False"
34
-
35
- pathFilenameData = Z0Z_makeJob(listDimensions, datatypeDefault=numpy_dtypeDefault, datatypeLarge=numpy_dtypeLarge)
36
-
37
- pathFilenameAlgorithm = pathlib.Path('/apps/mapFolding/mapFolding/countSequentialNoNumba.py')
37
+ # numpy_dtypeDefault = dtypeDefault
38
+ datatypeDefault = 'uint8'
39
+ numpy_dtypeDefault = make_dtype(datatypeDefault)
40
+ numpy_dtypeSmall = numpy_dtypeDefault
41
+ # forceinline=True might actually be useful
42
+ parametersNumba = f"numba.types.{datatypeLarge}(), \
43
+ cache=True, \
44
+ nopython=True, \
45
+ fastmath=True, \
46
+ forceinline=True, \
47
+ inline='always', \
48
+ looplift=False, \
49
+ _nrt=True, \
50
+ error_model='numpy', \
51
+ parallel=False, \
52
+ boundscheck=False, \
53
+ no_cfunc_wrapper=False, \
54
+ no_cpython_wrapper=False, \
55
+ "
56
+ # no_cfunc_wrapper=True, \
57
+ # no_cpython_wrapper=True, \
58
+
59
+ pathFilenameData = Z0Z_makeJob(listDimensions, datatypeDefault=numpy_dtypeDefault, datatypeLarge=numpy_dtypeLarge, datatypeSmall=numpy_dtypeSmall)
60
+
61
+ pathFilenameAlgorithm = pathlib.Path('/apps/mapFolding/mapFolding/someAssemblyRequired/countSequentialNoNumba.py')
38
62
  pathFilenameDestination = pathFilenameData.with_stem(pathFilenameData.parent.name).with_suffix(".py")
39
63
 
40
64
  lineNumba = f"@numba.jit({parametersNumba})"
@@ -49,16 +73,16 @@ def writeModuleWithNumba(listDimensions):
49
73
  ImaIndent = ' '
50
74
  linesDataDynamic = """"""
51
75
  linesDataDynamic = "\n".join([linesDataDynamic
52
- , ImaIndent + archivistFormatsArrayToCode(stateJob['my'], 'my')
53
- , ImaIndent + archivistFormatsArrayToCode(stateJob['foldsSubTotals'], 'foldsSubTotals')
54
- , ImaIndent + archivistFormatsArrayToCode(stateJob['gapsWhere'], 'gapsWhere')
55
- , ImaIndent + archivistFormatsArrayToCode(stateJob['track'], 'track')
76
+ , ImaIndent + f"foldsTotal = numba.types.{datatypeLarge}(0)"
77
+ , ImaIndent + convertNDArrayToStr(stateJob['my'], 'my')
78
+ , ImaIndent + convertNDArrayToStr(stateJob['foldGroups'], 'foldGroups')
79
+ , ImaIndent + convertNDArrayToStr(stateJob['gapsWhere'], 'gapsWhere')
80
+ , ImaIndent + convertNDArrayToStr(stateJob['track'], 'track')
56
81
  ])
57
82
 
58
83
  linesDataStatic = """"""
59
84
  linesDataStatic = "\n".join([linesDataStatic
60
- , ImaIndent + archivistFormatsArrayToCode(stateJob['the'], 'the')
61
- , ImaIndent + archivistFormatsArrayToCode(stateJob['connectionGraph'], 'connectionGraph')
85
+ , ImaIndent + convertNDArrayToStr(stateJob['connectionGraph'], 'connectionGraph')
62
86
  ])
63
87
 
64
88
  pathFilenameFoldsTotal: pathlib.Path = stateJob['pathFilenameFoldsTotal']
@@ -79,26 +103,28 @@ def writeModuleWithNumba(listDimensions):
79
103
  , lineSource
80
104
  ])
81
105
 
82
- lineReturn = f"{ImaIndent}return foldsSubTotals.sum().item()"
83
-
84
106
  linesLaunch = """"""
85
107
  linesLaunch = linesLaunch + f"""
86
108
  if __name__ == '__main__':
87
- foldsTotal = {identifierCallableLaunch}()"""
109
+ import time
110
+ timeStart = time.perf_counter()
111
+ {identifierCallableLaunch}()
112
+ print(time.perf_counter() - timeStart)"""
88
113
 
89
114
  linesWriteFoldsTotal = """"""
90
115
  linesWriteFoldsTotal = "\n".join([linesWriteFoldsTotal
116
+ , " foldsTotal = foldGroups[0:-1].sum() * foldGroups[-1]"
91
117
  , " print(foldsTotal)"
92
- , f" open('{pathFilenameFoldsTotal.as_posix()}', 'w').write(str(foldsTotal))"
118
+ , " with numba.objmode():"
119
+ , f" open('{pathFilenameFoldsTotal.as_posix()}', 'w').write(str(foldsTotal))"
120
+ , " return foldsTotal"
93
121
  ])
94
122
 
95
123
  linesAll = "\n".join([
96
124
  linesImport
97
125
  , linesAlgorithm
98
- , f"{ImaIndent}print(foldsSubTotals.sum().item())"
99
- , lineReturn
100
- , linesLaunch
101
126
  , linesWriteFoldsTotal
127
+ , linesLaunch
102
128
  ])
103
129
 
104
130
  pathFilenameDestination.write_text(linesAll)
@@ -0,0 +1,75 @@
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ authors = [{ name = "Hunter Hogan", email = "HunterHogan@pm.me" }]
7
+ classifiers = [
8
+ "Development Status :: 5 - Production/Stable",
9
+ "Environment :: Console",
10
+ "Intended Audience :: Education",
11
+ "Intended Audience :: End Users/Desktop",
12
+ "Intended Audience :: Other Audience",
13
+ "Intended Audience :: Science/Research",
14
+ "Natural Language :: English",
15
+ "Operating System :: OS Independent",
16
+ "Programming Language :: Python",
17
+ "Topic :: Scientific/Engineering :: Mathematics",
18
+ "Typing :: Typed",
19
+ ]
20
+ dependencies = ["numba", "numpy", "Z0Z_tools"]
21
+ description = "Count distinct ways to fold a map (or a strip of stamps)"
22
+ keywords = [
23
+ "A001415",
24
+ "A001416",
25
+ "A001417",
26
+ "A001418",
27
+ "A195646",
28
+ "folding",
29
+ "map folding",
30
+ "OEIS",
31
+ "stamp folding",
32
+ ]
33
+ license = { text = "CC-BY-NC-4.0" }
34
+ name = "mapFolding"
35
+ optional-dependencies = { benchmark = [
36
+ "ipywidgets",
37
+ "jupyter",
38
+ "pandas",
39
+ "tqdm",
40
+ ], testing = [
41
+ "pytest",
42
+ "pytest-cov",
43
+ "pytest-env",
44
+ "pytest-xdist",
45
+ ] }
46
+ readme = { file = "README.md", content-type = "text/markdown" }
47
+ requires-python = ">=3.10,<3.14"
48
+ scripts = { getOEISids = "mapFolding.oeis:getOEISids", clearOEIScache = "mapFolding.oeis:clearOEIScache", OEIS_for_n = "mapFolding.oeis:OEIS_for_n" }
49
+ urls = { Homepage = "https://github.com/hunterhogan/mapFolding", Donate = "https://www.patreon.com/integrated" }
50
+ version = "0.2.7"
51
+
52
+ [tool.coverage]
53
+ report = { exclude_lines = [
54
+ "if TYPE_CHECKING:",
55
+ "if __name__ == \"__main__\":",
56
+ "numba.jit_module",
57
+ ], ignore_errors = false }
58
+ run = { branch = true, concurrency = [
59
+ "multiprocessing",
60
+ "thread",
61
+ ], data_file = "tests/coverage/.coverage", omit = [
62
+ "tests/*",
63
+ "Z0Z_*",
64
+ ], parallel = true, source = [
65
+ "mapFolding",
66
+ ] }
67
+ xml = { output = "tests/coverage/coverage.xml" }
68
+
69
+ [tool.pytest.ini_options]
70
+ addopts = ["--color=yes", "-n 4"]
71
+ env = ["NUMBA_JIT_COVERAGE=1"]
72
+ testpaths = ["tests"]
73
+
74
+ [tool.setuptools.packages.find]
75
+ where = ["mapFolding"]
@@ -1,7 +1,8 @@
1
1
  import pathlib
2
+ from Z0Z_tools import intInnit
2
3
  from tests.conftest import *
3
4
  from tests.pythons_idiotic_namespace import *
4
- from typing import List, Optional
5
+ from typing import List, Optional, Any
5
6
  import itertools
6
7
  import numba
7
8
  import numpy
@@ -9,6 +10,8 @@ import pytest
9
10
  import random
10
11
  import sys
11
12
  import unittest.mock
13
+ import io
14
+ from contextlib import redirect_stdout
12
15
 
13
16
  @pytest.mark.parametrize("listDimensions,expected_intInnit,expected_parseListDimensions,expected_validateListDimensions,expected_getLeavesTotal", [
14
17
  (None, ValueError, ValueError, ValueError, ValueError), # None instead of list
@@ -81,23 +84,22 @@ def test_countFolds_writeFoldsTotal(
81
84
  pathWriteTarget = pathTempTesting / writeFoldsTarget
82
85
  filenameFoldsTotalExpected = writeFoldsTarget
83
86
 
87
+ foldsTotalExpected = foldsValue * getLeavesTotal(listDimensionsTestFunctionality)
84
88
  mock_countFolds = mockFoldingFunction(foldsValue, listDimensionsTestFunctionality)
85
89
 
86
90
  with unittest.mock.patch("mapFolding.babbage._countFolds", side_effect=mock_countFolds):
87
91
  returned = countFolds(listDimensionsTestFunctionality, pathishWriteFoldsTotal=pathWriteTarget)
88
92
 
89
- standardComparison(foldsValue, lambda: returned) # Check return value
90
- standardComparison(str(foldsValue), lambda: (pathTempTesting / filenameFoldsTotalExpected).read_text()) # Check file content
93
+ # standardComparison(foldsValue, lambda: returned) # Check return value
94
+ standardComparison(str(foldsTotalExpected), lambda: (pathTempTesting / filenameFoldsTotalExpected).read_text()) # Check file content
91
95
 
92
- def test_intInnit() -> None:
93
- """Test integer parsing using the test suite generator."""
94
- for testName, testFunction in makeTestSuiteIntInnit(intInnit).items():
95
- testFunction()
96
+ @pytest.mark.parametrize("nameOfTest,callablePytest", PytestFor_intInnit())
97
+ def testIntInnit(nameOfTest, callablePytest):
98
+ callablePytest()
96
99
 
97
- def test_oopsieKwargsie() -> None:
98
- """Test handling of unexpected keyword arguments."""
99
- for testName, testFunction in makeTestSuiteOopsieKwargsie(oopsieKwargsie).items():
100
- testFunction()
100
+ @pytest.mark.parametrize("nameOfTest,callablePytest", PytestFor_oopsieKwargsie())
101
+ def testOopsieKwargsie(nameOfTest, callablePytest):
102
+ callablePytest()
101
103
 
102
104
  @pytest.mark.parametrize("CPUlimit, expectedLimit", [
103
105
  (None, numba.config.NUMBA_DEFAULT_NUM_THREADS), # type: ignore
@@ -266,3 +268,14 @@ def test_pathJobDEFAULT_colab():
266
268
 
267
269
  # Reload one more time to restore original state
268
270
  importlib.reload(mapFolding.theSSOT)
271
+
272
+ def test_saveFoldsTotal_fallback(pathTempTesting: pathlib.Path) -> None:
273
+ foldsTotal = 123
274
+ pathFilename = pathTempTesting / "unwritable" / "foldsTotal.txt"
275
+ with unittest.mock.patch("pathlib.Path.write_text", side_effect=OSError("Simulated write failure")):
276
+ with unittest.mock.patch("os.getcwd", return_value=str(pathTempTesting)):
277
+ capturedOutput = io.StringIO()
278
+ with redirect_stdout(capturedOutput):
279
+ saveFoldsTotal(pathFilename, foldsTotal)
280
+ fallbackFiles = list(pathTempTesting.glob("foldsTotalYO_*.txt"))
281
+ assert len(fallbackFiles) == 1, "Fallback file was not created upon write failure."
@@ -1,4 +1,4 @@
1
- from .conftest import *
1
+ from tests.conftest import *
2
2
  import pytest
3
3
  from typing import List, Dict, Tuple
4
4
 
@@ -8,14 +8,13 @@ from typing import List, Dict, Tuple
8
8
  def test_countFolds_computationDivisions(listDimensionsTest_countFolds: List[int], foldsTotalKnown: Dict[Tuple[int, ...], int]) -> None:
9
9
  standardComparison(foldsTotalKnown[tuple(listDimensionsTest_countFolds)], countFolds, listDimensionsTest_countFolds, None, 'maximum')
10
10
 
11
- def test_defineConcurrencyLimit() -> None:
12
- testSuite = makeTestSuiteConcurrencyLimit(defineConcurrencyLimit)
13
- for testName, testFunction in testSuite.items():
14
- testFunction()
11
+ @pytest.mark.parametrize("nameOfTest,callablePytest", PytestFor_defineConcurrencyLimit())
12
+ def testConcurrencyLimit(nameOfTest, callablePytest):
13
+ callablePytest()
15
14
 
16
- @pytest.mark.parametrize("CPUlimitParameter", [{"invalid": True}, ["weird"]])
17
- def test_countFolds_cpuLimitOopsie(listDimensionsTestFunctionality: List[int], CPUlimitParameter: Dict[str, bool] | List[str]) -> None:
18
- standardComparison(ValueError, countFolds, listDimensionsTestFunctionality, None, 'cpu', CPUlimitParameter)
15
+ # @pytest.mark.parametrize("CPUlimitParameter", [{"invalid": True}, ["weird"]])
16
+ # def test_countFolds_cpuLimitOopsie(listDimensionsTestFunctionality: List[int], CPUlimitParameter: Dict[str, bool] | List[str]) -> None:
17
+ # standardComparison((AttributeError or ValueError), countFolds, listDimensionsTestFunctionality, None, 'cpu', CPUlimitParameter)
19
18
 
20
19
  def test_countFolds_invalid_computationDivisions(listDimensionsTestFunctionality: List[int]) -> None:
21
20
  standardComparison(ValueError, countFolds, listDimensionsTestFunctionality, None, {"wrong": "value"})
@@ -1,12 +0,0 @@
1
- from .theSSOT import *
2
- from Z0Z_tools import defineConcurrencyLimit, intInnit, oopsieKwargsie
3
- from .beDRY import getFilenameFoldsTotal, getPathFilenameFoldsTotal, outfitCountFolds, saveFoldsTotal
4
- from .startHere import countFolds
5
- from .oeis import oeisIDfor_n, getOEISids, clearOEIScache
6
-
7
- __all__ = [
8
- 'clearOEIScache',
9
- 'countFolds',
10
- 'getOEISids',
11
- 'oeisIDfor_n',
12
- ]
@@ -1,35 +0,0 @@
1
- from mapFolding.importSelector import countSequential, countParallel, countInitialize
2
- from mapFolding import indexThe
3
- from numpy import integer
4
- from numpy.typing import NDArray
5
- from typing import Any, Tuple
6
- import numba
7
- import numpy
8
-
9
- @numba.jit(cache=True)
10
- def _countFolds(connectionGraph: NDArray[integer[Any]], foldsSubTotals: NDArray[integer[Any]], gapsWhere: NDArray[integer[Any]], mapShape: Tuple[int, ...], my: NDArray[integer[Any]], the: NDArray[integer[Any]], track: NDArray[integer[Any]]):
11
- """
12
- What in tarnation is this stupid module and function?
13
-
14
- - This function is not in the same module as `countFolds` so that we can delay Numba just-in-time (jit) compilation of this function and the finalization of its settings until we are ready.
15
- - This function is not in the same module as `countFoldsCompiled`, which is the function that does the hard, so that we can delay `numba.jit` compilation of `countFoldsCompiled`.
16
- - `countFoldsCompiled` is not merely "jitted", it is super jitted, which makes it too arrogant to talk to plebian Python functions. It will, however, reluctantly talk to basic jitted functions.
17
- - The function in this module is jitted, so it can talk to `countFoldsCompiled`, and because it isn't so arrogant, it will talk to the low-class `countFolds` with only a few restrictions, such as:
18
- - No `TypedDict`
19
- - No Python v 3.13
20
- - The plebs must clean up their own memory problems
21
- - No oversized integers
22
- - No global variables, only global constants
23
- - They don't except pleb nonlocal variables either
24
- - Python "class": they are all inferior to a jit
25
- - No `**kwargs`
26
- - and just a few dozen-jillion other things.
27
-
28
- """
29
- # print("babbage")
30
- countInitialize(connectionGraph=connectionGraph, gapsWhere=gapsWhere, my=my, the=the, track=track)
31
-
32
- if the[indexThe.taskDivisions.value] > 0:
33
- countParallel(connectionGraph=connectionGraph, foldsSubTotals=foldsSubTotals, gapsWherePARALLEL=gapsWhere, myPARALLEL=my, the=the, trackPARALLEL=track)
34
- else:
35
- countSequential(connectionGraph=connectionGraph, foldsSubTotals=foldsSubTotals, gapsWhere=gapsWhere, my=my, the=the, track=track)