Beispiel #1
0
def test_scale_continuous():
    x = np.arange(11)
    # apply
    scaled = scale_continuous.apply(x, rescale)
    npt.assert_allclose(scaled, x*0.1)
    npt.assert_allclose(scaled, x*0.1)

    # Train
    limits = scale_continuous.train(x)
    npt.assert_allclose(limits, [0, 10])
    # Additional training
    limits = scale_continuous.train(np.arange(-4, 11), limits)
    npt.assert_allclose(limits, [-4, 10])
    limits = scale_continuous.train([], limits)
    npt.assert_allclose(limits, [-4, 10])

    # branches #
    scaled = scale_continuous.apply(x, rescale,
                                    trans=identity_trans())
    mapped = scale_continuous.map(x, list, [0, 10])
    npt.assert_allclose(mapped, x*0.1)

    with pytest.raises(TypeError):
        # discrete data
        limits = scale_continuous.train(['a', 'b', 'c'])
Beispiel #2
0
def test_gettrans():
    t0 = identity_trans()
    t1 = gettrans(t0)
    t2 = gettrans(identity_trans)
    t3 = gettrans('identity')
    assert all(isinstance(x, identity_trans) for x in (t0, t1, t2, t3))

    t = gettrans(exp_trans)
    assert t.__class__.__name__ == 'power_e_trans'

    with pytest.raises(ValueError):
        gettrans(object)
Beispiel #3
0
def test_gettrans():
    t0 = identity_trans()
    t1 = gettrans(t0)
    t2 = gettrans(identity_trans)
    t3 = gettrans('identity')
    assert all(
        isinstance(x, identity_trans) for x in (t0, t1, t2, t3))

    t = gettrans(exp_trans)
    assert t.__class__.__name__ == 'power_e_trans'

    with pytest.raises(ValueError):
        gettrans(object)
Beispiel #4
0
def test_scale_continuous():
    x = np.arange(11)
    # apply
    scaled = scale_continuous.apply(x, rescale)
    npt.assert_allclose(scaled, x * 0.1)
    npt.assert_allclose(scaled, x * 0.1)

    # Train
    limits = scale_continuous.train(x)
    npt.assert_allclose(limits, [0, 10])
    # Additional training
    limits = scale_continuous.train(np.arange(-4, 11), limits)
    npt.assert_allclose(limits, [-4, 10])
    limits = scale_continuous.train([], limits)
    npt.assert_allclose(limits, [-4, 10])

    # branches #
    scaled = scale_continuous.apply(x, rescale, trans=identity_trans())
    mapped = scale_continuous.map(x, list, [0, 10])
    npt.assert_allclose(mapped, x * 0.1)

    with pytest.raises(TypeError):
        # discrete data
        limits = scale_continuous.train(['a', 'b', 'c'])