示例#1
0
def test_nnls_repr():
    pytest.importorskip("scipy.optimize")

    check_init_args(Nnls, ["weights"])
    check_repr(Nnls(weights=True))
    assert repr(Nnls(weights=True)) == "Nnls(weights=True)"

    check_init_args(NnlsL2, ["weights", "reg"])
    check_repr(NnlsL2(weights=True, reg=0.2))
    assert repr(NnlsL2(weights=True, reg=0.2)) == "NnlsL2(weights=True, reg=0.2)"

    check_init_args(NnlsL2nz, ["weights", "reg"])
    check_repr(NnlsL2nz(weights=True, reg=0.2))
    assert repr(NnlsL2nz(weights=True, reg=0.2)) == "NnlsL2nz(weights=True, reg=0.2)"
示例#2
0
def test_non_compositional_solver_transform_error(Simulator):
    pytest.importorskip("scipy")

    with nengo.Network() as net:
        a = nengo.Ensemble(10, 1)
        b = nengo.Ensemble(10, 1)
        nengo.Connection(a, b, solver=Nnls(weights=True),
                         transform=nengo.Convolution(
                             1, (1, 1), kernel_size=(1,), strides=(1,)))

    # build error for non-compositional solver with non-dense transform
    with pytest.raises(BuildError, match="Non-compositional solvers"):
        with Simulator(net):
            pass