Skip to content

Conversation

jvsqzj
Copy link

@jvsqzj jvsqzj commented Apr 27, 2022

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

@h-vetinari
Copy link
Member

Closes #16050

Should be #15738

Still missing a whole bunch of instances in sparse/linalg/_isolve/ as discussed in the issue.

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
Copy link
Member

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.

Comment on lines 287 to 289

if type(atol) != float:
raise ValueError("Tolerance value expected float")
Copy link
Member

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

Suggested change
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!")

@tupui tupui added deprecated Items related to behavior that has been deprecated scipy.sparse.linalg labels Apr 27, 2022
@jvsqzj jvsqzj force-pushed the DEP-default-atol-15738 branch from 7b4b59d to e716dad Compare April 28, 2022 04:44
else:
return tol * float(bnrm2)
else:
return max(float(atol), tol * float(bnrm2))
Copy link
Author

@jvsqzj jvsqzj Apr 28, 2022

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.

Copy link
Author

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.

Copy link
Member

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.

Copy link
Author

@jvsqzj jvsqzj May 2, 2022

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.

@jvsqzj jvsqzj force-pushed the DEP-default-atol-15738 branch from e716dad to 2c229aa Compare May 2, 2022 00:04
@j-bowhay j-bowhay added this to the 1.10.0 milestone Jul 8, 2022
@tylerjereddy
Copy link
Contributor

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.

@j-bowhay
Copy link
Member

We should hold fire on this and reevaluate after #18488

@h-vetinari
Copy link
Member

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.

@h-vetinari
Copy link
Member

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! :)

@tylerjereddy
Copy link
Contributor

@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 1.13.0 may come out a few months earlier than usual (because of NumPy 2.0.0 support), there will likely be another medium-term opportunity to deal with this if desired.

@tylerjereddy tylerjereddy modified the milestones: 1.12.0, 1.13.0 Dec 4, 2023
@j-bowhay
Copy link
Member

j-bowhay commented Dec 4, 2023

I think we can close this as redundant as of #18488 regardless thanks for your contribution @jvsqzj

@j-bowhay j-bowhay closed this Dec 4, 2023
@j-bowhay j-bowhay removed this from the 1.13.0 milestone Dec 4, 2023
@ilayn
Copy link
Member

ilayn commented Dec 4, 2023

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

@j-bowhay j-bowhay reopened this Dec 4, 2023
@h-vetinari
Copy link
Member

#18488 did not touch gcrotmk and lmgres so I think this is still a valid PR.

Sounds like we need to reopen #15738 too?

@lucascolley lucascolley added this to the 1.13.0 milestone Dec 10, 2023
@h-vetinari
Copy link
Member

Does someone (@jvsqzj?) want to merge main here and see where things stand?

@h-vetinari
Copy link
Member

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.

@lucascolley
Copy link
Member

I actually don't think we want to do this (switch to errors directly), at least not yet

Do we want to leave this PR open or close it now?

@h-vetinari
Copy link
Member

h-vetinari commented Dec 19, 2023

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

@lucascolley lucascolley removed this from the 1.13.0 milestone Dec 19, 2023
@lucascolley lucascolley added this to the 1.14.0 milestone Mar 12, 2024
@lucascolley lucascolley self-requested a review March 12, 2024 20:23
@lucascolley lucascolley changed the title WIP remove msg on gcrotmk, add atol default DEP: sprase.linalg: remove msg on gcrotmk, add atol default Mar 14, 2024
@lucascolley lucascolley changed the title DEP: sprase.linalg: remove msg on gcrotmk, add atol default DEP: sparse.linalg: remove msg on gcrotmk, add atol default Mar 14, 2024
@lucascolley
Copy link
Member

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

1.13 has branched so just a reminder here @h-vetinari :)

@lucascolley lucascolley removed their request for review March 18, 2024 15:24
@h-vetinari
Copy link
Member

@jvsqzj, are you still here? 🙃

Would you like to keep working on this PR, or should we take it from here?

@jvsqzj
Copy link
Author

jvsqzj commented Mar 19, 2024

@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.
Need to set some time to continue this.

@tylerjereddy
Copy link
Contributor

It will become relevant for 1.14,

@h-vetinari can you provide a concise explanation of why we need to worry about this PR for 1.14.0 release? Deprecation timing-related stuff or?

@h-vetinari
Copy link
Member

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

@tylerjereddy tylerjereddy modified the milestones: 1.14.0, 1.15.0 May 26, 2024
@lucascolley
Copy link
Member

@jvsqzj just another ping in case you are interested in returning to this!

@lucascolley lucascolley removed this from the 1.15.0 milestone Nov 30, 2024
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.linalg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEP: change default of atol in scipy.sparse.linalg.*
7 participants