Skip to content

Commit bde9263

Browse files
committed
add __eq__ for circle and line
1 parent 0efa027 commit bde9263

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
* Added `divide_polyline`, `divide_polyline_by_length`, `Polyline.split_at_corners` and `Polyline.tangent_at_point_on_polyline`.
1313
* Added the magic method `__str__` to `compas.geoemetry.Transformation`.
1414
* Added `redraw` flag to the `compas_rhino` methods `delete_object`, `delete_objects` and `purge_objects`.
15+
* Added the `__eq__` method for `compas.geometry.Circle` and `compas.geometry.Line`.
1516

1617
### Changed
1718

src/compas/geometry/primitives/circle.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ def __setitem__(self, key, value):
141141
def __iter__(self):
142142
return iter([self.plane, self.radius])
143143

144+
def __eq__(self, other):
145+
try:
146+
other_plane = other[0]
147+
other_radius = other[1]
148+
except Exception:
149+
return False
150+
return self.plane == other_plane and self.radius == other_radius
151+
144152
# ==========================================================================
145153
# constructors
146154
# ==========================================================================

src/compas/geometry/primitives/line.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ def __iter__(self):
144144
return iter([self.start, self.end])
145145

146146
def __eq__(self, other):
147-
raise NotImplementedError
147+
try:
148+
other_start = other[0]
149+
other_end = other[1]
150+
except Exception:
151+
return False
152+
return self.start == other_start and self.end == other_end
148153

149154
# ==========================================================================
150155
# constructors

0 commit comments

Comments
 (0)