def copy_memmap_h5dt(arr, dt):
    """Copies a :class:`numpy.memmap` to a hdf5 dataset."""
    if arr.ndim > 2:
        raise Exception("I don't know how to handle arrays" +
            ' with more than 2 dimensions yet.')
    assert arr.shape == dt.shape
    if arr.ndim == 1:
        dt[:] = arr[:]
    else:
        if dt.chunks is not None:
            chunk_row = dt.chunks[0]
        else:
            chunk_row = 512
        r = 0
        while r < arr.shape[0]:
            re = r + chunk_row
            re = min(re, arr.shape[0])
            dt[r:re, :] = arr[r:re, :]
            r = re
