analog-daddy 3.0.1.dev2__tar.gz → 3.0.1.dev3__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026, Siddhant Laddha
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: analog-daddy
3
+ Version: 3.0.1.dev3
4
+ Summary: This library is an attempt to make transistor sizing for Analog Design less painful. Additionally, provides helper utilities to minimize churn and errors in repetative tasks.
5
+ Author: Sid L
6
+ Author-email: Sid L <25705822+sidm273@users.noreply.github.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Education
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
19
+ Classifier: Typing :: Typed
20
+ Requires-Dist: boltons
21
+ Requires-Dist: cyclopts ; sys_platform != 'emscripten'
22
+ Requires-Dist: great-tables
23
+ Requires-Dist: plotly
24
+ Requires-Dist: polars
25
+ Requires-Dist: pydantic>=2
26
+ Requires-Dist: pydantic-settings
27
+ Requires-Dist: quantiphy
28
+ Requires-Dist: rich
29
+ Requires-Dist: scipy
30
+ Requires-Dist: xarray
31
+ Requires-Dist: marimo[lsp,mcp,recommended] ; extra == 'notebooks'
32
+ Requires-Dist: wigglystuff ; extra == 'notebooks'
33
+ Maintainer: Sid L
34
+ Maintainer-email: Sid L <25705822+sidm273@users.noreply.github.com>
35
+ Requires-Python: >=3.12
36
+ Project-URL: bugs, https://github.com/sidm273/analog_daddy/issues
37
+ Project-URL: changelog, https://github.com/sidm273/analog_daddy/releases
38
+ Project-URL: documentation, https://sidm273.github.io/analog_daddy/
39
+ Project-URL: homepage, https://github.com/sidm273/analog_daddy
40
+ Provides-Extra: notebooks
41
+ Description-Content-Type: text/markdown
42
+
43
+ # Analog Daddy
44
+
45
+ [![actions-badge]][actions-link]
46
+
47
+ [![PyPI version][pypi-version]][pypi-link]
48
+ [![PyPI platforms][pypi-platforms]][pypi-link]
49
+
50
+ <!-- prettier-ignore-start -->
51
+ [actions-badge]: https://github.com/sidm273/analog-daddy/actions/workflows/ci.yml/badge.svg
52
+ [actions-link]: https://github.com/sidm273/analog-daddy/actions
53
+ [pypi-link]: https://pypi.org/project/analog-daddy/
54
+ [pypi-platforms]: https://img.shields.io/pypi/pyversions/analog-daddy
55
+ [pypi-version]: https://img.shields.io/pypi/v/analog-daddy
56
+
57
+ <!-- prettier-ignore-end -->
58
+
59
+ This is a dummy README for the dev version. Please refer
60
+ [main](https://github.com/sidm273/analog-daddy)
@@ -0,0 +1,18 @@
1
+ # Analog Daddy
2
+
3
+ [![actions-badge]][actions-link]
4
+
5
+ [![PyPI version][pypi-version]][pypi-link]
6
+ [![PyPI platforms][pypi-platforms]][pypi-link]
7
+
8
+ <!-- prettier-ignore-start -->
9
+ [actions-badge]: https://github.com/sidm273/analog-daddy/actions/workflows/ci.yml/badge.svg
10
+ [actions-link]: https://github.com/sidm273/analog-daddy/actions
11
+ [pypi-link]: https://pypi.org/project/analog-daddy/
12
+ [pypi-platforms]: https://img.shields.io/pypi/pyversions/analog-daddy
13
+ [pypi-version]: https://img.shields.io/pypi/v/analog-daddy
14
+
15
+ <!-- prettier-ignore-end -->
16
+
17
+ This is a dummy README for the dev version. Please refer
18
+ [main](https://github.com/sidm273/analog-daddy)
@@ -1,14 +1,21 @@
1
1
  [project]
2
2
  name = "analog-daddy"
3
- version = "3.0.1.dev2"
3
+ version = "3.0.1.dev3"
4
4
  description = "This library is an attempt to make transistor sizing for Analog Design less painful. Additionally, provides helper utilities to minimize churn and errors in repetative tasks."
5
5
  readme = "README.md"
6
6
  requires-python = ">= 3.12"
7
7
  license = "MIT"
8
+ license-files = ["LICENSE"]
8
9
  classifiers = [
9
10
  "Development Status :: 4 - Beta",
10
11
  "Intended Audience :: Education",
11
12
  "Intended Audience :: Science/Research",
13
+ "Programming Language :: Python",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3 :: Only",
16
+ "Programming Language :: Python :: 3.12",
17
+ "Programming Language :: Python :: 3.13",
18
+ "Programming Language :: Python :: 3.14",
12
19
  "Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)",
13
20
  "Typing :: Typed",
14
21
  ]
@@ -27,29 +34,32 @@ dependencies = [
27
34
  ]
28
35
 
29
36
  [[project.authors]]
30
- name = "Siddhant Laddha"
31
- email = "25705822+siddhantladdha@users.noreply.github.com"
37
+ name = "Sid L"
38
+ email = "25705822+sidm273@users.noreply.github.com"
32
39
 
33
40
  [[project.maintainers]]
34
- name = "Siddhant Laddha"
35
- email = "25705822+siddhantladdha@users.noreply.github.com"
41
+ name = "Sid L"
42
+ email = "25705822+sidm273@users.noreply.github.com"
36
43
 
37
44
  [project.urls]
38
- bugs = "https://github.com/siddhantladdha/analog_daddy/issues"
39
- changelog = "https://github.com/siddhantladdha/analog_daddy/releases"
40
- documentation = "https://siddhantladdha.github.io/analog_daddy/"
41
- homepage = "https://github.com/siddhantladdha/analog_daddy"
45
+ bugs = "https://github.com/sidm273/analog_daddy/issues"
46
+ changelog = "https://github.com/sidm273/analog_daddy/releases"
47
+ documentation = "https://sidm273.github.io/analog_daddy/"
48
+ homepage = "https://github.com/sidm273/analog_daddy"
42
49
 
43
50
  [project.scripts]
44
51
  analog_daddy = "analog_daddy.cli:app"
45
52
 
53
+ [project.optional-dependencies]
54
+ notebooks = [
55
+ "marimo[lsp,mcp,recommended]",
56
+ "wigglystuff",
57
+ ]
58
+
46
59
  [dependency-groups]
47
- dev = [
48
- "format-docstring",
49
- "hypothesis",
50
- "pytest",
51
- "ruff",
52
- "ty",
60
+ all = [
61
+ "analog-daddy[notebooks]",
62
+ { include-group = "dev" },
53
63
  ]
54
64
  docs = [
55
65
  "mkdocstrings-python",
@@ -57,20 +67,25 @@ docs = [
57
67
  "playwright",
58
68
  "zensical",
59
69
  ]
60
- lint = ["pydoclint"]
61
- notebooks = [
62
- "marimo[lsp,mcp,recommended]",
63
- "wigglystuff",
70
+ lint = [
71
+ "format-docstring",
72
+ "ruff",
73
+ "ty",
74
+ ]
75
+ lint_isolated = ["pydoclint"]
76
+ testing = [
77
+ "hypothesis",
78
+ "pytest >= 9",
64
79
  ]
65
80
 
66
- [[dependency-groups.all]]
67
- include-group = "dev"
68
-
69
- [[dependency-groups.all]]
81
+ [[dependency-groups.dev]]
70
82
  include-group = "docs"
71
83
 
72
- [[dependency-groups.all]]
73
- include-group = "notebooks"
84
+ [[dependency-groups.dev]]
85
+ include-group = "lint"
86
+
87
+ [[dependency-groups.dev]]
88
+ include-group = "testing"
74
89
 
75
90
  [build-system]
76
91
  requires = ["uv_build>=0.13.0,<0.14"]
@@ -94,12 +109,19 @@ check-style-mismatch = true
94
109
  show-filenames-in-every-violation-message = true
95
110
  exclude = '\.git|\.tox|\.venv|build|dist|.*drafts.*\.py'
96
111
 
97
- [tool.pytest.ini_options]
112
+ [tool.pytest]
98
113
  addopts = [
114
+ "--report-chars=A",
99
115
  "--doctest-modules",
100
116
  "--ignore-glob=*drafts*.py",
117
+ "--doctest-report=cdiff",
118
+ ]
119
+ doctest_optionflags = [
120
+ "IGNORE_EXCEPTION_DETAIL",
121
+ "NUMBER",
101
122
  ]
102
- doctest_optionflags = ["IGNORE_EXCEPTION_DETAIL"]
123
+ log_level = "INFO"
124
+ minversion = "9.0"
103
125
  testpaths = [
104
126
  "src",
105
127
  "tests",
@@ -109,6 +131,7 @@ testpaths = [
109
131
  line-length = 79
110
132
  extend-exclude = ["*drafts*.py"]
111
133
  output-prefer-rule-codes = true
134
+ show-fixes = true
112
135
 
113
136
  [tool.ruff.lint]
114
137
  ignore = [
@@ -116,8 +139,19 @@ ignore = [
116
139
  "D401",
117
140
  ]
118
141
  extend-select = [
142
+ "ARG",
143
+ "B",
144
+ "EM",
145
+ "G",
146
+ "ISC",
147
+ "Q",
148
+ "RET",
149
+ "RSE",
150
+ "RUF",
119
151
  "NPY",
152
+ "C4",
120
153
  "N",
154
+ "ICN",
121
155
  "PTH",
122
156
  "SIM",
123
157
  "EXE",
@@ -1,20 +1,27 @@
1
1
  [project]
2
2
  name = "analog-daddy"
3
- version = "3.0.1.dev2"
3
+ version = "3.0.1.dev3"
4
4
  description = "This library is an attempt to make transistor sizing for Analog Design less painful. Additionally, provides helper utilities to minimize churn and errors in repetative tasks."
5
5
  readme = "README.md"
6
6
  requires-python = ">= 3.12"
7
7
  license = "MIT"
8
+ license-files = ["LICENSE"]
8
9
  authors = [
9
- { name = "Siddhant Laddha", email = "25705822+siddhantladdha@users.noreply.github.com" }
10
+ { name = "Sid L", email = "25705822+sidm273@users.noreply.github.com" }
10
11
  ]
11
12
  maintainers = [
12
- { name = "Siddhant Laddha", email = "25705822+siddhantladdha@users.noreply.github.com" }
13
+ { name = "Sid L", email = "25705822+sidm273@users.noreply.github.com" }
13
14
  ]
14
15
  classifiers = [
15
16
  "Development Status :: 4 - Beta",
16
17
  "Intended Audience :: Education",
17
18
  "Intended Audience :: Science/Research",
19
+ "Programming Language :: Python",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
18
25
  "Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)",
19
26
  "Typing :: Typed",
20
27
  ]
@@ -33,26 +40,30 @@ dependencies = [
33
40
  ]
34
41
 
35
42
  [project.urls]
36
- bugs = "https://github.com/siddhantladdha/analog_daddy/issues"
37
- changelog = "https://github.com/siddhantladdha/analog_daddy/releases"
38
- documentation = "https://siddhantladdha.github.io/analog_daddy/"
39
- homepage = "https://github.com/siddhantladdha/analog_daddy"
43
+ bugs = "https://github.com/sidm273/analog_daddy/issues"
44
+ changelog = "https://github.com/sidm273/analog_daddy/releases"
45
+ documentation = "https://sidm273.github.io/analog_daddy/"
46
+ homepage = "https://github.com/sidm273/analog_daddy"
40
47
 
41
48
  [project.scripts]
42
49
  analog_daddy = "analog_daddy.cli:app"
43
50
 
51
+ [project.optional-dependencies]
52
+ notebooks = [
53
+ "marimo[lsp,mcp,recommended]",
54
+ "wigglystuff",
55
+ ]
56
+
44
57
  [dependency-groups]
45
58
  dev = [
46
- "format-docstring",
47
- "hypothesis",
48
- "pytest",
49
- "ruff",
50
- "ty",
59
+ { include-group = "docs" },
60
+ { include-group = "lint" },
61
+ { include-group = "testing" },
51
62
  ]
63
+
52
64
  all = [
65
+ "analog-daddy[notebooks]",
53
66
  { include-group = "dev" },
54
- { include-group = "docs" },
55
- { include-group = "notebooks" },
56
67
  ]
57
68
  docs = [
58
69
  "mkdocstrings-python",
@@ -61,11 +72,14 @@ docs = [
61
72
  "zensical",
62
73
  # TODO: evaluate vs great-docs for marimo notebooks in docs.
63
74
  ]
64
- lint = ["pydoclint"]
65
- notebooks = [
66
- "marimo[lsp,mcp,recommended]",
67
- "wigglystuff",
75
+ lint = [
76
+ "format-docstring",
77
+ "ruff",
78
+ "ty",
68
79
  ]
80
+ # pydoclint has issues with cyclopts.
81
+ lint_isolated = ["pydoclint"]
82
+ testing = ["hypothesis", "pytest >= 9"]
69
83
 
70
84
  [build-system]
71
85
  requires = ["uv_build>=0.13.0,<0.14"]
@@ -90,15 +104,23 @@ check-style-mismatch = true
90
104
  show-filenames-in-every-violation-message = true
91
105
  exclude = '\.git|\.tox|\.venv|build|dist|.*drafts.*\.py'
92
106
 
93
- [tool.pytest.ini_options]
94
- addopts = ["--doctest-modules", "--ignore-glob=*drafts*.py"]
95
- doctest_optionflags = ["IGNORE_EXCEPTION_DETAIL"]
107
+ [tool.pytest]
108
+ addopts = [
109
+ "--report-chars=A",
110
+ "--doctest-modules",
111
+ "--ignore-glob=*drafts*.py",
112
+ "--doctest-report=cdiff",
113
+ ]
114
+ doctest_optionflags = ["IGNORE_EXCEPTION_DETAIL", "NUMBER"]
115
+ log_level = "INFO"
116
+ minversion = "9.0"
96
117
  testpaths = ["src", "tests"]
97
118
 
98
119
  [tool.ruff]
99
120
  line-length = 79
100
121
  extend-exclude = ["*drafts*.py"]
101
122
  output-prefer-rule-codes = true
123
+ show-fixes = true
102
124
 
103
125
  [tool.ruff.lint]
104
126
  ignore = [
@@ -110,9 +132,20 @@ ignore = [
110
132
  "D401", # non-imperative-mood
111
133
  ]
112
134
  extend-select = [
135
+ "ARG", # flake8-unused-arguments
136
+ "B", # flake8-bugbear
137
+ "EM", # flake8-errmsg
138
+ "G", # flake8-logging-format
139
+ "ISC", # flake8-implicit-str-concat
140
+ "Q", # flake8-quotes
141
+ "RET", # flake8-return
142
+ "RSE", # flake8-raise
143
+ "RUF", # Ruff-specific
113
144
  "NPY", # numpy
114
145
  # "D", # docstring # handled by format-docstring and pydoclint
146
+ "C4", # flake8-comprehensions
115
147
  "N", # pep8-naming
148
+ "ICN", # flake8-import-conventions
116
149
  "PTH", # flake8-use-pathlib
117
150
  "SIM", # flake8-simplify
118
151
  "EXE", # flake8-executable
@@ -3,3 +3,5 @@
3
3
  from importlib.metadata import version
4
4
 
5
5
  __version__ = version("analog-daddy")
6
+
7
+ __all__ = ["__version__"]
@@ -1,8 +1,9 @@
1
1
  import polars.selectors as cs
2
2
  from great_tables import GT
3
3
 
4
+ __all__ = ["gt_defaults"]
5
+
4
6
 
5
7
  def gt_defaults(gtbl: GT):
6
8
  """Preferred defaults for rendering great tables."""
7
- gtbl = gtbl.fmt_number_si(columns=cs.numeric()).opt_stylize(style=4)
8
- return gtbl
9
+ return gtbl.fmt_number_si(columns=cs.numeric()).opt_stylize(style=4)
@@ -18,6 +18,12 @@ from wigglystuff import CopyToClipboard
18
18
 
19
19
  from analog_daddy.utils import render
20
20
 
21
+ __all__ = [
22
+ "df_repr_docstr_clip",
23
+ "mo_table",
24
+ "rich_md",
25
+ ]
26
+
21
27
 
22
28
  def format_mapping_num_to_si(df: pl.DataFrame) -> dict[str, Callable]:
23
29
  """
@@ -1,11 +1,13 @@
1
1
  """
2
2
  A collection of polars expressions/idioms.
3
3
 
4
- These expressions have an unstable API and will change over time. Use
5
- them as a template and vendor within your own codebase for stability.
6
- These probably belong in a docs page, but they have earned their place
7
- here due to their widespread use across multiple domains. most of them
8
- are scavenged from Stackoverflow, Discord and github issues.
4
+ These helpers could probably be snippets in a docs page. But they have
5
+ earned their place here due to their utility across different domains.
6
+ Most of these are slight modifications of snippets scavenged across the
7
+ internet (primarily Stackoverflow, Discord and Github) and I have
8
+ attempted to credit the original sources wherever possible. You can use
9
+ them as a template or building blocks for complex data processing
10
+ pipelines.
9
11
  """
10
12
 
11
13
  import re
@@ -29,6 +31,16 @@ _COL_RE = re.compile(
29
31
  re.VERBOSE,
30
32
  )
31
33
 
34
+ __all__ = [
35
+ "all_minmax_by",
36
+ "item_where",
37
+ "ksigma_bounds",
38
+ "list_cast",
39
+ "list_render_unique",
40
+ "minmax",
41
+ "spec",
42
+ ]
43
+
32
44
 
33
45
  def minmax(
34
46
  expr: pl.Expr,
@@ -422,8 +434,9 @@ def spec(
422
434
  operator, *vals = spec.split()
423
435
  try:
424
436
  vals = [_parse_operand(v) for v in vals]
425
- except InvalidNumber:
426
- raise ValueError(f"bad numbers {vals} in spec: {spec}")
437
+ except InvalidNumber as err:
438
+ err_msg = f"bad numbers {vals} in spec: {spec}"
439
+ raise ValueError(err_msg) from err
427
440
 
428
441
  match operator:
429
442
  case ">":
@@ -437,7 +450,8 @@ def spec(
437
450
  val, tol_pct = vals
438
451
  tol_abs = abs(val) * tol_pct / 100
439
452
  return col.is_between(val - tol_abs, val + tol_abs)
440
- raise ValueError(f"bad spec: {spec}")
453
+ err_msg = f"Improperly formatted spec: {spec}"
454
+ raise ValueError(err_msg)
441
455
 
442
456
 
443
457
  def list_cast() -> tuple[pl.Expr, pl.Expr]:
@@ -535,9 +549,8 @@ def list_render_unique(max_len: int = 3) -> pl.Expr:
535
549
  ulist = cs.list(cs.string()).list.unique().list
536
550
  n = ulist.len()
537
551
  head_n = ulist.head(max_len).list
538
- cond = (
552
+ return (
539
553
  pl.when(n > max_len)
540
554
  .then(pl.format("{} + {} more", head_n.join(", "), n - max_len))
541
555
  .otherwise(ulist.join(", "))
542
556
  )
543
- return cond
@@ -1,15 +1,77 @@
1
- """Utilities for working with Polars DataFrames."""
1
+ """
2
+ A collection of polars dataframe level helpers.
3
+
4
+ These helpers could probably be snippets in a docs page. But they have
5
+ earned their place here due to their utility across different domains.
6
+ Most of these are slight modifications of snippets scavenged across the
7
+ internet (primarily Stackoverflow, Discord and Github) and I have
8
+ attempted to credit the original sources wherever possible.
9
+
10
+ Examples are provided to illustrate their composability.
11
+
12
+ Examples
13
+ --------
14
+ >>> (
15
+ ... df := pl.DataFrame(
16
+ ... {
17
+ ... "x": [1, None, 3],
18
+ ... "e": [None, None, None],
19
+ ... "d": [None, None, None],
20
+ ... "y": [4.0, None, 6.0],
21
+ ... }
22
+ ... )
23
+ ... )
24
+ shape: (3, 4)
25
+ ┌──────┬──────┬──────┬──────┐
26
+ │ x ┆ e ┆ d ┆ y │
27
+ │ --- ┆ --- ┆ --- ┆ --- │
28
+ │ i64 ┆ null ┆ null ┆ f64 │
29
+ ╞══════╪══════╪══════╪══════╡
30
+ │ 1 ┆ null ┆ null ┆ 4.0 │
31
+ │ null ┆ null ┆ null ┆ null │
32
+ │ 3 ┆ null ┆ null ┆ 6.0 │
33
+ └──────┴──────┴──────┴──────┘
34
+ >>> (
35
+ ... # firstly we remove empty rows.
36
+ ... df.pipe(filter_all_null)
37
+ ... # then fill the delimiter column with junk to keep it.
38
+ ... .with_columns(pl.lit("|").alias("d"))
39
+ ... # finally drop any empty columns.
40
+ ... .pipe(drop_all_null)
41
+ ... )
42
+ shape: (2, 3)
43
+ ┌─────┬─────┬─────┐
44
+ │ x ┆ d ┆ y │
45
+ │ --- ┆ --- ┆ --- │
46
+ │ i64 ┆ str ┆ f64 │
47
+ ╞═════╪═════╪═════╡
48
+ │ 1 ┆ | ┆ 4.0 │
49
+ │ 3 ┆ | ┆ 6.0 │
50
+ └─────┴─────┴─────┘
51
+ """
2
52
 
3
53
  import re
4
54
 
5
55
  import polars as pl
6
56
  import polars.selectors as cs
7
57
 
58
+ __all__ = [
59
+ "drop_all_null",
60
+ "explode_nested_params",
61
+ "filter_all_null",
62
+ "metrics_to_rows",
63
+ "scan_nested_params",
64
+ ]
65
+
8
66
 
9
67
  def drop_all_null(df: pl.DataFrame) -> pl.DataFrame:
10
68
  """
11
69
  Drop columns where every value is null.
12
70
 
71
+ Notes
72
+ -----
73
+ - Obtained from examples in [drop_nulls](https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.DataFrame.drop_nulls.html#polars-dataframe-drop-nulls)
74
+
13
75
  Parameters
14
76
  ----------
15
77
  df : pl.DataFrame
@@ -60,6 +122,10 @@ def filter_all_null(df: pl.DataFrame) -> pl.DataFrame:
60
122
  """
61
123
  Filter out rows from a dataframe where every value is null.
62
124
 
125
+ Notes
126
+ -----
127
+ - Obtained from examples in [drop_nulls](https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.DataFrame.drop_nulls.html#polars-dataframe-drop-nulls)
128
+
63
129
  Parameters
64
130
  ----------
65
131
  df : pl.DataFrame
@@ -178,7 +244,8 @@ def scan_nested_params(
178
244
  ).item()
179
245
 
180
246
  if not first:
181
- raise ValueError(f"No row found starting with {identify_str}")
247
+ err_msg = f"No row found starting with {identify_str}"
248
+ raise ValueError(err_msg)
182
249
  first = first.replace(" ", "").removeprefix(identify_str)
183
250
  return [
184
251
  pair.split(re.escape(key_split))[0]
@@ -193,8 +260,25 @@ def explode_nested_params(
193
260
  identify_str: str = "Parameters:",
194
261
  ) -> pl.DataFrame:
195
262
  """
196
- Turn inline ``key=value`` parameter rows into columns on the data
197
- rows below them.
263
+ Extract inline parameter values and add them as columns to data
264
+ rows.
265
+
266
+ Parameter rows are identified by ``identify_str`` in ``index_col``
267
+ and contain comma-separated ``key=value`` pairs. Their values are
268
+ propagated to subsequent data rows until another parameter row is
269
+ encountered. The list of keys must be provided and cannot change
270
+ between rows. Use this as a building block for more nested rows with
271
+ dynamic keys.
272
+
273
+ See Also
274
+ --------
275
+ - :func:`scan_nested_params` for a helper to extract the keys if they remain identical within
276
+ a given dataframe.
277
+
278
+ Notes
279
+ -----
280
+ - This is based on the excellent solution provided in the polars
281
+ discord's *general discussion* channel.
198
282
 
199
283
  Parameters
200
284
  ----------
@@ -263,70 +347,9 @@ def explode_nested_params(
263
347
  )
264
348
 
265
349
 
266
- def cleanup(df: pl.DataFrame, delimiter: str) -> pl.DataFrame:
267
- """
268
- A representative demo of simple dataframe cleanup operation
269
- utilizing the helper functions.
270
-
271
- Parameters
272
- ----------
273
- df : pl.DataFrame
274
- DataFrame to clean up.
275
- delimiter : str
276
- Name of the column to keep, even if it is empty.
277
-
278
- Returns
279
- -------
280
- pl.DataFrame
281
- Cleaned DataFrame.
282
-
283
- Examples
284
- --------
285
- >>> (
286
- ... df := pl.DataFrame(
287
- ... {
288
- ... "x": [1, None, 3],
289
- ... "e": [None, None, None],
290
- ... "d": [None, None, None],
291
- ... "y": [4.0, None, 6.0],
292
- ... }
293
- ... )
294
- ... )
295
- shape: (3, 4)
296
- ┌──────┬──────┬──────┬──────┐
297
- │ x ┆ e ┆ d ┆ y │
298
- │ --- ┆ --- ┆ --- ┆ --- │
299
- │ i64 ┆ null ┆ null ┆ f64 │
300
- ╞══════╪══════╪══════╪══════╡
301
- │ 1 ┆ null ┆ null ┆ 4.0 │
302
- │ null ┆ null ┆ null ┆ null │
303
- │ 3 ┆ null ┆ null ┆ 6.0 │
304
- └──────┴──────┴──────┴──────┘
305
- >>> cleanup(df, delimiter="d")
306
- shape: (2, 3)
307
- ┌─────┬─────┬─────┐
308
- │ x ┆ d ┆ y │
309
- │ --- ┆ --- ┆ --- │
310
- │ i64 ┆ str ┆ f64 │
311
- ╞═════╪═════╪═════╡
312
- │ 1 ┆ | ┆ 4.0 │
313
- │ 3 ┆ | ┆ 6.0 │
314
- └─────┴─────┴─────┘
315
- """
316
- return (
317
- # firstly we remove empty rows.
318
- df.pipe(filter_all_null)
319
- # then fill the delimiter column with junk to keep it.
320
- .with_columns(pl.lit("|").alias(delimiter))
321
- # finally drop any empty columns.
322
- .pipe(drop_all_null)
323
- )
324
-
325
-
326
350
  def metrics_to_rows(df: pl.DataFrame, separator="__") -> pl.DataFrame:
327
351
  """
328
- Reshape a DataFrame by unpivoting and pivoting based on a column
329
- name separator being present.
352
+ Reshape wide-format dataframe to a concise summary.
330
353
 
331
354
  Parameters
332
355
  ----------
@@ -35,6 +35,8 @@ import polars as pl
35
35
  import polars.selectors as cs
36
36
  from boltons.iterutils import split
37
37
 
38
+ __all__ = ["map_roles"]
39
+
38
40
 
39
41
  class _CSRoles:
40
42
  """semantic roles of columns in a DataFrame as polars selectors."""
@@ -58,6 +58,18 @@ from quantiphy import Quantity as _Quantity
58
58
 
59
59
  UnitConversion(["ohm", "Ohms", "ohms", "Ω"], "Ohm")
60
60
 
61
+ __all__ = [
62
+ "Capacitance",
63
+ "Current",
64
+ "Frequency",
65
+ "Inductance",
66
+ "Power",
67
+ "Resistance",
68
+ "Temperature",
69
+ "Time",
70
+ "Voltage",
71
+ ]
72
+
61
73
 
62
74
  class Quantity(_Quantity):
63
75
  """
@@ -156,9 +168,10 @@ class Quantity(_Quantity):
156
168
  case "as_tuple":
157
169
  return as_tuple(self)
158
170
  case _:
159
- raise ValueError(
171
+ err_msg = (
160
172
  f"Unknown quantity_format value: {quantity_format}"
161
173
  )
174
+ raise ValueError(err_msg)
162
175
  else:
163
176
  return as_real(self)
164
177
 
@@ -6,6 +6,11 @@ from pathlib import Path
6
6
 
7
7
  from quantiphy import render as _render
8
8
 
9
+ __all__ = [
10
+ "render",
11
+ "scan_contents",
12
+ ]
13
+
9
14
 
10
15
  def scan_contents(
11
16
  contents: bytes | str | Path,
@@ -66,7 +71,8 @@ def scan_contents(
66
71
  with contents.open() as lines:
67
72
  yield from search(lines)
68
73
  else:
69
- raise TypeError(f"Unsupported type: {type(contents)}")
74
+ err_msg = f"Unsupported type: {type(contents)}"
75
+ raise TypeError(err_msg)
70
76
  # TODO: Runtime check needed?
71
77
 
72
78
 
@@ -103,5 +109,4 @@ def render(value: float | None, units: str = "") -> str:
103
109
  """ # noqa: DOC105
104
110
  if value is None:
105
111
  return ""
106
- else:
107
- return _render(value, units=units)
112
+ return _render(value, units=units)
@@ -1,36 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: analog-daddy
3
- Version: 3.0.1.dev2
4
- Summary: This library is an attempt to make transistor sizing for Analog Design less painful. Additionally, provides helper utilities to minimize churn and errors in repetative tasks.
5
- Author: Siddhant Laddha
6
- Author-email: Siddhant Laddha <25705822+siddhantladdha@users.noreply.github.com>
7
- License-Expression: MIT
8
- Classifier: Development Status :: 4 - Beta
9
- Classifier: Intended Audience :: Education
10
- Classifier: Intended Audience :: Science/Research
11
- Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
12
- Classifier: Typing :: Typed
13
- Requires-Dist: boltons
14
- Requires-Dist: cyclopts ; sys_platform != 'emscripten'
15
- Requires-Dist: great-tables
16
- Requires-Dist: plotly
17
- Requires-Dist: polars
18
- Requires-Dist: pydantic>=2
19
- Requires-Dist: pydantic-settings
20
- Requires-Dist: quantiphy
21
- Requires-Dist: rich
22
- Requires-Dist: scipy
23
- Requires-Dist: xarray
24
- Maintainer: Siddhant Laddha
25
- Maintainer-email: Siddhant Laddha <25705822+siddhantladdha@users.noreply.github.com>
26
- Requires-Python: >=3.12
27
- Project-URL: bugs, https://github.com/siddhantladdha/analog_daddy/issues
28
- Project-URL: changelog, https://github.com/siddhantladdha/analog_daddy/releases
29
- Project-URL: documentation, https://siddhantladdha.github.io/analog_daddy/
30
- Project-URL: homepage, https://github.com/siddhantladdha/analog_daddy
31
- Description-Content-Type: text/markdown
32
-
33
- # Analog Daddy
34
-
35
- This is a dummy README for the dev version. Please refer
36
- [main](https://github.com/siddhantladdha/analog-daddy)
@@ -1,4 +0,0 @@
1
- # Analog Daddy
2
-
3
- This is a dummy README for the dev version. Please refer
4
- [main](https://github.com/siddhantladdha/analog-daddy)