hunterMakesPy 0.8.1__tar.gz → 0.10.0__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 (38) hide show
  1. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/PKG-INFO +22 -18
  2. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/README.md +13 -9
  3. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/hunterMakesPy/__init__.py +22 -7
  4. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/hunterMakesPy/coping.py +22 -26
  5. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/hunterMakesPy/dataStructures.py +98 -50
  6. huntermakespy-0.8.1/hunterMakesPy/filesystemToolkit.py → huntermakespy-0.10.0/hunterMakesPy/kitFilesystem.py +150 -87
  7. huntermakespy-0.10.0/hunterMakesPy/parseParameters.py +276 -0
  8. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/hunterMakesPy/semiotics.py +2 -4
  9. huntermakespy-0.10.0/hunterMakesPy/tests/__init__.py +31 -0
  10. huntermakespy-0.10.0/hunterMakesPy/tests/conftest.py +24 -0
  11. huntermakespy-0.10.0/hunterMakesPy/tests/conftestAnnex.py +45 -0
  12. huntermakespy-0.10.0/hunterMakesPy/tests/test_coping.py +52 -0
  13. huntermakespy-0.10.0/hunterMakesPy/tests/test_dataStructures.py +79 -0
  14. huntermakespy-0.10.0/hunterMakesPy/tests/test_kitFilesystem.py +83 -0
  15. huntermakespy-0.10.0/hunterMakesPy/tests/test_parseParameters.py +53 -0
  16. huntermakespy-0.10.0/hunterMakesPy/tests/test_theTypes.py +15 -0
  17. huntermakespy-0.10.0/hunterMakesPy/theTypes.py +180 -0
  18. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/hunterMakesPy.egg-info/PKG-INFO +22 -18
  19. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/hunterMakesPy.egg-info/SOURCES.txt +2 -3
  20. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/hunterMakesPy.egg-info/requires.txt +5 -5
  21. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/pyproject.toml +12 -9
  22. huntermakespy-0.8.1/hunterMakesPy/parseParameters.py +0 -371
  23. huntermakespy-0.8.1/hunterMakesPy/tests/__init__.py +0 -33
  24. huntermakespy-0.8.1/hunterMakesPy/tests/conftest.py +0 -145
  25. huntermakespy-0.8.1/hunterMakesPy/tests/conftestAnnex.py +0 -22
  26. huntermakespy-0.8.1/hunterMakesPy/tests/test_coping.py +0 -322
  27. huntermakespy-0.8.1/hunterMakesPy/tests/test_dataStructures.py +0 -190
  28. huntermakespy-0.8.1/hunterMakesPy/tests/test_filesystemToolkit.py +0 -564
  29. huntermakespy-0.8.1/hunterMakesPy/tests/test_parseParameters.py +0 -402
  30. huntermakespy-0.8.1/hunterMakesPy/tests/test_theTypes.py +0 -246
  31. huntermakespy-0.8.1/hunterMakesPy/theTypes.py +0 -29
  32. huntermakespy-0.8.1/hunterMakesPy/theTypesCallableFunction.py +0 -63
  33. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/LICENSE +0 -0
  34. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/hunterMakesPy/_theSSOT.py +0 -0
  35. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/hunterMakesPy/py.typed +0 -0
  36. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/hunterMakesPy.egg-info/dependency_links.txt +0 -0
  37. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/hunterMakesPy.egg-info/top_level.txt +0 -0
  38. {huntermakespy-0.8.1 → huntermakespy-0.10.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hunterMakesPy
3
- Version: 0.8.1
3
+ Version: 0.10.0
4
4
  Summary: Easy Python functions making making functional Python functions easier.
5
5
  Author-email: Hunter Hogan <HunterHogan@pm.me>
6
6
  License-Expression: CC-BY-NC-4.0
@@ -17,27 +17,27 @@ Classifier: Intended Audience :: Developers
17
17
  Classifier: Natural Language :: English
18
18
  Classifier: Operating System :: OS Independent
19
19
  Classifier: Programming Language :: Python
20
- Classifier: Programming Language :: Python :: 3.11
21
- Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.15
22
22
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
23
  Classifier: Topic :: Utilities
24
24
  Classifier: Typing :: Typed
25
- Requires-Python: >=3.11
25
+ Requires-Python: >=3.12
26
26
  Description-Content-Type: text/markdown
27
27
  License-File: LICENSE
28
- Requires-Dist: Z0Z_tools>=2.2.1
28
+ Requires-Dist: Z0Z_tools>=4.0.0
29
29
  Requires-Dist: autoflake
30
30
  Requires-Dist: charset_normalizer
31
31
  Requires-Dist: isort
32
32
  Requires-Dist: more_itertools
33
- Requires-Dist: numpy
34
- Requires-Dist: tomli
33
+ Requires-Dist: numpy>=2.0
35
34
  Requires-Dist: typing_extensions>=4.10.0
36
35
  Provides-Extra: development
37
36
  Requires-Dist: pytest-cov; extra == "development"
38
37
  Provides-Extra: testing
39
- Requires-Dist: librosa; extra == "testing"
40
- Requires-Dist: pytest; extra == "testing"
38
+ Requires-Dist: hypothesis; extra == "testing"
39
+ Requires-Dist: pytest>=9.0; extra == "testing"
40
+ Requires-Dist: pytest-xdist; extra == "testing"
41
41
  Dynamic: license-file
42
42
 
43
43
  # hunterMakesPy
@@ -108,9 +108,10 @@ step = decreasing
108
108
  Load functions or classes from `"scipy.signal.windows"` or `"path/to/file.py"` without manual module-loading boilerplate.
109
109
 
110
110
  ```python
111
- from hunterMakesPy.filesystemToolkit import importLogicalPath2Identifier
111
+ from hunterMakesPy.kitFilesystem import importLogicalPath2Identifier, importPathFilename2Identifier
112
112
 
113
113
  windowFunction = importLogicalPath2Identifier("scipy.signal.windows", "hann")
114
+ parse = importPathFilename2Identifier("path/to/asdl.py", "parse")
114
115
  ```
115
116
 
116
117
  ## Create Directories Safely and Write Files with Formatting
@@ -118,7 +119,7 @@ windowFunction = importLogicalPath2Identifier("scipy.signal.windows", "hann")
118
119
  Write to `"deep/nested/path/file.txt"` and parent directories are created automatically. `writePython` removes unused imports and sorts import statements before writing.
119
120
 
120
121
  ```python
121
- from hunterMakesPy.filesystemToolkit import writeStringToHere, writePython
122
+ from hunterMakesPy.kitFilesystem import writeStringToHere, writePython
122
123
 
123
124
  writeStringToHere("content", "nested/dirs/file.txt") # Creates dirs
124
125
  writePython(sourceCode, "output/module.py") # Formats, then writes
@@ -170,21 +171,24 @@ from hunterMakesPy import PackageSettings
170
171
  settings = PackageSettings(identifierPackageFALLBACK="myPackage")
171
172
  ```
172
173
 
173
- ## Reuse Test Suites for Custom Implementations
174
+ ## Report the Call That Broke a Test
174
175
 
175
- Import parameterized test generators to validate custom functions that match the expected signatures.
176
+ Import assertion functions that name the function and the arguments in the failure message, so a failing parameterized test shows exactly which call produced the wrong value. `assert_array_equal` and `assert_allclose` do the same for NumPy arrays.
176
177
 
177
178
  ```python
178
- from hunterMakesPy.tests.test_parseParameters import PytestFor_intInnit
179
+ from hunterMakesPy.tests import assertEqualTo
179
180
 
180
- @pytest.mark.parametrize("test_name,test_func", PytestFor_intInnit(myFunction))
181
- def test_my_integer_validator(test_name, test_func):
182
- test_func()
181
+ assertEqualTo(intInnit(["8080", 443]), [8080, 443], intInnit.__name__, ["8080", 443])
183
182
  ```
184
183
 
185
184
  ## My recovery
186
185
 
187
186
  [![Static Badge](https://img.shields.io/badge/2011_August-Homeless_since-blue?style=flat)](https://HunterThinks.com/support)
188
- [![YouTube Channel Subscribers](https://img.shields.io/youtube/channel/subscribers/UC3Gx7kz61009NbhpRtPP7tw)](https://www.youtube.com/@HunterHogan)
189
187
 
190
188
  [![CC-BY-NC-4.0](https://raw.githubusercontent.com/hunterhogan/hunterMakesPy/refs/heads/main/.github/CC-BY-NC-4.0.png)](https://creativecommons.org/licenses/by-nc/4.0/)
189
+
190
+ By law, authors retain their copyrights unless they grant exceptions. The [Attribution-NonCommercial 4.0 International Deed](https://github.com/hunterhogan/hunterMakesPy#License-1-ov-file) outlines how you may use this work.
191
+
192
+ The restriction on commercial use (without a license) limits advantage-taking, unjust enrichment, and exploitation. You would be morally wrong if you were to enrich yourself by using this work while I am denied healthcare, housing, security of property, and the safety of my person.
193
+
194
+ To obtain and retain the right to use this work, you incur the cost of attributing the work to me. Your nominal cost might accrue as a benefit that mitigates my suffering or saves my life.
@@ -66,9 +66,10 @@ step = decreasing
66
66
  Load functions or classes from `"scipy.signal.windows"` or `"path/to/file.py"` without manual module-loading boilerplate.
67
67
 
68
68
  ```python
69
- from hunterMakesPy.filesystemToolkit import importLogicalPath2Identifier
69
+ from hunterMakesPy.kitFilesystem import importLogicalPath2Identifier, importPathFilename2Identifier
70
70
 
71
71
  windowFunction = importLogicalPath2Identifier("scipy.signal.windows", "hann")
72
+ parse = importPathFilename2Identifier("path/to/asdl.py", "parse")
72
73
  ```
73
74
 
74
75
  ## Create Directories Safely and Write Files with Formatting
@@ -76,7 +77,7 @@ windowFunction = importLogicalPath2Identifier("scipy.signal.windows", "hann")
76
77
  Write to `"deep/nested/path/file.txt"` and parent directories are created automatically. `writePython` removes unused imports and sorts import statements before writing.
77
78
 
78
79
  ```python
79
- from hunterMakesPy.filesystemToolkit import writeStringToHere, writePython
80
+ from hunterMakesPy.kitFilesystem import writeStringToHere, writePython
80
81
 
81
82
  writeStringToHere("content", "nested/dirs/file.txt") # Creates dirs
82
83
  writePython(sourceCode, "output/module.py") # Formats, then writes
@@ -128,21 +129,24 @@ from hunterMakesPy import PackageSettings
128
129
  settings = PackageSettings(identifierPackageFALLBACK="myPackage")
129
130
  ```
130
131
 
131
- ## Reuse Test Suites for Custom Implementations
132
+ ## Report the Call That Broke a Test
132
133
 
133
- Import parameterized test generators to validate custom functions that match the expected signatures.
134
+ Import assertion functions that name the function and the arguments in the failure message, so a failing parameterized test shows exactly which call produced the wrong value. `assert_array_equal` and `assert_allclose` do the same for NumPy arrays.
134
135
 
135
136
  ```python
136
- from hunterMakesPy.tests.test_parseParameters import PytestFor_intInnit
137
+ from hunterMakesPy.tests import assertEqualTo
137
138
 
138
- @pytest.mark.parametrize("test_name,test_func", PytestFor_intInnit(myFunction))
139
- def test_my_integer_validator(test_name, test_func):
140
- test_func()
139
+ assertEqualTo(intInnit(["8080", 443]), [8080, 443], intInnit.__name__, ["8080", 443])
141
140
  ```
142
141
 
143
142
  ## My recovery
144
143
 
145
144
  [![Static Badge](https://img.shields.io/badge/2011_August-Homeless_since-blue?style=flat)](https://HunterThinks.com/support)
146
- [![YouTube Channel Subscribers](https://img.shields.io/youtube/channel/subscribers/UC3Gx7kz61009NbhpRtPP7tw)](https://www.youtube.com/@HunterHogan)
147
145
 
148
146
  [![CC-BY-NC-4.0](https://raw.githubusercontent.com/hunterhogan/hunterMakesPy/refs/heads/main/.github/CC-BY-NC-4.0.png)](https://creativecommons.org/licenses/by-nc/4.0/)
147
+
148
+ By law, authors retain their copyrights unless they grant exceptions. The [Attribution-NonCommercial 4.0 International Deed](https://github.com/hunterhogan/hunterMakesPy#License-1-ov-file) outlines how you may use this work.
149
+
150
+ The restriction on commercial use (without a license) limits advantage-taking, unjust enrichment, and exploitation. You would be morally wrong if you were to enrich yourself by using this work while I am denied healthcare, housing, security of property, and the safety of my person.
151
+
152
+ To obtain and retain the right to use this work, you incur the cost of attributing the work to me. Your nominal cost might accrue as a benefit that mitigates my suffering or saves my life.
@@ -8,8 +8,7 @@ data structures with specialized encoding and merging utilities. The package pro
8
8
  curated collection of functions for common programming tasks with emphasis on fail-early
9
9
  validation and explicit semantic intent.
10
10
 
11
- The package re-exports core semantic constants (`decreasing`, `errorL33T`, `inclusive`,
12
- `zeroIndexed`) and type definitions (`identifierDotAttribute`, `Ordinals`) for direct
11
+ The package re-exports semantic constants, ANSI color codes, and type definitions for direct
13
12
  access. The package exposes configuration utilities (`PackageSettings`) and defensive
14
13
  programming functions (`raiseIfNone`) as primary interfaces. Public modules provide
15
14
  specialized functionality for parameter parsing, file operations, and data structure
@@ -24,14 +23,32 @@ Semantic Constants
24
23
  Signal an error state with a visually distinctive numeric value.
25
24
  inclusive
26
25
  Express inclusion or exclusion of a boundary value.
26
+ oneIndexed
27
+ Express that the adjustment to a value is due to one-based indexing.
27
28
  zeroIndexed
28
29
  Express that the adjustment to a value is due to zero-based indexing.
29
30
 
31
+ Terminal Colors
32
+ ansiColor
33
+ Look up ANSI escape codes for terminal text and background colors.
34
+ ansiColorReset
35
+ Reset terminal text color and background to default settings.
36
+
30
37
  Type Definitions
38
+ CallableFunction
39
+ Annotate a function in place of `Callable` so that type checkers accept `__name__`.
40
+ ConcurrencyLimit
41
+ Type alias for the values that specify a number of concurrent workers.
31
42
  identifierDotAttribute
32
43
  String representing a dotted attribute identifier.
33
44
  Ordinals
34
45
  Protocol for types supporting comparison operators.
46
+ 小于
47
+ Type variable bound to `Ordinals`.
48
+ 文义
49
+ Unbounded type variable.
50
+ 文件
51
+ Type variable bound to `Hashable`.
35
52
 
36
53
  Configuration and Defensive Programming
37
54
  PackageSettings
@@ -45,18 +62,16 @@ coping
45
62
  Package configuration and defensive programming utilities.
46
63
  dataStructures
47
64
  Data structure manipulation with encoding, extraction, and merging utilities.
48
- filesystemToolkit
65
+ kitFilesystem
49
66
  File system operations and dynamic module imports.
50
67
  parseParameters
51
68
  Parameter validation, integer parsing, and concurrency limit computation.
52
- pytestForYourUse
53
- Backward compatibility module redirecting to test_parseParameters.
54
69
  semiotics
55
70
  Semantic constants and ANSI color codes for terminal output.
71
+ tests
72
+ Test suites for the package modules, and assertion functions that other packages can import.
56
73
  theTypes
57
74
  Type aliases and protocols for type annotations.
58
- tests
59
- Comprehensive test suites for all package modules.
60
75
 
61
76
  References
62
77
  ----------
@@ -3,51 +3,52 @@ from __future__ import annotations
3
3
 
4
4
  from importlib.util import find_spec
5
5
  from pathlib import Path
6
- from tomli import loads as tomli_loads
7
6
  from typing import TYPE_CHECKING
8
- from typing_extensions import TypeVar
7
+ import contextlib
9
8
  import dataclasses
9
+ import tomllib
10
10
 
11
11
  if TYPE_CHECKING:
12
12
  from importlib.machinery import ModuleSpec
13
13
 
14
14
  def getIdentifierPackagePACKAGING(identifierPackageFALLBACK: str) -> str:
15
- #ruff: ignore[docstring-missing-returns]
16
15
  """Get package name from pyproject.toml or fallback to provided value."""
17
- try:
18
- return tomli_loads(Path('pyproject.toml').read_text(encoding='utf-8'))['project']['name']
19
- #ruff: ignore[blind-except]
20
- except Exception:
21
- return identifierPackageFALLBACK
16
+ identifierPackage: str = identifierPackageFALLBACK
17
+ with contextlib.suppress(OSError, tomllib.TOMLDecodeError, KeyError):
18
+ identifierPackage = tomllib.loads(Path('pyproject.toml').read_text(encoding='utf-8'))['project']['name'] or identifierPackageFALLBACK
19
+ return identifierPackage
22
20
 
23
21
  def getPathPackageINSTALLING(identifierPackage: str) -> Path:
24
- #ruff: ignore[docstring-missing-returns]
25
22
  """Return the root directory of the installed package."""
26
- try:
23
+ pathPackage: Path = Path.cwd()
24
+ with contextlib.suppress(ModuleNotFoundError):
27
25
  moduleSpecification: ModuleSpec | None = find_spec(identifierPackage)
28
26
  if moduleSpecification and moduleSpecification.origin:
29
27
  pathFilename: Path = Path(moduleSpecification.origin)
30
- return pathFilename.parent if pathFilename.is_file() else pathFilename
31
- except ModuleNotFoundError:
32
- pass
33
- return Path.cwd()
28
+ if pathFilename.is_file():
29
+ pathPackage = pathFilename.parent
30
+ else:
31
+ pathPackage = pathFilename
32
+ return pathPackage
34
33
 
35
34
  @dataclasses.dataclass
36
35
  class PackageSettings:
37
36
  """Configuration container for Python package metadata and runtime settings.
38
37
 
39
- This `class` provides a simple way to store and access basic information about a Python package, It will automatically resolve
40
- package identifiers and installation paths if they are not passed to the `class` constructor. Python `dataclasses` are easy to
41
- subtype and extend.
38
+ This `class` provides a simple way to store and access basic information about a Python package,
39
+ It will automatically resolve package identifiers and installation paths if they are not passed to
40
+ the `class` constructor. Python `dataclasses` are easy to subtype and extend.
42
41
 
43
42
  Attributes
44
43
  ----------
45
44
  identifierPackageFALLBACK : str = ''
46
45
  Fallback package identifier used only during initialization when automatic discovery fails.
47
46
  identifierPackage : str = ''
48
- Canonical name of the package. Automatically extracted from "pyproject.toml".
47
+ Canonical name of the package. An explicit value takes precedence over `pyproject.toml`, then
48
+ `identifierPackageFALLBACK`.
49
49
  pathPackage : Path = getPathPackageINSTALLING(identifierPackage)
50
- Absolute path to the installed package directory. Automatically resolved from `identifierPackage` if not provided.
50
+ Absolute path to the installed package directory. Automatically resolved from
51
+ `identifierPackage` if not provided.
51
52
  fileExtension : str = '.py'
52
53
  Default file extension.
53
54
 
@@ -68,7 +69,6 @@ class PackageSettings:
68
69
  fileExtension='.pyx'
69
70
  )
70
71
  ```
71
-
72
72
  """
73
73
 
74
74
  identifierPackageFALLBACK: dataclasses.InitVar[str] = ''
@@ -82,14 +82,11 @@ class PackageSettings:
82
82
 
83
83
  def __post_init__(self, identifierPackageFALLBACK: str) -> None:
84
84
  """Initialize computed fields after dataclass initialization."""
85
- if not self.identifierPackage and identifierPackageFALLBACK:
86
- self.identifierPackage = getIdentifierPackagePACKAGING(identifierPackageFALLBACK)
85
+ self.identifierPackage = self.identifierPackage or getIdentifierPackagePACKAGING(identifierPackageFALLBACK)
87
86
  if self.pathPackage == Path() and self.identifierPackage:
88
87
  self.pathPackage = getPathPackageINSTALLING(self.identifierPackage)
89
88
 
90
- TypeSansNone = TypeVar('TypeSansNone')
91
-
92
- def raiseIfNone(expression: TypeSansNone | None, errorMessage: str | None = None) -> TypeSansNone:
89
+ def raiseIfNone[TypeSansNone](expression: TypeSansNone | None, errorMessage: str | None = None) -> TypeSansNone:
93
90
  """Convert the `expression` return annotation from '`cerPytainty | None`' to '`cerPytainty`' because `expression` cannot be `None`; `raise` an `Exception` if you're wrong.
94
91
 
95
92
  The Python interpreter evaluates `expression` to a value: think of a function call or an attribute access. You can use
@@ -142,7 +139,6 @@ def raiseIfNone(expression: TypeSansNone | None, errorMessage: str | None = None
142
139
  Thanks
143
140
  ------
144
141
  sobolevn, https://github.com/sobolevn, for the seed of this function. https://github.com/python/typing/discussions/1997#discussioncomment-13108399
145
-
146
142
  """
147
143
  if expression is None:
148
144
  message: str = errorMessage or 'A function unexpectedly returned `None`. Hint: look at the traceback immediately before `raiseIfNone`.'
@@ -12,7 +12,7 @@ Functions
12
12
  removeExtraWhitespace
13
13
  Remove whitespace after commas and inside parentheses or square brackets.
14
14
  stringItUp
15
- Convert every element in input data structures to strings.
15
+ Collect string representations from nested values.
16
16
  updateExtendPolishDictionaryLists
17
17
  Merge iterable values into lists with optional deduplication and sorting.
18
18
  """
@@ -36,44 +36,65 @@ if TYPE_CHECKING:
36
36
  from typing import Any, Literal
37
37
 
38
38
  def removeExtraWhitespace(string: str) -> str:
39
- #ruff: ignore[docstring-missing-returns]
40
- """Remove extra whitespace from string representation of Python data structures."""
39
+ """Remove whitespace after commas and inside parentheses or square brackets.
40
+
41
+ (AI generated docstring)
42
+
43
+ Parameters
44
+ ----------
45
+ string : str
46
+ Text to compact. Whitespace inside quoted text is affected too, so use this operation
47
+ only when that whitespace can be removed without changing the intended meaning.
48
+
49
+ Returns
50
+ -------
51
+ stringCompacted : str
52
+ Text without whitespace immediately after commas, opening parentheses, or opening
53
+ square brackets, or immediately before closing parentheses or closing square brackets.
54
+ """
41
55
  commas: str = regex.sub(r',\s+', ',', string)
42
56
  bracketsOpening: str = regex.sub(r'([\[\(])\s+', r'\1', commas)
43
57
  return regex.sub(r'\s+([\]\)])', r'\1', bracketsOpening)
44
58
 
45
59
  def autoDecodingRLE(arrayTarget: NDArray[integer[Any]], *, assumeAddSpaces: bool = False) -> str:
46
- """Transform a NumPy array into a compact, self-decoding run-length encoded string representation.
60
+ """Transform a NumPy integer array into a compact, self-decoding Python expression.
61
+
62
+ (AI generated docstring)
47
63
 
48
- Use this function to convert a NumPy array into a string that, when evaluated as Python code,
49
- creates a list or nested lists representing the original array structure. You can create a NumPy
50
- array, torch Tensor, or other array-like object with the auto-decoded list of lists. The RLE
51
- (Run-Length Encoding) string does _not_ need a decoder function: it is native Python syntax. The
52
- function employs two encoding strategies: 1. Python `range` syntax for consecutive integer
53
- sequences. 2. Multiplication syntax for repeated elements.
64
+ You can convert a NumPy integer array into text that, when evaluated as Python code, reproduces
65
+ `arrayTarget.tolist()`. You can create a NumPy array, a PyTorch tensor, or another array-like
66
+ object from the decoded value. The RLE (Run-Length Encoding) text does not need a decoder
67
+ function; it is native Python syntax using unpacked `range` expressions for consecutive integers
68
+ and list multiplication for repeated elements.
54
69
 
55
- The resulting string representation is merely minified Python code, so it is space-efficient and,
56
- hypothetically, human-readable.
70
+ The resulting text is minified Python code, so it is space-efficient and, hypothetically,
71
+ human-readable.
57
72
 
58
73
  Parameters
59
74
  ----------
60
75
  arrayTarget : NDArray[integer[Any]]
61
- The NumPy array to be encoded.
76
+ The NumPy integer array to encode. A zero-dimensional array produces a scalar expression;
77
+ all other arrays produce a list expression.
62
78
  assumeAddSpaces : bool = False
63
- Affects internal length comparison during compression decisions. This parameter doesn't
64
- directly change the output: instead, use it to assume that something else will add spaces,
65
- such as `ast.unparse()` (Abstract Syntax Tree) or a Python formatter.
79
+ Whether encoding choices should account for spaces that `ast.unparse` or a Python
80
+ formatter may insert. `True` estimates one space per comma and two spaces around
81
+ multiplication after `]`. The returned expression remains compact in either mode.
66
82
 
67
83
  Returns
68
84
  -------
69
85
  encodedString : str
70
- A string representation of the array using run-length encoding that, when evaluated as Python
71
- code, reproduces the original array structure.
86
+ A Python expression representing `arrayTarget.tolist()`. The expression does not store
87
+ NumPy dtype or shape metadata, including dimensions beyond an empty axis.
72
88
  """
73
89
  def sliceNDArrayToNestedLists(arraySlice: NDArray[integer[Any]]) -> Any:
74
90
  def getLengthOption(optionAsStr: str) -> int:
75
- #ruff: ignore[docstring-missing-returns]
76
- """`assumeAddSpaces` characters: `,` 1 space; `]*` 2 spaces."""
91
+ """I use this estimate to compare encoding lengths with optional formatter spaces.
92
+
93
+ (AI generated docstring)
94
+
95
+ The estimate includes one extra space per comma and two extra spaces per `]*` when
96
+ `assumeAddSpaces` is `True`.
97
+ """
77
98
  return assumeAddSpaces * (optionAsStr.count(',') + optionAsStr.count(']*') * 2) + len(optionAsStr)
78
99
 
79
100
  if 1 < arraySlice.ndim:
@@ -150,19 +171,24 @@ def autoDecodingRLE(arrayTarget: NDArray[integer[Any]], *, assumeAddSpaces: bool
150
171
  patternRegex: regex.Pattern[str] = regex.compile(
151
172
  r"(?<!rang)(?:"
152
173
  #Pattern 1: Comma ahead, bracket behind
153
- r"(?P<joinAhead>,)\((?P<malkovich>\d+),(?P<multiply>\d+)\)(?P<bracketBehind>])|"
174
+ r"(?P<joinAhead>,)\((?P<malkovich>-?\d+|range\(-?\d+,-?\d+\)),(?P<multiply>\d+)\)(?P<bracketBehind>])|"
154
175
  #Pattern 2: Bracket or start ahead, comma behind
155
- r"(?P<bracketOrStartAhead>\[|^.)\((?P<malkovichMalkovich>\d+),(?P<multiplyIDK>\d+)\)(?P<joinBehind>,)|"
176
+ r"(?P<bracketOrStartAhead>\[|^.)\((?P<malkovichMalkovich>-?\d+|range\(-?\d+,-?\d+\)),(?P<multiplyIDK>\d+)\)(?P<joinBehind>,)|"
156
177
  #Pattern 3: Bracket ahead, bracket behind
157
- r"(?P<bracketAhead>\[)\((?P<malkovichMalkovichMalkovich>\d+),(?P<multiply_whatever>\d+)\)(?P<bracketBehindBracketBehind>])|"
178
+ r"(?P<bracketAhead>\[)\((?P<malkovichMalkovichMalkovich>-?\d+|range\(-?\d+,-?\d+\)),(?P<multiply_whatever>\d+)\)(?P<bracketBehindBracketBehind>])|"
158
179
  #Pattern 4: Comma ahead, comma behind
159
- r"(?P<joinAheadJoinAhead>,)\((?P<malkovichMalkovichMalkovichMalkovich>\d+),(?P<multiplyOrSomething>\d+)\)(?P<joinBehindJoinBehind>,)"
180
+ r"(?P<joinAheadJoinAhead>,)\((?P<malkovichMalkovichMalkovichMalkovich>-?\d+|range\(-?\d+,-?\d+\)),(?P<multiplyOrSomething>\d+)\)(?P<joinBehindJoinBehind>,)"
160
181
  r")"
161
182
  )
162
183
 
163
184
  def replacementByContext(match: regex.Match[str]) -> str:
164
- #ruff: ignore[docstring-missing-returns]
165
- """Generate replacement string based on context patterns."""
185
+ """I use this replacement to express a repeated value with Python list multiplication.
186
+
187
+ (AI generated docstring)
188
+
189
+ The replacement joins the repeated list with any surrounding list elements so that
190
+ the resulting expression preserves the decoded values and their order.
191
+ """
166
192
  elephino: dict[str, str | None] = match.groupdict()
167
193
  joinAhead: str | None = elephino.get('joinAhead') or elephino.get('joinAheadJoinAhead')
168
194
  malkovich: str | None = elephino.get('malkovich') or elephino.get('malkovichMalkovich') or elephino.get('malkovichMalkovichMalkovich') or elephino.get('malkovichMalkovichMalkovichMalkovich')
@@ -185,17 +211,44 @@ def autoDecodingRLE(arrayTarget: NDArray[integer[Any]], *, assumeAddSpaces: bool
185
211
  def stringItUp(*scrapPile: Any) -> list[str]:
186
212
  """Convert, if possible, every element in the input data structure to a string.
187
213
 
188
- Order is not preserved or readily predictable.
214
+ (AI generated docstring)
215
+
216
+ You can collect text from nested inputs into a flat `list`. Dictionaries contribute both keys
217
+ and values. Strings contribute their full text, and callables contribute their names.
189
218
 
190
219
  Parameters
191
220
  ----------
192
221
  *scrapPile : Any
193
- (scrap2pile) One or more data structures to unpack and convert to strings.
222
+ (scrap2pile) Values or nested data structures to unpack and convert. No arguments produce
223
+ an empty `list`. `bytes` and `bytearray` contribute their Python string representations.
224
+ A `memoryview` contributes decoded text when text decoding succeeds. Other iterables
225
+ contribute their elements and are consumed.
194
226
 
195
227
  Returns
196
228
  -------
197
229
  listStrungUp : list[str]
198
- (list2strung2up) A `list` of string versions of all convertible elements.
230
+ (list2strung2up) A flat `list` of string representations. The result follows argument order
231
+ and container iteration order. Unordered containers can make the result order unpredictable.
232
+
233
+ Incomplete Conversion
234
+ ---------------------
235
+ Other non-iterable values contribute their string representations. String conversion that
236
+ returns `None` or raises `AttributeError` or `TypeError` omits those values. Other exceptions
237
+ from that conversion produce a diagnostic on `sys.stderr` and propagate.
238
+
239
+ If recursive input exceeds Python's recursion limit, the result retains text already collected
240
+ and appends `repr` of the current top-level argument. Later arguments are not processed.
241
+
242
+ Examples
243
+ --------
244
+ The README collects text from nested user and configuration data.
245
+
246
+ ```python
247
+ from hunterMakesPy.dataStructures import stringItUp
248
+
249
+ strings = stringItUp({"users": ["alice"], "config": {"host": "localhost"}})
250
+ # Returns ["users", "alice", "config", "host", "localhost"].
251
+ ```
199
252
  """
200
253
  scrap: Any = None
201
254
  listStrungUp: list[str] = []
@@ -228,8 +281,9 @@ def stringItUp(*scrapPile: Any) -> list[str]:
228
281
  else:
229
282
  try:
230
283
  #ruff: ignore[unnecessary-dunder-call]
231
- sharingIsCaring: str = KitKat.__str__()
232
- listStrungUp.append(sharingIsCaring)
284
+ sharingIsCaring: str | None = KitKat.__str__()
285
+ if sharingIsCaring is not None:
286
+ listStrungUp.append(sharingIsCaring)
233
287
  except AttributeError:
234
288
  pass
235
289
  except TypeError:
@@ -258,24 +312,23 @@ def updateExtendPolishDictionaryLists(*dictionaryLists: Mapping[文件, Iterable
258
312
  def updateExtendPolishDictionaryLists(*dictionaryLists: Mapping[文件, Iterable[文义]], destroyDuplicates: bool = False, reorderLists: bool = False, killErroneousDataTypes: bool = False) -> dict[文件, list[文义]]:
259
313
  """Merge mappings of iterable values into a dictionary of lists.
260
314
 
261
- You can use this function to combine values under matching keys across `dictionaryLists`.
262
- This function returns a new dictionary with new lists and can remove duplicate elements,
263
- sort elements, or skip entries that raise `TypeError` during merging.
315
+ (AI generated docstring)
264
316
 
265
- Iteration and Ordering
266
- ----------------------
267
- This function consumes each value's iterable in mapping argument order. Within each value,
268
- the list follows the iterable's order, which may be unpredictable for sets. Strings contribute
269
- individual characters, and mapping values contribute their keys.
317
+ You can use this function to combine values under matching keys across `dictionaryLists`.
318
+ You receive a new dictionary with new lists and can remove duplicate elements, sort elements,
319
+ or skip entries that raise `TypeError` during merging.
270
320
 
271
- Deduplication uses `dict.fromkeys` [1] to preserve first occurrences. Sorting uses `sorted` [2]
272
- and runs after deduplication. Every retained value becomes a list regardless of the input type.
321
+ Input Consumption
322
+ -----------------
323
+ The input mappings and reusable value containers remain unchanged. Iterable values such as
324
+ generators are consumed. Each result list retains references to the original elements.
273
325
 
274
326
  Parameters
275
327
  ----------
276
328
  *dictionaryLists : Mapping[文件, Iterable[文义]]
277
329
  The mappings to merge, with hashable keys and iterable values. A single mapping receives
278
- the same conversion and optional processing. No mappings produce an empty dictionary.
330
+ the same conversion and optional processing. Omitting all mappings produces an empty
331
+ dictionary. Strings contribute individual characters. Mapping values contribute their keys.
279
332
  destroyDuplicates : bool = False
280
333
  If `True`, remove duplicate elements from each merged list, preserving the first occurrence.
281
334
  Elements must be hashable when this option is enabled.
@@ -290,8 +343,9 @@ def updateExtendPolishDictionaryLists(*dictionaryLists: Mapping[文件, Iterable
290
343
  Returns
291
344
  -------
292
345
  ePluribusUnum : dict[文件, list[文义]]
293
- The merged dictionary, with a list for every retained key. This function does not modify
294
- the input mappings or their containers, but the lists retain references to the original elements.
346
+ The merged dictionary, with a new list for every retained key. Mapping argument order and
347
+ each value's iteration order determine element order unless `reorderLists` is `True`.
348
+ Unordered inputs, such as sets, may produce unpredictable element order.
295
349
 
296
350
  Raises
297
351
  ------
@@ -315,12 +369,6 @@ def updateExtendPolishDictionaryLists(*dictionaryLists: Mapping[文件, Iterable
315
369
  # Returns {"servers": ["chicago", "tokyo"]}.
316
370
  ```
317
371
 
318
- References
319
- ----------
320
- [1] Python dictionaries and `dict.fromkeys`.
321
- https://docs.python.org/3/library/stdtypes.html#dict.fromkeys
322
- [2] Python `sorted`.
323
- https://docs.python.org/3/library/functions.html#sorted
324
372
  """
325
373
  ePluribusUnum: dict[文件, list[文义]] = {}
326
374