forked from open-atmos/PyPartMC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_util.py
70 lines (51 loc) · 1.59 KB
/
test_util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
####################################################################################################
# This file is a part of PyPartMC licensed under the GNU General Public License v3 (LICENSE file) #
# Copyright (C) 2022 University of Illinois Urbana-Champaign #
# Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors #
####################################################################################################
import numpy as np
import PyPartMC as ppmc
class TestUtil:
@staticmethod
def test_pow2_above():
# arrange
arg = 13
# act
pow2 = ppmc.pow2_above(arg)
# assert
assert pow2 == 16
@staticmethod
def test_deg2rad():
pass
@staticmethod
def test_sphere_vol2rad():
# arrange
arg = (4 / 3) * np.pi * (1e-6) ** 3
# act
rad = ppmc.sphere_vol2rad(arg)
# assert
np.testing.assert_almost_equal(1e-6, rad)
@staticmethod
def test_rad2diam():
# arrange
arg = 0.5e-6
# act
diam = ppmc.rad2diam(arg)
# assert
assert diam == 2 * arg
@staticmethod
def test_sphere_rad2vol():
# arrange
arg = 1e-6
# act
vol = ppmc.sphere_rad2vol(arg)
# assert
np.testing.assert_almost_equal(vol, (4 / 3) * np.pi * (arg) ** 3)
@staticmethod
def test_diam2rad():
# arrange
arg = 1e-6
# act
rad = ppmc.diam2rad(arg)
# assert
assert rad == arg / 2