Skip to content

Commit 032d316

Browse files
committed
#53 autodoc problems seem resolved. Add more docstrings
1 parent 2d2d7d6 commit 032d316

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

causalpy/pymc_experiments.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ class InterruptedTimeSeries(TimeSeriesExperiment):
127127
class DifferenceInDifferences(ExperimentalDesign):
128128
"""A class to analyse data from Difference in Difference settings.
129129
130-
.. Note::
130+
.. note::
131+
132+
There is no pre/post intervention data distinction for DiD, we fit all the data available.
131133
132-
There is no pre/post intervention data distinction for DiD, we fit all the data available.
133134
"""
134135

135136
def __init__(
@@ -287,9 +288,9 @@ class RegressionDiscontinuity(ExperimentalDesign):
287288
"""
288289
A class to analyse regression discontinuity experiments.
289290
290-
.. Note::
291+
.. note::
291292
292-
There is no pre/post intervention data distinction for DiD, we fit all the data available.
293+
There is no pre/post intervention data distinction for the regression discontinuity design, we fit all the data available.
293294
"""
294295

295296
def __init__(
@@ -355,8 +356,11 @@ def __init__(
355356
)
356357

357358
def _is_treated(self, x):
358-
"""Returns true is `x` is greater than or equal to the treatment threshold.
359-
Assumes treatment is given to those ABOVE the treatment threshold.
359+
"""Returns ``True`` if `x` is greater than or equal to the treatment threshold.
360+
361+
.. warning::
362+
363+
Assumes treatment is given to those ABOVE the treatment threshold.
360364
"""
361365
return np.greater_equal(x, self.treatment_threshold)
362366

causalpy/skl_experiments.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99

1010
class ExperimentalDesign:
11+
"""Base class for experiment designs"""
12+
1113
prediction_model = None
1214

1315
def __init__(self, prediction_model=None, **kwargs):
@@ -143,11 +145,16 @@ def plot_coeffs(self):
143145

144146

145147
class InterruptedTimeSeries(TimeSeriesExperiment):
148+
"""A wrapper around the TimeSeriesExperiment class"""
149+
146150
pass
147151

148152

149153
class SyntheticControl(TimeSeriesExperiment):
154+
"""A wrapper around the TimeSeriesExperiment class"""
155+
150156
def plot(self):
157+
"""Plot the results"""
151158
fig, ax = super().plot()
152159
# plot control units as well
153160
ax[0].plot(self.datapre.index, self.pre_X, "-", c=[0.8, 0.8, 0.8], zorder=1)
@@ -156,7 +163,11 @@ def plot(self):
156163

157164

158165
class DifferenceInDifferences(ExperimentalDesign):
159-
"""Note: there is no pre/post intervention data distinction for DiD, we fit all the data available."""
166+
"""
167+
.. note::
168+
169+
There is no pre/post intervention data distinction for DiD, we fit all the data available.
170+
"""
160171

161172
def __init__(
162173
self,
@@ -210,6 +221,7 @@ def __init__(
210221
self.causal_impact = self.y_pred_treatment[1] - self.y_pred_counterfactual[0]
211222

212223
def plot(self):
224+
"""Plot results"""
213225
fig, ax = plt.subplots()
214226

215227
# Plot raw data
@@ -279,7 +291,14 @@ def plot(self):
279291

280292

281293
class RegressionDiscontinuity(ExperimentalDesign):
282-
"""Note: there is no pre/post intervention data distinction, we fit all the data available."""
294+
"""
295+
Analyse data from regression discontinuity experiments.
296+
297+
.. note::
298+
299+
There is no pre/post intervention data distinction for the regression discontinuity design, we fit all the data available.
300+
301+
"""
283302

284303
def __init__(
285304
self,
@@ -340,6 +359,12 @@ def __init__(
340359
)
341360

342361
def _is_treated(self, x):
362+
"""Returns ``True`` if `x` is greater than or equal to the treatment threshold.
363+
364+
.. warning::
365+
366+
Assumes treatment is given to those ABOVE the treatment threshold.
367+
"""
343368
return np.greater_equal(x, self.treatment_threshold)
344369

345370
def plot(self):

causalpy/skl_models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
class WeightedProportion(LinearModel, RegressorMixin):
1010
"""
1111
Model which minimises sum squared error subject to:
12-
- all weights are bound between 0-1
13-
- weights sum to 1.
12+
13+
- All weights are bound between 0-1
14+
- Weights sum to 1.
1415
1516
Inspiration taken from this blog post
1617
https://towardsdatascience.com/understanding-synthetic-control-methods-dd9a291885a1

0 commit comments

Comments
 (0)