-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
DEP: sparse.linalg: remove msg on gcrotmk
, add atol
default
#16050
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
base: main
Are you sure you want to change the base?
Conversation
warnings.warn("scipy.sparse.linalg.gcrotmk called without specifying `atol`. " | ||
"The default value will change in the future. To preserve " | ||
"current behavior, set ``atol=tol``.", | ||
category=DeprecationWarning, stacklevel=2) | ||
atol = tol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should now raise an error, not set atol = tol
.
|
||
if type(atol) != float: | ||
raise ValueError("Tolerance value expected float") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be possible to replace both if-conditions with
if type(atol) != float: | |
raise ValueError("Tolerance value expected float") | |
if not np.issubdtype(type(atol), np.floating): | |
raise ValueError("Parameter `atol` must be a floating-point number!") |
7b4b59d
to
e716dad
Compare
else: | ||
return tol * float(bnrm2) | ||
else: | ||
return max(float(atol), tol * float(bnrm2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h-vetinari I assume we want to remove this legacy behavior here. This _get_atol()
function becomes rather small after removing the legacy code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, about scipy/sparse/linalg/_isolve/iterative.py:576
if callback is not None and callback_type is None:
# Warn about 'callback_type' semantic changes.
# Probably should be removed only in far future, Scipy 2.0 or so.
warnings.warn("scipy.sparse.linalg.gmres called without specifying `callback_type`. "
"The default value will be changed in a future release. "
"For compatibility, specify a value for `callback_type` explicitly, e.g., "
"``{name}(..., callback_type='pr_norm')``, or to retain the old behavior "
"``{name}(..., callback_type='legacy')``",
category=DeprecationWarning, stacklevel=3)
if callback_type is None:
callback_type = 'legacy'
Do we also want this warning gone? I suppose its better deprecated now than later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@h-vetinari I assume we want to remove this legacy behavior here. This
_get_atol()
function becomes rather small after removing the legacy code.
Indeed, that function only exists to work around the deprecation, and we should IMO remove it completely. You'll need to make sure that at each call site, the maximum of atol and the correct(ly calculated) residual is taken.
Also, about scipy/sparse/linalg/_isolve/iterative.py:576
[...]
Do we also want this warning gone? I suppose its better deprecated now than later.
It's deprecated already, and a whole separate issue IMO. I suggest not to touch it in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright. I think I'm done with gcrotmk and lgmres and their corresponding test files. However, I've stumbled upon issues when trying to remove the deprecation messages from iterative.py and test_iterative.py because I see some functions receive solver
as argument for different functions i.e:
# list of tuples (solver, symmetric, positive_definite )
solvers = [cg, cgs, bicg, bicgstab, gmres, qmr, minres, lgmres, gcrotmk, tfqmr]
sym_solvers = [minres, cg]
posdef_solvers = [cg]
real_solvers = [minres]
So, I'm having some conflicts due to some of these solvers not even having the atol parameter to start with. I suppose this is the reason _get_atol()
was implemented in the first place.
e716dad
to
2c229aa
Compare
Since CI is failing several tests, and the review process doesn't quite look complete, and deprecation-related cleanups probably aren't urgent (though can be quite nice) for releases, I'll likely bump the milestone to keep my "checklist" concise with branching scheduled in ~10 days. If this PR suddenly kicks back into action and gets merged on time, of course you can set the milestone back after merging. |
We should hold fire on this and reevaluate after #18488 |
100%, that was my intention as well. I just bumped the milestone to wind down the amount of stuff in there which is going to miss 1.11 anyway. |
And to not disparage the work of @jvsqzj, this is a really thorny subject that's been unsolved for many years, so please don't feel bad about things taking longer and turning out differently! :) |
@h-vetinari not sure what is going on here, but the matching issue is now closed even though some of the warnings removed in this PR do remain in our latest source. In any case, I'm not comfortable merging this due to the tricky API change and the merge conflicts that have shown up over the months. I'll bump the milestone, but since |
#18488 did not touch gcrotmk and lmgres so I think this is still a valid PR. Apologies not being precise, I'm too invested in special fortran code right now so don't remember all the details about what we did for this. |
Does someone (@jvsqzj?) want to merge |
I merged main here, but looking closer, I actually don't think we want to do this (switch to errors directly), at least not yet. I'll open another PR. |
Do we want to leave this PR open or close it now? |
Given that it's @jvsqzj's first contribution, I'm inclined to make an exception and leave it open. It will become relevant for 1.14, which is only ~6 month away, and the PR has already been open for 1.5 years, so this shouldn't make a big difference. I can rebase it once 1.13 branches (unless someone beats me to it). |
gcrotmk
, add atol
default
gcrotmk
, add atol
defaultgcrotmk
, add atol
default
1.13 has branched so just a reminder here @h-vetinari :) |
@jvsqzj, are you still here? 🙃 Would you like to keep working on this PR, or should we take it from here? |
I would like to. I'm sorry, work consuming all my time usually. |
@h-vetinari can you provide a concise explanation of why we need to worry about this PR for |
I think #20498 did everything that's necessary from the POV of executing deprecations. I think this PR is still useful because it contains a couple more test clean-ups that I had missed, but shouldn't be critical |
@jvsqzj just another ping in case you are interested in returning to this! |
Reference issue
Closes #15738
What does this implement/fix?
Successfully removes all deprecated default parameter warning messages from functions in _isolve
Docstrings updated to match method behavior and usage
Additional information