Skip to content

Commit

Permalink
Merge pull request #408 from westford14/westford14/pre-commit-codespell
Browse files Browse the repository at this point in the history
Implement the codespell pre-commit hook
  • Loading branch information
drbenvincent authored Sep 16, 2024
2 parents c584272 + 6aadfe4 commit f0ffe8d
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 17 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ repos:
# needed to make excludes in pyproject.toml work
# see here https://github.com/econchick/interrogate/issues/60#issuecomment-735436566
pass_filenames: false
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
# Support pyproject.toml configuration
- tomli
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ This is appropriate when you have multiple units, one of which is treated. You b
> The data (treated and untreated units), pre-treatment model fit, and counterfactual (i.e. the synthetic control) are plotted (top). The causal impact is shown as a blue shaded region. The Bayesian analysis shows shaded Bayesian credible regions of the model fit and counterfactual. Also shown is the causal impact (middle) and cumulative causal impact (bottom).
### Geographical lift (Geolift)
We can also use synthetic control methods to analyse data from geographical lift studies. For example, we can try to evaluate the causal impact of an intervention (e.g. a marketing campaign) run in one geographical area by using control geographical areas which are similar to the intervention area but which did not recieve the specific marketing intervention.
We can also use synthetic control methods to analyse data from geographical lift studies. For example, we can try to evaluate the causal impact of an intervention (e.g. a marketing campaign) run in one geographical area by using control geographical areas which are similar to the intervention area but which did not receive the specific marketing intervention.

### ANCOVA

Expand Down
4 changes: 2 additions & 2 deletions causalpy/data/simulate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def generate_ancova_data(
N=200, pre_treatment_means=np.array([10, 12]), treatment_effect=2, sigma=1
):
"""
Generate ANCOVA eample data
Generate ANCOVA example data
Example
--------
Expand Down Expand Up @@ -440,7 +440,7 @@ def generate_seasonality(n=12, amplitude=1, length_scale=0.5):


def periodic_kernel(x1, x2, period=1, length_scale=1, amplitude=1):
"""Generate a periodic kernal for gaussian process"""
"""Generate a periodic kernel for gaussian process"""
return amplitude**2 * np.exp(
-2 * np.sin(np.pi * np.abs(x1 - x2) / period) ** 2 / length_scale**2
)
Expand Down
2 changes: 1 addition & 1 deletion causalpy/experiments/instrumental_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class InstrumentalVariable(BaseExperiment):
:param model: A PyMC model
:param priors: An optional dictionary of priors for the
mus and sigmas of both regressions. If priors are not
specified we will substitue MLE estimates for the beta
specified we will substitute MLE estimates for the beta
coefficients. Greater control can be achieved
by specifying the priors directly e.g. priors = {
"mus": [0, 0],
Expand Down
2 changes: 1 addition & 1 deletion causalpy/experiments/inverse_propensity_weighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def make_doubly_robust_adjustment(self, ps):
m1 = sk_lin_reg().fit(X[t == 1].astype(float), self.y[t == 1])
m0_pred = m0.predict(X)
m1_pred = m1.predict(X)
## Compromise between outcome and treatement assignment model
## Compromise between outcome and treatment assignment model
weighted_outcome0 = (1 - t) * (self.y - m0_pred) / (1 - X["ps"]) + m0_pred
weighted_outcome1 = t * (self.y - m1_pred) / X["ps"] + m1_pred
return weighted_outcome0, weighted_outcome1, None, None
Expand Down
4 changes: 2 additions & 2 deletions causalpy/experiments/prepostfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class InterruptedTimeSeries(PrePostFit):
:param data:
A pandas dataframe
:param treatment_time:
The time when treatment occured, should be in reference to the data index
The time when treatment occurred, should be in reference to the data index
:param formula:
A statistical model formula
:param model:
Expand Down Expand Up @@ -352,7 +352,7 @@ class SyntheticControl(PrePostFit):
:param data:
A pandas dataframe
:param treatment_time:
The time when treatment occured, should be in reference to the data index
The time when treatment occurred, should be in reference to the data index
:param formula:
A statistical model formula
:param model:
Expand Down
2 changes: 1 addition & 1 deletion causalpy/plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def plot_xY(
ax=ax,
**plot_hdi_kwargs,
)
# Return handle to patch. We get a list of the childen of the axis. Filter for just
# Return handle to patch. We get a list of the children of the axis. Filter for just
# the PolyCollection objects. Take the last one.
h_patch = list(
filter(lambda x: isinstance(x, PolyCollection), ax_hdi.get_children())
Expand Down
2 changes: 1 addition & 1 deletion causalpy/pymc_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


class PyMCModel(pm.Model):
"""A wraper class for PyMC models. This provides a scikit-learn like interface with
"""A wrapper class for PyMC models. This provides a scikit-learn like interface with
methods like `fit`, `predict`, and `score`. It also provides other methods which are
useful for causal inference.
Expand Down
2 changes: 1 addition & 1 deletion causalpy/tests/test_pymc_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_idata_property():
@pytest.mark.parametrize("seed", seeds)
def test_result_reproducibility(seed):
"""Test that we can reproduce the results from the model. We could in theory test
this with all the model and experiment types, but what is being targetted is
this with all the model and experiment types, but what is being targeted is
the PyMCModel.fit method, so we should be safe testing with just one model. Here
we use the DifferenceInDifferences experiment class."""
# Load the data
Expand Down
4 changes: 4 additions & 0 deletions docs/source/.codespell/codespell-whitelist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
nD
CACE
compliers
complier
2 changes: 1 addition & 1 deletion docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ This is appropriate when you have multiple units, one of which is treated. You b
![Synthetic Control](./_static/synthetic_control_pymc.svg)

### Geographical Lift / Geolift
We can also use synthetic control methods to analyse data from geographical lift studies. For example, we can try to evaluate the causal impact of an intervention (e.g. a marketing campaign) run in one geographical area by using control geographical areas which are similar to the intervention area but which did not recieve the specific marketing intervention.
We can also use synthetic control methods to analyse data from geographical lift studies. For example, we can try to evaluate the causal impact of an intervention (e.g. a marketing campaign) run in one geographical area by using control geographical areas which are similar to the intervention area but which did not receive the specific marketing intervention.

### ANCOVA

Expand Down
10 changes: 5 additions & 5 deletions docs/source/knowledgebase/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Glossary

Average treatment effect
ATE
The average treatement effect across all units.
The average treatment effect across all units.

Average treatment effect on the treated
ATT
The average effect of the treatment on the units that recieved it. Also called Treatment on the treated.
The average effect of the treatment on the units that received it. Also called Treatment on the treated.

Change score analysis
A statistical procedure where the outcome variable is the difference between the posttest and protest scores.
Expand Down Expand Up @@ -48,7 +48,7 @@ Glossary

Local Average Treatment effect
LATE
Also known asthe complier average causal effect (CACE), is the effect of a treatment for subjects who comply with the experimental treatment assigned to their sample group. It is the quantity we're estimating in IV designs.
Also known as the complier average causal effect (CACE), is the effect of a treatment for subjects who comply with the experimental treatment assigned to their sample group. It is the quantity we're estimating in IV designs.

Non-equivalent group designs
NEGD
Expand Down Expand Up @@ -76,7 +76,7 @@ Glossary
Where units are assigned to conditions at random.

Randomized experiment
An emprical comparison used to estimate the effects of treatments where units are assigned to treatment conditions randomly.
An empirical comparison used to estimate the effects of treatments where units are assigned to treatment conditions randomly.

Regression discontinuity design
RDD
Expand All @@ -96,7 +96,7 @@ Glossary

Treatment on the treated effect
TOT
The average effect of the treatment on the units that recieved it. Also called the average treatment effect on the treated (ATT).
The average effect of the treatment on the units that received it. Also called the average treatment effect on the treated (ATT).

Treatment effect
The difference in outcomes between what happened after a treatment is implemented and what would have happened (see Counterfactual) if the treatment had not been implemented, assuming everything else had been the same.
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies = [
#
# Similar to `dependencies` above, these must be valid existing projects.
[project.optional-dependencies]
dev = ["pathlib", "pre-commit", "twine", "interrogate"]
dev = ["pathlib", "pre-commit", "twine", "interrogate", "codespell"]
docs = [
"ipykernel",
"daft",
Expand Down Expand Up @@ -122,3 +122,7 @@ badge-format = "svg"
extend-select = [
"I", # isort
]

[tool.codespell]
ignore-words = "./docs/source/.codespell/codespell-whitelist.txt"
skip = "*.ipynb,*.csv,pyproject.toml,docs/source/.codespell/codespell-whitelist.txt"

0 comments on commit f0ffe8d

Please sign in to comment.