mapFolding 0.3.6__py3-none-any.whl → 0.3.8__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.
citations/constants.py ADDED
@@ -0,0 +1,3 @@
1
+ GITHUB_API_VERSION_HEADER = {
2
+ "X-GitHub-Api-Version": "2022-11-28"
3
+ }
@@ -1,116 +1,354 @@
1
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
2
+ from mapFolding.citations.constants import GITHUB_API_VERSION_HEADER
3
+ from packaging.metadata import Metadata as PyPAMetadata
4
+ from typing import Any, Dict, List
5
+ import attrs
4
6
  import cffconvert
5
- import pathlib
6
- import packaging.metadata
7
- import tomli
8
- import inspect
9
- import json
10
- import ruamel.yaml
7
+ import os
11
8
  import packaging
12
- from packaging.metadata import Metadata as PyPAMetadata
9
+ import packaging.metadata
13
10
  import packaging.utils
14
11
  import packaging.version
12
+ import pathlib
13
+ import requests
14
+ import ruamel.yaml
15
+ import tomli
16
+
17
+ listProjectURLsTarget: List[str] = ["homepage", "license", "repository"]
18
+
19
+ """
20
+ Tentative plan:
21
+ - Commit and push to GitHub
22
+ - GitHub Action gathers information from the sources of truth
23
+ - If the citation needs to be updated, write to both
24
+ - pathFilenameCitationSSOT
25
+ - pathFilenameCitationDOTcffRepo
26
+ - Commit and push to GitHub
27
+ - this complicates things
28
+ - I want the updated citation to be in the `commit` field of itself: but the commit field isn't even working right now
29
+ """
15
30
 
16
- def addPypaMetadata(citation: cffconvert.Citation, metadata: PyPAMetadata) -> cffconvert.Citation:
17
- # https://github.com/citation-file-format/cff-initializer-javascript
31
+ @attrs.define
32
+ class CitationNexus:
18
33
  """
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
34
+ - one-to-one correlation with `cffconvert.lib.cff_1_2_x.citation` class Citation_1_2_x.cffobj
25
35
  """
26
- return citation
36
+ cffDASHversion: str
37
+ message: str
38
+
39
+ abstract: str | None = None
40
+ authors: list[dict[str,str]] = attrs.field(factory=list)
41
+ # GitHub TODO
42
+ commit: str | None = None
43
+ contact: list[dict[str,str]] = attrs.field(factory=list)
44
+ dateDASHreleased: str | None = None
45
+ doi: str | None = None
46
+ identifiers: list[str] = attrs.field(factory=list)
47
+ keywords: list[str] = attrs.field(factory=list)
48
+ license: str | None = None
49
+ licenseDASHurl: str | None = None
50
+ preferredDASHcitation: str | None = None
51
+ # TODO bibtex files in pathCitationSSOT. Conversion method and timing TBD.
52
+ references: list[str] = attrs.field(factory=list)
53
+ repository: str | None = None
54
+ repositoryDASHartifact: str | None = None
55
+ repositoryDASHcode: str | None = None
56
+ title: str | None = None
57
+ type: str | None = None
58
+ url: str | None = None
59
+ version: str | None = None
60
+
61
+ def setInStone(self, prophet: str) -> "CitationNexus":
62
+ match prophet:
63
+ case "Citation":
64
+ pass
65
+ # "freeze" these items
66
+ # setattr(self.cffDASHversion, 'type', Final[str])
67
+ # setattr(self.doi, 'type', Final[str])
68
+ # cffDASHversion: str
69
+ # message: str
70
+ # abstract: str | None = None
71
+ # doi: str | None = None
72
+ # preferredDASHcitation: str | None = None
73
+ # type: str | None = None
74
+ case "GitHub":
75
+ pass
76
+ # "freeze" these items
77
+ # setattr(self.commit, 'type', Final[str])
78
+ # setattr(self.dateDASHreleased, 'type', Final[str])
79
+ # setattr(self.identifiers, 'type', Final[list[str]])
80
+ # setattr(self.repositoryDASHcode, 'type', Final[str])
81
+ case "PyPA":
82
+ pass
83
+ # "freeze" these items
84
+ # setattr(self.keywords, 'type', Final[list[str]])
85
+ # setattr(self.license, 'type', Final[str])
86
+ # setattr(self.licenseDASHurl, 'type', Final[str])
87
+ # setattr(self.repository, 'type', Final[str])
88
+ # setattr(self.url, 'type', Final[str])
89
+ # setattr(self.version, 'type', Final[str])
90
+ case "PyPI":
91
+ pass
92
+ # "freeze" these items
93
+ # setattr(self.repositoryDASHartifact, 'type', Final[str])
94
+ case "pyprojectDOTtoml":
95
+ pass
96
+ # "freeze" these items
97
+ # setattr(self.authors, 'type', Final[list[dict[str,str]]])
98
+ # setattr(self.contact, 'type', Final[list[dict[str,str]]])
99
+ # setattr(self.title, 'type', Final[str])
100
+ return self
101
+
102
+ def addPypaMetadata(nexusCitation: CitationNexus, metadata: PyPAMetadata) -> CitationNexus:
103
+ if not metadata.name:
104
+ raise ValueError("Metadata name is required.")
105
+
106
+ nexusCitation.title = metadata.name
107
+ if metadata.version: nexusCitation.version = str(metadata.version)
108
+ if metadata.keywords: nexusCitation.keywords = metadata.keywords
109
+ if metadata.license_expression: nexusCitation.license = metadata.license_expression
110
+
111
+ Z0Z_lookup: Dict[str, str] = {
112
+ "homepage": "url",
113
+ "license": "licenseDASHurl",
114
+ "repository": "repository",
115
+ }
116
+ if metadata.project_urls:
117
+ for urlTarget in listProjectURLsTarget:
118
+ url = metadata.project_urls.get(urlTarget, None)
119
+ if url:
120
+ setattr(nexusCitation, Z0Z_lookup[urlTarget], url)
121
+
122
+ nexusCitation = nexusCitation.setInStone("PyPA")
123
+ return nexusCitation
124
+
125
+ def add_pyprojectDOTtoml(nexusCitation: CitationNexus, packageData: Dict[str, Any]) -> CitationNexus:
126
+ def Z0Z_ImaNotValidatingNoNames(person: Dict[str, str]) -> Dict[str, str]:
127
+ cffPerson: Dict[str, str] = {}
128
+ if person.get('name', None):
129
+ cffPerson['given-names'], cffPerson['family-names'] = person['name'].split(' ', 1)
130
+ if person.get('email', None):
131
+ cffPerson['email'] = person['email']
132
+ return cffPerson
133
+ listAuthors = packageData.get("authors", None)
134
+ if not listAuthors:
135
+ raise ValueError("Authors are required.")
136
+ else:
137
+ listPersons = []
138
+ for person in listAuthors:
139
+ listPersons.append(Z0Z_ImaNotValidatingNoNames(person))
140
+ nexusCitation.authors = listPersons
141
+ if packageData.get("maintainers", None):
142
+ listPersons = []
143
+ for person in packageData["maintainers"]:
144
+ listPersons.append(Z0Z_ImaNotValidatingNoNames(person))
145
+ nexusCitation.contact = listPersons
146
+ nexusCitation.title = packageData["name"]
147
+ nexusCitation = nexusCitation.setInStone("pyprojectDOTtoml")
148
+ return nexusCitation
149
+
150
+ def getGitHubRelease(nexusCitation: CitationNexus) -> Dict[str, Any]:
151
+ """Return a dictionary with GitHub release data.
152
+
153
+ The dictionary contains the following keys:
154
+ commit: The commit hash (using the API field 'target_commitish').
155
+ date-released: The published date (in YYYY-MM-DD format).
156
+ identifiers: A list with one identifier object, whose description is
157
+ 'The URL for {nexusCitation.title} {nexusCitation.version}.'
158
+ repository-code: A URL for the commit in the repository.
159
+
160
+ Raises:
161
+ ValueError: If the nexusCitation.repository is not set or cannot be parsed.
162
+ RuntimeError: If the HTTP request to GitHub fails.
163
+ """
164
+ if not nexusCitation.repository:
165
+ raise ValueError("Repository URL is required to get GitHub release info.")
166
+
167
+ urlparts = nexusCitation.repository.replace("https://github.com", "", 1).strip("/").split("/") + [None] * 5
168
+ ownername, reponame, _2, refvalue, *_filename_parts = urlparts
169
+ reponame = reponame.replace(".git", "") # type: ignore # Remove .git from the repository name, if present.
170
+ assert ownername is not None, "URL should include the name of the owner/organization."
171
+ assert reponame is not None, "URL should include the name of the repository."
172
+ if refvalue is None:
173
+ repos_api = f"https://api.github.com/repos/{ownername}/{reponame}/releases/latest"
174
+ headers = GITHUB_API_VERSION_HEADER
175
+ headers.update({"Accept": "application/vnd.github+json"})
176
+ token = os.environ.get("GITHUB_TOKEN")
177
+ headers.update({"Authorization": f"Bearer { token }"})
178
+ response = requests.get(repos_api, headers=headers)
179
+ if response.status_code != 200:
180
+ raise RuntimeError(f"Failed to get GitHub release info: {response.status_code}")
181
+
182
+ releaseData = response.json()
183
+ # commitHash = releaseData.get("target_commitish")
184
+ publishedAt = releaseData.get("published_at")
185
+ if publishedAt:
186
+ # Convert ISO timestamp (e.g., "2020-12-31T12:34:56Z") to "YYYY-MM-DD".
187
+ publishedAt = publishedAt.split("T")[0]
188
+
189
+ releaseHtmlUrl = releaseData.get("html_url")
190
+ identifierDescription = f"The URL for {nexusCitation.title} {nexusCitation.version}."
191
+ return {
192
+ # "commit": commitHash,
193
+ "dateDASHreleased": publishedAt,
194
+ "identifiers": [{
195
+ "type": "url",
196
+ "value": releaseHtmlUrl,
197
+ "description": identifierDescription,
198
+ }],
199
+ "repositoryDASHcode": releaseHtmlUrl,
200
+ }
201
+
202
+ def addGitHubRelease(nexusCitation: CitationNexus) -> CitationNexus:
203
+ """
204
+ Update the nexusCitation with GitHub release information.
205
+
206
+ This function populates the following fields on the nexusCitation:
207
+ - commit: using the commit hash from GitHub.
208
+ - dateDASHreleased: the release date.
209
+ - identifiers: appends a GitHub-specific identifier.
210
+ - repositoryDASHcode: the URL to view the commit in the repository.
211
+
212
+ Returns:
213
+ The updated CitationNexus instance.
214
+
215
+ Raises:
216
+ Any exception raised by getGitHubRelease.
217
+ """
218
+ gitHubReleaseData = getGitHubRelease(nexusCitation)
219
+ nexusCitation.commit = gitHubReleaseData.get("commit")
220
+ nexusCitation.dateDASHreleased = gitHubReleaseData.get("dateDASHreleased")
221
+ # Overwrite the existing list of identifiers. This could be better
222
+ nexusCitation.identifiers = gitHubReleaseData.get("identifiers", [])
223
+ nexusCitation.repositoryDASHcode = gitHubReleaseData.get("repositoryDASHcode")
224
+ return nexusCitation
225
+
226
+ def getPyPIrelease(nexusCitation: CitationNexus) -> Dict[str, Any]:
227
+ if not nexusCitation.title:
228
+ raise ValueError("Package name (title) is required to get PyPI release info.")
229
+ if not nexusCitation.version:
230
+ raise ValueError("Package version is required to get PyPI release info.")
231
+
232
+ packageName = packaging.utils.canonicalize_name(nexusCitation.title)
233
+ version = str(nexusCitation.version)
234
+ return {
235
+ "repositoryDASHartifact": f"https://pypi.org/project/{packageName}/{version}/"
236
+ }
237
+
238
+ def addPyPIrelease(nexusCitation: CitationNexus) -> CitationNexus:
239
+ pypiReleaseData = getPyPIrelease(nexusCitation)
240
+ nexusCitation.repositoryDASHartifact = pypiReleaseData.get("repositoryDASHartifact")
241
+ return nexusCitation
242
+
243
+ def getNexusCitation(pathFilenameCitationSSOT: pathlib.Path) -> CitationNexus:
244
+
245
+ # `cffconvert.cli.create_citation.create_citation()` is PAINFULLY mundane, but a major problem
246
+ # in the CFF ecosystem is divergence. Therefore, I will use this function so that my code
247
+ # converges with the CFF ecosystem.
248
+ citationObject: cffconvert.Citation = create_citation(infile=pathFilenameCitationSSOT, url=None)
249
+ # `._parse()` is a yaml loader: use it for convergence
250
+ cffobj: Dict[Any, Any] = citationObject._parse()
251
+
252
+ nexusCitation = CitationNexus(
253
+ cffDASHversion=cffobj["cff-version"],
254
+ message=cffobj["message"],
255
+ )
256
+
257
+ Z0Z_list: List[attrs.Attribute] = list(attrs.fields(type(nexusCitation)))
258
+ for Z0Z_field in Z0Z_list:
259
+ cffobjKeyName: str = Z0Z_field.name.replace("DASH", "-")
260
+ cffobjValue = cffobj.get(cffobjKeyName)
261
+ if cffobjValue: # An empty list will be False
262
+ setattr(nexusCitation, Z0Z_field.name, cffobjValue)
263
+
264
+ nexusCitation = nexusCitation.setInStone("Citation")
265
+ return nexusCitation
27
266
 
28
267
  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
268
+ """
269
+ Create a PyPA metadata object (version 2.4) from packageData.
270
+ https://packaging.python.org/en/latest/specifications/core-metadata/
271
+ """
272
+ dictionaryProjectURLs: Dict[str, str] = {}
273
+ for urlName, url in packageData.get("urls", {}).items():
274
+ urlName = urlName.lower()
275
+ if urlName in listProjectURLsTarget:
276
+ dictionaryProjectURLs[urlName] = url
34
277
 
35
278
  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),
279
+ keywords=packageData.get("keywords", []),
280
+ license_expression=packageData.get("license", {}).get("text", ""),
281
+ metadata_version="2.4",
282
+ name=packaging.utils.canonicalize_name(packageData.get("name", None), validate=True), # packaging.metadata.InvalidMetadata: 'name' is a required field
40
283
  project_urls=dictionaryProjectURLs,
41
- version=packageData.get('version', None),
284
+ version=packageData.get("version", None),
42
285
  )
43
286
 
44
287
  metadata = PyPAMetadata().from_raw(metadataRaw)
45
288
  return metadata
46
289
 
47
- """
48
- Tentative plan:
49
- - Commit and push to GitHub
50
- - GitHub Action gathers information from the sources of truth
51
- - If the citation needs to be updated, write to both
52
- - pathFilenameCitationSSOT
53
- - pathFilenameCitationDOTcffRepo
54
- - Commit and push to GitHub
55
- - this complicates things
56
- - I want the updated citation to be in the `commit` field of itself
57
- """
58
- """cffconvert.Citation fields and the source of truth
59
- abstract: pathFilenameCitationSSOT
60
- authors: pathFilenamePackageSSOT
61
- cff-version: pathFilenameCitationSSOT
62
- commit: workflows['Make GitHub Release']
63
- contact: pathFilenamePackageSSOT
64
- date-released: workflows['Make GitHub Release']
65
- doi: pathFilenameCitationSSOT
66
- identifiers: workflows['Make GitHub Release']
67
- license-url: pathFilenamePackageSSOT
68
- message: pathFilenameCitationSSOT
69
- preferred-citation: pathFilenameCitationSSOT
70
- references: to be determined
71
- repository-artifact: (https://pypi.org/pypi/{package_name}/json').json()['releases']
72
- repository-code: workflows['Make GitHub Release']
73
- type: pathFilenameCitationSSOT
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
81
- """
290
+ def writeCitation(nexusCitation: CitationNexus, pathFilenameCitationSSOT: pathlib.Path, pathFilenameCitationDOTcffRepo: pathlib.Path):
291
+ # NOTE embarrassingly hacky process to follow
292
+ parameterIndent= 2
293
+ parameterLineWidth = 60
294
+ yamlWorkhorse = ruamel.yaml.YAML()
295
+
296
+ def srsly(Z0Z_filed, Z0Z_value):
297
+ if Z0Z_value: # empty lists
298
+ return True
299
+ else:
300
+ return False
301
+
302
+ dictionaryCitation = attrs.asdict(nexusCitation, filter=srsly)
303
+ for keyName in list(dictionaryCitation.keys()):
304
+ dictionaryCitation[keyName.replace("DASH", "-")] = dictionaryCitation.pop(keyName)
305
+
306
+ pathFilenameForValidation = pathFilenameCitationSSOT.with_stem('validation')
307
+
308
+ def writeStream(pathFilename):
309
+ with open(pathFilename, 'w') as pathlibIsAStealthContextManagerThatRuamelCannotDetectAndRefusesToWorkWith:
310
+ yamlWorkhorse.dump(dictionaryCitation, pathlibIsAStealthContextManagerThatRuamelCannotDetectAndRefusesToWorkWith)
311
+
312
+ writeStream(pathFilenameForValidation)
313
+
314
+ citationObject: cffconvert.Citation = create_citation(infile=pathFilenameForValidation, url=None)
315
+ if citationObject.validate() is None:
316
+ writeStream(pathFilenameCitationSSOT)
317
+ writeStream(pathFilenameCitationDOTcffRepo)
318
+
319
+ pathFilenameForValidation.unlink()
82
320
 
83
321
  def logistics():
84
322
  # Prefer reliable, dynamic values over hardcoded ones
85
- packageName: str = 'mapFolding'
86
323
  pathRepoRoot = pathlib.Path(__file__).parent.parent.parent
87
324
  pathFilenamePackageSSOT = pathRepoRoot / 'pyproject.toml'
88
- filenameGitHubAction = 'updateCitation.yml'
89
- pathFilenameGitHubAction = pathRepoRoot / '.github' / 'workflows' / filenameGitHubAction
325
+
326
+ tomlPackageData: Dict[str, Any] = tomli.loads(pathFilenamePackageSSOT.read_text())['project']
327
+ # https://packaging.python.org/en/latest/specifications/pyproject-toml/
328
+
329
+ packageName: str = tomlPackageData.get("name", None)
330
+ if not packageName:
331
+ raise ValueError("Package name is required.")
90
332
 
91
333
  filenameCitationDOTcff = 'CITATION.cff'
92
334
  pathCitations = pathRepoRoot / packageName / 'citations'
93
335
  pathFilenameCitationSSOT = pathCitations / filenameCitationDOTcff
94
336
  pathFilenameCitationDOTcffRepo = pathRepoRoot / filenameCitationDOTcff
95
337
 
96
- citationObject: cffconvert.Citation = create_citation(infile=pathFilenameCitationSSOT, url=None)
97
- print(citationObject._parse().as_cff())
338
+ nexusCitation = getNexusCitation(pathFilenameCitationSSOT)
98
339
 
99
- tomlPackageData: Dict[str, Any] = tomli.loads(pathFilenamePackageSSOT.read_text())['project']
100
- # https://packaging.python.org/en/latest/specifications/pyproject-toml/
101
340
  pypaMetadata: PyPAMetadata = getPypaMetadata(tomlPackageData)
102
341
 
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)
342
+ nexusCitation = addPypaMetadata(nexusCitation, pypaMetadata)
343
+ nexusCitation = add_pyprojectDOTtoml(nexusCitation, tomlPackageData)
105
344
 
106
- if __name__ == '__main__':
107
- logistics()
345
+ nexusCitation = addGitHubRelease(nexusCitation)
346
+ nexusCitation = addPyPIrelease(nexusCitation)
108
347
 
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']
348
+ filenameGitHubAction = 'updateCitation.yml'
349
+ pathFilenameGitHubAction = pathRepoRoot / '.github' / 'workflows' / filenameGitHubAction
350
+
351
+ writeCitation(nexusCitation, pathFilenameCitationSSOT, pathFilenameCitationDOTcffRepo)
114
352
 
115
- # for property, subProperties in schemaSpecifications.items():
116
- # print(property, subProperties.get('items', None))
353
+ if __name__ == '__main__':
354
+ logistics()
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mapFolding
3
- Version: 0.3.6
3
+ Version: 0.3.8
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
+ Project-URL: Repository, https://github.com/hunterhogan/mapFolding.git
10
10
  Keywords: A001415,A001416,A001417,A001418,A195646,folding,map folding,OEIS,stamp folding
11
11
  Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Environment :: Console
@@ -30,12 +30,13 @@ Requires-Dist: jupyter; extra == "benchmark"
30
30
  Requires-Dist: pandas; extra == "benchmark"
31
31
  Requires-Dist: tqdm; extra == "benchmark"
32
32
  Provides-Extra: testing
33
+ Requires-Dist: attrs; extra == "testing"
33
34
  Requires-Dist: cffconvert; extra == "testing"
34
35
  Requires-Dist: more_itertools; extra == "testing"
35
- Requires-Dist: pytest; extra == "testing"
36
36
  Requires-Dist: pytest-cov; extra == "testing"
37
37
  Requires-Dist: pytest-env; extra == "testing"
38
38
  Requires-Dist: pytest-xdist; extra == "testing"
39
+ Requires-Dist: pytest; extra == "testing"
39
40
  Requires-Dist: python_minifier; extra == "testing"
40
41
  Requires-Dist: tomli; extra == "testing"
41
42
 
@@ -0,0 +1,26 @@
1
+ benchmarks/benchmarking.py,sha256=HD_0NSvuabblg94ftDre6LFnXShTe8MYj3hIodW-zV0,3076
2
+ citations/constants.py,sha256=1n3AC_18LOjmMLJWDo8YOGEIvDY7oZyLtI4QwqdB6z4,73
3
+ citations/updateCitation.py,sha256=ihZFafY1TtVgQ1cnVNAHGCJMgoBUR8cm1qvGobwjNKA,14949
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/getLLVMforNoReason.py,sha256=FtJzw2pZS3A4NimWdZsegXaU-vKeCw8m67kcfb5wvGM,894
15
+ someAssemblyRequired/makeJob.py,sha256=UUCNdkFnSrlhRAjkQp2_Qv4joKGXRnNJhZ4OdxI_aqU,2628
16
+ someAssemblyRequired/synthesizeModuleJobNumba.py,sha256=TCYNNI19vCw0C1FLP691VPpYknkedj-zpx-xQFVIVJU,9851
17
+ someAssemblyRequired/synthesizeModulesNumba.py,sha256=aOst0EC5zStLbUSDTpyMoyQe_8_3CLX7JSdHdPmlAsY,22847
18
+ syntheticModules/__init__.py,sha256=XMjNt8x24M82i1eCNVcWpIIhXwfVCnjfbb-y36RAafA,131
19
+ syntheticModules/numbaInitialize.py,sha256=H8Y22wwE5kYyroztAJ5HJ2W6qfw7Fu4iVrUsCPmnFjY,4088
20
+ syntheticModules/numbaParallel.py,sha256=fvprhBepBxQkY5yQInYRWb7agDVMArypGC6Y510tAcU,5452
21
+ syntheticModules/numbaSequential.py,sha256=Knru1I7BBvsBDTex7NfxO2U3IEcQfz-uG4Lpw2tLhOI,3629
22
+ mapFolding-0.3.8.dist-info/METADATA,sha256=hgOrdxAEB5vsBdIK41JvUc65iHQladkMBbbXwg-YPnc,7729
23
+ mapFolding-0.3.8.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
24
+ mapFolding-0.3.8.dist-info/entry_points.txt,sha256=F3OUeZR1XDTpoH7k3wXuRb3KF_kXTTeYhu5AGK1SiOQ,146
25
+ mapFolding-0.3.8.dist-info/top_level.txt,sha256=yVG9dNZywoaddcsUdEDg7o0XOBzJd_4Z-sDaXGHpiMY,69
26
+ mapFolding-0.3.8.dist-info/RECORD,,
@@ -1,25 +1,53 @@
1
- from mapFolding import getPathFilenameFoldsTotal, computationState
2
- from mapFolding import outfitCountFolds
1
+ import importlib.util
2
+ from mapFolding import getPathFilenameFoldsTotal, computationState, outfitCountFolds, getAlgorithmSource
3
3
  from typing import Any, Literal, Optional, Sequence, Type, overload
4
4
  import pathlib
5
5
  import pickle
6
6
 
7
7
  @overload
8
8
  def makeStateJob(listDimensions: Sequence[int], writeJob: Literal[True] = True
9
- , **keywordArguments: Optional[Type[Any]]) -> pathlib.Path:
9
+ , **keywordArguments: Optional[str]) -> pathlib.Path:
10
10
  ...
11
11
 
12
12
  @overload
13
13
  def makeStateJob(listDimensions: Sequence[int], writeJob: Literal[False] = False
14
- , **keywordArguments: Optional[Type[Any]]) -> computationState:
14
+ , **keywordArguments: Optional[str]) -> computationState:
15
15
  ...
16
16
 
17
- def makeStateJob(listDimensions: Sequence[int], writeJob: bool = True, **keywordArguments: Optional[Type[Any]]) -> computationState | pathlib.Path:
17
+ def makeStateJob(listDimensions: Sequence[int], writeJob: bool = True, **keywordArguments: Optional[str]) -> computationState | pathlib.Path:
18
+ """
19
+ Creates a computation state job for map folding calculations and optionally saves it to disk.
20
+
21
+ This function initializes a computation state for map folding calculations based on the given dimensions,
22
+ sets up the initial counting configuration, and can optionally save the state to a pickle file.
23
+
24
+ Parameters
25
+ ----------
26
+ listDimensions : Sequence[int]
27
+ The dimensions of the map to be folded, typically as [height, width].
28
+ writeJob : bool, optional
29
+ If True, saves the computation state to disk. If False, returns the state object directly.
30
+ Default is True.
31
+ **keywordArguments : Optional[str]
32
+ Additional keyword arguments to be passed to the outfitCountFolds function.
33
+
34
+ Returns
35
+ -------
36
+ Union[computationState, pathlib.Path]
37
+ If writeJob is False, returns the computation state object.
38
+ If writeJob is True, returns the Path object pointing to the saved state file.
39
+
40
+ Notes
41
+ -----
42
+ The function creates necessary directories and saves the state as a pickle file
43
+ when writeJob is True. The file is saved in a directory structure based on the map shape.
44
+ """
18
45
 
19
46
  stateUniversal: computationState = outfitCountFolds(listDimensions, computationDivisions=None, CPUlimit=None, **keywordArguments)
20
47
 
21
- from mapFolding.syntheticModules import countInitialize
22
- countInitialize(stateUniversal['connectionGraph'], stateUniversal['gapsWhere'], stateUniversal['my'], stateUniversal['track'])
48
+
49
+ moduleSource = getAlgorithmSource()
50
+ moduleSource.countInitialize(stateUniversal['connectionGraph'], stateUniversal['gapsWhere'], stateUniversal['my'], stateUniversal['track'])
23
51
 
24
52
  if not writeJob:
25
53
  return stateUniversal