open-space-toolkit-physics 11.3.0__py39-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-39-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,136 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
from ostk.core.type import String
|
6
|
+
|
7
|
+
from ostk.physics.time import Date
|
8
|
+
|
9
|
+
|
10
|
+
def test_date_constructors():
|
11
|
+
assert Date(2018, 1, 1) is not None
|
12
|
+
|
13
|
+
|
14
|
+
def test_date_undefined():
|
15
|
+
assert Date.undefined() is not None
|
16
|
+
|
17
|
+
|
18
|
+
def test_date_J2000():
|
19
|
+
assert Date.J2000() is not None
|
20
|
+
|
21
|
+
|
22
|
+
def test_date_GPS_epoch():
|
23
|
+
assert Date.GPS_epoch() is not None
|
24
|
+
|
25
|
+
|
26
|
+
def test_date_unix_epoch():
|
27
|
+
assert Date.unix_epoch() is not None
|
28
|
+
|
29
|
+
|
30
|
+
def test_date_modified_julian_date_epoch():
|
31
|
+
assert Date.modified_julian_date_epoch() is not None
|
32
|
+
|
33
|
+
|
34
|
+
def test_date_parse():
|
35
|
+
## Using python strings
|
36
|
+
|
37
|
+
# Testing with default format argument (Date::Format::Undefined)
|
38
|
+
date: Date = Date.parse("2018-01-01")
|
39
|
+
|
40
|
+
assert date is not None
|
41
|
+
assert isinstance(date, Date)
|
42
|
+
assert date.is_defined()
|
43
|
+
|
44
|
+
# Testing with Date.Format.Standard
|
45
|
+
date: Date = Date.parse("2018-01-01", Date.Format.Standard)
|
46
|
+
|
47
|
+
assert date is not None
|
48
|
+
assert isinstance(date, Date)
|
49
|
+
assert date.is_defined()
|
50
|
+
|
51
|
+
# Testing with Date.Format.STK
|
52
|
+
date: Date = Date.parse("2 Jan 2019", Date.Format.STK)
|
53
|
+
|
54
|
+
assert date is not None
|
55
|
+
assert isinstance(date, Date)
|
56
|
+
assert date.is_defined()
|
57
|
+
|
58
|
+
## Using String class
|
59
|
+
|
60
|
+
# Testing with default format argument (Date::Format::Undefined)
|
61
|
+
date: Date = Date.parse(String("2018-01-01"))
|
62
|
+
|
63
|
+
assert date is not None
|
64
|
+
assert isinstance(date, Date)
|
65
|
+
assert date.is_defined()
|
66
|
+
|
67
|
+
# Testing with Date.Format.Standard
|
68
|
+
date: Date = Date.parse(String("2018-01-01"), Date.Format.Standard)
|
69
|
+
|
70
|
+
assert date is not None
|
71
|
+
assert isinstance(date, Date)
|
72
|
+
assert date.is_defined()
|
73
|
+
|
74
|
+
# Testing with Date.Format.STK
|
75
|
+
date: Date = Date.parse(String("2 Jan 2019"), Date.Format.STK)
|
76
|
+
|
77
|
+
assert date is not None
|
78
|
+
assert isinstance(date, Date)
|
79
|
+
assert date.is_defined()
|
80
|
+
|
81
|
+
|
82
|
+
def test_date_operators():
|
83
|
+
date = Date(2018, 1, 1)
|
84
|
+
|
85
|
+
assert (date == date) is not None
|
86
|
+
assert (date != date) is not None
|
87
|
+
|
88
|
+
|
89
|
+
def test_date_is_defined():
|
90
|
+
date = Date(2018, 1, 1)
|
91
|
+
|
92
|
+
assert date.is_defined() is not None
|
93
|
+
|
94
|
+
|
95
|
+
def test_date_get_year():
|
96
|
+
date = Date(2018, 1, 1)
|
97
|
+
|
98
|
+
assert date.get_year() is not None
|
99
|
+
|
100
|
+
|
101
|
+
def test_date_get_day():
|
102
|
+
date = Date(2018, 1, 1)
|
103
|
+
|
104
|
+
assert date.get_day() is not None
|
105
|
+
|
106
|
+
|
107
|
+
def test_date_get_month():
|
108
|
+
date = Date(2018, 1, 1)
|
109
|
+
|
110
|
+
assert date.get_month() is not None
|
111
|
+
|
112
|
+
|
113
|
+
def test_date_to_string():
|
114
|
+
date = Date(2018, 1, 1)
|
115
|
+
|
116
|
+
date.to_string()
|
117
|
+
date.to_string(Date.Format.Standard)
|
118
|
+
date.to_string(Date.Format.STK)
|
119
|
+
|
120
|
+
|
121
|
+
def test_date_set_year():
|
122
|
+
date = Date(2018, 1, 1)
|
123
|
+
|
124
|
+
date.set_year(2019)
|
125
|
+
|
126
|
+
|
127
|
+
def test_date_set_month():
|
128
|
+
date = Date(2018, 1, 1)
|
129
|
+
|
130
|
+
date.set_month(2)
|
131
|
+
|
132
|
+
|
133
|
+
def test_date_set_day():
|
134
|
+
date = Date(2018, 1, 1)
|
135
|
+
|
136
|
+
date.set_day(2)
|
@@ -0,0 +1,230 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import datetime
|
4
|
+
|
5
|
+
from ostk.core.type import String
|
6
|
+
|
7
|
+
from ostk.physics.time import Date
|
8
|
+
from ostk.physics.time import Time
|
9
|
+
from ostk.physics.time import DateTime
|
10
|
+
|
11
|
+
|
12
|
+
class TestDateTime:
|
13
|
+
def test_constructor_success_full(self):
|
14
|
+
date_time = DateTime(
|
15
|
+
year=2020,
|
16
|
+
month=1,
|
17
|
+
day=1,
|
18
|
+
hour=0,
|
19
|
+
minute=0,
|
20
|
+
second=0,
|
21
|
+
millisecond=0,
|
22
|
+
microsecond=0,
|
23
|
+
nanosecond=0,
|
24
|
+
)
|
25
|
+
|
26
|
+
assert date_time is not None
|
27
|
+
assert isinstance(date_time, DateTime)
|
28
|
+
assert date_time.is_defined()
|
29
|
+
|
30
|
+
def test_constructor_success_partial(self):
|
31
|
+
date_time = DateTime(
|
32
|
+
year=2020,
|
33
|
+
month=1,
|
34
|
+
day=1,
|
35
|
+
hour=0,
|
36
|
+
minute=0,
|
37
|
+
second=0,
|
38
|
+
)
|
39
|
+
|
40
|
+
assert date_time is not None
|
41
|
+
assert isinstance(date_time, DateTime)
|
42
|
+
assert date_time.is_defined()
|
43
|
+
|
44
|
+
def test_constructor_success_date_time(self):
|
45
|
+
date_time = DateTime(
|
46
|
+
date=Date(2020, 1, 1),
|
47
|
+
time=Time(0, 0, 0),
|
48
|
+
)
|
49
|
+
|
50
|
+
assert date_time is not None
|
51
|
+
assert isinstance(date_time, DateTime)
|
52
|
+
assert date_time.is_defined()
|
53
|
+
|
54
|
+
# def test_constructor_success_python_datetime (self):
|
55
|
+
|
56
|
+
# # date_time = DateTime(
|
57
|
+
# # datetime.datetime(2020, 1, 2, 3, 4, 5),
|
58
|
+
# # )
|
59
|
+
|
60
|
+
# # assert date_time is not None
|
61
|
+
# # assert isinstance(date_time, DateTime)
|
62
|
+
# # assert date_time.is_defined()
|
63
|
+
|
64
|
+
# print(type(DateTime(2020, 1, 1)))
|
65
|
+
# print(type(DateTime.J2000()))
|
66
|
+
# print(type(DateTime(datetime.datetime.now())))
|
67
|
+
|
68
|
+
# datetime.datetime(date_time)
|
69
|
+
|
70
|
+
def test_comparators_success(self):
|
71
|
+
date_time_1 = DateTime(2020, 1, 1, 0, 0, 0, 0, 0, 0)
|
72
|
+
date_time_2 = DateTime(2020, 1, 1, 0, 0, 0, 0, 0, 1)
|
73
|
+
date_time_3 = DateTime(2020, 1, 1, 0, 0, 1, 0, 0, 0)
|
74
|
+
|
75
|
+
assert date_time_1 == date_time_1
|
76
|
+
assert date_time_2 == date_time_2
|
77
|
+
assert date_time_3 == date_time_3
|
78
|
+
assert date_time_1 != date_time_2
|
79
|
+
assert date_time_1 != date_time_3
|
80
|
+
|
81
|
+
date_time_1 = DateTime(2020, 1, 2, 3, 4, 5)
|
82
|
+
date_time_2 = datetime.datetime(2020, 1, 2, 3, 4, 5)
|
83
|
+
|
84
|
+
assert date_time_1 == date_time_1
|
85
|
+
assert date_time_1 == date_time_2
|
86
|
+
assert date_time_2 == date_time_2
|
87
|
+
assert (date_time_1 != date_time_1) is False
|
88
|
+
|
89
|
+
def test_is_defined_success(self):
|
90
|
+
date_time = DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0)
|
91
|
+
|
92
|
+
assert date_time is not None
|
93
|
+
assert date_time.is_defined()
|
94
|
+
|
95
|
+
def test_get_date_success(self):
|
96
|
+
date_time = DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0)
|
97
|
+
|
98
|
+
assert date_time.get_date() is not None
|
99
|
+
assert date_time.get_date() == Date(2018, 1, 1)
|
100
|
+
|
101
|
+
def test_get_time_success(self):
|
102
|
+
date_time = DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0)
|
103
|
+
|
104
|
+
assert date_time.get_time() is not None
|
105
|
+
assert date_time.get_time() == Time(0, 0, 0, 0, 0, 0)
|
106
|
+
|
107
|
+
def test_get_julian_date_success(self):
|
108
|
+
date_time = DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0)
|
109
|
+
|
110
|
+
assert date_time.get_julian_date()
|
111
|
+
|
112
|
+
def test_get_modified_julian_date_success(self):
|
113
|
+
date_time = DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0)
|
114
|
+
|
115
|
+
assert date_time.get_modified_julian_date()
|
116
|
+
|
117
|
+
def test_to_string_success(self):
|
118
|
+
date_time = DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0)
|
119
|
+
|
120
|
+
assert date_time.to_string()
|
121
|
+
assert date_time.to_string(DateTime.Format.Standard)
|
122
|
+
assert date_time.to_string(DateTime.Format.ISO8601)
|
123
|
+
assert date_time.to_string(DateTime.Format.STK)
|
124
|
+
|
125
|
+
def test_undefined_success(self):
|
126
|
+
assert DateTime.undefined() is None
|
127
|
+
|
128
|
+
def test_J2000_success(self):
|
129
|
+
date_time = DateTime.J2000()
|
130
|
+
|
131
|
+
assert date_time is not None
|
132
|
+
assert isinstance(date_time, datetime.datetime)
|
133
|
+
|
134
|
+
def test_GPS_epoch_success(self):
|
135
|
+
date_time = DateTime.GPS_epoch()
|
136
|
+
|
137
|
+
assert date_time is not None
|
138
|
+
assert isinstance(date_time, datetime.datetime)
|
139
|
+
|
140
|
+
def test_unix_epoch_success(self):
|
141
|
+
date_time = DateTime.unix_epoch()
|
142
|
+
|
143
|
+
assert date_time is not None
|
144
|
+
assert isinstance(date_time, datetime.datetime)
|
145
|
+
|
146
|
+
def test_modified_julian_date_epoch_success(self):
|
147
|
+
date_time = DateTime.modified_julian_date_epoch()
|
148
|
+
|
149
|
+
assert date_time is not None
|
150
|
+
assert isinstance(date_time, datetime.datetime)
|
151
|
+
|
152
|
+
def test_julian_date_success(self):
|
153
|
+
date_time = DateTime.julian_date(2458119.5)
|
154
|
+
|
155
|
+
assert date_time is not None
|
156
|
+
assert isinstance(date_time, datetime.datetime)
|
157
|
+
|
158
|
+
def test_modified_julian_date_success(self):
|
159
|
+
date_time = DateTime.modified_julian_date(58119.0)
|
160
|
+
|
161
|
+
assert date_time is not None
|
162
|
+
assert isinstance(date_time, datetime.datetime)
|
163
|
+
|
164
|
+
def test_parse_success_str_format_undefined(self):
|
165
|
+
date_time = DateTime.parse("2018-01-01 00:00:00")
|
166
|
+
|
167
|
+
assert date_time is not None
|
168
|
+
assert isinstance(date_time, datetime.datetime)
|
169
|
+
assert date_time == datetime.datetime(2018, 1, 1, 0, 0)
|
170
|
+
assert date_time == DateTime(2018, 1, 1, 0, 0, 0)
|
171
|
+
|
172
|
+
def test_parse_success_str_format_standard(self):
|
173
|
+
date_time = DateTime.parse("2018-01-01 00:00:00", DateTime.Format.Standard)
|
174
|
+
|
175
|
+
assert date_time is not None
|
176
|
+
assert isinstance(date_time, datetime.datetime)
|
177
|
+
assert date_time == datetime.datetime(2018, 1, 1, 0, 0)
|
178
|
+
assert date_time == DateTime(2018, 1, 1, 0, 0, 0)
|
179
|
+
|
180
|
+
def test_parse_success_str_format_iso8601(self):
|
181
|
+
date_time = DateTime.parse("2018-01-01T00:00:00", DateTime.Format.ISO8601)
|
182
|
+
|
183
|
+
assert date_time is not None
|
184
|
+
assert isinstance(date_time, datetime.datetime)
|
185
|
+
assert date_time == datetime.datetime(2018, 1, 1, 0, 0)
|
186
|
+
assert date_time == DateTime(2018, 1, 1, 0, 0, 0)
|
187
|
+
|
188
|
+
def test_parse_success_str_format_stk(self):
|
189
|
+
date_time = DateTime.parse("1 Jan 2018 00:00:00", DateTime.Format.STK)
|
190
|
+
|
191
|
+
assert date_time is not None
|
192
|
+
assert isinstance(date_time, datetime.datetime)
|
193
|
+
assert date_time == datetime.datetime(2018, 1, 1, 0, 0)
|
194
|
+
assert date_time == DateTime(2018, 1, 1, 0, 0, 0)
|
195
|
+
|
196
|
+
def test_parse_success_string_format_undefined(self):
|
197
|
+
date_time = DateTime.parse(String("2018-01-01 00:00:00"))
|
198
|
+
|
199
|
+
assert date_time is not None
|
200
|
+
assert isinstance(date_time, datetime.datetime)
|
201
|
+
assert date_time == datetime.datetime(2018, 1, 1, 0, 0)
|
202
|
+
assert date_time == DateTime(2018, 1, 1, 0, 0, 0)
|
203
|
+
|
204
|
+
def test_parse_success_string_format_standard(self):
|
205
|
+
date_time = DateTime.parse(
|
206
|
+
String("2018-01-01 00:00:00"), DateTime.Format.Standard
|
207
|
+
)
|
208
|
+
|
209
|
+
assert date_time is not None
|
210
|
+
assert isinstance(date_time, datetime.datetime)
|
211
|
+
assert date_time == datetime.datetime(2018, 1, 1, 0, 0)
|
212
|
+
assert date_time == DateTime(2018, 1, 1, 0, 0, 0)
|
213
|
+
|
214
|
+
def test_parse_success_string_format_iso8601(self):
|
215
|
+
date_time = DateTime.parse(String("2018-01-01T00:00:00"), DateTime.Format.ISO8601)
|
216
|
+
|
217
|
+
assert date_time is not None
|
218
|
+
assert isinstance(date_time, datetime.datetime)
|
219
|
+
assert date_time == datetime.datetime(2018, 1, 1, 0, 0)
|
220
|
+
assert date_time == DateTime(2018, 1, 1, 0, 0, 0)
|
221
|
+
|
222
|
+
def test_parse_success_string_format_stk(self):
|
223
|
+
date_time = DateTime.parse(String("1 Jan 2018 00:00:00"), DateTime.Format.STK)
|
224
|
+
|
225
|
+
assert date_time is not None
|
226
|
+
assert isinstance(date_time, datetime.datetime)
|
227
|
+
assert date_time == datetime.datetime(2018, 1, 1, 0, 0)
|
228
|
+
assert date_time == DateTime(2018, 1, 1, 0, 0, 0)
|
229
|
+
|
230
|
+
assert (datetime.datetime.now() + datetime.timedelta(days=1)) is not None
|
@@ -0,0 +1,215 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
from datetime import timedelta
|
4
|
+
|
5
|
+
from ostk.core.type import String
|
6
|
+
|
7
|
+
from ostk.physics.unit import Time
|
8
|
+
from ostk.physics.time import Instant
|
9
|
+
from ostk.physics.time import Duration
|
10
|
+
|
11
|
+
|
12
|
+
class TestDuration:
|
13
|
+
def test_constructor_success_timedelta(self):
|
14
|
+
assert Duration(timedelta(days=123)).in_days() == 123.0
|
15
|
+
assert Duration(timedelta(hours=123)).in_hours() == 123.0
|
16
|
+
assert Duration(timedelta(minutes=123)).in_minutes() == 123.0
|
17
|
+
assert Duration(timedelta(seconds=123)).in_seconds() == 123.0
|
18
|
+
assert (
|
19
|
+
Duration(timedelta(seconds=123, microseconds=456000)).in_seconds() == 123.456
|
20
|
+
)
|
21
|
+
assert (
|
22
|
+
Duration(timedelta(seconds=123, microseconds=456)).in_seconds() == 123.000456
|
23
|
+
)
|
24
|
+
assert Duration(timedelta(microseconds=456000)).in_seconds() == 0.456
|
25
|
+
assert Duration(timedelta(microseconds=456)).in_seconds() == 0.000456
|
26
|
+
|
27
|
+
def test_operators_success(self):
|
28
|
+
duration_A = Duration.seconds(123.0)
|
29
|
+
duration_B = Duration.seconds(456.0)
|
30
|
+
|
31
|
+
assert (duration_A == duration_B) is not None
|
32
|
+
assert (duration_A != duration_B) is not None
|
33
|
+
|
34
|
+
assert (duration_A < duration_B) is not None
|
35
|
+
assert (duration_A <= duration_B) is not None
|
36
|
+
assert (duration_A > duration_B) is not None
|
37
|
+
assert (duration_A >= duration_B) is not None
|
38
|
+
|
39
|
+
assert (duration_A + duration_B) is not None
|
40
|
+
assert (duration_A - duration_B) is not None
|
41
|
+
|
42
|
+
assert (duration_A * 2.0) is not None
|
43
|
+
assert (duration_A / 2.0) is not None
|
44
|
+
|
45
|
+
duration_A += duration_B
|
46
|
+
duration_A -= duration_B
|
47
|
+
|
48
|
+
duration_A *= 2.0
|
49
|
+
duration_A /= 2.0
|
50
|
+
|
51
|
+
def test_is_defined_success(self):
|
52
|
+
assert Duration.seconds(123.0).is_defined() is not None
|
53
|
+
|
54
|
+
def test_is_zero_success(self):
|
55
|
+
assert Duration.seconds(123.0).is_zero() is not None
|
56
|
+
|
57
|
+
def test_is_positive_success(self):
|
58
|
+
assert Duration.seconds(123.0).is_positive() is not None
|
59
|
+
|
60
|
+
def test_is_strictly_positive_success(self):
|
61
|
+
assert Duration.seconds(123.0).is_strictly_positive() is not None
|
62
|
+
|
63
|
+
def test_is_near_success(self):
|
64
|
+
assert (
|
65
|
+
Duration.seconds(123.0).is_near(Duration.seconds(123.0), Duration.zero())
|
66
|
+
is not None
|
67
|
+
)
|
68
|
+
|
69
|
+
def test_get_nanoseconds_success(self):
|
70
|
+
assert Duration.seconds(123.0).get_nanoseconds() is not None
|
71
|
+
|
72
|
+
def test_get_microseconds_success(self):
|
73
|
+
assert Duration.seconds(123.0).get_microseconds() is not None
|
74
|
+
|
75
|
+
def test_get_milliseconds_success(self):
|
76
|
+
assert Duration.seconds(123.0).get_milliseconds() is not None
|
77
|
+
|
78
|
+
def test_get_seconds_success(self):
|
79
|
+
assert Duration.seconds(123.0).get_seconds() is not None
|
80
|
+
|
81
|
+
def test_get_minutes_success(self):
|
82
|
+
assert Duration.seconds(123.0).get_minutes() is not None
|
83
|
+
|
84
|
+
def test_get_hours_success(self):
|
85
|
+
assert Duration.seconds(123.0).get_hours() is not None
|
86
|
+
|
87
|
+
def test_get_days_success(self):
|
88
|
+
assert Duration.seconds(123.0).get_days() is not None
|
89
|
+
|
90
|
+
def test_get_weeks_success(self):
|
91
|
+
assert Duration.seconds(123.0).get_weeks() is not None
|
92
|
+
|
93
|
+
def test_in_nanoseconds_success(self):
|
94
|
+
assert Duration.seconds(123.0).in_nanoseconds() is not None
|
95
|
+
|
96
|
+
def test_in_microseconds_success(self):
|
97
|
+
assert Duration.seconds(123.0).in_microseconds() is not None
|
98
|
+
|
99
|
+
def test_in_milliseconds_success(self):
|
100
|
+
assert Duration.seconds(123.0).in_milliseconds() is not None
|
101
|
+
|
102
|
+
def test_in_seconds_success(self):
|
103
|
+
assert Duration.seconds(123.0).in_seconds() is not None
|
104
|
+
|
105
|
+
def test_in_minutes_success(self):
|
106
|
+
assert Duration.seconds(123.0).in_minutes() is not None
|
107
|
+
|
108
|
+
def test_in_hours_success(self):
|
109
|
+
assert Duration.seconds(123.0).in_hours() is not None
|
110
|
+
|
111
|
+
def test_in_days_success(self):
|
112
|
+
assert Duration.seconds(123.0).in_days() is not None
|
113
|
+
|
114
|
+
def test_in_weeks_success(self):
|
115
|
+
assert Duration.seconds(123.0).in_weeks() is not None
|
116
|
+
|
117
|
+
def test_in_unit_success(self):
|
118
|
+
assert Duration.seconds(123.0).in_unit(Time.Unit.Second) is not None
|
119
|
+
|
120
|
+
def test_get_absolute_success(self):
|
121
|
+
assert Duration.seconds(123.0).get_absolute() is not None
|
122
|
+
|
123
|
+
def test_to_string_success(self):
|
124
|
+
assert Duration.seconds(123.0).to_string() is not None
|
125
|
+
assert Duration.seconds(123.0).to_string(Duration.Format.Standard)
|
126
|
+
assert Duration.seconds(123.0).to_string(Duration.Format.ISO8601)
|
127
|
+
|
128
|
+
def test_to_timedelta_success(self):
|
129
|
+
assert isinstance(Duration.hours(1.0).to_timedelta(), timedelta)
|
130
|
+
|
131
|
+
assert Duration.seconds(0.0).to_timedelta() == timedelta(seconds=0.0)
|
132
|
+
|
133
|
+
assert Duration.nanoseconds(1.0).to_timedelta() == timedelta(microseconds=0.001)
|
134
|
+
assert Duration.microseconds(1.0).to_timedelta() == timedelta(microseconds=1.0)
|
135
|
+
assert Duration.seconds(1.0).to_timedelta() == timedelta(seconds=1.0)
|
136
|
+
assert Duration.minutes(1.0).to_timedelta() == timedelta(minutes=1.0)
|
137
|
+
assert Duration.hours(1.0).to_timedelta() == timedelta(hours=1.0)
|
138
|
+
assert Duration.days(1.0).to_timedelta() == timedelta(days=1.0)
|
139
|
+
|
140
|
+
def test_undefined_success(self):
|
141
|
+
assert Duration.undefined() is not None
|
142
|
+
|
143
|
+
def test_zero_success(self):
|
144
|
+
assert Duration.zero() is not None
|
145
|
+
|
146
|
+
def test_nanoseconds_success(self):
|
147
|
+
assert Duration.nanoseconds(123.456) is not None
|
148
|
+
|
149
|
+
def test_microseconds_success(self):
|
150
|
+
assert Duration.microseconds(123.456) is not None
|
151
|
+
|
152
|
+
def test_milliseconds_success(self):
|
153
|
+
assert Duration.milliseconds(123.456) is not None
|
154
|
+
|
155
|
+
def test_seconds_success(self):
|
156
|
+
assert Duration.seconds(123.456) is not None
|
157
|
+
|
158
|
+
def test_minutes_success(self):
|
159
|
+
assert Duration.minutes(123.456) is not None
|
160
|
+
|
161
|
+
def test_hours_success(self):
|
162
|
+
assert Duration.hours(123.456) is not None
|
163
|
+
|
164
|
+
def test_days_success(self):
|
165
|
+
assert Duration.days(123.456) is not None
|
166
|
+
|
167
|
+
def test_weeks_success(self):
|
168
|
+
assert Duration.weeks(123.456) is not None
|
169
|
+
|
170
|
+
def test_between_success(self):
|
171
|
+
assert Duration.between(Instant.now(), Instant.now()) is not None
|
172
|
+
|
173
|
+
def test_parse_success_python_str(self):
|
174
|
+
# Testing with default format argument (Duration::Format::Undefined)
|
175
|
+
duration = Duration.parse("02:03.456.000.000")
|
176
|
+
|
177
|
+
assert duration is not None
|
178
|
+
assert isinstance(duration, Duration)
|
179
|
+
assert duration.is_defined() is True
|
180
|
+
|
181
|
+
# Testing with Duration.Format.Standard
|
182
|
+
duration = Duration.parse("02:03.456.000.000", Duration.Format.Standard)
|
183
|
+
|
184
|
+
assert duration is not None
|
185
|
+
assert isinstance(duration, Duration)
|
186
|
+
assert duration.is_defined() is True
|
187
|
+
|
188
|
+
# Testing with Duration.Format.ISO8601
|
189
|
+
duration = Duration.parse("PT2M3.456S", Duration.Format.ISO8601)
|
190
|
+
|
191
|
+
assert duration is not None
|
192
|
+
assert isinstance(duration, Duration)
|
193
|
+
assert duration.is_defined() is True
|
194
|
+
|
195
|
+
def test_parse_success_string(self):
|
196
|
+
# Testing with default format argument (Duration::Format::Undefined)
|
197
|
+
duration = Duration.parse(String("02:03.456.000.000"))
|
198
|
+
|
199
|
+
assert duration is not None
|
200
|
+
assert isinstance(duration, Duration)
|
201
|
+
assert duration.is_defined() is True
|
202
|
+
|
203
|
+
# Testing with Duration.Format.Standard
|
204
|
+
duration = Duration.parse(String("02:03.456.000.000"), Duration.Format.Standard)
|
205
|
+
|
206
|
+
assert duration is not None
|
207
|
+
assert isinstance(duration, Duration)
|
208
|
+
assert duration.is_defined() is True
|
209
|
+
|
210
|
+
# Testing with Duration.Format.ISO8601
|
211
|
+
duration = Duration.parse(String("PT2M3.456S"), Duration.Format.ISO8601)
|
212
|
+
|
213
|
+
assert duration is not None
|
214
|
+
assert isinstance(duration, Duration)
|
215
|
+
assert duration.is_defined() is True
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import datetime
|
4
|
+
import pytest
|
5
|
+
|
6
|
+
from ostk.physics.time import Scale
|
7
|
+
from ostk.physics.time import Instant
|
8
|
+
from ostk.physics.time import Duration
|
9
|
+
from ostk.physics.time import DateTime
|
10
|
+
|
11
|
+
|
12
|
+
def test_instant_undefined():
|
13
|
+
assert Instant.undefined() is not None
|
14
|
+
|
15
|
+
|
16
|
+
def test_instant_now():
|
17
|
+
assert Instant.now() is not None
|
18
|
+
|
19
|
+
|
20
|
+
def test_instant_J2000():
|
21
|
+
assert Instant.J2000() is not None
|
22
|
+
|
23
|
+
|
24
|
+
def test_instant_GPS_epock():
|
25
|
+
assert Instant.GPS_epoch() is not None
|
26
|
+
|
27
|
+
|
28
|
+
def test_instant_datetime():
|
29
|
+
assert (
|
30
|
+
Instant.date_time(DateTime(2018, 1, 1, 0, 0, 0, 0, 0, 0), Scale.UTC) is not None
|
31
|
+
)
|
32
|
+
|
33
|
+
assert Instant.date_time(datetime.datetime.now(), Scale.UTC)
|
34
|
+
|
35
|
+
|
36
|
+
def test_instant_julian_date():
|
37
|
+
assert Instant.julian_date(2458119.5, Scale.UTC) is not None
|
38
|
+
|
39
|
+
|
40
|
+
def test_instant_modified_julian_date():
|
41
|
+
assert Instant.modified_julian_date(58119.0, Scale.UTC) is not None
|
42
|
+
|
43
|
+
|
44
|
+
def test_instant_parse():
|
45
|
+
assert Instant.parse("2024-01-01 00:01:02.000", Scale.UTC) is not None
|
46
|
+
assert (
|
47
|
+
Instant.parse("2024-01-01 00:01:02.000", Scale.UTC, DateTime.Format.Standard)
|
48
|
+
is not None
|
49
|
+
)
|
50
|
+
assert (
|
51
|
+
Instant.parse("2024-01-01T00:01:02.000", Scale.UTC, DateTime.Format.ISO8601)
|
52
|
+
is not None
|
53
|
+
)
|
54
|
+
|
55
|
+
|
56
|
+
def test_instant_operators():
|
57
|
+
instant = Instant.J2000()
|
58
|
+
|
59
|
+
assert (instant == instant) is not None
|
60
|
+
assert (instant != instant) is not None
|
61
|
+
|
62
|
+
assert (instant < instant) is not None
|
63
|
+
assert (instant <= instant) is not None
|
64
|
+
assert (instant > instant) is not None
|
65
|
+
assert (instant >= instant) is not None
|
66
|
+
|
67
|
+
assert (instant + Duration.seconds(1.0)) is not None
|
68
|
+
assert (instant - Duration.seconds(1.0)) is not None
|
69
|
+
|
70
|
+
assert (instant - instant) is not None
|
71
|
+
|
72
|
+
instant += Duration.seconds(1.0)
|
73
|
+
instant -= Duration.seconds(1.0)
|
74
|
+
|
75
|
+
|
76
|
+
def test_instant_is_defined():
|
77
|
+
assert Instant.J2000().is_defined() is not None
|
78
|
+
|
79
|
+
|
80
|
+
def test_instant_is_post_epoch():
|
81
|
+
assert Instant.J2000().is_post_epoch() is not None
|
82
|
+
|
83
|
+
|
84
|
+
def test_instant_is_near():
|
85
|
+
assert Instant.J2000().is_near(Instant.J2000(), Duration.zero()) is not None
|
86
|
+
|
87
|
+
|
88
|
+
def test_instant_get_date_time():
|
89
|
+
assert Instant.J2000().get_date_time(Scale.UTC) is not None
|
90
|
+
|
91
|
+
|
92
|
+
def test_instant_get_julian_date():
|
93
|
+
assert Instant.J2000().get_julian_date(Scale.UTC) is not None
|
94
|
+
|
95
|
+
|
96
|
+
def test_instant_get_modified_julian_date():
|
97
|
+
assert Instant.J2000().get_modified_julian_date(Scale.UTC) is not None
|
98
|
+
|
99
|
+
|
100
|
+
def test_instant_to_string():
|
101
|
+
assert Instant.J2000().to_string() is not None
|
102
|
+
assert Instant.J2000().to_string(Scale.UTC) is not None
|
103
|
+
assert Instant.J2000().to_string(Scale.UTC, DateTime.Format.ISO8601) is not None
|