QGeometryTables#

class QGeometryTables(design: QDesign)[source]#

Class to create, store, and handle element tables.

A regular user would not need to create tables themselves. This is handled automatically by the design creation and plugins.

Structure:

A component, such as a qubit, is a collection of qgeometry. For example, an element includes a rectangle, a cpw path, or a more general polygon.

An element is a row in a table.

All qgeometry of a type (Path or Polygon, or otherwise) are stored in a single table of their element type.

All qgeometry of the same kind are stored in a table. A renderer has to know how to handle all types of qgeometry in order to render them.

For plugin developers:

In the following, we provide an example that illustrates for plugin developers how to add custom qgeometry and custom element properties. For example, we will add, for a renderer called hfss, a string property called ‘boundary’, a bool property called ‘perfectE’, and a property called ‘material’.

For plugin developers, example use:

 1import qiskit_metal as metal
 2
 3design = metal.designs.DesignPlanar()
 4design.qgeometry = metal.QGeometryTables(design)
 5
 6# return the path table - give access to ..
 7design.qgeometry['path']
 8design.qgeometry.table['path']
 9
10# Define interfaces
11design.qgeometry.get_component(
12        component_name,
13        element_name,
14        columns=all or geom or list) # get all elements for components
15
16>>> component       name    geometry        layer   type    chip    subtract        fillet  color   width

Now, if we want to add custom qgeometry through two fake renderers called hfss and gds:

 1metal.QGeometryTables.add_renderer_extension('hfss', dict(
 2    base=dict(
 3        boundary=str,
 4        perfectE=bool,
 5        material=str,
 6        )
 7    ))
 8
 9metal.QGeometryTables.add_renderer_extension('gds', dict(
10    path=dict(
11        color=str,
12        pcell=bool,
13        )
14    ))
15
16design = metal.designs.DesignPlanar()
17qgeometry = metal.QGeometryTables(design)
18
19qgeometry.tables['path']
20>>> component       name    geometry        layer   type    chip    subtract        fillet  color   width   hfss_boundary   hfss_perfectE   hfss_material   gds_color       gds_pcell

The constructor for the QGeometryTables class.

Parameters:

design – Design in use

Attributes

ELEMENT_COLUMNS = {'base': {'__renderers__': {}, 'chip': <class 'str'>, 'component': <class 'str'>, 'geometry': <class 'object'>, 'helper': <class 'bool'>, 'layer': <class 'int'>, 'name': <class 'str'>, 'subtract': <class 'bool'>}, 'junction': {'__renderers__': {}, 'width': <class 'float'>}, 'path': {'__renderers__': {}, 'fillet': <class 'object'>, 'width': <class 'float'>}, 'poly': {'__renderers__': {}, 'fillet': <class 'object'>}}#

Table column names to use to create. This dict should be updated by renderers.

design#

Return a reference to the parent design object.

logger#

Return the logger.

name_delimiter = '_'#

Delimiter to use when creating names of columns of renderer properties.

tables#

The dictionary of tables containing qgeometry.

Returns:

The keys of this dictionary are also obtained from self.get_element_types()

Return type:

Dict_[str, GeoDataFrame]

Methods

add_qgeometry(kind: str, component_name: str, geometry: dict, subtract: bool = False, helper: bool = False, layer: int | str = 1, chip: str = 'main', **other_options)[source]#

Main interface to add qgeometries.

Parameters:
  • kind (str) – Must be in get_element_types (‘path’, ‘poly’, etc.).

  • component_name (str) – Component name.

  • geometry (dict) – Dict of shapely geometry.

  • subtract (bool) – Subtract - passed through. Defaults to False.

  • helper (bool) – Helper - passed through. Defaults to False.

  • layer (Union[int, str]) – Layer - passed through. Defaults to 1.

  • chip (str) – Chip name - passed through. Defaults to ‘main’.

  • **other_options (object) – Other_options - passed through.

classmethod add_renderer_extension(renderer_name: str, qgeometry: dict)[source]#

Add renderer element extension to ELEMENT_COLUMNS. Called when the load function of a renderer is called.

Parameters:
  • renderer_name (str) – Name of renderer

  • qgeometry (dict) – dict of dict. Keys give element type names, such as base, poly, path, etc.

check_element_type(table_name: str, log_issue: bool = True) bool[source]#

Check if the name table_name is in the element tables.

Parameters:
  • table_name (str) – Element type (‘poly’, ‘path’, etc.) or ‘all’

  • log_issue (bool) – Throw an error in the log if name missing. Defaults to True.

Returns:

True if the name is valid, else False

Return type:

bool

check_lengths(geometry: BaseGeometry, kind: str, component_name: str, **other_options)[source]#

If user wants to fillet, check the line-segments to see if it is too short for fillet.

Parameters:
  • geometry (shapely.geometry.base.BaseGeometry) – The LineString to investigate.

  • kind (str) – Name of table, i.e. ‘path’, ‘poly’, ‘junction, etc

  • component_name (str) – Is an integer id.

clear_all_tables()[source]#

Clear all the internal tables and all else.

Use when clearing a design and starting from scratch.

create_tables()[source]#

Creates the default tables once. Populates the dict ‘tables’ of GeoDataFrame, each with columns corresponding to the types of qgeometry defined in ELEMENT_COLUMNS.

Should only be done once when a new design is created.

delete_component(name: str)[source]#

Delete component by name.

Parameters:

name (str) – Name of component (case sensitive)

delete_component_id(component_id: int)[source]#

Drop the components within the qgeometry.tables.

Parameters:

component_id (int) – Unique number to describe the component.

get_all_unique_layers(chip_name: str) list[source]#

Returns a lit of unique layers for the given chip names.

Parameters:

chip_name (str) – Name of the chip

Returns:

List of unique layers

Return type:

list

get_all_unique_layers_for_all_tables(qcomp_ids: list | None = None) list[source]#

Get a list of all unique layer number used in all of the geometry tables. User can get for all components or a subset.

Parameters:

qcomp_ids (Union[list, None], optional) – The list has integers which denote component_id. Defaults to None.

Returns:

The unique layer numbers for the list of component ids passed in argument.

Return type:

list

get_component(name: str, table_name: str = 'all') GeoDataFrame | Dict[str, GeoDataFrame][source]#

Return the table for just a given component. If all, returns a dictionary with keys as table names and tables of components as values.

Parameters:
  • name (str) – Name of component (case sensitive). Defaults to ‘all’.

  • table_name (str) – Element table name (‘poly’, ‘path’, etc.). Defaults to {‘all’}.

Returns:

Either a GeoDataFrame or a dict or GeoDataFrame.

Return type:

Union[GeoDataFrame, Dict_[str, GeoDataFrame]]

Example usage:

`table = pd.concat(qgeometry.get_component('Q1')) # , axis=0`

get_component_bounds(name: str) Tuple[float, float, float, float][source]#

Returns a tuple containing minx, miny, maxx, maxy values for the bounds of the component as a whole.

Parameters:

name (str) – Component name

Returns:

Bare element geometry

Return type:

Geometry

get_component_geometry(name: str) GeoSeries[source]#

Returns geometry of a given component.

Parameters:

name (str) – Name of component (case sensitive)

Returns:

Geometry of the component

Return type:

GeoSeries

get_component_geometry_dict(name: str, table_name: str = 'all') List[BaseGeometry][source]#

Return just the bare element geometry (shapely geometry objects) as a dict, with key being the names of the qgeometry and the values as the shapely geometry, for the selected component.

Parameters:
  • name (str) – Name of component (case sensitive)

  • table_name (str) – Element type (‘poly’, ‘path’, etc.). Defaults to ‘all’.

Returns:

Bare element geometry

Return type:

dict

get_component_geometry_list(name: str, table_name: str = 'all') List[BaseGeometry][source]#

Return just the bare element geometry (shapely geometry objects) as a list, for the selected component.

Parameters:
  • name (str) – Name of component (case sensitive)

  • table_name (str) – Element type (‘poly’, ‘path’, etc.). Can also be ‘all’ to return all. This is the default.

Returns:

List of shapley.geometry objects

Return type:

list

classmethod get_element_types() List[str][source]#

Return the names of the available qgeometry to create. This does not include ‘base’, but is rather such as poly and path.

Returns:

A list of name in self.ELEMENT_COLUMNS

Return type:

list(str)

get_rname(renderer_name: str, key: str) str[source]#

Get name for renderer property.

Parameters:
  • renderer_name (str) – Name of the renderer

  • key (str) – Key to get the name for

Returns:

The unique named used as a column in the table

Return type:

str

parse_value(value: Any | List | Dict | Iterable) Any[source]#

Same as design.parse_value. See design for help.

Returns:

Parsed value of input.

rename_component(component_id: int, new_name: str)[source]#

Rename component by ID (integer) cast to string format.

Parameters:
  • component_id (int) – ID of component (case sensitive)

  • new_name (str) – The new name of the component (case sensitive)