Skip to content

Commit

Permalink
convert the deprecation wrapper classes into functions
Browse files Browse the repository at this point in the history
  • Loading branch information
drbenvincent committed Jul 11, 2024
1 parent 6822c61 commit 1cdf7c2
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 110 deletions.
148 changes: 70 additions & 78 deletions causalpy/pymc_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,81 +46,73 @@
warnings.simplefilter("always", DeprecationWarning)


class PrePostNEGD(NewPrePostNEGD):
def __init__(self, *args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.PrePostNEGD is deprecated and will be removed in a future release. Please use causalpy.experiments.PrePostNEGD instead.""",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)


class DifferenceInDifferences(NewDifferenceInDifferences):
def __init__(self, *args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.DifferenceInDifferences is deprecated and will be removed in a future release. Please use causalpy.experiments.DifferenceInDifferences instead.""",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)


class InterruptedTimeSeries(NewInterruptedTimeSeries):
def __init__(self, *args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.InterruptedTimeSeries is deprecated and will be removed in a future release. Please use causalpy.experiments.InterruptedTimeSeries instead.""",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)


class SyntheticControl(NewSyntheticControl):
def __init__(self, *args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.SyntheticControl is deprecated and will be removed in a future release. Please use causalpy.experiments.SyntheticControl instead.""",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)


class RegressionKink(NewRegressionKink):
def __init__(self, *args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.RegressionKink is deprecated and will be removed in a future release. Please use causalpy.experiments.RegressionKink instead.""",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)


class RegressionDiscontinuity(NewRegressionDiscontinuity):
def __init__(self, *args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.RegressionDiscontinuity is deprecated and will be removed in a future release. Please use causalpy.experiments.RegressionDiscontinuity instead.""",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)


class InversePropensityWeighting(NewInversePropensityWeighting):
def __init__(self, *args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.InversePropensityWeighting is deprecated and will be removed in a future release. Please use causalpy.experiments.InversePropensityWeighting instead.""",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)


class InstrumentalVariable(NewInstrumentalVariable):
def __init__(self, *args, **kwargs):
warnings.warn(
"""causalpy.pymc_experiments.InstrumentalVariable is deprecated and will be removed in a future release. Please use causalpy.experiments.InstrumentalVariable instead.""",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
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.""",
DeprecationWarning,
stacklevel=2,
)
return NewPrePostNEGD(*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.""",
DeprecationWarning,
stacklevel=2,
)
return NewDifferenceInDifferences(*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.""",
DeprecationWarning,
stacklevel=2,
)
return NewInterruptedTimeSeries(*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.""",
DeprecationWarning,
stacklevel=2,
)
return NewSyntheticControl(*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.""",
DeprecationWarning,
stacklevel=2,
)
return NewRegressionKink(*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.""",
DeprecationWarning,
stacklevel=2,
)
return NewRegressionDiscontinuity(*args, **kwargs)


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

Check warning on line 104 in causalpy/pymc_experiments.py

View check run for this annotation

Codecov / codecov/patch

causalpy/pymc_experiments.py#L104

Added line #L104 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.""",
DeprecationWarning,
stacklevel=2,
)
return NewInversePropensityWeighting(*args, **kwargs)

Check warning on line 109 in causalpy/pymc_experiments.py

View check run for this annotation

Codecov / codecov/patch

causalpy/pymc_experiments.py#L109

Added line #L109 was not covered by tests


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.""",
DeprecationWarning,
stacklevel=2,
)
return NewInstrumentalVariable(*args, **kwargs)
60 changes: 28 additions & 32 deletions causalpy/skl_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,37 @@
warnings.simplefilter("always", DeprecationWarning)


class SyntheticControl(NewSyntheticControl):
def __init__(self, *args, **kwargs):
warnings.warn(
"""causalpy.skl_experiments.SyntheticControl is deprecated and will be removed in a future release. Please use causalpy.experiments.SyntheticControl instead.""",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
def SyntheticControl(*args, **kwargs):
warnings.warn(
"""causalpy.skl_experiments.SyntheticControl is deprecated and will be removed in a future release. Please use causalpy.experiments.SyntheticControl instead.""",
DeprecationWarning,
stacklevel=2,
)
return NewSyntheticControl(*args, **kwargs)


class DifferenceInDifferences(NewDifferenceInDifferences):
def __init__(self, *args, **kwargs):
warnings.warn(
"""causalpy.skl_experiments.DifferenceInDifferences is deprecated and will be removed in a future release. Please use causalpy.experiments.DifferenceInDifferences instead.""",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
def DifferenceInDifferences(*args, **kwargs):
warnings.warn(
"""causalpy.skl_experiments.DifferenceInDifferences is deprecated and will be removed in a future release. Please use causalpy.experiments.DifferenceInDifferences instead.""",
DeprecationWarning,
stacklevel=2,
)
return NewDifferenceInDifferences(*args, **kwargs)


class InterruptedTimeSeries(NewInterruptedTimeSeries):
def __init__(self, *args, **kwargs):
warnings.warn(
"""causalpy.skl_experiments.InterruptedTimeSeries is deprecated and will be removed in a future release. Please use causalpy.experiments.InterruptedTimeSeries instead.""",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
def InterruptedTimeSeries(*args, **kwargs):
warnings.warn(
"""causalpy.skl_experiments.InterruptedTimeSeries is deprecated and will be removed in a future release. Please use causalpy.experiments.InterruptedTimeSeries instead.""",
DeprecationWarning,
stacklevel=2,
)
return NewInterruptedTimeSeries(*args, **kwargs)


class RegressionDiscontinuity(NewRegressionDiscontinuity):
def __init__(self, *args, **kwargs):
warnings.warn(
"""causalpy.skl_experiments.RegressionDiscontinuity is deprecated and will be removed in a future release. Please use causalpy.experiments.RegressionDiscontinuity instead.""",
DeprecationWarning,
stacklevel=2,
)
super().__init__(*args, **kwargs)
def RegressionDiscontinuity(*args, **kwargs):
warnings.warn(
"""causalpy.skl_experiments.RegressionDiscontinuity is deprecated and will be removed in a future release. Please use causalpy.experiments.RegressionDiscontinuity instead.""",
DeprecationWarning,
stacklevel=2,
)
return NewRegressionDiscontinuity(*args, **kwargs)
Binary file modified docs/source/_static/classes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1cdf7c2

Please sign in to comment.