-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_peaks.py
More file actions
54 lines (43 loc) · 1.4 KB
/
test_peaks.py
File metadata and controls
54 lines (43 loc) · 1.4 KB
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
import urllib.request
import pytest
import scipp as sc
from ess.diffraction.peaks import dspacing_peaks_from_cif
def _cifdb_is_reachable(timeout=5):
try:
req = urllib.request.Request('http://cod.ibt.lt', method="HEAD")
with urllib.request.urlopen(req, timeout=timeout): # noqa: S310
return True
except Exception:
return False
@pytest.mark.skipif(
not _cifdb_is_reachable(), reason='The CIF database can not be reached.'
)
def test_retreived_peak_list_has_expected_units():
d = dspacing_peaks_from_cif(
'codid::9011998',
sc.scalar(50, unit='barn'),
)
assert d.coords['dspacing'].unit == 'angstrom'
assert d.unit == 'barn'
@pytest.mark.skipif(
not _cifdb_is_reachable(), reason='The CIF database can not be reached.'
)
def test_intensity_threshold_is_taken_into_account():
d = dspacing_peaks_from_cif(
'codid::9011998',
sc.scalar(50, unit='barn'),
)
assert len(d) > 0
d = dspacing_peaks_from_cif(
'codid::9011998',
sc.scalar(50, unit='Mbarn'),
)
assert len(d) == 0
@pytest.mark.skipif(
not _cifdb_is_reachable(), reason='The CIF database can not be reached.'
)
def test_retreived_peak_list_with_temperature_kwarg():
d = dspacing_peaks_from_cif(
'codid::9011998', sc.scalar(50, unit='barn'), uiso_temperature=300
)
assert d.coords['uiso_temperature'] == 300