You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix portless sub-netlists and internal-port handling (#97)
* Fix portless sub-netlists and internal-port handling (#95, #96)
- Filter out sub-netlists with no ports in circuit() to prevent errors
during construction of hierarchical netlists.
- Change default behavior for ports on internal connection nodes: drop
them instead of auto-converting to probes. Add on_internal_port flag
to circuit() with modes "warn" (default), "ignore", and "as_probes".
- Update and add tests for both fixes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* update docs
* fix notebooks
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: nbs/examples/14_probes.ipynb
+27-37Lines changed: 27 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -46,19 +46,9 @@
46
46
"import sax"
47
47
]
48
48
},
49
-
{
50
-
"cell_type": "code",
51
-
"execution_count": null,
52
-
"id": "4",
53
-
"metadata": {},
54
-
"outputs": [],
55
-
"source": [
56
-
"sax.__file__"
57
-
]
58
-
},
59
49
{
60
50
"cell_type": "markdown",
61
-
"id": "5",
51
+
"id": "4",
62
52
"metadata": {},
63
53
"source": [
64
54
"## Define Component Models\n",
@@ -69,7 +59,7 @@
69
59
{
70
60
"cell_type": "code",
71
61
"execution_count": null,
72
-
"id": "6",
62
+
"id": "5",
73
63
"metadata": {},
74
64
"outputs": [],
75
65
"source": [
@@ -101,7 +91,7 @@
101
91
},
102
92
{
103
93
"cell_type": "markdown",
104
-
"id": "7",
94
+
"id": "6",
105
95
"metadata": {},
106
96
"source": [
107
97
"## MZI Circuit\n",
@@ -121,7 +111,7 @@
121
111
{
122
112
"cell_type": "code",
123
113
"execution_count": null,
124
-
"id": "8",
114
+
"id": "7",
125
115
"metadata": {},
126
116
"outputs": [],
127
117
"source": [
@@ -154,7 +144,7 @@
154
144
},
155
145
{
156
146
"cell_type": "markdown",
157
-
"id": "9",
147
+
"id": "8",
158
148
"metadata": {},
159
149
"source": [
160
150
"## Adding Probes\n",
@@ -167,7 +157,7 @@
167
157
{
168
158
"cell_type": "code",
169
159
"execution_count": null,
170
-
"id": "10",
160
+
"id": "9",
171
161
"metadata": {},
172
162
"outputs": [],
173
163
"source": [
@@ -183,7 +173,7 @@
183
173
},
184
174
{
185
175
"cell_type": "markdown",
186
-
"id": "11",
176
+
"id": "10",
187
177
"metadata": {},
188
178
"source": [
189
179
"The circuit now has additional ports for each probe. Each probe creates two ports:\n",
@@ -194,7 +184,7 @@
194
184
{
195
185
"cell_type": "code",
196
186
"execution_count": null,
197
-
"id": "12",
187
+
"id": "11",
198
188
"metadata": {},
199
189
"outputs": [],
200
190
"source": [
@@ -205,7 +195,7 @@
205
195
},
206
196
{
207
197
"cell_type": "markdown",
208
-
"id": "13",
198
+
"id": "12",
209
199
"metadata": {},
210
200
"source": [
211
201
"## Simulating with Probes\n",
@@ -216,7 +206,7 @@
216
206
{
217
207
"cell_type": "code",
218
208
"execution_count": null,
219
-
"id": "14",
209
+
"id": "13",
220
210
"metadata": {},
221
211
"outputs": [],
222
212
"source": [
@@ -231,7 +221,7 @@
231
221
},
232
222
{
233
223
"cell_type": "markdown",
234
-
"id": "15",
224
+
"id": "14",
235
225
"metadata": {},
236
226
"source": [
237
227
"### Output Transmission\n",
@@ -242,7 +232,7 @@
242
232
{
243
233
"cell_type": "code",
244
234
"execution_count": null,
245
-
"id": "16",
235
+
"id": "15",
246
236
"metadata": {},
247
237
"outputs": [],
248
238
"source": [
@@ -260,7 +250,7 @@
260
250
},
261
251
{
262
252
"cell_type": "markdown",
263
-
"id": "17",
253
+
"id": "16",
264
254
"metadata": {},
265
255
"source": [
266
256
"### Signal at Probe Points\n",
@@ -271,7 +261,7 @@
271
261
{
272
262
"cell_type": "code",
273
263
"execution_count": null,
274
-
"id": "18",
264
+
"id": "17",
275
265
"metadata": {},
276
266
"outputs": [],
277
267
"source": [
@@ -289,15 +279,15 @@
289
279
},
290
280
{
291
281
"cell_type": "markdown",
292
-
"id": "19",
282
+
"id": "18",
293
283
"metadata": {},
294
284
"source": [
295
285
"As expected with a 50/50 coupler, the signal is split equally between the two arms.\n"
296
286
]
297
287
},
298
288
{
299
289
"cell_type": "markdown",
300
-
"id": "20",
290
+
"id": "19",
301
291
"metadata": {},
302
292
"source": [
303
293
"## Probes Don't Affect Circuit Behavior\n",
@@ -308,7 +298,7 @@
308
298
{
309
299
"cell_type": "code",
310
300
"execution_count": null,
311
-
"id": "21",
301
+
"id": "20",
312
302
"metadata": {},
313
303
"outputs": [],
314
304
"source": [
@@ -324,15 +314,15 @@
324
314
},
325
315
{
326
316
"cell_type": "markdown",
327
-
"id": "22",
317
+
"id": "21",
328
318
"metadata": {},
329
319
"source": [
330
320
"The outputs are identical (within numerical precision), confirming that probes are purely observational."
331
321
]
332
322
},
333
323
{
334
324
"cell_type": "markdown",
335
-
"id": "23",
325
+
"id": "22",
336
326
"metadata": {},
337
327
"source": [
338
328
"## Summary\n",
@@ -354,18 +344,18 @@
354
344
},
355
345
{
356
346
"cell_type": "markdown",
357
-
"id": "24",
347
+
"id": "23",
358
348
"metadata": {},
359
349
"source": [
360
350
"## Ports as probes\n",
361
351
"\n",
362
-
"When a port is applied on an internal node (i.e., an instance port that is already part of a connection), it will automatically be interpreted as a probe. SAX will issue a warning and create `{name}_fwd` and `{name}_bwd` ports instead of the original port name."
352
+
"When a port is applied on an internal node (i.e., an instance port that is already part of a connection) it usually is ignored, however we can also make it it automatically be interpreted as a probe:"
0 commit comments