diff --git a/klayout_package/python/kqcircuits/chips/junction_test2.py b/klayout_package/python/kqcircuits/chips/junction_test2.py index 8a37604bf..cd186a85b 100644 --- a/klayout_package/python/kqcircuits/chips/junction_test2.py +++ b/klayout_package/python/kqcircuits/chips/junction_test2.py @@ -52,9 +52,6 @@ class JunctionTest2(Chip): default=["large", "large", "small", "small", "small", "large"], ) - def coerce_parameters_impl(self): - self.sync_parameters(JunctionTestPads) - def build(self): left = self.box.left right = self.box.right diff --git a/klayout_package/python/kqcircuits/elements/element.py b/klayout_package/python/kqcircuits/elements/element.py index da99879ec..a912aaa3f 100644 --- a/klayout_package/python/kqcircuits/elements/element.py +++ b/klayout_package/python/kqcircuits/elements/element.py @@ -19,15 +19,13 @@ import importlib import importlib.util -import json from inspect import isclass from kqcircuits.defaults import default_layers, default_faces, default_parameter_values -from kqcircuits.pya_resolver import pya, is_standalone_session +from kqcircuits.pya_resolver import pya from kqcircuits.simulations.epr.gui_config import epr_gui_visualised_partition_regions from kqcircuits.util.geometry_helper import get_cell_path_length -from kqcircuits.util.geometry_json_encoder import GeometryJsonDecoder, GeometryJsonEncoder -from kqcircuits.util.library_helper import load_libraries, to_library_name, to_module_name, element_by_class_name +from kqcircuits.util.library_helper import load_libraries, to_library_name, to_module_name from kqcircuits.util.parameters import Param, pdt from kqcircuits.util.refpoints import Refpoints @@ -262,12 +260,6 @@ def create_subtype(cls, layout, library=None, subtype=None, **parameters): subtype = to_library_name(cls.__name__) cl = cls._get_abstract() - module = to_module_name(cl.__name__) - pname = f"{module}_parameters" - if pname in parameters: - jp = dict(json.loads(parameters[pname], cls=GeometryJsonDecoder).items()) - del parameters[pname], parameters[f"_{pname}"] - parameters = {**jp, **parameters} if subtype in library_layout.pcell_names(): # code generated pcell_class = type(library_layout.pcell_declaration(subtype)) @@ -628,66 +620,6 @@ def add_protection(self, shape, face_id=0): self.cell.shapes(self.get_layer("ground_grid_avoidance", other_face)).insert(shape) break - def sync_parameters(self, abc): - """Syncronise the calling class' parameters with a JSON representation. - - This is called several times from coerce_parameters_impl() while using the PCell editor GUI. Particularly, each - time a parameter of abc's sub-class is changed by the user. It figures out which parameter is changed and - updates the ``*_parameters`` JSON strings accordingly, or the other way around. - - For example, if abc is Fluxline and the fluxline_width parameter is changed in GUI then the fluxline_parameters - JSON string will be updated with this value. Or if fluxline_parameters string is changed then the corresponding - fluxline parameter of the calling pcell is updated. - - Args: - abc: An abstract class. Only consider parameters of this class' descendants - """ - if is_standalone_session(): - return - - def pformat(a): - if a.data_type == pdt.TypeInt: - return int(a.default) - elif a.data_type == pdt.TypeDouble: - return float(a.default) - return a.default - - module = to_module_name(abc.__name__) - pname = f"{module}_parameters" - json_str = getattr(self, pname) - saved = getattr(self, f"_{pname}") - params = json.loads(json_str, cls=GeometryJsonDecoder) if json_str else {} - subtype = getattr(self, f"{module}_type") - pd = {} - - if subtype == "none": - return - if json_str == "{}" or params[f"{module}_type"] != subtype: # initialise defaults - if f"{module}_type" in params and json_str != saved and saved != {}: - subtype = params[f"{module}_type"] - setattr(self, f"{module}_type", subtype) - cls = element_by_class_name(subtype.replace(" ", ""), abc.LIBRARY_PATH, abc.LIBRARY_NAME) - schema = cls.get_schema(abstract_class=abc) - for k, v in schema.items(): - if not k.endswith("_parameters"): - pd[k] = getattr(self, k) if hasattr(self, k) else pformat(v) - json_str = json.dumps(pd, cls=GeometryJsonEncoder) - setattr(self, pname, json_str) - Param.get_all(abc)[pname].default = json_str - elif saved == json_str: # some parameters changed, update the JSON string - for k, v in params.items(): - pd[k] = getattr(self, k) if hasattr(self, k) else v - json_str = json.dumps(pd, cls=GeometryJsonEncoder) - setattr(self, pname, json_str) - else: # the JSON string changed, use it to update other parameters - for k, v in params.items(): - if k.startswith("_epr_"): - # Don't sync epr visualisation parameters - continue - if hasattr(self, k): - setattr(self, k, v) - setattr(self, f"_{pname}", json_str) - @classmethod def get_sim_ports(cls, simulation): # pylint: disable=unused-argument """List of RefpointToSimPort objects defining which refpoints diff --git a/klayout_package/python/kqcircuits/elements/fluxlines/fluxline.py b/klayout_package/python/kqcircuits/elements/fluxlines/fluxline.py index 9c685c138..a9e343f3d 100644 --- a/klayout_package/python/kqcircuits/elements/fluxlines/fluxline.py +++ b/klayout_package/python/kqcircuits/elements/fluxlines/fluxline.py @@ -33,17 +33,11 @@ class Fluxline(Element): fluxline_width = Param(pdt.TypeDouble, "Fluxline width", 18, unit="μm") fluxline_gap_width = Param(pdt.TypeDouble, "Fluxline gap width", 2, unit="μm") - fluxline_parameters = Param(pdt.TypeString, "Extra Fluxline Parameters", "{}") - _fluxline_parameters = Param(pdt.TypeString, "Previous state of *_parameters", "{}", hidden=True) - @classmethod def create(cls, layout, library=None, fluxline_type=None, **parameters): """Create a Fluxline cell in layout.""" return cls.create_subtype(layout, library, fluxline_type, **parameters)[0] - def coerce_parameters_impl(self): - self.sync_parameters(Fluxline) - def _insert_fluxline_shapes(self, left_gap, right_gap): """Inserts the gap shapes to the cell. diff --git a/klayout_package/python/kqcircuits/junctions/junction.py b/klayout_package/python/kqcircuits/junctions/junction.py index 745cb0d95..0dcda35cc 100644 --- a/klayout_package/python/kqcircuits/junctions/junction.py +++ b/klayout_package/python/kqcircuits/junctions/junction.py @@ -49,13 +49,8 @@ class Junction(Element): unit="μm", docstring="Junction width (only used for code generated element)", ) - junction_parameters = Param(pdt.TypeString, "Extra Junction Parameters", "{}") - _junction_parameters = Param(pdt.TypeString, "Previous state of *_parameters", "{}", hidden=True) @classmethod def create(cls, layout, library=None, junction_type=None, **parameters): """Create cell for a junction in layout.""" return cls.create_subtype(layout, library, junction_type, **parameters)[0] - - def coerce_parameters_impl(self): - self.sync_parameters(Junction) diff --git a/klayout_package/python/kqcircuits/qubits/qubit.py b/klayout_package/python/kqcircuits/qubits/qubit.py index d0910ca7e..deaaf2094 100644 --- a/klayout_package/python/kqcircuits/qubits/qubit.py +++ b/klayout_package/python/kqcircuits/qubits/qubit.py @@ -22,15 +22,12 @@ from kqcircuits.elements.fluxlines.fluxline import Fluxline from kqcircuits.pya_resolver import pya from kqcircuits.util.parameters import Param, pdt, add_parameters_from -from kqcircuits.junctions.junction import Junction from kqcircuits.junctions.squid import Squid from kqcircuits.junctions.sim import Sim -@add_parameters_from(Fluxline, "fluxline_type", "fluxline_parameters", "_fluxline_parameters") -@add_parameters_from( - Squid, "junction_width", "loop_area", "junction_type", "junction_parameters", "_junction_parameters" -) +@add_parameters_from(Fluxline, "fluxline_type") +@add_parameters_from(Squid, "junction_width", "loop_area", "junction_type") @add_parameters_from( Sim, "junction_total_length", @@ -69,10 +66,6 @@ class Qubit(Element): mirror_squid = Param(pdt.TypeBoolean, "Mirror SQUID by its Y axis", False) - def coerce_parameters_impl(self): - self.sync_parameters(Fluxline) - self.sync_parameters(Junction) - def produce_squid(self, transf, only_arms=False, **parameters): """Produces the squid. diff --git a/klayout_package/python/kqcircuits/test_structures/junction_test_pads/junction_test_pads.py b/klayout_package/python/kqcircuits/test_structures/junction_test_pads/junction_test_pads.py index 9c4e43ce9..e23a8cb18 100644 --- a/klayout_package/python/kqcircuits/test_structures/junction_test_pads/junction_test_pads.py +++ b/klayout_package/python/kqcircuits/test_structures/junction_test_pads/junction_test_pads.py @@ -26,13 +26,10 @@ from kqcircuits.defaults import default_junction_test_pads_type from kqcircuits.test_structures.junction_test_pads import junction_test_pads_type_choices from kqcircuits.junctions.manhattan import Manhattan -from kqcircuits.junctions.junction import Junction @add_parameters_from(Manhattan) -@add_parameters_from( - Qubit, "junction_type", "junction_width", "loop_area", "mirror_squid", "junction_parameters", "_junction_parameters" -) +@add_parameters_from(Qubit, "junction_type", "junction_width", "loop_area", "mirror_squid") class JunctionTestPads(TestStructure): """Base class for junction test structures.""" @@ -58,9 +55,6 @@ class JunctionTestPads(TestStructure): pdt.TypeString, "Type of junction test pads", default_type, choices=junction_test_pads_type_choices ) - junction_test_pads_parameters = Param(pdt.TypeString, "Extra JunctionTestPads Parameters", "{}") - _junction_test_pads_parameters = Param(pdt.TypeString, "Previous state of *_parameters", "{}", hidden=True) - produce_squid = Qubit.produce_squid @classmethod @@ -68,10 +62,6 @@ def create(cls, layout, library=None, junction_test_pads_type=None, **parameters """Create a JunctionTestPads cell in layout.""" return cls.create_subtype(layout, library, junction_test_pads_type, **parameters)[0] - def coerce_parameters_impl(self): - self.sync_parameters(Junction) - self.sync_parameters(JunctionTestPads) - def _produce_impl(self): if self.pad_configuration == "2-port": self._produce_two_port_junction_tests()