mapFolding 0.2.6__tar.gz → 0.3.0__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 (45) hide show
  1. {mapfolding-0.2.6 → mapfolding-0.3.0}/PKG-INFO +23 -7
  2. {mapfolding-0.2.6 → mapfolding-0.3.0}/README.md +1 -1
  3. {mapfolding-0.2.6 → mapfolding-0.3.0/mapFolding}/mapFolding.egg-info/PKG-INFO +23 -7
  4. mapfolding-0.3.0/mapFolding/mapFolding.egg-info/SOURCES.txt +26 -0
  5. {mapfolding-0.2.6 → mapfolding-0.3.0/mapFolding}/mapFolding.egg-info/requires.txt +5 -3
  6. mapfolding-0.3.0/mapFolding/mapFolding.egg-info/top_level.txt +4 -0
  7. mapfolding-0.3.0/mapFolding/someAssemblyRequired/__init__.py +3 -0
  8. mapfolding-0.3.0/mapFolding/someAssemblyRequired/countInitialize.py +45 -0
  9. mapfolding-0.3.0/mapFolding/someAssemblyRequired/countParallel.py +52 -0
  10. mapfolding-0.3.0/mapFolding/someAssemblyRequired/countSequential.py +59 -0
  11. mapfolding-0.2.6/mapFolding/someAssemblyRequired/inlineAfunction.py → mapfolding-0.3.0/mapFolding/someAssemblyRequired/synthesizeModules.py +76 -41
  12. mapfolding-0.3.0/pyproject.toml +78 -0
  13. {mapfolding-0.2.6 → mapfolding-0.3.0}/tests/test_other.py +7 -8
  14. {mapfolding-0.2.6 → mapfolding-0.3.0}/tests/test_tasks.py +7 -8
  15. mapfolding-0.2.6/mapFolding/__init__.py +0 -12
  16. mapfolding-0.2.6/mapFolding/babbage.py +0 -35
  17. mapfolding-0.2.6/mapFolding/beDRY.py +0 -319
  18. mapfolding-0.2.6/mapFolding/importSelector.py +0 -7
  19. mapfolding-0.2.6/mapFolding/lovelace.py +0 -213
  20. mapfolding-0.2.6/mapFolding/oeis.py +0 -323
  21. mapfolding-0.2.6/mapFolding/someAssemblyRequired/jobsAndTasks.py +0 -47
  22. mapfolding-0.2.6/mapFolding/someAssemblyRequired/makeNuitkaSource.py +0 -99
  23. mapfolding-0.2.6/mapFolding/someAssemblyRequired/makeNumbaJob.py +0 -144
  24. mapfolding-0.2.6/mapFolding/startHere.py +0 -50
  25. mapfolding-0.2.6/mapFolding/theSSOT.py +0 -76
  26. mapfolding-0.2.6/mapFolding.egg-info/SOURCES.txt +0 -36
  27. mapfolding-0.2.6/mapFolding.egg-info/top_level.txt +0 -3
  28. mapfolding-0.2.6/pyproject.toml +0 -46
  29. mapfolding-0.2.6/tests/__init__.py +0 -1
  30. mapfolding-0.2.6/tests/conftest.py +0 -343
  31. mapfolding-0.2.6/tests/pythons_idiotic_namespace.py +0 -1
  32. {mapfolding-0.2.6 → mapfolding-0.3.0}/mapFolding/benchmarks/benchmarking.py +0 -0
  33. {mapfolding-0.2.6 → mapfolding-0.3.0/mapFolding}/mapFolding.egg-info/dependency_links.txt +0 -0
  34. {mapfolding-0.2.6 → mapfolding-0.3.0/mapFolding}/mapFolding.egg-info/entry_points.txt +0 -0
  35. {mapfolding-0.2.6 → mapfolding-0.3.0}/mapFolding/reference/flattened.py +0 -0
  36. {mapfolding-0.2.6 → mapfolding-0.3.0}/mapFolding/reference/hunterNumba.py +0 -0
  37. {mapfolding-0.2.6 → mapfolding-0.3.0}/mapFolding/reference/irvineJavaPort.py +0 -0
  38. {mapfolding-0.2.6 → mapfolding-0.3.0}/mapFolding/reference/jax.py +0 -0
  39. {mapfolding-0.2.6 → mapfolding-0.3.0}/mapFolding/reference/lunnan.py +0 -0
  40. {mapfolding-0.2.6 → mapfolding-0.3.0}/mapFolding/reference/lunnanNumpy.py +0 -0
  41. {mapfolding-0.2.6 → mapfolding-0.3.0}/mapFolding/reference/lunnanWhile.py +0 -0
  42. {mapfolding-0.2.6 → mapfolding-0.3.0}/mapFolding/reference/rotatedEntryPoint.py +0 -0
  43. {mapfolding-0.2.6 → mapfolding-0.3.0}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
  44. {mapfolding-0.2.6 → mapfolding-0.3.0}/setup.cfg +0 -0
  45. {mapfolding-0.2.6 → mapfolding-0.3.0}/tests/test_oeis.py +0 -0
@@ -1,24 +1,40 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mapFolding
3
- Version: 0.2.6
3
+ Version: 0.3.0
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
32
+ Requires-Dist: more_itertools; extra == "testing"
18
33
  Requires-Dist: pytest; extra == "testing"
19
34
  Requires-Dist: pytest-cov; extra == "testing"
20
35
  Requires-Dist: pytest-env; extra == "testing"
21
36
  Requires-Dist: pytest-xdist; extra == "testing"
37
+ Requires-Dist: python_minifier; extra == "testing"
22
38
 
23
39
  # Algorithm(s) for counting distinct ways to fold a map (or a strip of stamps)
24
40
 
@@ -40,7 +56,7 @@ The directory [mapFolding/reference](https://github.com/hunterhogan/mapFolding/b
40
56
 
41
57
  ## Simple, easy usage based on OEIS IDs
42
58
 
43
- `mapFolding` directly implements some IDs from _The On-Line Encyclopedia of Integer Sequences_.
59
+ `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
60
 
45
61
  ### Usage: command line
46
62
 
@@ -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,24 +1,40 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mapFolding
3
- Version: 0.2.6
3
+ Version: 0.3.0
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
32
+ Requires-Dist: more_itertools; extra == "testing"
18
33
  Requires-Dist: pytest; extra == "testing"
19
34
  Requires-Dist: pytest-cov; extra == "testing"
20
35
  Requires-Dist: pytest-env; extra == "testing"
21
36
  Requires-Dist: pytest-xdist; extra == "testing"
37
+ Requires-Dist: python_minifier; extra == "testing"
22
38
 
23
39
  # Algorithm(s) for counting distinct ways to fold a map (or a strip of stamps)
24
40
 
@@ -40,7 +56,7 @@ The directory [mapFolding/reference](https://github.com/hunterhogan/mapFolding/b
40
56
 
41
57
  ## Simple, easy usage based on OEIS IDs
42
58
 
43
- `mapFolding` directly implements some IDs from _The On-Line Encyclopedia of Integer Sequences_.
59
+ `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
60
 
45
61
  ### Usage: command line
46
62
 
@@ -0,0 +1,26 @@
1
+ README.md
2
+ pyproject.toml
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
10
+ mapFolding/reference/flattened.py
11
+ mapFolding/reference/hunterNumba.py
12
+ mapFolding/reference/irvineJavaPort.py
13
+ mapFolding/reference/jax.py
14
+ mapFolding/reference/lunnan.py
15
+ mapFolding/reference/lunnanNumpy.py
16
+ mapFolding/reference/lunnanWhile.py
17
+ mapFolding/reference/rotatedEntryPoint.py
18
+ mapFolding/reference/total_countPlus1vsPlusN.py
19
+ mapFolding/someAssemblyRequired/__init__.py
20
+ mapFolding/someAssemblyRequired/countInitialize.py
21
+ mapFolding/someAssemblyRequired/countParallel.py
22
+ mapFolding/someAssemblyRequired/countSequential.py
23
+ mapFolding/someAssemblyRequired/synthesizeModules.py
24
+ tests/test_oeis.py
25
+ tests/test_other.py
26
+ tests/test_tasks.py
@@ -1,15 +1,17 @@
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]
12
+ more_itertools
12
13
  pytest
13
14
  pytest-cov
14
15
  pytest-env
15
16
  pytest-xdist
17
+ python_minifier
@@ -0,0 +1,4 @@
1
+ benchmarks
2
+ citations
3
+ reference
4
+ someAssemblyRequired
@@ -0,0 +1,3 @@
1
+ from .countSequential import countSequential
2
+ from .countParallel import countParallel
3
+ from .countInitialize import countInitialize
@@ -0,0 +1,45 @@
1
+ from mapFolding import indexMy, indexTrack
2
+ import numba
3
+
4
+ @numba.jit((numba.uint8[:,:,::1], numba.uint8[::1], numba.uint8[::1], numba.uint8[:,::1]), parallel=False, boundscheck=False, cache=True, error_model="numpy", fastmath=True, looplift=False, nogil=True, nopython=True)
5
+ def countInitialize(connectionGraph, gapsWhere, my, track):
6
+ while my[7] > 0:
7
+ if my[7] <= 1 or track[1, 0] == 1:
8
+ my[1] = my[0]
9
+ my[3] = track[3, my[7] - 1]
10
+ my[4] = 0
11
+ while my[4] < my[0]:
12
+ if connectionGraph[my[4], my[7], my[7]] == my[7]:
13
+ my[1] -= 1
14
+ else:
15
+ my[8] = connectionGraph[my[4], my[7], my[7]]
16
+ while my[8] != my[7]:
17
+ gapsWhere[my[3]] = my[8]
18
+ if track[2, my[8]] == 0:
19
+ my[3] += 1
20
+ track[2, my[8]] += 1
21
+ my[8] = connectionGraph[my[4], my[7], track[1, my[8]]]
22
+ my[4] += 1
23
+ if not my[1]:
24
+ my[5] = 0
25
+ while my[5] < my[7]:
26
+ gapsWhere[my[3]] = my[5]
27
+ my[3] += 1
28
+ my[5] += 1
29
+ my[6] = my[2]
30
+ while my[6] < my[3]:
31
+ gapsWhere[my[2]] = gapsWhere[my[6]]
32
+ if track[2, gapsWhere[my[6]]] == my[1]:
33
+ my[2] += 1
34
+ track[2, gapsWhere[my[6]]] = 0
35
+ my[6] += 1
36
+ if my[7] > 0:
37
+ my[2] -= 1
38
+ track[0, my[7]] = gapsWhere[my[2]]
39
+ track[1, my[7]] = track[1, track[0, my[7]]]
40
+ track[1, track[0, my[7]]] = my[7]
41
+ track[0, track[1, my[7]]] = my[7]
42
+ track[3, my[7]] = my[2]
43
+ my[7] += 1
44
+ if my[2] > 0:
45
+ return
@@ -0,0 +1,52 @@
1
+ from mapFolding import indexMy, indexTrack
2
+ import numba
3
+
4
+ @numba.jit((numba.uint8[:,:,::1], numba.int64[::1], numba.uint8[::1], numba.uint8[::1], numba.uint8[:,::1]), parallel=True, boundscheck=False, cache=True, error_model="numpy", fastmath=True, looplift=False, nogil=True, nopython=True)
5
+ def countParallel(connectionGraph, foldGroups, gapsWherePARALLEL, myPARALLEL, trackPARALLEL):
6
+ for indexSherpa in numba.prange(myPARALLEL[9]):
7
+ gapsWhere = gapsWherePARALLEL.copy()
8
+ my = myPARALLEL.copy()
9
+ my[10] = indexSherpa
10
+ track = trackPARALLEL.copy()
11
+ groupsOfFolds: int = 0
12
+ while my[7] > 0:
13
+ if my[7] <= 1 or track[1, 0] == 1:
14
+ if my[7] > foldGroups[-1]:
15
+ groupsOfFolds = groupsOfFolds + 1
16
+ else:
17
+ my[1] = my[0]
18
+ my[3] = track[3, my[7] - 1]
19
+ my[4] = 0
20
+ while my[4] < my[0]:
21
+ if connectionGraph[my[4], my[7], my[7]] == my[7]:
22
+ my[1] -= 1
23
+ else:
24
+ my[8] = connectionGraph[my[4], my[7], my[7]]
25
+ while my[8] != my[7]:
26
+ if my[7] != my[9] or my[8] % my[9] == my[10]:
27
+ gapsWhere[my[3]] = my[8]
28
+ if track[2, my[8]] == 0:
29
+ my[3] += 1
30
+ track[2, my[8]] += 1
31
+ my[8] = connectionGraph[my[4], my[7], track[1, my[8]]]
32
+ my[4] += 1
33
+ my[6] = my[2]
34
+ while my[6] < my[3]:
35
+ gapsWhere[my[2]] = gapsWhere[my[6]]
36
+ if track[2, gapsWhere[my[6]]] == my[1]:
37
+ my[2] += 1
38
+ track[2, gapsWhere[my[6]]] = 0
39
+ my[6] += 1
40
+ while my[7] > 0 and my[2] == track[3, my[7] - 1]:
41
+ my[7] -= 1
42
+ track[1, track[0, my[7]]] = track[1, my[7]]
43
+ track[0, track[1, my[7]]] = track[0, my[7]]
44
+ if my[7] > 0:
45
+ my[2] -= 1
46
+ track[0, my[7]] = gapsWhere[my[2]]
47
+ track[1, my[7]] = track[1, track[0, my[7]]]
48
+ track[1, track[0, my[7]]] = my[7]
49
+ track[0, track[1, my[7]]] = my[7]
50
+ track[3, my[7]] = my[2]
51
+ my[7] += 1
52
+ foldGroups[my[10]] = groupsOfFolds
@@ -0,0 +1,59 @@
1
+ from mapFolding import indexMy, indexTrack
2
+ import numba
3
+
4
+ @numba.jit((numba.uint8[:,:,::1], numba.int64[::1], numba.uint8[::1], numba.uint8[::1], numba.uint8[:,::1]), parallel=False, boundscheck=False, cache=True, error_model="numpy", fastmath=True, looplift=False, nogil=True, nopython=True)
5
+ def countSequential(connectionGraph, foldGroups, gapsWhere, my, track):
6
+ doFindGaps = True
7
+ dimensionsTotal = my[indexMy.dimensionsTotal.value]
8
+ dimensionsUnconstrained = my[indexMy.dimensionsUnconstrained.value]
9
+ gap1ndex = my[indexMy.gap1ndex.value]
10
+ gap1ndexCeiling = my[indexMy.gap1ndexCeiling.value]
11
+ indexDimension = my[indexMy.indexDimension.value]
12
+ indexMiniGap = my[indexMy.indexMiniGap.value]
13
+ leaf1ndex = my[indexMy.leaf1ndex.value]
14
+ leafConnectee = my[indexMy.leafConnectee.value]
15
+ taskIndex = my[indexMy.taskIndex.value]
16
+ leafAbove = track[indexTrack.leafAbove.value]
17
+ leafBelow = track[indexTrack.leafBelow.value]
18
+ countDimensionsGapped = track[indexTrack.countDimensionsGapped.value]
19
+ gapRangeStart = track[indexTrack.gapRangeStart.value]
20
+ groupsOfFolds: int = 0
21
+ while leaf1ndex > 0:
22
+ if (doFindGaps := (leaf1ndex <= 1 or leafBelow[0] == 1)) and leaf1ndex > foldGroups[-1]:
23
+ groupsOfFolds = groupsOfFolds + 1
24
+ elif doFindGaps:
25
+ dimensionsUnconstrained = dimensionsTotal
26
+ gap1ndexCeiling = gapRangeStart[leaf1ndex - 1]
27
+ indexDimension = 0
28
+ while indexDimension < dimensionsTotal:
29
+ if connectionGraph[indexDimension, leaf1ndex, leaf1ndex] == leaf1ndex:
30
+ dimensionsUnconstrained -= 1
31
+ else:
32
+ leafConnectee = connectionGraph[indexDimension, leaf1ndex, leaf1ndex]
33
+ while leafConnectee != leaf1ndex:
34
+ gapsWhere[gap1ndexCeiling] = leafConnectee
35
+ if countDimensionsGapped[leafConnectee] == 0:
36
+ gap1ndexCeiling += 1
37
+ countDimensionsGapped[leafConnectee] += 1
38
+ leafConnectee = connectionGraph[indexDimension, leaf1ndex, leafBelow[leafConnectee]]
39
+ indexDimension += 1
40
+ indexMiniGap = gap1ndex
41
+ while indexMiniGap < gap1ndexCeiling:
42
+ gapsWhere[gap1ndex] = gapsWhere[indexMiniGap]
43
+ if countDimensionsGapped[gapsWhere[indexMiniGap]] == dimensionsUnconstrained:
44
+ gap1ndex += 1
45
+ countDimensionsGapped[gapsWhere[indexMiniGap]] = 0
46
+ indexMiniGap += 1
47
+ while leaf1ndex > 0 and gap1ndex == gapRangeStart[leaf1ndex - 1]:
48
+ leaf1ndex -= 1
49
+ leafBelow[leafAbove[leaf1ndex]] = leafBelow[leaf1ndex]
50
+ leafAbove[leafBelow[leaf1ndex]] = leafAbove[leaf1ndex]
51
+ if leaf1ndex > 0:
52
+ gap1ndex -= 1
53
+ leafAbove[leaf1ndex] = gapsWhere[gap1ndex]
54
+ leafBelow[leaf1ndex] = leafBelow[leafAbove[leaf1ndex]]
55
+ leafBelow[leafAbove[leaf1ndex]] = leaf1ndex
56
+ leafAbove[leafBelow[leaf1ndex]] = leaf1ndex
57
+ gapRangeStart[leaf1ndex] = gap1ndex
58
+ leaf1ndex += 1
59
+ foldGroups[taskIndex] = groupsOfFolds
@@ -1,20 +1,34 @@
1
- from mapFolding import indexMy, indexThe, indexTrack
1
+ from mapFolding import indexMy, indexTrack, theDao, datatypeDefault, datatypeLarge, datatypeSmall
2
2
  import ast
3
- import copy
4
3
  import pathlib
4
+ import inspect
5
+
6
+ algorithmSource = theDao
7
+
8
+ dictionaryDecorators={
9
+ 'countInitialize':
10
+ f'@numba.jit((numba.{datatypeSmall}[:,:,::1], numba.{datatypeDefault}[::1], numba.{datatypeSmall}[::1], numba.{datatypeDefault}[:,::1]), parallel=False, boundscheck=False, cache=True, error_model="numpy", fastmath=True, looplift=False, nogil=True, nopython=True)\n',
11
+ 'countParallel':
12
+ f'@numba.jit((numba.{datatypeSmall}[:,:,::1], numba.{datatypeLarge}[::1], numba.{datatypeDefault}[::1], numba.{datatypeSmall}[::1], numba.{datatypeDefault}[:,::1]), parallel=True, boundscheck=False, cache=True, error_model="numpy", fastmath=True, looplift=False, nogil=True, nopython=True)\n',
13
+ 'countSequential':
14
+ f'@numba.jit((numba.{datatypeSmall}[:,:,::1], numba.{datatypeLarge}[::1], numba.{datatypeDefault}[::1], numba.{datatypeSmall}[::1], numba.{datatypeDefault}[:,::1]), parallel=False, boundscheck=False, cache=True, error_model="numpy", fastmath=True, looplift=False, nogil=True, nopython=True)\n',
15
+ }
5
16
 
6
17
  def getDictionaryEnumValues():
7
18
  dictionaryEnumValues = {}
8
- for enumIndex in [indexMy, indexThe, indexTrack]:
19
+ for enumIndex in [indexMy, indexTrack]:
9
20
  for memberName, memberValue in enumIndex._member_map_.items():
10
21
  dictionaryEnumValues[f"{enumIndex.__name__}.{memberName}.value"] = memberValue.value
11
22
  return dictionaryEnumValues
12
23
 
13
24
  class RecursiveInlinerWithEnum(ast.NodeTransformer):
25
+ """Process AST nodes to inline functions and substitute enum values.
26
+ Also handles function decorators during inlining."""
27
+
14
28
  def __init__(self, dictionaryFunctions, dictionaryEnumValues):
15
29
  self.dictionaryFunctions = dictionaryFunctions
16
30
  self.dictionaryEnumValues = dictionaryEnumValues
17
- self.processed = set() # Track processed functions to avoid infinite recursion
31
+ self.processed = set()
18
32
 
19
33
  def inlineFunctionBody(self, functionName):
20
34
  if functionName in self.processed:
@@ -39,7 +53,7 @@ class RecursiveInlinerWithEnum(ast.NodeTransformer):
39
53
  callNode = self.generic_visit(node)
40
54
  if isinstance(callNode, ast.Call) and isinstance(callNode.func, ast.Name) and callNode.func.id in self.dictionaryFunctions:
41
55
  inlineDefinition = self.inlineFunctionBody(callNode.func.id)
42
- if inlineDefinition and inlineDefinition.body:
56
+ if (inlineDefinition and inlineDefinition.body):
43
57
  lastStmt = inlineDefinition.body[-1]
44
58
  if isinstance(lastStmt, ast.Return) and lastStmt.value is not None:
45
59
  return self.visit(lastStmt.value)
@@ -78,20 +92,21 @@ def findRequiredImports(node):
78
92
 
79
93
  def generateImports(requiredImports):
80
94
  """Generate import statements based on required modules."""
81
- importStatements = []
95
+ importStatements = {'import numba', 'from mapFolding import indexMy, indexTrack'}
82
96
 
83
- # Map of module names to their import statements
84
97
  importMapping = {
85
98
  'numba': 'import numba',
86
99
  }
87
100
 
88
101
  for moduleName in sorted(requiredImports):
89
102
  if moduleName in importMapping:
90
- importStatements.append(importMapping[moduleName])
103
+ importStatements.add(importMapping[moduleName])
91
104
 
92
105
  return '\n'.join(importStatements)
93
106
 
94
- def inlineFunctions(sourceCode, targetFunctionName, dictionaryEnumValues):
107
+ def inlineFunctions(sourceCode, targetFunctionName, dictionaryEnumValues, skipEnum=False):
108
+ if skipEnum:
109
+ dictionaryEnumValues = {}
95
110
  dictionaryParsed = ast.parse(sourceCode)
96
111
  dictionaryFunctions = {
97
112
  element.name: element
@@ -103,50 +118,70 @@ def inlineFunctions(sourceCode, targetFunctionName, dictionaryEnumValues):
103
118
  nodeInlined = nodeInliner.visit(nodeTarget)
104
119
  ast.fix_missing_locations(nodeInlined)
105
120
 
106
- # Generate imports
107
121
  requiredImports = findRequiredImports(nodeInlined)
108
122
  importStatements = generateImports(requiredImports)
109
123
 
110
- # Combine imports with inlined code
111
- inlinedCode = importStatements + '\n\n' + ast.unparse(ast.Module(body=[nodeInlined], type_ignores=[]))
124
+ lineNumbaDecorator = dictionaryDecorators[targetFunctionName]
125
+ inlinedCode = importStatements + '\n\n' + lineNumbaDecorator + ast.unparse(ast.Module(body=[nodeInlined], type_ignores=[]))
112
126
  return inlinedCode
113
127
 
128
+ def unpackArrays(codeInlined: str, callableTarget: str) -> str:
129
+ dictionaryReplaceScalars = {
130
+ 'my[indexMy.dimensionsTotal.value]': 'dimensionsTotal',
131
+ 'my[indexMy.dimensionsUnconstrained.value]': 'dimensionsUnconstrained',
132
+ 'my[indexMy.gap1ndex.value]': 'gap1ndex',
133
+ 'my[indexMy.gap1ndexCeiling.value]': 'gap1ndexCeiling',
134
+ 'my[indexMy.indexDimension.value]': 'indexDimension',
135
+ # 'my[indexMy.indexLeaf.value]': 'indexLeaf',
136
+ 'my[indexMy.indexMiniGap.value]': 'indexMiniGap',
137
+ 'my[indexMy.leaf1ndex.value]': 'leaf1ndex',
138
+ 'my[indexMy.leafConnectee.value]': 'leafConnectee',
139
+ # 'my[indexMy.taskDivisions.value]': 'taskDivisions',
140
+ 'my[indexMy.taskIndex.value]': 'taskIndex',
141
+ # 'foldGroups[-1]': 'leavesTotal',
142
+ }
143
+
144
+ dictionaryReplaceArrays = {
145
+ "track[indexTrack.leafAbove.value, ": 'leafAbove[',
146
+ "track[indexTrack.leafBelow.value, ": 'leafBelow[',
147
+ 'track[indexTrack.countDimensionsGapped.value, ': 'countDimensionsGapped[',
148
+ 'track[indexTrack.gapRangeStart.value, ': 'gapRangeStart[',
149
+ }
150
+
151
+ ImaIndent = " "
152
+ linesInitialize = """"""
153
+
154
+ for find, replace in dictionaryReplaceScalars.items():
155
+ linesInitialize += f"{ImaIndent}{replace} = {find}\n"
156
+ codeInlined = codeInlined.replace(find, replace)
157
+
158
+ for find, replace in dictionaryReplaceArrays.items():
159
+ linesInitialize += f"{ImaIndent}{replace[0:-1]} = {find[0:-2]}]\n"
160
+ codeInlined = codeInlined.replace(find, replace)
161
+
162
+ ourGuyOnTheInside = " doFindGaps = True\n"
163
+ linesInitialize = ourGuyOnTheInside + linesInitialize
164
+
165
+ codeInlined = codeInlined.replace(ourGuyOnTheInside, linesInitialize)
166
+
167
+ return codeInlined
168
+
114
169
  def Z0Z_inlineMapFolding():
115
170
  dictionaryEnumValues = getDictionaryEnumValues()
171
+ codeSource = inspect.getsource(algorithmSource)
172
+ pathFilenameAlgorithm = pathlib.Path(inspect.getfile(algorithmSource))
116
173
 
117
- pathFilenameSource = pathlib.Path("/apps/mapFolding/mapFolding/lovelace.py")
118
- codeSource = pathFilenameSource.read_text()
119
-
120
- listCallables = [
121
- 'countInitialize',
122
- 'countParallel',
123
- 'countSequential',
124
- ]
174
+ listCallables = [ 'countInitialize', 'countParallel', 'countSequential', ]
125
175
 
126
176
  listPathFilenamesDestination: list[pathlib.Path] = []
127
177
  for callableTarget in listCallables:
128
- pathFilenameDestination = pathFilenameSource.parent / "someAssemblyRequired" / pathFilenameSource.with_stem(callableTarget).name
129
- codeInlined = inlineFunctions(codeSource, callableTarget, dictionaryEnumValues)
130
- pathFilenameDestination.write_text(codeInlined)
178
+ skipEnum = (callableTarget == 'countInitialize')
179
+ skipEnum = (callableTarget == 'countSequential')
180
+ pathFilenameDestination = pathFilenameAlgorithm.parent / "someAssemblyRequired" / pathFilenameAlgorithm.with_stem(callableTarget).name
181
+ codeInlined = inlineFunctions(codeSource, callableTarget, dictionaryEnumValues, skipEnum)
182
+ codeUnpacked = unpackArrays(codeInlined, callableTarget)
183
+ pathFilenameDestination.write_text(codeUnpacked)
131
184
  listPathFilenamesDestination.append(pathFilenameDestination)
132
185
 
133
- listNoNumba = [
134
- 'countInitialize',
135
- 'countSequential',
136
- ]
137
-
138
- listPathFilenamesNoNumba = []
139
- for pathFilename in listPathFilenamesDestination:
140
- if pathFilename.stem in listNoNumba:
141
- pathFilenameNoNumba = pathFilename.with_name(pathFilename.stem + 'NoNumba' + pathFilename.suffix)
142
- else:
143
- continue
144
- codeNoNumba = pathFilename.read_text()
145
- for codeLine in copy.copy(codeNoNumba.splitlines()):
146
- if 'numba' in codeLine:
147
- codeNoNumba = codeNoNumba.replace(codeLine, '')
148
- pathFilenameNoNumba.write_text(codeNoNumba)
149
- listPathFilenamesNoNumba.append(pathFilenameNoNumba)
150
-
151
186
  if __name__ == '__main__':
152
187
  Z0Z_inlineMapFolding()
@@ -0,0 +1,78 @@
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
+ "more_itertools",
42
+ "pytest",
43
+ "pytest-cov",
44
+ "pytest-env",
45
+ "pytest-xdist",
46
+ "python_minifier",
47
+ ] }
48
+ readme = { file = "README.md", content-type = "text/markdown" }
49
+ requires-python = ">=3.10,<3.14"
50
+ scripts = { getOEISids = "mapFolding.oeis:getOEISids", clearOEIScache = "mapFolding.oeis:clearOEIScache", OEIS_for_n = "mapFolding.oeis:OEIS_for_n" }
51
+ urls = { Homepage = "https://github.com/hunterhogan/mapFolding", Donate = "https://www.patreon.com/integrated" }
52
+ version = "0.3.0"
53
+
54
+ [tool.coverage]
55
+ report = { exclude_lines = [
56
+ "if TYPE_CHECKING:",
57
+ "if __name__ == \"__main__\":",
58
+ "numba.jit_module",
59
+ ], ignore_errors = false }
60
+ run = { branch = true, concurrency = [
61
+ "multiprocessing",
62
+ "thread",
63
+ ], data_file = "tests/coverage/.coverage", omit = [
64
+ "tests/*",
65
+ "Z0Z_*",
66
+ ], parallel = true, source = [
67
+ "mapFolding",
68
+ ] }
69
+ xml = { output = "tests/coverage/coverage.xml" }
70
+
71
+ [tool.pytest.ini_options]
72
+ addopts = ["--color=yes", "-n 4"]
73
+ # env = ["NUMBA_JIT_COVERAGE=1"]
74
+ env = ["NUMBA_DISABLE_JIT=1"]
75
+ testpaths = ["tests"]
76
+
77
+ [tool.setuptools.packages.find]
78
+ where = ["mapFolding"]
@@ -1,4 +1,5 @@
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
5
  from typing import List, Optional, Any
@@ -92,15 +93,13 @@ def test_countFolds_writeFoldsTotal(
92
93
  # standardComparison(foldsValue, lambda: returned) # Check return value
93
94
  standardComparison(str(foldsTotalExpected), lambda: (pathTempTesting / filenameFoldsTotalExpected).read_text()) # Check file content
94
95
 
95
- def test_intInnit() -> None:
96
- """Test integer parsing using the test suite generator."""
97
- for testName, testFunction in makeTestSuiteIntInnit(intInnit).items():
98
- testFunction()
96
+ @pytest.mark.parametrize("nameOfTest,callablePytest", PytestFor_intInnit())
97
+ def testIntInnit(nameOfTest, callablePytest):
98
+ callablePytest()
99
99
 
100
- def test_oopsieKwargsie() -> None:
101
- """Test handling of unexpected keyword arguments."""
102
- for testName, testFunction in makeTestSuiteOopsieKwargsie(oopsieKwargsie).items():
103
- testFunction()
100
+ @pytest.mark.parametrize("nameOfTest,callablePytest", PytestFor_oopsieKwargsie())
101
+ def testOopsieKwargsie(nameOfTest, callablePytest):
102
+ callablePytest()
104
103
 
105
104
  @pytest.mark.parametrize("CPUlimit, expectedLimit", [
106
105
  (None, numba.config.NUMBA_DEFAULT_NUM_THREADS), # type: ignore
@@ -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"})