Skip to content

Commit

Permalink
Removes FIXME, minor code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlratzel committed Sep 28, 2023
1 parent ca5e255 commit 1232897
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions benchmarks/nx-cugraph/pytest-based/bench_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
soc_livejournal,
)

# Attempt to import the NetworkX dispatching module, which is only needed when
# testing with NX <3.2 in order to dynamically switch backends. NX >=3.2 allows
# the backend to be specified directly in the API call.
try:
from networkx.classes import backends # NX <3.2
except ImportError:
backends = None


################################################################################
# Fixtures and helpers
backend_params = ["cugraph", None]
Expand Down Expand Up @@ -90,18 +99,6 @@ def graph_obj(request):
return nx_graph_from_dataset(dataset)


# FIXME: this is needed for networkx <3.2, networkx >=3.2 simply allows the
# backend to be specified using a parameter. For now, use the same technique
# for all NX versions
try:
from networkx.classes import backends # NX <3.2

_using_legacy_dispatcher = True
except ImportError:
backends = None
_using_legacy_dispatcher = False


def get_legacy_backend_selector(backend_name):
"""
Returns a callable that wraps an algo function with either the default
Expand Down Expand Up @@ -167,7 +164,7 @@ def backend_selector(request):
function that calls the algo using the appropriate backend.
"""
backend_name = request.param
if _using_legacy_dispatcher:
if backends is not None:
return get_legacy_backend_selector(backend_name)
else:
return get_backend_selector(backend_name)
Expand Down

0 comments on commit 1232897

Please sign in to comment.