Skip to content

DOC: more barycenter and centroid equivalence - #8630

Merged
MridulS merged 13 commits into
networkx:mainfrom
Peiffap:codex/barycenter-centroid-alias-docstring
Apr 25, 2026
Merged

MridulS merged 13 commits into
networkx:mainfrom
Peiffap:codex/barycenter-centroid-alias-docstring

Conversation

@Peiffap

@Peiffap Peiffap commented Apr 23, 2026 •

Copy link
Copy Markdown
Member

Closes #8491.
Follow-up to #8622.

  • Make nx.barycenter point to the same function object as nx.centroid, to prevent drift and to share docstrings, and add a regression test to assert this.
  • Make centroid the default terminology.

@dschult

dschult commented Apr 23, 2026

Copy link
Copy Markdown
Member

I think we dont want to add the barycenter name where it doesnt already occur (i.e. in the tree subpackage)

@Peiffap

Peiffap commented Apr 23, 2026

Copy link
Copy Markdown
Member Author

@dschult Would the desirable state be that the only place barycenter shows up is where we need it for backward compatibility (and in a note saying it's equivalent to centroid)?

@rossbar

rossbar commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

We definitely don't want to add a tree.barycenter - I think the idea is to emphasize centroid over barycenter as the name of this concept.

@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.

I think we should go ahead and remove barycenter from the docs TOC too:
in doc/reference/algorithms/distance_measrues.rst.

And another thing (I would say "finally", but that would tempt fate), can we add in the centroid docs (line 738?)

        .. versionchanged:: 3.7
           centroid() is created by a renaming of barycenter().
           The old name still works to call this function.

@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.

This looks good to me.

@MridulS
MridulS merged commit 9886d2d into networkx:main Apr 25, 2026
44 checks passed
@dschult dschult added this to the 3.7 milestone Apr 25, 2026
@Peiffap
Peiffap deleted the codex/barycenter-centroid-alias-docstring branch April 30, 2026 20:48
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.

API: add centroid as alias to barycenter in distance_measures

4 participants