From bb424b6bf86e22c859c40f06e84f28b3f5a10602 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Tue, 27 Aug 2024 14:17:32 +0200 Subject: [PATCH 1/7] FIX: layer name --- src/pyedb/dotnet/edb.py | 4 ++-- src/pyedb/dotnet/edb_core/cell/primitive/primitive.py | 2 +- src/pyedb/dotnet/edb_core/modeler.py | 6 +++--- src/pyedb/dotnet/edb_core/stackup.py | 2 +- tests/legacy/system/test_edb_ipc.py | 4 ++++ 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/pyedb/dotnet/edb.py b/src/pyedb/dotnet/edb.py index 0e63159595..7bdd3ab233 100644 --- a/src/pyedb/dotnet/edb.py +++ b/src/pyedb/dotnet/edb.py @@ -2353,9 +2353,9 @@ def clean_prim(prim_1): # pragma: no cover list_prims = subtract(p, voids_data) for prim in list_prims: if not prim.IsNull(): - poly_to_create.append([prim, prim_1.layer.name, net, list_void]) + poly_to_create.append([prim, prim_1._edb_object.GetLayer().GetName(), net, list_void]) else: - poly_to_create.append([p, prim_1.layer.name, net, list_void]) + poly_to_create.append([p, prim_1._edb_object.GetLayer().GetName(), net, list_void]) prims_to_delete.append(prim_1) diff --git a/src/pyedb/dotnet/edb_core/cell/primitive/primitive.py b/src/pyedb/dotnet/edb_core/cell/primitive/primitive.py index 4cc95ab87a..afa6e38b89 100644 --- a/src/pyedb/dotnet/edb_core/cell/primitive/primitive.py +++ b/src/pyedb/dotnet/edb_core/cell/primitive/primitive.py @@ -125,7 +125,7 @@ def layer_name(self): str """ try: - return self.layer.name + return self._edb_object.GetLayer().GetName() except (KeyError, AttributeError): # pragma: no cover return None diff --git a/src/pyedb/dotnet/edb_core/modeler.py b/src/pyedb/dotnet/edb_core/modeler.py index bed4e89d5f..a287475fed 100644 --- a/src/pyedb/dotnet/edb_core/modeler.py +++ b/src/pyedb/dotnet/edb_core/modeler.py @@ -188,7 +188,7 @@ def primitives_by_layer(self): for lay in self._pedb.stackup.non_stackup_layers: _primitives_by_layer[lay] = [] for i in self._layout.primitives: - lay = i.layer.name + lay = i._edb_object.GetLayer().GetName() if lay in _primitives_by_layer: _primitives_by_layer[lay].append(i) return _primitives_by_layer @@ -256,7 +256,7 @@ def get_polygons_by_layer(self, layer_name, net_list=None): """ objinst = [] for el in self.polygons: - if el.layer.name == layer_name: + if el._edb_object.GetLayer().GetName() == layer_name: if net_list and el.net.name in net_list: objinst.append(el) else: @@ -1184,7 +1184,7 @@ def parametrize_trace_width( parameter_name, variable_value, is_parameter=True ) p.width = self._pedb.edb_value(parameter_name) - elif p.layer.name in layers_name: + elif p._edb_object.GetLayer().GetName() in layers_name: if not var_server: if not variable_value: variable_value = p.width diff --git a/src/pyedb/dotnet/edb_core/stackup.py b/src/pyedb/dotnet/edb_core/stackup.py index 2af9f92350..34b5e2930f 100644 --- a/src/pyedb/dotnet/edb_core/stackup.py +++ b/src/pyedb/dotnet/edb_core/stackup.py @@ -1800,7 +1800,7 @@ def residual_copper_area_per_layer(self): temp_data = {name: 0 for name, _ in self.signal_layers.items()} outline_area = 0 for i in self._pedb.modeler.primitives: - layer_name = i.layer.name + layer_name = i._edb_object.GetLayer().GetName() if layer_name.lower() == "outline": if i.area() > outline_area: outline_area = i.area() diff --git a/tests/legacy/system/test_edb_ipc.py b/tests/legacy/system/test_edb_ipc.py index 26b9ffc3b6..04f7e716c1 100644 --- a/tests/legacy/system/test_edb_ipc.py +++ b/tests/legacy/system/test_edb_ipc.py @@ -50,7 +50,11 @@ def test_export_to_ipc2581_0(self): self.local_scratch.copyfolder(source_path, target_path) edbapp = Edb(target_path, edbversion=desktop_version) xml_file = os.path.join(self.local_scratch.path, "test.xml") + from datetime import datetime + + now = datetime.now() edbapp.export_to_ipc2581(xml_file) + print(datetime.now() - now) assert os.path.exists(xml_file) # Export should be made with units set to default -millimeter-. From dbb44744499cfd5a8e3b780aa8b21933fb78bf43 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Tue, 27 Aug 2024 14:19:01 +0200 Subject: [PATCH 2/7] revert --- tests/legacy/system/test_edb_ipc.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/legacy/system/test_edb_ipc.py b/tests/legacy/system/test_edb_ipc.py index 04f7e716c1..26b9ffc3b6 100644 --- a/tests/legacy/system/test_edb_ipc.py +++ b/tests/legacy/system/test_edb_ipc.py @@ -50,11 +50,7 @@ def test_export_to_ipc2581_0(self): self.local_scratch.copyfolder(source_path, target_path) edbapp = Edb(target_path, edbversion=desktop_version) xml_file = os.path.join(self.local_scratch.path, "test.xml") - from datetime import datetime - - now = datetime.now() edbapp.export_to_ipc2581(xml_file) - print(datetime.now() - now) assert os.path.exists(xml_file) # Export should be made with units set to default -millimeter-. From ac4689573274a68778f036163e73be0faf18a21b Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Wed, 28 Aug 2024 10:49:37 +0200 Subject: [PATCH 3/7] fix --- src/pyedb/dotnet/edb.py | 4 ++-- .../dotnet/edb_core/cell/primitive/primitive.py | 4 ++-- src/pyedb/dotnet/edb_core/edb_data/layer_data.py | 7 +++++++ src/pyedb/dotnet/edb_core/modeler.py | 6 +++--- src/pyedb/dotnet/edb_core/stackup.py | 16 +++++++++++----- tests/legacy/system/test_edb_ipc.py | 4 ++++ 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/pyedb/dotnet/edb.py b/src/pyedb/dotnet/edb.py index 7bdd3ab233..0e63159595 100644 --- a/src/pyedb/dotnet/edb.py +++ b/src/pyedb/dotnet/edb.py @@ -2353,9 +2353,9 @@ def clean_prim(prim_1): # pragma: no cover list_prims = subtract(p, voids_data) for prim in list_prims: if not prim.IsNull(): - poly_to_create.append([prim, prim_1._edb_object.GetLayer().GetName(), net, list_void]) + poly_to_create.append([prim, prim_1.layer.name, net, list_void]) else: - poly_to_create.append([p, prim_1._edb_object.GetLayer().GetName(), net, list_void]) + poly_to_create.append([p, prim_1.layer.name, net, list_void]) prims_to_delete.append(prim_1) diff --git a/src/pyedb/dotnet/edb_core/cell/primitive/primitive.py b/src/pyedb/dotnet/edb_core/cell/primitive/primitive.py index afa6e38b89..cd48350603 100644 --- a/src/pyedb/dotnet/edb_core/cell/primitive/primitive.py +++ b/src/pyedb/dotnet/edb_core/cell/primitive/primitive.py @@ -114,7 +114,7 @@ def net_name(self, name): def layer(self): """Get the primitive edb layer object.""" layer_name = self._edb_object.GetLayer().GetName() - return self._pedb.stackup.all_layers[layer_name] + return self._pedb.stackup.find_layer_by_name(layer_name) @property def layer_name(self): @@ -125,7 +125,7 @@ def layer_name(self): str """ try: - return self._edb_object.GetLayer().GetName() + return self.layer.name except (KeyError, AttributeError): # pragma: no cover return None diff --git a/src/pyedb/dotnet/edb_core/edb_data/layer_data.py b/src/pyedb/dotnet/edb_core/edb_data/layer_data.py index 56a0cb427a..878fcac7f0 100644 --- a/src/pyedb/dotnet/edb_core/edb_data/layer_data.py +++ b/src/pyedb/dotnet/edb_core/edb_data/layer_data.py @@ -23,6 +23,13 @@ from __future__ import absolute_import +def layer_cast(pedb, edb_object): + if edb_object.IsStackupLayer(): + return StackupLayerEdbClass(pedb, edb_object.Clone(), name=edb_object.GetName()) + else: + return LayerEdbClass(pedb, edb_object.Clone(), name=edb_object.GetName()) + + class LayerEdbClass(object): """Manages Edb Layers. Replaces EDBLayer.""" diff --git a/src/pyedb/dotnet/edb_core/modeler.py b/src/pyedb/dotnet/edb_core/modeler.py index a287475fed..bed4e89d5f 100644 --- a/src/pyedb/dotnet/edb_core/modeler.py +++ b/src/pyedb/dotnet/edb_core/modeler.py @@ -188,7 +188,7 @@ def primitives_by_layer(self): for lay in self._pedb.stackup.non_stackup_layers: _primitives_by_layer[lay] = [] for i in self._layout.primitives: - lay = i._edb_object.GetLayer().GetName() + lay = i.layer.name if lay in _primitives_by_layer: _primitives_by_layer[lay].append(i) return _primitives_by_layer @@ -256,7 +256,7 @@ def get_polygons_by_layer(self, layer_name, net_list=None): """ objinst = [] for el in self.polygons: - if el._edb_object.GetLayer().GetName() == layer_name: + if el.layer.name == layer_name: if net_list and el.net.name in net_list: objinst.append(el) else: @@ -1184,7 +1184,7 @@ def parametrize_trace_width( parameter_name, variable_value, is_parameter=True ) p.width = self._pedb.edb_value(parameter_name) - elif p._edb_object.GetLayer().GetName() in layers_name: + elif p.layer.name in layers_name: if not var_server: if not variable_value: variable_value = p.width diff --git a/src/pyedb/dotnet/edb_core/stackup.py b/src/pyedb/dotnet/edb_core/stackup.py index 34b5e2930f..070c860c5c 100644 --- a/src/pyedb/dotnet/edb_core/stackup.py +++ b/src/pyedb/dotnet/edb_core/stackup.py @@ -34,6 +34,7 @@ import warnings from pyedb.dotnet.edb_core.edb_data.layer_data import ( + layer_cast, LayerEdbClass, StackupLayerEdbClass, ) @@ -284,10 +285,7 @@ def all_layers(self): layer_list = list(self._edb_object.Layers(self._pedb.edb_api.cell.layer_type_set.AllLayerSet)) temp = dict() for i in layer_list: - if i.IsStackupLayer(): - obj = StackupLayerEdbClass(self._pedb, i.Clone(), name=i.GetName()) - else: - obj = LayerEdbClass(self._pedb, i.Clone(), name=i.GetName()) + obj = layer_cast(self._pedb, i) temp[obj.name] = obj return temp @@ -306,12 +304,20 @@ def layers(self): """ return {name: obj for name, obj in self.all_layers.items() if obj.is_stackup_layer} + def find_layer_by_name(self, name: str): + """Finds a layer in a layer with given name. """ + obj = self._pedb.edb_api.cell._cell.Layer.FindByName(self._edb_object, name) + if obj.IsNull(): + raise ValueError("Layer with name '{}' was not found.".format(name)) + else: + return layer_cast(self._pedb, obj.Clone()) + class Stackup(LayerCollection): """Manages EDB methods for stackup accessible from `Edb.stackup` property.""" def __getitem__(self, item): - return self.all_layers[item] + return self.find_layer_by_name(item) def __init__(self, pedb, edb_object=None): super().__init__(pedb, edb_object) diff --git a/tests/legacy/system/test_edb_ipc.py b/tests/legacy/system/test_edb_ipc.py index 26b9ffc3b6..04f7e716c1 100644 --- a/tests/legacy/system/test_edb_ipc.py +++ b/tests/legacy/system/test_edb_ipc.py @@ -50,7 +50,11 @@ def test_export_to_ipc2581_0(self): self.local_scratch.copyfolder(source_path, target_path) edbapp = Edb(target_path, edbversion=desktop_version) xml_file = os.path.join(self.local_scratch.path, "test.xml") + from datetime import datetime + + now = datetime.now() edbapp.export_to_ipc2581(xml_file) + print(datetime.now() - now) assert os.path.exists(xml_file) # Export should be made with units set to default -millimeter-. From 1c1e673ba05cd2edd258883fbccbeacbe19444dd Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Wed, 28 Aug 2024 11:06:28 +0200 Subject: [PATCH 4/7] FIX --- tests/legacy/system/test_edb_ipc.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/legacy/system/test_edb_ipc.py b/tests/legacy/system/test_edb_ipc.py index 04f7e716c1..26b9ffc3b6 100644 --- a/tests/legacy/system/test_edb_ipc.py +++ b/tests/legacy/system/test_edb_ipc.py @@ -50,11 +50,7 @@ def test_export_to_ipc2581_0(self): self.local_scratch.copyfolder(source_path, target_path) edbapp = Edb(target_path, edbversion=desktop_version) xml_file = os.path.join(self.local_scratch.path, "test.xml") - from datetime import datetime - - now = datetime.now() edbapp.export_to_ipc2581(xml_file) - print(datetime.now() - now) assert os.path.exists(xml_file) # Export should be made with units set to default -millimeter-. From 3124736917118de4ccb758bccc84291864eb47f5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 09:42:30 +0000 Subject: [PATCH 5/7] MISC: Auto fixes from pre-commit.com hooks For more information, see https://pre-commit.ci --- src/pyedb/dotnet/edb_core/stackup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pyedb/dotnet/edb_core/stackup.py b/src/pyedb/dotnet/edb_core/stackup.py index 070c860c5c..8c27115c94 100644 --- a/src/pyedb/dotnet/edb_core/stackup.py +++ b/src/pyedb/dotnet/edb_core/stackup.py @@ -34,9 +34,9 @@ import warnings from pyedb.dotnet.edb_core.edb_data.layer_data import ( - layer_cast, LayerEdbClass, StackupLayerEdbClass, + layer_cast, ) from pyedb.dotnet.edb_core.general import convert_py_list_to_net_list from pyedb.generic.general_methods import ET, generate_unique_name @@ -305,7 +305,7 @@ def layers(self): return {name: obj for name, obj in self.all_layers.items() if obj.is_stackup_layer} def find_layer_by_name(self, name: str): - """Finds a layer in a layer with given name. """ + """Finds a layer in a layer with given name.""" obj = self._pedb.edb_api.cell._cell.Layer.FindByName(self._edb_object, name) if obj.IsNull(): raise ValueError("Layer with name '{}' was not found.".format(name)) From ce74369be468e74252d231b519cb253d1070a149 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Wed, 28 Aug 2024 11:54:41 +0200 Subject: [PATCH 6/7] fix: docstring --- src/pyedb/dotnet/edb_core/stackup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyedb/dotnet/edb_core/stackup.py b/src/pyedb/dotnet/edb_core/stackup.py index 8c27115c94..a6a332cf5e 100644 --- a/src/pyedb/dotnet/edb_core/stackup.py +++ b/src/pyedb/dotnet/edb_core/stackup.py @@ -305,7 +305,7 @@ def layers(self): return {name: obj for name, obj in self.all_layers.items() if obj.is_stackup_layer} def find_layer_by_name(self, name: str): - """Finds a layer in a layer with given name.""" + """Finds a layer with the given name.""" obj = self._pedb.edb_api.cell._cell.Layer.FindByName(self._edb_object, name) if obj.IsNull(): raise ValueError("Layer with name '{}' was not found.".format(name)) From 5ff5fbe79f652115145a728bfcd249893ef4d1fe Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Wed, 28 Aug 2024 13:44:30 +0200 Subject: [PATCH 7/7] fix --- src/pyedb/dotnet/edb_core/cell/primitive/primitive.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pyedb/dotnet/edb_core/cell/primitive/primitive.py b/src/pyedb/dotnet/edb_core/cell/primitive/primitive.py index cd48350603..aaf2a9252c 100644 --- a/src/pyedb/dotnet/edb_core/cell/primitive/primitive.py +++ b/src/pyedb/dotnet/edb_core/cell/primitive/primitive.py @@ -113,8 +113,11 @@ def net_name(self, name): @property def layer(self): """Get the primitive edb layer object.""" - layer_name = self._edb_object.GetLayer().GetName() - return self._pedb.stackup.find_layer_by_name(layer_name) + obj = self._edb_object.GetLayer() + if obj.IsNull(): + return None + else: + return self._pedb.stackup.find_layer_by_name(obj.GetName()) @property def layer_name(self):