Esempio n. 1
0
def test_params_diff_markdown_empty():
    assert _show_diff({}, markdown=True) == textwrap.dedent(
        """\
        | Path   | Param   | Old   | New   |
        |--------|---------|-------|-------|
        """
    )
Esempio n. 2
0
def test_params_diff_markdown():
    assert _show_diff(
        {
            "params.yaml": {
                "x.b": {
                    "old": 5,
                    "new": 6
                },
                "a.d.e": {
                    "old": None,
                    "new": 4
                },
                "a.b.c": {
                    "old": 1,
                    "new": None
                },
            }
        },
        markdown=True,
    ) == textwrap.dedent("""\
        | Path        | Param   | Old   | New   |
        |-------------|---------|-------|-------|
        | params.yaml | a.b.c   | 1     | —     |
        | params.yaml | a.d.e   | —     | 4     |
        | params.yaml | x.b     | 5     | 6     |
        """)
Esempio n. 3
0
def test_params_diff_list():
    assert _show_diff({"params.yaml": {
        "a.b.c": {
            "old": 1,
            "new": [2, 3]
        }
    }}) == ("   Path       Param   Old    New  \n"
            "params.yaml   a.b.c   1     [2, 3]")
Esempio n. 4
0
def test_params_diff_changed():
    assert _show_diff({"params.yaml": {
        "a.b.c": {
            "old": 1,
            "new": 2
        }
    }}) == ("   Path       Param   Old   New\n"
            "params.yaml   a.b.c   1     2  ")
Esempio n. 5
0
def test_params_diff_new():
    assert _show_diff({"params.yaml": {
        "a.b.d": {
            "old": None,
            "new": "new"
        }
    }}) == ("   Path       Param   Old    New\n"
            "params.yaml   a.b.d   None   new")
Esempio n. 6
0
def test_params_diff_prec():
    assert _show_diff(
        {"params.yaml": {"train.lr": {"old": 0.0042, "new": 0.0043}}}
    ) == textwrap.dedent(
        """\
        Path         Param     Old     New
        params.yaml  train.lr  0.0042  0.0043"""
    )
Esempio n. 7
0
def test_params_diff_deleted():
    assert _show_diff(
        {"params.yaml": {"a.b.d": {"old": "old", "new": None}}}
    ) == textwrap.dedent(
        """\
        Path         Param    Old    New
        params.yaml  a.b.d    old    None"""
    )
Esempio n. 8
0
def test_params_diff_new():
    assert _show_diff(
        {"params.yaml": {"a.b.d": {"old": None, "new": "new"}}}
    ) == textwrap.dedent(
        """\
        Path         Param    Old    New
        params.yaml  a.b.d    None   new"""
    )
Esempio n. 9
0
def test_params_diff_unchanged():
    assert _show_diff(
        {"params.yaml": {"a.b.d": {"old": "old", "new": "new"}}}
    ) == textwrap.dedent(
        """\
        Path         Param    Old    New
        params.yaml  a.b.d    old    new"""
    )
Esempio n. 10
0
def test_params_diff_list():
    assert _show_diff(
        {"params.yaml": {"a.b.c": {"old": 1, "new": [2, 3]}}}
    ) == textwrap.dedent(
        """\
        Path         Param    Old    New
        params.yaml  a.b.c    1      [2, 3]"""
    )
Esempio n. 11
0
def test_params_diff_changed():
    assert _show_diff(
        {"params.yaml": {"a.b.c": {"old": 1, "new": 2}}}
    ) == textwrap.dedent(
        """\
        Path         Param    Old    New
        params.yaml  a.b.c    1      2"""
    )
Esempio n. 12
0
def test_params_diff_deleted():
    assert _show_diff({"params.yaml": {
        "a.b.d": {
            "old": "old",
            "new": None
        }
    }}) == ("   Path       Param   Old   New \n"
            "params.yaml   a.b.d   old   None")
Esempio n. 13
0
def test_params_diff_unchanged():
    assert _show_diff({"params.yaml": {
        "a.b.d": {
            "old": "old",
            "new": "new"
        }
    }}) == ("   Path       Param   Old   New\n"
            "params.yaml   a.b.d   old   new")
Esempio n. 14
0
def test_params_diff_prec():
    assert _show_diff(
        {"params.yaml": {
            "train.lr": {
                "old": 0.0042,
                "new": 0.0043
            }
        }}) == ("   Path        Param      Old      New  \n"
                "params.yaml   train.lr   0.0042   0.0043")
Esempio n. 15
0
def test_params_diff_sorted():
    assert _show_diff(
        {
            "params.yaml": {
                "x.b": {"old": 5, "new": 6},
                "a.d.e": {"old": 3, "new": 4},
                "a.b.c": {"old": 1, "new": 2},
            }
        }
    ) == textwrap.dedent(
        """\
        Path         Param    Old    New
        params.yaml  a.b.c    1      2
        params.yaml  a.d.e    3      4
        params.yaml  x.b      5      6"""
    )
Esempio n. 16
0
def test_params_diff_no_path():
    assert _show_diff(
        {
            "params.yaml": {
                "x.b": {"old": 5, "new": 6},
                "a.d.e": {"old": 3, "new": 4},
                "a.b.c": {"old": 1, "new": 2},
            }
        },
        no_path=True,
    ) == textwrap.dedent(
        """\
        Param    Old    New
        a.b.c    1      2
        a.d.e    3      4
        x.b      5      6"""
    )
Esempio n. 17
0
def test_params_diff_sorted():
    assert _show_diff({
        "params.yaml": {
            "x.b": {
                "old": 5,
                "new": 6
            },
            "a.d.e": {
                "old": 3,
                "new": 4
            },
            "a.b.c": {
                "old": 1,
                "new": 2
            },
        }
    }) == ("   Path       Param   Old   New\n"
           "params.yaml   a.b.c   1     2  \n"
           "params.yaml   a.d.e   3     4  \n"
           "params.yaml   x.b     5     6  ")
Esempio n. 18
0
def test_params_diff_no_changes():
    assert _show_diff({}) == ""