43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
import pytest
|
|
import os
|
|
import numpy as np
|
|
from cristallina.utils import ROI, print_run_info, heuristic_extract_pgroup, gauss, find_nearest, xray_transmission
|
|
|
|
__author__ = "Alexander Steppke"
|
|
|
|
def test_print(capsys):
|
|
|
|
print_run_info(247)
|
|
captured = capsys.readouterr()
|
|
assert "15453208940" in captured.out
|
|
assert "LiTbF4_rocking" in captured.out
|
|
|
|
|
|
|
|
def test_ROI():
|
|
"""API Tests"""
|
|
r = ROI(left=1, right=2, top=4, bottom=2)
|
|
|
|
assert r.width == 1
|
|
assert r.height == 2
|
|
|
|
|
|
def test_extract_pgroup():
|
|
os.chdir("/sf/cristallina/data/p19739")
|
|
assert heuristic_extract_pgroup() == '19739'
|
|
|
|
def test_gauss():
|
|
# Test a random Gauss value and check whether the value didn't change in time
|
|
assert gauss(1.5,2.7,7,4.33,3) == 7.186044070987355
|
|
|
|
def test_find_nearest():
|
|
# Make an array of 1 to 100 and check that the nearest index is the value
|
|
a = np.linspace(0,99,100)
|
|
assert find_nearest(a,10.1) == 10
|
|
|
|
def test_xray_transmission():
|
|
T = xray_transmission(9000,100e-6,material='Si')
|
|
assert T == 0.342385039732607
|
|
|
|
|