示例#1
0
UNDIRECTED_DATASETS = [
    pytest.param("../datasets/karate.csv",
                 marks=[pytest.mark.tiny, pytest.mark.undirected]),
    pytest.param("../datasets/csv/undirected/hollywood.csv",
                 marks=[pytest.mark.small, pytest.mark.undirected]),
    pytest.param("../datasets/csv/undirected/europe_osm.csv",
                 marks=[pytest.mark.undirected]),
    # pytest.param("../datasets/csv/undirected/soc-twitter-2010.csv",
    #              marks=[pytest.mark.undirected]),
]
DIRECTED_DATASETS = [
    pytest.param("../datasets/csv/directed/cit-Patents.csv",
                 marks=[pytest.mark.small, pytest.mark.directed]),
    pytest.param("../datasets/csv/directed/soc-LiveJournal1.csv",
                 marks=[pytest.mark.directed]),
]

MANAGED_MEMORY = [
    pytest.param(True, marks=[pytest.mark.managedmem_on]),
    pytest.param(False, marks=[pytest.mark.managedmem_off]),
]

POOL_ALLOCATOR = [
    pytest.param(True, marks=[pytest.mark.poolallocator_on]),
    pytest.param(False, marks=[pytest.mark.poolallocator_off]),
]

FIXTURE_PARAMS = genFixtureParamsProduct(
    (DIRECTED_DATASETS + UNDIRECTED_DATASETS, "ds"), (MANAGED_MEMORY, "mm"),
    (POOL_ALLOCATOR, "pa"))
示例#2
0
def prepare_test():
    gc.collect()


# =============================================================================
# Pytest Fixtures
# =============================================================================
DIRECTED = [pytest.param(d) for d in DIRECTED_GRAPH_OPTIONS]
DATASETS_SMALL = [pytest.param(d) for d in utils.DATASETS_SMALL]
DATASETS_UNRENUMBERED = [pytest.param(d) for d in utils.DATASETS_UNRENUMBERED]
WEIGHTED_GRAPH_OPTIONS = [pytest.param(w) for w in WEIGHTED_GRAPH_OPTIONS]


small_graph_fixture_params = utils.genFixtureParamsProduct(
    (DATASETS_SMALL, "grph"),
    (DIRECTED, "dirctd"),
    (WEIGHTED_GRAPH_OPTIONS, "wgtd_gph_opts"))

unrenumbered_graph_fixture_params = utils.genFixtureParamsProduct(
    (DATASETS_UNRENUMBERED, "grph"),
    (DIRECTED, "dirctd"),
    (WEIGHTED_GRAPH_OPTIONS, "wgtd_gph_opts"))


@pytest.fixture(scope="module", params=small_graph_fixture_params)
def get_cu_nx_graph_datasets_small(request):
    return utils.build_cu_and_nx_graphs(*request.param)


@pytest.fixture(scope="module", params=unrenumbered_graph_fixture_params)
def get_cu_nx_graph_datasets_unrenumbered(request):
示例#3
0
# =============================================================================
# Pytest Fixtures
# =============================================================================
SEEDS = [pytest.param(s) for s in SUBSET_SEED_OPTIONS]
DIRECTED = [pytest.param(d) for d in DIRECTED_GRAPH_OPTIONS]
DATASETS = [pytest.param(d) for d in utils.DATASETS]
DATASETS_SMALL = [pytest.param(d) for d in utils.DATASETS_SMALL]
USE_SHORTEST_PATH_COUNTER = [pytest.param(False), pytest.param(True)]

# Call genFixtureParamsProduct() to caluculate the cartesian product of
# multiple lists of params. This is required since parameterized fixtures do
# not do this automatically (unlike multiply-parameterized tests). The 2nd
# item in the tuple is a label for the param value used when displaying the
# full test name.
algo_test_fixture_params = utils.genFixtureParamsProduct(
    (SEEDS, "seed"), (USE_SHORTEST_PATH_COUNTER, "spc"))

graph_fixture_params = utils.genFixtureParamsProduct((DATASETS, "ds"),
                                                     (DIRECTED, "dirctd"))

small_graph_fixture_params = utils.genFixtureParamsProduct(
    (DATASETS_SMALL, "ds"), (DIRECTED, "dirctd"))

# The single param list variants are used when only 1 param combination is
# needed (eg. testing non-native input types where tests for other combinations
# was covered elsewhere).
single_algo_test_fixture_params = utils.genFixtureParamsProduct(
    ([SEEDS[0]], "seed"), ([USE_SHORTEST_PATH_COUNTER[0]], "spc"))

single_small_graph_fixture_params = utils.genFixtureParamsProduct(
    ([DATASETS_SMALL[0]], "ds"), (DIRECTED, "dirctd"))
示例#4
0
    return (graph_file, source, nx_paths, Gnx)


# =============================================================================
# Pytest fixtures
# =============================================================================

# Call genFixtureParamsProduct() to caluculate the cartesian product of
# multiple lists of params. This is required since parameterized fixtures do
# not do this automatically (unlike multiply-parameterized tests). The 2nd
# item in the tuple is a label for the param value used when displaying the
# full test name.
DATASETS = [pytest.param(d) for d in utils.DATASETS]
SOURCES = [pytest.param(1)]
fixture_params = utils.genFixtureParamsProduct((DATASETS, "ds"),
                                               (SOURCES, "src"))
fixture_params_single_dataset = \
    utils.genFixtureParamsProduct(([DATASETS[0]], "ds"), (SOURCES, "src"))


# These fixtures will call networkx BFS algos and save the result. The networkx
# call is only made only once per input param combination.
@pytest.fixture(scope="module", params=fixture_params)
def dataset_source_nxresults(request):
    # request.param is a tuple of params from fixture_params. When expanded
    # with *, will be passed to networkx_call() as args (graph_file, source)
    return networkx_call(*(request.param))


@pytest.fixture(scope="module", params=fixture_params_single_dataset)
def single_dataset_source_nxresults(request):
示例#5
0
文件: test_bfs.py 项目: mattf/cugraph
# =============================================================================
# Pytest Fixtures
# =============================================================================
SEEDS = [pytest.param(s) for s in SUBSET_SEED_OPTIONS]
DIRECTED = [pytest.param(d) for d in DIRECTED_GRAPH_OPTIONS]
DATASETS = [pytest.param(d) for d in utils.DATASETS]
DATASETS_SMALL = [pytest.param(d) for d in utils.DATASETS_SMALL]
DEPTH_LIMIT = [pytest.param(d) for d in DEPTH_LIMITS]

# Call genFixtureParamsProduct() to caluculate the cartesian product of
# multiple lists of params. This is required since parameterized fixtures do
# not do this automatically (unlike multiply-parameterized tests). The 2nd
# item in the tuple is a label for the param value used when displaying the
# full test name.
algo_test_fixture_params = utils.genFixtureParamsProduct(
    (SEEDS, "seed"), (DEPTH_LIMIT, "depth_limit"))

graph_fixture_params = utils.genFixtureParamsProduct((DATASETS, "ds"),
                                                     (DIRECTED, "dirctd"))

small_graph_fixture_params = utils.genFixtureParamsProduct(
    (DATASETS_SMALL, "ds"), (DIRECTED, "dirctd"))

# The single param list variants are used when only 1 param combination is
# needed (eg. testing non-native input types where tests for other combinations
# was covered elsewhere).
single_algo_test_fixture_params = utils.genFixtureParamsProduct(
    ([SEEDS[0]], "seed"), ([DEPTH_LIMIT[0]], "depth_limit"))

single_small_graph_fixture_params = utils.genFixtureParamsProduct(
    ([DATASETS_SMALL[0]], "ds"), (DIRECTED, "dirctd"))
示例#6
0
# =============================================================================
# Pytest Setup / Teardown - called for each test function
# =============================================================================
def setup_function():
    gc.collect()


# =============================================================================
# Pytest fixtures
# =============================================================================
datasets = utils.DATASETS_UNDIRECTED + \
           [utils.RAPIDS_DATASET_ROOT_DIR_PATH/"email-Eu-core.csv"]
fixture_params = utils.genFixtureParamsProduct(
    (datasets, "graph_file"),
    ([50], "max_iter"),
    ([1.0e-6], "tol"),
)


@pytest.fixture(scope="module", params=fixture_params)
def input_combo(request):
    """
    Simply return the current combination of params as a dictionary for use in
    tests or other parameterized fixtures.
    """
    return dict(zip(("graph_file", "max_iter", "tol"), request.param))


@pytest.fixture(scope="module")
def input_expected_output(input_combo):
示例#7
0
# Pytest fixtures
# =============================================================================
df_types = [cudf.DataFrame, pd.DataFrame]


def df_type_id(dft):
    s = "df_type="
    if dft == cudf.DataFrame:
        return s + "cudf.DataFrame"
    if dft == pd.DataFrame:
        return s + "pandas.DataFrame"
    return s + "?"


@pytest.fixture(scope="module",
                params=utils.genFixtureParamsProduct((df_types, df_type_id)))
def property_graph_instance(request):
    """
    FIXME: fill this in
    """
    dataframe_type = request.param[0]
    from cugraph.experimental import PropertyGraph

    (merchants, users, taxpayers, transactions, relationships,
     referrals) = dataset1.values()

    pG = PropertyGraph()

    # Vertex and edge data is added as one or more DataFrames; either a Pandas
    # DataFrame to keep data on the CPU, a cuDF DataFrame to keep data on GPU,
    # or a dask_cudf DataFrame to keep data on distributed GPUs.