コード例 #1
0
def test_integer_array_numpy(file_map, numpy_data, numpy_files, i):
    file_n, file_idx = file_map
    array = MultifileNumpyArray(file_n, file_idx, numpy_files, (10, 10))
    check_idx = np.round(
        np.cumsum(np.random.rand(np.random.randint(
            1, file_n.shape[0]))).astype(int))
    np.random.shuffle(check_idx)
    assert np.all(array[check_idx] == numpy_data[check_idx])
コード例 #2
0
def test_expand_first_dim_numpy_a(file_map, numpy_data, numpy_files, i):
    file_n, file_idx = file_map
    array = MultifileNumpyArray(file_n, file_idx, numpy_files, (10, 10))
    check_idx = np.round(
        np.cumsum(
            np.random.rand((np.random.randint(4, file_n.shape[0]) // 4) *
                           4)).astype(int)).reshape((-1, 4))
    assert np.all(array[check_idx] == numpy_data[check_idx])
コード例 #3
0
def test_boolean_mask_numpy(file_map, numpy_data, numpy_files, i):
    file_n, file_idx = file_map
    array = MultifileNumpyArray(file_n, file_idx, numpy_files, (10, 10))
    random_ind = np.random.randint(0, file_n.shape[0],
                                   np.random.randint(1, file_n.shape[0]))
    check_idx = np.zeros_like(file_n, dtype=bool)
    check_idx[random_ind] = True
    assert np.all(array[check_idx] == numpy_data[check_idx])
コード例 #4
0
def test_integer_array_repeated_item_numpy(file_map, numpy_data, numpy_files,
                                           i):
    file_n, file_idx = file_map
    array = MultifileNumpyArray(file_n, file_idx, numpy_files, (10, 10))
    N = np.random.randint(2, 10)
    check_idx = np.concatenate([
        np.round(
            np.cumsum(
                np.random.rand(np.random.randint(1, file_n.shape[0]) //
                               N)).astype(int)) for _ in range(N)
    ])
    assert np.all(array[check_idx] == numpy_data[check_idx])
コード例 #5
0
def test_slices_numpy(file_map, numpy_data, numpy_files, i):
    file_n, file_idx = file_map
    array = MultifileNumpyArray(file_n, file_idx, numpy_files, (10, 10))

    check_idx = slice(np.random.randint(1, file_n.shape[0]))
    assert np.all(array[check_idx] == numpy_data[check_idx])

    a = np.random.randint(1, file_n.shape[0] - 1)
    b = np.random.randint(1, file_n.shape[0] - a)
    check_idx = slice(a, a + b)
    assert np.all(array[check_idx] == numpy_data[check_idx])

    a = np.random.randint(10, file_n.shape[0] - 10)
    b = np.random.randint(5, file_n.shape[0] - a - 5)
    c = np.random.randint(1, b - 1)
    check_idx = slice(a, a + b, c)
    assert np.all(array[check_idx] == numpy_data[check_idx])
コード例 #6
0
def test_integer_numpy(file_map, numpy_data, numpy_files, i):
    file_n, file_idx = file_map
    array = MultifileNumpyArray(file_n, file_idx, numpy_files, (10, 10))
    check_idx = np.random.randint(file_n.shape[0])
    assert np.all(array[check_idx] == numpy_data[check_idx])
コード例 #7
0
def test_mask_combinations_numpy_b(file_map, numpy_data, numpy_files, i):
    file_n, file_idx = file_map
    array = MultifileNumpyArray(file_n, file_idx, numpy_files, (10, 10))
    mask = np.random.randint(0, 2, (file_n.shape[0], 10), dtype=bool)
    assert np.all(array[mask] == numpy_data[mask])
コード例 #8
0
def test_simple_combination_numpy(file_map, numpy_data, numpy_files):
    file_n, file_idx = file_map
    array = MultifileNumpyArray(file_n, file_idx, numpy_files, (10, 10))
    assert np.all(array[10:20, 2:4, 8] == numpy_data[10:20, 2:4, 8])