Skip to content

Commit fab2292

Browse files
FIX: padstack and siwave (#792)
* fix * docstring * MISC: Auto fixes from pre-commit.com hooks For more information, see https://pre-commit.ci --------- Co-authored-by: ring630 <@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8bab672 commit fab2292

File tree

5 files changed

+80
-20
lines changed

5 files changed

+80
-20
lines changed

examples/use_configuration/import_ports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102

103103
port_5 = {"name": "port_5", "reference_designator": "U1", "type": "coax", "positive_terminal": {"pin": "AM17"}}
104104

105-
# ## Add a port reference to the neareast pin
105+
# ## Add a port reference to the nearest pin
106106

107107
# Keywords
108108
#

src/pyedb/configuration/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def load(self, config_file, append=True, apply_file=False, output_file=None, ope
7474
elif config_file.endswith(".toml"):
7575
data = toml.load(f)
7676
else: # pragma: no cover
77-
return False
77+
raise RuntimeError(f"File {config_file} does not exist.")
7878

7979
if not append: # pragma: no cover
8080
self.data = {}

src/pyedb/dotnet/edb_core/edb_data/padstacks_data.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,16 +426,32 @@ def __init__(self, edb_padstack, ppadstack):
426426
self._edb_object = edb_padstack
427427
self.edb_padstack = edb_padstack
428428
self._ppadstack = ppadstack
429-
self.pad_by_layer = {}
430-
self.antipad_by_layer = {}
431-
self.thermalpad_by_layer = {}
432429
self._bounding_box = []
433430
self._hole_params = None
431+
432+
@property
433+
def pad_by_layer(self):
434+
"""Regular pad property."""
435+
temp = {}
436+
for layer in self.via_layers:
437+
temp[layer] = EDBPadProperties(self._edb_object, layer, 0, self)
438+
return temp
439+
440+
@property
441+
def antipad_by_layer(self):
442+
"""Anti pad property."""
443+
temp = {}
444+
for layer in self.via_layers:
445+
temp[layer] = EDBPadProperties(self._edb_object, layer, 1, self)
446+
return temp
447+
448+
@property
449+
def thermalpad_by_layer(self):
450+
"""Thermal pad property."""
451+
temp = {}
434452
for layer in self.via_layers:
435-
self.pad_by_layer[layer] = EDBPadProperties(edb_padstack, layer, 0, self)
436-
self.antipad_by_layer[layer] = EDBPadProperties(edb_padstack, layer, 1, self)
437-
self.thermalpad_by_layer[layer] = EDBPadProperties(edb_padstack, layer, 2, self)
438-
pass
453+
temp[layer] = EDBPadProperties(self._edb_object, layer, 2, self)
454+
return temp
439455

440456
@property
441457
def _padstack_def_data(self):

src/pyedb/siwave.py

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import sys
1616
import tempfile
1717
import time
18+
from typing import Optional, Union
1819
import warnings
1920

2021
from pyedb import Edb
@@ -53,6 +54,15 @@ def wait_export_folder(flag, folder_path, time_sleep=0.5):
5354
time.sleep(time_sleep)
5455

5556

57+
def parser_file_path(file_path):
58+
if isinstance(file_path, Path):
59+
file_path = str(file_path)
60+
61+
if not Path(file_path).root:
62+
file_path = str(Path().cwd() / file_path)
63+
return file_path
64+
65+
5666
class Siwave(object): # pragma no cover
5767
"""Initializes SIwave based on the inputs provided and manages SIwave release and closing.
5868
@@ -264,9 +274,9 @@ def open_project(self, proj_path=None):
264274
``True`` when successful, ``False`` when failed.
265275
266276
"""
267-
268-
if os.path.exists(proj_path):
269-
open_result = self.oSiwave.OpenProject(proj_path)
277+
file_path = parser_file_path(proj_path)
278+
if os.path.exists(file_path):
279+
open_result = self.oSiwave.OpenProject(file_path)
270280
self._oproject = self.oSiwave.GetActiveProject()
271281
return open_result
272282
else:
@@ -306,6 +316,22 @@ def save_project(self, projectpath=None, projectName=None):
306316
self.oproject.Save()
307317
return True
308318

319+
def save(self, file_path: Optional[Union[str, Path]]):
320+
"""Save the project.
321+
322+
Parameters
323+
----------
324+
file_path : str, optional
325+
Full path to the project. The default is ``None``.
326+
"""
327+
328+
if file_path:
329+
file_path = parser_file_path(file_path)
330+
file_path = str(Path(file_path).with_suffix(".siw"))
331+
self.oproject.ScrSaveProjectAs(file_path)
332+
else:
333+
self.oproject.Save()
334+
309335
def close_project(self, save_project=False):
310336
"""Close the project.
311337
@@ -494,6 +520,8 @@ def import_edb(self, file_path: str):
494520
"""
495521
if isinstance(file_path, Path):
496522
file_path = str(file_path)
523+
if not Path(file_path).root:
524+
file_path = str(Path().cwd() / file_path)
497525
flag = self.oproject.ScrImportEDB(file_path)
498526
# self.save_project(self.di)
499527
if flag == 0:
@@ -510,8 +538,7 @@ def load_configuration(self, file_path: str):
510538
file_path : str
511539
Path to the configuration file.
512540
"""
513-
if isinstance(file_path, Path):
514-
file_path = str(file_path)
541+
file_path = parser_file_path(file_path)
515542

516543
# temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
517544
# temp_edb = os.path.join(temp_folder.name, "temp.aedb")
@@ -536,8 +563,7 @@ def export_configuration(self, file_path: str):
536563
file_path : str
537564
Path to the configuration file.
538565
"""
539-
if isinstance(file_path, Path):
540-
file_path = str(file_path)
566+
file_path = parser_file_path(file_path)
541567

542568
temp_folder = tempfile.TemporaryDirectory(suffix=".ansys")
543569
temp_edb = os.path.join(temp_folder.name, "temp.aedb")

tests/legacy/system/test_edb_configuration_2p0.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,28 @@ def test_05f_ports_between_two_points(self, edb_examples):
385385
edbapp.close()
386386

387387
def test_06_s_parameters(self, edb_examples):
388-
with open(self.local_input_folder / "s_parameter.json") as f:
389-
data = json.load(f)
390-
data["general"]["s_parameter_library"] = self.local_input_folder
391-
388+
data = {
389+
"general": {"s_parameter_library": self.local_input_folder},
390+
"s_parameters": [
391+
{
392+
"name": "GRM32_DC0V_25degC_series",
393+
"file_path": "GRM32_DC0V_25degC_series.s2p",
394+
"component_definition": "CAPC3216X180X55ML20T25",
395+
"apply_to_all": True,
396+
"components": [],
397+
"reference_net": "GND",
398+
},
399+
{
400+
"name": "GRM32_DC0V_25degC_series",
401+
"file_path": "GRM32_DC0V_25degC_series.s2p",
402+
"apply_to_all": False,
403+
"component_definition": "CAPC3216X190X55ML30T25",
404+
"components": ["C59"],
405+
"reference_net": "GND",
406+
"reference_net_per_component": {"C59": "GND"},
407+
},
408+
],
409+
}
392410
edbapp = edb_examples.get_si_verse()
393411
assert edbapp.configuration.load(data, apply_file=True)
394412
assert len(edbapp.components.nport_comp_definition) == 2

0 commit comments

Comments
 (0)