Skip to content

Commit c48dd97

Browse files
committed
resolve conflicts with main
2 parents f2579f1 + 491adc1 commit c48dd97

32 files changed

+1756
-1330
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
exclude: &exclude_pattern 'iv_weak_instruments.ipynb'
2626
args: ["--maxkb=1500"]
2727
- repo: https://github.com/astral-sh/ruff-pre-commit
28-
rev: v0.11.10
28+
rev: v0.11.13
2929
hooks:
3030
# Run the linter
3131
- id: ruff

CONTRIBUTING.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,19 @@ We recommend that your contribution complies with the following guidelines befor
167167

168168
## Building the documentation locally
169169

170-
A local build of the docs is achieved by:
170+
To build the documentation, run from the **project root**:
171171

172172
```bash
173-
cd docs
174173
make html
175174
```
176-
177-
Sometimes not all changes are recognised. In that case run this (again from within the `docs` folder):
178-
175+
To clean and rebuild the documentation from scratch:
179176
```bash
180-
make clean && make html
177+
make cleandocs
178+
make html
181179
```
180+
Docs are built in docs/_build/html, but these docs are not committed to the GitHub repository due to .gitignore.
182181

183-
Docs are built in `docs/_build`, but these docs are _not_ committed to the GitHub repository due to `.gitignore`.
182+
📌 Note: The previous docs/Makefile has been removed. Please use only the root-level Makefile for documentation commands
184183

185184
## Overview of code structure
186185

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: init lint check_lint test
1+
.PHONY: init lint check_lint test uml html cleandocs
22

33
init:
44
python -m pip install -e . --no-deps
@@ -20,3 +20,12 @@ test:
2020

2121
uml:
2222
pyreverse -o png causalpy --output-directory docs/source/_static --ignore tests
23+
24+
# Docs build commands
25+
26+
html:
27+
sphinx-build -b html docs/source docs/_build
28+
29+
cleandocs:
30+
rm -rf docs/_build
31+
rm -rf docs/source/api/generated

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
----
66

7-
![Build Status](https://github.com/pymc-labs/CausalPy/workflows/ci/badge.svg?branch=main)
7+
![Build Status](https://github.com/pymc-labs/CausalPy/actions/workflows/ci.yml/badge.svg?branch=main)
88
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
99
[![PyPI version](https://badge.fury.io/py/CausalPy.svg)](https://badge.fury.io/py/CausalPy)
1010
![GitHub Repo stars](https://img.shields.io/github/stars/pymc-labs/causalpy?style=social)

causalpy/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
# limitations under the License.
1414
import arviz as az
1515

16-
import causalpy.pymc_experiments as pymc_experiments # to be deprecated
1716
import causalpy.pymc_models as pymc_models
18-
import causalpy.skl_experiments as skl_experiments # to be deprecated
1917
import causalpy.skl_models as skl_models
2018
from causalpy.skl_models import create_causalpy_compatible_class
2119
from causalpy.version import __version__
@@ -43,11 +41,9 @@
4341
"InversePropensityWeighting",
4442
"load_data",
4543
"PrePostNEGD",
46-
"pymc_experiments", # to be deprecated
4744
"pymc_models",
4845
"RegressionDiscontinuity",
4946
"RegressionKink",
50-
"skl_experiments", # to be deprecated
5147
"skl_models",
5248
"SyntheticControl",
5349
]

causalpy/experiments/diff_in_diff.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import numpy as np
2020
import pandas as pd
2121
import seaborn as sns
22+
import xarray as xr
2223
from matplotlib import pyplot as plt
2324
from patsy import build_design_matrices, dmatrices
2425
from sklearn.base import RegressorMixin
@@ -87,7 +88,8 @@ def __init__(
8788
**kwargs,
8889
) -> None:
8990
super().__init__(model=model)
90-
91+
# rename the index to "obs_ind"
92+
data.index.name = "obs_ind"
9193
self.data = data
9294
self.expt_type = "Difference in Differences"
9395
self.formula = formula
@@ -102,6 +104,21 @@ def __init__(
102104
self.y, self.X = np.asarray(y), np.asarray(X)
103105
self.outcome_variable_name = y.design_info.column_names[0]
104106

107+
# turn into xarray.DataArray's
108+
self.X = xr.DataArray(
109+
self.X,
110+
dims=["obs_ind", "coeffs"],
111+
coords={
112+
"obs_ind": np.arange(self.X.shape[0]),
113+
"coeffs": self.labels,
114+
},
115+
)
116+
self.y = xr.DataArray(
117+
self.y[:, 0],
118+
dims=["obs_ind"],
119+
coords={"obs_ind": np.arange(self.y.shape[0])},
120+
)
121+
105122
# fit model
106123
if isinstance(self.model, PyMCModel):
107124
COORDS = {"coeffs": self.labels, "obs_ind": np.arange(self.X.shape[0])}
@@ -183,13 +200,15 @@ def __init__(
183200
)
184201
elif isinstance(self.model, RegressorMixin):
185202
# This is the coefficient on the interaction term
186-
# TODO: THIS IS NOT YET CORRECT ?????
203+
# TODO: CHECK FOR CORRECTNESS
187204
self.causal_impact = (
188205
self.y_pred_treatment[1] - self.y_pred_counterfactual[0]
189-
)[0]
206+
)
190207
else:
191208
raise ValueError("Model type not recognized")
192209

210+
return
211+
193212
def input_validation(self):
194213
"""Validate the input data and model formula for correctness"""
195214
if "post_treatment" not in self.formula:

0 commit comments

Comments
 (0)