Skip to content

Commit

Permalink
check for deprecationwarning
Browse files Browse the repository at this point in the history
  • Loading branch information
damonge committed Nov 22, 2024
1 parent e61a252 commit 5ddbeb5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pyccl/baryons/baccoemu_baryons.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import numpy as np
from copy import deepcopy
from warnings import warn

from .. import Pk2D, CCLDeprecationWarning
from . import Baryons
Expand Down Expand Up @@ -216,8 +215,9 @@ class BaccoemuBaryons(BaryonsBaccoemu):

def __init__(self, *args, **kwargs):
"""This throws a deprecation warning on initialization."""
warn(f"Class {self.__class__.__name__} will be deprecated. " +
f"Please use {BaryonsBaccoemu.__name__} instead.",
CCLDeprecationWarning, stacklevel=2)
from .. import warnings
warnings.warn(f"Class {self.__class__.__name__} will be deprecated. " +
f"Please use {BaryonsBaccoemu.__name__} instead.",
CCLDeprecationWarning, stacklevel=2,
importance='low')
super().__init__(*args, **kwargs)
pass
8 changes: 8 additions & 0 deletions pyccl/tests/test_cclerror.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,11 @@ def test_ccl_warning_verbosity():
with warnings.catch_warnings():
warnings.simplefilter("error")
pyccl.WeakLensingTracer(cosmo, dndz=(z, nz))


def test_ccl_deprecation_warning():
# Switch to high verbosity to catch it
pyccl.update_warning_verbosity("high")
with pytest.warns(pyccl.CCLDeprecationWarning):
pyccl.baryons.BaccoemuBaryons()
pyccl.update_warning_verbosity("low")

0 comments on commit 5ddbeb5

Please sign in to comment.