diff --git a/examples/use_configuration/import_ports.py b/examples/use_configuration/import_ports.py index 71ae8fc528..7776b5f25b 100644 --- a/examples/use_configuration/import_ports.py +++ b/examples/use_configuration/import_ports.py @@ -102,7 +102,7 @@ port_5 = {"name": "port_5", "reference_designator": "U1", "type": "coax", "positive_terminal": {"pin": "AM17"}} -# ## Add a port reference to the neareast pin +# ## Add a port reference to the nearest pin # Keywords # diff --git a/src/pyedb/configuration/configuration.py b/src/pyedb/configuration/configuration.py index 77ba84445d..22747d747c 100644 --- a/src/pyedb/configuration/configuration.py +++ b/src/pyedb/configuration/configuration.py @@ -74,7 +74,7 @@ def load(self, config_file, append=True, apply_file=False, output_file=None, ope elif config_file.endswith(".toml"): data = toml.load(f) else: # pragma: no cover - return False + raise RuntimeError(f"File {config_file} does not exist.") if not append: # pragma: no cover self.data = {} diff --git a/src/pyedb/dotnet/edb_core/edb_data/padstacks_data.py b/src/pyedb/dotnet/edb_core/edb_data/padstacks_data.py index 51ed532bf8..c0be7a6cb8 100644 --- a/src/pyedb/dotnet/edb_core/edb_data/padstacks_data.py +++ b/src/pyedb/dotnet/edb_core/edb_data/padstacks_data.py @@ -426,16 +426,32 @@ def __init__(self, edb_padstack, ppadstack): self._edb_object = edb_padstack self.edb_padstack = edb_padstack self._ppadstack = ppadstack - self.pad_by_layer = {} - self.antipad_by_layer = {} - self.thermalpad_by_layer = {} self._bounding_box = [] self._hole_params = None + + @property + def pad_by_layer(self): + """Regular pad property.""" + temp = {} + for layer in self.via_layers: + temp[layer] = EDBPadProperties(self._edb_object, layer, 0, self) + return temp + + @property + def antipad_by_layer(self): + """Anti pad property.""" + temp = {} + for layer in self.via_layers: + temp[layer] = EDBPadProperties(self._edb_object, layer, 1, self) + return temp + + @property + def thermalpad_by_layer(self): + """Thermal pad property.""" + temp = {} for layer in self.via_layers: - self.pad_by_layer[layer] = EDBPadProperties(edb_padstack, layer, 0, self) - self.antipad_by_layer[layer] = EDBPadProperties(edb_padstack, layer, 1, self) - self.thermalpad_by_layer[layer] = EDBPadProperties(edb_padstack, layer, 2, self) - pass + temp[layer] = EDBPadProperties(self._edb_object, layer, 2, self) + return temp @property def _padstack_def_data(self): diff --git a/src/pyedb/siwave.py b/src/pyedb/siwave.py index ea32afc5a4..8539bcfc92 100644 --- a/src/pyedb/siwave.py +++ b/src/pyedb/siwave.py @@ -15,6 +15,7 @@ import sys import tempfile import time +from typing import Optional, Union import warnings from pyedb import Edb @@ -53,6 +54,15 @@ def wait_export_folder(flag, folder_path, time_sleep=0.5): time.sleep(time_sleep) +def parser_file_path(file_path): + if isinstance(file_path, Path): + file_path = str(file_path) + + if not Path(file_path).root: + file_path = str(Path().cwd() / file_path) + return file_path + + class Siwave(object): # pragma no cover """Initializes SIwave based on the inputs provided and manages SIwave release and closing. @@ -264,9 +274,9 @@ def open_project(self, proj_path=None): ``True`` when successful, ``False`` when failed. """ - - if os.path.exists(proj_path): - open_result = self.oSiwave.OpenProject(proj_path) + file_path = parser_file_path(proj_path) + if os.path.exists(file_path): + open_result = self.oSiwave.OpenProject(file_path) self._oproject = self.oSiwave.GetActiveProject() return open_result else: @@ -306,6 +316,22 @@ def save_project(self, projectpath=None, projectName=None): self.oproject.Save() return True + def save(self, file_path: Optional[Union[str, Path]]): + """Save the project. + + Parameters + ---------- + file_path : str, optional + Full path to the project. The default is ``None``. + """ + + if file_path: + file_path = parser_file_path(file_path) + file_path = str(Path(file_path).with_suffix(".siw")) + self.oproject.ScrSaveProjectAs(file_path) + else: + self.oproject.Save() + def close_project(self, save_project=False): """Close the project. @@ -494,6 +520,8 @@ def import_edb(self, file_path: str): """ if isinstance(file_path, Path): file_path = str(file_path) + if not Path(file_path).root: + file_path = str(Path().cwd() / file_path) flag = self.oproject.ScrImportEDB(file_path) # self.save_project(self.di) if flag == 0: @@ -510,8 +538,7 @@ def load_configuration(self, file_path: str): file_path : str Path to the configuration file. """ - if isinstance(file_path, Path): - file_path = str(file_path) + file_path = parser_file_path(file_path) # temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") # temp_edb = os.path.join(temp_folder.name, "temp.aedb") @@ -536,8 +563,7 @@ def export_configuration(self, file_path: str): file_path : str Path to the configuration file. """ - if isinstance(file_path, Path): - file_path = str(file_path) + file_path = parser_file_path(file_path) temp_folder = tempfile.TemporaryDirectory(suffix=".ansys") temp_edb = os.path.join(temp_folder.name, "temp.aedb") diff --git a/tests/legacy/system/test_edb_configuration_2p0.py b/tests/legacy/system/test_edb_configuration_2p0.py index 551e0739f7..52306466cb 100644 --- a/tests/legacy/system/test_edb_configuration_2p0.py +++ b/tests/legacy/system/test_edb_configuration_2p0.py @@ -385,10 +385,28 @@ def test_05f_ports_between_two_points(self, edb_examples): edbapp.close() def test_06_s_parameters(self, edb_examples): - with open(self.local_input_folder / "s_parameter.json") as f: - data = json.load(f) - data["general"]["s_parameter_library"] = self.local_input_folder - + data = { + "general": {"s_parameter_library": self.local_input_folder}, + "s_parameters": [ + { + "name": "GRM32_DC0V_25degC_series", + "file_path": "GRM32_DC0V_25degC_series.s2p", + "component_definition": "CAPC3216X180X55ML20T25", + "apply_to_all": True, + "components": [], + "reference_net": "GND", + }, + { + "name": "GRM32_DC0V_25degC_series", + "file_path": "GRM32_DC0V_25degC_series.s2p", + "apply_to_all": False, + "component_definition": "CAPC3216X190X55ML30T25", + "components": ["C59"], + "reference_net": "GND", + "reference_net_per_component": {"C59": "GND"}, + }, + ], + } edbapp = edb_examples.get_si_verse() assert edbapp.configuration.load(data, apply_file=True) assert len(edbapp.components.nport_comp_definition) == 2