Skip to content

Commit

Permalink
first test added
Browse files Browse the repository at this point in the history
  • Loading branch information
svandenb-dev committed Nov 6, 2023
1 parent f65c708 commit ee83564
Show file tree
Hide file tree
Showing 37 changed files with 7,613 additions and 3,161 deletions.
2 changes: 1 addition & 1 deletion src/pyedb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

# By default we use pyedb legacy implementation
if "PYEDB_USE_LEGACY" not in os.environ:
os.environ["PYEDB_USE_LEGACY"] = "1"
os.environ["PYEDB_USE_LEGACY"] = "0"

from pyedb.generic.design_types import Edb
35 changes: 17 additions & 18 deletions src/pyedb/generic/general_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class MethodNotSupportedError(Exception):

pass


def _exception(ex_info, func, args, kwargs, message="Type Error"):
"""Write the trace stack to the desktop when a Python error occurs.
Expand Down Expand Up @@ -122,6 +123,7 @@ def _exception(ex_info, func, args, kwargs, message="Type Error"):
)
)


def _function_handler_wrapper(user_function):
def wrapper(*args, **kwargs):
if not settings.enable_error_handler:
Expand Down Expand Up @@ -158,8 +160,10 @@ def wrapper(*args, **kwargs):
except IOError:
_exception(sys.exc_info(), user_function, args, kwargs, "IO Error")
return False

return wrapper


def pyedb_function_handler(direct_func=None):
"""Provides an exception handler, logging mechanism, and argument converter for client-server
communications.
Expand Down Expand Up @@ -200,6 +204,7 @@ def get_filename_without_extension(path):
"""
return os.path.splitext(os.path.split(path)[1])[0]


def _write_mes(mes_text):
mes_text = str(mes_text)
parts = [mes_text[i: i + 250] for i in range(0, len(mes_text), 250)]
Expand Down Expand Up @@ -496,7 +501,7 @@ def open_file(file_path, file_options="r"):
if os.path.exists(file_path):
return open(file_path, file_options)
elif settings.remote_rpc_session and settings.remote_rpc_session.filemanager.pathexists(
file_path
file_path
): # pragma: no cover
local_file = os.path.join(tempfile.gettempdir(), os.path.split(file_path)[-1])
settings.remote_rpc_session.filemanager.download_file(file_path, local_file)
Expand All @@ -506,6 +511,7 @@ def open_file(file_path, file_options="r"):
else:
settings.logger.error("The file or folder %s does not exist", dir_name)


@pyedb_function_handler()
def get_string_version(input_version):
output_version = input_version
Expand All @@ -524,10 +530,6 @@ def get_string_version(input_version):
return output_version






@pyedb_function_handler()
def env_path_student(input_version):
"""Get the path of the version environment variable for an AEDT student version.
Expand Down Expand Up @@ -579,7 +581,6 @@ def env_value_student(input_version):
)



@pyedb_function_handler()
def generate_unique_folder_name(rootname=None, folder_name=None):
"""Generate a new AEDT folder name given a rootname.
Expand Down Expand Up @@ -1299,22 +1300,22 @@ def compute_fft(time_vals, value): # pragma: no cover
num_points = len(time_vals)
valueFFT = np.fft.fft(value, num_points)
Npoints = int(len(valueFFT) / 2)
valueFFT = valueFFT[1 : Npoints + 1]
valueFFT = valueFFT[1: Npoints + 1]
valueFFT = valueFFT / len(valueFFT)
n = np.arange(num_points)
freq = n / deltaT
return freq, valueFFT


def parse_excitation_file(
file_name,
is_time_domain=True,
x_scale=1,
y_scale=1,
impedance=50,
data_format="Power",
encoding="utf-8",
out_mag="Voltage",
file_name,
is_time_domain=True,
x_scale=1,
y_scale=1,
impedance=50,
data_format="Power",
encoding="utf-8",
out_mag="Voltage",
):
"""Parse a csv file and convert data in list that can be applied to Hfss and Hfss3dLayout sources.
Expand Down Expand Up @@ -1599,7 +1600,7 @@ def _arg2dict(arg, dict_out):
i = 1
while i < len(arg):
if arg[i][0][:5] == "NAME:" and (
isinstance(arg[i], (list, tuple)) or str(type(arg[i])) == r"<type 'List'>"
isinstance(arg[i], (list, tuple)) or str(type(arg[i])) == r"<type 'List'>"
):
_arg2dict(list(arg[i]), dict_in)
i += 1
Expand Down Expand Up @@ -1875,5 +1876,3 @@ def developer_forum(self):
# property = Property

online_help = Help()


29 changes: 16 additions & 13 deletions src/pyedb/grpc/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def get_component_by_name(self, name):
``True`` when successful, ``False`` when failed.
"""
edbcmp = self._pedb.cell.hierarchy.group.find(self._active_layout, name)
edbcmp = hierarchy.ComponentGroup.find(self._edb.layout, name)
if edbcmp:
return edbcmp
else:
Expand Down Expand Up @@ -1495,12 +1495,12 @@ def create_pingroup_from_pins(self, pins, group_name=None):
if _pins:
pins = _pins
if not group_name:
group_name = hierarchy.PinGroup.unique_name(self._active_layout)
group_name = hierarchy.PinGroup.unique_name(self._edb.layout, "")
for pin in pins:
pin.is_layout_pin = True
forbiden_car = "-><"
group_name = group_name.translate({ord(i): "_" for i in forbiden_car})
for pgroup in list(self._pedb.active_layout.pin_groups):
for pgroup in self._pedb.layout.pin_groups:
if pgroup.name == group_name:
pin_group_exists = True
if len(pgroup.pins) == len(pins):
Expand All @@ -1510,15 +1510,15 @@ def create_pingroup_from_pins(self, pins, group_name=None):
continue
else:
group_name = self._edb.cell.hierarchy.pin_group.unique_name(
self._active_layout, group_name
self._edb.layout, group_name
)
pin_group_exists = False
else:
group_name = self._edb.cell.hierarchy.pin_group.unique_name(self._active_layout, group_name)
group_name = hierarchy.PinGroup.unique_name(self._edb.layout, group_name)
pin_group_exists = False
if pin_group_exists:
return pgroup
pingroup = hierarchy.PinGroup.create(self._active_layout, group_name, pins)
pingroup = hierarchy.PinGroup.create(self._edb.layout, group_name, pins)
if pingroup.is_null:
return False
else:
Expand Down Expand Up @@ -2026,27 +2026,30 @@ def get_pin_from_component(self, component, netName=None, pinName=None):
"""
if not isinstance(component, hierarchy.ComponentGroup):
component = hierarchy.ComponentGroup.find(self._active_layout, component)
component = hierarchy.ComponentGroup.find(self._edb.layout, component)
if netName:
if not isinstance(netName, list):
netName = [netName]
pins = [
p
for p in list(component.layout_objs)
if int(p.obj_type) == 1 and p.is_layout_pin and p.net.name in netName]
for p in component.members if p.layout_obj_type.value == 1 and not p.net.is_null
and p.is_layout_pin and p.net.name in netName]
elif pinName:
if not isinstance(pinName, list):
pinName = [pinName]
pins = [
p
for p in list(component.layout_objs)
if int(p.obj_type) == 1
for p in list(component.members)
if p.layout_obj_type.value == 1
and p.is_layout_pin
and not p.net.is_null
and (self.get_aedt_pin_name(p) in pinName or p.name in pinName)
]
else:
pins = [p for p in list(component.layout_objs) if int(p.obj_type) == 1 and p.is_layout_pin]
return pins
pins = [p for p in list(component.members) if p.layout_obj_type.value == 1 and not p.net.is_null
and p.is_layout_pin]

return [EDBPadstackInstance(pin, self._pedb) for pin in pins]

@pyedb_function_handler()
def get_aedt_pin_name(self, pin):
Expand Down
Loading

0 comments on commit ee83564

Please sign in to comment.