Skip to content

select_references

select_references(
component: photonforge.Component, query: str | tuple
) -> list[str]

Paths of the references a query selects, as updates would.

The query uses the reference query syntax of updates in CircuitModel.start, and matches component names before any updates are applied.

Args

  • component: Component whose references are searched.
  • query: Path string, such as "SUB/BEND[1]" or "**/MZM*", or tuple query.

Returns

Reference paths in netlist order, such as "SUB[0]/BEND[1]". Each path selects exactly that reference when used as a query.

Example

>>> leaf = Component("LEAF")
>>> sub = Component("SUB").add(Reference(leaf), Reference(leaf))
>>> top = Component("TOP").add(Reference(sub), Reference(leaf))
>>> select_references(top, "**/LEAF")
['SUB[0]/LEAF[0]', 'SUB[0]/LEAF[1]', 'LEAF[0]']
>>> select_references(top, "SUB/LEAF[1]")
['SUB[0]/LEAF[1]']