def test_index_dataset():
    """
    Tests the index_dataset function using a numpy array to approximate
    a dataset.
    """

    data = np.arange(1000)
    mask = np.unique(np.random.randint(0, 1000, 100))

    true = data[mask]

    assert (index_dataset(data, mask) == true).all()
def test_index_dataset_h5py():
    """
    Tests the index_dataset function on a real HDF5 dataset.
    """

    file = create_in_memory_hdf5()

    data = np.arange(100000)
    mask = np.unique(np.random.randint(0, 100000, 10000))

    dataset = file.create_dataset("Test", data=data)

    assert (index_dataset(dataset, mask) == data[mask]).all()
def test_index_dataset_h5py():
    """
    Tests the index_dataset function on a real HDF5 dataset.
    """

    # This creates an in-memory file
    file = h5py.File(name='f1', driver='core', backing_store=False)

    data = np.arange(100000)
    mask = np.unique(np.random.randint(0, 100000, 10000))

    dataset = file.create_dataset("Test", data=data)

    assert (index_dataset(dataset, mask) == data[mask]).all()
def test_index_dataset():
    """
    Tests the index_dataset function using a numpy array to approximate
    a dataset.
    """

    file = create_in_memory_hdf5()
    data = file.create_dataset("test", data=np.arange(1000))
    mask = np.unique(np.random.randint(0, 1000, 100))

    true = data[list(mask)]

    assert (index_dataset(data, mask) == true).all()

    file.close()