mapFolding 0.3.6__tar.gz → 0.3.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. {mapfolding-0.3.6 → mapfolding-0.3.8}/PKG-INFO +5 -4
  2. mapfolding-0.3.8/mapFolding/citations/constants.py +3 -0
  3. mapfolding-0.3.8/mapFolding/citations/updateCitation.py +354 -0
  4. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/mapFolding.egg-info/PKG-INFO +5 -4
  5. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/mapFolding.egg-info/SOURCES.txt +6 -7
  6. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/mapFolding.egg-info/requires.txt +2 -1
  7. mapfolding-0.3.8/mapFolding/someAssemblyRequired/makeJob.py +62 -0
  8. mapfolding-0.3.6/mapFolding/someAssemblyRequired/synthesizeModuleJob.py → mapfolding-0.3.8/mapFolding/someAssemblyRequired/synthesizeModuleJobNumba.py +85 -30
  9. mapfolding-0.3.8/mapFolding/someAssemblyRequired/synthesizeModulesNumba.py +446 -0
  10. mapfolding-0.3.8/mapFolding/syntheticModules/__init__.py +3 -0
  11. mapfolding-0.3.6/mapFolding/syntheticModules/Initialize.py → mapfolding-0.3.8/mapFolding/syntheticModules/numbaInitialize.py +8 -5
  12. mapfolding-0.3.6/mapFolding/syntheticModules/Parallel.py → mapfolding-0.3.8/mapFolding/syntheticModules/numbaParallel.py +10 -6
  13. mapfolding-0.3.6/mapFolding/syntheticModules/Sequential.py → mapfolding-0.3.8/mapFolding/syntheticModules/numbaSequential.py +4 -4
  14. {mapfolding-0.3.6 → mapfolding-0.3.8}/pyproject.toml +4 -3
  15. {mapfolding-0.3.6 → mapfolding-0.3.8}/tests/test_other.py +7 -6
  16. mapfolding-0.3.6/mapFolding/citations/updateCitation.py +0 -116
  17. mapfolding-0.3.6/mapFolding/citations/updateCitationgpt.py +0 -125
  18. mapfolding-0.3.6/mapFolding/someAssemblyRequired/generalizeSourceCode.py +0 -122
  19. mapfolding-0.3.6/mapFolding/someAssemblyRequired/makeJob.py +0 -34
  20. mapfolding-0.3.6/mapFolding/someAssemblyRequired/synthesizeModules.py +0 -216
  21. mapfolding-0.3.6/mapFolding/syntheticModules/__init__.py +0 -4
  22. {mapfolding-0.3.6 → mapfolding-0.3.8}/README.md +0 -0
  23. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/benchmarks/benchmarking.py +0 -0
  24. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/mapFolding.egg-info/dependency_links.txt +0 -0
  25. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/mapFolding.egg-info/entry_points.txt +0 -0
  26. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/mapFolding.egg-info/top_level.txt +0 -0
  27. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/reference/flattened.py +0 -0
  28. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/reference/hunterNumba.py +0 -0
  29. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/reference/irvineJavaPort.py +0 -0
  30. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/reference/jax.py +0 -0
  31. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/reference/lunnan.py +0 -0
  32. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/reference/lunnanNumpy.py +0 -0
  33. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/reference/lunnanWhile.py +0 -0
  34. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/reference/rotatedEntryPoint.py +0 -0
  35. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
  36. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/someAssemblyRequired/__init__.py +0 -0
  37. {mapfolding-0.3.6 → mapfolding-0.3.8}/mapFolding/someAssemblyRequired/getLLVMforNoReason.py +0 -0
  38. {mapfolding-0.3.6 → mapfolding-0.3.8}/setup.cfg +0 -0
  39. {mapfolding-0.3.6 → mapfolding-0.3.8}/tests/test_oeis.py +0 -0
  40. {mapfolding-0.3.6 → mapfolding-0.3.8}/tests/test_tasks.py +0 -0
@@ -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,3 @@
1
+ GITHUB_API_VERSION_HEADER = {
2
+ "X-GitHub-Api-Version": "2022-11-28"
3
+ }
@@ -0,0 +1,354 @@
1
+ from cffconvert.cli.create_citation import create_citation
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
6
+ import cffconvert
7
+ import os
8
+ import packaging
9
+ import packaging.metadata
10
+ import packaging.utils
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
+ """
30
+
31
+ @attrs.define
32
+ class CitationNexus:
33
+ """
34
+ - one-to-one correlation with `cffconvert.lib.cff_1_2_x.citation` class Citation_1_2_x.cffobj
35
+ """
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
266
+
267
+ def getPypaMetadata(packageData: Dict[str, Any]) -> PyPAMetadata:
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
277
+
278
+ metadataRaw = packaging.metadata.RawMetadata(
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
283
+ project_urls=dictionaryProjectURLs,
284
+ version=packageData.get("version", None),
285
+ )
286
+
287
+ metadata = PyPAMetadata().from_raw(metadataRaw)
288
+ return metadata
289
+
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()
320
+
321
+ def logistics():
322
+ # Prefer reliable, dynamic values over hardcoded ones
323
+ pathRepoRoot = pathlib.Path(__file__).parent.parent.parent
324
+ pathFilenamePackageSSOT = pathRepoRoot / 'pyproject.toml'
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.")
332
+
333
+ filenameCitationDOTcff = 'CITATION.cff'
334
+ pathCitations = pathRepoRoot / packageName / 'citations'
335
+ pathFilenameCitationSSOT = pathCitations / filenameCitationDOTcff
336
+ pathFilenameCitationDOTcffRepo = pathRepoRoot / filenameCitationDOTcff
337
+
338
+ nexusCitation = getNexusCitation(pathFilenameCitationSSOT)
339
+
340
+ pypaMetadata: PyPAMetadata = getPypaMetadata(tomlPackageData)
341
+
342
+ nexusCitation = addPypaMetadata(nexusCitation, pypaMetadata)
343
+ nexusCitation = add_pyprojectDOTtoml(nexusCitation, tomlPackageData)
344
+
345
+ nexusCitation = addGitHubRelease(nexusCitation)
346
+ nexusCitation = addPyPIrelease(nexusCitation)
347
+
348
+ filenameGitHubAction = 'updateCitation.yml'
349
+ pathFilenameGitHubAction = pathRepoRoot / '.github' / 'workflows' / filenameGitHubAction
350
+
351
+ writeCitation(nexusCitation, pathFilenameCitationSSOT, pathFilenameCitationDOTcffRepo)
352
+
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
 
@@ -1,8 +1,8 @@
1
1
  README.md
2
2
  pyproject.toml
3
3
  mapFolding/benchmarks/benchmarking.py
4
+ mapFolding/citations/constants.py
4
5
  mapFolding/citations/updateCitation.py
5
- mapFolding/citations/updateCitationgpt.py
6
6
  mapFolding/mapFolding.egg-info/PKG-INFO
7
7
  mapFolding/mapFolding.egg-info/SOURCES.txt
8
8
  mapFolding/mapFolding.egg-info/dependency_links.txt
@@ -19,15 +19,14 @@ mapFolding/reference/lunnanWhile.py
19
19
  mapFolding/reference/rotatedEntryPoint.py
20
20
  mapFolding/reference/total_countPlus1vsPlusN.py
21
21
  mapFolding/someAssemblyRequired/__init__.py
22
- mapFolding/someAssemblyRequired/generalizeSourceCode.py
23
22
  mapFolding/someAssemblyRequired/getLLVMforNoReason.py
24
23
  mapFolding/someAssemblyRequired/makeJob.py
25
- mapFolding/someAssemblyRequired/synthesizeModuleJob.py
26
- mapFolding/someAssemblyRequired/synthesizeModules.py
27
- mapFolding/syntheticModules/Initialize.py
28
- mapFolding/syntheticModules/Parallel.py
29
- mapFolding/syntheticModules/Sequential.py
24
+ mapFolding/someAssemblyRequired/synthesizeModuleJobNumba.py
25
+ mapFolding/someAssemblyRequired/synthesizeModulesNumba.py
30
26
  mapFolding/syntheticModules/__init__.py
27
+ mapFolding/syntheticModules/numbaInitialize.py
28
+ mapFolding/syntheticModules/numbaParallel.py
29
+ mapFolding/syntheticModules/numbaSequential.py
31
30
  tests/test_oeis.py
32
31
  tests/test_other.py
33
32
  tests/test_tasks.py
@@ -9,11 +9,12 @@ pandas
9
9
  tqdm
10
10
 
11
11
  [testing]
12
+ attrs
12
13
  cffconvert
13
14
  more_itertools
14
- pytest
15
15
  pytest-cov
16
16
  pytest-env
17
17
  pytest-xdist
18
+ pytest
18
19
  python_minifier
19
20
  tomli
@@ -0,0 +1,62 @@
1
+ import importlib.util
2
+ from mapFolding import getPathFilenameFoldsTotal, computationState, outfitCountFolds, getAlgorithmSource
3
+ from typing import Any, Literal, Optional, Sequence, Type, overload
4
+ import pathlib
5
+ import pickle
6
+
7
+ @overload
8
+ def makeStateJob(listDimensions: Sequence[int], writeJob: Literal[True] = True
9
+ , **keywordArguments: Optional[str]) -> pathlib.Path:
10
+ ...
11
+
12
+ @overload
13
+ def makeStateJob(listDimensions: Sequence[int], writeJob: Literal[False] = False
14
+ , **keywordArguments: Optional[str]) -> computationState:
15
+ ...
16
+
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
+ """
45
+
46
+ stateUniversal: computationState = outfitCountFolds(listDimensions, computationDivisions=None, CPUlimit=None, **keywordArguments)
47
+
48
+
49
+ moduleSource = getAlgorithmSource()
50
+ moduleSource.countInitialize(stateUniversal['connectionGraph'], stateUniversal['gapsWhere'], stateUniversal['my'], stateUniversal['track'])
51
+
52
+ if not writeJob:
53
+ return stateUniversal
54
+
55
+ pathFilenameChopChop = getPathFilenameFoldsTotal(stateUniversal['mapShape'])
56
+ suffix = pathFilenameChopChop.suffix
57
+ pathJob = pathlib.Path(str(pathFilenameChopChop)[0:-len(suffix)])
58
+ pathJob.mkdir(parents=True, exist_ok=True)
59
+ pathFilenameJob = pathJob / 'stateJob.pkl'
60
+
61
+ pathFilenameJob.write_bytes(pickle.dumps(stateUniversal))
62
+ return pathFilenameJob