예제 #1
0
def test_create_in_memory_hdf5():
    """
    Tests the creation of an in-memory hdf5 file.
    """

    file = create_in_memory_hdf5()
    file.close()

    return
예제 #2
0
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()
예제 #3
0
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()
예제 #4
0
def test_read_ranges_from_file():
    """
    Tests the reading of ranges from file using a numpy array as a stand in for
    the dataset.
    """

    # In memory hdf5 file
    file_handle = create_in_memory_hdf5()
    handle = file_handle.create_dataset("test", data=np.arange(1000))
    ranges = np.array([[77, 79], [81, 81], [88, 98], [204, 204]])
    output_size = 2 + 10
    output_type = type(handle[0])

    expected = np.array([77, 78, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97])
    out = read_ranges_from_file(handle, ranges, output_size, output_type)

    assert (out == expected).all()

    file_handle.close()