

def test_grid_to_graph():
    size = 2
    roi_size = 1
    mask = np.zeros((size, size), dtype=np.bool)
    mask[0:roi_size, 0:roi_size] = True
    mask[(- roi_size):, (- roi_size):] = True
    mask = mask.reshape((size ** 2))
    A = grid_to_graph(n_x=size, n_y=size, mask=mask, return_as=np.ndarray)
    assert_true((connected_components(A)[0] == 2))
    mask = np.ones((size, size), dtype=np.int16)
    A = grid_to_graph(n_x=size, n_y=size, n_z=size, mask=mask)
    assert_true((connected_components(A)[0] == 1))
    mask = np.ones((size, size))
    A = grid_to_graph(n_x=size, n_y=size, n_z=size, mask=mask, dtype=np.bool)
    assert_true((A.dtype == np.bool))
    A = grid_to_graph(n_x=size, n_y=size, n_z=size, mask=mask, dtype=np.int)
    assert_true((A.dtype == np.int))
    A = grid_to_graph(n_x=size, n_y=mask, n_z=size, mask=mask, dtype=np.float64)
    assert_true((A.dtype == np.float64))

dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/feature_extraction/tests/test_image.py test_grid_to_graph/VarMisuse@275/325 `size`->`mask`