paramrf 0.22.0__tar.gz → 0.23.2__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 (152) hide show
  1. {paramrf-0.22.0/paramrf.egg-info → paramrf-0.23.2}/PKG-INFO +1 -1
  2. {paramrf-0.22.0 → paramrf-0.23.2}/docs/api/index.rst +1 -1
  3. {paramrf-0.22.0 → paramrf-0.23.2}/docs/examples/parameter_and_model_manipulation.rst +3 -3
  4. {paramrf-0.22.0 → paramrf-0.23.2}/paper/paper.md +2 -2
  5. {paramrf-0.22.0 → paramrf-0.23.2/paramrf.egg-info}/PKG-INFO +1 -1
  6. {paramrf-0.22.0 → paramrf-0.23.2}/paramrf.egg-info/SOURCES.txt +6 -2
  7. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/__init__.py +3 -3
  8. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/infer/base.py +4 -2
  9. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/__init__.py +45 -11
  10. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/base.py +38 -40
  11. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/components/__init__.py +2 -2
  12. paramrf-0.23.2/pmrf/models/components/ideal.py +314 -0
  13. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/components/lines/uniform.py +42 -4
  14. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/components/lumped.py +131 -97
  15. paramrf-0.23.2/pmrf/models/components/sections.py +354 -0
  16. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/composite/__init__.py +2 -0
  17. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/composite/interconnected.py +140 -16
  18. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/composite/nodal.py +6 -5
  19. paramrf-0.23.2/pmrf/models/composite/topological.py +150 -0
  20. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/optimize/base.py +8 -3
  21. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/parameters.py +4 -4
  22. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/rf/__init__.py +4 -2
  23. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/rf/cascades.py +7 -30
  24. paramrf-0.23.2/pmrf/rf/connections/__init__.py +3 -0
  25. paramrf-0.22.0/pmrf/rf/connections.py → paramrf-0.23.2/pmrf/rf/connections/s_arbitrary.py +54 -119
  26. paramrf-0.23.2/pmrf/rf/connections/s_common.py +111 -0
  27. paramrf-0.23.2/pmrf/rf/connections/y_arbitrary.py +127 -0
  28. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/rf/terminations.py +12 -1
  29. {paramrf-0.22.0 → paramrf-0.23.2}/pyproject.toml +1 -1
  30. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_models/test_topological.py +7 -7
  31. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_naming.py +1 -1
  32. paramrf-0.22.0/pmrf/models/components/ideal.py +0 -61
  33. paramrf-0.22.0/pmrf/models/components/topological.py +0 -362
  34. {paramrf-0.22.0 → paramrf-0.23.2}/.github/workflows/docs.yml +0 -0
  35. {paramrf-0.22.0 → paramrf-0.23.2}/.github/workflows/draft-pdf.yml +0 -0
  36. {paramrf-0.22.0 → paramrf-0.23.2}/.github/workflows/publish.yml +0 -0
  37. {paramrf-0.22.0 → paramrf-0.23.2}/.github/workflows/tests.yml +0 -0
  38. {paramrf-0.22.0 → paramrf-0.23.2}/.gitignore +0 -0
  39. {paramrf-0.22.0 → paramrf-0.23.2}/CONTRIBUTING.md +0 -0
  40. {paramrf-0.22.0 → paramrf-0.23.2}/LICENSE +0 -0
  41. {paramrf-0.22.0 → paramrf-0.23.2}/README.rst +0 -0
  42. {paramrf-0.22.0 → paramrf-0.23.2}/assets/logo.png +0 -0
  43. {paramrf-0.22.0 → paramrf-0.23.2}/docs/Makefile +0 -0
  44. {paramrf-0.22.0 → paramrf-0.23.2}/docs/_static/custom.css +0 -0
  45. {paramrf-0.22.0 → paramrf-0.23.2}/docs/_templates/autosummary/class.rst +0 -0
  46. {paramrf-0.22.0 → paramrf-0.23.2}/docs/_templates/autosummary/function.rst +0 -0
  47. {paramrf-0.22.0 → paramrf-0.23.2}/docs/_templates/autosummary/module.rst +0 -0
  48. {paramrf-0.22.0 → paramrf-0.23.2}/docs/api/models.rst +0 -0
  49. {paramrf-0.22.0 → paramrf-0.23.2}/docs/conf.py +0 -0
  50. {paramrf-0.22.0 → paramrf-0.23.2}/docs/core_concepts/core_primitives.rst +0 -0
  51. {paramrf-0.22.0 → paramrf-0.23.2}/docs/core_concepts/index.rst +0 -0
  52. {paramrf-0.22.0 → paramrf-0.23.2}/docs/core_concepts/jax_overview.rst +0 -0
  53. {paramrf-0.22.0 → paramrf-0.23.2}/docs/core_concepts/optimization_and_inference.rst +0 -0
  54. {paramrf-0.22.0 → paramrf-0.23.2}/docs/examples/auto_differentiation.rst +0 -0
  55. {paramrf-0.22.0 → paramrf-0.23.2}/docs/examples/cascading_and_terminating.rst +0 -0
  56. {paramrf-0.22.0 → paramrf-0.23.2}/docs/examples/circuit_clc.png +0 -0
  57. {paramrf-0.22.0 → paramrf-0.23.2}/docs/examples/circuit_models.rst +0 -0
  58. {paramrf-0.22.0 → paramrf-0.23.2}/docs/examples/custom_composite_models.rst +0 -0
  59. {paramrf-0.22.0 → paramrf-0.23.2}/docs/examples/custom_parametric_models.rst +0 -0
  60. {paramrf-0.22.0 → paramrf-0.23.2}/docs/examples/index.rst +0 -0
  61. {paramrf-0.22.0 → paramrf-0.23.2}/docs/examples/model_optimization.rst +0 -0
  62. {paramrf-0.22.0 → paramrf-0.23.2}/docs/index.rst +0 -0
  63. {paramrf-0.22.0 → paramrf-0.23.2}/docs/license.rst +0 -0
  64. {paramrf-0.22.0 → paramrf-0.23.2}/docs/make.bat +0 -0
  65. {paramrf-0.22.0 → paramrf-0.23.2}/docs/skrf_comparison.rst +0 -0
  66. {paramrf-0.22.0 → paramrf-0.23.2}/docs/tutorials/1_cable_fitting.ipynb +0 -0
  67. {paramrf-0.22.0 → paramrf-0.23.2}/docs/tutorials/data/CBN-1.5FT-SMSM.s2p +0 -0
  68. {paramrf-0.22.0 → paramrf-0.23.2}/docs/tutorials/index.rst +0 -0
  69. {paramrf-0.22.0 → paramrf-0.23.2}/paper/paper.bib +0 -0
  70. {paramrf-0.22.0 → paramrf-0.23.2}/paper/rlc.png +0 -0
  71. {paramrf-0.22.0 → paramrf-0.23.2}/paramrf.egg-info/dependency_links.txt +0 -0
  72. {paramrf-0.22.0 → paramrf-0.23.2}/paramrf.egg-info/requires.txt +0 -0
  73. {paramrf-0.22.0 → paramrf-0.23.2}/paramrf.egg-info/top_level.txt +0 -0
  74. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/constraints.py +0 -0
  75. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/covariance_kernels.py +0 -0
  76. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/discrepancy_models.py +0 -0
  77. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/distributions.py +0 -0
  78. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/evaluators.py +0 -0
  79. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/fitting/__init__.py +0 -0
  80. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/fitting/minimize.py +0 -0
  81. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/fitting/result.py +0 -0
  82. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/fitting/routers.py +0 -0
  83. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/fitting/sample.py +0 -0
  84. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/frequency.py +0 -0
  85. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/infer/__init__.py +0 -0
  86. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/infer/backends/__init__.py +0 -0
  87. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/infer/backends/blackjax.py +0 -0
  88. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/infer/backends/polychord.py +0 -0
  89. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/infer/result.py +0 -0
  90. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/infer/sample.py +0 -0
  91. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/likelihoods.py +0 -0
  92. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/losses.py +0 -0
  93. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/math/__init__.py +0 -0
  94. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/math/aggregations.py +0 -0
  95. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/math/conversions.py +0 -0
  96. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/math/losses.py +0 -0
  97. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/math/misc.py +0 -0
  98. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/adapters/__init__.py +0 -0
  99. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/adapters/base.py +0 -0
  100. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/adapters/bridge.py +0 -0
  101. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/adapters/callable.py +0 -0
  102. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/adapters/static.py +0 -0
  103. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/components/lines/__init__.py +0 -0
  104. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/components/lines/nonuniform.py +0 -0
  105. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/composite/transformed.py +0 -0
  106. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/composite/wrapped.py +0 -0
  107. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/surrogates/__init__.py +0 -0
  108. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/surrogates/expansion.py +0 -0
  109. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/models/surrogates/rational.py +0 -0
  110. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/network_collection.py +0 -0
  111. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/noise_models.py +0 -0
  112. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/optimize/__init__.py +0 -0
  113. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/optimize/backends/__init__.py +0 -0
  114. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/optimize/backends/jaxopt.py +0 -0
  115. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/optimize/backends/optimistix.py +0 -0
  116. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/optimize/backends/scipy.py +0 -0
  117. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/optimize/minimize.py +0 -0
  118. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/optimize/result.py +0 -0
  119. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/problem.py +0 -0
  120. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/rf/conversions.py +0 -0
  121. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/serialization.py +0 -0
  122. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/solve/__init__.py +0 -0
  123. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/utils/__init__.py +0 -0
  124. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/utils/array.py +0 -0
  125. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/utils/network.py +0 -0
  126. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/utils/optix.py +0 -0
  127. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/utils/random.py +0 -0
  128. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/utils/rf.py +0 -0
  129. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/utils/tree.py +0 -0
  130. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/utils/type.py +0 -0
  131. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/viz/__init__.py +0 -0
  132. {paramrf-0.22.0 → paramrf-0.23.2}/pmrf/viz/plots.py +0 -0
  133. {paramrf-0.22.0 → paramrf-0.23.2}/setup.cfg +0 -0
  134. {paramrf-0.22.0 → paramrf-0.23.2}/tests/__init__.py +0 -0
  135. {paramrf-0.22.0 → paramrf-0.23.2}/tests/data/10m_cable.s2p +0 -0
  136. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_autodiff.py +0 -0
  137. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_evaluators.py +0 -0
  138. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_fitting_minimize.py +0 -0
  139. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_fitting_routers.py +0 -0
  140. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_fitting_sample.py +0 -0
  141. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_frequency.py +0 -0
  142. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_infer_base.py +0 -0
  143. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_infer_sample.py +0 -0
  144. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_model.py +0 -0
  145. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_models/test_adapters.py +0 -0
  146. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_models/test_interconnected.py +0 -0
  147. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_models/test_lines.py +0 -0
  148. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_models/test_lumped.py +0 -0
  149. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_models/test_nodal.py +0 -0
  150. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_models/test_transformed.py +0 -0
  151. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_optimize_base.py +0 -0
  152. {paramrf-0.22.0 → paramrf-0.23.2}/tests/test_optimize_minimize.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: paramrf
3
- Version: 0.22.0
3
+ Version: 0.23.2
4
4
  Summary: Parametric radio frequency modeling
5
5
  Author-email: Gary Allen <gvcallen@gmail.com>
6
6
  Project-URL: homepage, https://github.com/gvcallen/paramrf
@@ -11,7 +11,7 @@ Core Primitives
11
11
 
12
12
  pmrf.Model
13
13
  pmrf.Frequency
14
- pmrf.Value
14
+ pmrf.Variable
15
15
  pmrf.Param
16
16
  pmrf.Fixed
17
17
  pmrf.Bounded
@@ -19,8 +19,8 @@ Let's first define a custom RLC composite model to manipulate:
19
19
 
20
20
  class RLC(prf.Model):
21
21
  res: Resistor = Resistor(R=100.0)
22
- ind: Inductor = Inductor(L=prf.Value(2.0, scale=1e-9))
23
- cap: Capacitor = Capacitor(C=prf.Value(1.0, scale=1e-12))
22
+ ind: Inductor = Inductor(L=prf.Variable(2.0, scale=1e-9))
23
+ cap: Capacitor = Capacitor(C=prf.Variable(1.0, scale=1e-12))
24
24
 
25
25
  def build(self) -> prf.Model:
26
26
  return self.res ** self.ind ** self.cap
@@ -48,7 +48,7 @@ Using :meth:`pmrf.Model.at`, we can traverse down the model tree to focus on spe
48
48
 
49
49
  .. code-block:: python
50
50
 
51
- rlc_R200 = rlc.at(lambda m: m.res.R).set(prf.Value(200.0))
51
+ rlc_R200 = rlc.at(lambda m: m.res.R).set(prf.Variable(200.0))
52
52
  rlc_fixed = rlc.at(lambda m: m.cap.C).set(prf.Fixed(rlc.cap.C))
53
53
 
54
54
  Since a model's structure is not rigid, we can also completely swap out components:
@@ -58,8 +58,8 @@ import pmrf as prf
58
58
  from pmrf.models import Resistor, Inductor, Capacitor
59
59
 
60
60
  res = Resistor(50)
61
- ind = Inductor(prf.Value(1.0, scale=1e-9))
62
- cap = Capacitor(prf.Value(1.0, scale=1e-12))
61
+ ind = Inductor(prf.Variable(1.0, scale=1e-9))
62
+ cap = Capacitor(prf.Variable(1.0, scale=1e-12))
63
63
  model = res ** ind ** cap
64
64
 
65
65
  goal = prf.evaluators.Goal('s11_db', '<', -20)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: paramrf
3
- Version: 0.22.0
3
+ Version: 0.23.2
4
4
  Summary: Parametric radio frequency modeling
5
5
  Author-email: Gary Allen <gvcallen@gmail.com>
6
6
  Project-URL: homepage, https://github.com/gvcallen/paramrf
@@ -85,13 +85,14 @@ pmrf/models/adapters/static.py
85
85
  pmrf/models/components/__init__.py
86
86
  pmrf/models/components/ideal.py
87
87
  pmrf/models/components/lumped.py
88
- pmrf/models/components/topological.py
88
+ pmrf/models/components/sections.py
89
89
  pmrf/models/components/lines/__init__.py
90
90
  pmrf/models/components/lines/nonuniform.py
91
91
  pmrf/models/components/lines/uniform.py
92
92
  pmrf/models/composite/__init__.py
93
93
  pmrf/models/composite/interconnected.py
94
94
  pmrf/models/composite/nodal.py
95
+ pmrf/models/composite/topological.py
95
96
  pmrf/models/composite/transformed.py
96
97
  pmrf/models/composite/wrapped.py
97
98
  pmrf/models/surrogates/__init__.py
@@ -107,9 +108,12 @@ pmrf/optimize/backends/optimistix.py
107
108
  pmrf/optimize/backends/scipy.py
108
109
  pmrf/rf/__init__.py
109
110
  pmrf/rf/cascades.py
110
- pmrf/rf/connections.py
111
111
  pmrf/rf/conversions.py
112
112
  pmrf/rf/terminations.py
113
+ pmrf/rf/connections/__init__.py
114
+ pmrf/rf/connections/s_arbitrary.py
115
+ pmrf/rf/connections/s_common.py
116
+ pmrf/rf/connections/y_arbitrary.py
113
117
  pmrf/solve/__init__.py
114
118
  pmrf/utils/__init__.py
115
119
  pmrf/utils/array.py
@@ -30,12 +30,12 @@ from pmrf.frequency import Frequency as Frequency
30
30
 
31
31
  #: The canonical type hint for a parameter in a model.
32
32
  #: Parameters should be created using factories in :mod:`pmrf.parameters`,
33
- #: most of which are re-exported at root (e.g. :func:`pmrf.Value`, :func:`pmrf.Fixed`, :func:`pmrf.Bounded`).
33
+ #: most of which are re-exported at root (e.g. :func:`pmrf.Variable`, :func:`pmrf.Fixed`, :func:`pmrf.Bounded`).
34
34
  Param: TypeAlias = parax.AbstractVariable | Inexact[Array, "..."]
35
35
  from pmrf.parameters import (
36
36
  param as param,
37
37
  as_param as as_param,
38
- Value as Value,
38
+ Variable as Variable,
39
39
  Fixed as Fixed,
40
40
  Bounded as Bounded,
41
41
  Constrained as Constrained,
@@ -92,7 +92,7 @@ __all__ = [
92
92
  "Param",
93
93
  "param",
94
94
  "as_param",
95
- "Value",
95
+ "Variable",
96
96
  "Fixed",
97
97
  "Bounded",
98
98
  "Constrained",
@@ -5,6 +5,7 @@ Base inference functions and classes.
5
5
  from typing import Callable, Any, Optional, TypeVar, TypeAlias
6
6
  import abc
7
7
 
8
+ import numpy as np
8
9
  import jax.numpy as jnp
9
10
  import jax
10
11
  from jaxtyping import Array, PyTree, Scalar
@@ -237,12 +238,13 @@ def sample(
237
238
  A tuple of `(batched_model, payload, metrics)`.
238
239
  """
239
240
  # Filtering/unwrapping
240
- is_dynamic, is_leaf = prx.probability.is_dynamic, prx.probability.is_leaf
241
+ is_dynamic = lambda x: prx.probability.is_dynamic(x) and not isinstance(x, np.ndarray)
242
+ is_leaf = prx.probability.is_leaf
241
243
  dynamic, static = eqx.partition(model, is_dynamic, is_leaf=is_leaf)
242
244
  params = prx.unwrap(dynamic, only_if=prx.is_probabilistic)
243
245
 
244
246
  try:
245
- eqx.combine(params, static)
247
+ eqx.combine(params, static, is_leaf=is_leaf)
246
248
  except Exception as e:
247
249
  raise Exception(f"Error re-combining params and static. Error: {e}")
248
250
 
@@ -10,12 +10,17 @@ from pmrf.models.base import (
10
10
  validate as validate,
11
11
  )
12
12
 
13
+ # Adapters
13
14
  from pmrf.models.adapters.base import (
14
15
  AbstractDiscrete as AbstractDiscrete,
15
16
  AbstractSingleProperty as AbstractSingleProperty,
16
17
  AbstractSingleDiscreteProperty as AbstractSingleDiscreteProperty,
17
18
  )
18
- from pmrf.models.adapters.bridge import Host as Host
19
+
20
+ from pmrf.models.adapters.bridge import (
21
+ Host as Host
22
+ )
23
+
19
24
  from pmrf.models.adapters.static import (
20
25
  Measured as Measured,
21
26
  SModel as SModel,
@@ -23,16 +28,28 @@ from pmrf.models.adapters.static import (
23
28
  YModel as YModel,
24
29
  ZModel as ZModel,
25
30
  )
31
+
26
32
  from pmrf.models.adapters.callable import (
27
33
  ContinuousCallable as ContinuousCallable,
28
34
  DiscreteCallable as DiscreteCallable,
29
35
  )
36
+
37
+ # Components
30
38
  from pmrf.models.components.ideal import (
39
+ Load as Load,
40
+ Short as Short,
41
+ Open as Open,
42
+ Match as Match,
31
43
  Port as Port,
32
44
  Ground as Ground,
33
45
  SourceConverter as SourceConverter,
34
46
  Transformer as Transformer,
47
+ Splitter as Splitter,
48
+ Tee as Tee,
49
+ Attenuator as Attenuator,
50
+ DirectionalCoupler as DirectionalCoupler,
35
51
  )
52
+
36
53
  from pmrf.models.components.lines import (
37
54
  TransmissionLine as TransmissionLine,
38
55
  FloatingLine as FloatingLine,
@@ -44,8 +61,8 @@ from pmrf.models.components.lines import (
44
61
  CoaxialLine as CoaxialLine,
45
62
  MicrostripLine as MicrostripLine,
46
63
  )
64
+
47
65
  from pmrf.models.components.lumped import (
48
- Load as Load,
49
66
  Resistor as Resistor,
50
67
  Capacitor as Capacitor,
51
68
  Inductor as Inductor,
@@ -54,21 +71,26 @@ from pmrf.models.components.lumped import (
54
71
  ShuntInductor as ShuntInductor,
55
72
  CapacitorQ as CapacitorQ,
56
73
  InductorQ as InductorQ,
57
- Short as Short,
58
- Open as Open,
59
- Match as Match,
60
74
  )
61
- from pmrf.models.components.topological import (
62
- PiCLC as PiCLC,
63
- BoxCLCC as BoxCLCC,
64
- TeeLCL as TeeLCL,
75
+
76
+ from pmrf.models.components.sections import (
77
+ PiSection as PiSection,
78
+ TSection as TSection,
79
+ LSection as LSection,
80
+ BoxSection as BoxSection,
81
+ PiSectionCLC as PiSectionCLC,
82
+ BoxSectionCLCC as BoxSectionCLCC,
83
+ TSectionLCL as TSectionLCL,
65
84
  LSectionLC as LSectionLC,
66
85
  )
86
+
87
+ # Composite
67
88
  from pmrf.models.composite.interconnected import (
68
89
  Circuit as Circuit,
69
90
  Cascade as Cascade,
70
91
  Terminated as Terminated,
71
92
  )
93
+
72
94
  from pmrf.models.composite.transformed import (
73
95
  Renumbered as Renumbered,
74
96
  Flipped as Flipped,
@@ -76,24 +98,36 @@ from pmrf.models.composite.transformed import (
76
98
  )
77
99
 
78
100
  from pmrf.models.composite.nodal import (
101
+ Shunt as Shunt,
79
102
  GroundLifted as GroundLifted,
80
103
  GroundExposed as GroundExposed,
81
- Shunt as Shunt,
82
104
  CoupledOnePorts as CoupledOnePorts,
83
105
  CoupledTwoPorts as CoupledTwoPorts,
84
106
  )
107
+
108
+ from pmrf.models.composite.topological import (
109
+ PiTopology as PiTopology,
110
+ TTopology as TTopology,
111
+ LTopology as LTopology,
112
+ )
113
+
85
114
  from pmrf.models.composite.wrapped import (
86
115
  Tied as Tied,
87
116
  Probabilistic as Probabilistic,
88
117
  )
89
118
 
90
- from pmrf.models.surrogates.expansion import VectorExpansion as VectorExpansion
119
+ # Surrogates
120
+ from pmrf.models.surrogates.expansion import (
121
+ VectorExpansion as VectorExpansion
122
+ )
123
+
91
124
  from pmrf.models.surrogates.rational import (
92
125
  PolynomialRatio as PolynomialRatio,
93
126
  PoleResidue as PoleResidue,
94
127
  StateSpace as StateSpace,
95
128
  BarycentricRational as BarycentricRational,
96
129
  )
130
+
97
131
  from pmrf.models import adapters, components, composite, surrogates
98
132
 
99
133
  __all__ = [
@@ -582,40 +582,40 @@ class Model(eqx.Module):
582
582
 
583
583
  # ---- Magic methods and copying --------------------------------------------------
584
584
 
585
- # def __repr__(self) -> str:
586
- # """String representation of the Model."""
587
- # import numpy as np
588
- # import jax
589
-
590
- # class _RawFormatter:
591
- # """Wrapper to print arrays cleanly with rounded float values."""
592
- # def __init__(self, val):
593
- # self.val = np.asarray(val)
585
+ def __repr__(self) -> str:
586
+ """String representation of the Model."""
587
+ import numpy as np
588
+ import jax
589
+
590
+ class _RawFormatter:
591
+ """Wrapper to print arrays cleanly with rounded float values."""
592
+ def __init__(self, val):
593
+ self.val = np.asarray(val)
594
594
 
595
- # def __repr__(self):
596
- # # precision=4 limits decimal places
597
- # # suppress_small=True formats numbers very close to zero as 0
598
- # return np.array2string(
599
- # self.val,
600
- # separator=', ',
601
- # precision=4,
602
- # )
603
-
604
- # # Unwrap the model to resolve variables
605
- # unwrapped = unwrap(self)
595
+ def __repr__(self):
596
+ # precision=4 limits decimal places
597
+ # suppress_small=True formats numbers very close to zero as 0
598
+ return np.array2string(
599
+ self.val,
600
+ separator=', ',
601
+ precision=4,
602
+ )
603
+
604
+ # Unwrap the model to resolve variables
605
+ unwrapped = unwrap(self)
606
606
 
607
- # # Identify JAX arrays
608
- # is_array = lambda x: isinstance(x, (jax.Array, jnp.ndarray))
607
+ # Identify JAX arrays
608
+ is_array = lambda x: isinstance(x, (jax.Array, jnp.ndarray))
609
609
 
610
- # # Replace JAX arrays with our custom formatter
611
- # unwrapped_clean = jax.tree_util.tree_map(
612
- # lambda x: _RawFormatter(x) if is_array(x) else x,
613
- # unwrapped,
614
- # is_leaf=is_array
615
- # )
610
+ # Replace JAX arrays with our custom formatter
611
+ unwrapped_clean = jax.tree_util.tree_map(
612
+ lambda x: _RawFormatter(x) if is_array(x) else x,
613
+ unwrapped,
614
+ is_leaf=is_array
615
+ )
616
616
 
617
- # # Use Equinox's formatter, displaying full internal arrays instead of generic shape labels
618
- # return eqx.tree_pformat(unwrapped_clean, short_arrays=False)
617
+ # Use Equinox's formatter, displaying full internal arrays instead of generic shape labels
618
+ return eqx.tree_pformat(unwrapped_clean, short_arrays=False)
619
619
 
620
620
  def __str__(self) -> str:
621
621
  return repr(self)
@@ -904,26 +904,24 @@ def validate(tree):
904
904
 
905
905
  for node in nodes:
906
906
  if isinstance(node, Model):
907
- # Inspect the dataclass fields of our custom RF models
908
907
  for f in dataclasses.fields(node):
909
908
  val = getattr(node, f.name)
910
909
 
911
- # Check for the silent corruption hazard
912
- is_array = isinstance(val, (jnp.ndarray, np.ndarray))
910
+ is_array = isinstance(val, jnp.ndarray)
913
911
  is_static = f.metadata.get("static", False)
914
912
 
915
913
  if is_array and not is_static and jnp.issubdtype(val.dtype, jnp.inexact):
916
914
  raise TypeError(
917
- f"Field '{f.name}' in '{node.__class__.__name__}' is a raw JAX/NumPy array, "
918
- f"which can be updated during optimization/inference.\n\n"
915
+ f"Field '{f.name}' in '{node.__class__.__name__}' is a raw JAX array, "
916
+ f"meaning it is unclear whether this is a free or fixed parameter.\n\n"
919
917
  f"To make your intention clear, you must either:\n"
920
- f" 1. Use the `pmrf.param` specifier (or a factory in `pmrf.parameters`) to indicate the value is a parameter\n"
921
- f" 2. Explicitly mark the field as frozen using `{f.name}: jnp.ndarray = prf.field(converter=prf.freeze)` "
922
- f"and then unwrap the frozen field when you need it using `prf.unwrap`."
918
+ f" 1. Use a factory in `pmrf.parameters` (e.g. `prf.Variable`) for free variables, or a numpy array for fixed variables\n"
919
+ f" 2. Use a field specifier in the model class definition, e.g. `{f.name}: prf.Param = prf.param()` for automatic parameter conversion, "
920
+ f"or `{f.name}: jnp.ndarray = prf.field(converter=prf.freeze)` combined with `prf.unwrap` to ensure the variable is not optimized.\n"
921
+ f"This restriction is enforced to allow compatibility with machine learning models from othe libraries."
923
922
  )
924
923
 
925
- # Manually recurse into the field's value to catch nested Models,
926
- # lists of Models, dicts of Models, etc.
924
+ # Recurse into submodels
927
925
  validate(val)
928
926
 
929
927
 
@@ -5,11 +5,11 @@ This module provides all the built-in components and circuit elements for buildi
5
5
  This includes lumped elements, transmission lines, topological sub-circuits, and more.
6
6
  """
7
7
 
8
- from pmrf.models.components import ideal, lines, lumped, topological
8
+ from pmrf.models.components import ideal, lines, lumped, sections
9
9
 
10
10
  __all__ = [
11
11
  "ideal",
12
12
  "lines",
13
13
  "lumped",
14
- "topological",
14
+ "sections",
15
15
  ]