File: test_prediction.py

package info (click to toggle)
dials 3.25.0%2Bdfsg3-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 20,112 kB
  • sloc: python: 134,740; cpp: 34,526; makefile: 160; sh: 142
file content (59 lines) | stat: -rw-r--r-- 1,714 bytes parent folder | download | duplicates (2)
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
from __future__ import annotations

import pytest


@pytest.fixture
def prediction():
    from dials.model.data import Prediction

    pred = Prediction()
    pred.miller_index = (1, 2, 3)
    pred.beam_vector = (4, 5, 6)
    pred.panel = 7
    pred.entering = True
    pred.position.px = (8, 9, 10)
    pred.position.mm = (11, 12, 13)
    return pred


def test_data(prediction):
    eps = 1e-7

    assert prediction.miller_index == (1, 2, 3)
    assert prediction.panel == 7
    assert prediction.entering
    assert abs(prediction.beam_vector[0] - 4) <= eps
    assert abs(prediction.beam_vector[1] - 5) <= eps
    assert abs(prediction.beam_vector[2] - 6) <= eps
    assert abs(prediction.position.px[0] - 8) <= eps
    assert abs(prediction.position.px[1] - 9) <= eps
    assert abs(prediction.position.px[2] - 10) <= eps
    assert abs(prediction.position.mm[0] - 11) <= eps
    assert abs(prediction.position.mm[1] - 12) <= eps
    assert abs(prediction.position.mm[2] - 13) <= eps


def test_equality(prediction):
    from dials.model.data import Prediction

    pred2 = Prediction(prediction)
    assert pred2 == prediction
    pred2 = Prediction(prediction)
    pred2.miller_index = (0, 0, 0)
    assert pred2 != prediction
    pred2 = Prediction(prediction)
    pred2.beam_vector = (0, 0, 0)
    assert pred2 != prediction
    pred2 = Prediction(prediction)
    pred2.panel = 0
    assert pred2 != prediction
    pred2 = Prediction(prediction)
    pred2.entering = False
    assert pred2 != prediction
    pred2 = Prediction(prediction)
    pred2.position.px = (0, 0, 0)
    assert pred2 != prediction
    pred2 = Prediction(prediction)
    pred2.position.mm = (0, 0, 0)
    assert pred2 != prediction