From 73d7e4acf370ef0c9b8f5b679a8ef5b35407d334 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Wed, 3 Aug 2022 15:55:16 -0400 Subject: [PATCH 01/12] Refactored box_plus_buffer code. --- .../renderers/renderer_base/renderer_base.py | 5 +- qiskit_metal/toolbox_metal/__init__.py | 2 + .../bounds_for_path_and_poly_tables.py | 234 ++++++++++++++++++ 3 files changed, 240 insertions(+), 1 deletion(-) create mode 100644 qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py diff --git a/qiskit_metal/renderers/renderer_base/renderer_base.py b/qiskit_metal/renderers/renderer_base/renderer_base.py index 2d15da5cb..0a85b7c23 100644 --- a/qiskit_metal/renderers/renderer_base/renderer_base.py +++ b/qiskit_metal/renderers/renderer_base/renderer_base.py @@ -421,7 +421,10 @@ def get_unique_component_ids( highlight_qcomponents (Union[list, None], optional): Components to render. Defaults to None. Returns: - Tuple[list, int]: Empty or partial list of components in QDesign. + Tuple[list, int]: Tuple: Empty or partial list of components in QDesign. + int: 0 subset selected + 1 every component selected + 2 invalid """ highlight_qcomponents = highlight_qcomponents if highlight_qcomponents else [] unique_qcomponents = set(highlight_qcomponents) diff --git a/qiskit_metal/toolbox_metal/__init__.py b/qiskit_metal/toolbox_metal/__init__.py index 120e519ef..532af3fb6 100644 --- a/qiskit_metal/toolbox_metal/__init__.py +++ b/qiskit_metal/toolbox_metal/__init__.py @@ -52,6 +52,7 @@ from .parsing import is_numeric_possible from .parsing import parse_units from .layer_stack_handler import LayerStackHandler +from .bounds_for_path_and_poly_tables import BoundsForPathAndPolyTables from .. import config if config.is_building_docs(): @@ -62,3 +63,4 @@ from . import parsing from . import math_and_overrides from . import layer_stack_handler + from . import bounds_for_path_and_poly_tables diff --git a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py new file mode 100644 index 000000000..6f7d3af30 --- /dev/null +++ b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py @@ -0,0 +1,234 @@ +# -*- coding: utf-8 -*- +from typing import List, Tuple, Union + +from qiskit_metal.designs import MultiPlanar +from qiskit_metal.toolbox_python.utility_functions import determine_larger_box + +import pandas as pd + + +class BoundsForPathAndPolyTables(): + """Create class which can be used by multiple renderers. In particular, this class + assumes a LayerStack is being used within QDesign. + """ + + def __init__(self, design: MultiPlanar): + self.design = design + self.chip_names_matched = None # bool + self.valid_chip_names = None # set of valid chip names from layer_stack + + def get_bounds_of_path_and_poly_tables( + self, box_plus_buffer: bool, qcomp_ids: List, case: int, x_buff: float, + y_buff: float + ) -> tuple[tuple[float, float, float, float], pd.DataFrame, bool, Union[ + None, set]]: + """If box_plus_buffer is True, returns a tuple containing minx, miny, maxx, maxy values for the + bounds of what was selected to be rendered. + Else, use the chip size for Tuple. + + Also, return the Tuple within the class to can be used later within a renderer. + + Args: + box_plus_buffer (bool): Use the box of selected components plus a buffer size OR + the chip size based on QComponents selected. + qcomp_ids (List): Empty or partial list of components in QDesign. From QRenderer.get_unique_component_ids + case (int): Return code used from QRenderer.get_unique_component_ids() + x_buff (float): If box_plus_buffer, need the buffer value in x coordinate. + y_buff (float): If box_plus_buffer, need the buffer value in y coordinate. + + Returns: + tuple[tuple[float, float, float, float], pd.DataFrame, bool, Union[None,set]]: + tuple: minx, miny, maxx, maxy values based + on either total chip size or box_plus_buffer. + pd.DataFrame: The path and poly dataframes concatenated for qcomp_ids + bool: If there is a key in design with same chip_name as in layer_stack + Union[None,set]: Either None if the names don't match, + or the set of chip_names that can be used. + """ + box_for_ansys = None + self.chip_names_matched = None + self.valid_chip_names = None + + path_dataframe = self.design.qgeometry.tables['path'] + poly_dataframe = self.design.qgeometry.tables['poly'] + + if box_plus_buffer: + # Based on component selection, determine the bounds for box_plus_buffer. + frames = None + path_and_poly_with_valid_comps = None + + if case == 2: # One or more components not in QDesign. + self.design.logger.warning("One or more components not found.") + elif case == 1: # Render all components + frames = [path_dataframe, poly_dataframe] + else: # Strict subset rendered. + mask_path = path_dataframe['component'].isin(qcomp_ids) + mask_poly = poly_dataframe['component'].isin(qcomp_ids) + subset_path_df = path_dataframe[mask_path] + subset_poly_df = poly_dataframe[mask_poly] + frames = [subset_path_df, subset_poly_df] + + #Concat the frames and then determine the total bounds of all the geometries. + # maybe, change name to package_cavity + path_and_poly_with_valid_comps = pd.concat(frames, + ignore_index=True) + minx, miny, maxx, maxy = list( + path_and_poly_with_valid_comps['geometry'].total_bounds) + # minx, miny, maxx, maxy = list( + # pd.concat(frames, ignore_index=True)['geometry'].total_bounds) + # # Add the buffer, using options for renderer. + # x_buff = parse_entry(self._options["x_buffer_width_mm"]) + # y_buff = parse_entry(self._options["y_buffer_width_mm"]) + + minx -= x_buff + miny -= y_buff + maxx += x_buff + maxy += y_buff + box_for_ansys = (minx, miny, maxx, maxy) + return box_for_ansys, path_and_poly_with_valid_comps, self.chip_names_matched, self.valid_chip_names + else: # Incorporate all the chip sizes. + + minx, miny, maxx, maxy = self.get_box_for_ansys() + box_for_ansys = (minx, miny, maxx, maxy) + + frames = [path_dataframe, poly_dataframe] + path_and_poly_with_valid_comps = pd.concat(frames, + ignore_index=True) + return box_for_ansys, path_and_poly_with_valid_comps, self.chip_names_matched, self.valid_chip_names + + def get_box_for_ansys( + self + ) -> Union[None, Union[Tuple[float, float, float, float], None]]: + """Assuming the chip size is used from Multiplanar design, and list of chip_names + comes from layer_stack that will be used to determine the box size for simulation. + + Returns: + Union[None, Union[Tuple[float, float, float, float], None]]: + None if not able to get the chip information + Tuple holds the box to use for simulation [minx, miny, maxx, maxy] + """ + + self.chip_names_matched, self.valid_chip_names = self.are_all_chipnames_in_design( + ) + + minx, miny, maxx, maxy = None, None, None, None + if self.chip_names_matched: + # Using the chip size from Multiplanar design and z_coord from layer_stack, get the box + # for chip_name in self.chip_names_matched: + for chip_name in self.valid_chip_names: + if self.design.chips[chip_name]['size']: + chip_box, return_code = self.get_x_y_for_chip(chip_name) + + if return_code == 0: # All was found and good. + minx, miny, maxx, maxy = determine_larger_box( + minx, miny, maxx, maxy, chip_box) + + else: + self.chip_size_not_in_chipname_within_design(chip_name) + + return minx, miny, maxx, maxy + + def are_all_chipnames_in_design(self) -> Tuple[bool, Union[set, None]]: + """Using chip names in layer_stack information, + then check if the information is in MultiPlanar design. + + Returns: + Tuple[bool, Union[set, None]]: bool if there is a key in design with same chip_name as in layer_stack + Union has either None if the names don't match, + or the set of chip_names that can be used. + """ + + chip_set_from_design = set(self.design.chips.keys()) + chip_set_from_layer_stack = self.design.ls.get_unique_chip_names() + if not chip_set_from_layer_stack.issubset(chip_set_from_design): + self.chip_names_not_in_design(chip_set_from_layer_stack, + chip_set_from_design) + return False, None + + return True, chip_set_from_layer_stack + + def get_x_y_for_chip(self, chip_name: str) -> Tuple[tuple, int]: + """If the chip_name is in self.chips, along with entry for size + information then return a tuple=(minx, miny, maxx, maxy). Used for + subtraction while exporting design. + + Args: + chip_name (str): Name of chip that you want the size of. + + Returns: + Tuple[tuple, int]: + tuple: The exact placement on rectangle coordinate (minx, miny, maxx, maxy). + int: 0=all is good + 1=chip_name not in self._chips + 2=size information missing or no good + """ + x_y_location = tuple() + + if chip_name in self.design.chips: + if 'size' in self.design.chips[chip_name]: + + size = self.design.parse_value( + self.design.chips[chip_name]['size']) + if 'center_x' in size \ + and 'center_y' in size \ + and 'size_x' in size \ + and 'size_y' in size: + if type(size.center_x) in [int, float] and \ + type(size.center_y) in [int, float] and \ + type(size.size_x) in [int, float] and \ + type(size.size_y) in [int, float]: + x_y_location = ( + size['center_x'] - (size['size_x'] / 2.0), + size['center_y'] - (size['size_y'] / 2.0), + size['center_x'] + (size['size_x'] / 2.0), + size['center_y'] + (size['size_y'] / 2.0)) + return x_y_location, 0 + + self.design.logger.warning( + f'Size information within self.design.chips[{chip_name}][\"size\"]' + f' is NOT an int or float.') + return x_y_location, 2 + + self.design.logger.warning( + 'center_x or center_y or size_x or size_y ' + f' NOT in self.design.chips[{chip_name}][\"size\"]') + return x_y_location, 2 + + self.design.logger.warning( + f'Information for size in NOT in self.design.chips[{chip_name}]' + ' dict. Return "None" in tuple.') + return x_y_location, 2 + + self.design.logger.warning( + f'Chip name "{chip_name}" is not in self.design.chips dict. Return "None" in tuple.' + ) + return x_y_location, 1 + + +######### Warnings and Errors################################################## + + def chip_names_not_in_design(self, layer_stack_names: set, + design_names: set): + """ + Tell user to check the chip name and data in design. + + Args: + layer_stack_names (set): Chip names from layer_stack. + design_names (set): Chip names from design. + """ + self.design.logger.warning( + f'\nThe chip_names from layer_stack are not in design. ' + f'\n The names in layer_stack:{layer_stack_names}.' + f'\n The names in design:{design_names}.') + + def chip_size_not_in_chipname_within_design(self, chip_name: str): + """ + Tell user to check the chip size data within design. + + Args: + chip_name (str): Chip names from layer_stack. + """ + self.design.logger.error( + f'\nThe chip_name:{chip_name} within design. ' + f'\n Update your QDesign or subclass to see confirm the size information is provided.' + ) \ No newline at end of file From 51f78d51a09cbea3779428e43fd3c6b8c91cd093 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Wed, 3 Aug 2022 15:56:22 -0400 Subject: [PATCH 02/12] Typos. --- qiskit_metal/toolbox_metal/layer_stack_handler.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/qiskit_metal/toolbox_metal/layer_stack_handler.py b/qiskit_metal/toolbox_metal/layer_stack_handler.py index 82a5e8f57..a890cb114 100644 --- a/qiskit_metal/toolbox_metal/layer_stack_handler.py +++ b/qiskit_metal/toolbox_metal/layer_stack_handler.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from textwrap import fill -from xmlrpc.client import Boolean import pandas as pd from typing import List, Tuple from typing import Union @@ -9,7 +7,7 @@ import os import logging -from .parsing import parse_units, TRUE_STR, FALSE_STR +from .parsing import TRUE_STR, FALSE_STR class LayerStackHandler(): From c6440ed9785f0f946b0e13f38f0a281bce0b4d36 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Wed, 3 Aug 2022 16:26:26 -0400 Subject: [PATCH 03/12] typos. --- qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py index 6f7d3af30..7066a8328 100644 --- a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py +++ b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py @@ -8,7 +8,7 @@ class BoundsForPathAndPolyTables(): - """Create class which can be used by multiple renderers. In particular, this class + """Create class which can be used by multiple renderers. In particular, this class assumes a LayerStack is being used within QDesign. """ @@ -37,7 +37,7 @@ def get_bounds_of_path_and_poly_tables( y_buff (float): If box_plus_buffer, need the buffer value in y coordinate. Returns: - tuple[tuple[float, float, float, float], pd.DataFrame, bool, Union[None,set]]: + tuple[tuple[float, float, float, float], pd.DataFrame, bool, Union[None,set]]: tuple: minx, miny, maxx, maxy values based on either total chip size or box_plus_buffer. pd.DataFrame: The path and poly dataframes concatenated for qcomp_ids From 42c85c2898556fe07db20172a3022758f82437d7 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Wed, 3 Aug 2022 17:05:57 -0400 Subject: [PATCH 04/12] Give a clear path for import. --- qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py index 7066a8328..c9cda30f3 100644 --- a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py +++ b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from typing import List, Tuple, Union -from qiskit_metal.designs import MultiPlanar +from qiskit_metal.designs.design_multiplanar import MultiPlanar from qiskit_metal.toolbox_python.utility_functions import determine_larger_box import pandas as pd From 828a22c91ef725999368a3c2c77eb05d580ead1b Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Wed, 3 Aug 2022 17:22:34 -0400 Subject: [PATCH 05/12] Can use quotes for typehints instead of importing MultiPlanar. --- qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py index c9cda30f3..9e2fcd66c 100644 --- a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py +++ b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from typing import List, Tuple, Union -from qiskit_metal.designs.design_multiplanar import MultiPlanar from qiskit_metal.toolbox_python.utility_functions import determine_larger_box import pandas as pd @@ -12,7 +11,7 @@ class BoundsForPathAndPolyTables(): assumes a LayerStack is being used within QDesign. """ - def __init__(self, design: MultiPlanar): + def __init__(self, design: "MultiPlanar"): self.design = design self.chip_names_matched = None # bool self.valid_chip_names = None # set of valid chip names from layer_stack From 4ec81b6317c61a46ca782cfed2382be174c632e6 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Thu, 4 Aug 2022 10:31:44 -0400 Subject: [PATCH 06/12] Use more accurate naming for variables. --- .../bounds_for_path_and_poly_tables.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py index 9e2fcd66c..95a8c2e35 100644 --- a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py +++ b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py @@ -44,7 +44,7 @@ def get_bounds_of_path_and_poly_tables( Union[None,set]: Either None if the names don't match, or the set of chip_names that can be used. """ - box_for_ansys = None + box_for_xy_bounds = None self.chip_names_matched = None self.valid_chip_names = None @@ -83,19 +83,19 @@ def get_bounds_of_path_and_poly_tables( miny -= y_buff maxx += x_buff maxy += y_buff - box_for_ansys = (minx, miny, maxx, maxy) - return box_for_ansys, path_and_poly_with_valid_comps, self.chip_names_matched, self.valid_chip_names + box_for_xy_bounds = (minx, miny, maxx, maxy) + return box_for_xy_bounds, path_and_poly_with_valid_comps, self.chip_names_matched, self.valid_chip_names else: # Incorporate all the chip sizes. - minx, miny, maxx, maxy = self.get_box_for_ansys() - box_for_ansys = (minx, miny, maxx, maxy) + minx, miny, maxx, maxy = self.get_box_for_xy_bounds() + box_for_xy_bounds = (minx, miny, maxx, maxy) frames = [path_dataframe, poly_dataframe] path_and_poly_with_valid_comps = pd.concat(frames, ignore_index=True) - return box_for_ansys, path_and_poly_with_valid_comps, self.chip_names_matched, self.valid_chip_names + return box_for_xy_bounds, path_and_poly_with_valid_comps, self.chip_names_matched, self.valid_chip_names - def get_box_for_ansys( + def get_box_for_xy_bounds( self ) -> Union[None, Union[Tuple[float, float, float, float], None]]: """Assuming the chip size is used from Multiplanar design, and list of chip_names From c3e3cc8ca89efb09a9221f70e5172aad1842a5a8 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Thu, 4 Aug 2022 15:39:58 -0400 Subject: [PATCH 07/12] Add logic to shave the box_plus_buffer if larger than the aggregate chip size, along with some error checking. --- .../bounds_for_path_and_poly_tables.py | 76 +++++++++++++++++-- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py index 95a8c2e35..9df7a3e90 100644 --- a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py +++ b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from typing import List, Tuple, Union - +from copy import deepcopy from qiskit_metal.toolbox_python.utility_functions import determine_larger_box import pandas as pd @@ -25,12 +25,13 @@ def get_bounds_of_path_and_poly_tables( bounds of what was selected to be rendered. Else, use the chip size for Tuple. - Also, return the Tuple within the class to can be used later within a renderer. + Also, return the Tuple so can be used later within a renderer. Args: box_plus_buffer (bool): Use the box of selected components plus a buffer size OR the chip size based on QComponents selected. - qcomp_ids (List): Empty or partial list of components in QDesign. From QRenderer.get_unique_component_ids + qcomp_ids (List): Empty or partial list of components in QDesign. + From QRenderer.get_unique_component_ids case (int): Return code used from QRenderer.get_unique_component_ids() x_buff (float): If box_plus_buffer, need the buffer value in x coordinate. y_buff (float): If box_plus_buffer, need the buffer value in y coordinate. @@ -39,6 +40,9 @@ def get_bounds_of_path_and_poly_tables( tuple[tuple[float, float, float, float], pd.DataFrame, bool, Union[None,set]]: tuple: minx, miny, maxx, maxy values based on either total chip size or box_plus_buffer. + In xy plane, the box_for_xy_bounds will be limited + by the chip_bounds_xy if box_for_xy_bounds is larger + than chip_bounds_xy. pd.DataFrame: The path and poly dataframes concatenated for qcomp_ids bool: If there is a key in design with same chip_name as in layer_stack Union[None,set]: Either None if the names don't match, @@ -51,6 +55,12 @@ def get_bounds_of_path_and_poly_tables( path_dataframe = self.design.qgeometry.tables['path'] poly_dataframe = self.design.qgeometry.tables['poly'] + # NOTE:get_box_for_xy_bounds populates self.chip_names_matched and self.valid_chip_names + chip_minx, chip_miny, chip_maxx, chip_maxy = self.get_box_for_xy_bounds( + ) + + chip_bounds_xy = (chip_minx, chip_miny, chip_maxx, chip_maxy) + if box_plus_buffer: # Based on component selection, determine the bounds for box_plus_buffer. frames = None @@ -84,16 +94,66 @@ def get_bounds_of_path_and_poly_tables( maxx += x_buff maxy += y_buff box_for_xy_bounds = (minx, miny, maxx, maxy) - return box_for_xy_bounds, path_and_poly_with_valid_comps, self.chip_names_matched, self.valid_chip_names - else: # Incorporate all the chip sizes. - minx, miny, maxx, maxy = self.get_box_for_xy_bounds() - box_for_xy_bounds = (minx, miny, maxx, maxy) + safe_xy_bounds = self.ensure_component_box_smaller_than_chip_box_( + box_for_xy_bounds, chip_bounds_xy) + + return safe_xy_bounds, path_and_poly_with_valid_comps, self.chip_names_matched, self.valid_chip_names + else: # Incorporate all the chip sizes. frames = [path_dataframe, poly_dataframe] path_and_poly_with_valid_comps = pd.concat(frames, ignore_index=True) - return box_for_xy_bounds, path_and_poly_with_valid_comps, self.chip_names_matched, self.valid_chip_names + return chip_bounds_xy, path_and_poly_with_valid_comps, self.chip_names_matched, self.valid_chip_names + + @classmethod + def ensure_component_box_smaller_than_chip_box_( + cls, box_for_xy_bounds: Tuple, chip_bounds_xy: Tuple) -> Tuple: + """If the box_plus_buffer is larger than the aggregate chip bounds from DesignPlanar, + use the chip bounds as the cutoff. + + Args: + box_for_xy_bounds (Tuple): In xy plane, the bounding box for the components to render. + Box from QGeometry tables. + chip_bounds_xy (Tuple): In xy plane, the bounding box for aggregate chip size. + Box from MultiPlanar chip size. + + Returns: + Tuple: In xy plane, the box_for_xy_bounds will be limited by the chip_bounds_xy + if box_for_xy_bounds is larger than chip_bounds_xy. + If chip_bounds_xy is None (bad input), no checking + will happen and box_for_xy_bounds will be returned. + """ + + chip_minx, chip_miny, chip_maxx, chip_maxy = chip_bounds_xy + if chip_minx is None or chip_miny is None or chip_maxx is None or chip_maxy is None: + input_xy_box = deepcopy(box_for_xy_bounds) + return input_xy_box + + box_minx, box_miny, box_maxx, box_maxy = box_for_xy_bounds + safe_xy_box = list() + # Keep the order of appends in this way. It should match (minx, miny, maxx, maxy) + if box_minx < chip_minx: + safe_xy_box.append(chip_minx) + else: + safe_xy_box.append(box_minx) + + if box_miny < chip_miny: + safe_xy_box.append(chip_miny) + else: + safe_xy_box.append(box_miny) + + if box_maxx > chip_maxx: + safe_xy_box.append(chip_maxx) + else: + safe_xy_box.append(box_maxx) + + if box_maxy > chip_maxy: + safe_xy_box.append(chip_maxy) + else: + safe_xy_box.append(box_maxy) + + return tuple(safe_xy_box) def get_box_for_xy_bounds( self From ef7d27a7a92957f964b1388e75e8407f896b1839 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Thu, 4 Aug 2022 15:45:05 -0400 Subject: [PATCH 08/12] typo --- qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py index 9df7a3e90..8ea38bd00 100644 --- a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py +++ b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py @@ -11,7 +11,7 @@ class BoundsForPathAndPolyTables(): assumes a LayerStack is being used within QDesign. """ - def __init__(self, design: "MultiPlanar"): + def __init__(self, design: 'MultiPlanar'): self.design = design self.chip_names_matched = None # bool self.valid_chip_names = None # set of valid chip names from layer_stack From 90dec8bcfd46c55bd5cc8f4309ced3ba2a5b6b22 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Mon, 8 Aug 2022 10:31:14 -0400 Subject: [PATCH 09/12] Use yapf disable to write the code more compact and view logic more clearly. --- .../bounds_for_path_and_poly_tables.py | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py index 8ea38bd00..548637056 100644 --- a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py +++ b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py @@ -4,6 +4,7 @@ from qiskit_metal.toolbox_python.utility_functions import determine_larger_box import pandas as pd +import numpy as np class BoundsForPathAndPolyTables(): @@ -133,25 +134,13 @@ def ensure_component_box_smaller_than_chip_box_( box_minx, box_miny, box_maxx, box_maxy = box_for_xy_bounds safe_xy_box = list() # Keep the order of appends in this way. It should match (minx, miny, maxx, maxy) - if box_minx < chip_minx: - safe_xy_box.append(chip_minx) - else: - safe_xy_box.append(box_minx) - - if box_miny < chip_miny: - safe_xy_box.append(chip_miny) - else: - safe_xy_box.append(box_miny) - - if box_maxx > chip_maxx: - safe_xy_box.append(chip_maxx) - else: - safe_xy_box.append(box_maxx) - - if box_maxy > chip_maxy: - safe_xy_box.append(chip_maxy) - else: - safe_xy_box.append(box_maxy) + + # yapf: disable + safe_xy_box.append(chip_minx) if box_minx < chip_minx else safe_xy_box.append(box_minx) + safe_xy_box.append(chip_miny) if box_miny < chip_miny else safe_xy_box.append(box_miny) + safe_xy_box.append(chip_maxx) if box_maxx > chip_maxx else safe_xy_box.append(box_maxx) + safe_xy_box.append(chip_maxy) if box_maxy > chip_maxy else safe_xy_box.append(box_maxy) + # yapf: enable return tuple(safe_xy_box) From 7d9657de6bde4911f12ed02c179405e45324bbe1 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Mon, 8 Aug 2022 11:17:54 -0400 Subject: [PATCH 10/12] Check if CI failed due to python adding pyaedt to environment.yml. --- .../bounds_for_path_and_poly_tables.py | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py index 548637056..02b8785f8 100644 --- a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py +++ b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py @@ -135,12 +135,32 @@ def ensure_component_box_smaller_than_chip_box_( safe_xy_box = list() # Keep the order of appends in this way. It should match (minx, miny, maxx, maxy) - # yapf: disable - safe_xy_box.append(chip_minx) if box_minx < chip_minx else safe_xy_box.append(box_minx) - safe_xy_box.append(chip_miny) if box_miny < chip_miny else safe_xy_box.append(box_miny) - safe_xy_box.append(chip_maxx) if box_maxx > chip_maxx else safe_xy_box.append(box_maxx) - safe_xy_box.append(chip_maxy) if box_maxy > chip_maxy else safe_xy_box.append(box_maxy) - # yapf: enable + # # yapf: disable + # safe_xy_box.append(chip_minx) if box_minx < chip_minx else safe_xy_box.append(box_minx) + # safe_xy_box.append(chip_miny) if box_miny < chip_miny else safe_xy_box.append(box_miny) + # safe_xy_box.append(chip_maxx) if box_maxx > chip_maxx else safe_xy_box.append(box_maxx) + # safe_xy_box.append(chip_maxy) if box_maxy > chip_maxy else safe_xy_box.append(box_maxy) + # # yapf: enable + + if box_minx < chip_minx: + safe_xy_box.append(chip_minx) + else: + safe_xy_box.append(box_minx) + + if box_miny < chip_miny: + safe_xy_box.append(chip_miny) + else: + safe_xy_box.append(box_miny) + + if box_maxx > chip_maxx: + safe_xy_box.append(chip_maxx) + else: + safe_xy_box.append(box_maxx) + + if box_maxy > chip_maxy: + safe_xy_box.append(chip_maxy) + else: + safe_xy_box.append(box_maxy) return tuple(safe_xy_box) From 27d478067dc31bd960d3f2bcd983f04a70ac44cb Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Mon, 8 Aug 2022 11:31:30 -0400 Subject: [PATCH 11/12] Remove the yapf enable and disable. --- .../bounds_for_path_and_poly_tables.py | 35 +++++-------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py index 02b8785f8..e513b6162 100644 --- a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py +++ b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py @@ -4,7 +4,6 @@ from qiskit_metal.toolbox_python.utility_functions import determine_larger_box import pandas as pd -import numpy as np class BoundsForPathAndPolyTables(): @@ -135,32 +134,14 @@ def ensure_component_box_smaller_than_chip_box_( safe_xy_box = list() # Keep the order of appends in this way. It should match (minx, miny, maxx, maxy) - # # yapf: disable - # safe_xy_box.append(chip_minx) if box_minx < chip_minx else safe_xy_box.append(box_minx) - # safe_xy_box.append(chip_miny) if box_miny < chip_miny else safe_xy_box.append(box_miny) - # safe_xy_box.append(chip_maxx) if box_maxx > chip_maxx else safe_xy_box.append(box_maxx) - # safe_xy_box.append(chip_maxy) if box_maxy > chip_maxy else safe_xy_box.append(box_maxy) - # # yapf: enable - - if box_minx < chip_minx: - safe_xy_box.append(chip_minx) - else: - safe_xy_box.append(box_minx) - - if box_miny < chip_miny: - safe_xy_box.append(chip_miny) - else: - safe_xy_box.append(box_miny) - - if box_maxx > chip_maxx: - safe_xy_box.append(chip_maxx) - else: - safe_xy_box.append(box_maxx) - - if box_maxy > chip_maxy: - safe_xy_box.append(chip_maxy) - else: - safe_xy_box.append(box_maxy) + safe_xy_box.append( + chip_minx) if box_minx < chip_minx else safe_xy_box.append(box_minx) + safe_xy_box.append( + chip_miny) if box_miny < chip_miny else safe_xy_box.append(box_miny) + safe_xy_box.append( + chip_maxx) if box_maxx > chip_maxx else safe_xy_box.append(box_maxx) + safe_xy_box.append( + chip_maxy) if box_maxy > chip_maxy else safe_xy_box.append(box_maxy) return tuple(safe_xy_box) From 9e044ede1dfaa93cf2295e00b7b2a24a3eca6dc4 Mon Sep 17 00:00:00 2001 From: Priti A Shah Date: Mon, 8 Aug 2022 11:43:44 -0400 Subject: [PATCH 12/12] Put the yapf enable and disable back in. --- .../bounds_for_path_and_poly_tables.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py index e513b6162..0d2fed79d 100644 --- a/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py +++ b/qiskit_metal/toolbox_metal/bounds_for_path_and_poly_tables.py @@ -134,14 +134,12 @@ def ensure_component_box_smaller_than_chip_box_( safe_xy_box = list() # Keep the order of appends in this way. It should match (minx, miny, maxx, maxy) - safe_xy_box.append( - chip_minx) if box_minx < chip_minx else safe_xy_box.append(box_minx) - safe_xy_box.append( - chip_miny) if box_miny < chip_miny else safe_xy_box.append(box_miny) - safe_xy_box.append( - chip_maxx) if box_maxx > chip_maxx else safe_xy_box.append(box_maxx) - safe_xy_box.append( - chip_maxy) if box_maxy > chip_maxy else safe_xy_box.append(box_maxy) + #yapf: disable + safe_xy_box.append(chip_minx) if box_minx < chip_minx else safe_xy_box.append(box_minx) + safe_xy_box.append(chip_miny) if box_miny < chip_miny else safe_xy_box.append(box_miny) + safe_xy_box.append(chip_maxx) if box_maxx > chip_maxx else safe_xy_box.append(box_maxx) + safe_xy_box.append(chip_maxy) if box_maxy > chip_maxy else safe_xy_box.append(box_maxy) + #yapf: enable return tuple(safe_xy_box)