From 075fa4f5ce107b0afd4a4dac6677232d69734698 Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Tue, 11 Mar 2025 16:25:47 +0100 Subject: [PATCH 1/4] materials.py --- src/pyedb/dotnet/edb_core/materials.py | 15 +++++++++++++++ tests/legacy/system/test_edb_materials.py | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/src/pyedb/dotnet/edb_core/materials.py b/src/pyedb/dotnet/edb_core/materials.py index 5d553f8e64..4a43ff0fb5 100644 --- a/src/pyedb/dotnet/edb_core/materials.py +++ b/src/pyedb/dotnet/edb_core/materials.py @@ -1043,3 +1043,18 @@ def read_syslib_material(self, material_name): self.__edb.logger.error(f"Material {material_name} does not exist in syslib AMAT file.") return res + + def update_materials_from_syslibrary(self, update_all:bool=True, material_name: Union[str, list]=None): + """Update material properties from syslib AMAT file.""" + amat_file = os.path.join(self.__edb.base_path, "syslib", "Materials.amat") + materials_dict = self.read_materials(amat_file) + if update_all: + for name, obj in self.materials.items(): + if name in materials_dict: + obj.update(materials_dict[name]) + self.__edb.logger.info(f"Material {name} is updated from syslibrary.") + else: + material_names = material_name if isinstance(material_name, list) else [material_name] + for name in material_names: + self.materials[name].update(materials_dict[name]) + self.__edb.logger.info(f"Material {name} is updated from syslibrary.") diff --git a/tests/legacy/system/test_edb_materials.py b/tests/legacy/system/test_edb_materials.py index fc6ab5d18a..387213d4da 100644 --- a/tests/legacy/system/test_edb_materials.py +++ b/tests/legacy/system/test_edb_materials.py @@ -346,3 +346,12 @@ def test_materials_load_dielectric_material(self): assert 0.00045 == material.loss_tangent assert 0.00045 == material.dielectric_loss_tangent assert 12 == material.permittivity + + def test_update_materials_from_syslib(self, edb_examples): + edbapp = edb_examples.get_si_verse() + edbapp.materials.update_materials_from_syslibrary(False, "copper") + assert edbapp.materials["copper"].thermal_conductivity == 400 + edbapp.materials["FR4_epoxy"].thermal_conductivity = 1 + edbapp.materials.update_materials_from_syslibrary() + edbapp.materials["FR4_epoxy"].thermal_conductivity = 0.294 + edbapp.close() From 7ac80cbec70ddc2c1e0f18effd92dd5f68b55085 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Mar 2025 15:30:23 +0000 Subject: [PATCH 2/4] MISC: Auto fixes from pre-commit.com hooks For more information, see https://pre-commit.ci --- src/pyedb/dotnet/edb_core/materials.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pyedb/dotnet/edb_core/materials.py b/src/pyedb/dotnet/edb_core/materials.py index 4a43ff0fb5..9d3caf6cfd 100644 --- a/src/pyedb/dotnet/edb_core/materials.py +++ b/src/pyedb/dotnet/edb_core/materials.py @@ -1044,9 +1044,9 @@ def read_syslib_material(self, material_name): self.__edb.logger.error(f"Material {material_name} does not exist in syslib AMAT file.") return res - def update_materials_from_syslibrary(self, update_all:bool=True, material_name: Union[str, list]=None): + def update_materials_from_syslibrary(self, update_all: bool = True, material_name: Union[str, list] = None): """Update material properties from syslib AMAT file.""" - amat_file = os.path.join(self.__edb.base_path, "syslib", "Materials.amat") + amat_file = os.path.join(self.__edb.base_path, "syslib", "Materials.amat") materials_dict = self.read_materials(amat_file) if update_all: for name, obj in self.materials.items(): From b07dd871796ee9d69e2b08c5a3928c6a814f6070 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Tue, 11 Mar 2025 16:44:46 +0100 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: svandenb-dev <74993647+svandenb-dev@users.noreply.github.com> --- src/pyedb/dotnet/edb_core/materials.py | 2 +- tests/legacy/system/test_edb_materials.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pyedb/dotnet/edb_core/materials.py b/src/pyedb/dotnet/edb_core/materials.py index 9d3caf6cfd..cb093d09c1 100644 --- a/src/pyedb/dotnet/edb_core/materials.py +++ b/src/pyedb/dotnet/edb_core/materials.py @@ -1044,7 +1044,7 @@ def read_syslib_material(self, material_name): self.__edb.logger.error(f"Material {material_name} does not exist in syslib AMAT file.") return res - def update_materials_from_syslibrary(self, update_all: bool = True, material_name: Union[str, list] = None): + def update_materials_from_sys_library(self, update_all: bool = True, material_name: Union[str, list] = None): """Update material properties from syslib AMAT file.""" amat_file = os.path.join(self.__edb.base_path, "syslib", "Materials.amat") materials_dict = self.read_materials(amat_file) diff --git a/tests/legacy/system/test_edb_materials.py b/tests/legacy/system/test_edb_materials.py index 387213d4da..abeb422c44 100644 --- a/tests/legacy/system/test_edb_materials.py +++ b/tests/legacy/system/test_edb_materials.py @@ -352,6 +352,6 @@ def test_update_materials_from_syslib(self, edb_examples): edbapp.materials.update_materials_from_syslibrary(False, "copper") assert edbapp.materials["copper"].thermal_conductivity == 400 edbapp.materials["FR4_epoxy"].thermal_conductivity = 1 - edbapp.materials.update_materials_from_syslibrary() + edbapp.materials.update_materials_from_sys_library() edbapp.materials["FR4_epoxy"].thermal_conductivity = 0.294 edbapp.close() From 6a2bbb90fb06432cbaaeaeb3867558acc1b2884a Mon Sep 17 00:00:00 2001 From: ring630 <@gmail.com> Date: Wed, 12 Mar 2025 10:43:34 +0100 Subject: [PATCH 4/4] minor fix --- tests/legacy/system/test_edb_materials.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/legacy/system/test_edb_materials.py b/tests/legacy/system/test_edb_materials.py index abeb422c44..6855bb4e3b 100644 --- a/tests/legacy/system/test_edb_materials.py +++ b/tests/legacy/system/test_edb_materials.py @@ -349,7 +349,7 @@ def test_materials_load_dielectric_material(self): def test_update_materials_from_syslib(self, edb_examples): edbapp = edb_examples.get_si_verse() - edbapp.materials.update_materials_from_syslibrary(False, "copper") + edbapp.materials.update_materials_from_sys_library(False, "copper") assert edbapp.materials["copper"].thermal_conductivity == 400 edbapp.materials["FR4_epoxy"].thermal_conductivity = 1 edbapp.materials.update_materials_from_sys_library()