hunterMakesPy 0.9.0__tar.gz → 0.10.1__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 (50) hide show
  1. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/PKG-INFO +13 -14
  2. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/README.md +7 -8
  3. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/hunterMakesPy/__init__.py +22 -7
  4. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/hunterMakesPy/coping.py +26 -26
  5. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/hunterMakesPy/dataStructures.py +108 -54
  6. huntermakespy-0.9.0/hunterMakesPy/filesystemToolkit.py → huntermakespy-0.10.1/hunterMakesPy/kitFilesystem.py +147 -59
  7. huntermakespy-0.10.1/hunterMakesPy/parseParameters.py +277 -0
  8. huntermakespy-0.10.1/hunterMakesPy/tests/__init__.py +33 -0
  9. huntermakespy-0.10.1/hunterMakesPy/tests/conftest.py +34 -0
  10. huntermakespy-0.10.1/hunterMakesPy/tests/conftestAnnex.py +46 -0
  11. huntermakespy-0.10.1/hunterMakesPy/tests/dataSamples/__init__.py +13 -0
  12. huntermakespy-0.10.1/hunterMakesPy/tests/dataSamples/arrays.py +85 -0
  13. huntermakespy-0.10.1/hunterMakesPy/tests/dataSamples/arraysRLE.py +11 -0
  14. huntermakespy-0.10.1/hunterMakesPy/tests/dataSamples/callables.py +20 -0
  15. huntermakespy-0.10.1/hunterMakesPy/tests/dataSamples/classes.py +50 -0
  16. huntermakespy-0.10.1/hunterMakesPy/tests/dataSamples/containers.py +22 -0
  17. huntermakespy-0.10.1/hunterMakesPy/tests/dataSamples/messages.py +4 -0
  18. huntermakespy-0.10.1/hunterMakesPy/tests/dataSamples/packages.py +11 -0
  19. huntermakespy-0.10.1/hunterMakesPy/tests/dataSamples/pyprojects.py +7 -0
  20. huntermakespy-0.10.1/hunterMakesPy/tests/dataSamples/pythonSource.py +10 -0
  21. huntermakespy-0.10.1/hunterMakesPy/tests/dataSamples/text.py +10 -0
  22. huntermakespy-0.10.1/hunterMakesPy/tests/test_conftestAnnex.py +68 -0
  23. huntermakespy-0.10.1/hunterMakesPy/tests/test_coping.py +100 -0
  24. huntermakespy-0.10.1/hunterMakesPy/tests/test_dataStructures.py +259 -0
  25. huntermakespy-0.10.1/hunterMakesPy/tests/test_kitFilesystem.py +167 -0
  26. huntermakespy-0.10.1/hunterMakesPy/tests/test_parseParameters.py +156 -0
  27. huntermakespy-0.10.1/hunterMakesPy/tests/test_theTypes.py +27 -0
  28. huntermakespy-0.10.1/hunterMakesPy/theTypes.py +180 -0
  29. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/hunterMakesPy.egg-info/PKG-INFO +13 -14
  30. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/hunterMakesPy.egg-info/SOURCES.txt +15 -4
  31. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/hunterMakesPy.egg-info/requires.txt +5 -5
  32. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/pyproject.toml +17 -8
  33. huntermakespy-0.9.0/hunterMakesPy/parseParameters.py +0 -351
  34. huntermakespy-0.9.0/hunterMakesPy/tests/__init__.py +0 -33
  35. huntermakespy-0.9.0/hunterMakesPy/tests/conftest.py +0 -145
  36. huntermakespy-0.9.0/hunterMakesPy/tests/conftestAnnex.py +0 -22
  37. huntermakespy-0.9.0/hunterMakesPy/tests/test_coping.py +0 -322
  38. huntermakespy-0.9.0/hunterMakesPy/tests/test_dataStructures.py +0 -190
  39. huntermakespy-0.9.0/hunterMakesPy/tests/test_filesystemToolkit.py +0 -564
  40. huntermakespy-0.9.0/hunterMakesPy/tests/test_parseParameters.py +0 -402
  41. huntermakespy-0.9.0/hunterMakesPy/tests/test_theTypes.py +0 -246
  42. huntermakespy-0.9.0/hunterMakesPy/theTypes.py +0 -29
  43. huntermakespy-0.9.0/hunterMakesPy/theTypesCallableFunction.py +0 -63
  44. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/LICENSE +0 -0
  45. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/hunterMakesPy/_theSSOT.py +0 -0
  46. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/hunterMakesPy/py.typed +0 -0
  47. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/hunterMakesPy/semiotics.py +0 -0
  48. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/hunterMakesPy.egg-info/dependency_links.txt +0 -0
  49. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/hunterMakesPy.egg-info/top_level.txt +0 -0
  50. {huntermakespy-0.9.0 → huntermakespy-0.10.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hunterMakesPy
3
- Version: 0.9.0
3
+ Version: 0.10.1
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
@@ -25,19 +25,19 @@ Classifier: Typing :: Typed
25
25
  Requires-Python: >=3.12
26
26
  Description-Content-Type: text/markdown
27
27
  License-File: LICENSE
28
- Requires-Dist: Z0Z_tools>=4.0.0
28
+ Requires-Dist: Z0Z_tools>=4.1.1
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,16 +171,14 @@ 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
@@ -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,16 +129,14 @@ 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
@@ -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,49 +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
- def getIdentifierPackagePACKAGING(identifierPackageFALLBACK: str) -> str:
14
+ def _getIdentifierPackagePACKAGING(identifierPackageFALLBACK: str) -> str:
15
15
  """Get package name from pyproject.toml or fallback to provided value."""
16
- try:
17
- return tomli_loads(Path('pyproject.toml').read_text(encoding='utf-8'))['project']['name']
18
- #ruff: ignore[blind-except]
19
- except Exception:
20
- 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
21
20
 
22
- def getPathPackageINSTALLING(identifierPackage: str) -> Path:
21
+ def _getPathPackageINSTALLING(identifierPackage: str) -> Path:
23
22
  """Return the root directory of the installed package."""
24
- try:
23
+ pathPackage: Path = Path.cwd()
24
+ with contextlib.suppress(ModuleNotFoundError):
25
25
  moduleSpecification: ModuleSpec | None = find_spec(identifierPackage)
26
26
  if moduleSpecification and moduleSpecification.origin:
27
27
  pathFilename: Path = Path(moduleSpecification.origin)
28
- return pathFilename.parent if pathFilename.is_file() else pathFilename
29
- except ModuleNotFoundError:
30
- pass
31
- return Path.cwd()
28
+ if pathFilename.is_file():
29
+ pathPackage = pathFilename.parent
30
+ else:
31
+ pathPackage = pathFilename
32
+ return pathPackage
32
33
 
33
34
  @dataclasses.dataclass
34
35
  class PackageSettings:
35
36
  """Configuration container for Python package metadata and runtime settings.
36
37
 
37
- This `class` provides a simple way to store and access basic information about a Python package, It will automatically resolve
38
- package identifiers and installation paths if they are not passed to the `class` constructor. Python `dataclasses` are easy to
39
- 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.
40
41
 
41
42
  Attributes
42
43
  ----------
43
44
  identifierPackageFALLBACK : str = ''
44
45
  Fallback package identifier used only during initialization when automatic discovery fails.
45
46
  identifierPackage : str = ''
46
- Canonical name of the package. Automatically extracted from "pyproject.toml".
47
- pathPackage : Path = getPathPackageINSTALLING(identifierPackage)
48
- Absolute path to the installed package directory. Automatically resolved from `identifierPackage` if not provided.
47
+ Canonical name of the package. An explicit value takes precedence over `pyproject.toml`, then
48
+ `identifierPackageFALLBACK`.
49
+ pathPackage : Path = _getPathPackageINSTALLING(identifierPackage)
50
+ Absolute path to the installed package directory. Automatically resolved from
51
+ `identifierPackage` if not provided.
49
52
  fileExtension : str = '.py'
50
53
  Default file extension.
51
54
 
@@ -79,14 +82,11 @@ class PackageSettings:
79
82
 
80
83
  def __post_init__(self, identifierPackageFALLBACK: str) -> None:
81
84
  """Initialize computed fields after dataclass initialization."""
82
- if not self.identifierPackage and identifierPackageFALLBACK:
83
- self.identifierPackage = getIdentifierPackagePACKAGING(identifierPackageFALLBACK)
85
+ self.identifierPackage = self.identifierPackage or _getIdentifierPackagePACKAGING(identifierPackageFALLBACK)
84
86
  if self.pathPackage == Path() and self.identifierPackage:
85
- self.pathPackage = getPathPackageINSTALLING(self.identifierPackage)
87
+ self.pathPackage = _getPathPackageINSTALLING(self.identifierPackage)
86
88
 
87
- TypeSansNone = TypeVar('TypeSansNone')
88
-
89
- def raiseIfNone(expression: TypeSansNone | None, errorMessage: str | None = None) -> TypeSansNone:
89
+ def raiseIfNone[TypeSansNone](expression: TypeSansNone | None, errorMessage: str | None = None) -> TypeSansNone:
90
90
  """Convert the `expression` return annotation from '`cerPytainty | None`' to '`cerPytainty`' because `expression` cannot be `None`; `raise` an `Exception` if you're wrong.
91
91
 
92
92
  The Python interpreter evaluates `expression` to a value: think of a function call or an attribute access. You can use
@@ -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
  """
@@ -29,49 +29,72 @@ import re as regex
29
29
  import sys
30
30
 
31
31
  if TYPE_CHECKING:
32
- from collections.abc import Callable, Iterable, Iterator, Mapping
32
+ from collections.abc import Callable, Iterable, Mapping
33
33
  from hunterMakesPy import 小于, 文义, 文件
34
34
  from numpy import integer
35
35
  from numpy.typing import NDArray
36
36
  from typing import Any, Literal
37
37
 
38
38
  def removeExtraWhitespace(string: str) -> str:
39
- """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
+ """
40
55
  commas: str = regex.sub(r',\s+', ',', string)
41
56
  bracketsOpening: str = regex.sub(r'([\[\(])\s+', r'\1', commas)
42
57
  return regex.sub(r'\s+([\]\)])', r'\1', bracketsOpening)
43
58
 
44
59
  def autoDecodingRLE(arrayTarget: NDArray[integer[Any]], *, assumeAddSpaces: bool = False) -> str:
45
- """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)
46
63
 
47
- Use this function to convert a NumPy array into a string that, when evaluated as Python code,
48
- creates a list or nested lists representing the original array structure. You can create a NumPy
49
- array, torch Tensor, or other array-like object with the auto-decoded list of lists. The RLE
50
- (Run-Length Encoding) string does _not_ need a decoder function: it is native Python syntax. The
51
- function employs two encoding strategies: 1. Python `range` syntax for consecutive integer
52
- 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.
53
69
 
54
- The resulting string representation is merely minified Python code, so it is space-efficient and,
55
- hypothetically, human-readable.
70
+ The resulting text is minified Python code, so it is space-efficient and, hypothetically,
71
+ human-readable.
56
72
 
57
73
  Parameters
58
74
  ----------
59
75
  arrayTarget : NDArray[integer[Any]]
60
- 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.
61
78
  assumeAddSpaces : bool = False
62
- Affects internal length comparison during compression decisions. This parameter doesn't
63
- directly change the output: instead, use it to assume that something else will add spaces,
64
- 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.
65
82
 
66
83
  Returns
67
84
  -------
68
85
  encodedString : str
69
- A string representation of the array using run-length encoding that, when evaluated as Python
70
- 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.
71
88
  """
72
89
  def sliceNDArrayToNestedLists(arraySlice: NDArray[integer[Any]]) -> Any:
73
90
  def getLengthOption(optionAsStr: str) -> int:
74
- """`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
+ """
75
98
  return assumeAddSpaces * (optionAsStr.count(',') + optionAsStr.count(']*') * 2) + len(optionAsStr)
76
99
 
77
100
  if 1 < arraySlice.ndim:
@@ -79,13 +102,14 @@ def autoDecodingRLE(arrayTarget: NDArray[integer[Any]], *, assumeAddSpaces: bool
79
102
  return [sliceNDArrayToNestedLists(arraySlice[index]) for index in range(arraySlice.shape[axisOfOperation])]
80
103
  if arraySlice.ndim == 1:
81
104
  arraySliceAsList: list[int | range] = []
82
- cache_consecutiveGroup_addMe: dict[Iterator[Any], list[int] | list[range]] = {}
105
+ cache_consecutiveGroup_addMe: dict[range, list[int] | list[range]] = {}
83
106
  for consecutiveGroup in more_itertools.consecutive_groups(arraySlice.tolist()):
84
- if consecutiveGroup in cache_consecutiveGroup_addMe:
85
- addMe = cache_consecutiveGroup_addMe[consecutiveGroup]
107
+ ImaSerious: list[int] = list(consecutiveGroup)
108
+ rangeConsecutiveGroup: range = range(ImaSerious[0], ImaSerious[-1] + 1)
109
+ if rangeConsecutiveGroup in cache_consecutiveGroup_addMe:
110
+ addMe = cache_consecutiveGroup_addMe[rangeConsecutiveGroup]
86
111
  else:
87
- ImaSerious: list[int] = list(consecutiveGroup)
88
- ImaRange: list[range] = [range(ImaSerious[0], ImaSerious[-1] + 1)]
112
+ ImaRange: list[range] = [rangeConsecutiveGroup]
89
113
  ImaRangeAsStr: str = removeExtraWhitespace(str(ImaRange)).replace('range(0,', 'range(').replace('range', '*range')
90
114
 
91
115
  option1 = ImaRange
@@ -104,7 +128,7 @@ def autoDecodingRLE(arrayTarget: NDArray[integer[Any]], *, assumeAddSpaces: bool
104
128
  else:
105
129
  addMe = option2
106
130
 
107
- cache_consecutiveGroup_addMe[consecutiveGroup] = addMe
131
+ cache_consecutiveGroup_addMe[rangeConsecutiveGroup] = addMe
108
132
 
109
133
  arraySliceAsList += addMe
110
134
 
@@ -148,18 +172,24 @@ def autoDecodingRLE(arrayTarget: NDArray[integer[Any]], *, assumeAddSpaces: bool
148
172
  patternRegex: regex.Pattern[str] = regex.compile(
149
173
  r"(?<!rang)(?:"
150
174
  #Pattern 1: Comma ahead, bracket behind
151
- r"(?P<joinAhead>,)\((?P<malkovich>\d+),(?P<multiply>\d+)\)(?P<bracketBehind>])|"
175
+ r"(?P<joinAhead>,)\((?P<malkovich>-?\d+|range\(-?\d+,-?\d+\)),(?P<multiply>\d+)\)(?P<bracketBehind>])|"
152
176
  #Pattern 2: Bracket or start ahead, comma behind
153
- r"(?P<bracketOrStartAhead>\[|^.)\((?P<malkovichMalkovich>\d+),(?P<multiplyIDK>\d+)\)(?P<joinBehind>,)|"
177
+ r"(?P<bracketOrStartAhead>\[|^.)\((?P<malkovichMalkovich>-?\d+|range\(-?\d+,-?\d+\)),(?P<multiplyIDK>\d+)\)(?P<joinBehind>,)|"
154
178
  #Pattern 3: Bracket ahead, bracket behind
155
- r"(?P<bracketAhead>\[)\((?P<malkovichMalkovichMalkovich>\d+),(?P<multiply_whatever>\d+)\)(?P<bracketBehindBracketBehind>])|"
179
+ r"(?P<bracketAhead>\[)\((?P<malkovichMalkovichMalkovich>-?\d+|range\(-?\d+,-?\d+\)),(?P<multiply_whatever>\d+)\)(?P<bracketBehindBracketBehind>])|"
156
180
  #Pattern 4: Comma ahead, comma behind
157
- r"(?P<joinAheadJoinAhead>,)\((?P<malkovichMalkovichMalkovichMalkovich>\d+),(?P<multiplyOrSomething>\d+)\)(?P<joinBehindJoinBehind>,)"
181
+ r"(?P<joinAheadJoinAhead>,)\((?P<malkovichMalkovichMalkovichMalkovich>-?\d+|range\(-?\d+,-?\d+\)),(?P<multiplyOrSomething>\d+)\)(?P<joinBehindJoinBehind>,)"
158
182
  r")"
159
183
  )
160
184
 
161
185
  def replacementByContext(match: regex.Match[str]) -> str:
162
- """Generate replacement string based on context patterns."""
186
+ """I use this replacement to express a repeated value with Python list multiplication.
187
+
188
+ (AI generated docstring)
189
+
190
+ The replacement joins the repeated list with any surrounding list elements so that
191
+ the resulting expression preserves the decoded values and their order.
192
+ """
163
193
  elephino: dict[str, str | None] = match.groupdict()
164
194
  joinAhead: str | None = elephino.get('joinAhead') or elephino.get('joinAheadJoinAhead')
165
195
  malkovich: str | None = elephino.get('malkovich') or elephino.get('malkovichMalkovich') or elephino.get('malkovichMalkovichMalkovich') or elephino.get('malkovichMalkovichMalkovichMalkovich')
@@ -182,17 +212,44 @@ def autoDecodingRLE(arrayTarget: NDArray[integer[Any]], *, assumeAddSpaces: bool
182
212
  def stringItUp(*scrapPile: Any) -> list[str]:
183
213
  """Convert, if possible, every element in the input data structure to a string.
184
214
 
185
- Order is not preserved or readily predictable.
215
+ (AI generated docstring)
216
+
217
+ You can collect text from nested inputs into a flat `list`. Dictionaries contribute both keys
218
+ and values. Strings contribute their full text, and callables contribute their names.
186
219
 
187
220
  Parameters
188
221
  ----------
189
222
  *scrapPile : Any
190
- (scrap2pile) One or more data structures to unpack and convert to strings.
223
+ (scrap2pile) Values or nested data structures to unpack and convert. No arguments produce
224
+ an empty `list`. `bytes` and `bytearray` contribute their Python string representations.
225
+ A `memoryview` contributes decoded text when text decoding succeeds. Other iterables
226
+ contribute their elements and are consumed.
191
227
 
192
228
  Returns
193
229
  -------
194
230
  listStrungUp : list[str]
195
- (list2strung2up) A `list` of string versions of all convertible elements.
231
+ (list2strung2up) A flat `list` of string representations. The result follows argument order
232
+ and container iteration order. Unordered containers can make the result order unpredictable.
233
+
234
+ Incomplete Conversion
235
+ ---------------------
236
+ Other non-iterable values contribute their string representations. String conversion that
237
+ returns `None` or raises `AttributeError` or `TypeError` omits those values. Other exceptions
238
+ from that conversion produce a diagnostic on `sys.stderr` and propagate.
239
+
240
+ If recursive input exceeds Python's recursion limit, the result retains text already collected
241
+ and appends `repr` of the current top-level argument. Later arguments are not processed.
242
+
243
+ Examples
244
+ --------
245
+ The README collects text from nested user and configuration data.
246
+
247
+ ```python
248
+ from hunterMakesPy.dataStructures import stringItUp
249
+
250
+ strings = stringItUp({"users": ["alice"], "config": {"host": "localhost"}})
251
+ # Returns ["users", "alice", "config", "host", "localhost"].
252
+ ```
196
253
  """
197
254
  scrap: Any = None
198
255
  listStrungUp: list[str] = []
@@ -217,7 +274,7 @@ def stringItUp(*scrapPile: Any) -> list[str]:
217
274
  drill(broken)
218
275
  drill(piece)
219
276
  elif isinstance(KitKat, (list, tuple, set, frozenset, range)):
220
- for kit in KitKat: # pyright: ignore[reportUnknownVariableType]
277
+ for kit in KitKat:
221
278
  drill(kit)
222
279
  elif hasattr(KitKat, '__iter__'):
223
280
  for kat in KitKat:
@@ -225,8 +282,9 @@ def stringItUp(*scrapPile: Any) -> list[str]:
225
282
  else:
226
283
  try:
227
284
  #ruff: ignore[unnecessary-dunder-call]
228
- sharingIsCaring: str = KitKat.__str__()
229
- listStrungUp.append(sharingIsCaring)
285
+ sharingIsCaring: str | None = KitKat.__str__()
286
+ if sharingIsCaring is not None:
287
+ listStrungUp.append(sharingIsCaring)
230
288
  except AttributeError:
231
289
  pass
232
290
  except TypeError:
@@ -255,24 +313,23 @@ def updateExtendPolishDictionaryLists(*dictionaryLists: Mapping[文件, Iterable
255
313
  def updateExtendPolishDictionaryLists(*dictionaryLists: Mapping[文件, Iterable[文义]], destroyDuplicates: bool = False, reorderLists: bool = False, killErroneousDataTypes: bool = False) -> dict[文件, list[文义]]:
256
314
  """Merge mappings of iterable values into a dictionary of lists.
257
315
 
258
- You can use this function to combine values under matching keys across `dictionaryLists`.
259
- This function returns a new dictionary with new lists and can remove duplicate elements,
260
- sort elements, or skip entries that raise `TypeError` during merging.
316
+ (AI generated docstring)
261
317
 
262
- Iteration and Ordering
263
- ----------------------
264
- This function consumes each value's iterable in mapping argument order. Within each value,
265
- the list follows the iterable's order, which may be unpredictable for sets. Strings contribute
266
- individual characters, and mapping values contribute their keys.
318
+ You can use this function to combine values under matching keys across `dictionaryLists`.
319
+ You receive a new dictionary with new lists and can remove duplicate elements, sort elements,
320
+ or skip entries that raise `TypeError` during merging.
267
321
 
268
- Deduplication uses `dict.fromkeys` [1] to preserve first occurrences. Sorting uses `sorted`
269
- and runs after deduplication. Every retained value becomes a list regardless of the input type.
322
+ Input Consumption
323
+ -----------------
324
+ The input mappings and reusable value containers remain unchanged. Iterable values such as
325
+ generators are consumed. Each result list retains references to the original elements.
270
326
 
271
327
  Parameters
272
328
  ----------
273
329
  *dictionaryLists : Mapping[文件, Iterable[文义]]
274
330
  The mappings to merge, with hashable keys and iterable values. A single mapping receives
275
- the same conversion and optional processing. No mappings produce an empty dictionary.
331
+ the same conversion and optional processing. Omitting all mappings produces an empty
332
+ dictionary. Strings contribute individual characters. Mapping values contribute their keys.
276
333
  destroyDuplicates : bool = False
277
334
  If `True`, remove duplicate elements from each merged list, preserving the first occurrence.
278
335
  Elements must be hashable when this option is enabled.
@@ -287,8 +344,9 @@ def updateExtendPolishDictionaryLists(*dictionaryLists: Mapping[文件, Iterable
287
344
  Returns
288
345
  -------
289
346
  ePluribusUnum : dict[文件, list[文义]]
290
- The merged dictionary, with a list for every retained key. This function does not modify
291
- the input mappings or their containers, but the lists retain references to the original elements.
347
+ The merged dictionary, with a new list for every retained key. Mapping argument order and
348
+ each value's iteration order determine element order unless `reorderLists` is `True`.
349
+ Unordered inputs, such as sets, may produce unpredictable element order.
292
350
 
293
351
  Raises
294
352
  ------
@@ -312,10 +370,6 @@ def updateExtendPolishDictionaryLists(*dictionaryLists: Mapping[文件, Iterable
312
370
  # Returns {"servers": ["chicago", "tokyo"]}.
313
371
  ```
314
372
 
315
- References
316
- ----------
317
- [1] Python dictionaries and `dict.fromkeys`.
318
- https://docs.python.org/3/library/stdtypes.html#dict.fromkeys
319
373
  """
320
374
  ePluribusUnum: dict[文件, list[文义]] = {}
321
375
 
@@ -330,7 +384,7 @@ def updateExtendPolishDictionaryLists(*dictionaryLists: Mapping[文件, Iterable
330
384
  raise TypeError from error
331
385
 
332
386
  if destroyDuplicates:
333
- ePluribusUnum = mapValues(compose(list, dict.fromkeys), ePluribusUnum)
387
+ ePluribusUnum = mapValues(compose(list, dict.fromkeys), ePluribusUnum) # ty: ignore[invalid-argument-type]
334
388
  if reorderLists:
335
389
  #=SIN= `sorted` is broken.
336
390
  ePluribusUnum = mapValues(cast('Callable[[list[文义]], list[文义]]', sorted), ePluribusUnum)