Skip to content

Commit df0c0f9

Browse files
committed
Merge branch 'main' into uml-autoupdate
2 parents f0e4bb1 + c0ea8a5 commit df0c0f9

11 files changed

+24
-21
lines changed

.github/workflows/release.yml

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: PyPI release
2+
23
on:
34
workflow_dispatch:
45
pull_request:
@@ -23,28 +24,30 @@ jobs:
2324
run: |
2425
pip install build
2526
python -m build
27+
ls dist # List the contents of the dist directory
2628
- name: Check the sdist installs and imports
2729
run: |
2830
mkdir -p test-sdist
2931
cd test-sdist
3032
python -m venv venv-sdist
3133
venv-sdist/bin/python -m pip install ../dist/causalpy*.tar.gz
3234
echo "Checking import and version number (on release)"
33-
venv-sdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else causalpy.__version__; print(causalpy.__version__)"
35+
venv-sdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else causalpy.__version__; print(causalpy.__version__)"
3436
cd ..
3537
- name: Check the bdist installs and imports
3638
run: |
3739
mkdir -p test-bdist
3840
cd test-bdist
3941
python -m venv venv-bdist
40-
venv-bdist/bin/python -m pip install ../dist/CausalPy*.whl
42+
venv-bdist/bin/python -m pip install ../dist/causalpy*.whl
4143
echo "Checking import and version number (on release)"
42-
venv-bdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else causalpy.__version__; print(causalpy.__version__)"
44+
venv-bdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else causalpy.__version__; print(causalpy.__version__)"
4345
cd ..
44-
- uses: actions/upload-artifact@v3
46+
- uses: actions/upload-artifact@v4
4547
with:
4648
name: artifact
4749
path: dist/*
50+
4851
test:
4952
name: Upload to Test PyPI
5053
permissions:
@@ -72,7 +75,7 @@ jobs:
7275
python -m venv venv-test-pypi
7376
venv-test-pypi/bin/python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple causalpy
7477
echo "Checking import and version number"
75-
venv-test-pypi/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}'"
78+
venv-test-pypi/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}'"
7679
7780
publish:
7881
environment: release

.pre-commit-config.yaml

+2-2
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.8.4
28+
rev: v0.9.8
2929
hooks:
3030
# Run the linter
3131
- id: ruff
@@ -42,7 +42,7 @@ repos:
4242
# see here https://github.com/econchick/interrogate/issues/60#issuecomment-735436566
4343
pass_filenames: false
4444
- repo: https://github.com/codespell-project/codespell
45-
rev: v2.3.0
45+
rev: v2.4.1
4646
hooks:
4747
- id: codespell
4848
additional_dependencies:

causalpy/pymc_models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def print_row(
164164
) -> None:
165165
"""Print one row of the coefficient table"""
166166
formatted_name = f" {name: <{max_label_length}}"
167-
formatted_val = f"{round_num(coeff_samples.mean().data, round_to)}, 94% HDI [{round_num(coeff_samples.quantile(0.03).data, round_to)}, {round_num(coeff_samples.quantile(1-0.03).data, round_to)}]" # noqa: E501
167+
formatted_val = f"{round_num(coeff_samples.mean().data, round_to)}, 94% HDI [{round_num(coeff_samples.quantile(0.03).data, round_to)}, {round_num(coeff_samples.quantile(1 - 0.03).data, round_to)}]" # noqa: E501
168168
print(f" {formatted_name} {formatted_val}")
169169

170170
print("Model coefficients:")

causalpy/tests/test_api_stability.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def test_causal_inference_and_discovery_with_python_example():
3636

3737
# Build the model
3838
model = cp.pymc_models.WeightedSumFitter(sample_kwargs=sample_kwargs)
39-
assert isinstance(
40-
model, WeightedSumFitter
41-
), "model is not an instance of WeightedSumFitter"
39+
assert isinstance(model, WeightedSumFitter), (
40+
"model is not an instance of WeightedSumFitter"
41+
)
4242

4343
formula = "twitter ~ 0 + tiktok + linkedin + instagram"
4444

@@ -49,9 +49,9 @@ def test_causal_inference_and_discovery_with_python_example():
4949
formula=formula,
5050
model=model,
5151
)
52-
assert isinstance(
53-
results, SyntheticControl
54-
), "results is not an instance of SyntheticControl"
52+
assert isinstance(results, SyntheticControl), (
53+
"results is not an instance of SyntheticControl"
54+
)
5555

5656
fig, ax = results.plot()
5757
assert isinstance(fig, plt.Figure)

docs/source/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ CausalPy has a broad range of quasi-experimental methods for causal inference:
9696
| Geographical lift | Measures the impact of an intervention in a specific geographic area by comparing it to similar areas without the intervention. Commonly used in marketing to assess regional campaigns. |
9797
| ANCOVA | Analysis of Covariance combines ANOVA and regression to control for the effects of one or more quantitative covariates. Used when comparing group means while controlling for other variables. |
9898
| Differences in Differences | Compares the changes in outcomes over time between a treatment group and a control group. Used in observational studies to estimate causal effects by accounting for time trends. |
99-
| Regression discontinuity | Identifies causal effects by exploiting a cutoff or threshold in an assignment variable. Used when treatment is assigned based on a threshold value of an observed variable, allowing comparison just above and below the cutoff. |
99+
|Regression discontinuity | Identifies causal effects by exploiting a sharp cutoff or threshold in an assignment variable. Used when treatment is assigned based on a threshold value of an observed variable, allowing comparison just above and below the cutoff. |
100100
| Regression kink designs | Focuses on changes in the slope (kinks) of the relationship between variables rather than jumps at cutoff points. Used to identify causal effects when treatment intensity changes at a threshold. |
101101
| Interrupted time series | Analyzes the effect of an intervention by comparing time series data before and after the intervention. Used when data is collected over time and an intervention occurs at a known point, allowing assessment of changes in level or trend. |
102102
| Instrumental variable regression | Addresses endogeneity by using an instrument variable that is correlated with the endogenous explanatory variable but uncorrelated with the error term. Used when explanatory variables are correlated with the error term, providing consistent estimates of causal effects. |

docs/source/notebooks/multi_cell_geolift.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@
10991099
"unpooled_results = []\n",
11001100
"\n",
11011101
"for i, target_geo in enumerate(treated):\n",
1102-
" print(f\"Analyzing test geo: {target_geo} ({i+1} of {len(treated)})\")\n",
1102+
" print(f\"Analyzing test geo: {target_geo} ({i + 1} of {len(treated)})\")\n",
11031103
" formula = f\"{target_geo} ~ 0 + {' + '.join(untreated)}\"\n",
11041104
" print(formula)\n",
11051105
"\n",

docs/source/notebooks/rd_pymc.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"cell_type": "markdown",
66
"metadata": {},
77
"source": [
8-
"# Regression discontinuity with `pymc` models"
8+
"# Sharp regression discontinuity with `pymc` models"
99
]
1010
},
1111
{

docs/source/notebooks/rd_pymc_drinking.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"source": [
88
"# Drinking age - Bayesian analysis\n",
99
"\n",
10-
"This example uses the regression discontinuity design to make claims about the causal effects of the minimum legal drinking age (21 in the USA) upon all cause mortality rates. The dataset is from a study by {cite:t}`carpenter2009effect`."
10+
"This example uses the sharp regression discontinuity design to make claims about the causal effects of the minimum legal drinking age (21 in the USA) upon all cause mortality rates. The dataset is from a study by {cite:t}`carpenter2009effect`."
1111
]
1212
},
1313
{

docs/source/notebooks/rd_skl.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Regression discontinuity with sci-kit learn models"
7+
"# Sharp regression discontinuity with sci-kit learn models"
88
]
99
},
1010
{

docs/source/notebooks/rd_skl_drinking.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"source": [
88
"# Drinking age with a scikit-learn model\n",
99
"\n",
10-
"This example uses the regression discontinuity design to make claims about the causal effects of the minimum legal drinking age (21 in the USA) upon all cause mortality rates. The dataset is from a study by {cite:t}`carpenter2009effect`."
10+
"This example uses the sharp regression discontinuity design to make claims about the causal effects of the minimum legal drinking age (21 in the USA) upon all cause mortality rates. The dataset is from a study by {cite:t}`carpenter2009effect`."
1111
]
1212
},
1313
{

docs/source/notebooks/rkink_pymc.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
" beta = rng.random(5)\n",
109109
" ax[0, col].plot(x, f(x, beta, kink), lw=3)\n",
110110
" ax[1, col].plot(x, np.gradient(f(x, beta, kink), x), lw=3)\n",
111-
" ax[0, col].set(title=f\"Random {col+1}\")\n",
111+
" ax[0, col].set(title=f\"Random {col + 1}\")\n",
112112
" ax[1, col].set(xlabel=\"x\")\n",
113113
"\n",
114114
"ax[0, 0].set(ylabel=\"$y = f(x)$\")\n",

0 commit comments

Comments
 (0)