Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: rename MaximumFlowResult.residual to flow #16004

Merged
merged 2 commits into from
Apr 18, 2022

Conversation

fuglede
Copy link
Contributor

@fuglede fuglede commented Apr 18, 2022

The attribute MaximumFlowResult.residual was poorly named: It in fact
represents the flow function of the maximum flow, whereas the residual
is given by the difference between the input graph and this flow
function. As such, we simply rename it from residual to flow to
avoid the risk of confusion.

A different possible fix would be to change the attribute to actually be
the residual graph, but that would change its value and therefore lead
to a slightly trickier deprecation. The flow is also useful in itself,
so for now, we simply include that, and let it be up to the user to make
the more or less trivial calculation of the residual if that's ever
needed.

This closes #14731

I think this is the first time I add a DeprecationWarning, so I'd appreciate
if the prospective reviewer could take a look at the form of that.

cc @czgdp1807 @pmla

The attribute `MaximumFlowResult.residual` was poorly named: It in fact
represents the flow function of the maximum flow, whereas the residual
is given by the difference between the input graph and this flow
function. As such, we simply rename it from `residual` to `flow` to
avoid the risk of confusion.

A different possible fix would be to change the attribute to actually be
the residual graph, but that would change its value and therefore lead
to a slightly trickier deprecation. The flow is also useful in itself,
so for now, we simply include that, and let it be up to the user to make
the more or less trivial calculation of the residual if that's ever
needed.

This closes scipygh-14731
Copy link
Member

@tupui tupui left a comment

Choose a reason for hiding this comment

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

Thanks @fuglede. LGTM, just a small thing about stacklevel. I will commit directly and if green I will merge.

scipy/sparse/csgraph/_flow.pyx Outdated Show resolved Hide resolved
@tupui tupui added deprecated Items related to behavior that has been deprecated scipy.sparse.csgraph labels Apr 18, 2022
@fuglede
Copy link
Contributor Author

fuglede commented Apr 18, 2022

Great, thanks both for checking.

@tupui tupui merged commit 4ce0a75 into scipy:main Apr 18, 2022
@tupui tupui added this to the 1.9.0 milestone Apr 18, 2022
@fuglede fuglede deleted the deprecate-residual branch April 18, 2022 19:08
@j-bowhay
Copy link
Member

@h-vetinari a future deprecation to be added to #15765

DietBru pushed a commit to DietBru/scipy that referenced this pull request Apr 19, 2022
* MAINT: rename MaximumFlowResult.residual to flow

The attribute `MaximumFlowResult.residual` was poorly named: It in fact
represents the flow function of the maximum flow, whereas the residual
is given by the difference between the input graph and this flow
function. As such, we simply rename it from `residual` to `flow` to
avoid the risk of confusion.

A different possible fix would be to change the attribute to actually be
the residual graph, but that would change its value and therefore lead
to a slightly trickier deprecation. The flow is also useful in itself,
so for now, we simply include that, and let it be up to the user to make
the more or less trivial calculation of the residual if that's ever
needed.

This closes scipygh-14731

* MAINT: add stacklevel to deprecation warning

[skip azp] [skip circle]

Co-authored-by: Pamphile Roy <roy.pamphile@gmail.com>
@h-vetinari
Copy link
Member

A removal after one release (i.e. deprecation in 1.9, removal in 1.10) is a bit aggressive, no? I think we should adapt the warning to promise removal by 1.11. Could you send a follow-up PR @fuglede?

(Thanks for the ping @j-bowhay 🙃)

@tupui
Copy link
Member

tupui commented Apr 20, 2022

@h-vetinari Note that our policy is flexible. In this case I did not think it was necessary. Feel free to send a quick fix otherwise.

@h-vetinari
Copy link
Member

I know that the policy if flexible, and I get that the naming was suboptimal, but just removing the old way of doing things will result in a hard break for everyone who had warning-less code in 1.8.

It's not uncommon that people don't upgrade for a while and then bump more than one version in one go. Of course we cannot accommodate that indefinitely, but two releases (~= 1 year) seems like a decent trade-off.

I'd be less outspoken if this was just a necessary behaviour-change, but for removing something entirely, we should leave more time IMO.

I'd ask @fuglede to do this, since it was their PR and I just didn't see it in time before it got merged.

@tupui
Copy link
Member

tupui commented Apr 20, 2022

@h-vetinari First, a maintainer approved (an another member of the triage team), and for such small thing it's more important to have a common voice than debating and have such conversation. We can meet offline to talk about these of course.

Second, it took me the same time to make a PR than it certainly took you to comment. So please, next time just do the change. If you really look at it, we have very limited people contributing to SciPy. So let's help everyone by not asking to make extra PRs to fix a single char.

@tupui
Copy link
Member

tupui commented Apr 20, 2022

I made the PR and updated the version. Thanks again everyone. All closed here 😃

swallan pushed a commit to swallan/scipy that referenced this pull request Apr 28, 2022
* MAINT: rename MaximumFlowResult.residual to flow

The attribute `MaximumFlowResult.residual` was poorly named: It in fact
represents the flow function of the maximum flow, whereas the residual
is given by the difference between the input graph and this flow
function. As such, we simply rename it from `residual` to `flow` to
avoid the risk of confusion.

A different possible fix would be to change the attribute to actually be
the residual graph, but that would change its value and therefore lead
to a slightly trickier deprecation. The flow is also useful in itself,
so for now, we simply include that, and let it be up to the user to make
the more or less trivial calculation of the residual if that's ever
needed.

This closes scipygh-14731

* MAINT: add stacklevel to deprecation warning

[skip azp] [skip circle]

Co-authored-by: Pamphile Roy <roy.pamphile@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated Items related to behavior that has been deprecated scipy.sparse.csgraph
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Incorrect residual graph in scipy.sparse.csgraph.maximum_flow
5 participants