open-space-toolkit-mathematics 4.0.1__py310-none-manylinux2014_aarch64.whl → 4.2.0__py310-none-manylinux2014_aarch64.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.0.1.dist-info → open_space_toolkit_mathematics-4.2.0.dist-info}/METADATA +1 -1
- {open_space_toolkit_mathematics-4.0.1.dist-info → open_space_toolkit_mathematics-4.2.0.dist-info}/RECORD +9 -9
- ostk/mathematics/OpenSpaceToolkitMathematicsPy.cpython-310-aarch64-linux-gnu.so +0 -0
- ostk/mathematics/test/geometry/d2/object/test_point_set.py +3 -2
- ostk/mathematics/test/geometry/d3/object/test_point_set.py +3 -0
- ostk/mathematics/test/object/test_interval.py +177 -101
- {open_space_toolkit_mathematics-4.0.1.dist-info → open_space_toolkit_mathematics-4.2.0.dist-info}/WHEEL +0 -0
- {open_space_toolkit_mathematics-4.0.1.dist-info → open_space_toolkit_mathematics-4.2.0.dist-info}/top_level.txt +0 -0
- {open_space_toolkit_mathematics-4.0.1.dist-info → open_space_toolkit_mathematics-4.2.0.dist-info}/zip-safe +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
ostk/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
|
|
2
|
-
ostk/mathematics/OpenSpaceToolkitMathematicsPy.cpython-310-aarch64-linux-gnu.so,sha256=
|
|
2
|
+
ostk/mathematics/OpenSpaceToolkitMathematicsPy.cpython-310-aarch64-linux-gnu.so,sha256=HvmPrcnZbIIZyMOsnuRyxbx6aVXxHKDrCancHFZEnXk,1541816
|
|
3
3
|
ostk/mathematics/__init__.py,sha256=U81I6jh2hIPyuT4dtZjNcLi-CQ8yXIvtFn32tVK1YCY,92
|
|
4
4
|
ostk/mathematics/libopen-space-toolkit-mathematics.so.4,sha256=xnL1DaFwUYYMVtCymNUZ0X_I-visG0ISIACY67HfxtA,2505264
|
|
5
5
|
ostk/mathematics/test/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
|
|
@@ -22,7 +22,7 @@ ostk/mathematics/test/geometry/d2/object/test_line.py,sha256=Dr0uHk-gFLJcsC69W1D
|
|
|
22
22
|
ostk/mathematics/test/geometry/d2/object/test_linestring.py,sha256=EucjDiSSQ2Ab3-huWtfanE6Cb0Jazb78LUuiFnpe8Mo,5933
|
|
23
23
|
ostk/mathematics/test/geometry/d2/object/test_multipolygon.py,sha256=kxLhoygnMIiSreFvf3C2nycFpZjZCHcit96cN0y5QYo,3543
|
|
24
24
|
ostk/mathematics/test/geometry/d2/object/test_point.py,sha256=Eoq1FAYB6W4yrjpassgG9PRb3Zdg2DOjpmTZZuNiQ9M,6457
|
|
25
|
-
ostk/mathematics/test/geometry/d2/object/test_point_set.py,sha256=
|
|
25
|
+
ostk/mathematics/test/geometry/d2/object/test_point_set.py,sha256=hxrck57IHXDkZa0FV717eAvj_sbDtUIqC2LX-ae4EZ0,3337
|
|
26
26
|
ostk/mathematics/test/geometry/d2/object/test_polygon.py,sha256=fHEJDXmzgl24-eQ3gMGIBwNZsEa-3F6_8T6eLzaVgFI,12621
|
|
27
27
|
ostk/mathematics/test/geometry/d2/object/test_segment.py,sha256=M1QTkseGo1ADeslcEl5JzlQEc_1-1LpBV4av_FuPX7E,3072
|
|
28
28
|
ostk/mathematics/test/geometry/d3/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
|
|
@@ -35,7 +35,7 @@ ostk/mathematics/test/geometry/d3/object/test_cuboid.py,sha256=xJp6ImRnkNw_k6Tt8
|
|
|
35
35
|
ostk/mathematics/test/geometry/d3/object/test_line.py,sha256=d-CvDjXeH1WQcleCU2yt4FdHLhWgy45NGzn3mEwy6xE,1690
|
|
36
36
|
ostk/mathematics/test/geometry/d3/object/test_linestring.py,sha256=L2gEJGDOaP17RgbLbX0-kBjskW_MrPLxVyf_l9yyxag,5938
|
|
37
37
|
ostk/mathematics/test/geometry/d3/object/test_point.py,sha256=-5Cjy3Pru3UWbMO7vBDNiJYfUkqVVxxZtDgsMYYaosc,6611
|
|
38
|
-
ostk/mathematics/test/geometry/d3/object/test_point_set.py,sha256=
|
|
38
|
+
ostk/mathematics/test/geometry/d3/object/test_point_set.py,sha256=ceMRMNcnVAAsuMWORMW6wwJDNbTtMn3y-4rWR04QnPM,3605
|
|
39
39
|
ostk/mathematics/test/geometry/d3/object/test_polygon.py,sha256=7ZjucWMsNzppN3pptxHgGgOtOGv1grseT7VnctgOJP4,4262
|
|
40
40
|
ostk/mathematics/test/geometry/d3/object/test_segment.py,sha256=HWg-BCJoa74EgWlvUPd85v_qR2p9THi0ejhtG0EQNEA,4027
|
|
41
41
|
ostk/mathematics/test/geometry/d3/objects/test_cuboid.py,sha256=uIDwPbkygXFIopKc2kayKYgadNfOKD_zxf3w2J4DfTY,471
|
|
@@ -46,11 +46,11 @@ ostk/mathematics/test/geometry/d3/transformation/rotation/test_quaternion.py,sha
|
|
|
46
46
|
ostk/mathematics/test/geometry/d3/transformation/rotation/test_rotation_matrix.py,sha256=pD-zR2e1uMTD2eenjQiFPPMKji_gdnuYPuDYQ7pGgUg,1055
|
|
47
47
|
ostk/mathematics/test/geometry/d3/transformation/rotation/test_rotation_vector.py,sha256=ngzrvqH_0QRGwNsWc2RupUkpsTU5vZI-eoh5q2BkKRQ,1568
|
|
48
48
|
ostk/mathematics/test/object/__init__.py,sha256=epnVn2PwdQkUDZ1msqBRO5nEZIOUBIq-IfK3IlNPijE,21
|
|
49
|
-
ostk/mathematics/test/object/test_interval.py,sha256=
|
|
49
|
+
ostk/mathematics/test/object/test_interval.py,sha256=rf7tL-m76inO18rzxopkWrk-cSjKhoN5xXek6e53wAU,21708
|
|
50
50
|
ostk/mathematics/test/object/test_vector.py,sha256=5MG3s8vhgoGKAIc5GzswlZObyIrJDIPNtsEd5wNORPU,76
|
|
51
51
|
ostk/mathematics/test/solver/test_numerical_solver.py,sha256=5Z7uXlvfQ_pjrSAOd7ff-ky5pjRZk3-R0F565FfCUrU,5672
|
|
52
|
-
open_space_toolkit_mathematics-4.0.
|
|
53
|
-
open_space_toolkit_mathematics-4.0.
|
|
54
|
-
open_space_toolkit_mathematics-4.0.
|
|
55
|
-
open_space_toolkit_mathematics-4.0.
|
|
56
|
-
open_space_toolkit_mathematics-4.0.
|
|
52
|
+
open_space_toolkit_mathematics-4.2.0.dist-info/METADATA,sha256=coHoNlg7g_qxCg_HslAcjTpM_xb4xylMqkHgcxV1KBo,1801
|
|
53
|
+
open_space_toolkit_mathematics-4.2.0.dist-info/WHEEL,sha256=qqN5URp-VURm8LPVcwSxCMMwBbCqD2CU32siGCKjjV0,111
|
|
54
|
+
open_space_toolkit_mathematics-4.2.0.dist-info/top_level.txt,sha256=zOR18699uDYnafgarhL8WU_LmTZY_5NVqutv-flp_x4,5
|
|
55
|
+
open_space_toolkit_mathematics-4.2.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
56
|
+
open_space_toolkit_mathematics-4.2.0.dist-info/RECORD,,
|
|
Binary file
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
from collections.abc import Iterator, Iterable
|
|
4
4
|
|
|
5
|
-
import pytest
|
|
6
|
-
|
|
7
5
|
import ostk.mathematics as mathematics
|
|
8
6
|
|
|
9
7
|
|
|
@@ -93,6 +91,9 @@ class TestPointSet:
|
|
|
93
91
|
assert isinstance(iter(point_set), Iterator)
|
|
94
92
|
assert isinstance(iter(point_set), Iterable)
|
|
95
93
|
|
|
94
|
+
def test_get_item_success(self, point_set: PointSet):
|
|
95
|
+
assert point_set[0] is not None
|
|
96
|
+
|
|
96
97
|
# def test_is_near_success(self):
|
|
97
98
|
|
|
98
99
|
# def test_get_point_closest_to_success(self):
|
|
@@ -104,6 +104,9 @@ class TestPointSet:
|
|
|
104
104
|
assert isinstance(iter(point_set), Iterator)
|
|
105
105
|
assert isinstance(iter(point_set), Iterable)
|
|
106
106
|
|
|
107
|
+
def test_get_item_success(self, point_set: PointSet):
|
|
108
|
+
assert point_set[0] is not None
|
|
109
|
+
|
|
107
110
|
# def test_is_near_success(self):
|
|
108
111
|
|
|
109
112
|
# def test_get_point_closest_to_success(self):
|
|
@@ -2,18 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import pytest
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
from ostk.core.type import Real
|
|
6
|
+
from ostk.core.type import String
|
|
6
7
|
|
|
7
|
-
from ostk.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
RealInterval = mathematics.object.RealInterval
|
|
11
|
-
Type = RealInterval.Type
|
|
8
|
+
from ostk.mathematics.object import RealInterval
|
|
12
9
|
|
|
13
10
|
|
|
14
11
|
class TestInterval:
|
|
15
12
|
def test_type(self):
|
|
16
|
-
enum_members = Type.__members__
|
|
13
|
+
enum_members = RealInterval.Type.__members__
|
|
17
14
|
|
|
18
15
|
assert list(enum_members.keys()) == [
|
|
19
16
|
"Undefined",
|
|
@@ -23,19 +20,19 @@ class TestInterval:
|
|
|
23
20
|
"HalfOpenRight",
|
|
24
21
|
]
|
|
25
22
|
assert list(enum_members.values()) == [
|
|
26
|
-
Type.Undefined,
|
|
27
|
-
Type.Closed,
|
|
28
|
-
Type.Open,
|
|
29
|
-
Type.HalfOpenLeft,
|
|
30
|
-
Type.HalfOpenRight,
|
|
23
|
+
RealInterval.Type.Undefined,
|
|
24
|
+
RealInterval.Type.Closed,
|
|
25
|
+
RealInterval.Type.Open,
|
|
26
|
+
RealInterval.Type.HalfOpenLeft,
|
|
27
|
+
RealInterval.Type.HalfOpenRight,
|
|
31
28
|
]
|
|
32
29
|
|
|
33
30
|
def test_default_constructor(self):
|
|
34
31
|
# Input types for RealInterval
|
|
35
|
-
interval_1 = RealInterval(-4.31, 1.0, Type.Open)
|
|
36
|
-
interval_2 = RealInterval(-2.0, -1.0, Type.Closed)
|
|
37
|
-
interval_3 = RealInterval(3.5, 4567.35566, Type.HalfOpenRight)
|
|
38
|
-
interval_4 = RealInterval(1.45, 1.45, Type.Closed)
|
|
32
|
+
interval_1 = RealInterval(-4.31, 1.0, RealInterval.Type.Open)
|
|
33
|
+
interval_2 = RealInterval(-2.0, -1.0, RealInterval.Type.Closed)
|
|
34
|
+
interval_3 = RealInterval(3.5, 4567.35566, RealInterval.Type.HalfOpenRight)
|
|
35
|
+
interval_4 = RealInterval(1.45, 1.45, RealInterval.Type.Closed)
|
|
39
36
|
|
|
40
37
|
assert isinstance(interval_1, RealInterval)
|
|
41
38
|
assert isinstance(interval_2, RealInterval)
|
|
@@ -47,12 +44,14 @@ class TestInterval:
|
|
|
47
44
|
assert interval_4 is not None
|
|
48
45
|
|
|
49
46
|
with pytest.raises(TypeError):
|
|
50
|
-
interval = RealInterval(3.0, 1, Type.Closed)
|
|
47
|
+
interval = RealInterval(3.0, 1, RealInterval.Type.Closed)
|
|
51
48
|
|
|
52
|
-
interval_5 = RealInterval(Real(-4.31), Real(1.0), Type.Open)
|
|
53
|
-
interval_6 = RealInterval(Real(-2.0), Real(-1.0), Type.Closed)
|
|
54
|
-
interval_7 = RealInterval(
|
|
55
|
-
|
|
49
|
+
interval_5 = RealInterval(Real(-4.31), Real(1.0), RealInterval.Type.Open)
|
|
50
|
+
interval_6 = RealInterval(Real(-2.0), Real(-1.0), RealInterval.Type.Closed)
|
|
51
|
+
interval_7 = RealInterval(
|
|
52
|
+
Real(3.5), Real(4567.35566), RealInterval.Type.HalfOpenRight
|
|
53
|
+
)
|
|
54
|
+
interval_8 = RealInterval(Real(1.45), Real(1.45), RealInterval.Type.Closed)
|
|
56
55
|
|
|
57
56
|
assert isinstance(interval_5, RealInterval)
|
|
58
57
|
assert isinstance(interval_6, RealInterval)
|
|
@@ -68,11 +67,11 @@ class TestInterval:
|
|
|
68
67
|
b = 3.0
|
|
69
68
|
|
|
70
69
|
# Types of RealInterval
|
|
71
|
-
interval_undefined = RealInterval(a, b, Type.Undefined)
|
|
72
|
-
interval_closed = RealInterval(a, b, Type.Closed)
|
|
73
|
-
interval_open = RealInterval(a, b, Type.Open)
|
|
74
|
-
interval_halfopenleft = RealInterval(a, b, Type.HalfOpenLeft)
|
|
75
|
-
interval_halfopenright = RealInterval(a, b, Type.HalfOpenRight)
|
|
70
|
+
interval_undefined = RealInterval(a, b, RealInterval.Type.Undefined)
|
|
71
|
+
interval_closed = RealInterval(a, b, RealInterval.Type.Closed)
|
|
72
|
+
interval_open = RealInterval(a, b, RealInterval.Type.Open)
|
|
73
|
+
interval_halfopenleft = RealInterval(a, b, RealInterval.Type.HalfOpenLeft)
|
|
74
|
+
interval_halfopenright = RealInterval(a, b, RealInterval.Type.HalfOpenRight)
|
|
76
75
|
|
|
77
76
|
assert isinstance(interval_undefined, RealInterval)
|
|
78
77
|
assert isinstance(interval_closed, RealInterval)
|
|
@@ -83,16 +82,16 @@ class TestInterval:
|
|
|
83
82
|
# Unvalid interval definition
|
|
84
83
|
|
|
85
84
|
with pytest.raises(RuntimeError):
|
|
86
|
-
invalid_interval_1 = RealInterval(4.8, 3.5, Type.Open)
|
|
85
|
+
invalid_interval_1 = RealInterval(4.8, 3.5, RealInterval.Type.Open)
|
|
87
86
|
|
|
88
87
|
with pytest.raises(RuntimeError):
|
|
89
|
-
invalid_interval_2 = RealInterval(4.8, 3.5, Type.Closed)
|
|
88
|
+
invalid_interval_2 = RealInterval(4.8, 3.5, RealInterval.Type.Closed)
|
|
90
89
|
|
|
91
90
|
with pytest.raises(RuntimeError):
|
|
92
|
-
invalid_interval_3 = RealInterval(4.8, 3.5, Type.HalfOpenLeft)
|
|
91
|
+
invalid_interval_3 = RealInterval(4.8, 3.5, RealInterval.Type.HalfOpenLeft)
|
|
93
92
|
|
|
94
93
|
with pytest.raises(RuntimeError):
|
|
95
|
-
invalid_interval_4 = RealInterval(4.8, 3.5, Type.HalfOpenRight)
|
|
94
|
+
invalid_interval_4 = RealInterval(4.8, 3.5, RealInterval.Type.HalfOpenRight)
|
|
96
95
|
|
|
97
96
|
def test_undefined_constructor(self):
|
|
98
97
|
undefined_interval = RealInterval.undefined()
|
|
@@ -101,11 +100,20 @@ class TestInterval:
|
|
|
101
100
|
assert undefined_interval is not None
|
|
102
101
|
assert undefined_interval.is_defined() is False
|
|
103
102
|
|
|
104
|
-
|
|
103
|
+
@pytest.mark.parametrize(
|
|
104
|
+
"static_func",
|
|
105
|
+
[
|
|
106
|
+
(RealInterval.closed),
|
|
107
|
+
(RealInterval.open),
|
|
108
|
+
(RealInterval.half_open_left),
|
|
109
|
+
(RealInterval.half_open_right),
|
|
110
|
+
],
|
|
111
|
+
)
|
|
112
|
+
def test_static_constructors(self, static_func):
|
|
105
113
|
a = -3.1
|
|
106
114
|
b = 45.6
|
|
107
115
|
|
|
108
|
-
closed_interval =
|
|
116
|
+
closed_interval = static_func(a, b)
|
|
109
117
|
|
|
110
118
|
assert isinstance(closed_interval, RealInterval)
|
|
111
119
|
assert closed_interval is not None
|
|
@@ -119,11 +127,11 @@ class TestInterval:
|
|
|
119
127
|
b = 3.0
|
|
120
128
|
|
|
121
129
|
# Types of RealInterval
|
|
122
|
-
interval_undefined = RealInterval(a, b, Type.Undefined)
|
|
123
|
-
interval_closed = RealInterval(a, b, Type.Closed)
|
|
124
|
-
interval_open = RealInterval(a, b, Type.Open)
|
|
125
|
-
interval_halfopenleft = RealInterval(a, b, Type.HalfOpenLeft)
|
|
126
|
-
interval_halfopenright = RealInterval(a, b, Type.HalfOpenRight)
|
|
130
|
+
interval_undefined = RealInterval(a, b, RealInterval.Type.Undefined)
|
|
131
|
+
interval_closed = RealInterval(a, b, RealInterval.Type.Closed)
|
|
132
|
+
interval_open = RealInterval(a, b, RealInterval.Type.Open)
|
|
133
|
+
interval_halfopenleft = RealInterval(a, b, RealInterval.Type.HalfOpenLeft)
|
|
134
|
+
interval_halfopenright = RealInterval(a, b, RealInterval.Type.HalfOpenRight)
|
|
127
135
|
|
|
128
136
|
assert interval_undefined.is_defined() is False
|
|
129
137
|
assert interval_closed.is_defined() is True
|
|
@@ -140,21 +148,21 @@ class TestInterval:
|
|
|
140
148
|
b = 3.0
|
|
141
149
|
|
|
142
150
|
# Types of RealInterval
|
|
143
|
-
interval_undefined = RealInterval(a, b, Type.Undefined)
|
|
144
|
-
interval_closed = RealInterval(a, b, Type.Closed)
|
|
145
|
-
interval_open = RealInterval(a, b, Type.Open)
|
|
146
|
-
interval_halfopenleft = RealInterval(a, b, Type.HalfOpenLeft)
|
|
147
|
-
interval_halfopenright = RealInterval(a, b, Type.HalfOpenRight)
|
|
151
|
+
interval_undefined = RealInterval(a, b, RealInterval.Type.Undefined)
|
|
152
|
+
interval_closed = RealInterval(a, b, RealInterval.Type.Closed)
|
|
153
|
+
interval_open = RealInterval(a, b, RealInterval.Type.Open)
|
|
154
|
+
interval_halfopenleft = RealInterval(a, b, RealInterval.Type.HalfOpenLeft)
|
|
155
|
+
interval_halfopenright = RealInterval(a, b, RealInterval.Type.HalfOpenRight)
|
|
148
156
|
|
|
149
157
|
# Define Test Intervals
|
|
150
|
-
interval_left = RealInterval(-5.0, -4.5, Type.Closed)
|
|
151
|
-
interval_intersects_left = RealInterval(-5.0, -4.26, Type.Closed)
|
|
152
|
-
interval_right = RealInterval(4.56, 4.67, Type.Closed)
|
|
153
|
-
interval_intersects_right = RealInterval(2.78, 46.09, Type.Closed)
|
|
154
|
-
interval_between = RealInterval(-3.4, 2.45, Type.Closed)
|
|
155
|
-
interval_bigger = RealInterval(-45.0, 34.12, Type.Closed)
|
|
156
|
-
|
|
157
|
-
# Add test cases with contained intervals not Type.Closed...
|
|
158
|
+
interval_left = RealInterval(-5.0, -4.5, RealInterval.Type.Closed)
|
|
159
|
+
interval_intersects_left = RealInterval(-5.0, -4.26, RealInterval.Type.Closed)
|
|
160
|
+
interval_right = RealInterval(4.56, 4.67, RealInterval.Type.Closed)
|
|
161
|
+
interval_intersects_right = RealInterval(2.78, 46.09, RealInterval.Type.Closed)
|
|
162
|
+
interval_between = RealInterval(-3.4, 2.45, RealInterval.Type.Closed)
|
|
163
|
+
interval_bigger = RealInterval(-45.0, 34.12, RealInterval.Type.Closed)
|
|
164
|
+
|
|
165
|
+
# Add test cases with contained intervals not RealInterval.Type.Closed...
|
|
158
166
|
# Add test cases with open intervals and half open intervals...
|
|
159
167
|
|
|
160
168
|
# Test intersects on undefined
|
|
@@ -205,11 +213,11 @@ class TestInterval:
|
|
|
205
213
|
b = 3.0
|
|
206
214
|
|
|
207
215
|
# Types of RealInterval
|
|
208
|
-
interval_undefined = RealInterval(a, b, Type.Undefined)
|
|
209
|
-
interval_closed = RealInterval(a, b, Type.Closed)
|
|
210
|
-
interval_open = RealInterval(a, b, Type.Open)
|
|
211
|
-
interval_halfopenleft = RealInterval(a, b, Type.HalfOpenLeft)
|
|
212
|
-
interval_halfopenright = RealInterval(a, b, Type.HalfOpenRight)
|
|
216
|
+
interval_undefined = RealInterval(a, b, RealInterval.Type.Undefined)
|
|
217
|
+
interval_closed = RealInterval(a, b, RealInterval.Type.Closed)
|
|
218
|
+
interval_open = RealInterval(a, b, RealInterval.Type.Open)
|
|
219
|
+
interval_halfopenleft = RealInterval(a, b, RealInterval.Type.HalfOpenLeft)
|
|
220
|
+
interval_halfopenright = RealInterval(a, b, RealInterval.Type.HalfOpenRight)
|
|
213
221
|
|
|
214
222
|
# Define Reals
|
|
215
223
|
real_left = -5.43
|
|
@@ -266,21 +274,21 @@ class TestInterval:
|
|
|
266
274
|
b = 3.0
|
|
267
275
|
|
|
268
276
|
# Types of RealInterval
|
|
269
|
-
interval_undefined = RealInterval(a, b, Type.Undefined)
|
|
270
|
-
interval_closed = RealInterval(a, b, Type.Closed)
|
|
271
|
-
interval_open = RealInterval(a, b, Type.Open)
|
|
272
|
-
interval_halfopenleft = RealInterval(a, b, Type.HalfOpenLeft)
|
|
273
|
-
interval_halfopenright = RealInterval(a, b, Type.HalfOpenRight)
|
|
277
|
+
interval_undefined = RealInterval(a, b, RealInterval.Type.Undefined)
|
|
278
|
+
interval_closed = RealInterval(a, b, RealInterval.Type.Closed)
|
|
279
|
+
interval_open = RealInterval(a, b, RealInterval.Type.Open)
|
|
280
|
+
interval_halfopenleft = RealInterval(a, b, RealInterval.Type.HalfOpenLeft)
|
|
281
|
+
interval_halfopenright = RealInterval(a, b, RealInterval.Type.HalfOpenRight)
|
|
274
282
|
|
|
275
283
|
# Define Test Intervals
|
|
276
|
-
interval_left = RealInterval(-5.0, -4.5, Type.Closed)
|
|
277
|
-
interval_intersects_left = RealInterval(-5.0, -4.56, Type.Closed)
|
|
278
|
-
interval_right = RealInterval(4.56, 4.67, Type.Closed)
|
|
279
|
-
interval_intersects_right = RealInterval(2.78, 46.09, Type.Closed)
|
|
280
|
-
interval_between = RealInterval(-3.4, 2.45, Type.Closed)
|
|
281
|
-
interval_bigger = RealInterval(-45.0, 34.12, Type.Closed)
|
|
284
|
+
interval_left = RealInterval(-5.0, -4.5, RealInterval.Type.Closed)
|
|
285
|
+
interval_intersects_left = RealInterval(-5.0, -4.56, RealInterval.Type.Closed)
|
|
286
|
+
interval_right = RealInterval(4.56, 4.67, RealInterval.Type.Closed)
|
|
287
|
+
interval_intersects_right = RealInterval(2.78, 46.09, RealInterval.Type.Closed)
|
|
288
|
+
interval_between = RealInterval(-3.4, 2.45, RealInterval.Type.Closed)
|
|
289
|
+
interval_bigger = RealInterval(-45.0, 34.12, RealInterval.Type.Closed)
|
|
282
290
|
|
|
283
|
-
# Add test cases with contained intervals not Type.Closed...
|
|
291
|
+
# Add test cases with contained intervals not RealInterval.Type.Closed...
|
|
284
292
|
|
|
285
293
|
# Test contains on undefined
|
|
286
294
|
|
|
@@ -329,11 +337,11 @@ class TestInterval:
|
|
|
329
337
|
b = 3.0
|
|
330
338
|
|
|
331
339
|
# Types of RealInterval
|
|
332
|
-
interval_undefined = RealInterval(a, b, Type.Undefined)
|
|
333
|
-
interval_closed = RealInterval(a, b, Type.Closed)
|
|
334
|
-
interval_open = RealInterval(a, b, Type.Open)
|
|
335
|
-
interval_halfopenleft = RealInterval(a, b, Type.HalfOpenLeft)
|
|
336
|
-
interval_halfopenright = RealInterval(a, b, Type.HalfOpenRight)
|
|
340
|
+
interval_undefined = RealInterval(a, b, RealInterval.Type.Undefined)
|
|
341
|
+
interval_closed = RealInterval(a, b, RealInterval.Type.Closed)
|
|
342
|
+
interval_open = RealInterval(a, b, RealInterval.Type.Open)
|
|
343
|
+
interval_halfopenleft = RealInterval(a, b, RealInterval.Type.HalfOpenLeft)
|
|
344
|
+
interval_halfopenright = RealInterval(a, b, RealInterval.Type.HalfOpenRight)
|
|
337
345
|
|
|
338
346
|
# get_lower_bound
|
|
339
347
|
with pytest.raises(RuntimeError):
|
|
@@ -359,11 +367,11 @@ class TestInterval:
|
|
|
359
367
|
b = 3.0
|
|
360
368
|
|
|
361
369
|
# Types of RealInterval
|
|
362
|
-
interval_undefined = RealInterval(a, b, Type.Undefined)
|
|
363
|
-
interval_closed = RealInterval(a, b, Type.Closed)
|
|
364
|
-
interval_open = RealInterval(a, b, Type.Open)
|
|
365
|
-
interval_halfopenleft = RealInterval(a, b, Type.HalfOpenLeft)
|
|
366
|
-
interval_halfopenright = RealInterval(a, b, Type.HalfOpenRight)
|
|
370
|
+
interval_undefined = RealInterval(a, b, RealInterval.Type.Undefined)
|
|
371
|
+
interval_closed = RealInterval(a, b, RealInterval.Type.Closed)
|
|
372
|
+
interval_open = RealInterval(a, b, RealInterval.Type.Open)
|
|
373
|
+
interval_halfopenleft = RealInterval(a, b, RealInterval.Type.HalfOpenLeft)
|
|
374
|
+
interval_halfopenright = RealInterval(a, b, RealInterval.Type.HalfOpenRight)
|
|
367
375
|
|
|
368
376
|
with pytest.raises(RuntimeError):
|
|
369
377
|
interval_undefined.to_string()
|
|
@@ -377,24 +385,24 @@ class TestInterval:
|
|
|
377
385
|
def test_get_intersection_with(self):
|
|
378
386
|
test_cases = [
|
|
379
387
|
(
|
|
380
|
-
RealInterval(0.0, 10.0, Type.HalfOpenLeft),
|
|
381
|
-
RealInterval(5.0, 7.0, Type.HalfOpenLeft),
|
|
382
|
-
RealInterval(5.0, 7.0, Type.HalfOpenLeft),
|
|
388
|
+
RealInterval(0.0, 10.0, RealInterval.Type.HalfOpenLeft),
|
|
389
|
+
RealInterval(5.0, 7.0, RealInterval.Type.HalfOpenLeft),
|
|
390
|
+
RealInterval(5.0, 7.0, RealInterval.Type.HalfOpenLeft),
|
|
383
391
|
),
|
|
384
392
|
(
|
|
385
|
-
RealInterval(0.0, 10.0, Type.HalfOpenRight),
|
|
386
|
-
RealInterval(-15.0, 25.0, Type.HalfOpenRight),
|
|
387
|
-
RealInterval(0.0, 10.0, Type.HalfOpenRight),
|
|
393
|
+
RealInterval(0.0, 10.0, RealInterval.Type.HalfOpenRight),
|
|
394
|
+
RealInterval(-15.0, 25.0, RealInterval.Type.HalfOpenRight),
|
|
395
|
+
RealInterval(0.0, 10.0, RealInterval.Type.HalfOpenRight),
|
|
388
396
|
),
|
|
389
397
|
(
|
|
390
|
-
RealInterval(0.0, 10.0, Type.Open),
|
|
391
|
-
RealInterval(-5.0, 7.0, Type.Open),
|
|
392
|
-
RealInterval(0.0, 7.0, Type.Open),
|
|
398
|
+
RealInterval(0.0, 10.0, RealInterval.Type.Open),
|
|
399
|
+
RealInterval(-5.0, 7.0, RealInterval.Type.Open),
|
|
400
|
+
RealInterval(0.0, 7.0, RealInterval.Type.Open),
|
|
393
401
|
),
|
|
394
402
|
(
|
|
395
|
-
RealInterval(0.0, 10.0, Type.Closed),
|
|
396
|
-
RealInterval(5.0, 15.0, Type.Closed),
|
|
397
|
-
RealInterval(5.0, 10.0, Type.Closed),
|
|
403
|
+
RealInterval(0.0, 10.0, RealInterval.Type.Closed),
|
|
404
|
+
RealInterval(5.0, 15.0, RealInterval.Type.Closed),
|
|
405
|
+
RealInterval(5.0, 10.0, RealInterval.Type.Closed),
|
|
398
406
|
),
|
|
399
407
|
]
|
|
400
408
|
|
|
@@ -410,24 +418,24 @@ class TestInterval:
|
|
|
410
418
|
def test_get_union_with(self):
|
|
411
419
|
test_cases = [
|
|
412
420
|
(
|
|
413
|
-
RealInterval(0.0, 10.0, Type.HalfOpenLeft),
|
|
414
|
-
RealInterval(5.0, 7.0, Type.HalfOpenLeft),
|
|
415
|
-
RealInterval(0.0, 10.0, Type.HalfOpenLeft),
|
|
421
|
+
RealInterval(0.0, 10.0, RealInterval.Type.HalfOpenLeft),
|
|
422
|
+
RealInterval(5.0, 7.0, RealInterval.Type.HalfOpenLeft),
|
|
423
|
+
RealInterval(0.0, 10.0, RealInterval.Type.HalfOpenLeft),
|
|
416
424
|
),
|
|
417
425
|
(
|
|
418
|
-
RealInterval(0.0, 10.0, Type.HalfOpenRight),
|
|
419
|
-
RealInterval(-15.0, 25.0, Type.HalfOpenRight),
|
|
420
|
-
RealInterval(-15.0, 25.0, Type.HalfOpenRight),
|
|
426
|
+
RealInterval(0.0, 10.0, RealInterval.Type.HalfOpenRight),
|
|
427
|
+
RealInterval(-15.0, 25.0, RealInterval.Type.HalfOpenRight),
|
|
428
|
+
RealInterval(-15.0, 25.0, RealInterval.Type.HalfOpenRight),
|
|
421
429
|
),
|
|
422
430
|
(
|
|
423
|
-
RealInterval(0.0, 10.0, Type.Open),
|
|
424
|
-
RealInterval(-5.0, 7.0, Type.Open),
|
|
425
|
-
RealInterval(-5.0, 10.0, Type.Open),
|
|
431
|
+
RealInterval(0.0, 10.0, RealInterval.Type.Open),
|
|
432
|
+
RealInterval(-5.0, 7.0, RealInterval.Type.Open),
|
|
433
|
+
RealInterval(-5.0, 10.0, RealInterval.Type.Open),
|
|
426
434
|
),
|
|
427
435
|
(
|
|
428
|
-
RealInterval(0.0, 10.0, Type.Closed),
|
|
429
|
-
RealInterval(5.0, 15.0, Type.Closed),
|
|
430
|
-
RealInterval(0.0, 15.0, Type.Closed),
|
|
436
|
+
RealInterval(0.0, 10.0, RealInterval.Type.Closed),
|
|
437
|
+
RealInterval(5.0, 15.0, RealInterval.Type.Closed),
|
|
438
|
+
RealInterval(0.0, 15.0, RealInterval.Type.Closed),
|
|
431
439
|
),
|
|
432
440
|
]
|
|
433
441
|
|
|
@@ -437,3 +445,71 @@ class TestInterval:
|
|
|
437
445
|
expected_interval = test_case[2]
|
|
438
446
|
|
|
439
447
|
assert first_interval.get_union_with(second_interval) == expected_interval
|
|
448
|
+
|
|
449
|
+
def test_clip(self):
|
|
450
|
+
intervals: list[RealInterval] = [
|
|
451
|
+
RealInterval(0.0, 10.0, RealInterval.Type.HalfOpenLeft),
|
|
452
|
+
RealInterval(6.5, 8.0, RealInterval.Type.HalfOpenLeft),
|
|
453
|
+
]
|
|
454
|
+
clipping_interval: RealInterval = RealInterval.closed(6.0, 7.0)
|
|
455
|
+
|
|
456
|
+
assert RealInterval.clip(intervals, clipping_interval) is not None
|
|
457
|
+
|
|
458
|
+
def test_sort(self):
|
|
459
|
+
intervals: list[RealInterval] = [
|
|
460
|
+
RealInterval(0.0, 10.0, RealInterval.Type.HalfOpenLeft),
|
|
461
|
+
RealInterval(10.0, 20.0, RealInterval.Type.HalfOpenLeft),
|
|
462
|
+
]
|
|
463
|
+
assert RealInterval.sort(intervals) is not None
|
|
464
|
+
assert RealInterval.sort(intervals, False) is not None
|
|
465
|
+
assert RealInterval.sort(intervals, False, False) is not None
|
|
466
|
+
|
|
467
|
+
def test_merge(self):
|
|
468
|
+
intervals: list[RealInterval] = [
|
|
469
|
+
RealInterval(0.0, 10.0, RealInterval.Type.HalfOpenLeft),
|
|
470
|
+
RealInterval(5.0, 7.0, RealInterval.Type.HalfOpenLeft),
|
|
471
|
+
RealInterval(0.0, 10.0, RealInterval.Type.HalfOpenLeft),
|
|
472
|
+
]
|
|
473
|
+
|
|
474
|
+
assert RealInterval.merge(intervals) is not None
|
|
475
|
+
|
|
476
|
+
def test_get_gaps(self):
|
|
477
|
+
intervals: list[RealInterval] = [
|
|
478
|
+
RealInterval(0.0, 10.0, RealInterval.Type.HalfOpenLeft),
|
|
479
|
+
RealInterval(5.0, 7.0, RealInterval.Type.HalfOpenLeft),
|
|
480
|
+
RealInterval(5.0, 15.0, RealInterval.Type.HalfOpenLeft),
|
|
481
|
+
]
|
|
482
|
+
|
|
483
|
+
assert RealInterval.get_gaps(intervals) is not None
|
|
484
|
+
|
|
485
|
+
assert (
|
|
486
|
+
RealInterval.get_gaps(intervals, RealInterval.closed(-5.0, 25.0)) is not None
|
|
487
|
+
)
|
|
488
|
+
|
|
489
|
+
def test_logical_or(self):
|
|
490
|
+
intervals_1: list[RealInterval] = [
|
|
491
|
+
RealInterval(8.0, 9.0, RealInterval.Type.Closed),
|
|
492
|
+
RealInterval(0.0, 1.0, RealInterval.Type.HalfOpenLeft),
|
|
493
|
+
RealInterval(2.0, 3.0, RealInterval.Type.Open),
|
|
494
|
+
]
|
|
495
|
+
|
|
496
|
+
intervals_2: list[RealInterval] = [
|
|
497
|
+
RealInterval(0.5, 3.5, RealInterval.Type.Open),
|
|
498
|
+
RealInterval(5.0, 7.0, RealInterval.Type.HalfOpenLeft),
|
|
499
|
+
]
|
|
500
|
+
|
|
501
|
+
assert RealInterval.logical_or(intervals_1, intervals_2) is not None
|
|
502
|
+
|
|
503
|
+
def test_logical_and(self):
|
|
504
|
+
intervals_1: list[RealInterval] = [
|
|
505
|
+
RealInterval(8.0, 9.0, RealInterval.Type.Closed),
|
|
506
|
+
RealInterval(0.0, 1.0, RealInterval.Type.HalfOpenLeft),
|
|
507
|
+
RealInterval(2.0, 3.0, RealInterval.Type.Open),
|
|
508
|
+
]
|
|
509
|
+
|
|
510
|
+
intervals_2: list[RealInterval] = [
|
|
511
|
+
RealInterval(0.5, 3.5, RealInterval.Type.Open),
|
|
512
|
+
RealInterval(5.0, 7.0, RealInterval.Type.HalfOpenLeft),
|
|
513
|
+
]
|
|
514
|
+
|
|
515
|
+
assert RealInterval.logical_and(intervals_1, intervals_2) is not None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|