[go: up one dir, main page]

File: test_tabulate.py

package info (click to toggle)
iminuit 2.30.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,660 kB
  • sloc: cpp: 14,591; python: 11,177; makefile: 11; sh: 5
file content (39 lines) | stat: -rw-r--r-- 931 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
from iminuit import Minuit
import pytest

tab = pytest.importorskip("tabulate")


def framed(s):
    return "\n" + str(s) + "\n"


def test_params():
    m = Minuit(lambda x, y: x**2 + (y / 2) ** 2 + 1, x=0, y=0)
    m.limits["y"] = (-1, 1)
    m.fixed["x"] = True
    m.migrad()
    m.minos()
    assert (
        framed(tab.tabulate(*m.params.to_table()))
        == """
  pos  name      value    error  error-    error+    limit-    limit+    fixed
-----  ------  -------  -------  --------  --------  --------  --------  -------
    0  x             0      0.1                                          yes
    1  y             0      1.5  -1.0      1.0       -1.0      1.0
"""
    )


def test_matrix():
    m = Minuit(lambda x, y: x**2 + (y / 2) ** 2 + 1, x=0, y=0)
    m.migrad()
    assert (
        framed(tab.tabulate(*m.covariance.to_table()))
        == """
      x    y
--  ---  ---
x     1    0
y     0    4
"""
    )