Ejemplo n.º 1
0
def test_gffd_and_uffd_w_input():
    torch.manual_seed(SEED)

    gLd = 0.333
    EL = -68.0
    EE = -10.0
    EI = -86.0
    wE = torch.Tensor([[[1.618]]])
    wI = torch.Tensor([[[3.141]]])
    r_in = torch.Tensor(1, 1).normal_(std=0.1) + 5.0

    gffd_expected = gLd + wE * r_in + wI * r_in
    uffd_expected = (gLd * EL + wE * r_in * EE +
                     wI * r_in * EI) / gffd_expected

    model = AbstractConvexCell([1], 1)
    model.gLd[0] = gLd
    model.EL = EL
    model.EE = EE
    model.EI = EI
    model.set_weightsE(0, wE[0])
    model.set_weightsI(0, wI[0])

    u_in = model.f_inv(r_in)
    gffd, uffd = model.compute_gffd_and_uffd(u_in)

    assert gffd[0][0].tolist() == pytest.approx(gffd_expected[0][0].tolist())
    assert uffd[0][0].tolist() == pytest.approx(uffd_expected[0][0].tolist())
Ejemplo n.º 2
0
def test_gff0_and_uff0():
    torch.manual_seed(SEED)

    gL0 = 0.333
    EL = -72.0

    model = AbstractConvexCell([1], 1)
    model.gL0 = gL0
    model.EL = EL
    gff0, uff0 = model.compute_gff0_and_uff0()

    assert gff0 == pytest.approx(gL0)
    assert uff0 == pytest.approx(EL)