Skip to content

DEP: Deprecate metric_closure - #8304

Merged
dschult merged 5 commits into
networkx:mainfrom
Aka2210:dep-metric-closure
Oct 2, 2025
Merged

dschult merged 5 commits into
networkx:mainfrom
Aka2210:dep-metric-closure

Conversation

@Aka2210

@Aka2210 Aka2210 commented Sep 30, 2025 •

Copy link
Copy Markdown
Contributor

Deprecates metric_closure in networkx.algorithms.approximation.steinertree.

  • Adds DeprecationWarning to metric_closure.
  • Adds .. deprecated:: 3.5 directive to the docstring.
  • Adds filter to conftest.py.
  • Adds entry to doc/developer/deprecations.rst for removal in 3.7.

Replacement: use :func:networkx.all_pairs_shortest_path_length.

Related to #8302

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Aka2210 ! Just a quick note re: versions - the deprecation version should be the next release, not the current one (as users won't see deprecation warnings until the changes are officially released). That means the deprecation version should be bumped from 3.5 -> 3.6 and the removal version from 3.7 -> 3.8.

@Aka2210

Aka2210 commented Oct 1, 2025

Copy link
Copy Markdown
Contributor Author

Thanks @Aka2210 ! Just a quick note re: versions - the deprecation version should be the next release, not the current one (as users won't see deprecation warnings until the changes are officially released). That means the deprecation version should be bumped from 3.5 -> 3.6 and the removal version from 3.7 -> 3.8.

Thanks for catching that! I’ve updated the deprecation directive and removal version to 3.6 / 3.8.

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @Aka2210 , I took the liberty of pushing up a few minor tweaks but LGTM!

@Aka2210

Aka2210 commented Oct 1, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for this @Aka2210 , I took the liberty of pushing up a few minor tweaks but LGTM!

Thanks for the tweaks! No worries at all — I really don’t mind you pushing those changes.

I just had a small question: I noticed you updated test_steinertree.py to wrap the metric_closure call in pytest.deprecated_call(). I didn’t see this step explicitly mentioned in the deprecations guideline — did I miss something, or is this more of an established testing convention for deprecated APIs?

@rossbar

rossbar commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

I just had a small question: I noticed you updated test_steinertree.py to wrap the metric_closure call in pytest.deprecated_call(). I didn’t see this step explicitly mentioned in the deprecations guideline — did I miss something, or is this more of an established testing convention for deprecated APIs?

You didn't miss anything - it's not required to do and doesn't apply to every case so it's not explicitly mentioned in the contributor guide. It's more of a double-check that the tests which touch metric closure have been reviewed at the deprecation stage!

@dschult dschult left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks @Aka2210 and @rossbar for review!

@dschult
dschult merged commit 5be4d12 into networkx:main Oct 2, 2025
@dschult dschult added this to the 3.6 milestone Oct 2, 2025
@Aka2210
Aka2210 deleted the dep-metric-closure branch October 4, 2025 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants