qiskit-community / qiskit-metal

Quantum Hardware Design. Open-source project for engineers and scientists to design superconducting quantum devices with ease.
https://qiskit-community.github.io/qiskit-metal/
Apache License 2.0
270 stars 201 forks source link

Help on adding datatypes as an option to qgeometries #982

Open maxhant opened 5 months ago

maxhant commented 5 months ago

I want to have the option to choose which GDS datatype each geometry will belong to. For that, I have tried editing the render as follows:

    def _qgeometry_to_gds(
        self, qgeometry_element: pd.Series
    ) -> Union['gdspy.polygon', 'gdspy.FlexPath', None]:
        """
         Docs
        """

        # pylint: disable=too-many-locals

        corners = self.options.corners
        tolerance = self.parse_value(self.options.tolerance)
        precision = self.parse_value(self.options.precision)
        max_points = int(self.parse_value(self.options.max_points))

        geom = qgeometry_element.geometry  # type: shapely.geometry.base.BaseGeometry

        if isinstance(geom, shapely.geometry.Polygon):
            exterior_poly = gdspy.Polygon(
                list(geom.exterior.coords),
                layer=qgeometry_element.layer,
                datatype=qgeometry_element.sublayer,
            )

However, it does not work and I don't really understand why. It has an impact which is that all geometries are now on datatype 0. Can someone point me to the right direction?

What is the feature being requested?

Being able to expose the same layer with different intensities. Having them on separate layers does not work, else the cheesing will ignore the feature on higher layers. I have been discussing this on Slack.

What are use cases for this feature?

Having a more advanced fab.

zlatko-minev commented 5 months ago

You have correctly identified the location where the GDS polygon is created and you can specify its datatype (integer) – The GDSII datatype for this element (between 0 and 255).

https://github.com/qiskit-community/qiskit-metal/blob/a4ea462791b4e823a27580abecea2bec63fa7888/qiskit_metal/renderers/renderer_gds/gds_renderer.py#L2243

What is qgeometry_element.sublayer? How do you set it, it must be set to zero. You can print the dataframe that is qgeometry_element or where it comes from. This is probably the issue that this dataframe object is not set correctly

maxhant commented 5 months ago

Hi @zlatko-minev, thanks for your quick answer. I have created a draft PR #983 for you to see what I have done. Please, keep in mind that I am a novice at all this, but I am happy to learn to make it right!

zlatko-minev commented 5 months ago

Great job, very well done! This is a substantial change part of the code so we should take this a little carefully.

Have you checked this in one or two settings to make sure it works and doesn't fail anywhere?

Is it backwards compatible

maxhant commented 5 months ago

Have you checked this in one or two settings to make sure it works and doesn't fail anywhere?

For now, it does not work, so it is already failing. I was hoping that you would know what am I missing to have it working.

Once it works, which settings do you want me to test and I will test it properly?

zlatko-minev commented 4 months ago

Can you tell me more about where it is failing.

Ideally you can print the pandas datatables that are the tables and post a screenshot of them here.

you can do

from IPython.display import display
display(my_table_variable)