Skip to content

add: nodes attribute is modifiable - #7532

Merged
rossbar merged 2 commits into
networkx:mainfrom
bakhtos:feature_json_custom_node_label
Jul 2, 2024
Merged

rossbar merged 2 commits into
networkx:mainfrom
bakhtos:feature_json_custom_node_label

Conversation

@bakhtos

@bakhtos bakhtos commented Jul 1, 2024

Copy link
Copy Markdown
Contributor

Fixes #7531

It is now possible to provide a keyword to replace the default nodes key for reading/writing json.

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

Thanks!

@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. (after the suggested change for the parameter name in the second function)

Fix documentation

Co-authored-by: Gilles Peiffer <[email protected]>
@bakhtos

bakhtos commented Jul 2, 2024

Copy link
Copy Markdown
Contributor Author

@dschult The PR is ready then

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

LGTM, thanks @bakhtos @dschult @Peiffap !

@rossbar
rossbar merged commit 35dfd99 into networkx:main Jul 2, 2024
@jarrodmillman jarrodmillman added this to the 3.4 milestone Jul 2, 2024
@bin-wang

Copy link
Copy Markdown

I do like this being modifiable, but the singular/plural discrepancy between link and nodes can be confusing, in my opinion.

@bakhtos

bakhtos commented Jul 11, 2024

Copy link
Copy Markdown
Contributor Author

@bin-wang the thing is, according to json graph schema (which I assumed networkx implements) it is supposed to be even edges, but any change would be backwards-incompatible at this point.

@dschult @Peiffap what do you think?

@dschult

dschult commented Jul 11, 2024

Copy link
Copy Markdown
Member

I also think it should be edges. And the code itself is strange in that it uses "link": "links", on line 13. It makes me wonder if it was a typo. Also, NetworkX consistently uses "edges" rather than "links".

Regarding backward compatibility, perhaps we can add the new "edges" while keeping the old "links", and early in the function check if links is not the default. If not, raise an exception or a deprecation warning depending on if edges is not the default. And copy the non-default value from links to edges if appropriate. After the two release deprecation cycle, we can remove the "links" argument. I guess the edges kwarg should go in the position of the links arg with the links arg at the end of the kwargs. I guess the doc_string should add the description of links as deprecated and to use edges.

Does this make sense?

@bakhtos

bakhtos commented Jul 16, 2024

Copy link
Copy Markdown
Contributor Author

@dschult Makes sense ofc

I can even make the deprecation change and send the pull request, but then will you handle the removal later on in the release cycle?

@dschult

dschult commented Jul 16, 2024

Copy link
Copy Markdown
Member

Yes -- as part of the deprecation, a line or two should be added to doc/developer/deprecations.rst under the section for the version that removal will take place. That line should say what should be removed. It shows up in the networkx documentation pages at: https://networkx.org/documentation/stable/developer/deprecations.html. There is also a section of the developers guide (subsection 7 of the section "development workflow") that mentions there should be a warning filter put into conftest.py (see the other similar warnings filters for deprecations and copy/paste/adapt). If you have other questions we'll cover them during PR review.
Thanks very much!

@bakhtos
bakhtos deleted the feature_json_custom_node_label branch July 16, 2024 19:46
@bakhtos

bakhtos commented Jul 16, 2024

Copy link
Copy Markdown
Contributor Author

Implemented in #7565

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.

6 participants