mapFolding 0.3.4__py3-none-any.whl → 0.3.6__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,10 +1,48 @@
1
1
  from cffconvert.cli.create_citation import create_citation
2
+ from cffconvert.cli.validate_or_write_output import validate_or_write_output
2
3
  from typing import Any, Dict
3
4
  import cffconvert
4
5
  import pathlib
6
+ import packaging.metadata
5
7
  import tomli
6
8
  import inspect
7
9
  import json
10
+ import ruamel.yaml
11
+ import packaging
12
+ from packaging.metadata import Metadata as PyPAMetadata
13
+ import packaging.utils
14
+ import packaging.version
15
+
16
+ def addPypaMetadata(citation: cffconvert.Citation, metadata: PyPAMetadata) -> cffconvert.Citation:
17
+ # https://github.com/citation-file-format/cff-initializer-javascript
18
+ """
19
+ keywords: pathFilenamePackageSSOT; packaging.metadata.Metadata.keywords
20
+ license: pathFilenamePackageSSOT; packaging.metadata.Metadata.license_expression
21
+ title: pathFilenamePackageSSOT; packaging.metadata.Metadata.name
22
+ url: pathFilenamePackageSSOT; packaging.metadata.Metadata.project_urls: homepage
23
+ repository: pathFilenamePackageSSOT; packaging.metadata.Metadata.project_urls: repository
24
+ version: pathFilenamePackageSSOT; packaging.metadata.Metadata.version
25
+ """
26
+ return citation
27
+
28
+ def getPypaMetadata(packageData: Dict[str, Any]) -> PyPAMetadata:
29
+ # https://packaging.python.org/en/latest/specifications/core-metadata/
30
+ dictionaryProjectURLs = {}
31
+ for urlKey, urlValue in packageData.get('urls', {}).items():
32
+ if urlKey.lower() in ('homepage', 'repository'):
33
+ dictionaryProjectURLs[urlKey] = urlValue
34
+
35
+ metadataRaw = packaging.metadata.RawMetadata(
36
+ keywords=packageData.get('keywords', []),
37
+ license_expression=packageData.get('license', {}).get('text', ''),
38
+ metadata_version='2.4',
39
+ name=packaging.utils.canonicalize_name(packageData.get('name', None), validate=True),
40
+ project_urls=dictionaryProjectURLs,
41
+ version=packageData.get('version', None),
42
+ )
43
+
44
+ metadata = PyPAMetadata().from_raw(metadataRaw)
45
+ return metadata
8
46
 
9
47
  """
10
48
  Tentative plan:
@@ -17,7 +55,6 @@ Tentative plan:
17
55
  - this complicates things
18
56
  - I want the updated citation to be in the `commit` field of itself
19
57
  """
20
-
21
58
  """cffconvert.Citation fields and the source of truth
22
59
  abstract: pathFilenameCitationSSOT
23
60
  authors: pathFilenamePackageSSOT
@@ -27,41 +64,53 @@ contact: pathFilenamePackageSSOT
27
64
  date-released: workflows['Make GitHub Release']
28
65
  doi: pathFilenameCitationSSOT
29
66
  identifiers: workflows['Make GitHub Release']
30
- keywords: pathFilenamePackageSSOT
31
- license: pathFilenamePackageSSOT
32
67
  license-url: pathFilenamePackageSSOT
33
68
  message: pathFilenameCitationSSOT
34
69
  preferred-citation: pathFilenameCitationSSOT
35
70
  references: to be determined
36
- repository: pathFilenamePackageSSOT
37
71
  repository-artifact: (https://pypi.org/pypi/{package_name}/json').json()['releases']
38
72
  repository-code: workflows['Make GitHub Release']
39
- title: pathFilenamePackageSSOT
40
73
  type: pathFilenameCitationSSOT
41
- url: pathFilenamePackageSSOT
42
- version: pathFilenamePackageSSOT
74
+
75
+ keywords: pathFilenamePackageSSOT; packaging.metadata.Metadata.keywords
76
+ license: pathFilenamePackageSSOT; packaging.metadata.Metadata.license_expression
77
+ title: pathFilenamePackageSSOT; packaging.metadata.Metadata.name
78
+ url: pathFilenamePackageSSOT; packaging.metadata.Metadata.project_urls: homepage
79
+ repository: pathFilenamePackageSSOT; packaging.metadata.Metadata.project_urls: repository
80
+ version: pathFilenamePackageSSOT; packaging.metadata.Metadata.version
43
81
  """
44
- # Prefer reliable, dynamic values over hardcoded ones
45
- packageName: str = 'mapFolding'
46
- pathRepoRoot = pathlib.Path(__file__).parent.parent.parent
47
- pathFilenamePackageSSOT = pathRepoRoot / 'pyproject.toml'
48
82
 
49
- filenameGitHubAction = 'updateCitation.yml'
50
- pathFilenameGitHubAction = pathRepoRoot / '.github' / 'workflows' / filenameGitHubAction
83
+ def logistics():
84
+ # Prefer reliable, dynamic values over hardcoded ones
85
+ packageName: str = 'mapFolding'
86
+ pathRepoRoot = pathlib.Path(__file__).parent.parent.parent
87
+ pathFilenamePackageSSOT = pathRepoRoot / 'pyproject.toml'
88
+ filenameGitHubAction = 'updateCitation.yml'
89
+ pathFilenameGitHubAction = pathRepoRoot / '.github' / 'workflows' / filenameGitHubAction
90
+
91
+ filenameCitationDOTcff = 'CITATION.cff'
92
+ pathCitations = pathRepoRoot / packageName / 'citations'
93
+ pathFilenameCitationSSOT = pathCitations / filenameCitationDOTcff
94
+ pathFilenameCitationDOTcffRepo = pathRepoRoot / filenameCitationDOTcff
95
+
96
+ citationObject: cffconvert.Citation = create_citation(infile=pathFilenameCitationSSOT, url=None)
97
+ print(citationObject._parse().as_cff())
51
98
 
52
- filenameCitationDOTcff = 'CITATION.cff'
53
- pathCitations = pathRepoRoot / packageName / 'citations'
54
- pathFilenameCitationSSOT = pathCitations / filenameCitationDOTcff
55
- pathFilenameCitationDOTcffRepo = pathRepoRoot / filenameCitationDOTcff
99
+ tomlPackageData: Dict[str, Any] = tomli.loads(pathFilenamePackageSSOT.read_text())['project']
100
+ # https://packaging.python.org/en/latest/specifications/pyproject-toml/
101
+ pypaMetadata: PyPAMetadata = getPypaMetadata(tomlPackageData)
56
102
 
57
- tomlPackageData: Dict[str, Any] = tomli.loads(pathFilenamePackageSSOT.read_text())['project']
103
+ validate_or_write_output(outfile=pathFilenameCitationSSOT, outputformat='cff', validate_only=False, citation=citationObject)
104
+ validate_or_write_output(outfile=pathFilenameCitationDOTcffRepo, outputformat='cff', validate_only=False, citation=citationObject)
58
105
 
59
- citationObject: cffconvert.Citation = create_citation(infile=pathFilenameCitationSSOT, url=None)
106
+ if __name__ == '__main__':
107
+ logistics()
60
108
 
61
- path_cffconvert = pathlib.Path(inspect.getfile(cffconvert)).parent
62
- pathFilenameSchema = path_cffconvert / "schemas/1.2.0/schema.json"
63
- scheme: Dict[str, Any] = json.loads(pathFilenameSchema.read_text())
64
- schemaSpecifications: Dict[str, Any] = scheme['properties']
109
+ # print(f"{pypaMetadata.name=}, {pypaMetadata.version=}, {pypaMetadata.keywords=}, {pypaMetadata.license_expression=}, {pypaMetadata.project_urls=}")
110
+ # path_cffconvert = pathlib.Path(inspect.getfile(cffconvert)).parent
111
+ # pathFilenameSchema = path_cffconvert / "schemas/1.2.0/schema.json"
112
+ # scheme: Dict[str, Any] = json.loads(pathFilenameSchema.read_text())
113
+ # schemaSpecifications: Dict[str, Any] = scheme['properties']
65
114
 
66
- for property, subProperties in schemaSpecifications.items():
67
- print(property, subProperties.get('items', None))
115
+ # for property, subProperties in schemaSpecifications.items():
116
+ # print(property, subProperties.get('items', None))
@@ -0,0 +1,125 @@
1
+ from cffconvert.cli.create_citation import create_citation
2
+ from cffconvert.cli.validate_or_write_output import validate_or_write_output
3
+ from typing import Any, Dict
4
+ import cffconvert
5
+ import pathlib
6
+ import packaging.metadata
7
+ import tomli
8
+ import ruamel.yaml
9
+ import packaging
10
+ from packaging.metadata import Metadata as PyPAMetadata
11
+ import packaging.utils
12
+ import packaging.version
13
+
14
+ def addPypaMetadata(citation: cffconvert.Citation, metadata: PyPAMetadata) -> cffconvert.Citation:
15
+ """
16
+ Map the PyPA metadata to the citation's internal representation.
17
+
18
+ Mapping:
19
+ - title: metadata.name
20
+ - version: metadata.version (converted to string)
21
+ - keywords: metadata.keywords
22
+ - license: metadata.license_expression
23
+ - url: from project URLs (homepage)
24
+ - repository: from project URLs (repository)
25
+ """
26
+ # Access the internal dictionary (used for conversion)
27
+ citationData: Dict[str, Any] = citation._cffobj
28
+
29
+ # Update title from PyPA metadata name
30
+ if metadata.name:
31
+ citationData["title"] = metadata.name
32
+
33
+ # Update version from PyPA metadata version
34
+ if metadata.version:
35
+ citationData["version"] = str(metadata.version)
36
+
37
+ # Update keywords from PyPA metadata keywords
38
+ if metadata.keywords:
39
+ citationData["keywords"] = metadata.keywords
40
+
41
+ # Update license from PyPA metadata license_expression
42
+ if metadata.license_expression:
43
+ citationData["license"] = metadata.license_expression
44
+
45
+ # Retrieve the project URLs that were attached in getPypaMetadata
46
+ projectURLs: Dict[str, str] = getattr(metadata, "_project_urls", {})
47
+
48
+ # Update the homepage URL
49
+ if "homepage" in projectURLs:
50
+ citationData["url"] = projectURLs["homepage"]
51
+
52
+ # Update the repository URL
53
+ if "repository" in projectURLs:
54
+ citationData["repository"] = projectURLs["repository"]
55
+
56
+ return citation
57
+
58
+ def getPypaMetadata(packageData: Dict[str, Any]) -> PyPAMetadata:
59
+ """
60
+ Create a PyPA metadata object (version 2.4) from packageData.
61
+
62
+ Mapping for project URLs:
63
+ - 'homepage' and 'repository' are accepted from packageData['urls'].
64
+ """
65
+ dictionaryProjectURLs: Dict[str, str] = {}
66
+ for urlKey, urlValue in packageData.get("urls", {}).items():
67
+ lowerUrlKey = urlKey.lower()
68
+ if lowerUrlKey in ("homepage", "repository"):
69
+ dictionaryProjectURLs[lowerUrlKey] = urlValue
70
+
71
+ metadataRaw = packaging.metadata.RawMetadata(
72
+ keywords=packageData.get("keywords", []),
73
+ license_expression=packageData.get("license", {}).get("text", ""),
74
+ metadata_version="2.4",
75
+ name=packaging.utils.canonicalize_name(packageData.get("name", None), validate=True),
76
+ project_urls=dictionaryProjectURLs,
77
+ version=packageData.get("version", None),
78
+ )
79
+
80
+ metadata = PyPAMetadata().from_raw(metadataRaw)
81
+ # Attach the project URLs dictionary so it can be used later.
82
+ setattr(metadata, "_project_urls", dictionaryProjectURLs)
83
+ return metadata
84
+
85
+ def logistics():
86
+ # Determine paths from your SSOT.
87
+ packageName: str = "mapFolding"
88
+ pathRepoRoot = pathlib.Path(__file__).parent.parent.parent
89
+ pathFilenamePackageSSOT = pathRepoRoot / "pyproject.toml"
90
+ filenameGitHubAction = "updateCitation.yml"
91
+ pathFilenameGitHubAction = pathRepoRoot / ".github" / "workflows" / filenameGitHubAction
92
+
93
+ filenameCitationDOTcff = "CITATION.cff"
94
+ pathCitations = pathRepoRoot / packageName / "citations"
95
+ pathFilenameCitationSSOT = pathCitations / filenameCitationDOTcff
96
+ pathFilenameCitationDOTcffRepo = pathRepoRoot / filenameCitationDOTcff
97
+
98
+ # Create a citation object from the SSOT citation file.
99
+ citationObject: cffconvert.Citation = create_citation(infile=pathFilenameCitationSSOT, url=None)
100
+ # Print the current citation in CFF format (for debugging) using the as_cff method.
101
+ print(citationObject.as_cff())
102
+
103
+ # Load package metadata from pyproject.toml.
104
+ tomlPackageData: Dict[str, Any] = tomli.loads(pathFilenamePackageSSOT.read_text())["project"]
105
+ pypaMetadata: PyPAMetadata = getPypaMetadata(tomlPackageData)
106
+
107
+ # Map the PyPA metadata into the citation's internal representation.
108
+ citationObject = addPypaMetadata(citation=citationObject, metadata=pypaMetadata)
109
+
110
+ # Validate and write out the updated citation file in both locations.
111
+ # validate_or_write_output(
112
+ # outfile=pathFilenameCitationSSOT,
113
+ # outputformat="cff",
114
+ # validate_only=False,
115
+ # citation=citationObject,
116
+ # )
117
+ validate_or_write_output(
118
+ outfile=pathFilenameCitationDOTcffRepo,
119
+ outputformat="cff",
120
+ validate_only=False,
121
+ citation=citationObject,
122
+ )
123
+
124
+ if __name__ == "__main__":
125
+ logistics()
@@ -1,11 +1,12 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mapFolding
3
- Version: 0.3.4
3
+ Version: 0.3.6
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
6
  License: CC-BY-NC-4.0
7
- Project-URL: Homepage, https://github.com/hunterhogan/mapFolding
7
+ Project-URL: homepage, https://github.com/hunterhogan/mapFolding
8
8
  Project-URL: Donate, https://www.patreon.com/integrated
9
+ Project-URL: repository, https://github.com/hunterhogan/mapFolding.git
9
10
  Keywords: A001415,A001416,A001417,A001418,A195646,folding,map folding,OEIS,stamp folding
10
11
  Classifier: Development Status :: 5 - Production/Stable
11
12
  Classifier: Environment :: Console
@@ -0,0 +1,27 @@
1
+ benchmarks/benchmarking.py,sha256=HD_0NSvuabblg94ftDre6LFnXShTe8MYj3hIodW-zV0,3076
2
+ citations/updateCitation.py,sha256=PPxOERlYnw9b9xydiZL8utTU-sC2B4rBfOgjXc1S0OY,5264
3
+ citations/updateCitationgpt.py,sha256=NtgSP4BCO5YcaYcYYb31vOxXcp3hmooug8VYpbhTc_w,4751
4
+ reference/flattened.py,sha256=6blZ2Y9G8mu1F3gV8SKndPE398t2VVFlsgKlyeJ765A,16538
5
+ reference/hunterNumba.py,sha256=HWndRgsajOf76rbb2LDNEZ6itsdYbyV-k3wgOFjeR6c,7104
6
+ reference/irvineJavaPort.py,sha256=Sj-63Z-OsGuDoEBXuxyjRrNmmyl0d7Yz_XuY7I47Oyg,4250
7
+ reference/jax.py,sha256=rojyK80lOATtbzxjGOHWHZngQa47CXCLJHZwIdN2MwI,14955
8
+ reference/lunnan.py,sha256=XEcql_gxvCCghb6Or3qwmPbn4IZUbZTaSmw_fUjRxZE,5037
9
+ reference/lunnanNumpy.py,sha256=HqDgSwTOZA-G0oophOEfc4zs25Mv4yw2aoF1v8miOLk,4653
10
+ reference/lunnanWhile.py,sha256=7NY2IKO5XBgol0aWWF_Fi-7oTL9pvu_z6lB0TF1uVHk,4063
11
+ reference/rotatedEntryPoint.py,sha256=z0QyDQtnMvXNj5ntWzzJUQUMFm1-xHGLVhtYzwmczUI,11530
12
+ reference/total_countPlus1vsPlusN.py,sha256=usenM8Yn_G1dqlPl7NKKkcnbohBZVZBXTQRm2S3_EDA,8106
13
+ someAssemblyRequired/__init__.py,sha256=3JnAKXfaYPtmxV_4AnZ6KpCosT_0GFV5Nw7K8sz4-Uo,34
14
+ someAssemblyRequired/generalizeSourceCode.py,sha256=qyJD0ZdG0t-SYTItL_JjaIXm3-joWt3e-2nMSAH4Dbg,6392
15
+ someAssemblyRequired/getLLVMforNoReason.py,sha256=FtJzw2pZS3A4NimWdZsegXaU-vKeCw8m67kcfb5wvGM,894
16
+ someAssemblyRequired/makeJob.py,sha256=RTC80FhDrR19GqHtEeo6GpmlWZQESuf8FXqBqVzdOpk,1465
17
+ someAssemblyRequired/synthesizeModuleJob.py,sha256=uyODwdI1_a76Pu21JsCNEapVW78yUD-CfInX-vg8U-w,7419
18
+ someAssemblyRequired/synthesizeModules.py,sha256=foxk-mG-HGVap2USiA3ppCyWWXUmkLFzQiKacp5DD9M,11569
19
+ syntheticModules/Initialize.py,sha256=KIAxLSyblzDTL8QJYINmdRjk2iRVYzXOWeqY8P6wPgw,4024
20
+ syntheticModules/Parallel.py,sha256=Kq1uo5kfeeczk871yxaagsaNz8zaM8GWy0S3hZAEQz4,5343
21
+ syntheticModules/Sequential.py,sha256=JwpHNFt_w77J0RBVoBji-OLnYNSTMnusRlYU-6b4P2w,3643
22
+ syntheticModules/__init__.py,sha256=lUDBXOiislfP2sIxT13_GZgElaytoYqk0ODUsucMYew,117
23
+ mapFolding-0.3.6.dist-info/METADATA,sha256=ViqnejEpnb4391VOp-nqnGXqyAwaXiqwUx3wpZbqyxM,7688
24
+ mapFolding-0.3.6.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
25
+ mapFolding-0.3.6.dist-info/entry_points.txt,sha256=F3OUeZR1XDTpoH7k3wXuRb3KF_kXTTeYhu5AGK1SiOQ,146
26
+ mapFolding-0.3.6.dist-info/top_level.txt,sha256=yVG9dNZywoaddcsUdEDg7o0XOBzJd_4Z-sDaXGHpiMY,69
27
+ mapFolding-0.3.6.dist-info/RECORD,,
@@ -1,2 +1 @@
1
1
  from .makeJob import makeStateJob
2
- # from .generalizeSourceCode import makeInlineFunction
@@ -1,16 +1,29 @@
1
- from mapFolding import getPathFilenameFoldsTotal
1
+ from mapFolding import getPathFilenameFoldsTotal, computationState
2
2
  from mapFolding import outfitCountFolds
3
- from typing import Any, Optional, Sequence, Type
3
+ from typing import Any, Literal, Optional, Sequence, Type, overload
4
4
  import pathlib
5
5
  import pickle
6
6
 
7
- def makeStateJob(listDimensions: Sequence[int], **keywordArguments: Optional[Type[Any]]) -> pathlib.Path:
7
+ @overload
8
+ def makeStateJob(listDimensions: Sequence[int], writeJob: Literal[True] = True
9
+ , **keywordArguments: Optional[Type[Any]]) -> pathlib.Path:
10
+ ...
8
11
 
9
- stateUniversal = outfitCountFolds(listDimensions, computationDivisions=None, CPUlimit=None, **keywordArguments)
12
+ @overload
13
+ def makeStateJob(listDimensions: Sequence[int], writeJob: Literal[False] = False
14
+ , **keywordArguments: Optional[Type[Any]]) -> computationState:
15
+ ...
10
16
 
11
- from syntheticModules import countInitialize
17
+ def makeStateJob(listDimensions: Sequence[int], writeJob: bool = True, **keywordArguments: Optional[Type[Any]]) -> computationState | pathlib.Path:
18
+
19
+ stateUniversal: computationState = outfitCountFolds(listDimensions, computationDivisions=None, CPUlimit=None, **keywordArguments)
20
+
21
+ from mapFolding.syntheticModules import countInitialize
12
22
  countInitialize(stateUniversal['connectionGraph'], stateUniversal['gapsWhere'], stateUniversal['my'], stateUniversal['track'])
13
23
 
24
+ if not writeJob:
25
+ return stateUniversal
26
+
14
27
  pathFilenameChopChop = getPathFilenameFoldsTotal(stateUniversal['mapShape'])
15
28
  suffix = pathFilenameChopChop.suffix
16
29
  pathJob = pathlib.Path(str(pathFilenameChopChop)[0:-len(suffix)])
@@ -1,15 +1,13 @@
1
- from mapFolding import getPathFilenameFoldsTotal
1
+ from mapFolding import getPathFilenameFoldsTotal, indexMy, indexTrack
2
2
  from mapFolding import make_dtype, datatypeLargeDEFAULT, datatypeMediumDEFAULT, datatypeSmallDEFAULT, datatypeModuleDEFAULT
3
- from mapFolding import computationState
4
3
  from someAssemblyRequired import makeStateJob
5
4
  from typing import Optional
6
- import more_itertools
7
- import inspect
8
5
  import importlib
9
6
  import importlib.util
7
+ import inspect
8
+ import more_itertools
10
9
  import numpy
11
10
  import pathlib
12
- import pickle
13
11
  import python_minifier
14
12
 
15
13
  identifierCallableLaunch = "goGoGadgetAbsurdity"
@@ -52,33 +50,15 @@ def writeModuleWithNumba(listDimensions, **keywordArguments: Optional[str]) -> p
52
50
  dtypeMedium = make_dtype(datatypeMedium, datatypeModule) # type: ignore
53
51
  dtypeSmall = make_dtype(datatypeSmall, datatypeModule) # type: ignore
54
52
 
55
- pathFilenameJob = makeStateJob(listDimensions, dtypeLarge = dtypeLarge, dtypeMedium = dtypeMedium, dtypeSmall = dtypeSmall)
56
- stateJob: computationState = pickle.loads(pathFilenameJob.read_bytes())
57
- pathFilenameFoldsTotal = getPathFilenameFoldsTotal(stateJob['mapShape'], pathFilenameJob.parent)
53
+ stateJob = makeStateJob(listDimensions, writeJob=False, dtypeLarge = dtypeLarge, dtypeMedium = dtypeMedium, dtypeSmall = dtypeSmall)
54
+ pathFilenameFoldsTotal = getPathFilenameFoldsTotal(stateJob['mapShape'])
58
55
 
59
56
  from syntheticModules import countSequential
60
57
  algorithmSource = countSequential
61
58
  codeSource = inspect.getsource(algorithmSource)
62
59
 
63
- # forceinline=True might actually be useful
64
- parametersNumba = f"numba.types.{datatypeLarge}(), \
65
- cache=True, \
66
- nopython=True, \
67
- fastmath=True, \
68
- forceinline=True, \
69
- inline='always', \
70
- looplift=False, \
71
- _nrt=True, \
72
- error_model='numpy', \
73
- parallel=False, \
74
- boundscheck=False, \
75
- no_cfunc_wrapper=False, \
76
- no_cpython_wrapper=False, \
77
- "
78
- # no_cfunc_wrapper=True, \
79
- # no_cpython_wrapper=True, \
80
-
81
- lineNumba = f"@numba.jit({parametersNumba})"
60
+ if datatypeLarge:
61
+ lineNumba = f"@numba.jit(numba.types.{datatypeLarge}(), cache=True, nopython=True, fastmath=True, forceinline=True, inline='always', looplift=False, _nrt=True, error_model='numpy', parallel=False, boundscheck=False, no_cfunc_wrapper=True, no_cpython_wrapper=False)"
82
62
 
83
63
  linesImport = "\n".join([
84
64
  "import numpy"
@@ -88,8 +68,8 @@ no_cpython_wrapper=False, \
88
68
  ImaIndent = ' '
89
69
  linesDataDynamic = """"""
90
70
  linesDataDynamic = "\n".join([linesDataDynamic
91
- , ImaIndent + f"foldsTotal = numba.types.{datatypeLarge}(0)"
92
- , ImaIndent + makeStrRLEcompacted(stateJob['foldGroups'], 'foldGroups')
71
+ # , ImaIndent + f"foldsTotal = numba.types.{datatypeLarge}(0)"
72
+ # , ImaIndent + makeStrRLEcompacted(stateJob['foldGroups'], 'foldGroups')
93
73
  , ImaIndent + makeStrRLEcompacted(stateJob['gapsWhere'], 'gapsWhere')
94
74
  ])
95
75
 
@@ -112,14 +92,22 @@ no_cpython_wrapper=False, \
112
92
  , linesDataDynamic
113
93
  , linesDataStatic
114
94
  ])
95
+ elif 'taskIndex' in lineSource:
96
+ continue
115
97
  elif 'my[indexMy.' in lineSource:
98
+ if 'dimensionsTotal' in lineSource:
99
+ continue
116
100
  # leaf1ndex = my[indexMy.leaf1ndex.value]
117
101
  identifier, statement = lineSource.split('=')
118
- lineSource = ImaIndent + identifier.strip() + '=' + str(eval(statement.strip()))
102
+ lineSource = ImaIndent + identifier.strip() + f"=numba.types.{datatypeSmall}({str(eval(statement.strip()))})"
119
103
  elif 'track[indexTrack.' in lineSource:
120
104
  # leafAbove = track[indexTrack.leafAbove.value]
121
105
  identifier, statement = lineSource.split('=')
122
106
  lineSource = ImaIndent + makeStrRLEcompacted(eval(statement.strip()), identifier.strip())
107
+ elif 'foldGroups[-1]' in lineSource:
108
+ lineSource = lineSource.replace('foldGroups[-1]', str(stateJob['foldGroups'][-1]))
109
+ elif 'dimensionsTotal' in lineSource:
110
+ lineSource = lineSource.replace('dimensionsTotal', str(stateJob['my'][indexMy.dimensionsTotal]))
123
111
 
124
112
  linesAlgorithm = "\n".join([linesAlgorithm
125
113
  , lineSource
@@ -135,11 +123,11 @@ if __name__ == '__main__':
135
123
 
136
124
  linesWriteFoldsTotal = """"""
137
125
  linesWriteFoldsTotal = "\n".join([linesWriteFoldsTotal
138
- , " foldsTotal = foldGroups[0:-1].sum() * foldGroups[-1]"
139
- , " print(foldsTotal)"
126
+ , f" groupsOfFolds *= {str(stateJob['foldGroups'][-1])}"
127
+ , " print(groupsOfFolds)"
140
128
  , " with numba.objmode():"
141
- , f" open('{pathFilenameFoldsTotal.as_posix()}', 'w').write(str(foldsTotal))"
142
- , " return foldsTotal"
129
+ , f" open('{pathFilenameFoldsTotal.as_posix()}', 'w').write(str(groupsOfFolds))"
130
+ , " return groupsOfFolds"
143
131
  ])
144
132
 
145
133
  linesAll = "\n".join([
@@ -149,7 +137,7 @@ if __name__ == '__main__':
149
137
  , linesLaunch
150
138
  ])
151
139
 
152
- pathFilenameDestination = pathFilenameJob.with_stem(pathFilenameJob.parent.name).with_suffix(".py")
140
+ pathFilenameDestination = pathFilenameFoldsTotal.with_suffix(".py")
153
141
  pathFilenameDestination.write_text(linesAll)
154
142
 
155
143
  return pathFilenameDestination
@@ -160,11 +148,10 @@ if __name__ == '__main__':
160
148
  datatypeMedium = 'uint8'
161
149
  datatypeSmall = datatypeMedium
162
150
  pathFilenameModule = writeModuleWithNumba(listDimensions, datatypeLarge=datatypeLarge, datatypeMedium=datatypeMedium, datatypeSmall=datatypeSmall)
151
+
163
152
  # Induce numba.jit compilation
164
153
  moduleSpec = importlib.util.spec_from_file_location(pathFilenameModule.stem, pathFilenameModule)
165
- if moduleSpec is None:
166
- raise ImportError(f"Could not load module specification from {pathFilenameModule}")
154
+ if moduleSpec is None: raise ImportError(f"Could not load module specification from {pathFilenameModule}")
167
155
  module = importlib.util.module_from_spec(moduleSpec)
168
- if moduleSpec.loader is None:
169
- raise ImportError(f"Could not load module from {moduleSpec}")
156
+ if moduleSpec.loader is None: raise ImportError(f"Could not load module from {moduleSpec}")
170
157
  moduleSpec.loader.exec_module(module)
@@ -1,10 +1,10 @@
1
1
  from mapFolding import indexMy, indexTrack, getAlgorithmSource, ParametersNumba, parametersNumbaDEFAULT, hackSSOTdtype
2
- from mapFolding import datatypeLargeDEFAULT, datatypeMediumDEFAULT, datatypeSmallDEFAULT
2
+ from mapFolding import datatypeLargeDEFAULT, datatypeMediumDEFAULT, datatypeSmallDEFAULT, EnumIndices
3
3
  import pathlib
4
4
  import inspect
5
5
  import numpy
6
6
  import numba
7
- from typing import Dict, Optional, List, Set, Union, Sequence
7
+ from typing import Dict, Optional, List, Union, Sequence, Type, cast
8
8
  import ast
9
9
 
10
10
  algorithmSource = getAlgorithmSource()
@@ -15,7 +15,7 @@ class RecursiveInliner(ast.NodeTransformer):
15
15
  self.processed = set()
16
16
 
17
17
  def inlineFunctionBody(self, functionName: str) -> Optional[ast.FunctionDef]:
18
- if functionName in self.processed:
18
+ if (functionName in self.processed):
19
19
  return None
20
20
 
21
21
  self.processed.add(functionName)
@@ -27,39 +27,38 @@ class RecursiveInliner(ast.NodeTransformer):
27
27
 
28
28
  def visit_Call(self, node: ast.Call) -> ast.AST:
29
29
  callNode = self.generic_visit(node)
30
- if isinstance(callNode, ast.Call) and isinstance(callNode.func, ast.Name) and callNode.func.id in self.dictionaryFunctions:
30
+ if (isinstance(callNode, ast.Call) and isinstance(callNode.func, ast.Name) and callNode.func.id in self.dictionaryFunctions):
31
31
  inlineDefinition = self.inlineFunctionBody(callNode.func.id)
32
32
  if (inlineDefinition and inlineDefinition.body):
33
33
  lastStmt = inlineDefinition.body[-1]
34
- if isinstance(lastStmt, ast.Return) and lastStmt.value is not None:
34
+ if (isinstance(lastStmt, ast.Return) and lastStmt.value is not None):
35
35
  return self.visit(lastStmt.value)
36
- elif isinstance(lastStmt, ast.Expr) and lastStmt.value is not None:
36
+ elif (isinstance(lastStmt, ast.Expr) and lastStmt.value is not None):
37
37
  return self.visit(lastStmt.value)
38
38
  return ast.Constant(value=None)
39
39
  return callNode
40
40
 
41
41
  def visit_Expr(self, node: ast.Expr) -> Union[ast.AST, List[ast.AST]]:
42
- if isinstance(node.value, ast.Call):
43
- if isinstance(node.value.func, ast.Name) and node.value.func.id in self.dictionaryFunctions:
42
+ if (isinstance(node.value, ast.Call)):
43
+ if (isinstance(node.value.func, ast.Name) and node.value.func.id in self.dictionaryFunctions):
44
44
  inlineDefinition = self.inlineFunctionBody(node.value.func.id)
45
- if inlineDefinition:
45
+ if (inlineDefinition):
46
46
  return [self.visit(stmt) for stmt in inlineDefinition.body]
47
47
  return self.generic_visit(node)
48
48
 
49
- def decorateCallableWithNumba(astCallable: ast.FunctionDef, parallel: bool=False, **keywordArguments: Optional[str]):
49
+ def decorateCallableWithNumba(astCallable: ast.FunctionDef, parallel: bool=False, **keywordArguments: Optional[str]) -> ast.FunctionDef:
50
50
  def makeNumbaParameterSignatureElement(signatureElement: ast.arg):
51
51
  if isinstance(signatureElement.annotation, ast.Subscript) and isinstance(signatureElement.annotation.slice, ast.Tuple):
52
-
53
52
  annotationShape = signatureElement.annotation.slice.elts[0]
54
53
  if isinstance(annotationShape, ast.Subscript) and isinstance(annotationShape.slice, ast.Tuple):
55
- shapeAsListSlices = [ast.Slice() for axis in range(len(annotationShape.slice.elts))]
54
+ shapeAsListSlices: Sequence[ast.expr] = [ast.Slice() for axis in range(len(annotationShape.slice.elts))]
56
55
  shapeAsListSlices[-1] = ast.Slice(step=ast.Constant(value=1))
57
- shapeAST = ast.Tuple(elts=shapeAsListSlices, ctx=ast.Load())
56
+ shapeAST = ast.Tuple(elts=list(shapeAsListSlices), ctx=ast.Load())
58
57
  else:
59
58
  shapeAST = ast.Slice(step=ast.Constant(value=1))
60
59
 
61
60
  annotationDtype = signatureElement.annotation.slice.elts[1]
62
- if isinstance(annotationDtype, ast.Subscript) and isinstance(annotationDtype.slice, ast.Attribute):
61
+ if (isinstance(annotationDtype, ast.Subscript) and isinstance(annotationDtype.slice, ast.Attribute)):
63
62
  datatypeAST = annotationDtype.slice.attr
64
63
  else:
65
64
  datatypeAST = None
@@ -75,15 +74,18 @@ def decorateCallableWithNumba(astCallable: ast.FunctionDef, parallel: bool=False
75
74
 
76
75
  # callableSourceDecorators = [decorator for decorator in callableInlined.decorator_list]
77
76
 
78
- listNumbaParameterSignature: List[ast.Subscript] = []
77
+ listNumbaParameterSignature: Sequence[ast.expr] = []
79
78
  for parameter in astCallable.args.args:
80
79
  signatureElement = makeNumbaParameterSignatureElement(parameter)
81
- if signatureElement:
80
+ if (signatureElement):
82
81
  listNumbaParameterSignature.append(signatureElement)
83
82
 
84
83
  astArgsNumbaSignature = ast.Tuple(elts=listNumbaParameterSignature, ctx=ast.Load())
85
84
 
86
- parametersNumba = parametersNumbaDEFAULT if not parallel else ParametersNumba({**parametersNumbaDEFAULT, 'parallel': True})
85
+ if astCallable.name == 'countInitialize':
86
+ parametersNumba = {}
87
+ else:
88
+ parametersNumba = parametersNumbaDEFAULT if not parallel else ParametersNumba({**parametersNumbaDEFAULT, 'parallel': True})
87
89
  listKeywordsNumbaSignature = [ast.keyword(arg=parameterName, value=ast.Constant(value=parameterValue)) for parameterName, parameterValue in parametersNumba.items()]
88
90
 
89
91
  astDecoratorNumba = ast.Call(func=ast.Attribute(value=ast.Name(id='numba', ctx=ast.Load()), attr='jit', ctx=ast.Load()), args=[astArgsNumbaSignature], keywords=listKeywordsNumbaSignature)
@@ -91,56 +93,92 @@ def decorateCallableWithNumba(astCallable: ast.FunctionDef, parallel: bool=False
91
93
  astCallable.decorator_list = [astDecoratorNumba]
92
94
  return astCallable
93
95
 
94
- def getDictionaryEnumValues() -> Dict[str, int]:
95
- dictionaryEnumValues = {}
96
- for enumIndex in [indexMy, indexTrack]:
97
- for memberName, memberValue in enumIndex._member_map_.items():
98
- dictionaryEnumValues[f"{enumIndex.__name__}.{memberName}.value"] = memberValue.value
99
- return dictionaryEnumValues
100
-
101
- def unpackArrays(codeInlined: str) -> str:
102
- dictionaryReplaceScalars = {
103
- 'my[indexMy.dimensionsTotal.value]': 'dimensionsTotal',
104
- 'my[indexMy.dimensionsUnconstrained.value]': 'dimensionsUnconstrained',
105
- 'my[indexMy.gap1ndex.value]': 'gap1ndex',
106
- 'my[indexMy.gap1ndexCeiling.value]': 'gap1ndexCeiling',
107
- 'my[indexMy.indexDimension.value]': 'indexDimension',
108
- # 'my[indexMy.indexLeaf.value]': 'indexLeaf',
109
- 'my[indexMy.indexMiniGap.value]': 'indexMiniGap',
110
- 'my[indexMy.leaf1ndex.value]': 'leaf1ndex',
111
- 'my[indexMy.leafConnectee.value]': 'leafConnectee',
112
- # 'my[indexMy.taskDivisions.value]': 'taskDivisions',
113
- 'my[indexMy.taskIndex.value]': 'taskIndex',
114
- # 'foldGroups[-1]': 'leavesTotal',
115
- }
116
-
117
- dictionaryReplaceArrays = {
118
- "track[indexTrack.leafAbove.value, ": 'leafAbove[',
119
- "track[indexTrack.leafBelow.value, ": 'leafBelow[',
120
- 'track[indexTrack.countDimensionsGapped.value, ': 'countDimensionsGapped[',
121
- 'track[indexTrack.gapRangeStart.value, ': 'gapRangeStart[',
122
- }
123
-
124
- ImaIndent = " "
125
- linesInitialize = """"""
126
-
127
- for find, replace in dictionaryReplaceScalars.items():
128
- linesInitialize += f"{ImaIndent}{replace} = {find}\n"
129
- codeInlined = codeInlined.replace(find, replace)
130
-
131
- for find, replace in dictionaryReplaceArrays.items():
132
- linesInitialize += f"{ImaIndent}{replace[0:-1]} = {find[0:-2]}]\n"
133
- codeInlined = codeInlined.replace(find, replace)
134
-
135
- ourGuyOnTheInside = " doFindGaps = True\n"
136
- linesInitialize = ourGuyOnTheInside + linesInitialize
137
-
138
- codeInlined = codeInlined.replace(ourGuyOnTheInside, linesInitialize)
139
-
140
- return codeInlined
96
+ class UnpackArrayAccesses(ast.NodeTransformer):
97
+ """AST transformer that replaces array accesses with simpler variables."""
98
+
99
+ def __init__(self, enumIndexClass: Type[EnumIndices], arrayName: str):
100
+ self.enumIndexClass = enumIndexClass
101
+ self.arrayName = arrayName
102
+ self.substitutions = {}
103
+
104
+ def extract_member_name(self, node: ast.AST) -> Optional[str]:
105
+ """Recursively extract enum member name from any node in the AST."""
106
+ if isinstance(node, ast.Attribute) and node.attr == 'value':
107
+ innerAttribute = node.value
108
+ while isinstance(innerAttribute, ast.Attribute):
109
+ if (isinstance(innerAttribute.value, ast.Name) and innerAttribute.value.id == self.enumIndexClass.__name__):
110
+ return innerAttribute.attr
111
+ innerAttribute = innerAttribute.value
112
+ return None
113
+
114
+ def transform_slice_element(self, node: ast.AST) -> ast.AST:
115
+ """Transform any enum references within a slice element."""
116
+ if isinstance(node, ast.Subscript):
117
+ if isinstance(node.slice, ast.Attribute):
118
+ member_name = self.extract_member_name(node.slice)
119
+ if member_name:
120
+ return ast.Name(id=member_name, ctx=node.ctx)
121
+ elif isinstance(node, ast.Tuple):
122
+ # Handle tuple slices by transforming each element
123
+ return ast.Tuple(elts=cast(List[ast.expr], [self.transform_slice_element(elt) for elt in node.elts]), ctx=node.ctx)
124
+ elif isinstance(node, ast.Attribute):
125
+ member_name = self.extract_member_name(node)
126
+ if member_name:
127
+ return ast.Name(id=member_name, ctx=ast.Load())
128
+ return node
129
+
130
+ def visit_Subscript(self, node: ast.Subscript) -> ast.AST:
131
+ # Recursively visit any nested subscripts in value or slice
132
+ node.value = self.visit(node.value)
133
+ node.slice = self.visit(node.slice)
134
+ # If node.value is not our arrayName, just return node
135
+ if not (isinstance(node.value, ast.Name) and node.value.id == self.arrayName):
136
+ return node
137
+
138
+ # Handle scalar array access
139
+ if isinstance(node.slice, ast.Attribute):
140
+ memberName = self.extract_member_name(node.slice)
141
+ if memberName:
142
+ self.substitutions[memberName] = ('scalar', node)
143
+ return ast.Name(id=memberName, ctx=ast.Load())
144
+
145
+ # Handle array slice access
146
+ if isinstance(node.slice, ast.Tuple) and node.slice.elts:
147
+ firstElement = node.slice.elts[0]
148
+ memberName = self.extract_member_name(firstElement)
149
+ sliceRemainder = [self.visit(elem) for elem in node.slice.elts[1:]]
150
+ if memberName:
151
+ self.substitutions[memberName] = ('array', node)
152
+ if len(sliceRemainder) == 0:
153
+ return ast.Name(id=memberName, ctx=ast.Load())
154
+ return ast.Subscript(value=ast.Name(id=memberName, ctx=ast.Load()), slice=ast.Tuple(elts=sliceRemainder, ctx=ast.Load()) if len(sliceRemainder) > 1 else sliceRemainder[0], ctx=ast.Load())
155
+
156
+ # If single-element tuple, unwrap
157
+ if isinstance(node.slice, ast.Tuple) and len(node.slice.elts) == 1:
158
+ node.slice = node.slice.elts[0]
159
+
160
+ return node
161
+
162
+ def visit_FunctionDef(self, node: ast.FunctionDef) -> ast.FunctionDef:
163
+ node = cast(ast.FunctionDef, self.generic_visit(node))
164
+
165
+ initializations = []
166
+ for name, (kind, original_node) in self.substitutions.items():
167
+ if kind == 'scalar':
168
+ initializations.append(ast.Assign(targets=[ast.Name(id=name, ctx=ast.Store())], value=original_node))
169
+ else: # array
170
+ initializations.append(
171
+ ast.Assign(
172
+ targets=[ast.Name(id=name, ctx=ast.Store())],
173
+ value=ast.Subscript(value=ast.Name(id=self.arrayName, ctx=ast.Load()),
174
+ slice=ast.Attribute(value=ast.Attribute(
175
+ value=ast.Name(id=self.enumIndexClass.__name__, ctx=ast.Load()),
176
+ attr=name, ctx=ast.Load()), attr='value', ctx=ast.Load()), ctx=ast.Load())))
177
+
178
+ node.body = initializations + node.body
179
+ return node
141
180
 
142
181
  def inlineMapFoldingNumba(**keywordArguments: Optional[str]):
143
- dictionaryEnumValues = getDictionaryEnumValues()
144
182
  codeSource = inspect.getsource(algorithmSource)
145
183
  pathFilenameAlgorithm = pathlib.Path(inspect.getfile(algorithmSource))
146
184
 
@@ -157,13 +195,21 @@ def inlineMapFoldingNumba(**keywordArguments: Optional[str]):
157
195
  ast.fix_missing_locations(callableInlined)
158
196
  callableDecorated = decorateCallableWithNumba(callableInlined, parallel, **keywordArguments)
159
197
 
160
- importsRequired = "\n".join([ast.unparse(importStatement) for importStatement in codeSourceImportStatements])
161
- callableInlined = ast.unparse(callableDecorated)
162
- codeUnpacked = unpackArrays(callableInlined) if callableTarget == 'countSequential' else callableInlined
163
- # inlinedCode = ast.unparse(ast.Module(body=[nodeInlined], type_ignores=[]))
198
+ if callableTarget == 'countSequential':
199
+ myUnpacker = UnpackArrayAccesses(indexMy, 'my')
200
+ callableDecorated = cast(ast.FunctionDef, myUnpacker.visit(callableDecorated))
201
+ ast.fix_missing_locations(callableDecorated)
202
+
203
+ trackUnpacker = UnpackArrayAccesses(indexTrack, 'track')
204
+ callableDecorated = cast(ast.FunctionDef, trackUnpacker.visit(callableDecorated))
205
+ ast.fix_missing_locations(callableDecorated)
206
+
207
+ moduleAST = ast.Module(body=cast(List[ast.stmt], list(codeSourceImportStatements) + [callableDecorated]), type_ignores=[])
208
+ ast.fix_missing_locations(moduleAST)
209
+ moduleSource = ast.unparse(moduleAST)
164
210
 
165
- pathFilenameDestination = pathFilenameAlgorithm.parent / "syntheticModules" / pathFilenameAlgorithm.with_stem(callableTarget).name
166
- pathFilenameDestination.write_text(importsRequired + "\n" + codeUnpacked)
211
+ pathFilenameDestination = pathFilenameAlgorithm.parent / "syntheticModules" / pathFilenameAlgorithm.with_stem(callableTarget).name[5:None]
212
+ pathFilenameDestination.write_text(moduleSource)
167
213
  listPathFilenamesDestination.append(pathFilenameDestination)
168
214
 
169
215
  if __name__ == '__main__':
@@ -1,11 +1,12 @@
1
- from numpy import integer
2
1
  import numba
3
- import numpy
2
+ from numpy import integer
4
3
  from mapFolding import indexMy, indexTrack
4
+ import numpy
5
5
  from typing import Any, Tuple
6
- @numba.jit((numba.uint8[:, :, ::1], numba.uint8[::1], numba.uint8[::1], numba.uint8[:, ::1]), _nrt=True, boundscheck=False, cache=True, error_model='numpy', fastmath=True, forceinline=False, inline='never', looplift=False, no_cfunc_wrapper=True, no_cpython_wrapper=True, nopython=True, parallel=False)
6
+
7
+ @numba.jit((numba.uint8[:, :, ::1], numba.uint8[::1], numba.uint8[::1], numba.uint8[:, ::1]))
7
8
  def countInitialize(connectionGraph: numpy.ndarray[Tuple[int, int, int], numpy.dtype[integer[Any]]], gapsWhere: numpy.ndarray[Tuple[int], numpy.dtype[integer[Any]]], my: numpy.ndarray[Tuple[int], numpy.dtype[integer[Any]]], track: numpy.ndarray[Tuple[int, int], numpy.dtype[integer[Any]]]):
8
- while my[indexMy.leaf1ndex.value] > 0:
9
+ while my[indexMy.leaf1ndex.value]:
9
10
  if my[indexMy.leaf1ndex.value] <= 1 or track[indexTrack.leafBelow.value, 0] == 1:
10
11
  my[indexMy.dimensionsUnconstrained.value] = my[indexMy.dimensionsTotal.value]
11
12
  my[indexMy.gap1ndexCeiling.value] = track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
@@ -35,7 +36,7 @@ def countInitialize(connectionGraph: numpy.ndarray[Tuple[int, int, int], numpy.d
35
36
  my[indexMy.gap1ndex.value] += 1
36
37
  track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] = 0
37
38
  my[indexMy.indexMiniGap.value] += 1
38
- if my[indexMy.leaf1ndex.value] > 0:
39
+ if my[indexMy.leaf1ndex.value]:
39
40
  my[indexMy.gap1ndex.value] -= 1
40
41
  track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]] = gapsWhere[my[indexMy.gap1ndex.value]]
41
42
  track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]] = track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]]
@@ -3,18 +3,19 @@ from typing import Any, Tuple
3
3
  import numba
4
4
  from mapFolding import indexMy, indexTrack
5
5
  import numpy
6
+
6
7
  @numba.jit((numba.uint8[:, :, ::1], numba.int64[::1], numba.uint8[::1], numba.uint8[::1], numba.uint8[:, ::1]), _nrt=True, boundscheck=False, cache=True, error_model='numpy', fastmath=True, forceinline=False, inline='never', looplift=False, no_cfunc_wrapper=True, no_cpython_wrapper=True, nopython=True, parallel=True)
7
8
  def countParallel(connectionGraph: numpy.ndarray[Tuple[int, int, int], numpy.dtype[integer[Any]]], foldGroups: numpy.ndarray[Tuple[int], numpy.dtype[integer[Any]]], gapsWherePARALLEL: numpy.ndarray[Tuple[int], numpy.dtype[integer[Any]]], myPARALLEL: numpy.ndarray[Tuple[int], numpy.dtype[integer[Any]]], trackPARALLEL: numpy.ndarray[Tuple[int, int], numpy.dtype[integer[Any]]]):
8
9
  for indexSherpa in numba.prange(myPARALLEL[indexMy.taskDivisions.value]):
10
+ groupsOfFolds = numba.types.int64(0)
9
11
  gapsWhere = gapsWherePARALLEL.copy()
10
12
  my = myPARALLEL.copy()
11
13
  my[indexMy.taskIndex.value] = indexSherpa
12
14
  track = trackPARALLEL.copy()
13
- groupsOfFolds: int = 0
14
- while my[indexMy.leaf1ndex.value] > 0:
15
+ while my[indexMy.leaf1ndex.value]:
15
16
  if my[indexMy.leaf1ndex.value] <= 1 or track[indexTrack.leafBelow.value, 0] == 1:
16
17
  if my[indexMy.leaf1ndex.value] > foldGroups[-1]:
17
- groupsOfFolds = groupsOfFolds + 1
18
+ groupsOfFolds += 1
18
19
  else:
19
20
  my[indexMy.dimensionsUnconstrained.value] = my[indexMy.dimensionsTotal.value]
20
21
  my[indexMy.gap1ndexCeiling.value] = track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]
@@ -39,11 +40,11 @@ def countParallel(connectionGraph: numpy.ndarray[Tuple[int, int, int], numpy.dty
39
40
  my[indexMy.gap1ndex.value] += 1
40
41
  track[indexTrack.countDimensionsGapped.value, gapsWhere[my[indexMy.indexMiniGap.value]]] = 0
41
42
  my[indexMy.indexMiniGap.value] += 1
42
- while my[indexMy.leaf1ndex.value] > 0 and my[indexMy.gap1ndex.value] == track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]:
43
+ while my[indexMy.leaf1ndex.value] and my[indexMy.gap1ndex.value] == track[indexTrack.gapRangeStart.value, my[indexMy.leaf1ndex.value] - 1]:
43
44
  my[indexMy.leaf1ndex.value] -= 1
44
45
  track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]
45
46
  track[indexTrack.leafAbove.value, track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]]] = track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]
46
- if my[indexMy.leaf1ndex.value] > 0:
47
+ if my[indexMy.leaf1ndex.value]:
47
48
  my[indexMy.gap1ndex.value] -= 1
48
49
  track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]] = gapsWhere[my[indexMy.gap1ndex.value]]
49
50
  track[indexTrack.leafBelow.value, my[indexMy.leaf1ndex.value]] = track[indexTrack.leafBelow.value, track[indexTrack.leafAbove.value, my[indexMy.leaf1ndex.value]]]
@@ -1,28 +1,29 @@
1
1
  from numpy import integer
2
- from typing import Any, Tuple
3
2
  import numba
3
+ from typing import Any, Tuple
4
4
  from mapFolding import indexMy, indexTrack
5
5
  import numpy
6
+
6
7
  @numba.jit((numba.uint8[:, :, ::1], numba.int64[::1], numba.uint8[::1], numba.uint8[::1], numba.uint8[:, ::1]), _nrt=True, boundscheck=False, cache=True, error_model='numpy', fastmath=True, forceinline=False, inline='never', looplift=False, no_cfunc_wrapper=True, no_cpython_wrapper=True, nopython=True, parallel=False)
7
8
  def countSequential(connectionGraph: numpy.ndarray[Tuple[int, int, int], numpy.dtype[integer[Any]]], foldGroups: numpy.ndarray[Tuple[int], numpy.dtype[integer[Any]]], gapsWhere: numpy.ndarray[Tuple[int], numpy.dtype[integer[Any]]], my: numpy.ndarray[Tuple[int], numpy.dtype[integer[Any]]], track: numpy.ndarray[Tuple[int, int], numpy.dtype[integer[Any]]]):
8
- doFindGaps = True
9
- dimensionsTotal = my[indexMy.dimensionsTotal.value]
9
+ leafBelow = track[indexTrack.leafBelow.value]
10
+ gapRangeStart = track[indexTrack.gapRangeStart.value]
11
+ countDimensionsGapped = track[indexTrack.countDimensionsGapped.value]
12
+ leafAbove = track[indexTrack.leafAbove.value]
13
+ leaf1ndex = my[indexMy.leaf1ndex.value]
10
14
  dimensionsUnconstrained = my[indexMy.dimensionsUnconstrained.value]
11
- gap1ndex = my[indexMy.gap1ndex.value]
15
+ dimensionsTotal = my[indexMy.dimensionsTotal.value]
12
16
  gap1ndexCeiling = my[indexMy.gap1ndexCeiling.value]
13
17
  indexDimension = my[indexMy.indexDimension.value]
14
- indexMiniGap = my[indexMy.indexMiniGap.value]
15
- leaf1ndex = my[indexMy.leaf1ndex.value]
16
18
  leafConnectee = my[indexMy.leafConnectee.value]
19
+ indexMiniGap = my[indexMy.indexMiniGap.value]
20
+ gap1ndex = my[indexMy.gap1ndex.value]
17
21
  taskIndex = my[indexMy.taskIndex.value]
18
- leafAbove = track[indexTrack.leafAbove.value]
19
- leafBelow = track[indexTrack.leafBelow.value]
20
- countDimensionsGapped = track[indexTrack.countDimensionsGapped.value]
21
- gapRangeStart = track[indexTrack.gapRangeStart.value]
22
- groupsOfFolds: int = 0
23
- while leaf1ndex > 0:
22
+ groupsOfFolds = numba.types.int64(0)
23
+ doFindGaps = True
24
+ while leaf1ndex:
24
25
  if (doFindGaps := (leaf1ndex <= 1 or leafBelow[0] == 1)) and leaf1ndex > foldGroups[-1]:
25
- groupsOfFolds = groupsOfFolds + 1
26
+ groupsOfFolds += 1
26
27
  elif doFindGaps:
27
28
  dimensionsUnconstrained = dimensionsTotal
28
29
  gap1ndexCeiling = gapRangeStart[leaf1ndex - 1]
@@ -46,11 +47,11 @@ def countSequential(connectionGraph: numpy.ndarray[Tuple[int, int, int], numpy.d
46
47
  gap1ndex += 1
47
48
  countDimensionsGapped[gapsWhere[indexMiniGap]] = 0
48
49
  indexMiniGap += 1
49
- while leaf1ndex > 0 and gap1ndex == gapRangeStart[leaf1ndex - 1]:
50
+ while leaf1ndex and gap1ndex == gapRangeStart[leaf1ndex - 1]:
50
51
  leaf1ndex -= 1
51
52
  leafBelow[leafAbove[leaf1ndex]] = leafBelow[leaf1ndex]
52
53
  leafAbove[leafBelow[leaf1ndex]] = leafAbove[leaf1ndex]
53
- if leaf1ndex > 0:
54
+ if leaf1ndex:
54
55
  gap1ndex -= 1
55
56
  leafAbove[leaf1ndex] = gapsWhere[gap1ndex]
56
57
  leafBelow[leaf1ndex] = leafBelow[leafAbove[leaf1ndex]]
@@ -1,3 +1,4 @@
1
- from .countSequential import countSequential
2
- from .countParallel import countParallel
3
- from .countInitialize import countInitialize
1
+ from .Initialize import countInitialize
2
+ from .Parallel import countParallel
3
+ from .Sequential import countSequential
4
+
@@ -1,26 +0,0 @@
1
- benchmarks/benchmarking.py,sha256=HD_0NSvuabblg94ftDre6LFnXShTe8MYj3hIodW-zV0,3076
2
- citations/updateCitation.py,sha256=3AUPo9_4SfH8AwQBMRl7KygAXoMRjQSqFl3ERWxtrtk,2541
3
- reference/flattened.py,sha256=6blZ2Y9G8mu1F3gV8SKndPE398t2VVFlsgKlyeJ765A,16538
4
- reference/hunterNumba.py,sha256=HWndRgsajOf76rbb2LDNEZ6itsdYbyV-k3wgOFjeR6c,7104
5
- reference/irvineJavaPort.py,sha256=Sj-63Z-OsGuDoEBXuxyjRrNmmyl0d7Yz_XuY7I47Oyg,4250
6
- reference/jax.py,sha256=rojyK80lOATtbzxjGOHWHZngQa47CXCLJHZwIdN2MwI,14955
7
- reference/lunnan.py,sha256=XEcql_gxvCCghb6Or3qwmPbn4IZUbZTaSmw_fUjRxZE,5037
8
- reference/lunnanNumpy.py,sha256=HqDgSwTOZA-G0oophOEfc4zs25Mv4yw2aoF1v8miOLk,4653
9
- reference/lunnanWhile.py,sha256=7NY2IKO5XBgol0aWWF_Fi-7oTL9pvu_z6lB0TF1uVHk,4063
10
- reference/rotatedEntryPoint.py,sha256=z0QyDQtnMvXNj5ntWzzJUQUMFm1-xHGLVhtYzwmczUI,11530
11
- reference/total_countPlus1vsPlusN.py,sha256=usenM8Yn_G1dqlPl7NKKkcnbohBZVZBXTQRm2S3_EDA,8106
12
- someAssemblyRequired/__init__.py,sha256=7iODZE6dM4h52spgivUvAuVsvYdSx-_YcSTz1gX82Vw,89
13
- someAssemblyRequired/generalizeSourceCode.py,sha256=qyJD0ZdG0t-SYTItL_JjaIXm3-joWt3e-2nMSAH4Dbg,6392
14
- someAssemblyRequired/getLLVMforNoReason.py,sha256=FtJzw2pZS3A4NimWdZsegXaU-vKeCw8m67kcfb5wvGM,894
15
- someAssemblyRequired/makeJob.py,sha256=iaLjr-FhFloTF6wSuwOpurgpqJulZht9CxNo9MDidbg,949
16
- someAssemblyRequired/synthesizeModuleJob.py,sha256=xLak-ZZ1zQ92jBobhJqbnA1Fua9ofiRvLdK1fmD8s_s,7271
17
- someAssemblyRequired/synthesizeModules.py,sha256=JGOx69DGCcCntRtw7aOXXcmERCHqVyhFo1oiKh3P8Mg,8842
18
- syntheticModules/__init__.py,sha256=nDtS5UFMKN-F5pTp0qKA0J0I-XR3n3OFxV2bosieBu8,131
19
- syntheticModules/countInitialize.py,sha256=QqKfQxCmUJuJutNxOZ0VfqYEHnuk7XSkCYx7RKz3kn4,4239
20
- syntheticModules/countParallel.py,sha256=77JzO3TsccjSUJRExZ0Nxdqowd_Sm0_2bRziVx5XMI4,5355
21
- syntheticModules/countSequential.py,sha256=QixgcN9R5zcrmJjxSO4oOCYViWogA35HbDNlni9hw8o,3655
22
- mapFolding-0.3.4.dist-info/METADATA,sha256=v8MJLZBzqS2hBp4trsRjjLzn8RAsddUPg16IiI9J1cg,7617
23
- mapFolding-0.3.4.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
24
- mapFolding-0.3.4.dist-info/entry_points.txt,sha256=F3OUeZR1XDTpoH7k3wXuRb3KF_kXTTeYhu5AGK1SiOQ,146
25
- mapFolding-0.3.4.dist-info/top_level.txt,sha256=yVG9dNZywoaddcsUdEDg7o0XOBzJd_4Z-sDaXGHpiMY,69
26
- mapFolding-0.3.4.dist-info/RECORD,,