Skip to content

Commit

Permalink
DOC: add a doctest step to CI to allow writing testable code blocs, f…
Browse files Browse the repository at this point in the history
…ix existing docstring code examples errors (#592)

* DOC: add a doctest step to CI to allow writing testable code blocs, fix existing docstring code examples errors
  • Loading branch information
Valentin-Laurent authored Jan 9, 2025
1 parent 423a87b commit 9cbaad8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
11 changes: 6 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ Please describe the tests that you ran to verify your changes. Provide instructi

- [ ] I have read the [contributing guidelines](https://github.com/scikit-learn-contrib/MAPIE/blob/master/CONTRIBUTING.rst)
- [ ] I have updated the [HISTORY.rst](https://github.com/scikit-learn-contrib/MAPIE/blob/master/HISTORY.rst) and [AUTHORS.rst](https://github.com/scikit-learn-contrib/MAPIE/blob/master/AUTHORS.rst) files
- [ ] Linting passes successfully : `make lint`
- [ ] Typing passes successfully : `make type-check`
- [ ] Unit tests pass successfully : `make tests`
- [ ] Coverage is 100% : `make coverage`
- [ ] Documentation builds successfully and without warnings : `make doc`
- [ ] Linting passes successfully: `make lint`
- [ ] Typing passes successfully: `make type-check`
- [ ] Unit tests pass successfully: `make tests`
- [ ] Coverage is 100%: `make coverage`
- [ ] When updating documentation: doc builds successfully and without warnings: `make doc`
- [ ] When updating documentation: code examples in doc run successfully: `make doctest`
3 changes: 3 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ build:
os: ubuntu-22.04
tools:
python: "mambaforge-22.9"
jobs:
post_build:
- cd doc && make doctest

python:
install:
Expand Down
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ History
* Limit max sklearn version allowed at MAPIE installation
* Refactor MapieRegressor, EnsembleRegressor, and MapieQuantileRegressor, to prepare for the release of v1.0.0
* Documentation build: fix warnings, fix image generation, update sklearn version requirement
* Documentation test: add a doc testing step (in MAKEFILE and CI)
* Increase max line length from 79 to 88 characters
* Bump wheel version

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ coverage:
doc:
$(MAKE) html -C doc

doctest:
$(MAKE) doctest -C doc

clean-doc:
$(MAKE) clean -C doc

Expand Down
4 changes: 3 additions & 1 deletion mapie/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def regression_ssc_score(
Examples
--------
>>> from mapie.metrics import regression_ssc
>>> from mapie.metrics import regression_ssc_score
>>> import numpy as np
>>> y_true = np.array([5, 7.5, 9.5])
>>> y_intervals = np.array([
Expand Down Expand Up @@ -1283,6 +1283,7 @@ def kolmogorov_smirnov_p_value(y_true: NDArray, y_score: NDArray) -> float:
Examples
--------
>>> import pandas as pd
>>> import numpy as np
>>> from mapie.metrics import kolmogorov_smirnov_p_value
>>> y_true = np.array([1, 0, 1, 0, 1, 0])
>>> y_score = np.array([0.8, 0.3, 0.5, 0.5, 0.7, 0.1])
Expand Down Expand Up @@ -1450,6 +1451,7 @@ def kuiper_p_value(y_true: NDArray, y_score: NDArray) -> float:
Examples
--------
>>> import pandas as pd
>>> import numpy as np
>>> from mapie.metrics import kuiper_p_value
>>> y_true = np.array([1, 0, 1, 0, 1, 0])
>>> y_score = np.array([0.8, 0.3, 0.5, 0.5, 0.7, 0.1])
Expand Down
1 change: 1 addition & 0 deletions mapie/mondrian.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class MondrianCP(BaseEstimator):
>>> import numpy as np
>>> from sklearn.linear_model import LogisticRegression
>>> from mapie.classification import MapieClassifier
>>> from mapie.mondrian import MondrianCP
>>> X_toy = np.arange(9).reshape(-1, 1)
>>> y_toy = np.stack([0, 0, 1, 0, 1, 2, 1, 2, 2])
>>> partition_toy = [0, 0, 0, 0, 1, 1, 1, 1, 1]
Expand Down

0 comments on commit 9cbaad8

Please sign in to comment.