Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2caeabc
add black formatter configuration
SvenKlaassen Jan 13, 2025
cebd465
add ruff configuration
SvenKlaassen Jan 13, 2025
f369cb2
update ruff configuration
SvenKlaassen Jan 13, 2025
5751524
run ruff for did
SvenKlaassen Jan 13, 2025
030eeae
reformat did dir
SvenKlaassen Jan 13, 2025
f06879d
run ruff for irm
SvenKlaassen Jan 13, 2025
0251a6f
reformat irm dir
SvenKlaassen Jan 13, 2025
36ae8b2
run ruff on plm
SvenKlaassen Jan 13, 2025
1c31e8b
reformat plm
SvenKlaassen Jan 13, 2025
28c64e1
run ruff on rdd
SvenKlaassen Jan 13, 2025
11664a2
format rdd
SvenKlaassen Jan 13, 2025
b55a04f
run ruff on tests
SvenKlaassen Jan 13, 2025
74b6b3f
format tests
SvenKlaassen Jan 13, 2025
fd13e1d
run ruff on utils
SvenKlaassen Jan 13, 2025
b49a526
format utils
SvenKlaassen Jan 13, 2025
f984773
ruff doubleml
SvenKlaassen Jan 13, 2025
68683ac
format doubleml
SvenKlaassen Jan 13, 2025
f95441b
ruff conf.py
SvenKlaassen Jan 13, 2025
0010aaa
format conf.py
SvenKlaassen Jan 13, 2025
e23134b
reformat with ruff
SvenKlaassen Jan 13, 2025
6144282
Update pyproject.toml
SvenKlaassen Jan 13, 2025
43fba26
update workflow to include black and ruff
SvenKlaassen Jan 13, 2025
1350005
Update pytest.yml
SvenKlaassen Jan 13, 2025
308c66c
Update CONTRIBUTING.md
SvenKlaassen Jan 13, 2025
b7b54e6
add pre-commit
SvenKlaassen Jan 13, 2025
7c6c5cd
remove trailing whitespaces
SvenKlaassen Jan 13, 2025
ccced2f
run end-of-file-fixer
SvenKlaassen Jan 13, 2025
72c32d5
add pre-commit hooks to contributing
SvenKlaassen Jan 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/api_docu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ body:
required: true
- type: textarea
attributes:
label: Suggested alternative or fix
label: Suggested alternative or fix
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ body:
import sklearn; print("Scikit-Learn", sklearn.__version__)
```
validations:
required: true
required: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ body:
label: Did you consider alternatives to the proposed solution. If yes, please describe
- type: textarea
attributes:
label: Comments, context or references
label: Comments, context or references
10 changes: 6 additions & 4 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8
pip install -e .[dev,rdd]
- name: Lint with flake8
- name: Lint with ruff
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
ruff check . --select E9,F63,F7,F82 --output-format=full --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
ruff check . --exit-zero --line-length 127 --output-format=full --statistics
- name: Check code formatting with black
run: |
black --check .
- name: Test with pytest
if: |
matrix.config.os != 'ubuntu-latest' ||
Expand Down
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.1
hooks:
- id: ruff
args: ["--fix", "--output-format=full"]
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ enforcement ladder](https://github.com/mozilla/diversity).

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
https://www.contributor-covenant.org/translations.
30 changes: 26 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ $ git merge upstream/main

5. **Install DoubleML in editable mode** (more details can be found
[here](https://docs.doubleml.org/stable/intro/install.html#python-building-the-package-from-source))
via
via
```bash
$ pip install --editable .[dev, rdd]
```
Expand Down Expand Up @@ -119,12 +119,34 @@ $ pytest .
- [x] Check whether your changes adhere to the **PEP8 standards**.
For the check you can use the following code
```bash
$ git diff upstream/main -u -- "*.py" | flake8 --diff --max-line-length=127
$ git diff upstream/main -u -- "*.py" | ruff check --diff
```

- [x] Check wether the code formatting adheres to the **Black code style**
by running
```bash
$ black . --check --diff
```

If your PR is still **work in progress**, please consider marking it a **draft PR**
(see also [here](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)).

### (Optional) Set up pre-commit Hooks

To ensure code quality and consistency before committing your changes, we recommend using [pre-commit hooks](https://pre-commit.com/). Pre-commit hooks will automatically run checks like code formatting and linting on your staged files.

1. **Install hooks**:
If you haven't already, install the required hooks by running:
```bash
$ pre-commit install
```

2. **Run pre-commit manually**:
To run the pre-commit checks manually, use:
```bash
$ pre-commit run --all-files
```

### Unit Tests and Test Coverage
We use the package **pytest for unit testing**.
Unit testing is considered to be a fundamental part of the development workflow.
Expand Down Expand Up @@ -165,7 +187,7 @@ The source code for the website, user guide, example gallery, etc. is available

### Contribute to the API Documentation
The **API documentation** is generated from **docstrings** in the source code.
It can be generated locally (dev requirements sphinx and pydata-sphinx-theme need to be installed) via
It can be generated locally (dev requirements sphinx and pydata-sphinx-theme need to be installed) via
```bash
$ cd doc/
$ make html
Expand All @@ -175,7 +197,7 @@ $ make html
The **documentation of DoubleML** is hosted at [https://docs.doubleml.org](https://docs.doubleml.org).
The **source code** for the website, user guide, example gallery, etc. is available in a **separate repository
[doubleml-docs](https://github.com/DoubleML/doubleml-docs)**.
Changes, issues and PRs for the documentation (except the API documentation) should be discussed in the
Changes, issues and PRs for the documentation (except the API documentation) should be discussed in the
[doubleml-docs](https://github.com/DoubleML/doubleml-docs) repo.
We welcome contributions to the user guide, especially case studies for the
[example gallery](https://docs.doubleml.org/stable/examples/index.html).
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include LICENSE
include pytest.ini
include pytest.ini
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The Python package **DoubleML** provides an implementation of the double / debia
It is built on top of [scikit-learn](https://scikit-learn.org) (Pedregosa et al., 2011).

Note that the Python package was developed together with an R twin based on [mlr3](https://mlr3.mlr-org.com/).
The R package is also available on [GitHub](https://github.com/DoubleML/doubleml-for-r) and
The R package is also available on [GitHub](https://github.com/DoubleML/doubleml-for-r) and
[![CRAN Version](https://www.r-pkg.org/badges/version/DoubleML)](https://cran.r-project.org/package=DoubleML).

## Documentation and Maintenance
Expand All @@ -27,7 +27,7 @@ Bugs can be reported to the issue tracker at

## Main Features

Double / debiased machine learning [(Chernozhukov et al. (2018))](https://doi.org/10.1111/ectj.12097) for
Double / debiased machine learning [(Chernozhukov et al. (2018))](https://doi.org/10.1111/ectj.12097) for

- Partially linear regression models (PLR)
- Partially linear IV regression models (PLIV)
Expand All @@ -46,14 +46,14 @@ This object-oriented implementation allows a high flexibility for the model spec
- ... the resampling schemes,
- ... the double machine learning algorithm,
- ... the Neyman orthogonal score functions,
- ...
- ...

It further can be readily extended with regards to

- ... new model classes that come with Neyman orthogonal score functions being linear in the target parameter,
- ... alternative score functions via callables,
- ... alternative resampling schemes,
- ...
- ...

![An overview of the OOP structure of the DoubleML package is given in the graphic available at https://github.com/DoubleML/doubleml-for-py/blob/main/doc/oop.svg](https://raw.githubusercontent.com/DoubleML/doubleml-for-py/main/doc/oop.svg)

Expand Down Expand Up @@ -106,7 +106,7 @@ Bibtex-entry:

```
@article{DoubleML2022,
title = {{DoubleML} -- {A}n Object-Oriented Implementation of Double Machine Learning in {P}ython},
title = {{DoubleML} -- {A}n Object-Oriented Implementation of Double Machine Learning in {P}ython},
author = {Philipp Bach and Victor Chernozhukov and Malte S. Kurz and Martin Spindler},
journal = {Journal of Machine Learning Research},
year = {2022},
Expand Down
2 changes: 1 addition & 1 deletion doc/_templates/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
.. automethod:: {{ name }}.{{ item }}
{% endif %}
{%- endfor %}
{% endif %}
{% endif %}
49 changes: 25 additions & 24 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))


# -- Project information -----------------------------------------------------

project = 'DoubleML'
copyright = '2021, Bach, P., Chernozhukov, V., Klaassen, S., Kurz, M. S., and Spindler, M.'
author = 'Bach, P., Chernozhukov, V., Klaassen, S., Kurz, M. S., and Spindler, M.'
project = "DoubleML"
copyright = "2021, Bach, P., Chernozhukov, V., Klaassen, S., Kurz, M. S., and Spindler, M."
author = "Bach, P., Chernozhukov, V., Klaassen, S., Kurz, M. S., and Spindler, M."

# The full version, including alpha/beta/rc tags
release = '0.10.dev0'
release = "0.10.dev0"


# -- General configuration ---------------------------------------------------
Expand All @@ -31,38 +32,38 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.coverage',
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.coverage",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

master_doc = 'index'
master_doc = "index"

autoclass_content = 'class'
autoclass_content = "class"
autosummary_generate = True

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'pydata_sphinx_theme'
html_theme = "pydata_sphinx_theme"

html_theme_options = {
'github_url': 'https://github.com/DoubleML/doubleml-for-py',
'navigation_with_keys': False,
'show_toc_level': 0
"github_url": "https://github.com/DoubleML/doubleml-for-py",
"navigation_with_keys": False,
"show_toc_level": 0,
}

# Add any paths that contain custom static files (such as style sheets) here,
Expand All @@ -74,9 +75,9 @@

# intersphinx configuration
intersphinx_mapping = {
'python': ('https://docs.python.org/{.major}'.format(sys.version_info), None),
'sklearn': ('https://scikit-learn.org/stable/', None),
'numpy': ('https://numpy.org/doc/stable/', None),
'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None),
'statsmodels': ('https://www.statsmodels.org/stable/', None),
"python": ("https://docs.python.org/{.major}".format(sys.version_info), None),
"sklearn": ("https://scikit-learn.org/stable/", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
"statsmodels": ("https://www.statsmodels.org/stable/", None),
}
2 changes: 1 addition & 1 deletion doc/oop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 30 additions & 32 deletions doubleml/__init__.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
import importlib.metadata

from .double_ml_framework import concat
from .double_ml_framework import DoubleMLFramework
from .plm.plr import DoubleMLPLR
from .plm.pliv import DoubleMLPLIV
from .irm.irm import DoubleMLIRM
from .did.did import DoubleMLDID
from .did.did_cs import DoubleMLDIDCS
from .double_ml_data import DoubleMLClusterData, DoubleMLData
from .double_ml_framework import DoubleMLFramework, concat
from .irm.apo import DoubleMLAPO
from .irm.apos import DoubleMLAPOS
from .irm.cvar import DoubleMLCVAR
from .irm.iivm import DoubleMLIIVM
from .double_ml_data import DoubleMLData, DoubleMLClusterData
from .did.did import DoubleMLDID
from .did.did_cs import DoubleMLDIDCS
from .irm.qte import DoubleMLQTE
from .irm.pq import DoubleMLPQ
from .irm.irm import DoubleMLIRM
from .irm.lpq import DoubleMLLPQ
from .irm.cvar import DoubleMLCVAR
from .irm.pq import DoubleMLPQ
from .irm.qte import DoubleMLQTE
from .irm.ssm import DoubleMLSSM

from .plm.pliv import DoubleMLPLIV
from .plm.plr import DoubleMLPLR
from .utils.blp import DoubleMLBLP
from .utils.policytree import DoubleMLPolicyTree

__all__ = [
'concat',
'DoubleMLFramework',
'DoubleMLPLR',
'DoubleMLPLIV',
'DoubleMLIRM',
'DoubleMLAPO',
'DoubleMLAPOS',
'DoubleMLIIVM',
'DoubleMLData',
'DoubleMLClusterData',
'DoubleMLDID',
'DoubleMLDIDCS',
'DoubleMLPQ',
'DoubleMLQTE',
'DoubleMLLPQ',
'DoubleMLCVAR',
'DoubleMLBLP',
'DoubleMLPolicyTree',
'DoubleMLSSM'
"concat",
"DoubleMLFramework",
"DoubleMLPLR",
"DoubleMLPLIV",
"DoubleMLIRM",
"DoubleMLAPO",
"DoubleMLAPOS",
"DoubleMLIIVM",
"DoubleMLData",
"DoubleMLClusterData",
"DoubleMLDID",
"DoubleMLDIDCS",
"DoubleMLPQ",
"DoubleMLQTE",
"DoubleMLLPQ",
"DoubleMLCVAR",
"DoubleMLBLP",
"DoubleMLPolicyTree",
"DoubleMLSSM",
]

__version__ = importlib.metadata.version('doubleml')
__version__ = importlib.metadata.version("doubleml")
Loading