open-space-toolkit-physics 11.3.0__py310-none-manylinux2014_aarch64.whl
Sign up to get free protection for your applications and to get access to all the features.
- open_space_toolkit_physics-11.3.0.dist-info/METADATA +29 -0
- open_space_toolkit_physics-11.3.0.dist-info/RECORD +104 -0
- open_space_toolkit_physics-11.3.0.dist-info/WHEEL +5 -0
- open_space_toolkit_physics-11.3.0.dist-info/top_level.txt +1 -0
- open_space_toolkit_physics-11.3.0.dist-info/zip-safe +1 -0
- ostk/__init__.py +1 -0
- ostk/physics/OpenSpaceToolkitPhysicsPy.cpython-310-aarch64-linux-gnu.so +0 -0
- ostk/physics/__init__.py +6 -0
- ostk/physics/__init__.pyi +488 -0
- ostk/physics/coordinate/__init__.pyi +1002 -0
- ostk/physics/coordinate/frame/__init__.pyi +30 -0
- ostk/physics/coordinate/frame/provider/__init__.pyi +77 -0
- ostk/physics/coordinate/frame/provider/iau.pyi +64 -0
- ostk/physics/coordinate/frame/provider/iers.pyi +584 -0
- ostk/physics/coordinate/spherical.pyi +421 -0
- ostk/physics/data/__init__.pyi +459 -0
- ostk/physics/data/provider.pyi +21 -0
- ostk/physics/environment/__init__.pyi +108 -0
- ostk/physics/environment/atmospheric/__init__.pyi +181 -0
- ostk/physics/environment/atmospheric/earth.pyi +552 -0
- ostk/physics/environment/gravitational/__init__.pyi +559 -0
- ostk/physics/environment/gravitational/earth.pyi +56 -0
- ostk/physics/environment/magnetic/__init__.pyi +171 -0
- ostk/physics/environment/magnetic/earth.pyi +56 -0
- ostk/physics/environment/object/__init__.pyi +430 -0
- ostk/physics/environment/object/celestial/__init__.pyi +248 -0
- ostk/physics/environment/object/celestial/moon.pyi +2 -0
- ostk/physics/environment/object/celestial/sun.pyi +2 -0
- ostk/physics/libopen-space-toolkit-physics.so.11 +0 -0
- ostk/physics/py.typed +0 -0
- ostk/physics/test/__init__.py +1 -0
- ostk/physics/test/coordinate/__init__.py +1 -0
- ostk/physics/test/coordinate/frame/__init__.py +1 -0
- ostk/physics/test/coordinate/frame/provider/__init__.py +1 -0
- ostk/physics/test/coordinate/frame/provider/iers/__init__.py +1 -0
- ostk/physics/test/coordinate/frame/provider/iers/conftest.py +38 -0
- ostk/physics/test/coordinate/frame/provider/iers/data/finals2000A.data +10953 -0
- ostk/physics/test/coordinate/frame/provider/iers/data/ser7.dat +524 -0
- ostk/physics/test/coordinate/frame/provider/iers/test_bulletin_a.py +108 -0
- ostk/physics/test/coordinate/frame/provider/iers/test_finals_2000a.py +93 -0
- ostk/physics/test/coordinate/frame/provider/iers/test_manager.py +205 -0
- ostk/physics/test/coordinate/spherical/__init__.py +1 -0
- ostk/physics/test/coordinate/spherical/test_aer.py +143 -0
- ostk/physics/test/coordinate/spherical/test_lla.py +514 -0
- ostk/physics/test/coordinate/test_axes.py +116 -0
- ostk/physics/test/coordinate/test_frame.py +107 -0
- ostk/physics/test/coordinate/test_position.py +201 -0
- ostk/physics/test/coordinate/test_transform.py +294 -0
- ostk/physics/test/coordinate/test_velocity.py +180 -0
- ostk/physics/test/data/conftest.py +34 -0
- ostk/physics/test/data/data/manifest.json +22 -0
- ostk/physics/test/data/provider/test_provider.py +34 -0
- ostk/physics/test/data/test_direction.py +40 -0
- ostk/physics/test/data/test_manifest.py +43 -0
- ostk/physics/test/data/test_manifest_manager.py +62 -0
- ostk/physics/test/data/test_scalar.py +54 -0
- ostk/physics/test/data/test_vector.py +70 -0
- ostk/physics/test/environment/__init__.py +1 -0
- ostk/physics/test/environment/atmospheric/__init__.py +1 -0
- ostk/physics/test/environment/atmospheric/earth/__init__.py +1 -0
- ostk/physics/test/environment/atmospheric/earth/conftest.py +67 -0
- ostk/physics/test/environment/atmospheric/earth/data/SW-Last5Years.test.csv +22 -0
- ostk/physics/test/environment/atmospheric/earth/data/SpaceWeather-All-v1.2.test.txt +811 -0
- ostk/physics/test/environment/atmospheric/earth/test_cssi_space_weather.py +126 -0
- ostk/physics/test/environment/atmospheric/earth/test_exponential.py +34 -0
- ostk/physics/test/environment/atmospheric/earth/test_manager.py +173 -0
- ostk/physics/test/environment/atmospheric/earth/test_nrlmsise00.py +34 -0
- ostk/physics/test/environment/atmospheric/test_earth.py +141 -0
- ostk/physics/test/environment/gravitational/__init__.py +1 -0
- ostk/physics/test/environment/gravitational/earth/__init__.py +1 -0
- ostk/physics/test/environment/gravitational/earth/test_manager.py +76 -0
- ostk/physics/test/environment/gravitational/test_earth.py +103 -0
- ostk/physics/test/environment/gravitational/test_moon.py +55 -0
- ostk/physics/test/environment/gravitational/test_spherical.py +36 -0
- ostk/physics/test/environment/gravitational/test_sun.py +53 -0
- ostk/physics/test/environment/magnetic/__init__.py +1 -0
- ostk/physics/test/environment/magnetic/earth/test_manager.py +64 -0
- ostk/physics/test/environment/magnetic/test_earth.py +38 -0
- ostk/physics/test/environment/object/__init__.py +1 -0
- ostk/physics/test/environment/object/celestial/__init__ .py +1 -0
- ostk/physics/test/environment/object/celestial/test_earth.py +174 -0
- ostk/physics/test/environment/object/celestial/test_moon.py +17 -0
- ostk/physics/test/environment/object/celestial/test_sun.py +17 -0
- ostk/physics/test/environment/object/test_celestial.py +12 -0
- ostk/physics/test/test_environment.py +97 -0
- ostk/physics/test/test_import.py +25 -0
- ostk/physics/test/time/__init__.py +1 -0
- ostk/physics/test/time/test_date.py +136 -0
- ostk/physics/test/time/test_date_time.py +230 -0
- ostk/physics/test/time/test_duration.py +215 -0
- ostk/physics/test/time/test_instant.py +103 -0
- ostk/physics/test/time/test_interval.py +432 -0
- ostk/physics/test/time/test_scale.py +11 -0
- ostk/physics/test/time/test_time.py +114 -0
- ostk/physics/test/unit/__init__.py +1 -0
- ostk/physics/test/unit/derived/__init__.py +1 -0
- ostk/physics/test/unit/derived/test_angle.py +368 -0
- ostk/physics/test/unit/test_derived.py +152 -0
- ostk/physics/test/unit/test_electric_current.py +5 -0
- ostk/physics/test/unit/test_length.py +297 -0
- ostk/physics/test/unit/test_mass.py +141 -0
- ostk/physics/test/unit/test_time.py +101 -0
- ostk/physics/time.pyi +1744 -0
- ostk/physics/unit.pyi +1590 -0
@@ -0,0 +1,432 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
from datetime import datetime
|
6
|
+
|
7
|
+
from ostk.core.type import String
|
8
|
+
|
9
|
+
from ostk.physics.time import Scale
|
10
|
+
from ostk.physics.time import Instant
|
11
|
+
from ostk.physics.time import Duration
|
12
|
+
from ostk.physics.time import Interval
|
13
|
+
|
14
|
+
|
15
|
+
@pytest.fixture
|
16
|
+
def closed_interval() -> Interval:
|
17
|
+
return Interval(
|
18
|
+
Instant.J2000(), Instant.J2000() + Duration.minutes(1.0), Interval.Type.Closed
|
19
|
+
)
|
20
|
+
|
21
|
+
|
22
|
+
@pytest.fixture
|
23
|
+
def open_interval() -> Interval:
|
24
|
+
return Interval(
|
25
|
+
Instant.J2000(), Instant.J2000() + Duration.minutes(1.0), Interval.Type.Open
|
26
|
+
)
|
27
|
+
|
28
|
+
|
29
|
+
@pytest.fixture
|
30
|
+
def half_open_right_interval() -> Interval:
|
31
|
+
return Interval(
|
32
|
+
Instant.J2000(),
|
33
|
+
Instant.J2000() + Duration.minutes(1.0),
|
34
|
+
Interval.Type.HalfOpenRight,
|
35
|
+
)
|
36
|
+
|
37
|
+
|
38
|
+
@pytest.fixture
|
39
|
+
def half_open_left_interval() -> Interval:
|
40
|
+
return Interval(
|
41
|
+
Instant.J2000(),
|
42
|
+
Instant.J2000() + Duration.minutes(1.0),
|
43
|
+
Interval.Type.HalfOpenLeft,
|
44
|
+
)
|
45
|
+
|
46
|
+
|
47
|
+
@pytest.fixture
|
48
|
+
def interval_1(closed_interval: Interval) -> Interval:
|
49
|
+
return closed_interval
|
50
|
+
|
51
|
+
|
52
|
+
@pytest.fixture
|
53
|
+
def interval_2() -> Interval:
|
54
|
+
return Interval(
|
55
|
+
Instant.J2000() - Duration.minutes(1.0), Instant.J2000(), Interval.Type.Closed
|
56
|
+
)
|
57
|
+
|
58
|
+
|
59
|
+
@pytest.fixture
|
60
|
+
def interval_3() -> Interval:
|
61
|
+
return Interval(
|
62
|
+
Instant.J2000() - Duration.minutes(2.0),
|
63
|
+
Instant.J2000() - Duration.minutes(1.0),
|
64
|
+
Interval.Type.Closed,
|
65
|
+
)
|
66
|
+
|
67
|
+
|
68
|
+
@pytest.fixture
|
69
|
+
def interval_4() -> Interval:
|
70
|
+
return Interval(
|
71
|
+
Instant.J2000(), Instant.J2000() + Duration.minutes(1.0), Interval.Type.Open
|
72
|
+
)
|
73
|
+
|
74
|
+
|
75
|
+
@pytest.fixture
|
76
|
+
def interval(interval_1: Interval) -> Interval:
|
77
|
+
return interval_1
|
78
|
+
|
79
|
+
|
80
|
+
@pytest.fixture
|
81
|
+
def instant_1() -> Interval:
|
82
|
+
return Instant.J2000()
|
83
|
+
|
84
|
+
|
85
|
+
@pytest.fixture
|
86
|
+
def instant_2() -> Interval:
|
87
|
+
return Instant.J2000() + Duration.seconds(30.0)
|
88
|
+
|
89
|
+
|
90
|
+
@pytest.fixture
|
91
|
+
def instant_3() -> Interval:
|
92
|
+
return Instant.J2000() + Duration.minutes(3.0)
|
93
|
+
|
94
|
+
|
95
|
+
def build_interval(
|
96
|
+
offset_1: float, offset_2: float, type: Interval.Type = Interval.Type.Closed
|
97
|
+
) -> Interval:
|
98
|
+
return Interval(
|
99
|
+
Instant.J2000() + Duration.seconds(offset_1),
|
100
|
+
Instant.J2000() + Duration.seconds(offset_2),
|
101
|
+
type,
|
102
|
+
)
|
103
|
+
|
104
|
+
|
105
|
+
class TestInterval:
|
106
|
+
def test_interval_constructor(self):
|
107
|
+
interval: Interval = Interval(
|
108
|
+
Instant.J2000(), Instant.J2000() + Duration.minutes(1.0), Interval.Type.Closed
|
109
|
+
)
|
110
|
+
|
111
|
+
assert interval is not None
|
112
|
+
assert isinstance(interval, Interval)
|
113
|
+
|
114
|
+
with pytest.raises(RuntimeError):
|
115
|
+
Interval(
|
116
|
+
Instant.J2000() + Duration.seconds(1.0),
|
117
|
+
Instant.J2000(),
|
118
|
+
Interval.Type.Closed,
|
119
|
+
)
|
120
|
+
|
121
|
+
def test_interval_undefined(self):
|
122
|
+
assert Interval.undefined() is not None
|
123
|
+
assert isinstance(Interval.undefined(), Interval)
|
124
|
+
|
125
|
+
def test_interval_constructor_closed(self):
|
126
|
+
assert (
|
127
|
+
Interval(
|
128
|
+
Instant.J2000(),
|
129
|
+
Instant.J2000() + Duration.minutes(1.0),
|
130
|
+
Interval.Type.Closed,
|
131
|
+
)
|
132
|
+
is not None
|
133
|
+
)
|
134
|
+
|
135
|
+
assert (
|
136
|
+
Interval.closed(Instant.J2000(), Instant.J2000() + Duration.minutes(1.0))
|
137
|
+
is not None
|
138
|
+
)
|
139
|
+
|
140
|
+
def test_interval_constructor_open(self):
|
141
|
+
assert (
|
142
|
+
Interval(
|
143
|
+
Instant.J2000(),
|
144
|
+
Instant.J2000() + Duration.minutes(1.0),
|
145
|
+
Interval.Type.Open,
|
146
|
+
)
|
147
|
+
is not None
|
148
|
+
)
|
149
|
+
|
150
|
+
assert (
|
151
|
+
Interval.open(Instant.J2000(), Instant.J2000() + Duration.minutes(1.0))
|
152
|
+
is not None
|
153
|
+
)
|
154
|
+
|
155
|
+
def test_interval_constructor_half_open_left(self):
|
156
|
+
assert (
|
157
|
+
Interval(
|
158
|
+
Instant.J2000(),
|
159
|
+
Instant.J2000() + Duration.minutes(1.0),
|
160
|
+
Interval.Type.HalfOpenLeft,
|
161
|
+
)
|
162
|
+
is not None
|
163
|
+
)
|
164
|
+
|
165
|
+
assert (
|
166
|
+
Interval.half_open_left(
|
167
|
+
Instant.J2000(), Instant.J2000() + Duration.minutes(1.0)
|
168
|
+
)
|
169
|
+
is not None
|
170
|
+
)
|
171
|
+
|
172
|
+
def test_interval_constructor_half_open_right(self):
|
173
|
+
assert (
|
174
|
+
Interval(
|
175
|
+
Instant.J2000(),
|
176
|
+
Instant.J2000() + Duration.minutes(1.0),
|
177
|
+
Interval.Type.HalfOpenRight,
|
178
|
+
)
|
179
|
+
is not None
|
180
|
+
)
|
181
|
+
|
182
|
+
assert (
|
183
|
+
Interval.half_open_right(
|
184
|
+
Instant.J2000(), Instant.J2000() + Duration.minutes(1.0)
|
185
|
+
)
|
186
|
+
is not None
|
187
|
+
)
|
188
|
+
|
189
|
+
def test_interval_constructor_centered(self):
|
190
|
+
assert (
|
191
|
+
Interval.centered(
|
192
|
+
Instant.J2000(), Duration.minutes(1.0), Interval.Type.Closed
|
193
|
+
)
|
194
|
+
is not None
|
195
|
+
)
|
196
|
+
assert (
|
197
|
+
Interval.centered(Instant.J2000(), Duration.minutes(1.0), Interval.Type.Open)
|
198
|
+
is not None
|
199
|
+
)
|
200
|
+
assert (
|
201
|
+
Interval.centered(
|
202
|
+
Instant.J2000(), Duration.minutes(1.0), Interval.Type.HalfOpenLeft
|
203
|
+
)
|
204
|
+
is not None
|
205
|
+
)
|
206
|
+
assert (
|
207
|
+
Interval.centered(
|
208
|
+
Instant.J2000(), Duration.minutes(1.0), Interval.Type.HalfOpenRight
|
209
|
+
)
|
210
|
+
is not None
|
211
|
+
)
|
212
|
+
|
213
|
+
def test_interval_operator_equality(self, interval_1: Interval, interval_4: Interval):
|
214
|
+
assert interval_1 == interval_1
|
215
|
+
assert (interval_1 != interval_1) is False
|
216
|
+
|
217
|
+
assert interval_1 != interval_4
|
218
|
+
|
219
|
+
def test_interval_is_defined(self, interval: Interval):
|
220
|
+
assert interval.is_defined()
|
221
|
+
assert Interval.undefined().is_defined() is False
|
222
|
+
|
223
|
+
def test_interval_is_degenerate(self, interval: Interval):
|
224
|
+
assert interval.is_degenerate() is False
|
225
|
+
assert Interval.closed(Instant.J2000(), Instant.J2000()).is_degenerate()
|
226
|
+
|
227
|
+
with pytest.raises(Exception):
|
228
|
+
Interval(Instant.J2000(), Instant.J2000(), Interval.Type.Open).is_degenerate()
|
229
|
+
Interval.centered(
|
230
|
+
Instant.J2000(), Duration.minutes(0.0), Interval.Type.Open
|
231
|
+
).is_degenerate()
|
232
|
+
|
233
|
+
def test_interval_intersects(
|
234
|
+
self,
|
235
|
+
interval_1: Interval,
|
236
|
+
interval_2: Interval,
|
237
|
+
interval_3: Interval,
|
238
|
+
interval_4: Interval,
|
239
|
+
):
|
240
|
+
assert interval_1.intersects(interval_1)
|
241
|
+
assert interval_1.intersects(interval_2)
|
242
|
+
assert interval_1.intersects(interval_3) is False
|
243
|
+
assert interval_1.intersects(interval_4)
|
244
|
+
assert interval_3.intersects(interval_4) is False
|
245
|
+
assert interval_3.intersects(interval_2)
|
246
|
+
|
247
|
+
def test_interval_contains_instant(
|
248
|
+
self,
|
249
|
+
interval_1: Interval,
|
250
|
+
interval_4: Interval,
|
251
|
+
instant_1: Instant,
|
252
|
+
instant_2: Instant,
|
253
|
+
instant_3: Instant,
|
254
|
+
):
|
255
|
+
assert interval_1.contains_instant(instant_1)
|
256
|
+
assert interval_1.contains_instant(instant_2)
|
257
|
+
assert interval_1.contains_instant(instant_3) is False
|
258
|
+
|
259
|
+
assert interval_4.contains_instant(instant_1) is False
|
260
|
+
assert interval_4.contains_instant(instant_2)
|
261
|
+
assert interval_4.contains_instant(instant_3) is False
|
262
|
+
|
263
|
+
def test_interval_contains_interval(
|
264
|
+
self,
|
265
|
+
interval_1: Interval,
|
266
|
+
interval_2: Interval,
|
267
|
+
interval_3: Interval,
|
268
|
+
interval_4: Interval,
|
269
|
+
):
|
270
|
+
assert interval_1.contains_interval(interval_1)
|
271
|
+
assert interval_1.contains_interval(interval_2) is False
|
272
|
+
assert interval_1.contains_interval(interval_3) is False
|
273
|
+
assert interval_1.contains_interval(interval_4)
|
274
|
+
assert interval_1.contains_interval(
|
275
|
+
Interval.closed(
|
276
|
+
Instant.J2000() + Duration.seconds(1.0),
|
277
|
+
Instant.J2000() + Duration.seconds(2.0),
|
278
|
+
)
|
279
|
+
)
|
280
|
+
|
281
|
+
def test_interval_get_properties(self, interval: Interval):
|
282
|
+
assert interval.get_start() == Instant.J2000()
|
283
|
+
assert interval.get_end() == Instant.J2000() + Duration.minutes(1.0)
|
284
|
+
assert interval.get_duration() == Duration.minutes(1.0)
|
285
|
+
assert interval.get_lower_bound() == interval.get_start()
|
286
|
+
assert interval.get_upper_bound() == interval.get_end()
|
287
|
+
assert interval.get_center() == Instant.J2000() + Duration.minutes(0.5)
|
288
|
+
|
289
|
+
def test_interval_to_string(self, interval: Interval):
|
290
|
+
assert interval.to_string() is not None
|
291
|
+
assert isinstance(interval.to_string(), String)
|
292
|
+
assert interval.to_string(Scale.UTC) is not None
|
293
|
+
assert isinstance(interval.to_string(Scale.UTC), String)
|
294
|
+
|
295
|
+
def test_interval_generate_grid(self, interval: Interval):
|
296
|
+
grid: list = interval.generate_grid(Duration.seconds(1.0))
|
297
|
+
|
298
|
+
assert grid is not None
|
299
|
+
assert isinstance(grid, list)
|
300
|
+
assert isinstance(grid[0], Instant)
|
301
|
+
assert len(grid) == 61
|
302
|
+
|
303
|
+
def test_to_datetime_span(self, interval: Interval):
|
304
|
+
assert interval.to_datetime_span() is not None
|
305
|
+
assert isinstance(interval.to_datetime_span(), tuple)
|
306
|
+
assert isinstance(interval.to_datetime_span()[0], datetime)
|
307
|
+
assert isinstance(interval.to_datetime_span()[1], datetime)
|
308
|
+
|
309
|
+
def test_get_intersection_with(self):
|
310
|
+
intersection: Interval = build_interval(0.0, 10.0).get_intersection_with(
|
311
|
+
build_interval(5.0, 15.0)
|
312
|
+
)
|
313
|
+
assert isinstance(intersection, Interval)
|
314
|
+
assert intersection.is_defined()
|
315
|
+
|
316
|
+
intersection: Interval = build_interval(0.0, 10.0).get_intersection_with(
|
317
|
+
build_interval(20.0, 30.0)
|
318
|
+
)
|
319
|
+
assert isinstance(intersection, Interval)
|
320
|
+
assert not intersection.is_defined()
|
321
|
+
|
322
|
+
def test_get_union_with(self):
|
323
|
+
union: Interval = build_interval(0.0, 10.0).get_union_with(
|
324
|
+
build_interval(5.0, 15.0)
|
325
|
+
)
|
326
|
+
assert isinstance(union, Interval)
|
327
|
+
assert union.is_defined()
|
328
|
+
|
329
|
+
union: Interval = build_interval(0.0, 10.0).get_union_with(
|
330
|
+
build_interval(20.0, 30.0)
|
331
|
+
)
|
332
|
+
assert isinstance(union, Interval)
|
333
|
+
assert not union.is_defined()
|
334
|
+
|
335
|
+
def test_clip(self):
|
336
|
+
intervals: list[Interval] = [
|
337
|
+
build_interval(0.0, 10.0),
|
338
|
+
build_interval(20.0, 30.0),
|
339
|
+
]
|
340
|
+
|
341
|
+
expected: list[Interval] = [
|
342
|
+
build_interval(5.0, 10.0),
|
343
|
+
build_interval(20.0, 25.0),
|
344
|
+
]
|
345
|
+
|
346
|
+
assert Interval.clip(intervals, build_interval(5.0, 25.0)) == expected
|
347
|
+
|
348
|
+
def test_sort(self):
|
349
|
+
intervals: list[Interval] = [
|
350
|
+
build_interval(20.0, 30.0),
|
351
|
+
build_interval(0.0, 10.0),
|
352
|
+
]
|
353
|
+
|
354
|
+
expected: list[Interval] = [
|
355
|
+
build_interval(0.0, 10.0),
|
356
|
+
build_interval(20.0, 30.0),
|
357
|
+
]
|
358
|
+
|
359
|
+
assert Interval.sort(intervals) == expected
|
360
|
+
|
361
|
+
def test_merge(self):
|
362
|
+
intervals: list[Interval] = [
|
363
|
+
build_interval(20.0, 30.0),
|
364
|
+
build_interval(5.0, 15.0),
|
365
|
+
build_interval(0.0, 10.0),
|
366
|
+
]
|
367
|
+
|
368
|
+
expected: list[Interval] = [
|
369
|
+
build_interval(0.0, 15.0),
|
370
|
+
build_interval(20.0, 30.0),
|
371
|
+
]
|
372
|
+
|
373
|
+
assert Interval.merge(intervals) == expected
|
374
|
+
|
375
|
+
def test_get_gaps(self):
|
376
|
+
intervals: list[Interval] = [
|
377
|
+
build_interval(5.0, 10.0),
|
378
|
+
build_interval(20.0, 30.0),
|
379
|
+
]
|
380
|
+
|
381
|
+
expected: list[Interval] = [
|
382
|
+
build_interval(10.0, 20.0, Interval.Type.Open),
|
383
|
+
]
|
384
|
+
|
385
|
+
assert Interval.get_gaps(intervals) == expected
|
386
|
+
|
387
|
+
expected = [
|
388
|
+
build_interval(0.0, 5.0, Interval.Type.Open),
|
389
|
+
build_interval(10.0, 20.0, Interval.Type.Open),
|
390
|
+
build_interval(30.0, 35.0, Interval.Type.Open),
|
391
|
+
]
|
392
|
+
|
393
|
+
assert (
|
394
|
+
Interval.get_gaps(intervals, build_interval(0.0, 35.0, Interval.Type.Open))
|
395
|
+
== expected
|
396
|
+
)
|
397
|
+
|
398
|
+
def test_logical_or(self):
|
399
|
+
intervals_1: list[Interval] = [
|
400
|
+
build_interval(0.0, 10.0),
|
401
|
+
build_interval(20.0, 30.0),
|
402
|
+
]
|
403
|
+
|
404
|
+
intervals_2: list[Interval] = [
|
405
|
+
build_interval(5.0, 25.0),
|
406
|
+
build_interval(40.0, 50.0),
|
407
|
+
]
|
408
|
+
|
409
|
+
expected: list[Interval] = [
|
410
|
+
build_interval(0.0, 30.0),
|
411
|
+
build_interval(40.0, 50.0),
|
412
|
+
]
|
413
|
+
|
414
|
+
assert Interval.logical_or(intervals_1, intervals_2) == expected
|
415
|
+
|
416
|
+
def test_logical_and(self):
|
417
|
+
intervals_1: list[Interval] = [
|
418
|
+
build_interval(0.0, 10.0),
|
419
|
+
build_interval(20.0, 30.0),
|
420
|
+
]
|
421
|
+
|
422
|
+
intervals_2: list[Interval] = [
|
423
|
+
build_interval(5.0, 25.0),
|
424
|
+
build_interval(40.0, 50.0),
|
425
|
+
]
|
426
|
+
|
427
|
+
expected: list[Interval] = [
|
428
|
+
build_interval(5.0, 10.0),
|
429
|
+
build_interval(20.0, 25.0),
|
430
|
+
]
|
431
|
+
|
432
|
+
assert Interval.logical_and(intervals_1, intervals_2) == expected
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
from ostk.core.type import String
|
5
|
+
from ostk.physics.time import Time
|
6
|
+
|
7
|
+
|
8
|
+
@pytest.fixture
|
9
|
+
def time() -> Time:
|
10
|
+
return Time(0, 0, 0)
|
11
|
+
|
12
|
+
|
13
|
+
class TestTime:
|
14
|
+
def test_constructors(self, time: Time) -> None:
|
15
|
+
assert time is not None
|
16
|
+
|
17
|
+
@pytest.mark.parametrize(
|
18
|
+
"time_string, format",
|
19
|
+
[
|
20
|
+
("00:00:00", None),
|
21
|
+
("00:00:00", Time.Format.Standard),
|
22
|
+
("00:00:00", Time.Format.ISO8601),
|
23
|
+
(String("00:00:00"), None),
|
24
|
+
(String("00:00:00"), Time.Format.Standard),
|
25
|
+
(String("00:00:00"), Time.Format.ISO8601),
|
26
|
+
],
|
27
|
+
)
|
28
|
+
def test_parse(self, time_string, format) -> None:
|
29
|
+
if format is None:
|
30
|
+
time = Time.parse(time_string)
|
31
|
+
else:
|
32
|
+
time = Time.parse(time_string, format)
|
33
|
+
|
34
|
+
assert time is not None
|
35
|
+
assert isinstance(time, Time)
|
36
|
+
assert time.is_defined()
|
37
|
+
|
38
|
+
def test_operators(self, time: Time) -> None:
|
39
|
+
assert (time == time) is not None
|
40
|
+
assert (time != time) is not None
|
41
|
+
|
42
|
+
def test_is_defined(self, time: Time) -> None:
|
43
|
+
assert time.is_defined() is not None
|
44
|
+
|
45
|
+
def test_get_hour(self, time: Time) -> None:
|
46
|
+
assert time.get_hour() is not None
|
47
|
+
|
48
|
+
def test_get_minute(self, time: Time) -> None:
|
49
|
+
assert time.get_minute() is not None
|
50
|
+
|
51
|
+
def test_get_second(self, time: Time) -> None:
|
52
|
+
assert time.get_second() is not None
|
53
|
+
|
54
|
+
def test_get_millisecond(self, time: Time) -> None:
|
55
|
+
assert time.get_millisecond() is not None
|
56
|
+
|
57
|
+
def test_get_microsecond(self, time: Time) -> None:
|
58
|
+
assert time.get_microsecond() is not None
|
59
|
+
|
60
|
+
def test_get_nanosecond(self, time: Time) -> None:
|
61
|
+
assert time.get_nanosecond() is not None
|
62
|
+
|
63
|
+
def test_get_floating_seconds(self, time: Time) -> None:
|
64
|
+
assert time.get_floating_seconds() is not None
|
65
|
+
|
66
|
+
def test_get_total_floating_seconds(self, time: Time) -> None:
|
67
|
+
assert time.get_total_floating_seconds() is not None
|
68
|
+
|
69
|
+
def test_get_total_floating_hours(self, time: Time) -> None:
|
70
|
+
assert time.get_total_floating_hours() is not None
|
71
|
+
|
72
|
+
def test_to_string(self, time: Time) -> None:
|
73
|
+
assert time.to_string() is not None
|
74
|
+
assert time.to_string(Time.Format.Standard) is not None
|
75
|
+
assert time.to_string(Time.Format.ISO8601) is not None
|
76
|
+
|
77
|
+
def test_set_hour(self, time: Time) -> None:
|
78
|
+
time.set_hour(1)
|
79
|
+
assert time.get_hour() == 1
|
80
|
+
|
81
|
+
def test_set_minute(self, time: Time) -> None:
|
82
|
+
time.set_minute(1)
|
83
|
+
assert time.get_minute() == 1
|
84
|
+
|
85
|
+
def test_set_second(self, time: Time) -> None:
|
86
|
+
time.set_second(1)
|
87
|
+
assert time.get_second() == 1
|
88
|
+
|
89
|
+
def test_set_millisecond(self, time: Time) -> None:
|
90
|
+
time.set_millisecond(1)
|
91
|
+
assert time.get_millisecond() == 1
|
92
|
+
|
93
|
+
def test_set_microsecond(self, time: Time) -> None:
|
94
|
+
time.set_microsecond(1)
|
95
|
+
assert time.get_microsecond() == 1
|
96
|
+
|
97
|
+
def test_set_nanosecond(self, time: Time) -> None:
|
98
|
+
time.set_nanosecond(1)
|
99
|
+
assert time.get_nanosecond() == 1
|
100
|
+
|
101
|
+
def test_undefined(self) -> None:
|
102
|
+
assert Time.undefined() is not None
|
103
|
+
|
104
|
+
def test_midnight(self) -> None:
|
105
|
+
assert Time.midnight() is not None
|
106
|
+
|
107
|
+
def test_noon(self) -> None:
|
108
|
+
assert Time.noon() is not None
|
109
|
+
|
110
|
+
def test_hours(self) -> None:
|
111
|
+
assert Time.hours(12.0345) is not None
|
112
|
+
|
113
|
+
def test_seconds(self) -> None:
|
114
|
+
assert Time.seconds(1238.0345) is not None
|
@@ -0,0 +1 @@
|
|
1
|
+
# Apache License 2.0
|
@@ -0,0 +1 @@
|
|
1
|
+
# Apache License 2.0
|