Example #1
0
def test_np_format_as_indexsequence2vectorsequence():
    index_sequence_space = IndexSequenceSpace(max_labels=6, dim=1)
    vector_sequence_space = VectorSequenceSpace(dim=6)

    data = np.array([[0], [1], [4], [3]])
    rval = index_sequence_space.np_format_as(data, vector_sequence_space)
    true_val = np.array([[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0],
                         [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0]])

    assert np.all(rval == true_val)
Example #2
0
def test_np_format_as_indexsequence2indexsequence():
    index_sequence_space1 = IndexSequenceSpace(max_labels=6, dim=1,
                                               dtype='int16')
    index_sequence_space2 = IndexSequenceSpace(max_labels=6, dim=1,
                                               dtype='int32')

    data = np.random.randint(low=0, high=5, size=(10, 1))
    rval = index_sequence_space1.np_format_as(data, index_sequence_space2)

    assert np.all(rval == data)
Example #3
0
def test_np_format_as_indexsequence2vectorsequence():
    index_sequence_space = IndexSequenceSpace(max_labels=6, dim=1)
    vector_sequence_space = VectorSequenceSpace(dim=6)

    data = np.array([[0], [1], [4], [3]])
    rval = index_sequence_space.np_format_as(data, vector_sequence_space)
    true_val = np.array([[1, 0, 0, 0, 0, 0],
                         [0, 1, 0, 0, 0, 0],
                         [0, 0, 0, 0, 1, 0],
                         [0, 0, 0, 1, 0, 0]])

    assert np.all(rval == true_val)
Example #4
0
def test_np_format_as_indexsequence2indexsequence():
    index_sequence_space1 = IndexSequenceSpace(max_labels=6,
                                               dim=1,
                                               dtype='int16')
    index_sequence_space2 = IndexSequenceSpace(max_labels=6,
                                               dim=1,
                                               dtype='int32')

    data = np.random.randint(low=0, high=5, size=(10, 1))
    rval = index_sequence_space1.np_format_as(data, index_sequence_space2)

    assert np.all(rval == data)