Skip to content

Commit

Permalink
test #89 done
Browse files Browse the repository at this point in the history
  • Loading branch information
svandenb-dev committed Oct 29, 2024
1 parent 76ecfc0 commit 4a84506
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
10 changes: 6 additions & 4 deletions src/pyedb/grpc/edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2662,10 +2662,11 @@ def add_project_variable(self, variable_name, variable_value):
"""
if not variable_name.startswith("$"):
variable_name = f"${variable_name}"
if not self.variable_exists(variable_name):
return self.active_db.add_variable(variable_name, variable_value)
else:
self.logger.error(f"Variable {variable_name} already exists.")
if not self.variable_exists(variable_name):
return self.active_db.add_variable(variable_name, variable_value)
else:
self.logger.error(f"Variable {variable_name} already exists.")
return False

def add_design_variable(self, variable_name, variable_value, is_parameter=False):
"""Add a variable to edb. The variable can be a design one or a project variable (using ``$`` prefix).
Expand Down Expand Up @@ -2708,6 +2709,7 @@ def add_design_variable(self, variable_name, variable_value, is_parameter=False)
return self.active_cell.add_variable(variable_name, variable_value)
else:
self.logger.error(f"Variable {variable_name} already exists.")
return False

def change_design_variable_value(self, variable_name, variable_value):
"""Change a variable value.
Expand Down
7 changes: 4 additions & 3 deletions src/pyedb/grpc/edb_core/modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,20 +1107,21 @@ def parametrize_trace_width(
layers_name = [layers_name]
for net_name in nets_name:
for p in self.paths:
_parameter_name = f"{parameter_name}_{p.id}"
if not p.net.is_null:
if p.net.name == net_name:
if not layers_name:
if not variable_value:
variable_value = p.width
self._pedb.active_cell.add_variable(
name=parameter_name, value=variable_value, is_param=True
name=_parameter_name, value=GrpcValue(variable_value), is_param=True
)
p.width = parameter_name
p.width = GrpcValue(_parameter_name, self._pedb.active_cell)
elif p.layer.name in layers_name:
if not variable_value:
variable_value = p.width
self._pedb.add_design_variable(parameter_name, variable_value, True)
p.width = GrpcValue(parameter_name)
p.width = GrpcValue(_parameter_name, self._pedb.active_cell)
return True

def unite_polygons_on_layer(self, layer_name=None, delete_padstack_gemometries=False, net_names_list=[]):
Expand Down
21 changes: 9 additions & 12 deletions tests/grpc/system/test_edb.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
class TestClass:
@pytest.fixture(autouse=True)
def init(self, local_scratch, target_path, target_path2, target_path4):
# self.edbapp = grpc_edb_app
self.local_scratch = local_scratch
self.target_path = target_path
self.target_path2 = target_path2
Expand Down Expand Up @@ -194,22 +193,20 @@ def test_hfss_mesh_operations(self, edb_examples):

def test_add_variables(self, edb_examples):
"""Add design and project variables."""
# TODO check status of buf #432 assigning parameter on
# Done
edbapp = edb_examples.get_si_verse()
edbapp.add_design_variable("my_variable", "1mm")
assert "my_variable" in edbapp.active_cell.get_all_variable_names()
assert edbapp.modeler.parametrize_trace_width("DDR4_DQ25")
assert edbapp.modeler.parametrize_trace_width("DDR4_A2")
result, var_server = edbapp.add_design_variable("my_parameter", "2mm", True)
assert result
assert var_server.IsVariableParameter("my_parameter")
result, var_server = edbapp.add_design_variable("my_parameter", "2mm", True)
assert not result
result, var_server = edbapp.add_project_variable("$my_project_variable", "3mm")
assert result
assert var_server
result, var_server = edbapp.add_project_variable("$my_project_variable", "3mm")
assert not result
edbapp.add_design_variable("my_parameter", "2mm", True)
assert "my_parameter" in edbapp.active_cell.get_all_variable_names()
variable_value = edbapp.active_cell.get_variable_value("my_parameter").value
assert variable_value == 2e-3
assert not edbapp.add_design_variable("my_parameter", "2mm", True)
edbapp.add_project_variable("$my_project_variable", "3mm")
assert edbapp.db.get_variable_value("$my_project_variable") == 3e-3
assert not edbapp.add_project_variable("$my_project_variable", "3mm")
edbapp.close()

def test_save_edb_as(self, edb_examples):
Expand Down

0 comments on commit 4a84506

Please sign in to comment.