MCPcopy
hub / github.com/dmlc/dgl / test_range_select

Function test_range_select

tests/python/pytorch/sparse/test_sparse_matrix.py:490–504  ·  view source on GitHub ↗
(create_func, shape, dense_dim, select_dim, rang)

Source from the content-addressed store, hash-verified

488@pytest.mark.parametrize("select_dim", [0, 1])
489@pytest.mark.parametrize("rang", [slice(0, 2), slice(1, 3)])
490def test_range_select(create_func, shape, dense_dim, select_dim, rang):
491 ctx = F.ctx()
492 A = create_func(shape, 20, ctx, dense_dim)
493 A_select = A.range_select(select_dim, rang)
494
495 dense = sparse_matrix_to_dense(A)
496 if select_dim == 0:
497 dense_select = dense[rang, :]
498 else:
499 dense_select = dense[:, rang]
500
501 A_select_to_dense = sparse_matrix_to_dense(A_select)
502
503 assert A_select_to_dense.shape == dense_select.shape
504 assert torch.allclose(A_select_to_dense, dense_select)
505
506
507@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 3

sparse_matrix_to_denseFunction · 0.85
range_selectMethod · 0.80
ctxMethod · 0.45

Tested by

no test coverage detected