示例#1
0
def test_MError():
    me = util.MError(
        1,
        "x",
        0.1,
        0.2,
        True,
        True,
        True,
        False,
        False,
        False,
        False,
        False,
        False,
        11,
        0.7,
    )

    assert repr(me) == (
        "<MError number=1 name='x' lower=0.1 upper=0.2 is_valid=True lower_valid=True "
        "upper_valid=True at_lower_limit=False at_upper_limit=False "
        "at_lower_max_fcn=False at_upper_max_fcn=False lower_new_min=False "
        "upper_new_min=False nfcn=11 min=0.7>")

    assert me == util.MError(
        1,
        "x",
        0.1,
        0.2,
        True,
        True,
        True,
        False,
        False,
        False,
        False,
        False,
        False,
        11,
        0.7,
    )

    assert me != util.MError(
        1,
        "x",
        0.1,
        0.2,
        True,
        True,
        True,
        False,
        False,
        False,
        False,
        False,
        False,
        11,
        0.8,
    )
示例#2
0
def test_MError():
    keys = "name is_valid lower upper lower_valid upper_valid at_lower_limit at_upper_limit at_lower_max_fcn at_upper_max_fcn lower_new_min upper_new_min nfcn min".split(
    )  # noqa: E501
    values = (
        "Foo",
        True,
        0.1,
        1.2,
        True,
        True,
        False,
        False,
        False,
        False,
        0.1,
        1.2,
        42,
        0.2,
    )

    m = util.MError(*values)

    assert m.keys() == tuple(keys)
    assert m.values() == values
    assert m.name == "Foo"
    assert m["name"] == "Foo"
示例#3
0
def test_MErrors():
    mes = util.MErrors(x=util.MError(
        1,
        "x",
        0.1,
        0.2,
        True,
        True,
        True,
        False,
        False,
        False,
        False,
        False,
        False,
        11,
        0.7,
    ))

    assert repr(mes) == f"<MErrors\n  {mes['x']!r}\n>"
示例#4
0
def test_MError():
    me = util.MError(
        1,
        "x",
        0.1,
        0.2,
        True,
        True,
        True,
        False,
        False,
        False,
        False,
        False,
        False,
        11,
        0.7,
    )

    with PrintAssert("<MError ...>") as pr:
        me._repr_pretty_(pr, True)

    with PrintAssert(tx.merrors({None: me})) as pr:
        me._repr_pretty_(pr, False)
示例#5
0
def test_MErrors():
    mes = util.MErrors(x=util.MError(
        1,
        "x",
        0.1,
        0.2,
        True,
        True,
        True,
        False,
        False,
        False,
        False,
        False,
        False,
        11,
        0.7,
    ))

    with PrintAssert("<MErrors ...>") as pr:
        mes._repr_pretty_(pr, True)

    with PrintAssert(tx.merrors(mes)) as pr:
        mes._repr_pretty_(pr, False)