Skip to content

Commit 01ce582

Browse files
committed
improve deprecation warnings
1 parent 3f9763a commit 01ce582

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

causalpy/pymc_experiments.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@
4444

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

4850

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

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

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

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

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

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

103117
def InversePropensityWeighting(*args, **kwargs):
104118
warnings.warn(
105-
"""causalpy.pymc_experiments.InversePropensityWeighting is deprecated and will be removed in a future release. Please use causalpy.experiments.InversePropensityWeighting instead.""",
119+
f"""{RED}cp.pymc_experiments.InversePropensityWeighting is deprecated and will be removed in a future release. Please use:
120+
import causalpy as cp
121+
cp.InversePropensityWeighting(...){RESET}""",
106122
DeprecationWarning,
107123
stacklevel=2,
108124
)
@@ -111,7 +127,9 @@ def InversePropensityWeighting(*args, **kwargs):
111127

112128
def InstrumentalVariable(*args, **kwargs):
113129
warnings.warn(
114-
"""causalpy.pymc_experiments.InstrumentalVariable is deprecated and will be removed in a future release. Please use causalpy.experiments.InstrumentalVariable instead.""",
130+
f"""{RED}cp.pymc_experiments.InstrumentalVariable is deprecated and will be removed in a future release. Please use:
131+
import causalpy as cp
132+
cp.InstrumentalVariable(...){RESET}""",
115133
DeprecationWarning,
116134
stacklevel=2,
117135
)

0 commit comments

Comments
 (0)