Repository navigation
Add edges keyword/deprecate link keyword arguments in JSON input-output - #7565
Conversation
rossbar
left a comment
There was a problem hiding this comment.
I went ahead and pushed up a few changes to get the tests passing etc. I left the logic for how the old/new kwargs are handled untouched as I think it's a sensible path forward.
In practice, this does change behavior... the defaults for node_link_data and node_link_graph now produce/expect attributes named "edges" instead of "links". The behavior change is most clearly illustrated in the test in c519175, which had to be modified to get these changes passing.
I'm okay with this breakage. In principle this will affect users who are using these functions to dump serialized graph data to disk with networkx <3.5, then trying to load them with networkx >=3.5. Even then, the behavior of reading the "old" files would still be recoverable by adding edges="links" when calling node_link_graph. This should be documented in the release notes, but I'm willing to add the breakage now rather than having to do two separate deprecation cycles (one for removing the link arg, and another for changing the default value of edges from "links" -> "edges").
All that's to say: +1 from me for this course of action! Thanks @bakhtos !
…t-output (networkx#7565) * deprecate `link` kwarg * change default value to `edges` * Update docstring deprecation warnings. * Update doctests. * Always warn when link is used, add comments for future removal. * Modify test to capture default behavior change. --------- Co-authored-by: Ross Barnowski <[email protected]>
Following the discussion in #7532, this PR does the following:
edgesis introduced to JSON reading/writing functionslinkis deprecatedValueErrorif both are providedDeprecationWarningiflinkis providedIn the second commit, the actual default value for
edgesis set to"edges"instead of"links".I am not sure if the idea was to chage it now or maintain backwards compatibility of scripts that might use default values.