open-space-toolkit-physics 11.3.0__py311-none-manylinux2014_x86_64.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-311-x86_64-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,297 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
from ostk.core.type import Real, String
|
6
|
+
|
7
|
+
import ostk.physics as physics
|
8
|
+
|
9
|
+
Length = physics.unit.Length
|
10
|
+
Unit = Length.Unit
|
11
|
+
Interval = physics.unit.Interval
|
12
|
+
|
13
|
+
|
14
|
+
def test_unit_length_unit():
|
15
|
+
enum_members = Unit.__members__
|
16
|
+
|
17
|
+
list_keys = [
|
18
|
+
"Undefined",
|
19
|
+
"Meter",
|
20
|
+
"Foot",
|
21
|
+
"TerrestrialMile",
|
22
|
+
"NauticalMile",
|
23
|
+
"AstronomicalUnit",
|
24
|
+
]
|
25
|
+
|
26
|
+
list_values = [
|
27
|
+
Unit.Undefined,
|
28
|
+
Unit.Meter,
|
29
|
+
Unit.Foot,
|
30
|
+
Unit.TerrestrialMile,
|
31
|
+
Unit.NauticalMile,
|
32
|
+
Unit.AstronomicalUnit,
|
33
|
+
]
|
34
|
+
|
35
|
+
assert enum_members is not None
|
36
|
+
assert list(enum_members.keys()) == list_keys
|
37
|
+
assert list(enum_members.values()) == list_values
|
38
|
+
|
39
|
+
|
40
|
+
def test_unit_length_constructors():
|
41
|
+
length: Length = Length(4.0, Unit.Meter)
|
42
|
+
|
43
|
+
assert length is not None
|
44
|
+
assert isinstance(length, Length)
|
45
|
+
assert length.is_defined()
|
46
|
+
|
47
|
+
length: Length = Length(4.0, Unit.Foot)
|
48
|
+
|
49
|
+
assert length is not None
|
50
|
+
assert isinstance(length, Length)
|
51
|
+
assert length.is_defined()
|
52
|
+
|
53
|
+
length: Length = Length(4.0, Unit.TerrestrialMile)
|
54
|
+
|
55
|
+
assert length is not None
|
56
|
+
assert isinstance(length, Length)
|
57
|
+
assert length.is_defined()
|
58
|
+
|
59
|
+
length: Length = Length(4.0, Unit.NauticalMile)
|
60
|
+
|
61
|
+
assert length is not None
|
62
|
+
assert isinstance(length, Length)
|
63
|
+
assert length.is_defined()
|
64
|
+
|
65
|
+
length: Length = Length(4.0, Unit.AstronomicalUnit)
|
66
|
+
|
67
|
+
assert length is not None
|
68
|
+
assert isinstance(length, Length)
|
69
|
+
assert length.is_defined()
|
70
|
+
|
71
|
+
length: Length = Length(4.0, Unit.Undefined)
|
72
|
+
|
73
|
+
assert length is not None
|
74
|
+
assert isinstance(length, Length)
|
75
|
+
assert length.is_defined() is False
|
76
|
+
|
77
|
+
length: Length = Length(-1.0, Unit.Meter)
|
78
|
+
|
79
|
+
assert length is not None
|
80
|
+
assert isinstance(length, Length)
|
81
|
+
assert length.is_defined() is True
|
82
|
+
|
83
|
+
|
84
|
+
def test_unit_length_comparators():
|
85
|
+
length_1: Length = Length(4.0, Unit.Meter)
|
86
|
+
length_2: Length = Length(3.5, Unit.Meter)
|
87
|
+
|
88
|
+
assert length_1 == length_1
|
89
|
+
assert length_2 == length_2
|
90
|
+
assert length_1 != length_2
|
91
|
+
|
92
|
+
assert length_1 <= length_1
|
93
|
+
assert length_2 <= length_1
|
94
|
+
assert length_2 <= length_2
|
95
|
+
assert length_2 < length_1
|
96
|
+
|
97
|
+
assert length_1 >= length_1
|
98
|
+
assert length_1 >= length_2
|
99
|
+
assert length_2 >= length_2
|
100
|
+
assert length_1 > length_2
|
101
|
+
|
102
|
+
|
103
|
+
def test_unit_length_operators():
|
104
|
+
length_1: Length = Length(4.0, Unit.Meter)
|
105
|
+
length_2: Length = Length(3.5, Unit.Meter)
|
106
|
+
|
107
|
+
sum_length: Length = length_1 + length_2
|
108
|
+
diff_length: Length = length_1 - length_2
|
109
|
+
mul_length: Length = length_1 * 2.0
|
110
|
+
div_length: Length = length_1 / 2.0
|
111
|
+
|
112
|
+
assert sum_length is not None
|
113
|
+
assert isinstance(sum_length, Length)
|
114
|
+
assert sum_length.is_defined()
|
115
|
+
assert sum_length == Length(7.5, Unit.Meter)
|
116
|
+
|
117
|
+
assert diff_length is not None
|
118
|
+
assert isinstance(diff_length, Length)
|
119
|
+
assert diff_length.is_defined()
|
120
|
+
assert diff_length == Length(0.5, Unit.Meter)
|
121
|
+
|
122
|
+
assert mul_length is not None
|
123
|
+
assert isinstance(mul_length, Length)
|
124
|
+
assert mul_length.is_defined()
|
125
|
+
assert mul_length == Length(8.0, Unit.Meter)
|
126
|
+
|
127
|
+
assert div_length is not None
|
128
|
+
assert isinstance(div_length, Length)
|
129
|
+
assert div_length.is_defined()
|
130
|
+
assert div_length == Length(2.0, Unit.Meter)
|
131
|
+
|
132
|
+
length_1 += length_2
|
133
|
+
|
134
|
+
assert length_1 is not None
|
135
|
+
assert isinstance(length_1, Length)
|
136
|
+
assert length_1.is_defined()
|
137
|
+
assert length_1 == Length(7.5, Unit.Meter)
|
138
|
+
|
139
|
+
length_1 -= length_2
|
140
|
+
|
141
|
+
assert length_1 is not None
|
142
|
+
assert isinstance(length_1, Length)
|
143
|
+
assert length_1.is_defined()
|
144
|
+
assert length_1 == Length(4.0, Unit.Meter)
|
145
|
+
|
146
|
+
length_1 *= 2.0
|
147
|
+
|
148
|
+
assert length_1 is not None
|
149
|
+
assert isinstance(length_1, Length)
|
150
|
+
assert length_1.is_defined()
|
151
|
+
assert length_1 == Length(8.0, Unit.Meter)
|
152
|
+
|
153
|
+
length_1 /= 2.0
|
154
|
+
|
155
|
+
assert length_1 is not None
|
156
|
+
assert isinstance(length_1, Length)
|
157
|
+
assert length_1.is_defined()
|
158
|
+
assert length_1 == Length(4.0, Unit.Meter)
|
159
|
+
|
160
|
+
|
161
|
+
def test_unit_length_is_defined():
|
162
|
+
length: Length = Length(4.0, Unit.Meter)
|
163
|
+
|
164
|
+
assert length.is_defined() is True
|
165
|
+
assert length.undefined().is_defined() is False
|
166
|
+
|
167
|
+
|
168
|
+
def test_unit_length_get_unit():
|
169
|
+
length: Length = Length(4.0, Unit.Meter)
|
170
|
+
unit: Unit = length.get_unit()
|
171
|
+
|
172
|
+
assert unit is not None
|
173
|
+
assert isinstance(unit, Unit)
|
174
|
+
assert unit == Unit.Meter
|
175
|
+
|
176
|
+
length: Length = Length(4.0, Unit.Foot)
|
177
|
+
unit: Unit = length.get_unit()
|
178
|
+
|
179
|
+
assert unit is not None
|
180
|
+
assert isinstance(unit, Unit)
|
181
|
+
assert unit == Unit.Foot
|
182
|
+
|
183
|
+
length: Length = Length(4.0, Unit.TerrestrialMile)
|
184
|
+
unit: Unit = length.get_unit()
|
185
|
+
|
186
|
+
assert unit is not None
|
187
|
+
assert isinstance(unit, Unit)
|
188
|
+
assert unit == Unit.TerrestrialMile
|
189
|
+
|
190
|
+
length: Length = Length(4.0, Unit.NauticalMile)
|
191
|
+
unit: Unit = length.get_unit()
|
192
|
+
|
193
|
+
assert unit is not None
|
194
|
+
assert isinstance(unit, Unit)
|
195
|
+
assert unit == Unit.NauticalMile
|
196
|
+
|
197
|
+
length: Length = Length(4.0, Unit.AstronomicalUnit)
|
198
|
+
unit: Unit = length.get_unit()
|
199
|
+
|
200
|
+
assert unit is not None
|
201
|
+
assert isinstance(unit, Unit)
|
202
|
+
assert unit == Unit.AstronomicalUnit
|
203
|
+
|
204
|
+
|
205
|
+
def test_unit_length_in_unit():
|
206
|
+
length: Length = Length(4.0, Unit.Meter)
|
207
|
+
|
208
|
+
assert length.in_unit(Unit.Meter) is not None
|
209
|
+
assert length.in_unit(Unit.Meter) == 4.0
|
210
|
+
|
211
|
+
assert length.in_unit(Unit.Foot) is not None
|
212
|
+
# assert length.in_unit(Unit.Foot) == 4.0
|
213
|
+
|
214
|
+
assert length.in_unit(Unit.TerrestrialMile) is not None
|
215
|
+
# assert length.in_unit(Unit.TerrestrialMile) == 4.0
|
216
|
+
|
217
|
+
assert length.in_unit(Unit.NauticalMile) is not None
|
218
|
+
# assert length.in_unit(Unit.NauticalMile) == 4.0
|
219
|
+
|
220
|
+
assert length.in_unit(Unit.AstronomicalUnit) is not None
|
221
|
+
# assert length.in_unit(Unit.AstronomicalUnit) == 4.0
|
222
|
+
|
223
|
+
|
224
|
+
def test_unit_length_in_meters():
|
225
|
+
length: Length = Length(4000.0, Unit.Meter)
|
226
|
+
|
227
|
+
assert length.in_meters() is not None
|
228
|
+
assert isinstance(length.in_meters(), Real)
|
229
|
+
assert length.in_meters() == 4000.0
|
230
|
+
|
231
|
+
|
232
|
+
# def test_unit_length_millimeters ():
|
233
|
+
|
234
|
+
# length: Length = Length(4000.0, Unit.Meter)
|
235
|
+
|
236
|
+
# assert length.in_millimeters() is not None
|
237
|
+
# assert isinstance(length.in_millimeters(), Real)
|
238
|
+
# assert length.in_millimeters() == 4000000.0
|
239
|
+
|
240
|
+
|
241
|
+
def test_unit_length_kilometers():
|
242
|
+
length: Length = Length(4000.0, Unit.Meter)
|
243
|
+
|
244
|
+
assert length.in_kilometers() is not None
|
245
|
+
assert isinstance(length.in_kilometers(), Real)
|
246
|
+
assert length.in_kilometers() == 4.0
|
247
|
+
|
248
|
+
|
249
|
+
def test_unit_length_to_string():
|
250
|
+
length: Length = Length(4000.0, Unit.Meter)
|
251
|
+
|
252
|
+
assert length.to_string() is not None
|
253
|
+
assert isinstance(length.to_string(), String)
|
254
|
+
assert length.to_string() == "4000.0 [m]"
|
255
|
+
|
256
|
+
|
257
|
+
# def test_unit_length_parse ():
|
258
|
+
|
259
|
+
|
260
|
+
def test_unit_length_string_from_unit():
|
261
|
+
string_0: Unit = Length.string_from_unit(Unit.Meter)
|
262
|
+
string_1: Unit = Length.string_from_unit(Unit.Foot)
|
263
|
+
string_2: Unit = Length.string_from_unit(Unit.TerrestrialMile)
|
264
|
+
string_3: Unit = Length.string_from_unit(Unit.NauticalMile)
|
265
|
+
string_4: Unit = Length.string_from_unit(Unit.AstronomicalUnit)
|
266
|
+
|
267
|
+
assert string_0 is not None
|
268
|
+
assert string_1 is not None
|
269
|
+
assert string_2 is not None
|
270
|
+
assert string_3 is not None
|
271
|
+
assert string_4 is not None
|
272
|
+
|
273
|
+
assert string_0 == "Meter"
|
274
|
+
assert string_1 == "Foot"
|
275
|
+
assert string_2 == "Terrestrial Mile"
|
276
|
+
assert string_3 == "Nautical Mile"
|
277
|
+
assert string_4 == "Astronomical Unit"
|
278
|
+
|
279
|
+
|
280
|
+
def test_unit_length_symbol_from_unit():
|
281
|
+
unit_0: Unit = Length.symbol_from_unit(Unit.Meter)
|
282
|
+
unit_1: Unit = Length.symbol_from_unit(Unit.Foot)
|
283
|
+
unit_2: Unit = Length.symbol_from_unit(Unit.TerrestrialMile)
|
284
|
+
unit_3: Unit = Length.symbol_from_unit(Unit.NauticalMile)
|
285
|
+
unit_4: Unit = Length.symbol_from_unit(Unit.AstronomicalUnit)
|
286
|
+
|
287
|
+
assert unit_0 is not None
|
288
|
+
assert unit_1 is not None
|
289
|
+
assert unit_2 is not None
|
290
|
+
assert unit_3 is not None
|
291
|
+
assert unit_4 is not None
|
292
|
+
|
293
|
+
assert unit_0 == "m"
|
294
|
+
assert unit_1 == "ft"
|
295
|
+
assert unit_2 == "mi"
|
296
|
+
assert unit_3 == "nmi"
|
297
|
+
assert unit_4 == "AU"
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
from ostk.core.type import Real, String
|
6
|
+
|
7
|
+
import ostk.physics as physics
|
8
|
+
|
9
|
+
Mass = physics.unit.Mass
|
10
|
+
Unit = Mass.Unit
|
11
|
+
|
12
|
+
|
13
|
+
def test_unit_mass_unit():
|
14
|
+
enum_members = Unit.__members__
|
15
|
+
|
16
|
+
list_keys = ["Undefined", "Kilogram", "Pound", "Tonne"]
|
17
|
+
|
18
|
+
list_values = [Unit.Undefined, Unit.Kilogram, Unit.Pound, Unit.Tonne]
|
19
|
+
|
20
|
+
assert enum_members is not None
|
21
|
+
assert list(enum_members.keys()) == list_keys
|
22
|
+
assert list(enum_members.values()) == list_values
|
23
|
+
|
24
|
+
|
25
|
+
def test_unit_mass_constructors():
|
26
|
+
mass: Mass = Mass(4.0, Unit.Kilogram)
|
27
|
+
|
28
|
+
assert mass is not None
|
29
|
+
assert isinstance(mass, Mass)
|
30
|
+
assert mass.is_defined()
|
31
|
+
|
32
|
+
mass: Mass = Mass(4.0, Unit.Pound)
|
33
|
+
|
34
|
+
assert mass is not None
|
35
|
+
assert isinstance(mass, Mass)
|
36
|
+
assert mass.is_defined()
|
37
|
+
|
38
|
+
mass: Mass = Mass(4.0, Unit.Tonne)
|
39
|
+
|
40
|
+
assert mass is not None
|
41
|
+
assert isinstance(mass, Mass)
|
42
|
+
assert mass.is_defined()
|
43
|
+
|
44
|
+
|
45
|
+
def test_unit_mass_comparators():
|
46
|
+
mass_1: Mass = Mass(4.0, Unit.Kilogram)
|
47
|
+
mass_2: Mass = Mass(3.5, Unit.Kilogram)
|
48
|
+
|
49
|
+
assert mass_1 == mass_1
|
50
|
+
assert mass_2 == mass_2
|
51
|
+
assert mass_1 != mass_2
|
52
|
+
|
53
|
+
|
54
|
+
def test_unit_mass_is_defined():
|
55
|
+
mass: Mass = Mass(4.0, Unit.Kilogram)
|
56
|
+
|
57
|
+
assert mass.is_defined() is True
|
58
|
+
assert mass.undefined().is_defined() is False
|
59
|
+
|
60
|
+
|
61
|
+
def test_unit_mass_get_unit():
|
62
|
+
mass: Mass = Mass(4.0, Unit.Kilogram)
|
63
|
+
unit: Unit = mass.get_unit()
|
64
|
+
|
65
|
+
assert unit is not None
|
66
|
+
assert isinstance(unit, Unit)
|
67
|
+
assert unit == Unit.Kilogram
|
68
|
+
|
69
|
+
mass: Mass = Mass(4.0, Unit.Pound)
|
70
|
+
unit: Unit = mass.get_unit()
|
71
|
+
|
72
|
+
assert unit is not None
|
73
|
+
assert isinstance(unit, Unit)
|
74
|
+
assert unit == Unit.Pound
|
75
|
+
|
76
|
+
mass: Mass = Mass(4.0, Unit.Tonne)
|
77
|
+
unit: Unit = mass.get_unit()
|
78
|
+
|
79
|
+
assert unit is not None
|
80
|
+
assert isinstance(unit, Unit)
|
81
|
+
assert unit == Unit.Tonne
|
82
|
+
|
83
|
+
|
84
|
+
def test_unit_mass_in_unit():
|
85
|
+
mass: Mass = Mass(4.0, Unit.Kilogram)
|
86
|
+
|
87
|
+
assert mass.in_unit(Unit.Kilogram) is not None
|
88
|
+
assert mass.in_unit(Unit.Kilogram) == 4.0
|
89
|
+
|
90
|
+
assert mass.in_unit(Unit.Pound) is not None
|
91
|
+
|
92
|
+
assert mass.in_unit(Unit.Tonne) is not None
|
93
|
+
|
94
|
+
|
95
|
+
def test_unit_mass_in_kilograms():
|
96
|
+
mass: Mass = Mass(4000.0, Unit.Kilogram)
|
97
|
+
|
98
|
+
assert mass.in_kilograms() is not None
|
99
|
+
assert isinstance(mass.in_kilograms(), Real)
|
100
|
+
assert mass.in_kilograms() == 4000.0
|
101
|
+
|
102
|
+
|
103
|
+
def test_unit_mass_to_string():
|
104
|
+
mass: Mass = Mass(4000.0, Unit.Kilogram)
|
105
|
+
|
106
|
+
assert mass.to_string() is not None
|
107
|
+
assert isinstance(mass.to_string(), String)
|
108
|
+
assert mass.to_string() == "4000.0 [kg]"
|
109
|
+
|
110
|
+
|
111
|
+
@pytest.mark.skip(reason="TBI")
|
112
|
+
def test_unit_mass_parse():
|
113
|
+
pass
|
114
|
+
|
115
|
+
|
116
|
+
def test_unit_mass_string_from_unit():
|
117
|
+
string_0: Unit = Mass.string_from_unit(Unit.Kilogram)
|
118
|
+
string_1: Unit = Mass.string_from_unit(Unit.Pound)
|
119
|
+
string_2: Unit = Mass.string_from_unit(Unit.Tonne)
|
120
|
+
|
121
|
+
assert string_0 is not None
|
122
|
+
assert string_1 is not None
|
123
|
+
assert string_2 is not None
|
124
|
+
|
125
|
+
assert string_0 == "Kilogram"
|
126
|
+
assert string_1 == "Pound"
|
127
|
+
assert string_2 == "Tonne"
|
128
|
+
|
129
|
+
|
130
|
+
def test_unit_mass_symbol_from_unit():
|
131
|
+
unit_0: Unit = Mass.symbol_from_unit(Unit.Kilogram)
|
132
|
+
unit_1: Unit = Mass.symbol_from_unit(Unit.Pound)
|
133
|
+
unit_2: Unit = Mass.symbol_from_unit(Unit.Tonne)
|
134
|
+
|
135
|
+
assert unit_0 is not None
|
136
|
+
assert unit_1 is not None
|
137
|
+
assert unit_2 is not None
|
138
|
+
|
139
|
+
assert unit_0 == "kg"
|
140
|
+
assert unit_1 == "lb"
|
141
|
+
assert unit_2 == "t"
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
import ostk.physics as physics
|
6
|
+
|
7
|
+
Time = physics.unit.Time
|
8
|
+
Unit = Time.Unit
|
9
|
+
|
10
|
+
|
11
|
+
def test_unit_time_unit():
|
12
|
+
enum_members = Unit.__members__
|
13
|
+
|
14
|
+
list_keys = [
|
15
|
+
"Undefined",
|
16
|
+
"Nanosecond",
|
17
|
+
"Microsecond",
|
18
|
+
"Millisecond",
|
19
|
+
"Second",
|
20
|
+
"Minute",
|
21
|
+
"Hour",
|
22
|
+
"Day",
|
23
|
+
"Week",
|
24
|
+
]
|
25
|
+
|
26
|
+
list_values = [
|
27
|
+
Unit.Undefined,
|
28
|
+
Unit.Nanosecond,
|
29
|
+
Unit.Microsecond,
|
30
|
+
Unit.Millisecond,
|
31
|
+
Unit.Second,
|
32
|
+
Unit.Minute,
|
33
|
+
Unit.Hour,
|
34
|
+
Unit.Day,
|
35
|
+
Unit.Week,
|
36
|
+
]
|
37
|
+
|
38
|
+
assert enum_members is not None
|
39
|
+
assert list(enum_members.keys()) == list_keys
|
40
|
+
assert list(enum_members.values()) == list_values
|
41
|
+
|
42
|
+
|
43
|
+
def test_unit_time_constructors():
|
44
|
+
time: Time = Time(3.2, Unit.Nanosecond)
|
45
|
+
|
46
|
+
assert time is not None
|
47
|
+
assert isinstance(time, Time)
|
48
|
+
assert time.is_defined()
|
49
|
+
|
50
|
+
time: Time = Time(3.2, Unit.Microsecond)
|
51
|
+
|
52
|
+
assert time is not None
|
53
|
+
assert isinstance(time, Time)
|
54
|
+
assert time.is_defined()
|
55
|
+
|
56
|
+
time: Time = Time(3.2, Unit.Millisecond)
|
57
|
+
|
58
|
+
assert time is not None
|
59
|
+
assert isinstance(time, Time)
|
60
|
+
assert time.is_defined()
|
61
|
+
|
62
|
+
time: Time = Time(3.2, Unit.Second)
|
63
|
+
|
64
|
+
assert time is not None
|
65
|
+
assert isinstance(time, Time)
|
66
|
+
assert time.is_defined()
|
67
|
+
|
68
|
+
time: Time = Time(3.2, Unit.Minute)
|
69
|
+
|
70
|
+
assert time is not None
|
71
|
+
assert isinstance(time, Time)
|
72
|
+
assert time.is_defined()
|
73
|
+
|
74
|
+
time: Time = Time(3.2, Unit.Hour)
|
75
|
+
|
76
|
+
assert time is not None
|
77
|
+
assert isinstance(time, Time)
|
78
|
+
assert time.is_defined()
|
79
|
+
|
80
|
+
time: Time = Time(3.2, Unit.Day)
|
81
|
+
|
82
|
+
assert time is not None
|
83
|
+
assert isinstance(time, Time)
|
84
|
+
assert time.is_defined()
|
85
|
+
|
86
|
+
time: Time = Time(3.2, Unit.Week)
|
87
|
+
|
88
|
+
assert time is not None
|
89
|
+
assert isinstance(time, Time)
|
90
|
+
assert time.is_defined()
|
91
|
+
|
92
|
+
time: Time = Time(3.2, Unit.Undefined)
|
93
|
+
|
94
|
+
assert time is not None
|
95
|
+
assert isinstance(time, Time)
|
96
|
+
assert time.is_defined() is False
|
97
|
+
|
98
|
+
|
99
|
+
def test_unit_time_is_defined():
|
100
|
+
assert Time(2.0, Unit.Second).is_defined()
|
101
|
+
assert Time.undefined().is_defined() is False
|