mapFolding 0.12.1__py3-none-any.whl → 0.12.2__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.
Files changed (34) hide show
  1. mapFolding/__init__.py +42 -18
  2. mapFolding/_theSSOT.py +137 -0
  3. mapFolding/basecamp.py +28 -18
  4. mapFolding/beDRY.py +21 -19
  5. mapFolding/dataBaskets.py +170 -18
  6. mapFolding/datatypes.py +109 -1
  7. mapFolding/filesystemToolkit.py +38 -33
  8. mapFolding/oeis.py +209 -93
  9. mapFolding/someAssemblyRequired/RecipeJob.py +120 -9
  10. mapFolding/someAssemblyRequired/__init__.py +35 -38
  11. mapFolding/someAssemblyRequired/_toolIfThis.py +78 -16
  12. mapFolding/someAssemblyRequired/_toolkitContainers.py +121 -43
  13. mapFolding/someAssemblyRequired/infoBooth.py +37 -2
  14. mapFolding/someAssemblyRequired/makeAllModules.py +712 -0
  15. mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +102 -39
  16. mapFolding/someAssemblyRequired/toolkitNumba.py +171 -19
  17. mapFolding/someAssemblyRequired/transformationTools.py +84 -40
  18. mapfolding-0.12.2.dist-info/METADATA +167 -0
  19. mapfolding-0.12.2.dist-info/RECORD +53 -0
  20. {mapfolding-0.12.1.dist-info → mapfolding-0.12.2.dist-info}/WHEEL +1 -1
  21. tests/__init__.py +28 -44
  22. tests/conftest.py +66 -61
  23. tests/test_computations.py +39 -82
  24. tests/test_filesystem.py +25 -1
  25. tests/test_oeis.py +30 -1
  26. tests/test_other.py +27 -0
  27. tests/test_tasks.py +31 -1
  28. mapFolding/someAssemblyRequired/Z0Z_makeAllModules.py +0 -433
  29. mapFolding/theSSOT.py +0 -34
  30. mapfolding-0.12.1.dist-info/METADATA +0 -184
  31. mapfolding-0.12.1.dist-info/RECORD +0 -53
  32. {mapfolding-0.12.1.dist-info → mapfolding-0.12.2.dist-info}/entry_points.txt +0 -0
  33. {mapfolding-0.12.1.dist-info → mapfolding-0.12.2.dist-info}/licenses/LICENSE +0 -0
  34. {mapfolding-0.12.1.dist-info → mapfolding-0.12.2.dist-info}/top_level.txt +0 -0
mapFolding/oeis.py CHANGED
@@ -1,28 +1,33 @@
1
1
  """
2
- Interface to The Online Encyclopedia of Integer Sequences (OEIS) for map folding sequences.
3
-
4
- This module provides a comprehensive interface for accessing and utilizing integer sequences from the OEIS that relate
5
- to map folding problems. It serves as the bridge between mathematical sequence definitions and the computational
6
- algorithm, implementing:
7
-
8
- 1. Retrieval of sequence data from OEIS with local caching for performance optimization.
9
- 2. Mapping of sequence indices to corresponding map shapes based on sequence definitions.
10
- 3. Command-line and programmatic interfaces for sequence lookups and validation.
11
- 4. Computation of sequence terms not available in the OEIS database.
12
-
13
- The module maintains a registry of implemented OEIS sequences (A001415-A001418, A195646) with their metadata, known
14
- values, and conversion functions between sequence indices and map dimensions. This allows the package to validate
15
- results against established mathematical literature while also extending sequences beyond their currently known terms.
16
-
17
- Each sequence is carefully mapped to its corresponding map folding problem, enabling seamless integration between the
18
- mathematical definition in OEIS and the computational implementation in the package.
2
+ Mathematical validation and discovery through OEIS integration.
3
+
4
+ Complementing the unified computational interface, this module extends the map
5
+ folding ecosystem into the broader mathematical community through comprehensive
6
+ integration with the Online Encyclopedia of Integer Sequences (OEIS). This bridge
7
+ enables validation of computational results against established mathematical
8
+ knowledge while supporting the discovery of new sequence values through the
9
+ sophisticated computational pipeline.
10
+
11
+ The integration provides multiple pathways for mathematical verification: direct
12
+ computation of OEIS sequences using the complete algorithmic implementation,
13
+ cached access to published sequence data for rapid validation, and research
14
+ support for extending known sequences through new computational discoveries.
15
+ The module handles sequence families ranging from simple strip folding to
16
+ complex multi-dimensional hypercube problems.
17
+
18
+ Through intelligent caching and optimized lookup mechanisms, this module ensures
19
+ that the computational power developed through the foundational layers can contribute
20
+ meaningfully to mathematical research. Whether validating results, avoiding
21
+ redundant computation, or extending mathematical knowledge, this integration
22
+ completes the journey from configuration foundation to mathematical discovery.
19
23
  """
24
+
20
25
  from collections.abc import Callable
21
26
  from datetime import datetime, timedelta
22
27
  from functools import cache
23
- from mapFolding import countFolds, packageSettings, TypedDict
28
+ from mapFolding import countFolds, packageSettings
24
29
  from pathlib import Path
25
- from typing import Any, Final
30
+ from typing import Any, Final, TypedDict
26
31
  from urllib.parse import urlparse
27
32
  from Z0Z_tools import writeStringToHere
28
33
  import argparse
@@ -33,10 +38,18 @@ import urllib.request
33
38
  import warnings
34
39
 
35
40
  cacheDays = 30
41
+ """Number of days to retain cached OEIS data before refreshing from the online source."""
36
42
 
37
43
  pathCache: Path = packageSettings.pathPackage / ".cache"
44
+ """Local directory path for storing cached OEIS sequence data and metadata."""
38
45
 
39
46
  class SettingsOEIS(TypedDict):
47
+ """
48
+ Complete configuration settings for a single OEIS sequence implementation.
49
+
50
+ This TypedDict defines the structure for storing all metadata, known values, and operational parameters
51
+ needed to work with an OEIS sequence within the map folding context.
52
+ """
40
53
  description: str
41
54
  getMapShape: Callable[[int], tuple[int, ...]]
42
55
  offset: int
@@ -47,6 +60,12 @@ class SettingsOEIS(TypedDict):
47
60
  valueUnknown: int
48
61
 
49
62
  class SettingsOEIShardcodedValues(TypedDict):
63
+ """
64
+ Hardcoded configuration values for OEIS sequences defined within the module.
65
+
66
+ This TypedDict contains the static configuration data that is embedded in the source code
67
+ rather than retrieved from external sources.
68
+ """
50
69
  getMapShape: Callable[[int], tuple[int, ...]]
51
70
  valuesBenchmark: list[int]
52
71
  valuesTestParallelization: list[int]
@@ -90,6 +109,13 @@ settingsOEIShardcodedValues: dict[str, SettingsOEIShardcodedValues] = {
90
109
  'valuesTestValidation': [random.randint(2, 4)],
91
110
  },
92
111
  }
112
+ """
113
+ Registry of hardcoded OEIS sequence configurations implemented in this module.
114
+
115
+ Each key is a standardized OEIS sequence identifier (e.g., 'A001415'), and each value contains
116
+ the static configuration needed to work with that sequence, including the mapping function from
117
+ sequence index to map shape and various test parameter sets.
118
+ """
93
119
 
94
120
  oeisIDsImplemented: Final[list[str]] = sorted([oeisID.upper().strip() for oeisID in settingsOEIShardcodedValues.keys()])
95
121
  """Directly implemented OEIS IDs; standardized, e.g., 'A001415'."""
@@ -123,25 +149,37 @@ def validateOEISid(oeisIDcandidate: str) -> str:
123
149
  )
124
150
 
125
151
  def getFilenameOEISbFile(oeisID: str) -> str:
152
+ """
153
+ Generate the filename for an OEIS b-file given a sequence ID.
154
+
155
+ OEIS b-files contain sequence values in a standardized format and follow the naming convention
156
+ 'b{sequence_number}.txt', where the sequence number excludes the 'A' prefix.
157
+
158
+ Parameters:
159
+ oeisID: The OEIS sequence identifier to convert to a b-file filename.
160
+
161
+ Returns:
162
+ filename: The corresponding b-file filename for the given sequence ID.
163
+ """
126
164
  oeisID = validateOEISid(oeisID)
127
165
  return f"b{oeisID[1:]}.txt"
128
166
 
129
167
  def _parseBFileOEIS(OEISbFile: str, oeisID: str) -> dict[int, int]:
130
168
  """
131
- Parses the content of an OEIS b-file for a given sequence ID.
169
+ Parse the content of an OEIS b-file into a sequence dictionary.
132
170
 
133
- This function processes a multiline string representing an OEIS b-file and creates a dictionary mapping integer
134
- indices to their corresponding sequence values. The first line of the b-file is expected to contain a comment that
135
- matches the given sequence ID. If it does not match, a ValueError is raised.
171
+ OEIS b-files contain sequence data in a standardized two-column format where each line represents
172
+ an index-value pair. Comment lines beginning with '#' are ignored during parsing.
136
173
 
137
174
  Parameters:
138
- OEISbFile: A multiline string representing an OEIS b-file. oeisID: The expected OEIS sequence identifier.
175
+ OEISbFile: A multiline string representing the content of an OEIS b-file.
176
+ oeisID: The expected OEIS sequence identifier for validation purposes.
177
+
139
178
  Returns:
140
- OEISsequence: A dictionary where each key is an integer index `n` and each value is the sequence value `a(n)`
141
- corresponding to that index.
179
+ OEISsequence: A dictionary mapping sequence indices to their corresponding values.
180
+
142
181
  Raises:
143
- ValueError: If the first line of the file does not indicate the expected sequence ID or if the content format is
144
- invalid.
182
+ ValueError: If the file content format is invalid or cannot be parsed.
145
183
  """
146
184
  bFileLines: list[str] = OEISbFile.strip().splitlines()
147
185
 
@@ -155,23 +193,22 @@ def _parseBFileOEIS(OEISbFile: str, oeisID: str) -> dict[int, int]:
155
193
 
156
194
  def getOEISofficial(pathFilenameCache: Path, url: str) -> None | str:
157
195
  """
158
- Retrieve OEIS sequence data from cache or online source.
196
+ Retrieve OEIS sequence data from cache or online source with intelligent caching.
159
197
 
160
- This function implements a caching strategy for OEIS sequence data, first checking if a local cached copy exists and
161
- is not expired. If a valid cache exists, it returns the cached content; otherwise, it fetches the data from the OEIS
162
- website and writes it to the cache for future use.
198
+ This function implements a caching strategy that prioritizes local cached data when it exists and
199
+ has not expired. Fresh data is retrieved from the OEIS website when the cache is stale or missing,
200
+ and the cache is updated for future use.
163
201
 
164
202
  Parameters:
165
- pathFilenameCache: Path to the local cache file. url: URL to retrieve the OEIS sequence data from if cache is
166
- invalid or missing.
203
+ pathFilenameCache: Path to the local cache file for storing retrieved data.
204
+ url: URL to retrieve the OEIS sequence data from if cache is invalid or missing.
167
205
 
168
206
  Returns:
169
- oeisInformation: The retrieved OEIS sequence information as a string, or None if the information could not be
170
- retrieved.
207
+ oeisInformation: The retrieved OEIS sequence information as a string, or None if retrieval failed.
171
208
 
172
209
  Notes:
173
- The cache expiration period is controlled by the global `cacheDays` variable. If the function fails to retrieve
174
- data from both cache and online source, it will return None and issue a warning.
210
+ Cache expiration is controlled by the module-level `cacheDays` variable. The function validates
211
+ URL schemes and issues warnings for failed retrievals.
175
212
  """
176
213
  tryCache: bool = False
177
214
  if pathFilenameCache.exists():
@@ -202,20 +239,22 @@ def getOEISofficial(pathFilenameCache: Path, url: str) -> None | str:
202
239
 
203
240
  def getOEISidValues(oeisID: str) -> dict[int, int]:
204
241
  """
205
- Retrieves the specified OEIS sequence as a dictionary mapping integer indices to their corresponding values.
242
+ Retrieve known sequence values for a specified OEIS sequence.
206
243
 
207
- This function checks for a cached local copy of the sequence data, using it if it has not expired. Otherwise, it
208
- fetches the sequence data from the OEIS website and writes it to the cache. The parsed data is returned as a
209
- dictionary mapping each index to its sequence value.
244
+ This function fetches the complete set of known values for an OEIS sequence by accessing cached
245
+ data when available or retrieving fresh data from the OEIS website. The data is parsed from the
246
+ standard OEIS b-file format.
210
247
 
211
248
  Parameters:
212
249
  oeisID: The identifier of the OEIS sequence to retrieve.
250
+
213
251
  Returns:
214
- OEISsequence: A dictionary where each key is an integer index, `n`, and each value is the corresponding `a(n)`
215
- from the OEIS entry.
252
+ OEISsequence: A dictionary mapping sequence indices to their corresponding values, or a fallback
253
+ dictionary containing {-1: -1} if retrieval fails.
254
+
216
255
  Raises:
217
- ValueError: If the cached or downloaded file format is invalid. IOError: If there is an error reading from or
218
- writing to the local cache.
256
+ ValueError: If the cached or downloaded file format is invalid.
257
+ IOError: If there is an error reading from or writing to the local cache.
219
258
  """
220
259
 
221
260
  pathFilenameCache: Path = pathCache / getFilenameOEISbFile(oeisID)
@@ -229,21 +268,22 @@ def getOEISidValues(oeisID: str) -> dict[int, int]:
229
268
 
230
269
  def getOEISidInformation(oeisID: str) -> tuple[str, int]:
231
270
  """
232
- Retrieve the description and offset for an OEIS sequence.
271
+ Retrieve the description and offset metadata for an OEIS sequence.
233
272
 
234
- This function fetches the metadata for a given OEIS sequence ID, including its textual description and index offset
235
- value. It uses a caching mechanism to avoid redundant network requests while ensuring data freshness.
273
+ This function extracts the mathematical description and starting index offset from OEIS sequence
274
+ metadata using the machine-readable text format. It employs the same caching mechanism as other
275
+ retrieval functions to minimize network requests.
236
276
 
237
277
  Parameters:
238
- oeisID: The OEIS sequence identifier to retrieve information for.
278
+ oeisID: The OEIS sequence identifier to retrieve metadata for.
239
279
 
240
280
  Returns:
241
- A tuple containing: - description: A string describing the sequence's mathematical meaning. - offset: An integer
242
- representing the starting index of the sequence. Usually 0 or 1, depending on the mathematical context.
281
+ description: A human-readable string describing the sequence's mathematical meaning.
282
+ offset: The starting index of the sequence, typically 0 or 1 depending on mathematical context.
243
283
 
244
284
  Notes:
245
- Sequence descriptions are parsed from the machine-readable format of OEIS. If information cannot be retrieved,
246
- warning messages are issued and fallback values are returned.
285
+ Descriptions are parsed from OEIS %N entries and offsets from %O entries. If metadata cannot
286
+ be retrieved, warning messages are issued and fallback values are returned.
247
287
  """
248
288
  oeisID = validateOEISid(oeisID)
249
289
  pathFilenameCache: Path = pathCache / f"{oeisID}.txt"
@@ -253,16 +293,17 @@ def getOEISidInformation(oeisID: str) -> tuple[str, int]:
253
293
 
254
294
  if not oeisInformation:
255
295
  return "Not found", -1
256
-
257
296
  listDescriptionDeconstructed: list[str] = []
258
297
  offset = None
259
- for ImaStr in oeisInformation.splitlines():
260
- ImaStr = ImaStr.strip() + "I am writing code to string parse machine readable data because in 2025, people can't even spell enteroperableity."
261
- secretCode, title, secretData =ImaStr.split(maxsplit=2)
262
- if secretCode == '%N' and title == oeisID:
263
- listDescriptionDeconstructed.append(secretData)
264
- if secretCode == '%O' and title == oeisID:
265
- offsetAsStr: str = secretData.split(',')[0]
298
+ for lineOEIS in oeisInformation.splitlines():
299
+ lineOEIS = lineOEIS.strip()
300
+ if not lineOEIS or len(lineOEIS.split()) < 3:
301
+ continue
302
+ fieldCode, sequenceID, fieldData = lineOEIS.split(maxsplit=2)
303
+ if fieldCode == '%N' and sequenceID == oeisID:
304
+ listDescriptionDeconstructed.append(fieldData)
305
+ if fieldCode == '%O' and sequenceID == oeisID:
306
+ offsetAsStr: str = fieldData.split(',')[0]
266
307
  offset = int(offsetAsStr)
267
308
  if not listDescriptionDeconstructed:
268
309
  warnings.warn(f"No description found for {oeisID}")
@@ -277,22 +318,20 @@ def makeSettingsOEIS() -> dict[str, SettingsOEIS]:
277
318
  """
278
319
  Construct the comprehensive settings dictionary for all implemented OEIS sequences.
279
320
 
280
- This function builds a complete configuration dictionary for all supported OEIS sequences by retrieving and
281
- combining:
321
+ This function builds the complete configuration dictionary by merging hardcoded settings with
322
+ dynamically retrieved data from OEIS. For each implemented sequence, it combines:
323
+
282
324
  1. Sequence values from OEIS b-files
283
- 2. Sequence metadata (descriptions and offsets)
284
- 3. Hardcoded mapping functions and test values
325
+ 2. Sequence metadata including descriptions and offsets
326
+ 3. Hardcoded mapping functions and test parameter sets
285
327
 
286
- The resulting dictionary provides a single authoritative source for all OEIS-related configurations used throughout
287
- the package, including:
288
- - Mathematical descriptions of each sequence
289
- - Functions to convert between sequence indices and map dimensions
290
- - Known sequence values retrieved from OEIS
291
- - Testing and benchmarking reference values
328
+ The resulting dictionary serves as the authoritative configuration source for all OEIS-related
329
+ operations throughout the package, enabling consistent access to sequence definitions, known values,
330
+ and operational parameters.
292
331
 
293
332
  Returns:
294
- A dictionary mapping OEIS sequence IDs to their complete settings objects, containing all metadata and known
295
- values needed for computation and validation.
333
+ settingsTarget: A comprehensive dictionary mapping OEIS sequence IDs to their complete settings
334
+ objects, containing all metadata and known values needed for computation and validation.
296
335
  """
297
336
  settingsTarget: dict[str, SettingsOEIS] = {}
298
337
  for oeisID in oeisIDsImplemented:
@@ -311,11 +350,29 @@ def makeSettingsOEIS() -> dict[str, SettingsOEIS]:
311
350
  return settingsTarget
312
351
 
313
352
  settingsOEIS: dict[str, SettingsOEIS] = makeSettingsOEIS()
314
- """All values and settings for `oeisIDsImplemented`."""
353
+ """
354
+ Complete settings and metadata for all implemented OEIS sequences.
355
+
356
+ This dictionary contains the comprehensive configuration for each OEIS sequence supported by the module,
357
+ including known values retrieved from OEIS, mathematical descriptions, offset information, and all
358
+ operational parameters needed for computation and testing. The dictionary is populated by combining
359
+ hardcoded configurations with dynamically retrieved OEIS data during module initialization.
360
+ """
315
361
 
316
362
  @cache
317
363
  def makeDictionaryFoldsTotalKnown() -> dict[tuple[int, ...], int]:
318
- """Returns a dictionary mapping dimension tuples to their known folding totals."""
364
+ """
365
+ Create a cached lookup dictionary mapping map shapes to their known folding totals.
366
+
367
+ This function processes all known sequence values from implemented OEIS sequences and creates
368
+ a unified dictionary that maps map dimension tuples to their corresponding folding totals. The
369
+ resulting dictionary enables rapid lookup of known values without requiring knowledge of which
370
+ specific OEIS sequence contains the data.
371
+
372
+ Returns:
373
+ dictionaryMapDimensionsToFoldsTotalKnown: A dictionary where keys are tuples representing
374
+ map shapes and values are the total number of distinct folding patterns for those shapes.
375
+ """
319
376
  dictionaryMapDimensionsToFoldsTotalKnown: dict[tuple[int, ...], int] = {}
320
377
 
321
378
  for settings in settingsOEIS.values():
@@ -329,28 +386,36 @@ def makeDictionaryFoldsTotalKnown() -> dict[tuple[int, ...], int]:
329
386
 
330
387
  def getFoldsTotalKnown(mapShape: tuple[int, ...]) -> int:
331
388
  """
332
- Retrieve the known total number of foldings for a given map shape.
389
+ Retrieve the known total number of distinct folding patterns for a given map shape.
333
390
 
334
- This function looks up precalculated folding totals for specific map dimensions from OEIS sequences. It serves as a
335
- rapid reference for known values without requiring computation, and can be used to validate algorithm results.
391
+ This function provides rapid access to precalculated folding totals from OEIS sequences without
392
+ requiring computation. It serves as a validation reference for algorithm results and enables
393
+ quick lookup of known values across all implemented sequences.
336
394
 
337
395
  Parameters:
338
396
  mapShape: A tuple of integers representing the dimensions of the map.
339
397
 
340
398
  Returns:
341
- foldingsTotal: The known total number of foldings for the given map shape, or -1 if the map shape doesn't match
342
- any known values in the OEIS sequences.
399
+ foldingsTotal: The known total number of distinct folding patterns for the given map shape,
400
+ or -1 if the map shape does not match any known values in the OEIS sequences.
343
401
 
344
402
  Notes:
345
- The function uses a cached dictionary (via makeDictionaryFoldsTotalKnown) to efficiently retrieve values without
346
- repeatedly parsing OEIS data. Map shape tuples are sorted internally to ensure consistent lookup regardless of
347
- dimension order.
403
+ The function uses a cached dictionary for efficient retrieval without repeatedly processing
404
+ OEIS data. Map shapes are matched exactly as provided without internal sorting or normalization.
348
405
  """
349
406
  lookupFoldsTotal = makeDictionaryFoldsTotalKnown()
350
407
  return lookupFoldsTotal.get(tuple(mapShape), -1)
351
408
 
352
409
  def _formatHelpText() -> str:
353
- """Format standardized help text for both CLI and interactive use."""
410
+ """
411
+ Format comprehensive help text for both command-line and interactive use.
412
+
413
+ This function generates standardized help documentation that includes all available OEIS sequences
414
+ with their descriptions and provides usage examples for both command-line and programmatic interfaces.
415
+
416
+ Returns:
417
+ helpText: A formatted string containing complete usage information and examples.
418
+ """
354
419
  exampleOEISid: str = oeisIDsImplemented[0]
355
420
  exampleN: int = settingsOEIS[exampleOEISid]['valuesTestValidation'][-1]
356
421
 
@@ -366,7 +431,15 @@ def _formatHelpText() -> str:
366
431
  )
367
432
 
368
433
  def _formatOEISsequenceInfo() -> str:
369
- """Format information about available OEIS sequences for display or error messages."""
434
+ """
435
+ Format information about available OEIS sequences for display in help messages and error output.
436
+
437
+ This function creates a standardized listing of all implemented OEIS sequences with their mathematical
438
+ descriptions, suitable for inclusion in help text and error messages.
439
+
440
+ Returns:
441
+ sequenceInfo: A formatted string listing each OEIS sequence ID with its description.
442
+ """
370
443
  return "\n".join(
371
444
  f" {oeisID}: {settingsOEIS[oeisID]['description']}"
372
445
  for oeisID in oeisIDsImplemented
@@ -374,16 +447,24 @@ def _formatOEISsequenceInfo() -> str:
374
447
 
375
448
  def oeisIDfor_n(oeisID: str, n: int | Any) -> int:
376
449
  """
377
- Calculate `a(n)` of a sequence from "The On-Line Encyclopedia of Integer Sequences" (OEIS).
450
+ Calculate the value a(n) for a specified OEIS sequence and index.
451
+
452
+ This function serves as the primary interface for computing OEIS sequence values within the map folding
453
+ context. For small values or values within the known range, it returns cached OEIS data. For larger
454
+ values, it computes the result using the map folding algorithm with the appropriate map shape derived
455
+ from the sequence definition.
378
456
 
379
457
  Parameters:
380
- oeisID: The ID of the OEIS sequence. n: A non-negative integer for which to calculate the sequence value.
458
+ oeisID: The identifier of the OEIS sequence to evaluate.
459
+ n: A non-negative integer index for which to calculate the sequence value.
381
460
 
382
461
  Returns:
383
- sequenceValue: `a(n)` of the OEIS sequence.
462
+ sequenceValue: The value a(n) of the specified OEIS sequence.
384
463
 
385
464
  Raises:
386
- ValueError: If `n` is negative. KeyError: If the OEIS sequence ID is not directly implemented.
465
+ ValueError: If n is not a non-negative integer.
466
+ KeyError: If the OEIS sequence ID is not directly implemented.
467
+ ArithmeticError: If n is below the sequence's defined offset.
387
468
  """
388
469
  oeisID = validateOEISid(oeisID)
389
470
 
@@ -401,7 +482,23 @@ def oeisIDfor_n(oeisID: str, n: int | Any) -> int:
401
482
  return countFolds(mapShape)
402
483
 
403
484
  def OEIS_for_n() -> None:
404
- """Command-line interface for oeisIDfor_n."""
485
+ """
486
+ Command-line interface for calculating OEIS sequence values.
487
+
488
+ This function provides a command-line interface to the oeisIDfor_n function, enabling users to
489
+ calculate specific values of implemented OEIS sequences from the terminal. It includes argument
490
+ parsing, error handling, and performance timing to provide a complete user experience.
491
+
492
+ The function accepts two command-line arguments: an OEIS sequence identifier and an integer index,
493
+ then outputs the calculated sequence value along with execution time. Error messages are directed
494
+ to stderr with appropriate exit codes for shell scripting integration.
495
+
496
+ Usage:
497
+ python -m mapFolding.oeis OEIS_for_n A001415 10
498
+
499
+ Raises:
500
+ SystemExit: With code 1 if invalid arguments are provided or computation fails.
501
+ """
405
502
  parserCLI = argparse.ArgumentParser(
406
503
  description="Calculate a(n) for an OEIS sequence.",
407
504
  epilog=_formatHelpText(),
@@ -424,7 +521,16 @@ def OEIS_for_n() -> None:
424
521
  print(f"Time elapsed: {timeElapsed:.3f} seconds")
425
522
 
426
523
  def clearOEIScache() -> None:
427
- """Delete all cached OEIS sequence files."""
524
+ """
525
+ Delete all cached OEIS sequence files from the local cache directory.
526
+
527
+ This function removes all cached OEIS data files, including both sequence value files (b-files)
528
+ and metadata files, forcing fresh retrieval from the OEIS website on the next access. This is
529
+ useful for clearing stale cache data or troubleshooting network-related issues.
530
+
531
+ The function safely handles missing files and provides user feedback about the cache clearing
532
+ operation. If the cache directory does not exist, an informative message is displayed.
533
+ """
428
534
  if not pathCache.exists():
429
535
  print(f"Cache directory, {pathCache}, not found - nothing to clear.")
430
536
  return
@@ -434,7 +540,17 @@ def clearOEIScache() -> None:
434
540
  print(f"Cache cleared from {pathCache}")
435
541
 
436
542
  def getOEISids() -> None:
437
- """Print all available OEIS sequence IDs that are directly implemented."""
543
+ """
544
+ Display comprehensive information about all implemented OEIS sequences.
545
+
546
+ This function serves as the primary help interface for the module, displaying detailed information
547
+ about all directly implemented OEIS sequences along with usage examples for both command-line and
548
+ programmatic interfaces. It provides users with a complete overview of available sequences and
549
+ their mathematical meanings.
550
+
551
+ The output includes sequence identifiers, mathematical descriptions, and practical usage examples
552
+ to help users understand how to access and utilize the OEIS interface functionality.
553
+ """
438
554
  print(_formatHelpText())
439
555
 
440
556
  if __name__ == "__main__":