Skip to content

Commit

Permalink
improve deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
drbenvincent committed Aug 9, 2024
1 parent 3f9763a commit 01ce582
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions causalpy/pymc_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@

# Ensure deprecation warnings are always shown in Jupyter Notebooks
warnings.simplefilter("always", DeprecationWarning)
RED = "\033[91m"
RESET = "\033[0m"


def PrePostNEGD(*args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.PrePostNEGD is deprecated and will be removed in a future release. Please use causalpy.experiments.PrePostNEGD instead.""",
f"""{RED}cp.pymc_experiments.PrePostNEGD is deprecated and will be removed in a future release. Please use:
import causalpy as cp
cp.PrePostNEGD(...){RESET}""",
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -57,7 +61,9 @@ def PrePostNEGD(*args, **kwargs):

def DifferenceInDifferences(*args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.DifferenceInDifferences is deprecated and will be removed in a future release. Please use causalpy.experiments.DifferenceInDifferences instead.""",
f"""{RED}cp.pymc_experiments.DifferenceInDifferences is deprecated and will be removed in a future release. Please use:
import causalpy as cp
cp.DifferenceInDifferences(...){RESET}""",
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -66,7 +72,9 @@ def DifferenceInDifferences(*args, **kwargs):

def InterruptedTimeSeries(*args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.InterruptedTimeSeries is deprecated and will be removed in a future release. Please use causalpy.experiments.InterruptedTimeSeries instead.""",
f"""{RED}cp.pymc_experiments.InterruptedTimeSeries is deprecated and will be removed in a future release. Please use:
import causalpy as cp
cp.InterruptedTimeSeries(...){RESET}""",
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -75,7 +83,9 @@ def InterruptedTimeSeries(*args, **kwargs):

def SyntheticControl(*args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.SyntheticControl is deprecated and will be removed in a future release. Please use causalpy.experiments.SyntheticControl instead.""",
f"""{RED}cp.pymc_experiments.SyntheticControl is deprecated and will be removed in a future release. Please use:
import causalpy as cp
cp.SyntheticControl(...){RESET}""",
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -84,7 +94,9 @@ def SyntheticControl(*args, **kwargs):

def RegressionKink(*args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.RegressionKink is deprecated and will be removed in a future release. Please use causalpy.experiments.RegressionKink instead.""",
f"""{RED}cp.pymc_experiments.RegressionKink is deprecated and will be removed in a future release. Please use:
import causalpy as cp
cp.RegressionKink(...){RESET}""",
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -93,7 +105,9 @@ def RegressionKink(*args, **kwargs):

def RegressionDiscontinuity(*args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.RegressionDiscontinuity is deprecated and will be removed in a future release. Please use causalpy.experiments.RegressionDiscontinuity instead.""",
f"""{RED}cp.pymc_experiments.RegressionDiscontinuity is deprecated and will be removed in a future release. Please use:
import causalpy as cp
cp.RegressionDiscontinuity(...){RESET}""",
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -102,7 +116,9 @@ def RegressionDiscontinuity(*args, **kwargs):

def InversePropensityWeighting(*args, **kwargs):
warnings.warn(

Check warning on line 118 in causalpy/pymc_experiments.py

View check run for this annotation

Codecov / codecov/patch

causalpy/pymc_experiments.py#L118

Added line #L118 was not covered by tests
"""causalpy.pymc_experiments.InversePropensityWeighting is deprecated and will be removed in a future release. Please use causalpy.experiments.InversePropensityWeighting instead.""",
f"""{RED}cp.pymc_experiments.InversePropensityWeighting is deprecated and will be removed in a future release. Please use:
import causalpy as cp
cp.InversePropensityWeighting(...){RESET}""",
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -111,7 +127,9 @@ def InversePropensityWeighting(*args, **kwargs):

def InstrumentalVariable(*args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.InstrumentalVariable is deprecated and will be removed in a future release. Please use causalpy.experiments.InstrumentalVariable instead.""",
f"""{RED}cp.pymc_experiments.InstrumentalVariable is deprecated and will be removed in a future release. Please use:
import causalpy as cp
cp.InstrumentalVariable(...){RESET}""",
DeprecationWarning,
stacklevel=2,
)
Expand Down

0 comments on commit 01ce582

Please sign in to comment.