Esempio n. 1
0
def test_k_hot_dtypes():
    int_dt = ['int8', 'int16', 'int32', 'int64']
    int_dt += ['u' + dt for dt in int_dt]
    float_dt = ['float64', 'float32', 'complex64', 'complex128']
    all_dt = int_dt + float_dt
    assert_(
        all(k_hot([[5, 3]], dtype=dt).dtype == np.dtype(dt) for dt in all_dt))
Esempio n. 2
0
def test_k_hot_out():
    out = np.empty((2, 3), dtype="uint8")
    assert_equal(k_hot([[1, 0], [2, 1]], out=out), [[1, 1, 0], [0, 1, 1]])
    assert_equal(out, [[1, 1, 0], [0, 1, 1]])
Esempio n. 3
0
def test_k_hot_dtypes():
    int_dt = ["int8", "int16", "int32", "int64"]
    int_dt += ["u" + dt for dt in int_dt]
    float_dt = ["float64", "float32", "complex64", "complex128"]
    all_dt = int_dt + float_dt
    assert_(all(k_hot([[5, 3]], dtype=dt).dtype == np.dtype(dt) for dt in all_dt))
Esempio n. 4
0
def test_k_hot_basic():
    assert_equal(k_hot([[1], [2], [1]], max_label=3), [[0, 1, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0]])
    assert_equal(k_hot([[1, 2], [2, 0], [1, 0]], max_label=3), [[0, 1, 1, 0], [1, 0, 1, 0], [1, 1, 0, 0]])
Esempio n. 5
0
def test_k_hot_out():
    out = np.empty((2, 3), dtype='uint8')
    assert_equal(k_hot([[1, 0], [2, 1]], out=out), [[1, 1, 0], [0, 1, 1]])
    assert_equal(out, [[1, 1, 0], [0, 1, 1]])
Esempio n. 6
0
def test_k_hot_basic():
    assert_equal(k_hot([[1], [2], [1]], max_label=3),
                 [[0, 1, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0]])
    assert_equal(k_hot([[1, 2], [2, 0], [1, 0]], max_label=3),
                 [[0, 1, 1, 0], [1, 0, 1, 0], [1, 1, 0, 0]])