h2lib-tests 13.0.604__py3-none-any.whl → 13.0.605__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- h2lib_tests/test_calc.py +19 -7
- h2lib_tests/test_files/__init__.py +1 -1
- h2lib_tests/test_h2lib.py +13 -8
- h2lib_tests/test_h2rotor.py +10 -11
- {h2lib_tests-13.0.604.dist-info → h2lib_tests-13.0.605.dist-info}/METADATA +2 -2
- {h2lib_tests-13.0.604.dist-info → h2lib_tests-13.0.605.dist-info}/RECORD +8 -8
- {h2lib_tests-13.0.604.dist-info → h2lib_tests-13.0.605.dist-info}/WHEEL +0 -0
- {h2lib_tests-13.0.604.dist-info → h2lib_tests-13.0.605.dist-info}/top_level.txt +0 -0
h2lib_tests/test_calc.py
CHANGED
@@ -31,14 +31,13 @@ def test_hdf5(h2):
|
|
31
31
|
|
32
32
|
|
33
33
|
def test_two_in_same_process():
|
34
|
+
s = 'already in use in current process'
|
34
35
|
if os.name == 'posix':
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
h2_1 = H2Lib(subprocess=False)
|
41
|
-
h2_2 = H2Lib(subprocess=False)
|
36
|
+
s += '|cannot open shared object file'
|
37
|
+
with pytest.raises(Exception, match='already in use in current process|cannot open shared object file'):
|
38
|
+
with H2Lib(subprocess=False) as h2_1:
|
39
|
+
with H2Lib(subprocess=False) as h2_2:
|
40
|
+
pass
|
42
41
|
|
43
42
|
|
44
43
|
def test_state(h2):
|
@@ -67,3 +66,16 @@ def test_hidden_functions_is_hidden():
|
|
67
66
|
# cannot hide function names
|
68
67
|
assert 'hidden_c_function' in os.popen(f"nm {os.path.dirname(h2lib.__file__)}/HAWC2Lib.so").read()
|
69
68
|
assert 'hidden_function' in os.popen(f"nm {os.path.dirname(h2lib.__file__)}/HAWC2Lib.so").read()
|
69
|
+
|
70
|
+
|
71
|
+
def test_myfunction_and_mysubroutine(h2):
|
72
|
+
|
73
|
+
args, res = h2.myfunction(1, 2., restype=np.float64)
|
74
|
+
print(args, res)
|
75
|
+
assert args == [1, 2.]
|
76
|
+
assert res == 3.
|
77
|
+
|
78
|
+
s = "hello" + " " * 20
|
79
|
+
args = h2.mysubroutine(s, np.array([3., 4]))[0]
|
80
|
+
assert args[0].strip() == 'world'
|
81
|
+
np.testing.assert_array_equal(args[1], [4, 5])
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import os
|
2
|
-
tfp = os.path.dirname
|
2
|
+
tfp = os.path.dirname(__file__) + "/"
|
h2lib_tests/test_h2lib.py
CHANGED
@@ -34,15 +34,18 @@ def test_sensors():
|
|
34
34
|
model_path = tfp + "minimal/"
|
35
35
|
htc = HTCFile(model_path + 'htc/minimal.htc')
|
36
36
|
htc.output.add_sensor("general", 'variable', [1, 5, 'mysensor', 'myunit', 'mydesc'])
|
37
|
+
htc.output.add_sensor("wind", 'free_wind', [1, 5, 0, -119])
|
38
|
+
htc.wind.shear_format = 1, 0
|
39
|
+
|
37
40
|
htc.set_name('tmp')
|
38
41
|
htc.save()
|
39
42
|
h2.init('htc/tmp.htc', model_path)
|
40
43
|
i1 = h2.add_sensor('wind free_wind 1 0 0 -119;') # adds three sensors
|
41
|
-
assert i1 == 3
|
44
|
+
assert i1 == [1, 2, 3]
|
42
45
|
i2 = h2.add_sensor('general step 0.5 1 2;')
|
43
|
-
assert i2 == 4
|
46
|
+
assert i2 == [4]
|
44
47
|
i3 = h2.add_sensor('general variable 1 5 myname myunit mydesc;')
|
45
|
-
assert i3 == 5
|
48
|
+
assert i3 == [5]
|
46
49
|
t = h2.step()
|
47
50
|
assert h2.get_sensor_info(1) == ['WSP gl. coo.,Vx', 'm/s',
|
48
51
|
'Free wind speed Vx, gl. coo, of gl. pos 0.00, 0.00,-119.00']
|
@@ -50,12 +53,13 @@ def test_sensors():
|
|
50
53
|
'Free wind speed Vy, gl. coo, of gl. pos 0.00, 0.00,-119.00']
|
51
54
|
assert h2.get_sensor_info(3) == ['WSP gl. coo.,Vz', 'm/s',
|
52
55
|
'Free wind speed Vz, gl. coo, of gl. pos 0.00, 0.00,-119.00']
|
56
|
+
assert [n for n, u, d in h2.get_sensor_info(i1)] == ['WSP gl. coo.,Vx', 'WSP gl. coo.,Vy', 'WSP gl. coo.,Vz']
|
53
57
|
assert h2.get_sensor_info(4) == ['Step', '-', 'Step value']
|
54
58
|
assert h2.get_sensor_info(5) == ['myname', 'myunit', 'mydesc']
|
55
59
|
|
56
60
|
r = []
|
57
61
|
for _ in range(10):
|
58
|
-
r.append([t, h2.
|
62
|
+
r.append([t, h2.get_sensor_values(4), h2.get_sensor_values(5)] + h2.get_sensor_values(i1).tolist())
|
59
63
|
if t == 0.6:
|
60
64
|
h2.set_variable_sensor_value(1, 2)
|
61
65
|
t = h2.step()
|
@@ -64,6 +68,7 @@ def test_sensors():
|
|
64
68
|
npt.assert_array_equal(r[:, 2], np.where(r[:, 0] >= .7, 2, 5.))
|
65
69
|
time, data, _ = gtsdf.load(h2.model_path + 'res/tmp.hdf5')
|
66
70
|
npt.assert_array_equal(data[:, 0], np.where(time >= .7, 2, 5.))
|
71
|
+
npt.assert_array_equal(data[:, 1:4], r[:, 3:6])
|
67
72
|
|
68
73
|
|
69
74
|
def test_set_windspeed_uvw():
|
@@ -205,10 +210,10 @@ def test_mann_turb_small_buffer():
|
|
205
210
|
npt.assert_array_almost_equal(mtf_uvw, h2l_uvw)
|
206
211
|
|
207
212
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
213
|
+
def test_context_manager():
|
214
|
+
if os.name == 'nt':
|
215
|
+
with H2Lib(subprocess=False) as h2:
|
216
|
+
h2.get_version()
|
212
217
|
|
213
218
|
|
214
219
|
def test_parallel():
|
h2lib_tests/test_h2rotor.py
CHANGED
@@ -70,7 +70,7 @@ def test_rotor_orientation_multi_instance():
|
|
70
70
|
dtu10.save()
|
71
71
|
with MultiH2Lib(2) as mh2:
|
72
72
|
mh2.read_input(['htc/tmp_5_0.htc', 'htc/tmp_6_10.htc'], model_path=tfp + "DTU_10_MW")
|
73
|
-
#h2.suppress_output = False
|
73
|
+
# h2.suppress_output = False
|
74
74
|
s_id = mh2.add_sensor('aero power')[0]
|
75
75
|
mh2.init()
|
76
76
|
yaw, tilt, _ = zip(*mh2.get_rotor_orientation())
|
@@ -83,7 +83,7 @@ def test_rotor_orientation_multi_instance():
|
|
83
83
|
res = []
|
84
84
|
for t in np.arange(0, 2.5, .01):
|
85
85
|
h2.run(t)
|
86
|
-
res.append([h2.get_rotor_orientation(deg=True)[2], h2.
|
86
|
+
res.append([h2.get_rotor_orientation(deg=True)[2], h2.get_sensor_values(s_id)] +
|
87
87
|
h2.get_rotor_position().tolist())
|
88
88
|
|
89
89
|
data = gtsdf.load(h2.model_path + '/res/tmp_5_0.hdf5')[1]
|
@@ -112,10 +112,10 @@ def test_aerosections():
|
|
112
112
|
h2 = get_h2()
|
113
113
|
h2.suppress_output = False
|
114
114
|
# blade 1, global coo, r>30
|
115
|
-
pos_ids = [h2.add_sensor(f'aero position 3 1 {xyz} 30') for xyz in [1, 2, 3]]
|
116
|
-
wsp_ids = [h2.add_sensor(f'aero windspeed 3 1 {xyz} 30') for xyz in [1, 2, 3]]
|
117
|
-
frc_ids = [h2.add_sensor(f'aero secforce 1 {xyz} 30 3') for xyz in [1, 2, 3]]
|
118
|
-
mom_ids = [h2.add_sensor(f'aero secmoment 1 {xyz} 30 3') for xyz in [1, 2, 3]]
|
115
|
+
pos_ids = [h2.add_sensor(f'aero position 3 1 {xyz} 30')[0] for xyz in [1, 2, 3]]
|
116
|
+
wsp_ids = [h2.add_sensor(f'aero windspeed 3 1 {xyz} 30')[0] for xyz in [1, 2, 3]]
|
117
|
+
frc_ids = [h2.add_sensor(f'aero secforce 1 {xyz} 30 3')[0] for xyz in [1, 2, 3]]
|
118
|
+
mom_ids = [h2.add_sensor(f'aero secmoment 1 {xyz} 30 3')[0] for xyz in [1, 2, 3]]
|
119
119
|
h2.init()
|
120
120
|
|
121
121
|
a = h2.get_aerosections_position()
|
@@ -131,20 +131,19 @@ def test_aerosections():
|
|
131
131
|
i = np.searchsorted(r, 30)
|
132
132
|
|
133
133
|
h2.step()
|
134
|
-
name, unit, desc = h2.get_sensor_info(pos_ids)
|
134
|
+
name, unit, desc = h2.get_sensor_info(pos_ids[-1])
|
135
135
|
assert str(np.round(r[i], 2)) in desc
|
136
136
|
assert str(np.round(r[i], 1)) in name
|
137
137
|
assert unit == 'm'
|
138
138
|
|
139
139
|
a = h2.get_aerosections_position()
|
140
|
-
npt.assert_array_almost_equal(a[0, i], [h2.
|
140
|
+
npt.assert_array_almost_equal(a[0, i], [h2.get_sensor_values(id) for id in pos_ids])
|
141
141
|
uvw = a * 0
|
142
142
|
uvw[:, :, 0] = 6
|
143
143
|
uvw[0, i, 0] = 12
|
144
144
|
h2.run(3)
|
145
|
-
npt.assert_array_equal(
|
146
|
-
npt.assert_array_almost_equal(
|
147
|
-
h2.get_aerosections_forces()[0, i] / 1000)
|
145
|
+
npt.assert_array_equal(h2.get_sensor_values(wsp_ids), [0, 6, 0])
|
146
|
+
npt.assert_array_almost_equal(h2.get_sensor_values(frc_ids), h2.get_aerosections_forces()[0, i] / 1000)
|
148
147
|
|
149
148
|
frc_before = h2.get_aerosections_forces()
|
150
149
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: h2lib-tests
|
3
|
-
Version: 13.0.
|
4
|
-
Summary: Tests and test_files for test h2lib (13.0.6+
|
3
|
+
Version: 13.0.605
|
4
|
+
Summary: Tests and test_files for test h2lib (13.0.6+8-g2148dea)
|
5
5
|
Download-URL:
|
6
6
|
Author: Mads M Pedersen
|
7
7
|
Author-email:
|
@@ -1,11 +1,11 @@
|
|
1
1
|
h2lib_tests/__init__.py,sha256=VjSqfGg8BzdmSjfSFhJh4hZbYZ_cME7xp9EWFKHQphA,61
|
2
2
|
h2lib_tests/dtu10mw.py,sha256=a7SXfyDwDQPastYKb5CgghOQcYfgO1eTwGrd-H3Enok,4374
|
3
|
-
h2lib_tests/test_calc.py,sha256=
|
3
|
+
h2lib_tests/test_calc.py,sha256=D5JC2L3UOvJa9gidfxswu7ZhcbEtgP6EhkwKK87WIug,2175
|
4
4
|
h2lib_tests/test_ellipsys_couplings.py,sha256=qVgEsn7iJq6dK0S3n8iY15rU8SfpcH2mav4Ktybhnz8,1399
|
5
|
-
h2lib_tests/test_h2lib.py,sha256=
|
6
|
-
h2lib_tests/test_h2rotor.py,sha256=
|
5
|
+
h2lib_tests/test_h2lib.py,sha256=MzQzQbgWe0IKmQVxXN6obihDp9gJiE5q3Em--q5htPU,10315
|
6
|
+
h2lib_tests/test_h2rotor.py,sha256=2XZg7-FK0-NO9hTPMjjpgxBjRPxdoDWa8swfJjO8kKk,5864
|
7
7
|
h2lib_tests/utils.py,sha256=Kj1WxegDt0SR-l9jNKnTIDx9QczoYi-7LUnWSSDcTKM,2859
|
8
|
-
h2lib_tests/test_files/__init__.py,sha256=
|
8
|
+
h2lib_tests/test_files/__init__.py,sha256=9e6ZUPb42e0wf2E1rutdcTM8hROcWFRVPXtZriU3ySw,50
|
9
9
|
h2lib_tests/test_files/DTU_10_MW/control/dtu_we_controller.dll,sha256=C5T_CuAFtIuDgCXSYAoNu24yKPwj2nWOeORacJbLN9s,1134592
|
10
10
|
h2lib_tests/test_files/DTU_10_MW/control/dtu_we_controller.so,sha256=FTQadOxTulwqwj-31emRlt85V0EkVYyKp8aNRb3c7Lc,370984
|
11
11
|
h2lib_tests/test_files/DTU_10_MW/control/dtu_we_controller_64.dll,sha256=n87Q3_xLZhNVHVf-4rBV4jmXGyIIY9nN9clWgCuNKMM,1386496
|
@@ -75,7 +75,7 @@ h2lib_tests/test_files/minimal/res/minimal_mann_turb.hdf5,sha256=Q3cs3bZyplZjBpo
|
|
75
75
|
h2lib_tests/test_files/minimal/turb/hawc2_mann_l33.6_ae0.1000_g3.9_h0_512xd32xd16_2.000x3.00x4.00_s0001_u,sha256=byiorJmXDL6uKFbyfXthHTjJdm6ELvLR2lS202KrhRI,1048576
|
76
76
|
h2lib_tests/test_files/minimal/turb/hawc2_mann_l33.6_ae0.1000_g3.9_h0_512xd32xd16_2.000x3.00x4.00_s0001_v,sha256=cxK5Rfgfm3gyJsEYi_KlmYY8DIIl_G0aizN2jt18Glc,1048576
|
77
77
|
h2lib_tests/test_files/minimal/turb/hawc2_mann_l33.6_ae0.1000_g3.9_h0_512xd32xd16_2.000x3.00x4.00_s0001_w,sha256=xs61jAwhP3fIR1P5Oa8ovEt2baLoF8uCNs6pKIT8L4o,1048576
|
78
|
-
h2lib_tests-13.0.
|
79
|
-
h2lib_tests-13.0.
|
80
|
-
h2lib_tests-13.0.
|
81
|
-
h2lib_tests-13.0.
|
78
|
+
h2lib_tests-13.0.605.dist-info/METADATA,sha256=JnREx5_zQvTU-kZR84zd5R9oZi_PW4bq645S4oKmRRo,360
|
79
|
+
h2lib_tests-13.0.605.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
80
|
+
h2lib_tests-13.0.605.dist-info/top_level.txt,sha256=WufAL3LO35YJBhWg1AfgTjSld-6l_WuRkXAkNKczUrM,12
|
81
|
+
h2lib_tests-13.0.605.dist-info/RECORD,,
|
File without changes
|
File without changes
|