Skip to content

Commit 41abc62

Browse files
authored
Merge pull request #1421 from compas-dev/bugfix_linecopy
removed call to __init__ in __new__
2 parents 645dc74 + 1837d4a commit 41abc62

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
* Changed vector comparison (`compas.geometry.Vector.__eq__`) to use `TOL.is_allclose` instead of raw coordinate comparison.
1818
* Fixed bug in frame comparison (`compas.geometry.Frame.__eq__`).
1919
* Fixed bug in `compas.geometry.oriented_bounding_box_numpy`.
20+
* Fixed cannot copy `Line` using `deepcopy`.
2021

2122
### Removed
2223

src/compas/geometry/curves/line.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ class Line(Curve):
6969
# overwriting the __new__ method is necessary
7070
# to avoid triggering the plugin mechanism of the base curve class
7171
def __new__(cls, *args, **kwargs):
72-
curve = object.__new__(cls)
73-
curve.__init__(*args, **kwargs)
74-
return curve
72+
return object.__new__(cls)
7573

7674
DATASCHEMA = {
7775
"type": "object",

tests/compas/geometry/test_curves_line.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from copy import deepcopy
12
import pytest
23
import json
34
import compas
@@ -282,3 +283,17 @@ def test_line_flip(p1, p2):
282283
flipped_line = Line(p1, p2).flipped()
283284
assert TOL.is_zero(distance_point_point(flipped_line.start, p2))
284285
assert TOL.is_zero(distance_point_point(flipped_line.end, p1))
286+
287+
288+
def test_line_copy_deepcopy():
289+
line = Line([0, 0, 0], [1, 0, 0])
290+
291+
line_copy = line.copy()
292+
293+
assert line is not line_copy
294+
assert line == line_copy
295+
296+
line_deepcopy = deepcopy(line)
297+
298+
assert line is not line_deepcopy
299+
assert line == line_deepcopy

0 commit comments

Comments
 (0)