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

Warnings verbosity #1213

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Warnings verbosity #1213

wants to merge 8 commits into from

Conversation

damonge
Copy link
Collaborator

@damonge damonge commented Nov 19, 2024

CCL often throws warnings about things that are relatively benign and should not plague the output of e.g. MCMC runs. This PR implements a granular way to control the verbosity of the warning messages thrown by CCL.

It uses some code by @nikfilippas .

While doing this I fixed a couple of bugs in the documentation.

Most of the changes are cosmetic. Anyone reviewing should start by looking at the changes in error.py (the rest is boilerplate)

@coveralls
Copy link

coveralls commented Nov 19, 2024

Pull Request Test Coverage Report for Build 11976595227

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 31 of 31 (100.0%) changed or added relevant lines in 8 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 97.449%

Files with Coverage Reduction New Missed Lines %
pyccl/_nonlimber_FKEM.py 1 96.12%
Totals Coverage Status
Change from base Build 11894056889: 0.03%
Covered Lines: 6533
Relevant Lines: 6704

💛 - Coveralls

@damonge damonge marked this pull request as ready for review November 19, 2024 13:28
@@ -1,6 +1,50 @@
__all__ = ("CCLError", "CCLWarning", "CCLDeprecationWarning",)
__all__ = ("CCLError", "CCLWarning", "CCLDeprecationWarning",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Start reviewing here.

pyccl/errors.py Outdated Show resolved Hide resolved
@@ -40,8 +84,8 @@ def __hash__(self):

@classmethod
def enable(cls):
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the deprecation warnings covered by the verbosity filter as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think so, but let me check

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No they are not. Do you think they should?

Copy link
Contributor

Choose a reason for hiding this comment

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

My gut feeling is yes - they're good to know while building a model but you probably don't want them in an MCMC log.

Copy link
Contributor

Choose a reason for hiding this comment

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

If they mute them and CCL's deprecation cycle completes, their MCMC will simply stop working, and they won't be able to figure out why. I don't think it's a good idea muting those.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, but deprecation warnings have to do with CCL functionality whereas CCLWarnings mostly have to do with numerical stability, so they represent different things. At the very least I'd add a different flag to separate the verbosity level for deprecation-specific warnings. BTW now that v3 is out, is CCLDeprecationWarning used at all?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, and also, deprecation warnings should be on my default, contrary to other, informative-only warnings, because that's how you tell people that the API will change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

CCLDeprecationWarnings are not used right now. I'll leave them there for the future in any case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As developers we can decide what the priority of the different warnings are. If we decide that specific deprecation warnings are sufficiently important, we can just tag them as "high", and they'll go through the filter.

@tilmantroester I've now added the CCLDeprecationWarnings to the list of warnings that can be suppressed if desired.

Copy link
Contributor

@tilmantroester tilmantroester left a comment

Choose a reason for hiding this comment

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

LGTM!

@tilmantroester
Copy link
Contributor

We should document this somewhere though and make a point to check any model with verbosity="high".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants