示例#1
0
文件: to_polar.py 项目: gasparka/pyha
def test_overflow_condition():
    import pytest
    pytest.xfail('abs would be > 1 (1.84)')
    inputs = [0.92j + 0.92j]
    expect = [np.abs(inputs), np.angle(inputs) / np.pi]
    dut = ToPolar()
    sim_out = simulate(dut, inputs)
    assert sims_close(sim_out, expect)
示例#2
0
def test_simple_one():
    dut = CRC16(init_galois=0x48f9, xor=0x1021)
    inp = hex_to_bool_list('8dfc4ff97dffdb11ff438aee29243910365e908970b9475e')
    reload = [False] * len(inp)

    sims = simulate(dut, inp, reload)
    assert sims['MODEL_PYHA'][-1] == 0  # CRC was correct
    assert sims_close(sims)
示例#3
0
文件: to_polar.py 项目: gasparka/pyha
def test_angle_randoms():
    np.random.seed(123)
    inputs = (np.random.rand(1024) * 2 - 1) + ((np.random.rand(1024) * 2 - 1) * 1j)
    inputs *= 0.25
    expect = np.angle(inputs) / np.pi

    dut = Angle()
    sim_out = simulate(dut, inputs)
    assert sims_close(sim_out, expected=expect, rtol=1e-1)