-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_settle_sft.py
executable file
·68 lines (55 loc) · 2.64 KB
/
test_settle_sft.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
#! /usr/bin/env python3
"""
This is Short Functional test of settle.
settle calls are done via settler.py interface module.
Test type: integration, end-to-end, positive.
Runs a limited number of settle solutions and check result
for the last one only agains expected values.
"""
from __future__ import print_function
from pySettle import settler as se
import numpy as np
def test_SFT():
print("Settle Short Functional Test (SFT)...")
try:
# initialize settle interface
settl = se.Settle()
for i in range(10):
print(settl.full(Z=0.02, X=0.5, M=0.1, F=0.1, C=0, R=11.2, Ma=1.4))
print(settl.run(Z=0.02, X=0.5, M=0.1, R=11.2, Ma=1.4))
set2 = se.Settle(F=0.5)
# having created the link with different default Flux will generate different output with the same compact call
print(settl.run(Z=0.02, X=0.5, M=0.1, R=11.2, Ma=1.4), set2.run(Z=0.02, X=0.5, M=0.1, R=11.2, Ma=1.4))
print()
# you can override the default Flux you created using the full call, this will generate the same output,
# even if you created different links with different defaults for Flux (same for C)
print(settl.full(F=0.7, C=0, Z=0.02, X=0.5, M=0.1, R=11.2, Ma=1.4), set2.full(F=0.7, C=0, Z=0.02, X=0.5, M=0.1, R=11.2, Ma=1.4))
print()
print(settl.full(Z=0.026, X=0.505, M=0.1, F=0.12, C=0, R=11.16, Ma=1.426))
print("settl.full() test - check expected result.")
res = settl.full(F=0.1, M=0.1, X=0.7, Z=0.02, C=0, R=11.2, Ma=1.4)
print(res)
# alpha,tdel, E_b
# result = np.allclose(res, [66.32432920153866, 4.630885096736736, 7.516383459074593])
# updated here with the new (corrected) alpha calculation, for
# v0.1.3 and later
# result = np.allclose(res, [43.846559833302855, 4.630885096736736, 7.516383459074593])
# and now with the removal of the recurrence time scaling, and
# scaling alpha by the redshift for the observer frame, for
# v1.3.0 and later
result = np.allclose(res, [55.209529360603085, 7.124438610364355, 7.516383459074704])
except:
raise AssertionError("Settle SFT failed - some error occurred!")
if result:
print("PASSED")
else:
print("FAILED")
raise AssertionError("Settle SFT failed - result of settler.full() not as expected!")
# this is just a simple check, without any useful infor printed.
# assert result
if __name__ == "__main__":
# introspect and run all the functions starting with 'test'
for f in dir():
if f.startswith('test'):
print(f)
globals()[f]()