Example #1
0
def test_matrix_file_pointer_load_helper_works_with_string_io(ubyte_matrix):
    with open(ubyte_matrix, 'rb') as fp:
        file_like_buffer = BytesIO(fp.read())
    matrix = mnisttk.decode_file(file_like_buffer)
    assert matrix.dtype == np.uint8
    assert matrix.shape == (2, 3)
    assert np.all(matrix.reshape(6) == [1, 2, 3, 4, 5, 6])
Example #2
0
def test_matrix_file_pointer_load_helper_file_position(ubyte_matrix):
    with open(ubyte_matrix, 'rb') as fp:
        fp.seek(10)
        matrix = mnisttk.decode_file(fp)
        assert fp.tell() == 10
        assert matrix.dtype == np.uint8
        assert matrix.shape == (2, 3)
        assert np.all(matrix.reshape(6) == [1, 2, 3, 4, 5, 6])