-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_interpolation.py
53 lines (40 loc) · 1.52 KB
/
test_interpolation.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
import os
import numpy as np
import pytest
from interpolation import read_model
from interpolation import interpolator
from interpolation import save_model
def test_read_model():
fname = 'models/kurucz95/p00/5750g45.p00.gz'
model = read_model(fname)
assert isinstance(model, np.ndarray)
assert model.shape[0] > model.shape[1]
with pytest.raises(IOError):
read_model('wrong-path')
def test_interpolator_kurucz95():
params = (5777, 4.0, 0.04, 1.00)
m, p = interpolator(params, save=False, atmtype='kurucz95', result=True)
assert len(p) == len(params)
assert list(p) == list(params)
assert isinstance(m, np.ndarray)
assert m.shape[0] > m.shape[1]
with pytest.raises(ValueError):
m, p = interpolator('params', save=False, atmtype='kurucz95', result=True)
res = interpolator(params, save=False, atmtype='kurucz95', result=False)
assert res is None
def test_interpolator_save():
params = (5777, 4.0, 0.04, 1.00)
interpolator(params)
assert os.path.isfile('out.atm')
def test_interpolator_wrong_model():
params = (5777, 4.0, 0.04, 1.00)
with pytest.raises(NotImplementedError):
interpolator(params, atmtype='wrong')
def test_save_model():
params = (5777, 4.0, 0.04, 1.00)
m, p = interpolator(params, save=False, atmtype='kurucz95', result=True)
save_model(m, p, fout='test.atm')
assert os.path.isfile('test.atm')
os.remove('test.atm')
with pytest.raises(NameError):
save_model(m, p, type='wrong', fout='test.atm')