diff --git a/CHANGELOG.md b/CHANGELOG.md index d3d5a2b17ab..703b5db0193 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Changed vector comparison (`compas.geometry.Vector.__eq__`) to use `TOL.is_allclose` instead of raw coordinate comparison. * Fixed bug in frame comparison (`compas.geometry.Frame.__eq__`). * Fixed bug in `compas.geometry.oriented_bounding_box_numpy`. +* Fixed cannot copy `Line` using `deepcopy`. ### Removed diff --git a/src/compas/geometry/curves/line.py b/src/compas/geometry/curves/line.py index f715b47e0a1..b17799987db 100644 --- a/src/compas/geometry/curves/line.py +++ b/src/compas/geometry/curves/line.py @@ -69,9 +69,7 @@ class Line(Curve): # overwriting the __new__ method is necessary # to avoid triggering the plugin mechanism of the base curve class def __new__(cls, *args, **kwargs): - curve = object.__new__(cls) - curve.__init__(*args, **kwargs) - return curve + return object.__new__(cls) DATASCHEMA = { "type": "object", diff --git a/tests/compas/geometry/test_curves_line.py b/tests/compas/geometry/test_curves_line.py index d049ec091a7..fbc272b2fa4 100644 --- a/tests/compas/geometry/test_curves_line.py +++ b/tests/compas/geometry/test_curves_line.py @@ -1,3 +1,4 @@ +from copy import deepcopy import pytest import json import compas @@ -282,3 +283,17 @@ def test_line_flip(p1, p2): flipped_line = Line(p1, p2).flipped() assert TOL.is_zero(distance_point_point(flipped_line.start, p2)) assert TOL.is_zero(distance_point_point(flipped_line.end, p1)) + + +def test_line_copy_deepcopy(): + line = Line([0, 0, 0], [1, 0, 0]) + + line_copy = line.copy() + + assert line is not line_copy + assert line == line_copy + + line_deepcopy = deepcopy(line) + + assert line is not line_deepcopy + assert line == line_deepcopy