Skip to content

Commit

Permalink
chore: Update dependencies and fix import order in Python files
Browse files Browse the repository at this point in the history
  • Loading branch information
LacombeLouis committed May 3, 2024
1 parent 4cff8ae commit 2229b16
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 16 deletions.
17 changes: 14 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
# "sphinx.ext.autosectionlabel",
"sphinx.ext.viewcode",
"sphinx.ext.mathjax",
"sphinx-prompt",
"sphinx_gallery.gen_gallery",
"numpydoc",
]
mathjax_path = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"


templates_path = ["_templates"]
exclude_patterns = ["_build", "_templates", "Thumbs.db", ".DS_Store"]
Expand Down Expand Up @@ -102,12 +107,18 @@
# -- Options for sphinx-gallery -----------------------------------------------

# Generate the plot for the gallery
plot_gallery = True
plot_gallery = "True"

sphinx_gallery_conf = {
"examples_dirs": ["../examples"],
"gallery_dirs": [
"examples_regression",
"examples_classification",
"examples_multilabel_classification",
"examples_calibration",
],
"doc_module": "mapie",
"filename_pattern": "**/plot_*.py",
"backreferences_dir": os.path.join("generated"),
"examples_dirs": "../examples",
"gallery_dirs": "auto_examples",
"reference_url": {"mapie": None},
}
46 changes: 46 additions & 0 deletions doc/fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import re

def fix_docstrings(file_path):
with open(file_path, 'r') as file:
lines = file.readlines()

fixed_lines = []
bullet_list_active = False
in_directive = False
directive_indent = 0

for line in lines:
stripped_line = line.strip()

if re.match(r'^- ', stripped_line): # Detect bullet points
bullet_list_active = True
indent_level = len(line) - len(line.lstrip())
elif bullet_list_active and (stripped_line == "" or not stripped_line.startswith('- ')):
fixed_lines.append('\n') # Ensure a blank line after a list
bullet_list_active = False
elif re.match(r'^\.\. \w+::', stripped_line): # Check for directive start
in_directive = True
directive_indent = len(line) - len(line.lstrip())
elif in_directive and (len(line) - len(line.lstrip())) <= directive_indent:
in_directive = False

if 'unexpected indentation' in line or (in_directive and not stripped_line.startswith(' ')):
continue # Skip adding lines with unexpected indentation

if 'undefined substitution referenced' in line:
line = '#' + line # Comment out lines with undefined substitutions

fixed_lines.append(line)

with open(file_path, 'w') as file:
file.writelines(fixed_lines)

def fix_rst_files(directory):
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith('.rst'):
fix_docstrings(os.path.join(root, file))

# Example usage:
fix_rst_files('/Users/llacombe/CODE/quantmetry/MAPIE/doc')
2 changes: 1 addition & 1 deletion examples/calibration/README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _calibration_examples:

Calibration examples
=======================
====================
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
# 2 Recall control risk with CRC and RCPS
# ---------------------------------------
# 2.1 Fitting MapieMultiLabelClassifier
# ------------------------------------
# -------------------------------------
# MapieMultiLabelClassifier will be fitted with RCPS and CRC methods. For the
# RCPS method, we will test all three Upper Confidence Bounds (Hoeffding,
# Bernstein and Waudby-Smith–Ramdas).
Expand Down
6 changes: 3 additions & 3 deletions examples/multilabel_classification/README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _general_examples:
.. _multilabel_classification_examples:

General examples
================
Multilabel Classification examples
==================================
4 changes: 2 additions & 2 deletions mapie/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
__version_tuple__: VERSION_TUPLE
version_tuple: VERSION_TUPLE

__version__ = version = '0.8.4.dev4+g6b5418b.d20240503'
__version_tuple__ = version_tuple = (0, 8, 4, 'dev4', 'g6b5418b.d20240503')
__version__ = version = '0.8.4.dev5+g4cff8ae.d20240503'
__version_tuple__ = version_tuple = (0, 8, 4, 'dev5', 'g4cff8ae.d20240503')
8 changes: 4 additions & 4 deletions mapie/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ class MapieCalibrator(BaseEstimator, ClassifierMixin):
Parameters
----------
estimator : Optional[ClassifierMixin]
estimator: Optional[ClassifierMixin]
Any classifier with scikit-learn API
(i.e. with fit, predict, and predict_proba methods), by default
``None``.
(i.e. with fit, predict, and predict_proba methods), by default ``None``.
If ``None``, estimator defaults to a ``LogisticRegression`` instance.
method: Optional[str]
Expand All @@ -46,7 +45,7 @@ class MapieCalibrator(BaseEstimator, ClassifierMixin):
By default "top_label".
calibrator : Optional[Union[str, RegressorMixin]]
calibrator: Optional[Union[str, RegressorMixin]]
Any calibrator with scikit-learn API
(i.e. with fit, predict, and predict_proba methods), by default
``None``.
Expand Down Expand Up @@ -90,6 +89,7 @@ class MapieCalibrator(BaseEstimator, ClassifierMixin):
[1] Gupta, Chirag, and Aaditya K. Ramdas. "Top-label calibration
and multiclass-to-binary reductions." arXiv preprint
arXiv:2107.08353 (2021).
"""

fit_attributes = [
Expand Down
121 changes: 119 additions & 2 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ setuptools-scm = ">=8" # needed for the versioning
sphinx = "*"
sphinx-gallery = "*"
sphinx-prompt = "*"
pandas = "*"

[tool.pixi.feature.doc.tasks]
build-doc = { cmd = "make html", cwd = "doc" }
Expand Down

0 comments on commit 2229b16

Please sign in to comment.