-
Notifications
You must be signed in to change notification settings - Fork 24
/
test_legacy_export_import.py
42 lines (34 loc) · 1.12 KB
/
test_legacy_export_import.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
import phoebe
import numpy as np
def test_reimport(filename=None):
if filename:
b = phoebe.from_legacy(filename)
else:
b = phoebe.default_binary()
b.add_compute(kind='legacy')
b.export_legacy('test.legacy')
b2 = phoebe.from_legacy('test.legacy')
# check to see if datasets are attached and the right number
Nlcs = len(b.get_dataset(kind='lc').datasets)
Nlcs2 = len(b2.get_dataset(kind='lc').datasets)
Nrvs = len(b.get_dataset(kind='rv').datasets)
Nrvs2 = len(b2.get_dataset(kind='rv').datasets)
# must be equal
assert Nlcs == Nlcs2
assert 2*Nrvs == Nrvs2
# check to make sure parameters are the same
pars = b.filter()
pars2 = b.filter()
# checking parameters
for x in range(len(pars)):
val1 = pars[x].value
val2 = pars2[x].value
if pars[x].qualifier not in ['times', 'fluxes', 'sigmas', 'rvs']:
try:
assert val1 == val2
except:
assert np.all(val1 == val2)
if __name__ == '__main__':
filename = 'default.phoebe'
test_reimport()
test_reimport(filename)