Skip to content

Commit

Permalink
Add doc on joblib
Browse files Browse the repository at this point in the history
  • Loading branch information
fraimondo committed Oct 21, 2024
1 parent e648e7c commit bd18951
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 deletions.
55 changes: 29 additions & 26 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,39 +212,42 @@
# -- Sphinx-Gallery configuration --------------------------------------------


class SubSectionTitleOrder:
"""Sort example gallery by title of subsection.
# class SubSectionTitleOrder:
# """Sort example gallery by title of subsection.

Assumes README.txt exists for all subsections and uses the subsection with
dashes, '---', as the adornment.
"""
# Assumes README.txt exists for all subsections and uses the subsection with
# dashes, '---', as the adornment.
# """

def __init__(self, src_dir):
self.src_dir = src_dir
self.regex = re.compile(r"^([\w ]+)\n-", re.MULTILINE)
# def __init__(self, src_dir):
# self.src_dir = src_dir
# self.regex = re.compile(r"^([\w ]+)\n-", re.MULTILINE)

def __repr__(self):
return f"<{self.__class__.__name__}>"
# def __reduce__(self):
# return (self.__class__, (self.src_dir, ))

def __call__(self, directory):
src_path = os.path.normpath(os.path.join(self.src_dir, directory))
# def __repr__(self):
# return f"<{self.__class__.__name__}>"

# Forces Release Highlights to the top
if os.path.basename(src_path) == "release_highlights":
return "0"
# def __call__(self, directory):
# src_path = os.path.normpath(os.path.join(self.src_dir, directory))

readme = os.path.join(src_path, "README.txt")
# # Forces Release Highlights to the top
# if os.path.basename(src_path) == "release_highlights":
# return "0"

try:
with open(readme) as f:
content = f.read()
except FileNotFoundError:
return directory
# readme = os.path.join(src_path, "README.txt")

title_match = self.regex.search(content)
if title_match is not None:
return title_match.group(1)
return directory
# try:
# with open(readme) as f:
# content = f.read()
# except FileNotFoundError:
# return directory

# title_match = self.regex.search(content)
# if title_match is not None:
# return title_match.group(1)
# return directory


ex_dirs = [
Expand All @@ -269,7 +272,7 @@ def __call__(self, directory):
"examples_dirs": example_dirs,
"gallery_dirs": gallery_dirs,
"nested_sections": True,
"subsection_order": SubSectionTitleOrder("../examples"),
# "subsection_order": SubSectionTitleOrder("../examples"),
"filename_pattern": "/(plot|run)_",
"download_all_examples": False,
}
Expand Down
5 changes: 4 additions & 1 deletion docs/selected_deeper_topics/joblib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ computed in parallel.
Without going into details about parallel and distributed computing, the idea
is to split the computation into smaller tasks that can be executed
independently from each other. This way, you can take advantage of multiple
*processors* to do them in parallel.
*processors* to do them in parallel. A very clear example of this situation is
when you are estimating a model's performance using cross-validation. In this
case, you can parallelize the computation of the different folds, as the
training and testing of each fold are independent from each other.

0 comments on commit bd18951

Please sign in to comment.