Skip to content

Commit b4c8cbf

Browse files
committed
FIX: Fix geometry doc
1 parent 3ab58f0 commit b4c8cbf

File tree

7 files changed

+247
-199
lines changed

7 files changed

+247
-199
lines changed

doc/source/api/geometry.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Classes
1111

1212
arc_data.ArcData
1313
r_tree.RTree
14+
r_tree.RTreeObj
1415
polygon_data.PolygonData
1516
point_data.PointData
1617
point3d_data.Point3DData

src/ansys/edb/core/geometry/arc_data.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from typing import TYPE_CHECKING
55

66
if TYPE_CHECKING:
7-
from ansys.edb.core.geometry.arc_data import ArcData
87
from ansys.edb.core.typing import PointLike
98

109

@@ -37,8 +36,8 @@ def __init__(self, start: PointLike, end: PointLike, **kwargs):
3736
3837
Parameters
3938
----------
40-
start : .PointLike
41-
end : .PointLike
39+
start : :term:`Point2DLike`
40+
end : :term:`Point2DLike`
4241
height: float, int, optional
4342
direction : Literal["cw", "ccw", "colinear"], optional
4443
"""
@@ -152,7 +151,7 @@ def is_big(self) -> bool:
152151
def is_left(self) -> bool:
153152
"""Determine if the arc rotates clockwise.
154153
155-
This method is the same as the ``is_cw`` method.
154+
This method is the same as the :obj:`is_cw` method.
156155
157156
Returns
158157
-------
@@ -185,7 +184,7 @@ def is_ccw(self) -> bool:
185184

186185
@property
187186
def direction(self) -> str:
188-
""":obj:`Literal["cw", "ccw", "colinear"]`: Rotational direction of the arc."""
187+
""":obj:`str` : Rotational direction of the arc which can be "cw" or "ccw" or "colinear"."""
189188
if self.is_cw():
190189
return "cw"
191190
elif self.is_ccw():
@@ -236,7 +235,7 @@ def tangent_at(self, point: PointLike) -> PointData:
236235
237236
Parameters
238237
----------
239-
point : .PointLike
238+
point : :term:`Point2DLike`
240239
Point.
241240
242241
Returns
@@ -260,7 +259,7 @@ def closest_points(self, other: ArcData) -> tuple[PointData, PointData]:
260259
261260
Parameters
262261
----------
263-
other : .ArcDataother
262+
other : .ArcData
264263
Other arc.
265264
266265
Returns

src/ansys/edb/core/geometry/point_data.py

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
"""Point data."""
2+
from __future__ import annotations
3+
4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from ansys.edb.core.typing import ValueLike, PointLike
8+
from ansys.edb.core.utility.value import Value
9+
from typing import Iterable
10+
211
from functools import reduce
312
import math
413
import operator
@@ -18,12 +27,12 @@ class PointData:
1827
session.StubType.point_data
1928
)
2029

21-
def __init__(self, *data):
30+
def __init__(self, *data: Iterable[ValueLike]):
2231
"""Initialize point data from a list of coordinates.
2332
2433
Parameters
2534
----------
26-
data : Iterable[Iterable[ansys.edb.core.typing.ValueLike], ansys.edb.core.typing.ValueLike]
35+
data : :obj:`list` of :term:`ValueLike`
2736
"""
2837
self._x = self._y = self._arc_h = None
2938

@@ -49,20 +58,20 @@ def __init__(self, *data):
4958
f"two values representing x and y coordinates. - Received '{data}'"
5059
)
5160

52-
def __eq__(self, other):
61+
def __eq__(self, other: PointData) -> bool:
5362
"""Determine if two objects represent the same coordinates.
5463
5564
Parameters
5665
----------
57-
other : PointData
66+
other : .PointData
5867
5968
Returns
6069
-------
6170
bool
6271
"""
6372
return self.equals(other)
6473

65-
def __len__(self):
74+
def __len__(self) -> int:
6675
"""Return the number of coordinates present.
6776
6877
Returns
@@ -71,33 +80,33 @@ def __len__(self):
7180
"""
7281
return len(self._matrix_values)
7382

74-
def __add__(self, other):
83+
def __add__(self, other: PointLike) -> PointData:
7584
"""Perform matrix addition of two points.
7685
7786
Parameters
7887
----------
79-
other : ansys.edb.core.typing.PointLike
88+
other : :term:`Point2DLike`
8089
8190
Returns
8291
-------
83-
PointData
92+
.PointData
8493
"""
8594
return self.__class__(self._map_reduce(other, operator.__add__))
8695

87-
def __sub__(self, other):
96+
def __sub__(self, other: PointLike) -> PointData:
8897
"""Perform matrix subtraction of two points.
8998
9099
Parameters
91100
----------
92-
other : ansys.edb.core.typing.PointLike
101+
other : :term:`Point2DLike`
93102
94103
Returns
95104
-------
96-
PointData
105+
.PointData
97106
"""
98107
return self.__class__(self._map_reduce(other, operator.__sub__))
99108

100-
def __str__(self):
109+
def __str__(self) -> str:
101110
"""Generate unique name for the point object.
102111
103112
Returns
@@ -107,13 +116,13 @@ def __str__(self):
107116
coord = ",".join([str(v) for v in self._matrix_values])
108117
return f"<{coord}>" if self.is_arc else f"({coord})"
109118

110-
def equals(self, other, tolerance=0.0):
119+
def equals(self, other, tolerance: float = 0.0) -> bool:
111120
"""Determine if two points are located at the same coordinates.
112121
113122
Parameters
114123
----------
115-
other : ansys.edb.core.typing.PointLike
116-
tolerance : float, optional
124+
other : :term:`Point2DLike`
125+
tolerance : float, default: 0.0
117126
118127
Returns
119128
-------
@@ -131,7 +140,7 @@ def value_equals(a, b):
131140
return False
132141

133142
@property
134-
def _matrix_values(self):
143+
def _matrix_values(self) -> list[Value]:
135144
""":obj:`list` of :class:`.Value`: Coordinates of the point as a list of values."""
136145
return [self.arc_height] if self.is_arc else [self.x, self.y]
137146

@@ -140,31 +149,31 @@ def _map_reduce(self, other, op):
140149
return [reduce(op, values) for values in zip(self._matrix_values, other._matrix_values)]
141150

142151
@property
143-
def is_arc(self):
152+
def is_arc(self) -> bool:
144153
""":obj:`bool`: Flag indicating if the point represents an arc."""
145154
return self._arc_h is not None
146155

147156
@property
148-
def arc_height(self):
157+
def arc_height(self) -> Value:
149158
""":class:`.Value`: Height of the arc."""
150159
return self._arc_h
151160

152161
@property
153-
def x(self):
162+
def x(self) -> Value:
154163
""":class:`.Value`: X coordinate."""
155164
return self._x
156165

157166
@property
158-
def y(self):
167+
def y(self) -> Value:
159168
""":class:`.Value`: Y coordinate."""
160169
return self._y
161170

162171
@property
163-
def is_parametric(self):
172+
def is_parametric(self) -> bool:
164173
""":obj:`bool`: Flag indicating if the point contains parametric values (variable expressions)."""
165174
return any(val.is_parametric for val in self._matrix_values)
166175

167-
def magnitude(self):
176+
def magnitude(self) -> float:
168177
"""Get the magnitude of the point vector.
169178
170179
Returns
@@ -176,7 +185,7 @@ def magnitude(self):
176185
return 0
177186
return math.sqrt(sum([v**2 for v in self._matrix_values], value.Value(0)).value)
178187

179-
def normalized(self):
188+
def normalized(self) -> PointData:
180189
"""Normalize the point vector.
181190
182191
Returns
@@ -188,32 +197,32 @@ def normalized(self):
188197
return self.__class__(n)
189198

190199
@parser.to_point_data
191-
def closest(self, start, end):
200+
def closest(self, start: PointLike, end: PointLike) -> PointData | None:
192201
"""Get the closest point on a line segment from the point.
193202
194203
Parameters
195204
----------
196-
start : ansys.edb.core.typing.PointLike
205+
start : :term:`Point2DLike`
197206
Start point of the line segment.
198-
end : ansys.edb.core.typing.PointLike
207+
end : :term:`Point2DLike`
199208
End point of the line segment.
200209
201210
Returns
202211
-------
203-
typing.Optional[PointData] or ``None`` if either point is an arc.
212+
.PointData or :obj:`None` if either point is an arc.
204213
"""
205214
if not self.is_arc:
206215
return self.__stub.ClosestPoint(messages.point_data_with_line_message(self, start, end))
207216

208-
def distance(self, start, end=None):
217+
def distance(self, start: PointLike, end: PointLike = None) -> float:
209218
"""Compute the shortest distance from the point to a line segment when an end point is given. \
210219
Otherwise, compute the distance between this point and another point.
211220
212221
Parameters
213222
----------
214-
start : ansys.edb.core.typing.PointLike
223+
start : :term:`Point2DLike`
215224
Start point of the line segment.
216-
end : ansys.edb.core.typing.PointLike, default: None
225+
end : :term:`Point2DLike`, default: None
217226
End point of the line segment.
218227
219228
Returns
@@ -227,62 +236,62 @@ def distance(self, start, end=None):
227236
messages.point_data_with_line_message(self, start, end)
228237
).value
229238

230-
def cross(self, other):
239+
def cross(self, other: PointLike) -> Value | None:
231240
"""Compute the cross product of the point vector with another point vector.
232241
233242
Parameters
234243
----------
235-
other : ansys.edb.core.typing.PointLike
244+
other : :term:`Point2DLike`
236245
Other point vector.
237246
238247
Returns
239248
-------
240-
typing.Optional[.Value] or ``None`` if either point is an arc.
249+
.Value or :obj:`None` if either point is an arc.
241250
"""
242251
other = conversions.to_point(other)
243252
if not self.is_arc and not other.is_arc:
244253
return self.x * other.y - self.y * other.x
245254

246-
def move(self, vector):
255+
def move(self, vector: PointLike) -> PointData:
247256
"""Move the point by a vector.
248257
249258
Parameters
250259
----------
251-
vector : ansys.edb.core.typing.PointLike
260+
vector : :term:`Point2DLike`
252261
Vector.
253262
254263
Returns
255264
-------
256-
typing.Optional[PointData] or ``None`` if either point is an arc.
265+
.PointData or :obj:`None` if either point is an arc.
257266
"""
258267
vector = conversions.to_point(vector)
259268
if not self.is_arc and not vector.is_arc:
260269
return self + vector
261270

262271
@parser.to_point_data
263-
def rotate(self, angle, center):
272+
def rotate(self, angle: float, center: PointLike) -> PointData | None:
264273
"""Rotate a point at a given center by a given angle.
265274
266275
Parameters
267276
----------
268277
angle : float
269278
Angle in radians.
270-
center : ansys.edb.core.typing.PointLike
279+
center : :term:`Point2DLike`
271280
Center.
272281
273282
Returns
274283
-------
275-
typing.Optional[PointData] or ``None`` if either point is an arc.
284+
.PointData or :obj:`None` if either point is an arc.
276285
"""
277286
if not self.is_arc:
278287
return self.__stub.Rotate(messages.point_data_rotate_message(self, center, angle))
279288

280-
def dot(self, other):
289+
def dot(self, other: PointLike) -> float:
281290
"""Perform per-component multiplication (dot product) of this point and another point.
282291
283292
Parameters
284293
----------
285-
other : ansys.edb.core.typing.PointLike
294+
other : :term:`Point2DLike`
286295
Other point.
287296
288297
Returns
@@ -292,12 +301,12 @@ def dot(self, other):
292301
"""
293302
return sum(self._map_reduce(other, operator.__mul__), value.Value(0)).value
294303

295-
def angle(self, other):
304+
def angle(self, other: PointLike) -> float:
296305
"""Get the angle between this vector and another vector.
297306
298307
Parameters
299308
----------
300-
other : ansys.edb.core.typing.PointLike
309+
other : :term:`Point2DLike`
301310
Other vector.
302311
303312
Returns

0 commit comments

Comments
 (0)