Skip to content

Commit 1cdf7c2

Browse files
committed
convert the deprecation wrapper classes into functions
1 parent 6822c61 commit 1cdf7c2

File tree

3 files changed

+98
-110
lines changed

3 files changed

+98
-110
lines changed

causalpy/pymc_experiments.py

Lines changed: 70 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -46,81 +46,73 @@
4646
warnings.simplefilter("always", DeprecationWarning)
4747

4848

49-
class PrePostNEGD(NewPrePostNEGD):
50-
def __init__(self, *args, **kwargs):
51-
warnings.warn(
52-
"""causalpy.pymc_experiments.PrePostNEGD is deprecated and will be removed in a future release. Please use causalpy.experiments.PrePostNEGD instead.""",
53-
DeprecationWarning,
54-
stacklevel=2,
55-
)
56-
super().__init__(*args, **kwargs)
57-
58-
59-
class DifferenceInDifferences(NewDifferenceInDifferences):
60-
def __init__(self, *args, **kwargs):
61-
warnings.warn(
62-
"""causalpy.pymc_experiments.DifferenceInDifferences is deprecated and will be removed in a future release. Please use causalpy.experiments.DifferenceInDifferences instead.""",
63-
DeprecationWarning,
64-
stacklevel=2,
65-
)
66-
super().__init__(*args, **kwargs)
67-
68-
69-
class InterruptedTimeSeries(NewInterruptedTimeSeries):
70-
def __init__(self, *args, **kwargs):
71-
warnings.warn(
72-
"""causalpy.pymc_experiments.InterruptedTimeSeries is deprecated and will be removed in a future release. Please use causalpy.experiments.InterruptedTimeSeries instead.""",
73-
DeprecationWarning,
74-
stacklevel=2,
75-
)
76-
super().__init__(*args, **kwargs)
77-
78-
79-
class SyntheticControl(NewSyntheticControl):
80-
def __init__(self, *args, **kwargs):
81-
warnings.warn(
82-
"""causalpy.pymc_experiments.SyntheticControl is deprecated and will be removed in a future release. Please use causalpy.experiments.SyntheticControl instead.""",
83-
DeprecationWarning,
84-
stacklevel=2,
85-
)
86-
super().__init__(*args, **kwargs)
87-
88-
89-
class RegressionKink(NewRegressionKink):
90-
def __init__(self, *args, **kwargs):
91-
warnings.warn(
92-
"""causalpy.pymc_experiments.RegressionKink is deprecated and will be removed in a future release. Please use causalpy.experiments.RegressionKink instead.""",
93-
DeprecationWarning,
94-
stacklevel=2,
95-
)
96-
super().__init__(*args, **kwargs)
97-
98-
99-
class RegressionDiscontinuity(NewRegressionDiscontinuity):
100-
def __init__(self, *args, **kwargs):
101-
warnings.warn(
102-
"""causalpy.pymc_experiments.RegressionDiscontinuity is deprecated and will be removed in a future release. Please use causalpy.experiments.RegressionDiscontinuity instead.""",
103-
DeprecationWarning,
104-
stacklevel=2,
105-
)
106-
super().__init__(*args, **kwargs)
107-
108-
109-
class InversePropensityWeighting(NewInversePropensityWeighting):
110-
def __init__(self, *args, **kwargs):
111-
warnings.warn(
112-
"""causalpy.pymc_experiments.InversePropensityWeighting is deprecated and will be removed in a future release. Please use causalpy.experiments.InversePropensityWeighting instead.""",
113-
DeprecationWarning,
114-
stacklevel=2,
115-
)
116-
super().__init__(*args, **kwargs)
117-
118-
119-
class InstrumentalVariable(NewInstrumentalVariable):
120-
def __init__(self, *args, **kwargs):
121-
warnings.warn(
122-
"""causalpy.pymc_experiments.InstrumentalVariable is deprecated and will be removed in a future release. Please use causalpy.experiments.InstrumentalVariable instead.""",
123-
DeprecationWarning,
124-
stacklevel=2,
125-
)
126-
super().__init__(*args, **kwargs)
49+
def PrePostNEGD(*args, **kwargs):
50+
warnings.warn(
51+
"""causalpy.pymc_experiments.PrePostNEGD is deprecated and will be removed in a future release. Please use causalpy.experiments.PrePostNEGD instead.""",
52+
DeprecationWarning,
53+
stacklevel=2,
54+
)
55+
return NewPrePostNEGD(*args, **kwargs)
56+
57+
58+
def DifferenceInDifferences(*args, **kwargs):
59+
warnings.warn(
60+
"""causalpy.pymc_experiments.DifferenceInDifferences is deprecated and will be removed in a future release. Please use causalpy.experiments.DifferenceInDifferences instead.""",
61+
DeprecationWarning,
62+
stacklevel=2,
63+
)
64+
return NewDifferenceInDifferences(*args, **kwargs)
65+
66+
67+
def InterruptedTimeSeries(*args, **kwargs):
68+
warnings.warn(
69+
"""causalpy.pymc_experiments.InterruptedTimeSeries is deprecated and will be removed in a future release. Please use causalpy.experiments.InterruptedTimeSeries instead.""",
70+
DeprecationWarning,
71+
stacklevel=2,
72+
)
73+
return NewInterruptedTimeSeries(*args, **kwargs)
74+
75+
76+
def SyntheticControl(*args, **kwargs):
77+
warnings.warn(
78+
"""causalpy.pymc_experiments.SyntheticControl is deprecated and will be removed in a future release. Please use causalpy.experiments.SyntheticControl instead.""",
79+
DeprecationWarning,
80+
stacklevel=2,
81+
)
82+
return NewSyntheticControl(*args, **kwargs)
83+
84+
85+
def RegressionKink(*args, **kwargs):
86+
warnings.warn(
87+
"""causalpy.pymc_experiments.RegressionKink is deprecated and will be removed in a future release. Please use causalpy.experiments.RegressionKink instead.""",
88+
DeprecationWarning,
89+
stacklevel=2,
90+
)
91+
return NewRegressionKink(*args, **kwargs)
92+
93+
94+
def RegressionDiscontinuity(*args, **kwargs):
95+
warnings.warn(
96+
"""causalpy.pymc_experiments.RegressionDiscontinuity is deprecated and will be removed in a future release. Please use causalpy.experiments.RegressionDiscontinuity instead.""",
97+
DeprecationWarning,
98+
stacklevel=2,
99+
)
100+
return NewRegressionDiscontinuity(*args, **kwargs)
101+
102+
103+
def InversePropensityWeighting(*args, **kwargs):
104+
warnings.warn(
105+
"""causalpy.pymc_experiments.InversePropensityWeighting is deprecated and will be removed in a future release. Please use causalpy.experiments.InversePropensityWeighting instead.""",
106+
DeprecationWarning,
107+
stacklevel=2,
108+
)
109+
return NewInversePropensityWeighting(*args, **kwargs)
110+
111+
112+
def InstrumentalVariable(*args, **kwargs):
113+
warnings.warn(
114+
"""causalpy.pymc_experiments.InstrumentalVariable is deprecated and will be removed in a future release. Please use causalpy.experiments.InstrumentalVariable instead.""",
115+
DeprecationWarning,
116+
stacklevel=2,
117+
)
118+
return NewInstrumentalVariable(*args, **kwargs)

causalpy/skl_experiments.py

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,37 @@
3838
warnings.simplefilter("always", DeprecationWarning)
3939

4040

41-
class SyntheticControl(NewSyntheticControl):
42-
def __init__(self, *args, **kwargs):
43-
warnings.warn(
44-
"""causalpy.skl_experiments.SyntheticControl is deprecated and will be removed in a future release. Please use causalpy.experiments.SyntheticControl instead.""",
45-
DeprecationWarning,
46-
stacklevel=2,
47-
)
48-
super().__init__(*args, **kwargs)
41+
def SyntheticControl(*args, **kwargs):
42+
warnings.warn(
43+
"""causalpy.skl_experiments.SyntheticControl is deprecated and will be removed in a future release. Please use causalpy.experiments.SyntheticControl instead.""",
44+
DeprecationWarning,
45+
stacklevel=2,
46+
)
47+
return NewSyntheticControl(*args, **kwargs)
4948

5049

51-
class DifferenceInDifferences(NewDifferenceInDifferences):
52-
def __init__(self, *args, **kwargs):
53-
warnings.warn(
54-
"""causalpy.skl_experiments.DifferenceInDifferences is deprecated and will be removed in a future release. Please use causalpy.experiments.DifferenceInDifferences instead.""",
55-
DeprecationWarning,
56-
stacklevel=2,
57-
)
58-
super().__init__(*args, **kwargs)
50+
def DifferenceInDifferences(*args, **kwargs):
51+
warnings.warn(
52+
"""causalpy.skl_experiments.DifferenceInDifferences is deprecated and will be removed in a future release. Please use causalpy.experiments.DifferenceInDifferences instead.""",
53+
DeprecationWarning,
54+
stacklevel=2,
55+
)
56+
return NewDifferenceInDifferences(*args, **kwargs)
5957

6058

61-
class InterruptedTimeSeries(NewInterruptedTimeSeries):
62-
def __init__(self, *args, **kwargs):
63-
warnings.warn(
64-
"""causalpy.skl_experiments.InterruptedTimeSeries is deprecated and will be removed in a future release. Please use causalpy.experiments.InterruptedTimeSeries instead.""",
65-
DeprecationWarning,
66-
stacklevel=2,
67-
)
68-
super().__init__(*args, **kwargs)
59+
def InterruptedTimeSeries(*args, **kwargs):
60+
warnings.warn(
61+
"""causalpy.skl_experiments.InterruptedTimeSeries is deprecated and will be removed in a future release. Please use causalpy.experiments.InterruptedTimeSeries instead.""",
62+
DeprecationWarning,
63+
stacklevel=2,
64+
)
65+
return NewInterruptedTimeSeries(*args, **kwargs)
6966

7067

71-
class RegressionDiscontinuity(NewRegressionDiscontinuity):
72-
def __init__(self, *args, **kwargs):
73-
warnings.warn(
74-
"""causalpy.skl_experiments.RegressionDiscontinuity is deprecated and will be removed in a future release. Please use causalpy.experiments.RegressionDiscontinuity instead.""",
75-
DeprecationWarning,
76-
stacklevel=2,
77-
)
78-
super().__init__(*args, **kwargs)
68+
def RegressionDiscontinuity(*args, **kwargs):
69+
warnings.warn(
70+
"""causalpy.skl_experiments.RegressionDiscontinuity is deprecated and will be removed in a future release. Please use causalpy.experiments.RegressionDiscontinuity instead.""",
71+
DeprecationWarning,
72+
stacklevel=2,
73+
)
74+
return NewRegressionDiscontinuity(*args, **kwargs)

docs/source/_static/classes.png

-44.1 KB
Loading

0 commit comments

Comments
 (0)