open-space-toolkit-physics 11.2.1__py313-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.2.1.dist-info/METADATA +29 -0
- open_space_toolkit_physics-11.2.1.dist-info/RECORD +81 -0
- open_space_toolkit_physics-11.2.1.dist-info/WHEEL +5 -0
- open_space_toolkit_physics-11.2.1.dist-info/top_level.txt +1 -0
- open_space_toolkit_physics-11.2.1.dist-info/zip-safe +1 -0
- ostk/__init__.py +1 -0
- ostk/physics/OpenSpaceToolkitPhysicsPy.cpython-313-aarch64-linux-gnu.so +0 -0
- ostk/physics/__init__.py +6 -0
- ostk/physics/libopen-space-toolkit-physics.so.11 +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 +490 -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 +206 -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
@@ -0,0 +1,368 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import math
|
4
|
+
|
5
|
+
import pytest
|
6
|
+
|
7
|
+
from ostk.mathematics.geometry import Angle as AngleMathematics
|
8
|
+
from ostk.physics.unit import Angle as AnglePhysics
|
9
|
+
|
10
|
+
Unit = AnglePhysics.Unit
|
11
|
+
|
12
|
+
|
13
|
+
def test_angle_conversion():
|
14
|
+
angle_physics: AnglePhysics = AnglePhysics(30.0, AnglePhysics.Unit.Degree)
|
15
|
+
angle_mathematics: AngleMathematics = AngleMathematics(
|
16
|
+
30.0, AngleMathematics.Unit.Degree
|
17
|
+
)
|
18
|
+
|
19
|
+
assert angle_physics is not None
|
20
|
+
assert angle_mathematics is not None
|
21
|
+
assert angle_physics == angle_mathematics
|
22
|
+
|
23
|
+
|
24
|
+
def test_angle_unit():
|
25
|
+
enum_members = Unit.__members__
|
26
|
+
|
27
|
+
list_keys = ["Undefined", "Radian", "Degree", "Arcminute", "Arcsecond", "Revolution"]
|
28
|
+
|
29
|
+
list_values = [
|
30
|
+
Unit.Undefined,
|
31
|
+
Unit.Radian,
|
32
|
+
Unit.Degree,
|
33
|
+
Unit.Arcminute,
|
34
|
+
Unit.Arcsecond,
|
35
|
+
Unit.Revolution,
|
36
|
+
]
|
37
|
+
|
38
|
+
assert list(enum_members.keys()) == list_keys
|
39
|
+
assert list(enum_members.values()) == list_values
|
40
|
+
|
41
|
+
|
42
|
+
def test_angle_default_constructor():
|
43
|
+
# Default constructor with Degree Unit
|
44
|
+
angle: AnglePhysics = AnglePhysics(12.34, Unit.Degree)
|
45
|
+
|
46
|
+
assert angle is not None
|
47
|
+
assert isinstance(angle, AnglePhysics)
|
48
|
+
assert angle.in_degrees() == 12.34
|
49
|
+
|
50
|
+
angle: AnglePhysics = AnglePhysics(-12.34, Unit.Degree)
|
51
|
+
|
52
|
+
assert angle is not None
|
53
|
+
assert isinstance(angle, AnglePhysics)
|
54
|
+
assert angle.in_degrees() == -12.34
|
55
|
+
|
56
|
+
angle: AnglePhysics = AnglePhysics(365.34, Unit.Degree)
|
57
|
+
|
58
|
+
assert angle is not None
|
59
|
+
assert isinstance(angle, AnglePhysics)
|
60
|
+
assert angle.in_degrees() == 365.34
|
61
|
+
|
62
|
+
angle: AnglePhysics = AnglePhysics(-4000.34, Unit.Degree)
|
63
|
+
|
64
|
+
assert angle is not None
|
65
|
+
assert isinstance(angle, AnglePhysics)
|
66
|
+
assert angle.in_degrees() == -4000.34
|
67
|
+
|
68
|
+
# Default constructor with Radian Unit
|
69
|
+
angle: AnglePhysics = AnglePhysics(3.4, Unit.Radian)
|
70
|
+
|
71
|
+
assert angle is not None
|
72
|
+
assert isinstance(angle, AnglePhysics)
|
73
|
+
assert angle.in_radians() == 3.4
|
74
|
+
|
75
|
+
# Default constructor with Arcminute Unit
|
76
|
+
angle: AnglePhysics = AnglePhysics(3600.0, Unit.Arcminute)
|
77
|
+
|
78
|
+
assert angle is not None
|
79
|
+
assert isinstance(angle, AnglePhysics)
|
80
|
+
assert angle.in_arcminutes() == 3600.0
|
81
|
+
|
82
|
+
# Default constructor with Arcsecond Unit
|
83
|
+
angle: AnglePhysics = AnglePhysics(3600.0, Unit.Arcsecond)
|
84
|
+
|
85
|
+
assert angle is not None
|
86
|
+
assert isinstance(angle, AnglePhysics)
|
87
|
+
assert angle.in_arcseconds() == 3600.0
|
88
|
+
|
89
|
+
# Default constructor with Revolution Unit
|
90
|
+
angle: AnglePhysics = AnglePhysics(18.0, Unit.Revolution)
|
91
|
+
|
92
|
+
assert angle is not None
|
93
|
+
assert isinstance(angle, AnglePhysics)
|
94
|
+
assert angle.in_revolutions() == 18.0
|
95
|
+
|
96
|
+
# Invalid construction
|
97
|
+
with pytest.raises(TypeError):
|
98
|
+
angle: AnglePhysics = AnglePhysics(45, Unit.Degree)
|
99
|
+
|
100
|
+
|
101
|
+
def test_angle_undefined_constructor():
|
102
|
+
angle: AnglePhysics = AnglePhysics.undefined()
|
103
|
+
|
104
|
+
assert angle is not None
|
105
|
+
assert isinstance(angle, AnglePhysics)
|
106
|
+
assert angle.is_defined() is False
|
107
|
+
|
108
|
+
|
109
|
+
def test_angle_zero_constructor():
|
110
|
+
angle: AnglePhysics = AnglePhysics.zero()
|
111
|
+
|
112
|
+
assert angle is not None
|
113
|
+
assert isinstance(angle, AnglePhysics)
|
114
|
+
assert angle.is_defined() is True
|
115
|
+
assert angle.get_unit() == Unit.Radian
|
116
|
+
assert angle.is_zero() is True
|
117
|
+
assert angle.in_radians() == 0.0
|
118
|
+
assert angle.in_degrees() == 0.0
|
119
|
+
assert angle.in_arcminutes() == 0.0
|
120
|
+
assert angle.in_arcseconds() == 0.0
|
121
|
+
assert angle.in_revolutions() == 0.0
|
122
|
+
|
123
|
+
|
124
|
+
def test_angle_pi_constructors():
|
125
|
+
angle: AnglePhysics = AnglePhysics.half_pi()
|
126
|
+
|
127
|
+
assert angle is not None
|
128
|
+
assert isinstance(angle, AnglePhysics)
|
129
|
+
assert angle.is_defined()
|
130
|
+
assert angle.get_unit() == Unit.Radian
|
131
|
+
assert angle.in_radians() == math.pi / 2
|
132
|
+
|
133
|
+
angle: AnglePhysics = AnglePhysics.pi()
|
134
|
+
|
135
|
+
assert angle is not None
|
136
|
+
assert isinstance(angle, AnglePhysics)
|
137
|
+
assert angle.is_defined()
|
138
|
+
assert angle.get_unit() == Unit.Radian
|
139
|
+
assert angle.in_radians() == math.pi
|
140
|
+
|
141
|
+
angle: AnglePhysics = AnglePhysics.two_pi()
|
142
|
+
|
143
|
+
assert angle is not None
|
144
|
+
assert isinstance(angle, AnglePhysics)
|
145
|
+
assert angle.is_defined()
|
146
|
+
assert angle.get_unit() == Unit.Radian
|
147
|
+
assert angle.in_radians() == 2 * math.pi
|
148
|
+
|
149
|
+
|
150
|
+
def test_angle_unit_constructors():
|
151
|
+
# Radian
|
152
|
+
angle: AnglePhysics = AnglePhysics.radians(3.4)
|
153
|
+
|
154
|
+
assert angle is not None
|
155
|
+
assert isinstance(angle, AnglePhysics)
|
156
|
+
assert angle.is_defined()
|
157
|
+
assert angle.get_unit() == Unit.Radian
|
158
|
+
assert angle.in_radians() == 3.4
|
159
|
+
|
160
|
+
# Degree
|
161
|
+
angle: AnglePhysics = AnglePhysics.degrees(-45.0)
|
162
|
+
|
163
|
+
assert angle is not None
|
164
|
+
assert isinstance(angle, AnglePhysics)
|
165
|
+
assert angle.is_defined()
|
166
|
+
assert angle.get_unit() == Unit.Degree
|
167
|
+
assert angle.in_degrees() == -45.0
|
168
|
+
|
169
|
+
# Arcminutes
|
170
|
+
angle: AnglePhysics = AnglePhysics.arcminutes(60.5)
|
171
|
+
|
172
|
+
assert angle is not None
|
173
|
+
assert isinstance(angle, AnglePhysics)
|
174
|
+
assert angle.is_defined()
|
175
|
+
assert angle.get_unit() == Unit.Arcminute
|
176
|
+
assert angle.in_arcminutes() == 60.5
|
177
|
+
|
178
|
+
# Arcseconds
|
179
|
+
angle: AnglePhysics = AnglePhysics.arcseconds(60.5)
|
180
|
+
|
181
|
+
assert angle is not None
|
182
|
+
assert isinstance(angle, AnglePhysics)
|
183
|
+
assert angle.is_defined()
|
184
|
+
assert angle.get_unit() == Unit.Arcsecond
|
185
|
+
assert angle.in_arcseconds() == 60.5
|
186
|
+
|
187
|
+
# Revolutions
|
188
|
+
angle: AnglePhysics = AnglePhysics.revolutions(3.9)
|
189
|
+
|
190
|
+
assert angle is not None
|
191
|
+
assert isinstance(angle, AnglePhysics)
|
192
|
+
assert angle.is_defined()
|
193
|
+
assert angle.get_unit() == Unit.Revolution
|
194
|
+
assert angle.in_revolutions() == 3.9
|
195
|
+
|
196
|
+
|
197
|
+
def test_angle_unit_conversion():
|
198
|
+
angle: AnglePhysics = AnglePhysics(60.0, Unit.Degree)
|
199
|
+
|
200
|
+
assert angle.in_degrees() == 60.0
|
201
|
+
assert angle.in_radians() == (math.pi * 60.0 / 180.0)
|
202
|
+
assert angle.in_arcminutes() == 60.0 * 60.0
|
203
|
+
assert (angle.in_arcseconds() - 60.0 * 3600.0) <= 1e-10
|
204
|
+
|
205
|
+
|
206
|
+
def test_angle_comparators():
|
207
|
+
angle_deg: AnglePhysics = AnglePhysics(60.0, Unit.Degree)
|
208
|
+
angle_rad: AnglePhysics = AnglePhysics(60.0 * math.pi / 180.0, Unit.Radian)
|
209
|
+
|
210
|
+
assert angle_deg == angle_deg
|
211
|
+
assert angle_rad == angle_rad
|
212
|
+
assert angle_deg == angle_rad
|
213
|
+
assert angle_deg != AnglePhysics(59.0, Unit.Degree)
|
214
|
+
|
215
|
+
|
216
|
+
def test_angle_operators():
|
217
|
+
angle: AnglePhysics = AnglePhysics(30.0, Unit.Degree)
|
218
|
+
half_angle: AnglePhysics = angle / 2.0
|
219
|
+
double_angle: AnglePhysics = angle * 2.0
|
220
|
+
sum_angle: AnglePhysics = angle + angle
|
221
|
+
diff_angle: AnglePhysics = angle - angle
|
222
|
+
positive_angle: AnglePhysics = +angle
|
223
|
+
negative_angle: AnglePhysics = -angle
|
224
|
+
|
225
|
+
assert half_angle is not None
|
226
|
+
assert isinstance(half_angle, AnglePhysics)
|
227
|
+
assert double_angle is not None
|
228
|
+
assert isinstance(double_angle, AnglePhysics)
|
229
|
+
assert sum_angle is not None
|
230
|
+
assert isinstance(sum_angle, AnglePhysics)
|
231
|
+
assert diff_angle is not None
|
232
|
+
assert isinstance(diff_angle, AnglePhysics)
|
233
|
+
assert positive_angle is not None
|
234
|
+
assert isinstance(positive_angle, AnglePhysics)
|
235
|
+
assert negative_angle is not None
|
236
|
+
assert isinstance(negative_angle, AnglePhysics)
|
237
|
+
|
238
|
+
assert half_angle.in_degrees() == 15.0
|
239
|
+
assert double_angle.in_degrees() == 60.0
|
240
|
+
assert sum_angle.in_degrees() == 60.0
|
241
|
+
assert diff_angle.in_degrees() == 0.0
|
242
|
+
assert diff_angle.is_zero()
|
243
|
+
assert positive_angle.in_degrees() == +30.0
|
244
|
+
assert negative_angle.in_degrees() == -30.0
|
245
|
+
|
246
|
+
angle_deg: AnglePhysics = AnglePhysics(90.0, Unit.Degree)
|
247
|
+
angle_rad: AnglePhysics = AnglePhysics(math.pi / 2, Unit.Radian)
|
248
|
+
|
249
|
+
sum_angle: AnglePhysics = angle_rad + angle_deg
|
250
|
+
assert sum_angle is not None
|
251
|
+
assert isinstance(sum_angle, AnglePhysics)
|
252
|
+
assert (sum_angle.in_degrees() - 180.0) <= 1e-10
|
253
|
+
|
254
|
+
angle: AnglePhysics = AnglePhysics(90.0, Unit.Degree)
|
255
|
+
|
256
|
+
angle *= 3.0
|
257
|
+
assert angle is not None
|
258
|
+
assert isinstance(angle, AnglePhysics)
|
259
|
+
assert angle.get_unit() == Unit.Degree
|
260
|
+
assert angle.in_degrees() == 270.0
|
261
|
+
|
262
|
+
angle /= 3.0
|
263
|
+
assert angle is not None
|
264
|
+
assert isinstance(angle, AnglePhysics)
|
265
|
+
assert angle.get_unit() == Unit.Degree
|
266
|
+
assert angle.in_degrees() == 90.0
|
267
|
+
|
268
|
+
|
269
|
+
def test_angle_string_from_unit():
|
270
|
+
assert AnglePhysics.string_from_unit(Unit.Degree) == "Degree"
|
271
|
+
assert AnglePhysics.string_from_unit(Unit.Radian) == "Radian"
|
272
|
+
assert AnglePhysics.string_from_unit(Unit.Arcminute) == "Arcminute"
|
273
|
+
assert AnglePhysics.string_from_unit(Unit.Arcsecond) == "Arcsecond"
|
274
|
+
assert AnglePhysics.string_from_unit(Unit.Revolution) == "Revolution"
|
275
|
+
|
276
|
+
|
277
|
+
def test_angle_string_symbol_from_unit():
|
278
|
+
assert AnglePhysics.symbol_from_unit(Unit.Degree) == "deg"
|
279
|
+
assert AnglePhysics.symbol_from_unit(Unit.Radian) == "rad"
|
280
|
+
assert AnglePhysics.symbol_from_unit(Unit.Arcminute) == "amin"
|
281
|
+
assert AnglePhysics.symbol_from_unit(Unit.Arcsecond) == "asec"
|
282
|
+
assert AnglePhysics.symbol_from_unit(Unit.Revolution) == "rev"
|
283
|
+
|
284
|
+
|
285
|
+
def test_angle_in_radians_reduction():
|
286
|
+
angle: AnglePhysics = AnglePhysics(math.pi * 3 / 2, Unit.Radian)
|
287
|
+
assert angle.in_radians(lower_bound=-math.pi, upper_bound=math.pi) == -math.pi / 2
|
288
|
+
|
289
|
+
angle: AnglePhysics = AnglePhysics(math.pi / 2, Unit.Radian)
|
290
|
+
assert angle.in_radians(lower_bound=-math.pi, upper_bound=math.pi) == math.pi / 2
|
291
|
+
|
292
|
+
angle: AnglePhysics = AnglePhysics(-math.pi, Unit.Radian)
|
293
|
+
assert angle.in_radians(-math.pi, math.pi) == -math.pi
|
294
|
+
|
295
|
+
angle: AnglePhysics = AnglePhysics(math.pi, Unit.Radian)
|
296
|
+
assert angle.in_radians(-math.pi, math.pi) == -math.pi
|
297
|
+
|
298
|
+
|
299
|
+
def test_angle_in_degrees_reduction():
|
300
|
+
angle: AnglePhysics = AnglePhysics(359.0, Unit.Degree)
|
301
|
+
assert angle.in_degrees(lower_bound=-180.0, upper_bound=180.0) == -1.0
|
302
|
+
|
303
|
+
angle: AnglePhysics = AnglePhysics(1.0, Unit.Degree)
|
304
|
+
assert angle.in_degrees(lower_bound=-180.0, upper_bound=180.0) == 1.0
|
305
|
+
|
306
|
+
angle: AnglePhysics = AnglePhysics(-180.0, Unit.Degree)
|
307
|
+
assert angle.in_degrees(-180.0, 180.0) == -180.0
|
308
|
+
|
309
|
+
angle: AnglePhysics = AnglePhysics(180.0, Unit.Degree)
|
310
|
+
assert angle.in_degrees(-180.0, 180.0) == -180.0
|
311
|
+
|
312
|
+
|
313
|
+
def test_angle_in_arcminutes_reduction():
|
314
|
+
angle: AnglePhysics = AnglePhysics(359.0 * 60.0, Unit.Arcminute)
|
315
|
+
assert (
|
316
|
+
angle.in_arcminutes(lower_bound=-180.0 * 60.0, upper_bound=180.0 * 60.0) == -60.0
|
317
|
+
)
|
318
|
+
|
319
|
+
angle: AnglePhysics = AnglePhysics(60.0, Unit.Arcminute)
|
320
|
+
assert (
|
321
|
+
angle.in_arcminutes(lower_bound=-180.0 * 60.0, upper_bound=180.0 * 60.0) == 60.0
|
322
|
+
)
|
323
|
+
|
324
|
+
angle: AnglePhysics = AnglePhysics(-180.0 * 60.0, Unit.Arcminute)
|
325
|
+
assert angle.in_arcminutes(-180.0 * 60.0, 180.0 * 60.0) == -180.0 * 60.0
|
326
|
+
|
327
|
+
angle: AnglePhysics = AnglePhysics(180.0 * 60.0, Unit.Arcminute)
|
328
|
+
assert angle.in_arcminutes(-180.0 * 60.0, 180.0 * 60.0) == -180.0 * 60.0
|
329
|
+
|
330
|
+
|
331
|
+
def test_angle_in_arcseconds_reduction():
|
332
|
+
angle: AnglePhysics = AnglePhysics(359.0 * 3600.0, Unit.Arcsecond)
|
333
|
+
assert (
|
334
|
+
angle.in_arcseconds(lower_bound=-180.0 * 3600.0, upper_bound=180.0 * 3600.0)
|
335
|
+
== -3600.0
|
336
|
+
)
|
337
|
+
|
338
|
+
angle: AnglePhysics = AnglePhysics(3600.0, Unit.Arcsecond)
|
339
|
+
assert (
|
340
|
+
angle.in_arcseconds(lower_bound=-180.0 * 3600.0, upper_bound=180.0 * 3600.0)
|
341
|
+
== 3600.0
|
342
|
+
)
|
343
|
+
|
344
|
+
angle: AnglePhysics = AnglePhysics(-180 * 3600.0, Unit.Arcsecond)
|
345
|
+
assert angle.in_arcseconds(-180.0 * 3600.0, 180.0 * 3600.0) == -180.0 * 3600.0
|
346
|
+
|
347
|
+
angle: AnglePhysics = AnglePhysics(180.0 * 3600.0, Unit.Arcsecond)
|
348
|
+
assert angle.in_arcseconds(-180.0 * 3600.0, 180.0 * 3600.0) == -180.0 * 3600.0
|
349
|
+
|
350
|
+
|
351
|
+
def test_parse():
|
352
|
+
angle: AnglePhysics = AnglePhysics.parse(string="3.14 [rad]")
|
353
|
+
assert angle == AnglePhysics(3.14, Unit.Radian)
|
354
|
+
|
355
|
+
angle: AnglePhysics = AnglePhysics.parse(string="60 [deg]")
|
356
|
+
assert angle == AnglePhysics(60.0, Unit.Degree)
|
357
|
+
|
358
|
+
angle: AnglePhysics = AnglePhysics.parse("60 [amin]")
|
359
|
+
assert angle == AnglePhysics(60.0, Unit.Arcminute)
|
360
|
+
|
361
|
+
angle: AnglePhysics = AnglePhysics.parse("3600 [asec]")
|
362
|
+
assert angle == AnglePhysics(3600.0, Unit.Arcsecond)
|
363
|
+
|
364
|
+
|
365
|
+
def test_to_string():
|
366
|
+
angle: AnglePhysics = AnglePhysics(3.141592653589793, Unit.Radian)
|
367
|
+
assert angle.to_string() == "3.1415926535897931 [rad]"
|
368
|
+
assert angle.to_string(precision=1) == "3.1 [rad]"
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
from ostk.physics.unit import Length
|
4
|
+
from ostk.physics.unit import Time
|
5
|
+
from ostk.physics.unit import Angle
|
6
|
+
from ostk.physics.unit import Mass
|
7
|
+
from ostk.physics.unit import Derived
|
8
|
+
|
9
|
+
|
10
|
+
class TestDerived:
|
11
|
+
def test_derived_square_meter(self):
|
12
|
+
derived_unit: Derived.Unit = Derived.Unit.square_meter()
|
13
|
+
|
14
|
+
assert derived_unit is not None
|
15
|
+
assert isinstance(derived_unit, Derived.Unit)
|
16
|
+
|
17
|
+
def test_derived_cubic_meter(self):
|
18
|
+
derived_unit: Derived.Unit = Derived.Unit.cubic_meter()
|
19
|
+
|
20
|
+
assert derived_unit is not None
|
21
|
+
assert isinstance(derived_unit, Derived.Unit)
|
22
|
+
|
23
|
+
def test_derived_hertz(self):
|
24
|
+
derived_unit: Derived.Unit = Derived.Unit.hertz()
|
25
|
+
|
26
|
+
assert derived_unit is not None
|
27
|
+
assert isinstance(derived_unit, Derived.Unit)
|
28
|
+
|
29
|
+
def test_derived_watt(self):
|
30
|
+
derived_unit: Derived.Unit = Derived.Unit.watt()
|
31
|
+
|
32
|
+
assert derived_unit is not None
|
33
|
+
assert isinstance(derived_unit, Derived.Unit)
|
34
|
+
|
35
|
+
def test_derived_tesla(self):
|
36
|
+
derived_unit: Derived.Unit = Derived.Unit.tesla()
|
37
|
+
|
38
|
+
assert derived_unit is not None
|
39
|
+
assert isinstance(derived_unit, Derived.Unit)
|
40
|
+
|
41
|
+
def test_newton(self):
|
42
|
+
derived_unit: Derived.Unit = Derived.Unit.newton()
|
43
|
+
|
44
|
+
assert derived_unit is not None
|
45
|
+
assert isinstance(derived_unit, Derived.Unit)
|
46
|
+
|
47
|
+
def test_kilogram_per_second(self):
|
48
|
+
derived_unit: Derived.Unit = Derived.Unit.kilogram_per_second()
|
49
|
+
|
50
|
+
assert derived_unit is not None
|
51
|
+
assert isinstance(derived_unit, Derived.Unit)
|
52
|
+
|
53
|
+
def test_meter_per_second(self):
|
54
|
+
derived_unit: Derived.Unit = Derived.Unit.meter_per_second()
|
55
|
+
|
56
|
+
assert derived_unit is not None
|
57
|
+
assert isinstance(derived_unit, Derived.Unit)
|
58
|
+
|
59
|
+
def test_meter_per_second_squared(self):
|
60
|
+
derived_unit: Derived.Unit = Derived.Unit.meter_per_second_squared()
|
61
|
+
|
62
|
+
assert derived_unit is not None
|
63
|
+
assert isinstance(derived_unit, Derived.Unit)
|
64
|
+
|
65
|
+
def test_meter_cubed_per_second_squared(self):
|
66
|
+
derived_unit: Derived.Unit = Derived.Unit.meter_cubed_per_second_squared()
|
67
|
+
|
68
|
+
assert derived_unit is not None
|
69
|
+
assert isinstance(derived_unit, Derived.Unit)
|
70
|
+
|
71
|
+
def test_radian_per_second(self):
|
72
|
+
derived_unit: Derived.Unit = Derived.Unit.radian_per_second()
|
73
|
+
|
74
|
+
assert derived_unit is not None
|
75
|
+
assert isinstance(derived_unit, Derived.Unit)
|
76
|
+
|
77
|
+
def test_revolution_per_day(self):
|
78
|
+
derived_unit: Derived.Unit = Derived.Unit.revolution_per_day()
|
79
|
+
|
80
|
+
assert derived_unit is not None
|
81
|
+
assert isinstance(derived_unit, Derived.Unit)
|
82
|
+
|
83
|
+
def test_derived_velocity(self):
|
84
|
+
derived_unit: Derived.Unit = Derived.Unit.velocity(
|
85
|
+
Length.Unit.Meter, Time.Unit.Second
|
86
|
+
)
|
87
|
+
|
88
|
+
assert derived_unit is not None
|
89
|
+
assert isinstance(derived_unit, Derived.Unit)
|
90
|
+
|
91
|
+
def test_derived_acceleration(self):
|
92
|
+
derived_unit: Derived.Unit = Derived.Unit.acceleration(
|
93
|
+
Length.Unit.Meter, Time.Unit.Second
|
94
|
+
)
|
95
|
+
|
96
|
+
assert derived_unit is not None
|
97
|
+
assert isinstance(derived_unit, Derived.Unit)
|
98
|
+
|
99
|
+
def test_derived_angular_velocity(self):
|
100
|
+
derived_unit: Derived.Unit = Derived.Unit.angular_velocity(
|
101
|
+
Angle.Unit.Revolution, Time.Unit.Day
|
102
|
+
)
|
103
|
+
|
104
|
+
assert derived_unit is not None
|
105
|
+
assert isinstance(derived_unit, Derived.Unit)
|
106
|
+
|
107
|
+
def test_derived_gravitational_parameter(self):
|
108
|
+
derived_unit: Derived.Unit = Derived.Unit.gravitational_parameter(
|
109
|
+
Length.Unit.Meter, Time.Unit.Second
|
110
|
+
)
|
111
|
+
|
112
|
+
assert derived_unit is not None
|
113
|
+
assert isinstance(derived_unit, Derived.Unit)
|
114
|
+
|
115
|
+
def test_derived_force(self):
|
116
|
+
derived_unit: Derived.Unit = Derived.Unit.force(
|
117
|
+
Mass.Unit.Kilogram, Length.Unit.Meter, Time.Unit.Second
|
118
|
+
)
|
119
|
+
|
120
|
+
assert derived_unit is not None
|
121
|
+
assert isinstance(derived_unit, Derived.Unit)
|
122
|
+
|
123
|
+
def test_derived_mass_flow_rate(self):
|
124
|
+
derived_unit: Derived.Unit = Derived.Unit.mass_flow_rate(
|
125
|
+
Mass.Unit.Kilogram, Time.Unit.Second
|
126
|
+
)
|
127
|
+
|
128
|
+
assert derived_unit is not None
|
129
|
+
assert isinstance(derived_unit, Derived.Unit)
|
130
|
+
|
131
|
+
def test_unit_derived_unit_undefined(self):
|
132
|
+
derived_unit: Derived.Unit = Derived.Unit.undefined()
|
133
|
+
|
134
|
+
assert derived_unit is not None
|
135
|
+
assert isinstance(derived_unit, Derived.Unit)
|
136
|
+
assert derived_unit.is_defined() is False
|
137
|
+
|
138
|
+
def test_unit_derived_unit_comparators(self):
|
139
|
+
derived_unit: Derived.Unit = Derived.Unit.square_meter()
|
140
|
+
|
141
|
+
assert derived_unit == derived_unit
|
142
|
+
assert (derived_unit != derived_unit) is False
|
143
|
+
|
144
|
+
# TBI: add these tests
|
145
|
+
# def test_unit_derived_unit_is_compatible_with(self):
|
146
|
+
# pass
|
147
|
+
|
148
|
+
# def test_unit_derived_unit_to_string(self):
|
149
|
+
# pass
|
150
|
+
|
151
|
+
# def test_unit_derived_unit_get_symbol(self):
|
152
|
+
# pass
|