Beispiel #1
0
def test_auto_size_negative_int_bits():
    pytest.skip()
    a = 0.00390623013197
    b = Sfix.auto_size(a, 18)
    np.isclose(b.val, a)
    assert b.left == -7
    assert b.right == -24

    a = 0.45
    b = Sfix.auto_size(a, 18)
    np.isclose(b.val, a)
    assert b.left == -2
    assert b.right == -19

    a = 0.25
    b = Sfix.auto_size(a, 18)
    np.isclose(b.val, a)
    assert b.left == -1
    assert b.right == -18

    a = -0.000000025124
    b = Sfix.auto_size(a, 18)
    np.isclose(b.val, a)
    assert b.left == -25
    assert b.right == -42
Beispiel #2
0
def test_auto_size_bits_list():
    pytest.skip()
    a = [0.5, 1.2, 3.2]
    b = Sfix.auto_size(a, 18)
    for x, y in zip(a, b):
        np.isclose(y.val, x)
        assert y.left == 2
        assert y.right == -15

    a = [np.arctan(2**-i) for i in range(8)]
    b = Sfix.auto_size(a, 18)
    for x, y in zip(a, b):
        np.isclose(y.val, x)
        assert y.left == 0
        assert y.right == -17

    a = [np.arctan(2**-i) for i in range(8, 12)]
    b = Sfix.auto_size(a, 18)
    for x, y in zip(a, b):
        np.isclose(y.val, x)
        assert y.left == -8
        assert y.right == -25