Skip to content

Commit 20c6acd

Browse files
DOC: Fix up top level core modules
1 parent b8a667d commit 20c6acd

File tree

4 files changed

+106
-78
lines changed

4 files changed

+106
-78
lines changed

doc/source/api/session.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ Functions
1212
.. autosummary::
1313
:toctree: _autosummary
1414

15+
attach_session
1516
launch_session
1617
session

src/ansys/edb/core/database.py

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
"""Database."""
2+
from __future__ import annotations
3+
4+
from typing import TYPE_CHECKING, List, Tuple, Union
5+
6+
if TYPE_CHECKING:
7+
from ansys.edb.core.inner.messages import EDBObjMessage
28

39
from enum import Enum
410

@@ -34,7 +40,7 @@
3440

3541

3642
class ProductIdType(Enum):
37-
"""Provides an enum representing IDs of Ansys products that support EDB usage."""
43+
"""Enum representing IDs of Ansys products that support EDB usage."""
3844

3945
HFSS_3D_LAYOUT = DESIGNER = edb_defs_pb2.DESIGNER
4046
SIWAVE = edb_defs_pb2.SI_WAVE
@@ -48,18 +54,18 @@ class Database(ObjBase, variable_server.VariableServer):
4854

4955
__stub: DatabaseServiceStub = StubAccessor(StubType.database)
5056

51-
def __init__(self, msg):
57+
def __init__(self, msg: EDBObjMessage):
5258
"""Initialize a new database.
5359
5460
Parameters
5561
----------
56-
msg : EDBObjMessage
62+
msg : .EDBObjMessage
5763
"""
5864
ObjBase.__init__(self, msg)
5965
variable_server.VariableServer.__init__(self, self)
6066

6167
@classmethod
62-
def create(cls, db_path):
68+
def create(cls, db_path: str) -> Database:
6369
"""Create a database in a given location.
6470
6571
Parameters
@@ -69,13 +75,13 @@ def create(cls, db_path):
6975
7076
Returns
7177
-------
72-
Database
78+
.Database
7379
"""
7480
msg = cls.__stub.Create(proto_wrappers.StringValue(value=db_path))
7581
return Database(msg)
7682

7783
@classmethod
78-
def open(cls, db_path, read_only):
84+
def open(cls, db_path: str, read_only: bool) -> Database:
7985
"""Open a database in a given location.
8086
8187
Parameters
@@ -87,8 +93,7 @@ def open(cls, db_path, read_only):
8793
8894
Returns
8995
-------
90-
Database object or None
91-
Database object opened or ``None`` if no database object is found.
96+
.Database
9297
"""
9398
return Database(
9499
cls.__stub.Open(
@@ -100,7 +105,7 @@ def open(cls, db_path, read_only):
100105
)
101106

102107
@classmethod
103-
def delete(cls, db_path):
108+
def delete(cls, db_path: str):
104109
"""Delete a database in a given specified location.
105110
106111
Parameters
@@ -124,37 +129,37 @@ def close(self):
124129
self.msg = None
125130

126131
@staticmethod
127-
def _map_cell_edb_obj_collection(cells_msg):
128-
"""Get a list of cell objects from the ``EDBObjCollection`` message."""
132+
def _map_cell_edb_obj_collection(cells_msg: EDBObjMessage) -> List[Cell]:
133+
"""Get a list of cell objects from the :class:`.EDBObjCollection` message."""
129134
return map_list(cells_msg.items, Cell)
130135

131136
@property
132-
def top_circuit_cells(self):
137+
def top_circuit_cells(self) -> List[Cell]:
133138
""":obj:`list` of :class:`.Cell`: Top circuit cells in the database."""
134139
return Database._map_cell_edb_obj_collection(self.__stub.GetTopCircuits(self.msg))
135140

136141
@property
137-
def circuit_cells(self):
142+
def circuit_cells(self) -> List[Cell]:
138143
""":obj:`list` of :class:`.Cell`: All circuit cells in the database."""
139144
return Database._map_cell_edb_obj_collection(self.__stub.GetCircuits(self.msg))
140145

141146
@property
142-
def footprint_cells(self):
147+
def footprint_cells(self) -> List[Cell]:
143148
""":obj:`list` of :class:`.Cell`: All footprint cells in the database."""
144149
return Database._map_cell_edb_obj_collection(self.__stub.GetFootprints(self.msg))
145150

146151
@property
147-
def edb_uid(self):
152+
def edb_uid(self) -> int:
148153
""":obj:`int`: Unique EDB ID of the database."""
149154
return self.__stub.GetId(self.msg).value
150155

151156
@property
152-
def is_read_only(self):
157+
def is_read_only(self) -> bool:
153158
""":obj:`bool`: Flag indicating if the database is open in read-only mode."""
154159
return self.__stub.IsReadOnly(self.msg).value
155160

156161
@classmethod
157-
def find_by_id(cls, db_id):
162+
def find_by_id(cls, db_id: int) -> Database:
158163
"""Find a database by ID.
159164
160165
Parameters
@@ -164,12 +169,11 @@ def find_by_id(cls, db_id):
164169
165170
Returns
166171
-------
167-
Database
168-
Database when successful, Null when failed.
172+
.Database
169173
"""
170174
return Database(cls.__stub.FindById(proto_wrappers.Int64Value(value=db_id)))
171175

172-
def save_as(self, path, version=""):
176+
def save_as(self, path: str, version: str = ""):
173177
"""Save the database to a new location and older EDB version.
174178
175179
Parameters
@@ -185,7 +189,7 @@ def save_as(self, path, version=""):
185189
)
186190

187191
@classmethod
188-
def get_version_by_release(cls, release):
192+
def get_version_by_release(cls, release: str) -> str:
189193
"""Get the EDB version for a given release name.
190194
191195
Parameters
@@ -201,16 +205,16 @@ def get_version_by_release(cls, release):
201205
return cls.__stub.GetVersionByRelease(str_message(release)).value
202206

203207
@property
204-
def directory(self):
208+
def directory(self) -> str:
205209
""":obj:`str`: Directory where the database is located."""
206210
return self.__stub.GetDirectory(self.msg).value
207211

208-
def get_product_property(self, prod_id, attr_it):
212+
def get_product_property(self, prod_id: ProductIdType, attr_it: int) -> str:
209213
"""Get a product-specific property value.
210214
211215
Parameters
212216
----------
213-
prod_id : ProductIdType
217+
prod_id : .ProductIdType
214218
Product ID.
215219
attr_it : int
216220
Attribute ID.
@@ -224,12 +228,12 @@ def get_product_property(self, prod_id, attr_it):
224228
get_product_property_message(self, prod_id, attr_it)
225229
).value
226230

227-
def set_product_property(self, prod_id, attr_it, prop_value):
231+
def set_product_property(self, prod_id: ProductIdType, attr_it: int, prop_value: str):
228232
"""Set the product property associated with the given product ID and attribute ID.
229233
230234
Parameters
231235
----------
232-
prod_id : ProductIdType
236+
prod_id : .ProductIdType
233237
Product ID.
234238
attr_it : int
235239
Attribute ID.
@@ -240,12 +244,12 @@ def set_product_property(self, prod_id, attr_it, prop_value):
240244
set_product_property_message(self, prod_id, attr_it, prop_value)
241245
)
242246

243-
def get_product_property_ids(self, prod_id):
247+
def get_product_property_ids(self, prod_id: ProductIdType) -> List[int]:
244248
"""Get a list of attribute IDs for a given product property ID.
245249
246250
Parameters
247251
----------
248-
prod_id : ProductIdType
252+
prod_id : .ProductIdType
249253
Product ID.
250254
251255
Returns
@@ -258,14 +262,16 @@ def get_product_property_ids(self, prod_id):
258262
).ids
259263
return [attr_id for attr_id in attr_ids]
260264

261-
def import_material_from_control_file(self, control_file, schema_dir=None, append=True):
265+
def import_material_from_control_file(
266+
self, control_file: str, schema_dir: Union[str, None] = None, append: bool = True
267+
):
262268
"""Import materials from a control file.
263269
264270
Parameters
265271
----------
266272
control_file : str
267273
Full path to the control file.
268-
schema_dir : str
274+
schema_dir : Union[str, None]
269275
Path to the schema directory.
270276
append : bool, default: True
271277
Whether to keep existing materials in the database. If ``False``, the
@@ -281,12 +287,12 @@ def import_material_from_control_file(self, control_file, schema_dir=None, appen
281287
)
282288

283289
@property
284-
def version(self):
290+
def version(self) -> Tuple[int, int]:
285291
""":obj:`tuple` of (:obj:`int`, :obj:`int`): Version [major, minor] of the database."""
286292
version_msg = self.__stub.GetVersion(self.msg)
287293
return version_msg.major.id, version_msg.minor.id
288294

289-
def scale(self, scale_factor):
295+
def scale(self, scale_factor: float):
290296
"""Scale all geometries and their locations uniformly by a positive factor.
291297
292298
Parameters
@@ -297,34 +303,34 @@ def scale(self, scale_factor):
297303
self.__stub.Scale(double_property_message(self, scale_factor))
298304

299305
@property
300-
def source(self):
306+
def source(self) -> str:
301307
""":obj:`str`: Name of the source database."""
302308
return self.__stub.GetSource(self.msg).value
303309

304310
@source.setter
305-
def source(self, source):
311+
def source(self, source: str):
306312
self.__stub.SetSource(edb_obj_name_message(self, source))
307313

308314
@property
309-
def source_version(self):
315+
def source_version(self) -> str:
310316
""":obj:`str`: Source version for the database."""
311317
return self.__stub.GetSourceVersion(self.msg).value
312318

313319
@source_version.setter
314-
def source_version(self, source_version):
320+
def source_version(self, source_version: str):
315321
self.__stub.SetSourceVersion(edb_obj_name_message(self, source_version))
316322

317-
def copy_cells(self, cells_to_copy):
323+
def copy_cells(self, cells_to_copy: List[Cell]) -> List[Cell]:
318324
"""Copy cells from other databases or this database into this database.
319325
320326
Parameters
321327
----------
322-
cells_to_copy : list[:class:`.Cell`]
328+
cells_to_copy : list of .Cell
323329
Cells to copy.
324330
325331
Returns
326332
-------
327-
list[:class:`.Cell`]
333+
list of .Cell
328334
New cells created in this database.
329335
"""
330336
return Database._map_cell_edb_obj_collection(
@@ -353,45 +359,45 @@ def _get_bondwire_definition_objs(self, def_class, bw_def_type_enum):
353359
)
354360

355361
@property
356-
def apd_bondwire_defs(self):
362+
def apd_bondwire_defs(self) -> List[ApdBondwireDef]:
357363
""":obj:`list` of :class:`.ApdBondwireDef`: All APD bondwire definitions in the database."""
358364
return self._get_bondwire_definition_objs(ApdBondwireDef, BondwireDefType.APD_BONDWIRE_DEF)
359365

360366
@property
361-
def jedec4_bondwire_defs(self):
367+
def jedec4_bondwire_defs(self) -> List[Jedec4BondwireDef]:
362368
""":obj:`list` of :class:`.Jedec4BondwireDef`: All JEDEC4 bondwire definitions in the database."""
363369
return self._get_bondwire_definition_objs(
364370
Jedec4BondwireDef, BondwireDefType.JEDEC4_BONDWIRE_DEF
365371
)
366372

367373
@property
368-
def jedec5_bondwire_defs(self):
374+
def jedec5_bondwire_defs(self) -> List[Jedec5BondwireDef]:
369375
""":obj:`list` of:class:`.Jedec5BondwireDef`: All JEDEC5 bondwire definitions in the database."""
370376
return self._get_bondwire_definition_objs(
371377
Jedec5BondwireDef, BondwireDefType.JEDEC5_BONDWIRE_DEF
372378
)
373379

374380
@property
375-
def padstack_defs(self):
381+
def padstack_defs(self) -> List[PadstackDef]:
376382
""":obj:`list` of :class:`.PadstackDef`: All padstack definitions in the database."""
377383
return self._get_definition_objs(PadstackDef, DefinitionObjType.PADSTACK_DEF)
378384

379385
@property
380-
def package_defs(self):
386+
def package_defs(self) -> List[PackageDef]:
381387
""":obj:`list` of :class:`.PackageDef`: All package definitions in the database."""
382388
return self._get_definition_objs(PackageDef, DefinitionObjType.PACKAGE_DEF)
383389

384390
@property
385-
def component_defs(self):
391+
def component_defs(self) -> List[ComponentDef]:
386392
""":obj:`list` of :class:`.ComponentDef`: All component definitions in the database."""
387393
return self._get_definition_objs(ComponentDef, DefinitionObjType.COMPONENT_DEF)
388394

389395
@property
390-
def material_defs(self):
396+
def material_defs(self) -> List[MaterialDef]:
391397
""":obj:`list` of :class:`.MaterialDef`: All material definitions in the database."""
392398
return self._get_definition_objs(MaterialDef, DefinitionObjType.MATERIAL_DEF)
393399

394400
@property
395-
def dataset_defs(self):
401+
def dataset_defs(self) -> List[DatasetDef]:
396402
""":obj:`list` of :class:`.DatasetDef`: All dataset definitions in the database."""
397403
return self._get_definition_objs(DatasetDef, DefinitionObjType.DATASET_DEF)

src/ansys/edb/core/edb_defs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class LayoutObjType(Enum):
10-
"""Provides an enum representing layout object types."""
10+
"""Enum representing layout object types."""
1111

1212
INVALID_LAYOUT_OBJ = layout_obj_pb2.INVALID_LAYOUT_OBJ
1313
PRIMITIVE = layout_obj_pb2.PRIMITIVE
@@ -28,7 +28,7 @@ class LayoutObjType(Enum):
2828

2929

3030
class DefinitionObjType(Enum):
31-
"""Provides an enum representing definition object types."""
31+
"""Enum representing definition object types."""
3232

3333
INVALID_DEFINITION_TYPE = definition_obj_pb2.INVALID_DEFINITION_TYPE
3434
PADSTACK_DEF = definition_obj_pb2.PADSTACK_DEF

0 commit comments

Comments
 (0)