Repository navigation
Save Layouts on Graphs - #7571
Conversation
|
If the layout functions create a dict/array of positions during the algorithm and then stores it on the graph it might be good to return the dict in addition to storing it on the graph. I believe layout might be useful for more than just drawing. It is certainly related to planar embeddings. :) |
|
This is a great point and would minimize changes to the API as well. |
dschult
left a comment
There was a problem hiding this comment.
Each layout algorithm function gets a new "attribute" parameter. But why does only one of the rescaling functions get it (and then not do anything with it)?
Also, the "attribute" name is very generic (perhaps on purpose). And it doesn't indicate that this is the name of the attribute, not it's value or a boolean indicating something. How about something like: pos_attr_name (too many abbreviations?)
And that brings up a naming issue: we've used 'pos' to mean position to such an extent that it doesn't even feel like an abbreviation after a while. (similar to G standing for Graph.) Do we still want to do that? If not what to do instead of spelling out position every time?
|
I'm not sure why only one of the rescale layouts has the About the new parameter name, |
…to mjschwenne-layouts-on-graph
dschult
left a comment
There was a problem hiding this comment.
I think this one is ready to megre after removing "attribute" from rescale_layout.
Looks good!
|
So, are we OK with the parameter name being |
It feels like more than just a change in the default attribute value -- though that is how the change is implemented. The change (if I understand it) is to automatically add "pos" values to the node attributes in the graph getting the layout. That means we are changing the parameter I'm not sure whether that is officially a deprecation or some other kind of change. But it seems pretty important for users to notice it. Right now it is a generic As for names, you point out that |
|
As per the deprecation policy, changing the default value of the function does require a deprecation cycle. I've added the needed warnings and renamed the |
dschult
left a comment
There was a problem hiding this comment.
I approve this PR. It is ready to merge as far as I'm concerned.
|
(Just putting in a comment here to not forget about the conversation with @dschult) I think it may make sense to bump up the deprecation release cycle to something like 3 or 4 instead of standard 2 cycles in the broader context of the new draw API. It should give us extra time to flush out the new API changes. |
|
One way to make the release cycles 3 or 4 instead of 2 would be to merge this PR with the deprecation warnings removed. Then 3.4 has both functions without any deprecation warnings. We advertise the changes in the release notes, etc. Then once 3.4 (or 3.5) is released, we add the deprecation warnings for the old functions. This would give us some time with early adopters before we make the "scary" deprecation warnings nudge less early adopters. And then we finally remove the functions. Thoughts? |
|
As far as I'm concerned either option is valid. On one hand, having all of the changes land at once is appealing but they are a large set of changes so being cautious about them is probably also wise. I think that having a longer deprecation cycle would be less cognitive burden on the developers at least, but it would mean that the users have to spend more time with the annoying warnings popping up. Of the two options, I'd probably agree with Dan to minimize the impact on the users, but I wasn't at the conversation you're referencing. If we decide to wait a cycle or two before adding the deprecation warning, I strongly think that we should add warnings in 3.4 when the new draw API takes effect. |
@mjschwenne can you repeat or reword that last phrase? We can't wait a cycle or two for warnings and also include the warnings in 3.4. Are you saying that we should have some sort of warning even if it isn't a deprecation warning? Or is the 3.4 number a typo? I want to make sure I understand what you are thinking. |
|
My bad, I got the release numbers mixed up in my head. If we wait before adding the deprecation warnings, we should add them when the rest of the next drawing API becomes the only drawing API in 3.6. |
|
I've removed plans to write layouts on graphs by default and added examples to the doc strings showing how to do that. |
|
Bumping this PR. It should just need another round of reviews. |
There was a problem hiding this comment.
I think this is a fairly clean PR that might seem long because it is a repeated application of the same changes for many functions. It really shouldn't take very long to work through once the pattern is clear in the first layout function.
I read through it again and have two small comments/suggestions. Feel free to leave them as is if that is better. I just had to re-read those words to understand them, that's all.
I have already approved this PR and that still stands.
rossbar
left a comment
There was a problem hiding this comment.
Thanks @mjschwenne - sorry for the slow burn on this. I always struggle with proposals to expand API, but adding this hook for convenience makes a lot of sense in the context of a visualization system where all visualization information can be extracted from the graphs themselves!
I took the liberty of removing a warnings filter that I believe was left over from a previous iteration + a minor rst tweak. I'd also like to see if the examples can't be prettified, but that's not a blocker. Thanks again so much for your patience!
|
The CI failures are unrelated, so I'll go ahead and get this in. Thanks again @mjschwenne ! |
to handle new `store_pos_as=` parameter introduced in networkx#7571.
to handle new `store_pos_as=` parameter introduced in #7571.
Adds the option to save positions onto the graph. Everything still returns an dict for now for backwards compatibility. In the future we'll want the default behavior to write the position back onto the graph, but that will require a deprecation cycle. I'm particularly interested in advice on how to structure the API during the cycle and still need to add the warnings.
In the meantime, I still need to add tests and look into the possibility that it's more efficient to compute the positions directly on the graph rather than use
set_edge_attributeat the end.