analog_daddy.utils
¶
Miscellaneous utilities.
render(value, units='')
¶
Render a value with SI prefix, or "" for None.
Thin wrapper over quantiphy.render so tables and displays can
show missing values as blanks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float | None
|
Value to render. |
required |
units
|
str
|
Units appended to the rendered value. |
""
|
Returns:
| Type | Description |
|---|---|
str
|
Rendered value with SI prefix and units, or |
Examples:
Source code in src/analog_daddy/utils.py
scan_contents(contents, search_pattern)
¶
Yield line numbers matching a search pattern.
Contents are scanned lazily where possible (files are read line by line).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contents
|
bytes | str | Path
|
Text to scan, or a path to a file to scan. |
required |
search_pattern
|
str
|
Regex pattern searched for in each line. |
required |
Yields:
| Type | Description |
|---|---|
int
|
1-based line number of each matching line. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Examples:
>>> list(
... scan_contents(
... (b"Line 1\nLine 2\nLine 3"),
... r"Line 2",
... )
... )
[2]
>>> list(
... scan_contents(
... ("Line 1\nLine 2\n Line 3 \n"),
... "^Line 3$",
... )
... )
[]