Skip to content

Commit

Permalink
Update _nx_cugraph.__version__; support threshold in louvain
Browse files Browse the repository at this point in the history
  • Loading branch information
eriknw committed Sep 27, 2023
1 parent d2ab5cf commit 465bf69
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/cugr
sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/cugraph-service/server/cugraph_service_server/__init__.py
sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/pylibcugraph/pylibcugraph/__init__.py
sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/nx-cugraph/nx_cugraph/__init__.py
sed_runner "s/__version__ = .*/__version__ = \"${NEXT_FULL_TAG}\"/g" python/nx-cugraph/_nx_cugraph/__init__.py

# Python pyproject.toml updates
sed_runner "s/^version = .*/version = \"${NEXT_FULL_TAG}\"/g" python/cugraph/pyproject.toml
Expand Down
15 changes: 11 additions & 4 deletions python/nx-cugraph/_nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,21 @@ def get_info():
This tells NetworkX about the cugraph backend without importing nx_cugraph.
"""
# Convert to e.g. `{"functions" {"myfunc": {"extra_docstrings": ...}}}`
# Convert to e.g. `{"functions": {"myfunc": {"extra_docstring": ...}}}`
d = _info.copy()
func_keys = ("extra_docstrings", "extra_parameters")
info_keys = {
"extra_docstrings": "extra_docstring",
"extra_parameters": "extra_parameters",
}
d["functions"] = {
func: {key: vals[func] for key in func_keys if func in (vals := d[key])}
func: {
new_key: vals[func]
for old_key, new_key in info_keys.items()
if func in (vals := d[old_key])
}
for func in d["functions"]
}
for key in func_keys:
for key in info_keys:
del d[key]
return d

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def louvain_communities(
resource_handle=plc.ResourceHandle(),
graph=G._get_plc_graph(),
max_level=max_level, # TODO: add this parameter to NetworkX
threshold=threshold,
resolution=resolution,
# threshold=threshold, # TODO: add this parameter to PLC
do_expensive_check=False,
)
groups = _groupby(clusters, vertices)
Expand Down
5 changes: 1 addition & 4 deletions python/nx-cugraph/nx_cugraph/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ def key(testpath):
# Reasons for xfailing
no_weights = "weighted implementation not currently supported"
no_multigraph = "multigraphs not currently supported"
louvain_different = (
"Louvain may be different due to RNG or unsupported threshold parameter"
)
louvain_different = "Louvain may be different due to RNG"

xfail = {}

Expand Down Expand Up @@ -176,7 +174,6 @@ def key(testpath):
): louvain_different,
key("test_louvain.py:test_none_weight_param"): louvain_different,
key("test_louvain.py:test_multigraph"): louvain_different,
key("test_louvain.py:test_threshold"): louvain_different,
}
)

Expand Down
3 changes: 2 additions & 1 deletion python/nx-cugraph/nx_cugraph/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def __new__(
# The docstring on our function is added to the NetworkX docstring.
instance.extra_doc = func.__doc__
# Copy __doc__ from NetworkX
instance.__doc__ = _registered_algorithms[instance.name].__doc__
if instance.name in _registered_algorithms:
instance.__doc__ = _registered_algorithms[instance.name].__doc__
instance.can_run = _default_can_run
setattr(BackendInterface, instance.name, instance)
# Set methods so they are in __dict__
Expand Down

0 comments on commit 465bf69

Please sign in to comment.