File: test_refine_error_model.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 (46 lines) | stat: -rw-r--r-- 1,436 bytes parent folder | download
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
from __future__ import annotations

import json
import shutil
import subprocess

import pytest


@pytest.mark.parametrize("grouping", ["combined", "individual", "grouped"])
def test_standalone_error_model_refinement_on_scaled_data(
    dials_data, tmp_path, grouping
):
    location = dials_data("l_cysteine_4_sweeps_scaled", pathlib=True)
    refls = location / "scaled_20_25.refl"
    expts = location / "scaled_20_25.expt"

    # Use a range of options, some default.
    command = [
        shutil.which("dials.refine_error_model"),
        refls,
        expts,
        "json=error_model.json",
        "html=error_model.html",
        "intensity_choice=combine",
        "combine.Imid=250",
        "basic.minimisation=individual",
        f"grouping={grouping}",
    ]
    if grouping == "grouped":
        command.append("error_model_group='0'")
        command.append("error_model_group='1'")

    result = subprocess.run(command, cwd=tmp_path, capture_output=True)
    assert not result.returncode and not result.stderr
    assert tmp_path.joinpath("error_model.html").is_file()
    assert tmp_path.joinpath("error_model.json").is_file()
    with open(tmp_path.joinpath("error_model.json")) as f:
        d = json.load(f)
    n_models = sum(
        "normal_distribution_plot" in k for k in d["error_model_plots"].keys()
    )
    if grouping == "combined":
        assert n_models == 1
    else:
        assert n_models == 2