Skip to content

Fix model lookup for numbered component variants#121

Closed
jackgdsf wants to merge 1 commit into
gdsfactory:mainfrom
jackgdsf:fix/numbered-model-lookup
Closed

Fix model lookup for numbered component variants#121
jackgdsf wants to merge 1 commit into
gdsfactory:mainfrom
jackgdsf:fix/numbered-model-lookup

Conversation

@jackgdsf

Copy link
Copy Markdown

Summary

  • Adds _strip_counted_suffix() helper that strips trailing numeric suffixes (e.g. coupler2coupler) added by gdsfactory's CountedNetlistNamer in recursive netlists
  • Applied to DAG construction, model validation, the main circuit build loop, and the flat circuit builder — all numbered variants now resolve to the base analytical model
  • Conservative: only strips when the exact name isn't found AND the base name exists (explicit numbered models still take priority)

Closes #120

Test plan

  • New test test_numbered_component_variants: recursive netlist with coupler/coupler2 and waveguide/waveguide2 — all resolve to base model
  • New test test_numbered_variant_explicit_model_takes_priority: explicit waveguide2 model is used directly, not stripped
  • Full existing test suite passes (90/90, 0 regressions)
  • Ruff lint and format pass clean

🤖 Generated with Claude Code

gdsfactory's CountedNetlistNamer appends numeric suffixes (e.g. coupler2,
coupler3) to deduplicate cell names in recursive netlists. SAX's strict
dict lookup failed for these variants, causing them to silently degrade
to layout-extracted sub-netlists instead of using the analytical model.

Add _strip_counted_suffix() to fall back to the base model name when the
exact numbered name isn't found. Applied to DAG construction, model
validation, the main circuit build loop, and the flat circuit builder.

Closes gdsfactory#120

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jackgdsf

Copy link
Copy Markdown
Author

Closing per Mark's request — leaving the approach to Floris.

@jackgdsf jackgdsf closed this Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SAX model lookup fails for numbered component variants in recursive netlists

1 participant