open-space-toolkit-mathematics 4.4.0__py313-none-manylinux2014_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of open-space-toolkit-mathematics might be problematic. Click here for more details.
- open_space_toolkit_mathematics-4.4.0.dist-info/METADATA +28 -0
- open_space_toolkit_mathematics-4.4.0.dist-info/RECORD +69 -0
- open_space_toolkit_mathematics-4.4.0.dist-info/WHEEL +5 -0
- open_space_toolkit_mathematics-4.4.0.dist-info/top_level.txt +1 -0
- open_space_toolkit_mathematics-4.4.0.dist-info/zip-safe +1 -0
- ostk/__init__.py +1 -0
- ostk/mathematics/OpenSpaceToolkitMathematicsPy.cpython-313-x86_64-linux-gnu.so +0 -0
- ostk/mathematics/__init__.py +5 -0
- ostk/mathematics/__init__.pyi +11 -0
- ostk/mathematics/curve_fitting/__init__.pyi +65 -0
- ostk/mathematics/curve_fitting/interpolator.pyi +46 -0
- ostk/mathematics/geometry/__init__.pyi +178 -0
- ostk/mathematics/geometry/d2/__init__.pyi +315 -0
- ostk/mathematics/geometry/d2/object.pyi +405 -0
- ostk/mathematics/geometry/d3/__init__.pyi +351 -0
- ostk/mathematics/geometry/d3/object.pyi +837 -0
- ostk/mathematics/geometry/d3/transformation/__init__.pyi +3 -0
- ostk/mathematics/geometry/d3/transformation/rotation.pyi +421 -0
- ostk/mathematics/libopen-space-toolkit-mathematics.so.4 +0 -0
- ostk/mathematics/object.pyi +123 -0
- ostk/mathematics/py.typed +0 -0
- ostk/mathematics/solver.pyi +147 -0
- ostk/mathematics/test/__init__.py +1 -0
- ostk/mathematics/test/curve_fitting/__init__.py +1 -0
- ostk/mathematics/test/curve_fitting/interpolator/__init__.py +1 -0
- ostk/mathematics/test/curve_fitting/interpolator/test_barycentric_rational.py +34 -0
- ostk/mathematics/test/curve_fitting/interpolator/test_cubic_spline.py +45 -0
- ostk/mathematics/test/curve_fitting/interpolator/test_interpolator.py +71 -0
- ostk/mathematics/test/curve_fitting/interpolator/test_linear.py +35 -0
- ostk/mathematics/test/geometry/__init__.py +1 -0
- ostk/mathematics/test/geometry/d2/__init__.py +1 -0
- ostk/mathematics/test/geometry/d2/conftest.py +82 -0
- ostk/mathematics/test/geometry/d2/object/__init__.py +1 -0
- ostk/mathematics/test/geometry/d2/object/test_composite.py +96 -0
- ostk/mathematics/test/geometry/d2/object/test_line.py +57 -0
- ostk/mathematics/test/geometry/d2/object/test_linestring.py +174 -0
- ostk/mathematics/test/geometry/d2/object/test_multipolygon.py +101 -0
- ostk/mathematics/test/geometry/d2/object/test_point.py +213 -0
- ostk/mathematics/test/geometry/d2/object/test_point_set.py +103 -0
- ostk/mathematics/test/geometry/d2/object/test_polygon.py +370 -0
- ostk/mathematics/test/geometry/d2/object/test_segment.py +104 -0
- ostk/mathematics/test/geometry/d2/test_object.py +25 -0
- ostk/mathematics/test/geometry/d2/test_transformation.py +84 -0
- ostk/mathematics/test/geometry/d3/__init__.py +1 -0
- ostk/mathematics/test/geometry/d3/object/__init__.py +1 -0
- ostk/mathematics/test/geometry/d3/object/test_composite.py +262 -0
- ostk/mathematics/test/geometry/d3/object/test_cuboid.py +20 -0
- ostk/mathematics/test/geometry/d3/object/test_line.py +68 -0
- ostk/mathematics/test/geometry/d3/object/test_linestring.py +168 -0
- ostk/mathematics/test/geometry/d3/object/test_point.py +234 -0
- ostk/mathematics/test/geometry/d3/object/test_point_set.py +116 -0
- ostk/mathematics/test/geometry/d3/object/test_polygon.py +141 -0
- ostk/mathematics/test/geometry/d3/object/test_segment.py +120 -0
- ostk/mathematics/test/geometry/d3/objects/test_cuboid.py +20 -0
- ostk/mathematics/test/geometry/d3/test_intersection.py +3 -0
- ostk/mathematics/test/geometry/d3/test_object.py +3 -0
- ostk/mathematics/test/geometry/d3/test_transformation.py +3 -0
- ostk/mathematics/test/geometry/d3/transformation/__init__.py +1 -0
- ostk/mathematics/test/geometry/d3/transformation/rotation/__init__.py +1 -0
- ostk/mathematics/test/geometry/d3/transformation/rotation/test_euler_angle.py +138 -0
- ostk/mathematics/test/geometry/d3/transformation/rotation/test_quaternion.py +185 -0
- ostk/mathematics/test/geometry/d3/transformation/rotation/test_rotation_matrix.py +29 -0
- ostk/mathematics/test/geometry/d3/transformation/rotation/test_rotation_vector.py +47 -0
- ostk/mathematics/test/geometry/test_angle.py +345 -0
- ostk/mathematics/test/object/__init__.py +1 -0
- ostk/mathematics/test/object/test_interval.py +515 -0
- ostk/mathematics/test/object/test_vector.py +5 -0
- ostk/mathematics/test/solver/test_numerical_solver.py +176 -0
- ostk/mathematics/test/test_object.py +24 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Apache License 2.0
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
import ostk.mathematics as mathematics
|
|
8
|
+
|
|
9
|
+
from ostk.core.type import String
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Object = mathematics.geometry.d2.Object
|
|
13
|
+
Polygon = mathematics.geometry.d2.object.Polygon
|
|
14
|
+
MultiPolygon = mathematics.geometry.d2.object.MultiPolygon
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TestMultipolygon:
|
|
18
|
+
def test_constructor_success(self, square_1: Polygon, square_2: Polygon):
|
|
19
|
+
# Construction using a python list of polygons
|
|
20
|
+
multipolygon: MultiPolygon = MultiPolygon([square_1, square_2])
|
|
21
|
+
|
|
22
|
+
assert multipolygon is not None
|
|
23
|
+
assert isinstance(multipolygon, MultiPolygon)
|
|
24
|
+
assert isinstance(multipolygon, Object)
|
|
25
|
+
assert multipolygon.is_defined()
|
|
26
|
+
|
|
27
|
+
# Construction using a python tuple of polygons
|
|
28
|
+
multipolygon: MultiPolygon = MultiPolygon((square_1, square_2))
|
|
29
|
+
|
|
30
|
+
assert multipolygon is not None
|
|
31
|
+
assert isinstance(multipolygon, MultiPolygon)
|
|
32
|
+
assert isinstance(multipolygon, Object)
|
|
33
|
+
assert multipolygon.is_defined()
|
|
34
|
+
|
|
35
|
+
# Construction using a python numpy array of polygons
|
|
36
|
+
multipolygon: MultiPolygon = MultiPolygon(np.array((square_1, square_2)))
|
|
37
|
+
|
|
38
|
+
assert multipolygon is not None
|
|
39
|
+
assert isinstance(multipolygon, MultiPolygon)
|
|
40
|
+
assert isinstance(multipolygon, Object)
|
|
41
|
+
assert multipolygon.is_defined()
|
|
42
|
+
|
|
43
|
+
# Construction using polygon static constructor
|
|
44
|
+
multipolygon: MultiPolygon = MultiPolygon.polygon(square_1)
|
|
45
|
+
|
|
46
|
+
assert multipolygon is not None
|
|
47
|
+
assert isinstance(multipolygon, MultiPolygon)
|
|
48
|
+
assert isinstance(multipolygon, Object)
|
|
49
|
+
assert multipolygon.is_defined()
|
|
50
|
+
|
|
51
|
+
# Construction using an array of one polygon
|
|
52
|
+
multipolygon: MultiPolygon = MultiPolygon([square_1])
|
|
53
|
+
|
|
54
|
+
assert multipolygon is not None
|
|
55
|
+
assert isinstance(multipolygon, MultiPolygon)
|
|
56
|
+
assert isinstance(multipolygon, Object)
|
|
57
|
+
assert multipolygon.is_defined()
|
|
58
|
+
|
|
59
|
+
def test_comparators_success(self, square_1: Polygon, square_2: Polygon):
|
|
60
|
+
# Multiple MultiPolygons
|
|
61
|
+
multipolygon_1: MultiPolygon = MultiPolygon([square_1, square_2])
|
|
62
|
+
multipolygon_2: MultiPolygon = MultiPolygon([square_1])
|
|
63
|
+
multipolygon_3: MultiPolygon = MultiPolygon.polygon(square_1)
|
|
64
|
+
|
|
65
|
+
assert multipolygon_1 == multipolygon_1
|
|
66
|
+
assert multipolygon_1 != multipolygon_2
|
|
67
|
+
assert multipolygon_1 != multipolygon_3
|
|
68
|
+
assert multipolygon_2 == multipolygon_3
|
|
69
|
+
|
|
70
|
+
def test_undefined_constructor_success(self):
|
|
71
|
+
multipolygon: MultiPolygon = MultiPolygon.undefined()
|
|
72
|
+
|
|
73
|
+
assert multipolygon is not None
|
|
74
|
+
assert isinstance(multipolygon, MultiPolygon)
|
|
75
|
+
assert isinstance(multipolygon, Object)
|
|
76
|
+
assert multipolygon.is_defined() is False
|
|
77
|
+
|
|
78
|
+
def test_getters_success(
|
|
79
|
+
self,
|
|
80
|
+
square_1: Polygon,
|
|
81
|
+
square_2: Polygon,
|
|
82
|
+
):
|
|
83
|
+
# Multiple Polygons
|
|
84
|
+
multipolygon: MultiPolygon = MultiPolygon([square_1, square_2])
|
|
85
|
+
|
|
86
|
+
assert multipolygon.get_polygon_count() == 2
|
|
87
|
+
assert multipolygon.get_polygons()[0] == square_1
|
|
88
|
+
assert multipolygon.get_polygons()[-1] == square_2
|
|
89
|
+
|
|
90
|
+
# One Polygon
|
|
91
|
+
multipolygon: MultiPolygon = MultiPolygon.polygon(square_1)
|
|
92
|
+
|
|
93
|
+
assert multipolygon.get_polygon_count() == 1
|
|
94
|
+
assert multipolygon.get_polygons()[0] == square_1
|
|
95
|
+
assert multipolygon.get_convex_hull() == square_1
|
|
96
|
+
|
|
97
|
+
# def test_union_with_success (self) :
|
|
98
|
+
|
|
99
|
+
# def test_to_string_success (self):
|
|
100
|
+
|
|
101
|
+
# def test_apply_transformation_success (self):
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Apache License 2.0
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
import math
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
import ostk.mathematics as mathematics
|
|
10
|
+
|
|
11
|
+
from ostk.core.type import String
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Object = mathematics.geometry.d2.Object
|
|
15
|
+
Point = mathematics.geometry.d2.object.Point
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class TestPoint:
|
|
19
|
+
def test_constructor_success(self):
|
|
20
|
+
point: Point = Point(1.0, 2.0)
|
|
21
|
+
|
|
22
|
+
assert point is not None
|
|
23
|
+
assert isinstance(point, Point)
|
|
24
|
+
assert isinstance(point, Object)
|
|
25
|
+
assert point.is_defined()
|
|
26
|
+
|
|
27
|
+
def test_undefined_constructor_success(self):
|
|
28
|
+
point: Point = Point.undefined()
|
|
29
|
+
|
|
30
|
+
assert point is not None
|
|
31
|
+
assert isinstance(point, Point)
|
|
32
|
+
assert isinstance(point, Object)
|
|
33
|
+
assert point.is_defined() is False
|
|
34
|
+
|
|
35
|
+
def test_origin_constructor_success(self):
|
|
36
|
+
point: Point = Point.origin()
|
|
37
|
+
|
|
38
|
+
assert point is not None
|
|
39
|
+
assert isinstance(point, Point)
|
|
40
|
+
assert isinstance(point, Object)
|
|
41
|
+
assert point.is_defined()
|
|
42
|
+
assert point.x() - 0.0 <= 1e-12
|
|
43
|
+
assert point.y() - 0.0 <= 1e-12
|
|
44
|
+
|
|
45
|
+
def test_vector_constructor_success(self):
|
|
46
|
+
# Construction using a python list
|
|
47
|
+
point: Point = Point.vector([3.4, -6.7])
|
|
48
|
+
|
|
49
|
+
assert point is not None
|
|
50
|
+
assert isinstance(point, Point)
|
|
51
|
+
assert isinstance(point, Object)
|
|
52
|
+
assert point.is_defined()
|
|
53
|
+
assert (point.x() - 3.4) <= 1e-15
|
|
54
|
+
assert (point.y() + 6.7) <= 1e-15
|
|
55
|
+
|
|
56
|
+
# Construction using a python tuple
|
|
57
|
+
point: Point = Point.vector((3.4, -6.7))
|
|
58
|
+
|
|
59
|
+
assert point is not None
|
|
60
|
+
assert isinstance(point, Point)
|
|
61
|
+
assert isinstance(point, Object)
|
|
62
|
+
assert point.is_defined()
|
|
63
|
+
assert (point.x() - 3.4) <= 1e-15
|
|
64
|
+
assert (point.y() + 6.7) <= 1e-15
|
|
65
|
+
|
|
66
|
+
# Construction using a python numpy array
|
|
67
|
+
point: Point = Point.vector(np.array((3.4, -6.7)))
|
|
68
|
+
|
|
69
|
+
assert point is not None
|
|
70
|
+
assert isinstance(point, Point)
|
|
71
|
+
assert isinstance(point, Object)
|
|
72
|
+
assert point.is_defined()
|
|
73
|
+
assert (point.x() - 3.4) <= 1e-15
|
|
74
|
+
assert (point.y() + 6.7) <= 1e-15
|
|
75
|
+
|
|
76
|
+
def test_comparators_success(self):
|
|
77
|
+
point_1: Point = Point(3.4, -6.7)
|
|
78
|
+
point_2: Point = Point.vector([3.4, -6.7])
|
|
79
|
+
point_3: Point = Point(3.3, -6.5)
|
|
80
|
+
point_4: Point = Point.vector(
|
|
81
|
+
(
|
|
82
|
+
3.4,
|
|
83
|
+
-6.7,
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
point_5: Point = Point.vector(np.array((3.4, -6.7)))
|
|
87
|
+
|
|
88
|
+
assert point_1 == point_1
|
|
89
|
+
assert point_1 == point_2
|
|
90
|
+
assert point_1 != point_3
|
|
91
|
+
assert point_2 != point_3
|
|
92
|
+
assert point_1 == point_4
|
|
93
|
+
assert point_1 == point_5
|
|
94
|
+
assert point_2 == point_4
|
|
95
|
+
assert point_2 == point_5
|
|
96
|
+
assert point_3 != point_4
|
|
97
|
+
|
|
98
|
+
def test_operators_success(self):
|
|
99
|
+
point_1: Point = Point(3.4, -6.7)
|
|
100
|
+
point_2: Point = Point.vector([3.4, -6.7])
|
|
101
|
+
point_3: Point = Point.vector((3.4, -6.7))
|
|
102
|
+
point_4: Point = Point.vector(np.array((3.3, -6.5)))
|
|
103
|
+
|
|
104
|
+
point: Point = point_1 + [3.4, -6.7]
|
|
105
|
+
|
|
106
|
+
assert point is not None
|
|
107
|
+
assert isinstance(point, Point)
|
|
108
|
+
assert point.is_defined()
|
|
109
|
+
assert point.x() - (point_1.x() + point_2.x()) <= 1e-12
|
|
110
|
+
assert point.y() - (point_1.y() + point_2.y()) <= 1e-12
|
|
111
|
+
|
|
112
|
+
point: Point = point_3 + [3.4, -6.7]
|
|
113
|
+
|
|
114
|
+
assert point is not None
|
|
115
|
+
assert isinstance(point, Point)
|
|
116
|
+
assert point.is_defined()
|
|
117
|
+
assert point.x() - (point_3.x() + point_2.x()) <= 1e-12
|
|
118
|
+
assert point.y() - (point_3.y() + point_2.y()) <= 1e-12
|
|
119
|
+
|
|
120
|
+
point: Point = point_1 + (3.3, -6.5)
|
|
121
|
+
|
|
122
|
+
assert point is not None
|
|
123
|
+
assert isinstance(point, Point)
|
|
124
|
+
assert point.is_defined()
|
|
125
|
+
assert point.x() - (point_1.x() + point_4.x()) <= 1e-12
|
|
126
|
+
assert point.y() - (point_1.y() + point_4.y()) <= 1e-12
|
|
127
|
+
|
|
128
|
+
point: Point = point_1 + (0.0, 0.0)
|
|
129
|
+
|
|
130
|
+
assert point is not None
|
|
131
|
+
assert isinstance(point, Point)
|
|
132
|
+
assert point.is_defined()
|
|
133
|
+
assert point == point_1
|
|
134
|
+
|
|
135
|
+
point: Point = point_1 + [0.0, 0.0]
|
|
136
|
+
|
|
137
|
+
assert point is not None
|
|
138
|
+
assert isinstance(point, Point)
|
|
139
|
+
assert point.is_defined()
|
|
140
|
+
assert point == point_1
|
|
141
|
+
|
|
142
|
+
point: Point = point_1 + np.array((0.0, 0.0))
|
|
143
|
+
|
|
144
|
+
assert point is not None
|
|
145
|
+
assert isinstance(point, Point)
|
|
146
|
+
assert point.is_defined()
|
|
147
|
+
assert point == point_1
|
|
148
|
+
|
|
149
|
+
# point: Point = point_1 - point_1
|
|
150
|
+
|
|
151
|
+
# assert point is not None
|
|
152
|
+
# assert isinstance(point, Point)
|
|
153
|
+
# assert isinstance(point, Object)
|
|
154
|
+
# assert point.is_defined()
|
|
155
|
+
# assert point.x == 0.0
|
|
156
|
+
# assert point.y == 0.0
|
|
157
|
+
# assert point == Point.origin()
|
|
158
|
+
|
|
159
|
+
def test_is_defined(self):
|
|
160
|
+
point: Point = Point(3.5, 5.6)
|
|
161
|
+
|
|
162
|
+
assert point.is_defined()
|
|
163
|
+
assert Point.undefined().is_defined() is False
|
|
164
|
+
|
|
165
|
+
def test_is_near(self):
|
|
166
|
+
point_1: Point = Point(3.5, 5.6)
|
|
167
|
+
point_2: Point = Point(3.4999999999, 5.5999999999)
|
|
168
|
+
|
|
169
|
+
assert point_1.is_near(point_2, 1e-8) is True
|
|
170
|
+
assert point_2.is_near(point_1, 1e-8) is True
|
|
171
|
+
assert point_1.is_near(point_2, 1e-11) is False
|
|
172
|
+
assert point_1.is_near(point_2, 1e-9) is True
|
|
173
|
+
|
|
174
|
+
def test_coordinates(self):
|
|
175
|
+
point: Point = Point(4.5, 34.5)
|
|
176
|
+
|
|
177
|
+
assert point.x() == 4.5
|
|
178
|
+
assert point.y() == 34.5
|
|
179
|
+
|
|
180
|
+
def test_as_vector(self):
|
|
181
|
+
point: Point = Point(3.4, -3.5)
|
|
182
|
+
vec: np.ndarray = point.as_vector()
|
|
183
|
+
|
|
184
|
+
assert vec is not None
|
|
185
|
+
assert isinstance(vec, np.ndarray)
|
|
186
|
+
|
|
187
|
+
def test_distance_to(self):
|
|
188
|
+
point_1: Point = Point(0.0, 4.0)
|
|
189
|
+
point_2: Point = Point(0.0, 3.0)
|
|
190
|
+
point_3: Point = Point(3.0, 0.0)
|
|
191
|
+
point_4: Point = Point(1.1, 1.0)
|
|
192
|
+
|
|
193
|
+
assert point_1.distance_to(point_2) == 1.0
|
|
194
|
+
assert point_2.distance_to(point_1) == 1.0
|
|
195
|
+
|
|
196
|
+
assert point_1.distance_to(point_3) == 5.0
|
|
197
|
+
assert point_3.distance_to(point_1) == 5.0
|
|
198
|
+
|
|
199
|
+
assert point_1.distance_to(point_4) == math.sqrt((1.1 * 1.1) + 9.0)
|
|
200
|
+
assert point_4.distance_to(point_1) == math.sqrt((1.1 * 1.1) + 9.0)
|
|
201
|
+
|
|
202
|
+
with pytest.raises(TypeError):
|
|
203
|
+
point_1.distance_to((0.0, 0.0))
|
|
204
|
+
|
|
205
|
+
def test_to_string(self):
|
|
206
|
+
point: Point = Point(3.0, 5.0)
|
|
207
|
+
|
|
208
|
+
assert isinstance(point.to_string(), String)
|
|
209
|
+
assert point.to_string() == "[3.0, 5.0]"
|
|
210
|
+
|
|
211
|
+
# def test_apply_transformation_success (self):
|
|
212
|
+
|
|
213
|
+
# point: Point = Point(4.5, 5.4)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Apache License 2.0
|
|
2
|
+
|
|
3
|
+
from collections.abc import Iterator, Iterable
|
|
4
|
+
|
|
5
|
+
import ostk.mathematics as mathematics
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object = mathematics.geometry.d2.Object
|
|
9
|
+
Point = mathematics.geometry.d2.object.Point
|
|
10
|
+
PointSet = mathematics.geometry.d2.object.PointSet
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class TestPointSet:
|
|
14
|
+
def test_constructor_success(self):
|
|
15
|
+
point_1: Point = Point(1.0, 2.0)
|
|
16
|
+
point_2: Point = Point(3.0, 4.0)
|
|
17
|
+
|
|
18
|
+
# Construction using python list
|
|
19
|
+
point_set: PointSet = PointSet([point_1, point_2])
|
|
20
|
+
|
|
21
|
+
assert point_set is not None
|
|
22
|
+
assert isinstance(point_set, PointSet)
|
|
23
|
+
assert isinstance(point_set, Object)
|
|
24
|
+
assert point_set.is_defined()
|
|
25
|
+
|
|
26
|
+
# Construction using python tuple
|
|
27
|
+
point_set = PointSet((point_1, point_2))
|
|
28
|
+
|
|
29
|
+
assert point_set is not None
|
|
30
|
+
assert isinstance(point_set, PointSet)
|
|
31
|
+
assert isinstance(point_set, Object)
|
|
32
|
+
assert point_set.is_defined()
|
|
33
|
+
|
|
34
|
+
point_set = PointSet((point_1,))
|
|
35
|
+
|
|
36
|
+
assert point_set is not None
|
|
37
|
+
assert isinstance(point_set, PointSet)
|
|
38
|
+
assert isinstance(point_set, Object)
|
|
39
|
+
assert point_set.is_defined()
|
|
40
|
+
|
|
41
|
+
def test_empty_success(self):
|
|
42
|
+
point_set: Pointset = PointSet.empty()
|
|
43
|
+
|
|
44
|
+
assert point_set is not None
|
|
45
|
+
assert isinstance(point_set, PointSet)
|
|
46
|
+
assert isinstance(point_set, Object)
|
|
47
|
+
assert point_set.is_defined() is False
|
|
48
|
+
assert point_set.is_empty()
|
|
49
|
+
|
|
50
|
+
def test_comparators_success(self):
|
|
51
|
+
point_1: Point = Point(1.0, 2.0)
|
|
52
|
+
point_2: Point = Point(3.0, 4.0)
|
|
53
|
+
|
|
54
|
+
point_set_1: PointSet = PointSet([point_1, point_2])
|
|
55
|
+
point_set_2: PointSet = PointSet((point_2, point_1))
|
|
56
|
+
point_set_3: PointSet = PointSet([point_2])
|
|
57
|
+
|
|
58
|
+
assert point_set_1 == point_set_2
|
|
59
|
+
assert point_set_1 == point_set_2
|
|
60
|
+
assert point_set_3 != point_set_1
|
|
61
|
+
assert point_set_2 != point_set_3
|
|
62
|
+
|
|
63
|
+
def test_get_size_success(self):
|
|
64
|
+
point_1: Point = Point(1.0, 2.0)
|
|
65
|
+
point_2: Point = Point(3.0, 4.0)
|
|
66
|
+
|
|
67
|
+
point_set_1: PointSet = PointSet([point_1, point_2])
|
|
68
|
+
point_set_2: PointSet = PointSet((point_2, point_1))
|
|
69
|
+
point_set_3: PointSet = PointSet([point_2])
|
|
70
|
+
point_set_4: PointSet = PointSet.empty()
|
|
71
|
+
point_set_5: PointSet = PointSet([point_1, point_1])
|
|
72
|
+
|
|
73
|
+
assert point_set_1.get_size() == 2
|
|
74
|
+
assert point_set_2.get_size() == 2
|
|
75
|
+
assert point_set_3.get_size() == 1
|
|
76
|
+
assert point_set_4.get_size() == 0
|
|
77
|
+
assert point_set_5.get_size() == 1
|
|
78
|
+
|
|
79
|
+
def test_distance_to_success_point(self, point_set: PointSet):
|
|
80
|
+
assert point_set.distance_to(Point(1.0, 2.0)) == 0.0
|
|
81
|
+
|
|
82
|
+
def test_len_success(self, point_set: PointSet):
|
|
83
|
+
assert len(point_set) == 2
|
|
84
|
+
assert len(PointSet.empty()) == 0
|
|
85
|
+
|
|
86
|
+
def test_iter_success(self, point_set: PointSet):
|
|
87
|
+
for point in point_set:
|
|
88
|
+
assert isinstance(point, Point)
|
|
89
|
+
|
|
90
|
+
assert iter(point_set) is not None
|
|
91
|
+
assert isinstance(iter(point_set), Iterator)
|
|
92
|
+
assert isinstance(iter(point_set), Iterable)
|
|
93
|
+
|
|
94
|
+
def test_get_item_success(self, point_set: PointSet):
|
|
95
|
+
assert point_set[0] is not None
|
|
96
|
+
|
|
97
|
+
# def test_is_near_success(self):
|
|
98
|
+
|
|
99
|
+
# def test_get_point_closest_to_success(self):
|
|
100
|
+
|
|
101
|
+
# def test_to_string_success(self):
|
|
102
|
+
|
|
103
|
+
# def test_apply_transformation_success(self):
|