Skip to content

Commit 94f4861

Browse files
authored
Merge pull request #346 from DoubleML/s-add-pre-commit-ci
Update workflows
2 parents 5b55aa9 + 1d7c832 commit 94f4861

File tree

3 files changed

+64
-65
lines changed

3 files changed

+64
-65
lines changed

.github/workflows/pytest.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,26 @@ jobs:
3434
- uses: actions/checkout@v4
3535
with:
3636
fetch-depth: 2
37+
3738
- name: Set up Python ${{ matrix.config.python-version }}
3839
uses: actions/setup-python@v5
3940
with:
4041
python-version: ${{ matrix.config.python-version }}
42+
4143
- name: Install OpenMP runtime for unit tests with xgboost learners
4244
if: matrix.config.os == 'macOS-latest'
4345
run: brew install libomp
46+
4447
- name: Install dependencies
4548
run: |
4649
python -m pip install --upgrade pip
4750
pip install -e .[dev,rdd]
48-
- name: Lint with ruff
49-
run: |
50-
# stop the build if there are Python syntax errors or undefined names
51-
ruff check . --select E9,F63,F7,F82 --output-format=full --statistics
52-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
53-
ruff check . --exit-zero --line-length 127 --output-format=full --statistics
54-
- name: Check code formatting with black
51+
52+
- name: Run pre-commit checks
5553
run: |
56-
black --check --verbose . || echo "Warning: Code is not formatted according to black"
57-
exit 0
54+
pip install pre-commit
55+
pre-commit run --all-files --show-diff-on-failure
56+
5857
- name: Test with pytest
5958
if: |
6059
matrix.config.os != 'ubuntu-latest' ||

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
hooks:
1818
- id: black
1919
- repo: https://github.com/astral-sh/ruff-pre-commit
20-
rev: v0.11.7
20+
rev: v0.12.3
2121
hooks:
2222
- id: ruff
2323
args: ["--fix", "--output-format=full"]

doubleml/did/did_cs_binary.py

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -28,78 +28,78 @@
2828

2929

3030
class DoubleMLDIDCSBinary(LinearScoreMixin, DoubleML):
31-
"""Double machine learning for difference-in-differences models with repeated cross sections (binary setting in terms of group and time
32-
combinations).
31+
"""Double machine learning for difference-in-differences models with repeated cross sections
32+
(binary setting in terms of group and time combinations).
3333
34-
Parameters
35-
----------
36-
obj_dml_data : :class:`DoubleMLPanelData` object
37-
The :class:`DoubleMLPanelData` object providing the data and specifying the variables for the causal model.
34+
Parameters
35+
----------
36+
obj_dml_data : :class:`DoubleMLPanelData` object
37+
The :class:`DoubleMLPanelData` object providing the data and specifying the variables for the causal model.
3838
39-
g_value : int
40-
The value indicating the treatment group (first period with treatment).
41-
Default is ``None``. This implements the case for the smallest, non-zero value of G.
39+
g_value : int
40+
The value indicating the treatment group (first period with treatment).
41+
Default is ``None``. This implements the case for the smallest, non-zero value of G.
4242
43-
t_value_pre : int
44-
The value indicating the baseline pre-treatment period.
43+
t_value_pre : int
44+
The value indicating the baseline pre-treatment period.
4545
46-
t_value_eval : int
47-
The value indicating the period for evaluation.
46+
t_value_eval : int
47+
The value indicating the period for evaluation.
4848
49-
ml_g : estimator implementing ``fit()`` and ``predict()``
50-
A machine learner implementing ``fit()`` and ``predict()`` methods (e.g.
51-
:py:class:`sklearn.ensemble.RandomForestRegressor`) for the nuisance function :math:`g_0(d,X) = E[Y_1-Y_0|D=d, X]`.
52-
For a binary outcome variable :math:`Y` (with values 0 and 1), a classifier implementing ``fit()`` and
53-
``predict_proba()`` can also be specified. If :py:func:`sklearn.base.is_classifier` returns ``True``,
54-
``predict_proba()`` is used otherwise ``predict()``.
49+
ml_g : estimator implementing ``fit()`` and ``predict()``
50+
A machine learner implementing ``fit()`` and ``predict()`` methods (e.g.
51+
:py:class:`sklearn.ensemble.RandomForestRegressor`) for the nuisance function :math:`g_0(d,X) = E[Y_1-Y_0|D=d, X]`.
52+
For a binary outcome variable :math:`Y` (with values 0 and 1), a classifier implementing ``fit()`` and
53+
``predict_proba()`` can also be specified. If :py:func:`sklearn.base.is_classifier` returns ``True``,
54+
``predict_proba()`` is used otherwise ``predict()``.
5555
56-
ml_m : classifier implementing ``fit()`` and ``predict_proba()``
57-
A machine learner implementing ``fit()`` and ``predict_proba()`` methods (e.g.
58-
:py:class:`sklearn.ensemble.RandomForestClassifier`) for the nuisance function :math:`m_0(X) = E[D=1|X]`.
59-
Only relevant for ``score='observational'``.
56+
ml_m : classifier implementing ``fit()`` and ``predict_proba()``
57+
A machine learner implementing ``fit()`` and ``predict_proba()`` methods (e.g.
58+
:py:class:`sklearn.ensemble.RandomForestClassifier`) for the nuisance function :math:`m_0(X) = E[D=1|X]`.
59+
Only relevant for ``score='observational'``.
6060
61-
control_group : str
62-
Specifies the control group. Either ``'never_treated'`` or ``'not_yet_treated'``.
63-
Default is ``'never_treated'``.
61+
control_group : str
62+
Specifies the control group. Either ``'never_treated'`` or ``'not_yet_treated'``.
63+
Default is ``'never_treated'``.
6464
65-
anticipation_periods : int
66-
Number of anticipation periods. Default is ``0``.
65+
anticipation_periods : int
66+
Number of anticipation periods. Default is ``0``.
6767
68-
n_folds : int
69-
Number of folds.
70-
Default is ``5``.
68+
n_folds : int
69+
Number of folds.
70+
Default is ``5``.
7171
72-
n_rep : int
73-
Number of repetitions for the sample splitting.
74-
Default is ``1``.
72+
n_rep : int
73+
Number of repetitions for the sample splitting.
74+
Default is ``1``.
7575
76-
score : str
77-
A str (``'observational'`` or ``'experimental'``) specifying the score function.
78-
The ``'experimental'`` scores refers to an A/B setting, where the treatment is independent
79-
from the pretreatment covariates.
80-
Default is ``'observational'``.
76+
score : str
77+
A str (``'observational'`` or ``'experimental'``) specifying the score function.
78+
The ``'experimental'`` scores refers to an A/B setting, where the treatment is independent
79+
from the pretreatment covariates.
80+
Default is ``'observational'``.
8181
82-
in_sample_normalization : bool
83-
Indicates whether to use a slightly different normalization from Sant'Anna and Zhao (2020).
84-
Default is ``True``.
82+
in_sample_normalization : bool
83+
Indicates whether to use a slightly different normalization from Sant'Anna and Zhao (2020).
84+
Default is ``True``.
8585
86-
trimming_rule : str
87-
A str (``'truncate'`` is the only choice) specifying the trimming approach.
88-
Default is ``'truncate'``.
86+
trimming_rule : str
87+
A str (``'truncate'`` is the only choice) specifying the trimming approach.
88+
Default is ``'truncate'``.
8989
90-
trimming_threshold : float
91-
The threshold used for trimming.
92-
Default is ``1e-2``.
90+
trimming_threshold : float
91+
The threshold used for trimming.
92+
Default is ``1e-2``.
9393
94-
draw_sample_splitting : bool
95-
Indicates whether the sample splitting should be drawn during initialization of the object.
96-
Default is ``True``.
94+
draw_sample_splitting : bool
95+
Indicates whether the sample splitting should be drawn during initialization of the object.
96+
Default is ``True``.
9797
98-
print_periods : bool
99-
Indicates whether to print information about the evaluated periods.
100-
Default is ``False``.
98+
print_periods : bool
99+
Indicates whether to print information about the evaluated periods.
100+
Default is ``False``.
101101
102-
"""
102+
"""
103103

104104
def __init__(
105105
self,

0 commit comments

Comments
 (0)