mapFolding 0.14.0__py3-none-any.whl → 0.14.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.
@@ -1,5 +1,4 @@
1
1
  from mapFolding._oeisFormulas.A000136 import A000136
2
- from mapFolding._oeisFormulas.matrixMeanders import curveMaximum
3
2
  from mapFolding.oeis import dictionaryOEIS
4
3
  import sys
5
4
  import time
@@ -1,65 +1,79 @@
1
1
  from mapFolding._oeisFormulas.matrixMeandersAnnex import curveMaximum as curveMaximum
2
+ from typing import NamedTuple
2
3
 
3
- dictionaryCurveLocations: dict[int, int] = {}
4
+ class BifurcatedCurves(NamedTuple):
5
+ bifurcationEven: int
6
+ bifurcationOdd: int
7
+ distinctCrossings: int
8
+ curveLocationsMAXIMUM: int
4
9
 
5
- def getCurveLocations() -> dict[int, int]:
10
+ dictionaryCurveLocations: dict[int, list[int]] = {}
11
+
12
+ def getCurveLocations(bridges: int) -> list[BifurcatedCurves]:
6
13
  global dictionaryCurveLocations # noqa: PLW0603
7
- sherpa = dictionaryCurveLocations.copy()
14
+ curveLocationsMAXIMUM, bifurcationEvenLocator, bifurcationOddLocator = curveMaximum[bridges]
15
+ listBifurcatedCurves: list[BifurcatedCurves] = []
16
+ # TODO This is ready for concurrency and/or vectorization.
17
+ for curveLocations, listDistinctCrossings in dictionaryCurveLocations.items():
18
+ bifurcationEven = (curveLocations & bifurcationEvenLocator) >> 1
19
+ bifurcationOdd = (curveLocations & bifurcationOddLocator)
20
+ distinctCrossings = sum(listDistinctCrossings)
21
+ listBifurcatedCurves.append(BifurcatedCurves(bifurcationEven, bifurcationOdd, distinctCrossings, curveLocationsMAXIMUM))
8
22
  dictionaryCurveLocations = {}
9
- return sherpa
23
+ return listBifurcatedCurves
10
24
 
11
25
  def recordAnalysis(curveLocationAnalysis: int, curveLocationsMAXIMUM: int, distinctCrossings: int) -> None:
12
26
  if curveLocationAnalysis < curveLocationsMAXIMUM:
13
- dictionaryCurveLocations[curveLocationAnalysis] = dictionaryCurveLocations.get(curveLocationAnalysis, 0) + distinctCrossings
27
+ dictionaryCurveLocations.setdefault(curveLocationAnalysis, []).append(distinctCrossings)
14
28
 
15
- def initializeCurveLocations(startingCurveLocations: dict[int, int]) -> None:
16
- global dictionaryCurveLocations # noqa: PLW0603
17
- dictionaryCurveLocations = startingCurveLocations.copy()
29
+ def analyzeCurve(bifurcationEven: int, bifurcationOdd: int, distinctCrossings: int, curveLocationsMAXIMUM: int) -> None:
30
+ bifurcationEvenFinalZero = (bifurcationEven & 0b1) == 0
31
+ bifurcationEvenHasCurves = bifurcationEven != 1
32
+ bifurcationOddFinalZero = (bifurcationOdd & 0b1) == 0
33
+ bifurcationOddHasCurves = bifurcationOdd != 1
18
34
 
19
- def count(bridges: int, startingCurveLocations: dict[int, int]) -> int:
20
- initializeCurveLocations(startingCurveLocations)
35
+ if bifurcationEvenHasCurves:
36
+ curveLocationAnalysis = (bifurcationEven >> 1) | (bifurcationOdd << 2) | bifurcationEvenFinalZero
37
+ recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
21
38
 
22
- while bridges > 0:
23
- bridges -= 1
24
- curveLocationsMAXIMUM, bifurcationEvenLocator, bifurcationOddLocator = curveMaximum[bridges]
39
+ if bifurcationOddHasCurves:
40
+ curveLocationAnalysis = (bifurcationOdd >> 2) | (bifurcationEven << 3) | (bifurcationOddFinalZero << 1)
41
+ recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
25
42
 
26
- for curveLocations, distinctCrossings in getCurveLocations().items():
27
- bifurcationEven = (curveLocations & bifurcationEvenLocator) >> 1
28
- bifurcationOdd = curveLocations & bifurcationOddLocator
43
+ curveLocationAnalysis = ((bifurcationOdd | (bifurcationEven << 1)) << 2) | 3
44
+ recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
29
45
 
30
- bifurcationEvenFinalZero = (bifurcationEven & 0b1) == 0
31
- bifurcationEvenHasCurves = bifurcationEven != 1
32
- bifurcationOddFinalZero = (bifurcationOdd & 0b1) == 0
33
- bifurcationOddHasCurves = bifurcationOdd != 1
46
+ if bifurcationEvenHasCurves and bifurcationOddHasCurves and (bifurcationEvenFinalZero or bifurcationOddFinalZero):
47
+ XOrHere2makePair = 0b1
48
+ findUnpairedBinary1 = 0
34
49
 
35
- if bifurcationEvenHasCurves:
36
- curveLocationAnalysis = (bifurcationEven >> 1) | (bifurcationOdd << 2) | bifurcationEvenFinalZero
37
- recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
50
+ if bifurcationEvenFinalZero and not bifurcationOddFinalZero:
51
+ while findUnpairedBinary1 >= 0:
52
+ XOrHere2makePair <<= 2
53
+ findUnpairedBinary1 += 1 if (bifurcationEven & XOrHere2makePair) == 0 else -1
54
+ bifurcationEven ^= XOrHere2makePair
38
55
 
39
- if bifurcationOddHasCurves:
40
- curveLocationAnalysis = (bifurcationOdd >> 2) | (bifurcationEven << 3) | (bifurcationOddFinalZero << 1)
41
- recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
56
+ elif bifurcationOddFinalZero and not bifurcationEvenFinalZero:
57
+ while findUnpairedBinary1 >= 0:
58
+ XOrHere2makePair <<= 2
59
+ findUnpairedBinary1 += 1 if (bifurcationOdd & XOrHere2makePair) == 0 else -1
60
+ bifurcationOdd ^= XOrHere2makePair
42
61
 
43
- curveLocationAnalysis = ((bifurcationOdd | (bifurcationEven << 1)) << 2) | 3
44
- recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
62
+ curveLocationAnalysis = ((bifurcationEven >> 2) << 1) | (bifurcationOdd >> 2)
63
+ recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
45
64
 
46
- if bifurcationEvenHasCurves and bifurcationOddHasCurves and (bifurcationEvenFinalZero or bifurcationOddFinalZero):
47
- XOrHere2makePair = 0b1
48
- findUnpairedBinary1 = 0
65
+ def initializeCurveLocations(startingCurveLocations: dict[int, int]) -> None:
66
+ global dictionaryCurveLocations # noqa: PLW0603
67
+ dictionaryCurveLocations = {curve: [distinctCrossings] for curve, distinctCrossings in startingCurveLocations.items()}
49
68
 
50
- if bifurcationEvenFinalZero and not bifurcationOddFinalZero:
51
- while findUnpairedBinary1 >= 0:
52
- XOrHere2makePair <<= 2
53
- findUnpairedBinary1 += 1 if (bifurcationEven & XOrHere2makePair) == 0 else -1
54
- bifurcationEven ^= XOrHere2makePair
69
+ def count(bridges: int, startingCurveLocations: dict[int, int]) -> int:
70
+ initializeCurveLocations(startingCurveLocations)
55
71
 
56
- elif bifurcationOddFinalZero and not bifurcationEvenFinalZero:
57
- while findUnpairedBinary1 >= 0:
58
- XOrHere2makePair <<= 2
59
- findUnpairedBinary1 += 1 if (bifurcationOdd & XOrHere2makePair) == 0 else -1
60
- bifurcationOdd ^= XOrHere2makePair
72
+ while bridges > 0:
73
+ bridges -= 1
61
74
 
62
- curveLocationAnalysis = ((bifurcationEven >> 2) << 1) | (bifurcationOdd >> 2)
63
- recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
75
+ # TODO This could be parallelized when `recordAnalysis` is thread-safe
76
+ for bifurcatedCurve in getCurveLocations(bridges):
77
+ analyzeCurve(*bifurcatedCurve)
64
78
 
65
- return sum(getCurveLocations().values())
79
+ return getCurveLocations(bridges)[0].distinctCrossings
@@ -35,7 +35,7 @@ curveMaximum: dict[int, limitLocators] = {
35
35
  25: limitLocators(18014398509481984, 0xaaaaaaaaaaaaaa, 0x55555555555555),
36
36
  26: limitLocators(72057594037927936, 0x2aaaaaaaaaaaaaa, 0x155555555555555),
37
37
  27: limitLocators(288230376151711744, 0xaaaaaaaaaaaaaaa, 0x555555555555555),
38
- 28: limitLocators(1152921504606846976, 0x2aaaaaaaaaaaaaaa, 0x1555555555555555),
38
+ 28: limitLocators(1152921504606846976, 0x2aaaaaaaaaaaaaaa, 0x1555555555555555), # 0x2aaaaaaaaaaaaaaa.bit_length() = 62
39
39
  29: limitLocators(4611686018427387904, 0xaaaaaaaaaaaaaaaa, 0x5555555555555555),
40
40
  30: limitLocators(18446744073709551616, 0x2aaaaaaaaaaaaaaaa, 0x15555555555555555),
41
41
  31: limitLocators(73786976294838206464, 0xaaaaaaaaaaaaaaaaa, 0x55555555555555555),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mapFolding
3
- Version: 0.14.0
3
+ Version: 0.14.1
4
4
  Summary: Map folding, meanders, stamp folding, semi-meanders. Experiment with algorithm transformations and code optimization.
5
5
  Author-email: Hunter Hogan <HunterHogan@pm.me>
6
6
  License: CC-BY-NC-4.0
@@ -34,15 +34,14 @@ Classifier: Typing :: Typed
34
34
  Requires-Python: >=3.12
35
35
  Description-Content-Type: text/markdown
36
36
  License-File: LICENSE
37
- Requires-Dist: astToolkit>=0.7.1
38
- Requires-Dist: cytoolz
37
+ Requires-Dist: astToolkit
39
38
  Requires-Dist: hunterMakesPy
40
- Requires-Dist: numba
41
39
  Requires-Dist: numpy
42
40
  Requires-Dist: platformdirs
43
41
  Provides-Extra: development
44
42
  Requires-Dist: mypy; extra == "development"
45
43
  Requires-Dist: pyupgrade; extra == "development"
44
+ Requires-Dist: py-spy; extra == "development"
46
45
  Requires-Dist: setuptools-scm; extra == "development"
47
46
  Provides-Extra: numba
48
47
  Requires-Dist: numba; extra == "numba"
@@ -16,11 +16,11 @@ mapFolding/_oeisFormulas/A005316.py,sha256=3B4_2TT_ip3CcYngEaFS-rTNDx-x2TZ0r_J0f
16
16
  mapFolding/_oeisFormulas/A223094.py,sha256=z7t6RcRQlhXdbYImIER15KwG1_W7iV4MNIRDx9Q_Efs,284
17
17
  mapFolding/_oeisFormulas/A259702.py,sha256=9hUs8jzwOnJGmBsueS1yGsLjau4YVa0Yd9lYMG8UFso,123
18
18
  mapFolding/_oeisFormulas/A301620.py,sha256=pY0OJsCLhIEDHQUKpeSMTZ2SUFvcqt83uCOPE_lZCsw,225
19
- mapFolding/_oeisFormulas/Z0Z_aOFn.py,sha256=PjSUpcpNh_YXvc4lrC3xzpx6rz0yWbOuYEHugsssmns,572
19
+ mapFolding/_oeisFormulas/Z0Z_aOFn.py,sha256=qTtjahVu733d-9Z86y1-A9VQC3-ge7j75ikNCIqX3HU,507
20
20
  mapFolding/_oeisFormulas/Z0Z_oeisMeanders.py,sha256=IDwGgieBJffmC3bAFaCqgIxPC9ZyRmqSxsWJ3VKyY2U,1746
21
21
  mapFolding/_oeisFormulas/__init__.py,sha256=n83beVb7HHplXYAM5HveaIAuR7KrJG99OaNHJGMb_uc,44
22
- mapFolding/_oeisFormulas/matrixMeanders.py,sha256=0QEzcOTvaOb0-6MiKUe1Uxoi-ESVIG5rlZxUA1e_l_s,2965
23
- mapFolding/_oeisFormulas/matrixMeandersAnnex.py,sha256=sl0UWwivpnbzIfi6E5cD0vSpHlSUu-Htw4yb4aN-Eg4,5809
22
+ mapFolding/_oeisFormulas/matrixMeanders.py,sha256=me0YV5LDH-s5n9QaUTBT2OdVsc4m_EWxpKN_tvpidvI,3694
23
+ mapFolding/_oeisFormulas/matrixMeandersAnnex.py,sha256=4_269UTFwWuxDwHPBYC7rpEUdrivA-imNN3j1C2udY0,5848
24
24
  mapFolding/reference/A005316JavaPort.py,sha256=6qqTzbD3PTwYGtqaywEURGXtNFx1lp8ofEwpQeEvAHc,4899
25
25
  mapFolding/reference/A005316imperative.py,sha256=hhjUxELOktNBmHrwIoxVA-mcFsOWgg01p780OBeqL04,3816
26
26
  mapFolding/reference/A005316intOptimized.py,sha256=oO9ktdYeFwtosVp5KliwH8JmCSxfjapjBM1iMECuDAc,4121
@@ -68,9 +68,9 @@ mapFolding/tests/test_filesystem.py,sha256=0rYQ62f4e3HOoymXrxDWbqNEBJQ7DGN8RUOMI
68
68
  mapFolding/tests/test_oeis.py,sha256=ejqaOMB61c1oUEBblPPBG9hFFXffpKuIS0CJMe7Rd1o,5497
69
69
  mapFolding/tests/test_other.py,sha256=ScBiJ78LnyAaW-RhxcouX6Xw10wgpSdqfvT4LO3WjnQ,4766
70
70
  mapFolding/tests/test_tasks.py,sha256=_pr9JRWjjNKA7sww70XvkJJdGPruBVzubM63RmD_Du0,4013
71
- mapfolding-0.14.0.dist-info/licenses/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
72
- mapfolding-0.14.0.dist-info/METADATA,sha256=Y9pEjwsX2B8QeCarplVsfNroHV1PbngK9qej7DcuH40,5122
73
- mapfolding-0.14.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
74
- mapfolding-0.14.0.dist-info/entry_points.txt,sha256=F3OUeZR1XDTpoH7k3wXuRb3KF_kXTTeYhu5AGK1SiOQ,146
75
- mapfolding-0.14.0.dist-info/top_level.txt,sha256=aG3bjFBoxxuaV3Iu1wZAd241Ubs3cdaJtKYBQBDIjsg,11
76
- mapfolding-0.14.0.dist-info/RECORD,,
71
+ mapfolding-0.14.1.dist-info/licenses/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
72
+ mapfolding-0.14.1.dist-info/METADATA,sha256=yu3RbpzV6ly9l-BejCo8RhHhjNO2xQaXldeali2Vxak,5117
73
+ mapfolding-0.14.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
74
+ mapfolding-0.14.1.dist-info/entry_points.txt,sha256=F3OUeZR1XDTpoH7k3wXuRb3KF_kXTTeYhu5AGK1SiOQ,146
75
+ mapfolding-0.14.1.dist-info/top_level.txt,sha256=aG3bjFBoxxuaV3Iu1wZAd241Ubs3cdaJtKYBQBDIjsg,11
76
+ mapfolding-0.14.1.dist-info/RECORD,,