Skip to content

Warnings verbosity#1213

Merged
damonge merged 8 commits intomasterfrom
warnings_verbosity
Dec 4, 2024
Merged

Warnings verbosity#1213
damonge merged 8 commits intomasterfrom
warnings_verbosity

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.

@@ -40,8 +84,8 @@ def __hash__(self):

@classmethod
def enable(cls):
Copy link
Member

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
Member

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
Member

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
Member

@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
Member

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

@damonge damonge merged commit 5273ca6 into master Dec 4, 2024
@damonge damonge deleted the warnings_verbosity branch December 4, 2024 08:32
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