Skip to content

Commit

Permalink
D312: Change inner module to only import classes/methods as needed
Browse files Browse the repository at this point in the history
  • Loading branch information
drewm102 committed Dec 13, 2023
1 parent c0e3c29 commit 757f763
Show file tree
Hide file tree
Showing 75 changed files with 1,120 additions and 954 deletions.
7 changes: 4 additions & 3 deletions src/ansys/edb/core/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
PadstackDef,
)
from ansys.edb.core.edb_defs import DefinitionObjType
from ansys.edb.core.inner import ObjBase, variable_server
from ansys.edb.core.inner.base import ObjBase
from ansys.edb.core.inner.messages import (
double_property_message,
edb_obj_collection_message,
Expand All @@ -29,6 +29,7 @@
str_message,
)
from ansys.edb.core.inner.utils import map_list
from ansys.edb.core.inner.variable_server import VariableServer
from ansys.edb.core.layout import Cell
from ansys.edb.core.session import DatabaseServiceStub, StubAccessor, StubType

Expand All @@ -50,7 +51,7 @@ class ProductIdType(Enum):
INVALID_PRODUCT = edb_defs_pb2.INVALID_PRODUCT


class Database(ObjBase, variable_server.VariableServer):
class Database(ObjBase, VariableServer):
"""Class representing a database object."""

__stub: DatabaseServiceStub = StubAccessor(StubType.database)
Expand All @@ -63,7 +64,7 @@ def __init__(self, msg):
msg : EDBObjMessage
"""
ObjBase.__init__(self, msg)
variable_server.VariableServer.__init__(self, msg)
VariableServer.__init__(self, msg)

@classmethod
def create(cls, db_path):
Expand Down
11 changes: 6 additions & 5 deletions src/ansys/edb/core/definition/bondwire_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import ansys.api.edb.v1.bondwire_def_pb2 as pb

from ansys.edb.core.edb_defs import DefinitionObjType
from ansys.edb.core.inner import ObjBase, messages
from ansys.edb.core.inner.base import ObjBase
from ansys.edb.core.inner.messages import value_message
from ansys.edb.core.session import StubAccessor, StubType
from ansys.edb.core.utility import Value

Expand Down Expand Up @@ -176,7 +177,7 @@ class _Jedec4QueryBuilder:
def jedec4_bondwire_def_set_parameters_message(j, top_to_die_distance):
return pb.Jedec4BondwireDefSetParametersMessage(
target=j.msg,
top_to_die_distance=messages.value_message(top_to_die_distance),
top_to_die_distance=value_message(top_to_die_distance),
)


Expand Down Expand Up @@ -264,9 +265,9 @@ class _Jedec5QueryBuilder:
@staticmethod
def jedec5_bondwire_def_parameters_message(top_to_die_distance, die_pad_angle, lead_pad_angle):
return pb.Jedec5BondwireDefParametersMessage(
top_to_die_distance=messages.value_message(top_to_die_distance),
die_pad_angle=messages.value_message(die_pad_angle),
lead_pad_angle=messages.value_message(lead_pad_angle),
top_to_die_distance=value_message(top_to_die_distance),
die_pad_angle=value_message(die_pad_angle),
lead_pad_angle=value_message(lead_pad_angle),
)

@staticmethod
Expand Down
18 changes: 11 additions & 7 deletions src/ansys/edb/core/definition/component_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@

from ansys.edb.core.definition import component_model, component_pin
from ansys.edb.core.edb_defs import DefinitionObjType
from ansys.edb.core.inner import ObjBase, messages
from ansys.edb.core.inner.base import ObjBase
from ansys.edb.core.inner.messages import (
component_def_creation_message,
edb_obj_pair_message,
object_name_in_layout_message,
string_property_message,
)
from ansys.edb.core.inner.utils import map_list
from ansys.edb.core.layout import cell
from ansys.edb.core.session import StubAccessor, StubType
Expand Down Expand Up @@ -33,7 +39,7 @@ def create(cls, db, comp_def_name, fp):
Newly created component definition.
"""
return ComponentDef(
cls.__stub.Create(messages.component_def_creation_message(db, comp_def_name, fp))
cls.__stub.Create(component_def_creation_message(db, comp_def_name, fp))
)

@classmethod
Expand All @@ -52,9 +58,7 @@ def find(cls, db, comp_def_name):
ComponentDef
Component definition that was found, None otherwise.
"""
return ComponentDef(
cls.__stub.FindByName(messages.object_name_in_layout_message(db, comp_def_name))
)
return ComponentDef(cls.__stub.FindByName(object_name_in_layout_message(db, comp_def_name)))

@property
def definition_type(self):
Expand All @@ -68,7 +72,7 @@ def name(self):

@name.setter
def name(self, value):
self.__stub.SetName(messages.string_property_message(self, value))
self.__stub.SetName(string_property_message(self, value))

@property
def footprint(self):
Expand All @@ -77,7 +81,7 @@ def footprint(self):

@footprint.setter
def footprint(self, value):
self.__stub.SetFootprintCell(messages.edb_obj_pair_message(self, value))
self.__stub.SetFootprintCell(edb_obj_pair_message(self, value))

@property
def component_models(self):
Expand Down
7 changes: 4 additions & 3 deletions src/ansys/edb/core/definition/component_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
)
import google.protobuf.wrappers_pb2 as proto_wrappers

from ansys.edb.core.inner import ObjBase, messages
from ansys.edb.core.inner.base import ObjBase
from ansys.edb.core.inner.messages import string_property_message
from ansys.edb.core.session import StubAccessor, StubType


Expand All @@ -22,7 +23,7 @@ def reference_file(self):

@reference_file.setter
def reference_file(self, value):
self.__stub.SetReferenceFile(messages.string_property_message(self, value))
self.__stub.SetReferenceFile(string_property_message(self, value))


class NPortComponentModel(ComponentModel):
Expand Down Expand Up @@ -85,4 +86,4 @@ def design_name(self):

@design_name.setter
def design_name(self, value):
self.__stub.SetDesignName(messages.string_property_message(self, value))
self.__stub.SetDesignName(string_property_message(self, value))
9 changes: 5 additions & 4 deletions src/ansys/edb/core/definition/component_pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from ansys.api.edb.v1.component_pin_pb2_grpc import ComponentPinServiceStub

from ansys.edb.core.definition import component_def
from ansys.edb.core.inner import ObjBase, messages
from ansys.edb.core.inner.base import ObjBase
from ansys.edb.core.inner.messages import edb_obj_name_message, string_property_message
from ansys.edb.core.session import StubAccessor, StubType


Expand All @@ -27,7 +28,7 @@ def create(cls, comp_def, name):
ComponentPin
Newly created component pin.
"""
return ComponentPin(cls.__stub.Create(messages.edb_obj_name_message(comp_def, name)))
return ComponentPin(cls.__stub.Create(edb_obj_name_message(comp_def, name)))

@classmethod
def find(cls, comp_def, name):
Expand All @@ -45,7 +46,7 @@ def find(cls, comp_def, name):
ComponentPin
Component pin that was found, None otherwise.
"""
return ComponentPin(cls.__stub.FindByName(messages.edb_obj_name_message(comp_def, name)))
return ComponentPin(cls.__stub.FindByName(edb_obj_name_message(comp_def, name)))

@property
def name(self):
Expand All @@ -54,7 +55,7 @@ def name(self):

@name.setter
def name(self, value):
self.__stub.SetName(messages.string_property_message(self, value))
self.__stub.SetName(string_property_message(self, value))

@property
def number(self):
Expand Down
24 changes: 14 additions & 10 deletions src/ansys/edb/core/definition/component_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
import ansys.api.edb.v1.model_pb2 as model_pb2

from ansys.edb.core.definition import package_def
from ansys.edb.core.inner import ObjBase, messages
from ansys.edb.core.inner.base import ObjBase
from ansys.edb.core.inner.messages import (
edb_obj_message,
pointer_property_message,
value_message,
value_property_message,
)
from ansys.edb.core.session import StubAccessor, StubType
from ansys.edb.core.utility import Value

Expand All @@ -21,38 +27,36 @@ def clone(self):
-------
ComponentProperty
"""
return ComponentProperty(self.__stub.Clone(messages.edb_obj_message(self)))
return ComponentProperty(self.__stub.Clone(edb_obj_message(self)))

@property
def package_mounting_offset(self):
""":class:`Value <ansys.edb.core.utility.Value>`: Offset of the package definition object.
Property can be set with :term:`ValueLike`
"""
return Value(self.__stub.GetPackageMountingOffset(messages.edb_obj_message(self)))
return Value(self.__stub.GetPackageMountingOffset(edb_obj_message(self)))

@package_mounting_offset.setter
def package_mounting_offset(self, offset):
self.__stub.SetPackageMountingOffset(
messages.value_property_message(self, messages.value_message(offset))
)
self.__stub.SetPackageMountingOffset(value_property_message(self, value_message(offset)))

@property
def package_def(self):
""":obj:`PackageDef` : Package definition object."""
return package_def.PackageDef(self.__stub.GetPackageDef(messages.edb_obj_message(self)))
return package_def.PackageDef(self.__stub.GetPackageDef(edb_obj_message(self)))

@package_def.setter
def package_def(self, value):
self.__stub.SetPackageDef(messages.pointer_property_message(target=self, value=value))
self.__stub.SetPackageDef(pointer_property_message(target=self, value=value))

@property
def model(self):
""":class:`Model <ansys.edb.core.hierarchy.Model>` : Model object.
A copy is returned. Use the setter for any modifications to be reflected.
"""
comp_model_msg = self.__stub.GetModel(messages.edb_obj_message(self))
comp_model_msg = self.__stub.GetModel(edb_obj_message(self))

def get_model_obj_type():
from ansys.edb.core.hierarchy import (
Expand All @@ -77,4 +81,4 @@ def get_model_obj_type():

@model.setter
def model(self, value):
self.__stub.SetModel(messages.pointer_property_message(target=self, value=value))
self.__stub.SetModel(pointer_property_message(target=self, value=value))
2 changes: 1 addition & 1 deletion src/ansys/edb/core/definition/dataset_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ansys.api.edb.v1.dataset_def_pb2_grpc import DatasetDefServiceStub

from ansys.edb.core.edb_defs import DefinitionObjType
from ansys.edb.core.inner import ObjBase
from ansys.edb.core.inner.base import ObjBase
from ansys.edb.core.inner.messages import (
edb_obj_message,
edb_obj_name_message,
Expand Down
29 changes: 15 additions & 14 deletions src/ansys/edb/core/definition/debye_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@

from ansys.edb.core import session
from ansys.edb.core.definition.dielectric_material_model import DielectricMaterialModel
from ansys.edb.core.inner import messages
from ansys.edb.core.inner.messages import (
bool_property_message,
double_message,
double_property_message,
edb_obj_message,
)


class _DebyeModelQueryBuilder:
@staticmethod
def frequency_range_message(low, high):
return pb.FrequencyRangeMessage(
low=messages.double_message(low), high=messages.double_message(high)
)
return pb.FrequencyRangeMessage(low=double_message(low), high=double_message(high))

@staticmethod
def set_frequency_range_message(target, low, high):
Expand All @@ -38,12 +41,12 @@ def create(cls):
-------
DebyeModelService
"""
return DebyeModel(DielectricMaterialModel(cls.__stub.Create(empty_pb2.Empty())))
return DebyeModel(cls.__stub.Create(empty_pb2.Empty()))

@property
def frequency_range(self):
""":obj:`tuple` of :obj:`float`, :obj:`float`: Frequency range (low, high)."""
range_msg = self.__stub.GetFrequencyRange(messages.edb_obj_message(self))
range_msg = self.__stub.GetFrequencyRange(edb_obj_message(self))
return range_msg.low.value, range_msg.high.value

@frequency_range.setter
Expand All @@ -57,9 +60,7 @@ def frequency_range(self, freq):
@property
def relative_permitivity_at_high_low_frequency(self):
""":obj:`tuple` of :obj:`float`, :obj:`float`: Relative permitivity frequency range (low, high)."""
range_msg = self.__stub.GetRelativePermitivityAtHighLowFrequency(
messages.edb_obj_message(self)
)
range_msg = self.__stub.GetRelativePermitivityAtHighLowFrequency(edb_obj_message(self))
return range_msg.low.value, range_msg.high.value

@relative_permitivity_at_high_low_frequency.setter
Expand All @@ -73,7 +74,7 @@ def relative_permitivity_at_high_low_frequency(self, freq):
@property
def loss_tangent_at_high_low_frequency(self):
""":obj:`tuple` of :obj:`float`, :obj:`float`: Loss tangent frequency range (low, high)."""
range_msg = self.__stub.GetLossTangentAtHighLowFrequency(messages.edb_obj_message(self))
range_msg = self.__stub.GetLossTangentAtHighLowFrequency(edb_obj_message(self))
return range_msg.low.value, range_msg.high.value

@loss_tangent_at_high_low_frequency.setter
Expand All @@ -92,7 +93,7 @@ def is_relative_permitivity_enabled_at_optical_frequency(self):
@is_relative_permitivity_enabled_at_optical_frequency.setter
def is_relative_permitivity_enabled_at_optical_frequency(self, enabled):
self.__stub.SetRelativePermitivityEnabledAtOpticalFrequency(
messages.bool_property_message(self, enabled)
bool_property_message(self, enabled)
)

@property
Expand All @@ -102,7 +103,7 @@ def use_dc_conductivity(self):

@use_dc_conductivity.setter
def use_dc_conductivity(self, enabled):
self.__stub.SetUseDCConductivity(messages.bool_property_message(self, enabled))
self.__stub.SetUseDCConductivity(bool_property_message(self, enabled))

@property
def relative_permitivity_at_optical_frequency(self):
Expand All @@ -112,7 +113,7 @@ def relative_permitivity_at_optical_frequency(self):
@relative_permitivity_at_optical_frequency.setter
def relative_permitivity_at_optical_frequency(self, frequency):
self.__stub.SetRelativePermitivityAtOpticalFrequency(
messages.double_property_message(self, frequency)
double_property_message(self, frequency)
)

@property
Expand All @@ -122,4 +123,4 @@ def dc_conductivity(self):

@dc_conductivity.setter
def dc_conductivity(self, conductivity):
self.__stub.SetDCConductivity(messages.double_property_message(self, conductivity))
self.__stub.SetDCConductivity(double_property_message(self, conductivity))
Loading

0 comments on commit 757f763

Please sign in to comment.