From d7217a741762f85dfac899fef7981218c12820cd Mon Sep 17 00:00:00 2001 From: mmcky Date: Tue, 21 Oct 2025 15:16:58 +1100 Subject: [PATCH 01/16] Update test suite for Python 3.11-3.13 and Sphinx 6-8 compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update pyproject.toml: require Python >=3.11, Sphinx >=6.1, matplotlib >=3.8 - Update tox.ini: add 9 test environments (py311/312/313 × sphinx6/7/8) - Fix deprecation warnings: - Use os.path.splitext() instead of string operations (RemovedInSphinx90Warning) - Update sphinx.util.console import path - Implement Sphinx-version-specific regression fixtures: - Generate separate .sphinx6/.sphinx7/.sphinx8 fixtures for HTML and XML - Track actual Sphinx output differences without filtering - Add ipykernel process ID normalization for test stability - All 110 tests pass across all 9 Python/Sphinx combinations --- pyproject.toml | 13 +- sphinx_exercise/directive.py | 24 +-- sphinx_exercise/post_transforms.py | 3 +- tests/conftest.py | 2 + tests/test_exercise_references.py | 5 +- .../_enum_numref_mathtitle.sphinx7.html | 4 + .../_enum_numref_mathtitle.sphinx8.html | 6 + .../_enum_numref_notitle.sphinx7.html | 4 + .../_enum_numref_notitle.sphinx8.html | 6 + .../_enum_numref_placeholders.sphinx7.html | 10 + .../_enum_numref_placeholders.sphinx8.html | 12 ++ .../_enum_numref_title.sphinx7.html | 4 + .../_enum_numref_title.sphinx8.html | 6 + .../_enum_ref_mathtitle.sphinx7.html | 2 + .../_enum_ref_mathtitle.sphinx8.html | 4 + .../_enum_ref_notitle.sphinx7.html | 2 + .../_enum_ref_notitle.sphinx8.html | 4 + .../_enum_ref_title.sphinx7.html | 2 + .../_enum_ref_title.sphinx8.html | 4 + .../_unenum_numref_mathtitle.sphinx7.html | 4 + .../_unenum_numref_mathtitle.sphinx8.html | 6 + .../_unenum_numref_notitle.sphinx7.html | 4 + .../_unenum_numref_notitle.sphinx8.html | 6 + .../_unenum_numref_title.sphinx7.html | 4 + .../_unenum_numref_title.sphinx8.html | 6 + .../_unenum_ref_mathtitle.sphinx7.html | 2 + .../_unenum_ref_mathtitle.sphinx8.html | 4 + .../_unenum_ref_notitle.sphinx7.html | 2 + .../_unenum_ref_notitle.sphinx8.html | 4 + .../_unenum_ref_title.sphinx7.html | 2 + .../_unenum_ref_title.sphinx8.html | 4 + tests/test_gateddirective.py | 7 +- .../exercise-gated-0.sphinx7.html | 9 + .../exercise-gated-0.sphinx8.html | 9 + .../exercise-gated-1.sphinx7.html | 8 + .../exercise-gated-1.sphinx8.html | 8 + .../exercise-gated.sphinx7.xml | 24 +++ .../exercise-gated.sphinx8.xml | 24 +++ .../solution-exercise-0.sphinx7.html | 10 +- .../solution-exercise-0.sphinx8.html | 47 +++++ .../solution-exercise-1.sphinx7.html | 10 +- .../solution-exercise-1.sphinx8.html | 47 +++++ .../solution-exercise-gated-0.sphinx7.html | 10 +- .../solution-exercise-gated-0.sphinx8.html | 47 +++++ .../solution-exercise-gated-1.sphinx7.html | 10 +- .../solution-exercise-gated-1.sphinx8.html | 47 +++++ .../solution-exercise-gated.sphinx7.xml | 10 +- .../solution-exercise-gated.sphinx8.xml | 117 +++++++++++ .../solution-exercise.sphinx7.xml | 10 +- .../solution-exercise.sphinx8.xml | 120 ++++++++++++ tests/test_latex/test_latex_build.sphinx8.tex | 181 ++++++++++++++++++ tests/test_solution.py | 7 + .../_linked_duplicate_label.sphinx7.xml | 10 + .../_linked_duplicate_label.sphinx8.xml | 10 + tests/test_solution/_linked_enum.sphinx7.xml | 29 +++ tests/test_solution/_linked_enum.sphinx8.xml | 29 +++ tests/test_solution/_linked_enum.xml | 4 +- .../_linked_enum_class.sphinx7.xml | 10 + .../_linked_enum_class.sphinx8.xml | 10 + .../_linked_missing_arg.sphinx7.xml | 4 + .../_linked_missing_arg.sphinx8.xml | 4 + .../_linked_unenum_mathtitle.sphinx7.xml | 24 +++ .../_linked_unenum_mathtitle.sphinx8.xml | 24 +++ .../_linked_unenum_mathtitle2.sphinx7.xml | 24 +++ .../_linked_unenum_mathtitle2.sphinx8.xml | 24 +++ .../_linked_unenum_notitle.sphinx7.xml | 20 ++ .../_linked_unenum_notitle.sphinx8.xml | 20 ++ .../_linked_unenum_title.sphinx7.xml | 22 +++ .../_linked_unenum_title.sphinx8.xml | 22 +++ .../_linked_wrong_targetlabel.sphinx7.xml | 10 + .../_linked_wrong_targetlabel.sphinx8.xml | 10 + .../_linked_duplicate_label.sphinx7.xml | 10 + .../_linked_duplicate_label.sphinx8.xml | 10 + .../solution/_linked_enum.sphinx7.xml | 29 +++ .../solution/_linked_enum.sphinx8.xml | 29 +++ .../solution/_linked_enum_class.sphinx7.xml | 10 + .../solution/_linked_enum_class.sphinx8.xml | 10 + .../solution/_linked_missing_arg.sphinx7.xml | 4 + .../solution/_linked_missing_arg.sphinx8.xml | 4 + .../_linked_unenum_mathtitle.sphinx7.xml | 24 +++ .../_linked_unenum_mathtitle.sphinx8.xml | 24 +++ .../_linked_unenum_mathtitle2.sphinx7.xml | 24 +++ .../_linked_unenum_mathtitle2.sphinx8.xml | 24 +++ .../_linked_unenum_notitle.sphinx7.xml | 20 ++ .../_linked_unenum_notitle.sphinx8.xml | 20 ++ .../solution/_linked_unenum_title.sphinx7.xml | 22 +++ .../solution/_linked_unenum_title.sphinx8.xml | 22 +++ .../_linked_wrong_targetlabel.sphinx7.xml | 10 + .../_linked_wrong_targetlabel.sphinx8.xml | 10 + tests/test_solution_references.py | 5 +- .../_linked_ref_enum.sphinx7.html | 2 + .../_linked_ref_enum.sphinx8.html | 4 + .../_linked_ref_unenum_mathtitle.sphinx7.html | 2 + .../_linked_ref_unenum_mathtitle.sphinx8.html | 4 + ..._linked_ref_unenum_mathtitle2.sphinx7.html | 2 + ..._linked_ref_unenum_mathtitle2.sphinx8.html | 4 + .../_linked_ref_unenum_notitle.sphinx7.html | 2 + .../_linked_ref_unenum_notitle.sphinx8.html | 4 + .../_linked_ref_unenum_title.sphinx7.html | 2 + .../_linked_ref_unenum_title.sphinx8.html | 4 + tox.ini | 11 +- 101 files changed, 1543 insertions(+), 46 deletions(-) create mode 100644 tests/test_exercise_references/_enum_numref_mathtitle.sphinx7.html create mode 100644 tests/test_exercise_references/_enum_numref_mathtitle.sphinx8.html create mode 100644 tests/test_exercise_references/_enum_numref_notitle.sphinx7.html create mode 100644 tests/test_exercise_references/_enum_numref_notitle.sphinx8.html create mode 100644 tests/test_exercise_references/_enum_numref_placeholders.sphinx7.html create mode 100644 tests/test_exercise_references/_enum_numref_placeholders.sphinx8.html create mode 100644 tests/test_exercise_references/_enum_numref_title.sphinx7.html create mode 100644 tests/test_exercise_references/_enum_numref_title.sphinx8.html create mode 100644 tests/test_exercise_references/_enum_ref_mathtitle.sphinx7.html create mode 100644 tests/test_exercise_references/_enum_ref_mathtitle.sphinx8.html create mode 100644 tests/test_exercise_references/_enum_ref_notitle.sphinx7.html create mode 100644 tests/test_exercise_references/_enum_ref_notitle.sphinx8.html create mode 100644 tests/test_exercise_references/_enum_ref_title.sphinx7.html create mode 100644 tests/test_exercise_references/_enum_ref_title.sphinx8.html create mode 100644 tests/test_exercise_references/_unenum_numref_mathtitle.sphinx7.html create mode 100644 tests/test_exercise_references/_unenum_numref_mathtitle.sphinx8.html create mode 100644 tests/test_exercise_references/_unenum_numref_notitle.sphinx7.html create mode 100644 tests/test_exercise_references/_unenum_numref_notitle.sphinx8.html create mode 100644 tests/test_exercise_references/_unenum_numref_title.sphinx7.html create mode 100644 tests/test_exercise_references/_unenum_numref_title.sphinx8.html create mode 100644 tests/test_exercise_references/_unenum_ref_mathtitle.sphinx7.html create mode 100644 tests/test_exercise_references/_unenum_ref_mathtitle.sphinx8.html create mode 100644 tests/test_exercise_references/_unenum_ref_notitle.sphinx7.html create mode 100644 tests/test_exercise_references/_unenum_ref_notitle.sphinx8.html create mode 100644 tests/test_exercise_references/_unenum_ref_title.sphinx7.html create mode 100644 tests/test_exercise_references/_unenum_ref_title.sphinx8.html create mode 100644 tests/test_gateddirective/exercise-gated-0.sphinx7.html create mode 100644 tests/test_gateddirective/exercise-gated-0.sphinx8.html create mode 100644 tests/test_gateddirective/exercise-gated-1.sphinx7.html create mode 100644 tests/test_gateddirective/exercise-gated-1.sphinx8.html create mode 100644 tests/test_gateddirective/exercise-gated.sphinx7.xml create mode 100644 tests/test_gateddirective/exercise-gated.sphinx8.xml create mode 100644 tests/test_gateddirective/solution-exercise-0.sphinx8.html create mode 100644 tests/test_gateddirective/solution-exercise-1.sphinx8.html create mode 100644 tests/test_gateddirective/solution-exercise-gated-0.sphinx8.html create mode 100644 tests/test_gateddirective/solution-exercise-gated-1.sphinx8.html create mode 100644 tests/test_gateddirective/solution-exercise-gated.sphinx8.xml create mode 100644 tests/test_gateddirective/solution-exercise.sphinx8.xml create mode 100644 tests/test_latex/test_latex_build.sphinx8.tex create mode 100644 tests/test_solution/_linked_duplicate_label.sphinx7.xml create mode 100644 tests/test_solution/_linked_duplicate_label.sphinx8.xml create mode 100644 tests/test_solution/_linked_enum.sphinx7.xml create mode 100644 tests/test_solution/_linked_enum.sphinx8.xml create mode 100644 tests/test_solution/_linked_enum_class.sphinx7.xml create mode 100644 tests/test_solution/_linked_enum_class.sphinx8.xml create mode 100644 tests/test_solution/_linked_missing_arg.sphinx7.xml create mode 100644 tests/test_solution/_linked_missing_arg.sphinx8.xml create mode 100644 tests/test_solution/_linked_unenum_mathtitle.sphinx7.xml create mode 100644 tests/test_solution/_linked_unenum_mathtitle.sphinx8.xml create mode 100644 tests/test_solution/_linked_unenum_mathtitle2.sphinx7.xml create mode 100644 tests/test_solution/_linked_unenum_mathtitle2.sphinx8.xml create mode 100644 tests/test_solution/_linked_unenum_notitle.sphinx7.xml create mode 100644 tests/test_solution/_linked_unenum_notitle.sphinx8.xml create mode 100644 tests/test_solution/_linked_unenum_title.sphinx7.xml create mode 100644 tests/test_solution/_linked_unenum_title.sphinx8.xml create mode 100644 tests/test_solution/_linked_wrong_targetlabel.sphinx7.xml create mode 100644 tests/test_solution/_linked_wrong_targetlabel.sphinx8.xml create mode 100644 tests/test_solution/solution/_linked_duplicate_label.sphinx7.xml create mode 100644 tests/test_solution/solution/_linked_duplicate_label.sphinx8.xml create mode 100644 tests/test_solution/solution/_linked_enum.sphinx7.xml create mode 100644 tests/test_solution/solution/_linked_enum.sphinx8.xml create mode 100644 tests/test_solution/solution/_linked_enum_class.sphinx7.xml create mode 100644 tests/test_solution/solution/_linked_enum_class.sphinx8.xml create mode 100644 tests/test_solution/solution/_linked_missing_arg.sphinx7.xml create mode 100644 tests/test_solution/solution/_linked_missing_arg.sphinx8.xml create mode 100644 tests/test_solution/solution/_linked_unenum_mathtitle.sphinx7.xml create mode 100644 tests/test_solution/solution/_linked_unenum_mathtitle.sphinx8.xml create mode 100644 tests/test_solution/solution/_linked_unenum_mathtitle2.sphinx7.xml create mode 100644 tests/test_solution/solution/_linked_unenum_mathtitle2.sphinx8.xml create mode 100644 tests/test_solution/solution/_linked_unenum_notitle.sphinx7.xml create mode 100644 tests/test_solution/solution/_linked_unenum_notitle.sphinx8.xml create mode 100644 tests/test_solution/solution/_linked_unenum_title.sphinx7.xml create mode 100644 tests/test_solution/solution/_linked_unenum_title.sphinx8.xml create mode 100644 tests/test_solution/solution/_linked_wrong_targetlabel.sphinx7.xml create mode 100644 tests/test_solution/solution/_linked_wrong_targetlabel.sphinx8.xml create mode 100644 tests/test_solution_references/_linked_ref_enum.sphinx7.html create mode 100644 tests/test_solution_references/_linked_ref_enum.sphinx8.html create mode 100644 tests/test_solution_references/_linked_ref_unenum_mathtitle.sphinx7.html create mode 100644 tests/test_solution_references/_linked_ref_unenum_mathtitle.sphinx8.html create mode 100644 tests/test_solution_references/_linked_ref_unenum_mathtitle2.sphinx7.html create mode 100644 tests/test_solution_references/_linked_ref_unenum_mathtitle2.sphinx8.html create mode 100644 tests/test_solution_references/_linked_ref_unenum_notitle.sphinx7.html create mode 100644 tests/test_solution_references/_linked_ref_unenum_notitle.sphinx8.html create mode 100644 tests/test_solution_references/_linked_ref_unenum_title.sphinx7.html create mode 100644 tests/test_solution_references/_linked_ref_unenum_title.sphinx8.html diff --git a/pyproject.toml b/pyproject.toml index 13e41f7..3c07db1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ dynamic = ["version"] description = "A Sphinx extension for producing exercises and solutions." readme = "README.md" license = { file = "LICENSE" } -requires-python = ">=3.9" +requires-python = ">=3.11" authors = [ { name = "QuantEcon", email = "admin@quantecon.org" }, ] @@ -22,10 +22,9 @@ classifiers = [ "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Documentation", "Topic :: Documentation :: Sphinx", "Topic :: Software Development :: Documentation", @@ -34,7 +33,7 @@ classifiers = [ ] dependencies = [ "sphinx-book-theme", - "sphinx>=5", + "sphinx>=6.1", ] [project.optional-dependencies] @@ -52,17 +51,17 @@ rtd = [ "myst-nb~=1.0.0", "sphinx-book-theme", "sphinx_togglebutton", - "sphinx>=5,<8", + "sphinx>=6.1,<9", ] testing = [ "beautifulsoup4", "coverage", - "matplotlib==3.8.*", + "matplotlib>=3.8", "myst-nb~=1.0.0", "pytest-cov", "pytest-regressions", "pytest~=8.0.0", - "sphinx>=5,<8", + "sphinx>=6.1,<9", "texsoup", "defusedxml", # Required by sphinx-testing ] diff --git a/sphinx_exercise/directive.py b/sphinx_exercise/directive.py index 2db6d5b..ac83c36 100644 --- a/sphinx_exercise/directive.py +++ b/sphinx_exercise/directive.py @@ -8,28 +8,30 @@ :licences: see LICENSE for details """ +import os from typing import List -from docutils.nodes import Node -from sphinx.util.docutils import SphinxDirective +from docutils import nodes +from docutils.nodes import Node from docutils.parsers.rst import directives +from sphinx.locale import get_translation +from sphinx.util import logging +from sphinx.util.docutils import SphinxDirective + from .nodes import ( - exercise_node, - exercise_enumerable_node, exercise_end_node, + exercise_enumerable_node, + exercise_node, + exercise_subtitle, + exercise_title, + solution_end_node, solution_node, solution_start_node, - solution_end_node, - exercise_title, - exercise_subtitle, solution_title, ) -from docutils import nodes -from sphinx.util import logging logger = logging.getLogger(__name__) -from sphinx.locale import get_translation MESSAGE_CATALOG_NAME = "exercise" translate = get_translation(MESSAGE_CATALOG_NAME) @@ -40,7 +42,7 @@ def duplicate_labels(self, label): if not label == "" and label in self.env.sphinx_exercise_registry.keys(): docpath = self.env.doc2path(self.env.docname) - path = docpath[: docpath.rfind(".")] + path = os.path.splitext(docpath)[0] other_path = self.env.doc2path( self.env.sphinx_exercise_registry[label]["docname"] ) diff --git a/sphinx_exercise/post_transforms.py b/sphinx_exercise/post_transforms.py index 6b477b5..75063fc 100644 --- a/sphinx_exercise/post_transforms.py +++ b/sphinx_exercise/post_transforms.py @@ -1,3 +1,4 @@ +import os import sphinx.addnodes as sphinx_nodes from sphinx.transforms.post_transforms import SphinxPostTransform from sphinx.util import logging @@ -195,7 +196,7 @@ def run(self): except AttributeError: docname = self.env.docname # for builder such as JupyterBuilder that don't support current_docname docpath = self.env.doc2path(docname) - path = docpath[: docpath.rfind(".")] + path = os.path.splitext(docpath)[0] msg = f"undefined label: {target_label}" logger.warning(msg, location=path, color="red") return diff --git a/tests/conftest.py b/tests/conftest.py index df54536..9c3c593 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -94,6 +94,8 @@ class FileRegression: (r"original_uri=\"[^\"]*\"\s", ""), # TODO: Remove when support for Sphinx<7.2 is dropped ("Link to", "Permalink to"), + # Strip ipykernel process IDs (temporary directory paths) + (r"ipykernel_\d+", "ipykernel_XXXXX"), ) def __init__(self, file_regression): diff --git a/tests/test_exercise_references.py b/tests/test_exercise_references.py index 4ba56a9..5b419e7 100644 --- a/tests/test_exercise_references.py +++ b/tests/test_exercise_references.py @@ -1,5 +1,8 @@ from bs4 import BeautifulSoup import pytest +import sphinx + +SPHINX_VERSION = f".sphinx{sphinx.version_info[0]}" @pytest.mark.sphinx("html", testroot="mybook") @@ -35,7 +38,7 @@ def test_reference(app, idir, file_regression): excs += f"{ref}\n" file_regression.check( - str(excs[:-1]), basename=idir.split(".")[0], extension=".html" + str(excs[:-1]), basename=idir.split(".")[0], extension=f"{SPHINX_VERSION}.html" ) diff --git a/tests/test_exercise_references/_enum_numref_mathtitle.sphinx7.html b/tests/test_exercise_references/_enum_numref_mathtitle.sphinx7.html new file mode 100644 index 0000000..5d17801 --- /dev/null +++ b/tests/test_exercise_references/_enum_numref_mathtitle.sphinx7.html @@ -0,0 +1,4 @@ +

This is a reference Exercise 1.

+

This is a second reference some text 1.

+

This is a third reference some text 1.

+

This is a fourth reference some text Exercise.

\ No newline at end of file diff --git a/tests/test_exercise_references/_enum_numref_mathtitle.sphinx8.html b/tests/test_exercise_references/_enum_numref_mathtitle.sphinx8.html new file mode 100644 index 0000000..16a3e5b --- /dev/null +++ b/tests/test_exercise_references/_enum_numref_mathtitle.sphinx8.html @@ -0,0 +1,6 @@ +

This is a reference Exercise 1.

+

This is a second reference some text 1.

+

This is a third reference some text 1.

+

This is a fourth reference some text Exercise.

+

_enum_numref_title

+

_unenum_mathtitle_label

\ No newline at end of file diff --git a/tests/test_exercise_references/_enum_numref_notitle.sphinx7.html b/tests/test_exercise_references/_enum_numref_notitle.sphinx7.html new file mode 100644 index 0000000..90a5c54 --- /dev/null +++ b/tests/test_exercise_references/_enum_numref_notitle.sphinx7.html @@ -0,0 +1,4 @@ +

This is a reference Exercise 2.

+

This is a second reference some text 2.

+

This is a third reference some text 2.

+

This is a fourth reference some text Exercise.

\ No newline at end of file diff --git a/tests/test_exercise_references/_enum_numref_notitle.sphinx8.html b/tests/test_exercise_references/_enum_numref_notitle.sphinx8.html new file mode 100644 index 0000000..eb699a4 --- /dev/null +++ b/tests/test_exercise_references/_enum_numref_notitle.sphinx8.html @@ -0,0 +1,6 @@ +

This is a reference Exercise 2.

+

This is a second reference some text 2.

+

This is a third reference some text 2.

+

This is a fourth reference some text Exercise.

+

_enum_ref_mathtitle

+

_enum_numref_title

\ No newline at end of file diff --git a/tests/test_exercise_references/_enum_numref_placeholders.sphinx7.html b/tests/test_exercise_references/_enum_numref_placeholders.sphinx7.html new file mode 100644 index 0000000..07f2a5a --- /dev/null +++ b/tests/test_exercise_references/_enum_numref_placeholders.sphinx7.html @@ -0,0 +1,10 @@ +

This reference does not include math some 3 text %s test Exercise.

+

This reference does not include math some 3 text %s test.

+

This reference does not include math some Exercise text %s test.

+

This reference does not include math some Exercise text 3 test.

+

This reference does not include math some 3 text test.

+

This reference includes math some 1 text %s test Exercise.

+

This reference includes math some 1 text %s test.

+

This reference includes math some Exercise text %s test.

+

This reference includes math some Exercise text 1 test.

+

This reference includes math some 1 text test.

\ No newline at end of file diff --git a/tests/test_exercise_references/_enum_numref_placeholders.sphinx8.html b/tests/test_exercise_references/_enum_numref_placeholders.sphinx8.html new file mode 100644 index 0000000..9bc2e26 --- /dev/null +++ b/tests/test_exercise_references/_enum_numref_placeholders.sphinx8.html @@ -0,0 +1,12 @@ +

This reference does not include math some 3 text %s test Exercise.

+

This reference does not include math some 3 text %s test.

+

This reference does not include math some Exercise text %s test.

+

This reference does not include math some Exercise text 3 test.

+

This reference does not include math some 3 text test.

+

This reference includes math some 1 text %s test Exercise.

+

This reference includes math some 1 text %s test.

+

This reference includes math some Exercise text %s test.

+

This reference includes math some Exercise text 1 test.

+

This reference includes math some 1 text test.

+

_unenum_numref_mathtitle

+

_enum_duplicate_label

\ No newline at end of file diff --git a/tests/test_exercise_references/_enum_numref_title.sphinx7.html b/tests/test_exercise_references/_enum_numref_title.sphinx7.html new file mode 100644 index 0000000..c2a4496 --- /dev/null +++ b/tests/test_exercise_references/_enum_numref_title.sphinx7.html @@ -0,0 +1,4 @@ +

This is a reference Exercise 3.

+

This is a second reference some text 3.

+

This is a third reference some text 3.

+

This is a fourth reference some text Exercise.

\ No newline at end of file diff --git a/tests/test_exercise_references/_enum_numref_title.sphinx8.html b/tests/test_exercise_references/_enum_numref_title.sphinx8.html new file mode 100644 index 0000000..e3e637c --- /dev/null +++ b/tests/test_exercise_references/_enum_numref_title.sphinx8.html @@ -0,0 +1,6 @@ +

This is a reference Exercise 3.

+

This is a second reference some text 3.

+

This is a third reference some text 3.

+

This is a fourth reference some text Exercise.

+

_enum_numref_notitle

+

_enum_numref_mathtitle

\ No newline at end of file diff --git a/tests/test_exercise_references/_enum_ref_mathtitle.sphinx7.html b/tests/test_exercise_references/_enum_ref_mathtitle.sphinx7.html new file mode 100644 index 0000000..508253a --- /dev/null +++ b/tests/test_exercise_references/_enum_ref_mathtitle.sphinx7.html @@ -0,0 +1,2 @@ +

This is a reference Exercise 1.

+

This is a second reference some text.

\ No newline at end of file diff --git a/tests/test_exercise_references/_enum_ref_mathtitle.sphinx8.html b/tests/test_exercise_references/_enum_ref_mathtitle.sphinx8.html new file mode 100644 index 0000000..e12e85d --- /dev/null +++ b/tests/test_exercise_references/_enum_ref_mathtitle.sphinx8.html @@ -0,0 +1,4 @@ +

This is a reference Exercise 1.

+

This is a second reference some text.

+

_enum_ref_title

+

_enum_numref_notitle

\ No newline at end of file diff --git a/tests/test_exercise_references/_enum_ref_notitle.sphinx7.html b/tests/test_exercise_references/_enum_ref_notitle.sphinx7.html new file mode 100644 index 0000000..972f9f9 --- /dev/null +++ b/tests/test_exercise_references/_enum_ref_notitle.sphinx7.html @@ -0,0 +1,2 @@ +

This is a reference Exercise 2.

+

This is a second reference some text.

\ No newline at end of file diff --git a/tests/test_exercise_references/_enum_ref_notitle.sphinx8.html b/tests/test_exercise_references/_enum_ref_notitle.sphinx8.html new file mode 100644 index 0000000..2f1474c --- /dev/null +++ b/tests/test_exercise_references/_enum_ref_notitle.sphinx8.html @@ -0,0 +1,4 @@ +

This is a reference Exercise 2.

+

This is a second reference some text.

+

_enum_title_nolabel

+

_enum_ref_title

\ No newline at end of file diff --git a/tests/test_exercise_references/_enum_ref_title.sphinx7.html b/tests/test_exercise_references/_enum_ref_title.sphinx7.html new file mode 100644 index 0000000..5235a0a --- /dev/null +++ b/tests/test_exercise_references/_enum_ref_title.sphinx7.html @@ -0,0 +1,2 @@ +

This is a reference Exercise 3.

+

This is a second reference some text.

\ No newline at end of file diff --git a/tests/test_exercise_references/_enum_ref_title.sphinx8.html b/tests/test_exercise_references/_enum_ref_title.sphinx8.html new file mode 100644 index 0000000..53e83f8 --- /dev/null +++ b/tests/test_exercise_references/_enum_ref_title.sphinx8.html @@ -0,0 +1,4 @@ +

This is a reference Exercise 3.

+

This is a second reference some text.

+

_enum_ref_notitle

+

_enum_ref_mathtitle

\ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_numref_mathtitle.sphinx7.html b/tests/test_exercise_references/_unenum_numref_mathtitle.sphinx7.html new file mode 100644 index 0000000..93876d4 --- /dev/null +++ b/tests/test_exercise_references/_unenum_numref_mathtitle.sphinx7.html @@ -0,0 +1,4 @@ +

This is a reference unen-exc-label-math.

+

This is a second reference some text %s.

+

This is a third reference some text {number}.

+

This is a fourth reference some text {name}.

\ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_numref_mathtitle.sphinx8.html b/tests/test_exercise_references/_unenum_numref_mathtitle.sphinx8.html new file mode 100644 index 0000000..0773678 --- /dev/null +++ b/tests/test_exercise_references/_unenum_numref_mathtitle.sphinx8.html @@ -0,0 +1,6 @@ +

This is a reference unen-exc-label-math.

+

This is a second reference some text %s.

+

This is a third reference some text {number}.

+

This is a fourth reference some text {name}.

+

_unenum_numref_title

+

_enum_numref_placeholders

\ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_numref_notitle.sphinx7.html b/tests/test_exercise_references/_unenum_numref_notitle.sphinx7.html new file mode 100644 index 0000000..a952ce1 --- /dev/null +++ b/tests/test_exercise_references/_unenum_numref_notitle.sphinx7.html @@ -0,0 +1,4 @@ +

This is a reference unen-exc-notitle.

+

This is a second reference some text %s.

+

This is a third reference some text {number}.

+

This is a fourth reference some text {name}.

\ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_numref_notitle.sphinx8.html b/tests/test_exercise_references/_unenum_numref_notitle.sphinx8.html new file mode 100644 index 0000000..a7329f2 --- /dev/null +++ b/tests/test_exercise_references/_unenum_numref_notitle.sphinx8.html @@ -0,0 +1,6 @@ +

This is a reference unen-exc-notitle.

+

This is a second reference some text %s.

+

This is a third reference some text {number}.

+

This is a fourth reference some text {name}.

+

_unenum_ref_mathtitle

+

_unenum_numref_title

\ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_numref_title.sphinx7.html b/tests/test_exercise_references/_unenum_numref_title.sphinx7.html new file mode 100644 index 0000000..0bc31c3 --- /dev/null +++ b/tests/test_exercise_references/_unenum_numref_title.sphinx7.html @@ -0,0 +1,4 @@ +

This is a reference unen-exc-label.

+

This is a second reference some text %s.

+

This is a third reference some text {number}.

+

This is a fourth reference some text {name}.

\ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_numref_title.sphinx8.html b/tests/test_exercise_references/_unenum_numref_title.sphinx8.html new file mode 100644 index 0000000..25c62f2 --- /dev/null +++ b/tests/test_exercise_references/_unenum_numref_title.sphinx8.html @@ -0,0 +1,6 @@ +

This is a reference unen-exc-label.

+

This is a second reference some text %s.

+

This is a third reference some text {number}.

+

This is a fourth reference some text {name}.

+

_unenum_numref_notitle

+

_unenum_numref_mathtitle

\ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_ref_mathtitle.sphinx7.html b/tests/test_exercise_references/_unenum_ref_mathtitle.sphinx7.html new file mode 100644 index 0000000..a4a4bf8 --- /dev/null +++ b/tests/test_exercise_references/_unenum_ref_mathtitle.sphinx7.html @@ -0,0 +1,2 @@ +

This is a reference Exercise.

+

This is a second reference some text.

\ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_ref_mathtitle.sphinx8.html b/tests/test_exercise_references/_unenum_ref_mathtitle.sphinx8.html new file mode 100644 index 0000000..3a9cdc0 --- /dev/null +++ b/tests/test_exercise_references/_unenum_ref_mathtitle.sphinx8.html @@ -0,0 +1,4 @@ +

This is a reference Exercise.

+

This is a second reference some text.

+

_unenum_ref_title

+

_unenum_numref_notitle

\ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_ref_notitle.sphinx7.html b/tests/test_exercise_references/_unenum_ref_notitle.sphinx7.html new file mode 100644 index 0000000..c20af93 --- /dev/null +++ b/tests/test_exercise_references/_unenum_ref_notitle.sphinx7.html @@ -0,0 +1,2 @@ +

This is a reference Exercise.

+

This is a second reference some text.

\ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_ref_notitle.sphinx8.html b/tests/test_exercise_references/_unenum_ref_notitle.sphinx8.html new file mode 100644 index 0000000..9678f3d --- /dev/null +++ b/tests/test_exercise_references/_unenum_ref_notitle.sphinx8.html @@ -0,0 +1,4 @@ +

This is a reference Exercise.

+

This is a second reference some text.

+

_unenum_title_nolabel

+

_unenum_ref_title

\ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_ref_title.sphinx7.html b/tests/test_exercise_references/_unenum_ref_title.sphinx7.html new file mode 100644 index 0000000..50ea0dd --- /dev/null +++ b/tests/test_exercise_references/_unenum_ref_title.sphinx7.html @@ -0,0 +1,2 @@ +

This is a reference Exercise.

+

This is a second reference some text.

\ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_ref_title.sphinx8.html b/tests/test_exercise_references/_unenum_ref_title.sphinx8.html new file mode 100644 index 0000000..f9e2427 --- /dev/null +++ b/tests/test_exercise_references/_unenum_ref_title.sphinx8.html @@ -0,0 +1,4 @@ +

This is a reference Exercise.

+

This is a second reference some text.

+

_unenum_ref_notitle

+

_unenum_ref_mathtitle

\ No newline at end of file diff --git a/tests/test_gateddirective.py b/tests/test_gateddirective.py index 4a493ca..3bdc616 100644 --- a/tests/test_gateddirective.py +++ b/tests/test_gateddirective.py @@ -5,7 +5,7 @@ from bs4 import BeautifulSoup from sphinx.errors import ExtensionError from pathlib import Path -from sphinx.testing.util import strip_escseq +from sphinx.util.console import strip_escape_sequences as strip_escseq SPHINX_VERSION = f".sphinx{sphinx.version_info[0]}" @@ -20,7 +20,9 @@ def test_gated_exercise_build(app, docname, file_regression): exercise_directives = soup.select("div.exercise") for idx, ed in enumerate(exercise_directives): basename = docname.split(".")[0] + f"-{idx}" - file_regression.check(str(ed), basename=basename, extension=".html") + file_regression.check( + str(ed), basename=basename, extension=f"{SPHINX_VERSION}.html" + ) @pytest.mark.sphinx("html", testroot="gateddirective") @@ -35,6 +37,7 @@ def test_gated_exercise_doctree(app, docname, get_sphinx_app_doctree): docname, resolve=False, regress=True, + sphinx_version=SPHINX_VERSION, ) diff --git a/tests/test_gateddirective/exercise-gated-0.sphinx7.html b/tests/test_gateddirective/exercise-gated-0.sphinx7.html new file mode 100644 index 0000000..efd2440 --- /dev/null +++ b/tests/test_gateddirective/exercise-gated-0.sphinx7.html @@ -0,0 +1,9 @@ +
+

Exercise 3

+
+

Replicate this figure using matplotlib

+
+_images/sphx_glr_cohere_001_2_0x.png +
+
+
\ No newline at end of file diff --git a/tests/test_gateddirective/exercise-gated-0.sphinx8.html b/tests/test_gateddirective/exercise-gated-0.sphinx8.html new file mode 100644 index 0000000..efd2440 --- /dev/null +++ b/tests/test_gateddirective/exercise-gated-0.sphinx8.html @@ -0,0 +1,9 @@ +
+

Exercise 3

+
+

Replicate this figure using matplotlib

+
+_images/sphx_glr_cohere_001_2_0x.png +
+
+
\ No newline at end of file diff --git a/tests/test_gateddirective/exercise-gated-1.sphinx7.html b/tests/test_gateddirective/exercise-gated-1.sphinx7.html new file mode 100644 index 0000000..bded47e --- /dev/null +++ b/tests/test_gateddirective/exercise-gated-1.sphinx7.html @@ -0,0 +1,8 @@ +
+

Exercise 4 (Replicate Matplotlib Plot)

+
+
+_images/sphx_glr_cohere_001_2_0x.png +
+
+
\ No newline at end of file diff --git a/tests/test_gateddirective/exercise-gated-1.sphinx8.html b/tests/test_gateddirective/exercise-gated-1.sphinx8.html new file mode 100644 index 0000000..bded47e --- /dev/null +++ b/tests/test_gateddirective/exercise-gated-1.sphinx8.html @@ -0,0 +1,8 @@ +
+

Exercise 4 (Replicate Matplotlib Plot)

+
+
+_images/sphx_glr_cohere_001_2_0x.png +
+
+
\ No newline at end of file diff --git a/tests/test_gateddirective/exercise-gated.sphinx7.xml b/tests/test_gateddirective/exercise-gated.sphinx7.xml new file mode 100644 index 0000000..40285bf --- /dev/null +++ b/tests/test_gateddirective/exercise-gated.sphinx7.xml @@ -0,0 +1,24 @@ + +
+ + Gated Exercises + <paragraph> + Some Gated reference exercises + <exercise_enumerable_node classes="exercise" docname="exercise-gated" hidden="False" ids="gated-exercise-1" label="gated-exercise-1" names="gated-exercise-1" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <section ids="exercise-content"> + <paragraph> + Replicate this figure using matplotlib + <figure> + <image candidates="{'*': 'sphx_glr_cohere_001_2_0x.png'}" uri="sphx_glr_cohere_001_2_0x.png"> + <paragraph> + and another version with a title embedded + <exercise_enumerable_node classes="exercise" docname="exercise-gated" hidden="False" ids="gated-exercise-2" label="gated-exercise-2" names="gated-exercise-2" serial_number="1" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + Replicate Matplotlib Plot + <section ids="exercise-content"> + <figure> + <image candidates="{'*': 'sphx_glr_cohere_001_2_0x.png'}" uri="sphx_glr_cohere_001_2_0x.png"> diff --git a/tests/test_gateddirective/exercise-gated.sphinx8.xml b/tests/test_gateddirective/exercise-gated.sphinx8.xml new file mode 100644 index 0000000..40285bf --- /dev/null +++ b/tests/test_gateddirective/exercise-gated.sphinx8.xml @@ -0,0 +1,24 @@ +<document source="exercise-gated.md"> + <section ids="gated-exercises" names="gated\ exercises"> + <title> + Gated Exercises + <paragraph> + Some Gated reference exercises + <exercise_enumerable_node classes="exercise" docname="exercise-gated" hidden="False" ids="gated-exercise-1" label="gated-exercise-1" names="gated-exercise-1" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <section ids="exercise-content"> + <paragraph> + Replicate this figure using matplotlib + <figure> + <image candidates="{'*': 'sphx_glr_cohere_001_2_0x.png'}" uri="sphx_glr_cohere_001_2_0x.png"> + <paragraph> + and another version with a title embedded + <exercise_enumerable_node classes="exercise" docname="exercise-gated" hidden="False" ids="gated-exercise-2" label="gated-exercise-2" names="gated-exercise-2" serial_number="1" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + Replicate Matplotlib Plot + <section ids="exercise-content"> + <figure> + <image candidates="{'*': 'sphx_glr_cohere_001_2_0x.png'}" uri="sphx_glr_cohere_001_2_0x.png"> diff --git a/tests/test_gateddirective/solution-exercise-0.sphinx7.html b/tests/test_gateddirective/solution-exercise-0.sphinx7.html index 3d8d02b..b6fc437 100644 --- a/tests/test_gateddirective/solution-exercise-0.sphinx7.html +++ b/tests/test_gateddirective/solution-exercise-0.sphinx7.html @@ -4,8 +4,8 @@ <p>This is a solution to Non-Gated Exercise 1</p> <div class="cell docutils container"> <div class="cell_input docutils container"> -<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> -<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span> +<span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span> <span class="c1"># Fixing random state for reproducibility</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">19680801</span><span class="p">)</span> @@ -35,7 +35,11 @@ </div> </div> <div class="cell_output docutils container"> -<img alt="_images/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png" src="_images/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png"/> +<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) +</pre></div> +</div> +<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> </div> </div> <p>With some follow up text to the solution</p> diff --git a/tests/test_gateddirective/solution-exercise-0.sphinx8.html b/tests/test_gateddirective/solution-exercise-0.sphinx8.html new file mode 100644 index 0000000..b6fc437 --- /dev/null +++ b/tests/test_gateddirective/solution-exercise-0.sphinx8.html @@ -0,0 +1,47 @@ +<div class="solution admonition" id="solution-gated-1"> +<p class="admonition-title">Solution to<a class="reference internal" href="exercise.html#exercise-1"> Exercise 1</a></p> +<section id="solution-content"> +<p>This is a solution to Non-Gated Exercise 1</p> +<div class="cell docutils container"> +<div class="cell_input docutils container"> +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span> +<span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span> + +<span class="c1"># Fixing random state for reproducibility</span> +<span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">19680801</span><span class="p">)</span> + +<span class="n">dt</span> <span class="o">=</span> <span class="mf">0.01</span> +<span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">nse1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 1</span> +<span class="n">nse2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 2</span> + +<span class="c1"># Two signals with a coherent part at 10Hz and a random part</span> +<span class="n">s1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse1</span> +<span class="n">s2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse2</span> + +<span class="n">fig</span><span class="p">,</span> <span class="n">axs</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">s1</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">'time'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> + +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="mi">256</span><span class="p">,</span> <span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> + +<span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> +<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> +</pre></div> +</div> +</div> +<div class="cell_output docutils container"> +<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) +</pre></div> +</div> +<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> +</div> +</div> +<p>With some follow up text to the solution</p> +</section> +</div> \ No newline at end of file diff --git a/tests/test_gateddirective/solution-exercise-1.sphinx7.html b/tests/test_gateddirective/solution-exercise-1.sphinx7.html index 3adf959..64d29f5 100644 --- a/tests/test_gateddirective/solution-exercise-1.sphinx7.html +++ b/tests/test_gateddirective/solution-exercise-1.sphinx7.html @@ -4,8 +4,8 @@ <p>This is a solution to Non-Gated Exercise 1</p> <div class="cell docutils container"> <div class="cell_input docutils container"> -<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> -<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span> +<span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span> <span class="c1"># Fixing random state for reproducibility</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">19680801</span><span class="p">)</span> @@ -35,7 +35,11 @@ </div> </div> <div class="cell_output docutils container"> -<img alt="_images/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png" src="_images/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png"/> +<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) +</pre></div> +</div> +<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> </div> </div> <p>With some follow up text to the solution</p> diff --git a/tests/test_gateddirective/solution-exercise-1.sphinx8.html b/tests/test_gateddirective/solution-exercise-1.sphinx8.html new file mode 100644 index 0000000..64d29f5 --- /dev/null +++ b/tests/test_gateddirective/solution-exercise-1.sphinx8.html @@ -0,0 +1,47 @@ +<div class="solution admonition" id="solution-gated-2"> +<p class="admonition-title">Solution to<a class="reference internal" href="exercise.html#exercise-2"> Exercise 2 (Replicate Matplotlib Plot)</a></p> +<section id="solution-content"> +<p>This is a solution to Non-Gated Exercise 1</p> +<div class="cell docutils container"> +<div class="cell_input docutils container"> +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span> +<span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span> + +<span class="c1"># Fixing random state for reproducibility</span> +<span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">19680801</span><span class="p">)</span> + +<span class="n">dt</span> <span class="o">=</span> <span class="mf">0.01</span> +<span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">nse1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 1</span> +<span class="n">nse2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 2</span> + +<span class="c1"># Two signals with a coherent part at 10Hz and a random part</span> +<span class="n">s1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse1</span> +<span class="n">s2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse2</span> + +<span class="n">fig</span><span class="p">,</span> <span class="n">axs</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">s1</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">'time'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> + +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="mi">256</span><span class="p">,</span> <span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> + +<span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> +<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> +</pre></div> +</div> +</div> +<div class="cell_output docutils container"> +<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) +</pre></div> +</div> +<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> +</div> +</div> +<p>With some follow up text to the solution</p> +</section> +</div> \ No newline at end of file diff --git a/tests/test_gateddirective/solution-exercise-gated-0.sphinx7.html b/tests/test_gateddirective/solution-exercise-gated-0.sphinx7.html index 9bedded..e8229c0 100644 --- a/tests/test_gateddirective/solution-exercise-gated-0.sphinx7.html +++ b/tests/test_gateddirective/solution-exercise-gated-0.sphinx7.html @@ -4,8 +4,8 @@ <p>This is a solution to Gated Exercise 1</p> <div class="cell docutils container"> <div class="cell_input docutils container"> -<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> -<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span> +<span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span> <span class="c1"># Fixing random state for reproducibility</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">19680801</span><span class="p">)</span> @@ -35,7 +35,11 @@ </div> </div> <div class="cell_output docutils container"> -<img alt="_images/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png" src="_images/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png"/> +<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) +</pre></div> +</div> +<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> </div> </div> <p>With some follow up text to the solution</p> diff --git a/tests/test_gateddirective/solution-exercise-gated-0.sphinx8.html b/tests/test_gateddirective/solution-exercise-gated-0.sphinx8.html new file mode 100644 index 0000000..e8229c0 --- /dev/null +++ b/tests/test_gateddirective/solution-exercise-gated-0.sphinx8.html @@ -0,0 +1,47 @@ +<div class="solution admonition" id="gated-exercise-solution-1"> +<p class="admonition-title">Solution to<a class="reference internal" href="exercise-gated.html#gated-exercise-1"> Exercise 3</a></p> +<section id="solution-content"> +<p>This is a solution to Gated Exercise 1</p> +<div class="cell docutils container"> +<div class="cell_input docutils container"> +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span> +<span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span> + +<span class="c1"># Fixing random state for reproducibility</span> +<span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">19680801</span><span class="p">)</span> + +<span class="n">dt</span> <span class="o">=</span> <span class="mf">0.01</span> +<span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">nse1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 1</span> +<span class="n">nse2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 2</span> + +<span class="c1"># Two signals with a coherent part at 10Hz and a random part</span> +<span class="n">s1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse1</span> +<span class="n">s2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse2</span> + +<span class="n">fig</span><span class="p">,</span> <span class="n">axs</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">s1</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">'time'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> + +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="mi">256</span><span class="p">,</span> <span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> + +<span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> +<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> +</pre></div> +</div> +</div> +<div class="cell_output docutils container"> +<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) +</pre></div> +</div> +<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> +</div> +</div> +<p>With some follow up text to the solution</p> +</section> +</div> \ No newline at end of file diff --git a/tests/test_gateddirective/solution-exercise-gated-1.sphinx7.html b/tests/test_gateddirective/solution-exercise-gated-1.sphinx7.html index e93bf84..96c2fc3 100644 --- a/tests/test_gateddirective/solution-exercise-gated-1.sphinx7.html +++ b/tests/test_gateddirective/solution-exercise-gated-1.sphinx7.html @@ -4,8 +4,8 @@ <p>This is a solution to Gated Exercise 2</p> <div class="cell docutils container"> <div class="cell_input docutils container"> -<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span> -<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span> +<span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span> <span class="c1"># Fixing random state for reproducibility</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">19680801</span><span class="p">)</span> @@ -35,7 +35,11 @@ </div> </div> <div class="cell_output docutils container"> -<img alt="_images/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png" src="_images/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png"/> +<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) +</pre></div> +</div> +<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> </div> </div> <p>With some follow up text to the solution</p> diff --git a/tests/test_gateddirective/solution-exercise-gated-1.sphinx8.html b/tests/test_gateddirective/solution-exercise-gated-1.sphinx8.html new file mode 100644 index 0000000..96c2fc3 --- /dev/null +++ b/tests/test_gateddirective/solution-exercise-gated-1.sphinx8.html @@ -0,0 +1,47 @@ +<div class="solution admonition" id="gated-exercise-solution-2"> +<p class="admonition-title">Solution to<a class="reference internal" href="exercise-gated.html#gated-exercise-2"> Exercise 4 (Replicate Matplotlib Plot)</a></p> +<section id="solution-content"> +<p>This is a solution to Gated Exercise 2</p> +<div class="cell docutils container"> +<div class="cell_input docutils container"> +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span> +<span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span> + +<span class="c1"># Fixing random state for reproducibility</span> +<span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">19680801</span><span class="p">)</span> + +<span class="n">dt</span> <span class="o">=</span> <span class="mf">0.01</span> +<span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">nse1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 1</span> +<span class="n">nse2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 2</span> + +<span class="c1"># Two signals with a coherent part at 10Hz and a random part</span> +<span class="n">s1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse1</span> +<span class="n">s2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse2</span> + +<span class="n">fig</span><span class="p">,</span> <span class="n">axs</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">s1</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">'time'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> + +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="mi">256</span><span class="p">,</span> <span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> + +<span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> +<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> +</pre></div> +</div> +</div> +<div class="cell_output docutils container"> +<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) +</pre></div> +</div> +<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> +</div> +</div> +<p>With some follow up text to the solution</p> +</section> +</div> \ No newline at end of file diff --git a/tests/test_gateddirective/solution-exercise-gated.sphinx7.xml b/tests/test_gateddirective/solution-exercise-gated.sphinx7.xml index c84d9a3..4ae085a 100644 --- a/tests/test_gateddirective/solution-exercise-gated.sphinx7.xml +++ b/tests/test_gateddirective/solution-exercise-gated.sphinx7.xml @@ -41,12 +41,15 @@ fig.tight_layout() plt.show() <container classes="cell_output" nb_element="cell_code_output"> + <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> + /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) <container nb_element="mime_bundle"> <container mime_type="text/plain"> <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> <Figure size 640x480 with 2 Axes> <container mime_type="image/png"> - <image candidates="{'*': '_build/jupyter_execute/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png'}" uri="_build/jupyter_execute/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png"> + <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> <paragraph> With some follow up text to the solution <paragraph> @@ -93,12 +96,15 @@ fig.tight_layout() plt.show() <container classes="cell_output" nb_element="cell_code_output"> + <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> + /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) <container nb_element="mime_bundle"> <container mime_type="text/plain"> <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> <Figure size 640x480 with 2 Axes> <container mime_type="image/png"> - <image candidates="{'*': '_build/jupyter_execute/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png'}" uri="_build/jupyter_execute/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png"> + <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> <paragraph> With some follow up text to the solution <section ids="references-to-solutions" names="references\ to\ solutions"> diff --git a/tests/test_gateddirective/solution-exercise-gated.sphinx8.xml b/tests/test_gateddirective/solution-exercise-gated.sphinx8.xml new file mode 100644 index 0000000..4ae085a --- /dev/null +++ b/tests/test_gateddirective/solution-exercise-gated.sphinx8.xml @@ -0,0 +1,117 @@ +<document source="solution-exercise-gated.md"> + <section ids="gated-solutions-to-exercise-gated-md" names="gated\ solutions\ to\ exercise-gated.md"> + <title> + Gated Solutions to exercise-gated.md + <paragraph> + A solution using the gated directive + <solution_node classes="solution" docname="solution-exercise-gated" hidden="False" ids="gated-exercise-solution-1" label="gated-exercise-solution-1" names="gated-exercise-solution-1" serial_number="0" target_label="gated-exercise-1" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + This is a solution to Gated Exercise 1 + <container cell_index="1" cell_metadata="{}" classes="cell" exec_count="1" nb_element="cell_code"> + <container classes="cell_input" nb_element="cell_code_source"> + <literal_block language="ipython3" xml:space="preserve"> + import numpy as np + import matplotlib.pyplot as plt + + # Fixing random state for reproducibility + np.random.seed(19680801) + + dt = 0.01 + t = np.arange(0, 30, dt) + nse1 = np.random.randn(len(t)) # white noise 1 + nse2 = np.random.randn(len(t)) # white noise 2 + + # Two signals with a coherent part at 10Hz and a random part + s1 = np.sin(2 * np.pi * 10 * t) + nse1 + s2 = np.sin(2 * np.pi * 10 * t) + nse2 + + fig, axs = plt.subplots(2, 1) + axs[0].plot(t, s1, t, s2) + axs[0].set_xlim(0, 2) + axs[0].set_xlabel('time') + axs[0].set_ylabel('s1 and s2') + axs[0].grid(True) + + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + axs[1].set_ylabel('coherence') + + fig.tight_layout() + plt.show() + <container classes="cell_output" nb_element="cell_code_output"> + <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> + /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + <container nb_element="mime_bundle"> + <container mime_type="text/plain"> + <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> + <Figure size 640x480 with 2 Axes> + <container mime_type="image/png"> + <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> + <paragraph> + With some follow up text to the solution + <paragraph> + and then a solution to + <pending_xref refdoc="solution-exercise-gated" refdomain="std" refexplicit="False" reftarget="gated-exercise-2" reftype="ref" refwarn="True"> + <inline classes="xref std std-ref"> + gated-exercise-2 + <paragraph> + A solution using the gated directive + <solution_node classes="solution" docname="solution-exercise-gated" hidden="False" ids="gated-exercise-solution-2" label="gated-exercise-solution-2" names="gated-exercise-solution-2" serial_number="1" target_label="gated-exercise-2" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + This is a solution to Gated Exercise 2 + <container cell_index="3" cell_metadata="{}" classes="cell" exec_count="2" nb_element="cell_code"> + <container classes="cell_input" nb_element="cell_code_source"> + <literal_block language="ipython3" xml:space="preserve"> + import numpy as np + import matplotlib.pyplot as plt + + # Fixing random state for reproducibility + np.random.seed(19680801) + + dt = 0.01 + t = np.arange(0, 30, dt) + nse1 = np.random.randn(len(t)) # white noise 1 + nse2 = np.random.randn(len(t)) # white noise 2 + + # Two signals with a coherent part at 10Hz and a random part + s1 = np.sin(2 * np.pi * 10 * t) + nse1 + s2 = np.sin(2 * np.pi * 10 * t) + nse2 + + fig, axs = plt.subplots(2, 1) + axs[0].plot(t, s1, t, s2) + axs[0].set_xlim(0, 2) + axs[0].set_xlabel('time') + axs[0].set_ylabel('s1 and s2') + axs[0].grid(True) + + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + axs[1].set_ylabel('coherence') + + fig.tight_layout() + plt.show() + <container classes="cell_output" nb_element="cell_code_output"> + <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> + /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + <container nb_element="mime_bundle"> + <container mime_type="text/plain"> + <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> + <Figure size 640x480 with 2 Axes> + <container mime_type="image/png"> + <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> + <paragraph> + With some follow up text to the solution + <section ids="references-to-solutions" names="references\ to\ solutions"> + <title> + References to Solutions + <paragraph> + This is a reference to + <pending_xref refdoc="solution-exercise-gated" refdomain="std" refexplicit="False" reftarget="gated-exercise-solution-1" reftype="ref" refwarn="True"> + <inline classes="xref std std-ref"> + gated-exercise-solution-1 diff --git a/tests/test_gateddirective/solution-exercise.sphinx7.xml b/tests/test_gateddirective/solution-exercise.sphinx7.xml index 87a7dbc..ba8c92d 100644 --- a/tests/test_gateddirective/solution-exercise.sphinx7.xml +++ b/tests/test_gateddirective/solution-exercise.sphinx7.xml @@ -41,12 +41,15 @@ fig.tight_layout() plt.show() <container classes="cell_output" nb_element="cell_code_output"> + <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> + /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) <container nb_element="mime_bundle"> <container mime_type="text/plain"> <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> <Figure size 640x480 with 2 Axes> <container mime_type="image/png"> - <image candidates="{'*': '_build/jupyter_execute/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png'}" uri="_build/jupyter_execute/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png"> + <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> <paragraph> With some follow up text to the solution <paragraph> @@ -91,12 +94,15 @@ fig.tight_layout() plt.show() <container classes="cell_output" nb_element="cell_code_output"> + <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> + /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) <container nb_element="mime_bundle"> <container mime_type="text/plain"> <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> <Figure size 640x480 with 2 Axes> <container mime_type="image/png"> - <image candidates="{'*': '_build/jupyter_execute/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png'}" uri="_build/jupyter_execute/e54e180c35e94dd0df219d42c2477d4c5763db55da00a21803bd9ce8f9859cb2.png"> + <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> <paragraph> With some follow up text to the solution <section ids="references" names="references"> diff --git a/tests/test_gateddirective/solution-exercise.sphinx8.xml b/tests/test_gateddirective/solution-exercise.sphinx8.xml new file mode 100644 index 0000000..ba8c92d --- /dev/null +++ b/tests/test_gateddirective/solution-exercise.sphinx8.xml @@ -0,0 +1,120 @@ +<document source="solution-exercise.md"> + <section ids="gated-solutions-to-exercise-md" names="gated\ solutions\ to\ exercise.md"> + <title> + Gated Solutions to exercise.md + <paragraph> + A solution using the gated directive + <solution_node classes="solution" docname="solution-exercise" hidden="False" ids="solution-gated-1" label="solution-gated-1" names="solution-gated-1" serial_number="0" target_label="exercise-1" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + This is a solution to Non-Gated Exercise 1 + <container cell_index="1" cell_metadata="{}" classes="cell" exec_count="1" nb_element="cell_code"> + <container classes="cell_input" nb_element="cell_code_source"> + <literal_block language="ipython3" xml:space="preserve"> + import numpy as np + import matplotlib.pyplot as plt + + # Fixing random state for reproducibility + np.random.seed(19680801) + + dt = 0.01 + t = np.arange(0, 30, dt) + nse1 = np.random.randn(len(t)) # white noise 1 + nse2 = np.random.randn(len(t)) # white noise 2 + + # Two signals with a coherent part at 10Hz and a random part + s1 = np.sin(2 * np.pi * 10 * t) + nse1 + s2 = np.sin(2 * np.pi * 10 * t) + nse2 + + fig, axs = plt.subplots(2, 1) + axs[0].plot(t, s1, t, s2) + axs[0].set_xlim(0, 2) + axs[0].set_xlabel('time') + axs[0].set_ylabel('s1 and s2') + axs[0].grid(True) + + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + axs[1].set_ylabel('coherence') + + fig.tight_layout() + plt.show() + <container classes="cell_output" nb_element="cell_code_output"> + <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> + /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + <container nb_element="mime_bundle"> + <container mime_type="text/plain"> + <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> + <Figure size 640x480 with 2 Axes> + <container mime_type="image/png"> + <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> + <paragraph> + With some follow up text to the solution + <paragraph> + and a solution to + <pending_xref refdoc="solution-exercise" refdomain="std" refexplicit="False" reftarget="exercise-2" reftype="ref" refwarn="True"> + <inline classes="xref std std-ref"> + exercise-2 + <solution_node classes="solution" docname="solution-exercise" hidden="False" ids="solution-gated-2" label="solution-gated-2" names="solution-gated-2" serial_number="1" target_label="exercise-2" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + This is a solution to Non-Gated Exercise 1 + <container cell_index="3" cell_metadata="{}" classes="cell" exec_count="2" nb_element="cell_code"> + <container classes="cell_input" nb_element="cell_code_source"> + <literal_block language="ipython3" xml:space="preserve"> + import numpy as np + import matplotlib.pyplot as plt + + # Fixing random state for reproducibility + np.random.seed(19680801) + + dt = 0.01 + t = np.arange(0, 30, dt) + nse1 = np.random.randn(len(t)) # white noise 1 + nse2 = np.random.randn(len(t)) # white noise 2 + + # Two signals with a coherent part at 10Hz and a random part + s1 = np.sin(2 * np.pi * 10 * t) + nse1 + s2 = np.sin(2 * np.pi * 10 * t) + nse2 + + fig, axs = plt.subplots(2, 1) + axs[0].plot(t, s1, t, s2) + axs[0].set_xlim(0, 2) + axs[0].set_xlabel('time') + axs[0].set_ylabel('s1 and s2') + axs[0].grid(True) + + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + axs[1].set_ylabel('coherence') + + fig.tight_layout() + plt.show() + <container classes="cell_output" nb_element="cell_code_output"> + <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> + /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. + cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + <container nb_element="mime_bundle"> + <container mime_type="text/plain"> + <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> + <Figure size 640x480 with 2 Axes> + <container mime_type="image/png"> + <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> + <paragraph> + With some follow up text to the solution + <section ids="references" names="references"> + <title> + References + <paragraph> + This is a reference to + <pending_xref refdoc="solution-exercise" refdomain="std" refexplicit="False" reftarget="solution-gated-1" reftype="ref" refwarn="True"> + <inline classes="xref std std-ref"> + solution-gated-1 + <paragraph> + This is a reference to + <pending_xref refdoc="solution-exercise" refdomain="std" refexplicit="False" reftarget="solution-gated-2" reftype="ref" refwarn="True"> + <inline classes="xref std std-ref"> + solution-gated-2 diff --git a/tests/test_latex/test_latex_build.sphinx8.tex b/tests/test_latex/test_latex_build.sphinx8.tex new file mode 100644 index 0000000..f6293f6 --- /dev/null +++ b/tests/test_latex/test_latex_build.sphinx8.tex @@ -0,0 +1,181 @@ +\begin{document} + +\ifdefined\shorthandoff + \ifnum\catcode`\=\string=\active\shorthandoff{=}\fi + \ifnum\catcode`\"=\active\shorthandoff{"}\fi +\fi + +\pagestyle{empty} +\sphinxmaketitle +\pagestyle{plain} +\sphinxtableofcontents +\pagestyle{normal} +\phantomsection\label{\detokenize{index::doc}} + + +\sphinxstepscope + + +\chapter{Exercise} +\label{\detokenize{exercise:exercise}}\label{\detokenize{exercise::doc}} +\sphinxAtStartPar +A collection of exercise directives +\phantomsection \label{exercise:exercise-1} + +\begin{sphinxadmonition}{note}{Exercise 1 (\protect\(n!\protect\) factorial)} + + + +\sphinxAtStartPar +Exercise 1 about \(n!\) factorial +\end{sphinxadmonition} +\phantomsection \label{exercise:exercise-2} +\begin{sphinxadmonition}{note}{Exercise (\protect\(n!\protect\) factorial)} + + + +\sphinxAtStartPar +Exercise 2 about \(n!\) factorial +\end{sphinxadmonition} +\phantomsection \label{exercise:exercise-3} + +\begin{sphinxadmonition}{note}{Exercise 2} + + + +\sphinxAtStartPar +Exercise 3 Content with Number +\end{sphinxadmonition} +\phantomsection \label{exercise:exercise-4} +\begin{sphinxadmonition}{note}{Exercise} + + + +\sphinxAtStartPar +Exercise 4 Content with no Number +\end{sphinxadmonition} + + +\section{References} +\label{\detokenize{exercise:references}} + +\subsection{Standard References} +\label{\detokenize{exercise:standard-references}} +\sphinxAtStartPar +This is a link to \DUrole{xref}{\DUrole{std}{\DUrole{std-ref}{exercise\sphinxhyphen{}no\sphinxhyphen{}title}}} + +\sphinxAtStartPar +This is a link to \hyperref[exercise:exercise-1]{Exercise 1} + +\sphinxAtStartPar +This is a link to {\hyperref[\detokenize{exercise:exercise-2}]{\sphinxcrossref{\DUrole{std}{\DUrole{std-ref}{Exercise}}}}} + +\sphinxAtStartPar +This ia another link with custom text \hyperref[exercise:exercise-3]{Exercise 3 Custom Text} + +\sphinxAtStartPar +This ia another link with custom text {\hyperref[\detokenize{exercise:exercise-4}]{\sphinxcrossref{\DUrole{std}{\DUrole{std-ref}{Exercise 4 Custom Text}}}}} + + +\subsection{Numbered References} +\label{\detokenize{exercise:numbered-references}} +\sphinxAtStartPar +This is a numbered reference to \hyperref[exercise:exercise-1]{Exercise 1} + +\sphinxAtStartPar +This is a numbered reference to \sphinxcode{\sphinxupquote{exercise\sphinxhyphen{}2}} and should be broken as exercise 2 is not an +enumerated exercise node. + +\sphinxAtStartPar +This is a numbered reference to \hyperref[exercise:exercise-3]{Exercise 2} + +\sphinxAtStartPar +This is a numbered reference with custom text to \hyperref[exercise:exercise-3]{Custom Text with a Number 2} + +\sphinxAtStartPar +This is a numbered reference to \sphinxcode{\sphinxupquote{exercise\sphinxhyphen{}4}} and should be broken as exercise 2 is not an +enumerated exercise node. + +\sphinxAtStartPar +This is a numbered reference with custom text to \sphinxcode{\sphinxupquote{Custom Text with a Number \{number\}}} and should be broken as exercise 2 is not an +enumerated exercise node. + +\sphinxstepscope + + +\chapter{Solution} +\label{\detokenize{solution:solution}}\label{\detokenize{solution::doc}} +\sphinxAtStartPar +A collection of solution directives +\phantomsection \label{solution:solution-1} + +\begin{sphinxadmonition}{note}{Solution to Exercise 1 (\protect\(n!\protect\) factorial)} + + + +\sphinxAtStartPar +This is a solution to exercise 1 +\end{sphinxadmonition} +\phantomsection \label{solution:solution-2} + +\begin{sphinxadmonition}{note}{Solution to Exercise (\protect\(n!\protect\) factorial)} + + + +\sphinxAtStartPar +This is a solution to exercise 2 +\end{sphinxadmonition} +\phantomsection \label{solution:solution-3} + +\begin{sphinxadmonition}{note}{Solution to Exercise 2} + + + +\sphinxAtStartPar +This is a solution to exercise 3 +\end{sphinxadmonition} +\phantomsection \label{solution:solution-4} + +\begin{sphinxadmonition}{note}{Solution to Exercise} + + + +\sphinxAtStartPar +This is a solution to exercise 4 +\end{sphinxadmonition} + + +\section{References} +\label{\detokenize{solution:references}} + +\subsection{Standard References} +\label{\detokenize{solution:standard-references}} +\sphinxAtStartPar +This is a link to {\hyperref[\detokenize{solution:solution-1}]{\sphinxcrossref{\DUrole{std}{\DUrole{std-ref}{Solution to Exercise 1 (n! factorial)}}}}} + +\sphinxAtStartPar +This is a link to {\hyperref[\detokenize{solution:solution-2}]{\sphinxcrossref{\DUrole{std}{\DUrole{std-ref}{Solution to Exercise (n! factorial)}}}}} + +\sphinxAtStartPar +This is a link to {\hyperref[\detokenize{solution:solution-3}]{\sphinxcrossref{\DUrole{std}{\DUrole{std-ref}{Solution to Exercise 2}}}}} + +\sphinxAtStartPar +This is a link to {\hyperref[\detokenize{solution:solution-4}]{\sphinxcrossref{\DUrole{std}{\DUrole{std-ref}{Solution to Exercise}}}}} + +\sphinxAtStartPar +This ia another link to a different {\hyperref[\detokenize{solution:solution-1}]{\sphinxcrossref{\DUrole{std}{\DUrole{std-ref}{Solution to Exercise 1 (n! factorial)}}}}} + + +\subsection{Numbered References} +\label{\detokenize{solution:numbered-references}} +\sphinxAtStartPar +Solution nodes are not enumerated nodes so these won’t work + +\sphinxAtStartPar +This is a link to \sphinxcode{\sphinxupquote{solution\sphinxhyphen{}1}} + + + +\renewcommand{\indexname}{Index} +\printindex +\end{document} diff --git a/tests/test_solution.py b/tests/test_solution.py index bbda60b..07c50bc 100644 --- a/tests/test_solution.py +++ b/tests/test_solution.py @@ -1,5 +1,8 @@ from bs4 import BeautifulSoup import pytest +import sphinx + +SPHINX_VERSION = f".sphinx{sphinx.version_info[0]}" @pytest.mark.sphinx("html", testroot="mybook") @@ -48,10 +51,14 @@ def test_solution(app, idir, file_regression): def test_solution_doctree(app, docname, file_regression, get_sphinx_app_doctree): app.build() docname = "solution" + "/" + docname + get_sphinx_app_doctree( + app, docname, resolve=False, regress=True, sphinx_version=SPHINX_VERSION + ) get_sphinx_app_doctree( app, docname, resolve=False, regress=True, flatten_outdir=True, # noqa: E501 flatten files "solution/<file> -> <file>.xml" for convenience + sphinx_version=SPHINX_VERSION, ) diff --git a/tests/test_solution/_linked_duplicate_label.sphinx7.xml b/tests/test_solution/_linked_duplicate_label.sphinx7.xml new file mode 100644 index 0000000..911fa54 --- /dev/null +++ b/tests/test_solution/_linked_duplicate_label.sphinx7.xml @@ -0,0 +1,10 @@ +<document source="_linked_duplicate_label.rst"> + <section ids="linked-duplicate-label" names="_linked_duplicate_label"> + <title> + _linked_duplicate_label + <solution_node classes="solution" docname="solution/_linked_duplicate_label" hidden="False" ids="sol-duplicate-label" label="sol-duplicate-label" names="sol-duplicate-label" serial_number="0" target_label="ex-nonumber-notitle" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_duplicate_label.sphinx8.xml b/tests/test_solution/_linked_duplicate_label.sphinx8.xml new file mode 100644 index 0000000..911fa54 --- /dev/null +++ b/tests/test_solution/_linked_duplicate_label.sphinx8.xml @@ -0,0 +1,10 @@ +<document source="_linked_duplicate_label.rst"> + <section ids="linked-duplicate-label" names="_linked_duplicate_label"> + <title> + _linked_duplicate_label + <solution_node classes="solution" docname="solution/_linked_duplicate_label" hidden="False" ids="sol-duplicate-label" label="sol-duplicate-label" names="sol-duplicate-label" serial_number="0" target_label="ex-nonumber-notitle" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_enum.sphinx7.xml b/tests/test_solution/_linked_enum.sphinx7.xml new file mode 100644 index 0000000..272bd7f --- /dev/null +++ b/tests/test_solution/_linked_enum.sphinx7.xml @@ -0,0 +1,29 @@ +<document source="_linked_enum.rst"> + <section ids="linked-enum" names="_linked_enum"> + <title> + _linked_enum + <exercise_enumerable_node classes="exercise" docname="solution/_linked_enum" hidden="False" ids="ex-number" label="ex-number" names="ex-number" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_enum" hidden="False" ids="sol-number" label="sol-number" names="sol-number" serial_number="1" target_label="ex-number" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <math_block docname="solution/_linked_enum" label="True" nowrap="False" number="True" xml:space="preserve"> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <target refid="equation-ex-math"> + <math_block docname="solution/_linked_enum" ids="equation-ex-math" label="ex-math" nowrap="False" number="1" xml:space="preserve"> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) diff --git a/tests/test_solution/_linked_enum.sphinx8.xml b/tests/test_solution/_linked_enum.sphinx8.xml new file mode 100644 index 0000000..06e6f5f --- /dev/null +++ b/tests/test_solution/_linked_enum.sphinx8.xml @@ -0,0 +1,29 @@ +<document source="_linked_enum.rst"> + <section ids="linked-enum" names="_linked_enum"> + <title> + _linked_enum + <exercise_enumerable_node classes="exercise" docname="solution/_linked_enum" hidden="False" ids="ex-number" label="ex-number" names="ex-number" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_enum" hidden="False" ids="sol-number" label="sol-number" names="sol-number" serial_number="1" target_label="ex-number" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <math_block docname="solution/_linked_enum" label="True" no-wrap="False" nowrap="False" number="True" xml:space="preserve"> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <target refid="equation-ex-math"> + <math_block docname="solution/_linked_enum" ids="equation-ex-math" label="ex-math" no-wrap="False" nowrap="False" number="1" xml:space="preserve"> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) diff --git a/tests/test_solution/_linked_enum.xml b/tests/test_solution/_linked_enum.xml index 272bd7f..06e6f5f 100644 --- a/tests/test_solution/_linked_enum.xml +++ b/tests/test_solution/_linked_enum.xml @@ -20,10 +20,10 @@ <section ids="solution-content"> <paragraph> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - <math_block docname="solution/_linked_enum" label="True" nowrap="False" number="True" xml:space="preserve"> + <math_block docname="solution/_linked_enum" label="True" no-wrap="False" nowrap="False" number="True" xml:space="preserve"> P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) <paragraph> Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. <target refid="equation-ex-math"> - <math_block docname="solution/_linked_enum" ids="equation-ex-math" label="ex-math" nowrap="False" number="1" xml:space="preserve"> + <math_block docname="solution/_linked_enum" ids="equation-ex-math" label="ex-math" no-wrap="False" nowrap="False" number="1" xml:space="preserve"> P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) diff --git a/tests/test_solution/_linked_enum_class.sphinx7.xml b/tests/test_solution/_linked_enum_class.sphinx7.xml new file mode 100644 index 0000000..daa32c8 --- /dev/null +++ b/tests/test_solution/_linked_enum_class.sphinx7.xml @@ -0,0 +1,10 @@ +<document source="_linked_enum_class.rst"> + <section ids="linked-enum-class" names="_linked_enum_class"> + <title> + _linked_enum_class + <solution_node classes="solution test-solution" docname="solution/_linked_enum_class" hidden="False" ids="solution-label" label="solution-label" names="solution-label" serial_number="0" target_label="ex-number" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_enum_class.sphinx8.xml b/tests/test_solution/_linked_enum_class.sphinx8.xml new file mode 100644 index 0000000..daa32c8 --- /dev/null +++ b/tests/test_solution/_linked_enum_class.sphinx8.xml @@ -0,0 +1,10 @@ +<document source="_linked_enum_class.rst"> + <section ids="linked-enum-class" names="_linked_enum_class"> + <title> + _linked_enum_class + <solution_node classes="solution test-solution" docname="solution/_linked_enum_class" hidden="False" ids="solution-label" label="solution-label" names="solution-label" serial_number="0" target_label="ex-number" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_missing_arg.sphinx7.xml b/tests/test_solution/_linked_missing_arg.sphinx7.xml new file mode 100644 index 0000000..6ecb8d7 --- /dev/null +++ b/tests/test_solution/_linked_missing_arg.sphinx7.xml @@ -0,0 +1,4 @@ +<document source="_linked_missing_arg.rst"> + <section ids="linked-missing-arg" names="_linked_missing_arg"> + <title> + _linked_missing_arg diff --git a/tests/test_solution/_linked_missing_arg.sphinx8.xml b/tests/test_solution/_linked_missing_arg.sphinx8.xml new file mode 100644 index 0000000..6ecb8d7 --- /dev/null +++ b/tests/test_solution/_linked_missing_arg.sphinx8.xml @@ -0,0 +1,4 @@ +<document source="_linked_missing_arg.rst"> + <section ids="linked-missing-arg" names="_linked_missing_arg"> + <title> + _linked_missing_arg diff --git a/tests/test_solution/_linked_unenum_mathtitle.sphinx7.xml b/tests/test_solution/_linked_unenum_mathtitle.sphinx7.xml new file mode 100644 index 0000000..d5c931a --- /dev/null +++ b/tests/test_solution/_linked_unenum_mathtitle.sphinx7.xml @@ -0,0 +1,24 @@ +<document source="_linked_unenum_mathtitle.rst"> + <section ids="linked-unenum-mathtitle" names="_linked_unenum_mathtitle"> + <title> + _linked_unenum_mathtitle + <exercise_node classes="exercise" docname="solution/_linked_unenum_mathtitle" hidden="False" ids="ex-nonumber-title-math" label="ex-nonumber-title-math" names="ex-nonumber-title-math" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <math> + \mathbb{R} + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_mathtitle" hidden="False" ids="sol-nonumber-title-math" label="sol-nonumber-title-math" names="sol-nonumber-title-math" serial_number="1" target_label="ex-nonumber-title-math" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_unenum_mathtitle.sphinx8.xml b/tests/test_solution/_linked_unenum_mathtitle.sphinx8.xml new file mode 100644 index 0000000..d5c931a --- /dev/null +++ b/tests/test_solution/_linked_unenum_mathtitle.sphinx8.xml @@ -0,0 +1,24 @@ +<document source="_linked_unenum_mathtitle.rst"> + <section ids="linked-unenum-mathtitle" names="_linked_unenum_mathtitle"> + <title> + _linked_unenum_mathtitle + <exercise_node classes="exercise" docname="solution/_linked_unenum_mathtitle" hidden="False" ids="ex-nonumber-title-math" label="ex-nonumber-title-math" names="ex-nonumber-title-math" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <math> + \mathbb{R} + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_mathtitle" hidden="False" ids="sol-nonumber-title-math" label="sol-nonumber-title-math" names="sol-nonumber-title-math" serial_number="1" target_label="ex-nonumber-title-math" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_unenum_mathtitle2.sphinx7.xml b/tests/test_solution/_linked_unenum_mathtitle2.sphinx7.xml new file mode 100644 index 0000000..a369002 --- /dev/null +++ b/tests/test_solution/_linked_unenum_mathtitle2.sphinx7.xml @@ -0,0 +1,24 @@ +<document source="_linked_unenum_mathtitle2.rst"> + <section ids="linked-unenum-mathtitle2" names="_linked_unenum_mathtitle2"> + <title> + _linked_unenum_mathtitle2 + <exercise_node classes="exercise" docname="solution/_linked_unenum_mathtitle2" hidden="False" ids="ex-nonumber-title-math2" label="ex-nonumber-title-math2" names="ex-nonumber-title-math2" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <math> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_mathtitle2" hidden="False" ids="sol-nonumber-title-math2" label="sol-nonumber-title-math2" names="sol-nonumber-title-math2" serial_number="1" target_label="ex-nonumber-title-math2" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_unenum_mathtitle2.sphinx8.xml b/tests/test_solution/_linked_unenum_mathtitle2.sphinx8.xml new file mode 100644 index 0000000..a369002 --- /dev/null +++ b/tests/test_solution/_linked_unenum_mathtitle2.sphinx8.xml @@ -0,0 +1,24 @@ +<document source="_linked_unenum_mathtitle2.rst"> + <section ids="linked-unenum-mathtitle2" names="_linked_unenum_mathtitle2"> + <title> + _linked_unenum_mathtitle2 + <exercise_node classes="exercise" docname="solution/_linked_unenum_mathtitle2" hidden="False" ids="ex-nonumber-title-math2" label="ex-nonumber-title-math2" names="ex-nonumber-title-math2" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <math> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_mathtitle2" hidden="False" ids="sol-nonumber-title-math2" label="sol-nonumber-title-math2" names="sol-nonumber-title-math2" serial_number="1" target_label="ex-nonumber-title-math2" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_unenum_notitle.sphinx7.xml b/tests/test_solution/_linked_unenum_notitle.sphinx7.xml new file mode 100644 index 0000000..8140aec --- /dev/null +++ b/tests/test_solution/_linked_unenum_notitle.sphinx7.xml @@ -0,0 +1,20 @@ +<document source="_linked_unenum_notitle.rst"> + <section ids="linked-unenum-notitle" names="_linked_unenum_notitle"> + <title> + _linked_unenum_notitle + <exercise_node classes="exercise" docname="solution/_linked_unenum_notitle" hidden="False" ids="ex-nonumber-notitle" label="ex-nonumber-notitle" names="ex-nonumber-notitle" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_notitle" hidden="False" ids="sol-nonumber-notitle" label="sol-nonumber-notitle" names="sol-nonumber-notitle" serial_number="1" target_label="ex-nonumber-notitle" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_unenum_notitle.sphinx8.xml b/tests/test_solution/_linked_unenum_notitle.sphinx8.xml new file mode 100644 index 0000000..8140aec --- /dev/null +++ b/tests/test_solution/_linked_unenum_notitle.sphinx8.xml @@ -0,0 +1,20 @@ +<document source="_linked_unenum_notitle.rst"> + <section ids="linked-unenum-notitle" names="_linked_unenum_notitle"> + <title> + _linked_unenum_notitle + <exercise_node classes="exercise" docname="solution/_linked_unenum_notitle" hidden="False" ids="ex-nonumber-notitle" label="ex-nonumber-notitle" names="ex-nonumber-notitle" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_notitle" hidden="False" ids="sol-nonumber-notitle" label="sol-nonumber-notitle" names="sol-nonumber-notitle" serial_number="1" target_label="ex-nonumber-notitle" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_unenum_title.sphinx7.xml b/tests/test_solution/_linked_unenum_title.sphinx7.xml new file mode 100644 index 0000000..da1dc3f --- /dev/null +++ b/tests/test_solution/_linked_unenum_title.sphinx7.xml @@ -0,0 +1,22 @@ +<document source="_linked_unenum_title.rst"> + <section ids="linked-unenum-title" names="_linked_unenum_title"> + <title> + _linked_unenum_title + <exercise_node classes="exercise" docname="solution/_linked_unenum_title" hidden="False" ids="ex-nonumber-title" label="ex-nonumber-title" names="ex-nonumber-title" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_title" hidden="False" ids="sol-nonumber-title" label="sol-nonumber-title" names="sol-nonumber-title" serial_number="1" target_label="ex-nonumber-title" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_unenum_title.sphinx8.xml b/tests/test_solution/_linked_unenum_title.sphinx8.xml new file mode 100644 index 0000000..da1dc3f --- /dev/null +++ b/tests/test_solution/_linked_unenum_title.sphinx8.xml @@ -0,0 +1,22 @@ +<document source="_linked_unenum_title.rst"> + <section ids="linked-unenum-title" names="_linked_unenum_title"> + <title> + _linked_unenum_title + <exercise_node classes="exercise" docname="solution/_linked_unenum_title" hidden="False" ids="ex-nonumber-title" label="ex-nonumber-title" names="ex-nonumber-title" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_title" hidden="False" ids="sol-nonumber-title" label="sol-nonumber-title" names="sol-nonumber-title" serial_number="1" target_label="ex-nonumber-title" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_wrong_targetlabel.sphinx7.xml b/tests/test_solution/_linked_wrong_targetlabel.sphinx7.xml new file mode 100644 index 0000000..b03b9ac --- /dev/null +++ b/tests/test_solution/_linked_wrong_targetlabel.sphinx7.xml @@ -0,0 +1,10 @@ +<document source="_linked_wrong_targetlabel.rst"> + <section ids="linked-wrong-targetlabel" names="_linked_wrong_targetlabel"> + <title> + _linked_wrong_targetlabel + <solution_node classes="solution" docname="solution/_linked_wrong_targetlabel" hidden="False" ids="solution/_linked_wrong_targetlabel-solution-0" label="solution/_linked_wrong_targetlabel-solution-0" names="solution/_linked_wrong_targetlabel-solution-0" serial_number="0" target_label="wrong-ex-label" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_wrong_targetlabel.sphinx8.xml b/tests/test_solution/_linked_wrong_targetlabel.sphinx8.xml new file mode 100644 index 0000000..b03b9ac --- /dev/null +++ b/tests/test_solution/_linked_wrong_targetlabel.sphinx8.xml @@ -0,0 +1,10 @@ +<document source="_linked_wrong_targetlabel.rst"> + <section ids="linked-wrong-targetlabel" names="_linked_wrong_targetlabel"> + <title> + _linked_wrong_targetlabel + <solution_node classes="solution" docname="solution/_linked_wrong_targetlabel" hidden="False" ids="solution/_linked_wrong_targetlabel-solution-0" label="solution/_linked_wrong_targetlabel-solution-0" names="solution/_linked_wrong_targetlabel-solution-0" serial_number="0" target_label="wrong-ex-label" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_duplicate_label.sphinx7.xml b/tests/test_solution/solution/_linked_duplicate_label.sphinx7.xml new file mode 100644 index 0000000..911fa54 --- /dev/null +++ b/tests/test_solution/solution/_linked_duplicate_label.sphinx7.xml @@ -0,0 +1,10 @@ +<document source="_linked_duplicate_label.rst"> + <section ids="linked-duplicate-label" names="_linked_duplicate_label"> + <title> + _linked_duplicate_label + <solution_node classes="solution" docname="solution/_linked_duplicate_label" hidden="False" ids="sol-duplicate-label" label="sol-duplicate-label" names="sol-duplicate-label" serial_number="0" target_label="ex-nonumber-notitle" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_duplicate_label.sphinx8.xml b/tests/test_solution/solution/_linked_duplicate_label.sphinx8.xml new file mode 100644 index 0000000..911fa54 --- /dev/null +++ b/tests/test_solution/solution/_linked_duplicate_label.sphinx8.xml @@ -0,0 +1,10 @@ +<document source="_linked_duplicate_label.rst"> + <section ids="linked-duplicate-label" names="_linked_duplicate_label"> + <title> + _linked_duplicate_label + <solution_node classes="solution" docname="solution/_linked_duplicate_label" hidden="False" ids="sol-duplicate-label" label="sol-duplicate-label" names="sol-duplicate-label" serial_number="0" target_label="ex-nonumber-notitle" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_enum.sphinx7.xml b/tests/test_solution/solution/_linked_enum.sphinx7.xml new file mode 100644 index 0000000..272bd7f --- /dev/null +++ b/tests/test_solution/solution/_linked_enum.sphinx7.xml @@ -0,0 +1,29 @@ +<document source="_linked_enum.rst"> + <section ids="linked-enum" names="_linked_enum"> + <title> + _linked_enum + <exercise_enumerable_node classes="exercise" docname="solution/_linked_enum" hidden="False" ids="ex-number" label="ex-number" names="ex-number" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_enum" hidden="False" ids="sol-number" label="sol-number" names="sol-number" serial_number="1" target_label="ex-number" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <math_block docname="solution/_linked_enum" label="True" nowrap="False" number="True" xml:space="preserve"> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <target refid="equation-ex-math"> + <math_block docname="solution/_linked_enum" ids="equation-ex-math" label="ex-math" nowrap="False" number="1" xml:space="preserve"> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) diff --git a/tests/test_solution/solution/_linked_enum.sphinx8.xml b/tests/test_solution/solution/_linked_enum.sphinx8.xml new file mode 100644 index 0000000..06e6f5f --- /dev/null +++ b/tests/test_solution/solution/_linked_enum.sphinx8.xml @@ -0,0 +1,29 @@ +<document source="_linked_enum.rst"> + <section ids="linked-enum" names="_linked_enum"> + <title> + _linked_enum + <exercise_enumerable_node classes="exercise" docname="solution/_linked_enum" hidden="False" ids="ex-number" label="ex-number" names="ex-number" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_enum" hidden="False" ids="sol-number" label="sol-number" names="sol-number" serial_number="1" target_label="ex-number" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <math_block docname="solution/_linked_enum" label="True" no-wrap="False" nowrap="False" number="True" xml:space="preserve"> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <target refid="equation-ex-math"> + <math_block docname="solution/_linked_enum" ids="equation-ex-math" label="ex-math" no-wrap="False" nowrap="False" number="1" xml:space="preserve"> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) diff --git a/tests/test_solution/solution/_linked_enum_class.sphinx7.xml b/tests/test_solution/solution/_linked_enum_class.sphinx7.xml new file mode 100644 index 0000000..daa32c8 --- /dev/null +++ b/tests/test_solution/solution/_linked_enum_class.sphinx7.xml @@ -0,0 +1,10 @@ +<document source="_linked_enum_class.rst"> + <section ids="linked-enum-class" names="_linked_enum_class"> + <title> + _linked_enum_class + <solution_node classes="solution test-solution" docname="solution/_linked_enum_class" hidden="False" ids="solution-label" label="solution-label" names="solution-label" serial_number="0" target_label="ex-number" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_enum_class.sphinx8.xml b/tests/test_solution/solution/_linked_enum_class.sphinx8.xml new file mode 100644 index 0000000..daa32c8 --- /dev/null +++ b/tests/test_solution/solution/_linked_enum_class.sphinx8.xml @@ -0,0 +1,10 @@ +<document source="_linked_enum_class.rst"> + <section ids="linked-enum-class" names="_linked_enum_class"> + <title> + _linked_enum_class + <solution_node classes="solution test-solution" docname="solution/_linked_enum_class" hidden="False" ids="solution-label" label="solution-label" names="solution-label" serial_number="0" target_label="ex-number" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_missing_arg.sphinx7.xml b/tests/test_solution/solution/_linked_missing_arg.sphinx7.xml new file mode 100644 index 0000000..6ecb8d7 --- /dev/null +++ b/tests/test_solution/solution/_linked_missing_arg.sphinx7.xml @@ -0,0 +1,4 @@ +<document source="_linked_missing_arg.rst"> + <section ids="linked-missing-arg" names="_linked_missing_arg"> + <title> + _linked_missing_arg diff --git a/tests/test_solution/solution/_linked_missing_arg.sphinx8.xml b/tests/test_solution/solution/_linked_missing_arg.sphinx8.xml new file mode 100644 index 0000000..6ecb8d7 --- /dev/null +++ b/tests/test_solution/solution/_linked_missing_arg.sphinx8.xml @@ -0,0 +1,4 @@ +<document source="_linked_missing_arg.rst"> + <section ids="linked-missing-arg" names="_linked_missing_arg"> + <title> + _linked_missing_arg diff --git a/tests/test_solution/solution/_linked_unenum_mathtitle.sphinx7.xml b/tests/test_solution/solution/_linked_unenum_mathtitle.sphinx7.xml new file mode 100644 index 0000000..d5c931a --- /dev/null +++ b/tests/test_solution/solution/_linked_unenum_mathtitle.sphinx7.xml @@ -0,0 +1,24 @@ +<document source="_linked_unenum_mathtitle.rst"> + <section ids="linked-unenum-mathtitle" names="_linked_unenum_mathtitle"> + <title> + _linked_unenum_mathtitle + <exercise_node classes="exercise" docname="solution/_linked_unenum_mathtitle" hidden="False" ids="ex-nonumber-title-math" label="ex-nonumber-title-math" names="ex-nonumber-title-math" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <math> + \mathbb{R} + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_mathtitle" hidden="False" ids="sol-nonumber-title-math" label="sol-nonumber-title-math" names="sol-nonumber-title-math" serial_number="1" target_label="ex-nonumber-title-math" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_unenum_mathtitle.sphinx8.xml b/tests/test_solution/solution/_linked_unenum_mathtitle.sphinx8.xml new file mode 100644 index 0000000..d5c931a --- /dev/null +++ b/tests/test_solution/solution/_linked_unenum_mathtitle.sphinx8.xml @@ -0,0 +1,24 @@ +<document source="_linked_unenum_mathtitle.rst"> + <section ids="linked-unenum-mathtitle" names="_linked_unenum_mathtitle"> + <title> + _linked_unenum_mathtitle + <exercise_node classes="exercise" docname="solution/_linked_unenum_mathtitle" hidden="False" ids="ex-nonumber-title-math" label="ex-nonumber-title-math" names="ex-nonumber-title-math" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <math> + \mathbb{R} + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_mathtitle" hidden="False" ids="sol-nonumber-title-math" label="sol-nonumber-title-math" names="sol-nonumber-title-math" serial_number="1" target_label="ex-nonumber-title-math" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_unenum_mathtitle2.sphinx7.xml b/tests/test_solution/solution/_linked_unenum_mathtitle2.sphinx7.xml new file mode 100644 index 0000000..a369002 --- /dev/null +++ b/tests/test_solution/solution/_linked_unenum_mathtitle2.sphinx7.xml @@ -0,0 +1,24 @@ +<document source="_linked_unenum_mathtitle2.rst"> + <section ids="linked-unenum-mathtitle2" names="_linked_unenum_mathtitle2"> + <title> + _linked_unenum_mathtitle2 + <exercise_node classes="exercise" docname="solution/_linked_unenum_mathtitle2" hidden="False" ids="ex-nonumber-title-math2" label="ex-nonumber-title-math2" names="ex-nonumber-title-math2" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <math> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_mathtitle2" hidden="False" ids="sol-nonumber-title-math2" label="sol-nonumber-title-math2" names="sol-nonumber-title-math2" serial_number="1" target_label="ex-nonumber-title-math2" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_unenum_mathtitle2.sphinx8.xml b/tests/test_solution/solution/_linked_unenum_mathtitle2.sphinx8.xml new file mode 100644 index 0000000..a369002 --- /dev/null +++ b/tests/test_solution/solution/_linked_unenum_mathtitle2.sphinx8.xml @@ -0,0 +1,24 @@ +<document source="_linked_unenum_mathtitle2.rst"> + <section ids="linked-unenum-mathtitle2" names="_linked_unenum_mathtitle2"> + <title> + _linked_unenum_mathtitle2 + <exercise_node classes="exercise" docname="solution/_linked_unenum_mathtitle2" hidden="False" ids="ex-nonumber-title-math2" label="ex-nonumber-title-math2" names="ex-nonumber-title-math2" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <math> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_mathtitle2" hidden="False" ids="sol-nonumber-title-math2" label="sol-nonumber-title-math2" names="sol-nonumber-title-math2" serial_number="1" target_label="ex-nonumber-title-math2" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_unenum_notitle.sphinx7.xml b/tests/test_solution/solution/_linked_unenum_notitle.sphinx7.xml new file mode 100644 index 0000000..8140aec --- /dev/null +++ b/tests/test_solution/solution/_linked_unenum_notitle.sphinx7.xml @@ -0,0 +1,20 @@ +<document source="_linked_unenum_notitle.rst"> + <section ids="linked-unenum-notitle" names="_linked_unenum_notitle"> + <title> + _linked_unenum_notitle + <exercise_node classes="exercise" docname="solution/_linked_unenum_notitle" hidden="False" ids="ex-nonumber-notitle" label="ex-nonumber-notitle" names="ex-nonumber-notitle" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_notitle" hidden="False" ids="sol-nonumber-notitle" label="sol-nonumber-notitle" names="sol-nonumber-notitle" serial_number="1" target_label="ex-nonumber-notitle" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_unenum_notitle.sphinx8.xml b/tests/test_solution/solution/_linked_unenum_notitle.sphinx8.xml new file mode 100644 index 0000000..8140aec --- /dev/null +++ b/tests/test_solution/solution/_linked_unenum_notitle.sphinx8.xml @@ -0,0 +1,20 @@ +<document source="_linked_unenum_notitle.rst"> + <section ids="linked-unenum-notitle" names="_linked_unenum_notitle"> + <title> + _linked_unenum_notitle + <exercise_node classes="exercise" docname="solution/_linked_unenum_notitle" hidden="False" ids="ex-nonumber-notitle" label="ex-nonumber-notitle" names="ex-nonumber-notitle" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_notitle" hidden="False" ids="sol-nonumber-notitle" label="sol-nonumber-notitle" names="sol-nonumber-notitle" serial_number="1" target_label="ex-nonumber-notitle" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_unenum_title.sphinx7.xml b/tests/test_solution/solution/_linked_unenum_title.sphinx7.xml new file mode 100644 index 0000000..da1dc3f --- /dev/null +++ b/tests/test_solution/solution/_linked_unenum_title.sphinx7.xml @@ -0,0 +1,22 @@ +<document source="_linked_unenum_title.rst"> + <section ids="linked-unenum-title" names="_linked_unenum_title"> + <title> + _linked_unenum_title + <exercise_node classes="exercise" docname="solution/_linked_unenum_title" hidden="False" ids="ex-nonumber-title" label="ex-nonumber-title" names="ex-nonumber-title" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_title" hidden="False" ids="sol-nonumber-title" label="sol-nonumber-title" names="sol-nonumber-title" serial_number="1" target_label="ex-nonumber-title" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_unenum_title.sphinx8.xml b/tests/test_solution/solution/_linked_unenum_title.sphinx8.xml new file mode 100644 index 0000000..da1dc3f --- /dev/null +++ b/tests/test_solution/solution/_linked_unenum_title.sphinx8.xml @@ -0,0 +1,22 @@ +<document source="_linked_unenum_title.rst"> + <section ids="linked-unenum-title" names="_linked_unenum_title"> + <title> + _linked_unenum_title + <exercise_node classes="exercise" docname="solution/_linked_unenum_title" hidden="False" ids="ex-nonumber-title" label="ex-nonumber-title" names="ex-nonumber-title" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_title" hidden="False" ids="sol-nonumber-title" label="sol-nonumber-title" names="sol-nonumber-title" serial_number="1" target_label="ex-nonumber-title" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_wrong_targetlabel.sphinx7.xml b/tests/test_solution/solution/_linked_wrong_targetlabel.sphinx7.xml new file mode 100644 index 0000000..b03b9ac --- /dev/null +++ b/tests/test_solution/solution/_linked_wrong_targetlabel.sphinx7.xml @@ -0,0 +1,10 @@ +<document source="_linked_wrong_targetlabel.rst"> + <section ids="linked-wrong-targetlabel" names="_linked_wrong_targetlabel"> + <title> + _linked_wrong_targetlabel + <solution_node classes="solution" docname="solution/_linked_wrong_targetlabel" hidden="False" ids="solution/_linked_wrong_targetlabel-solution-0" label="solution/_linked_wrong_targetlabel-solution-0" names="solution/_linked_wrong_targetlabel-solution-0" serial_number="0" target_label="wrong-ex-label" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_wrong_targetlabel.sphinx8.xml b/tests/test_solution/solution/_linked_wrong_targetlabel.sphinx8.xml new file mode 100644 index 0000000..b03b9ac --- /dev/null +++ b/tests/test_solution/solution/_linked_wrong_targetlabel.sphinx8.xml @@ -0,0 +1,10 @@ +<document source="_linked_wrong_targetlabel.rst"> + <section ids="linked-wrong-targetlabel" names="_linked_wrong_targetlabel"> + <title> + _linked_wrong_targetlabel + <solution_node classes="solution" docname="solution/_linked_wrong_targetlabel" hidden="False" ids="solution/_linked_wrong_targetlabel-solution-0" label="solution/_linked_wrong_targetlabel-solution-0" names="solution/_linked_wrong_targetlabel-solution-0" serial_number="0" target_label="wrong-ex-label" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution_references.py b/tests/test_solution_references.py index 1aa82ca..0e789b4 100644 --- a/tests/test_solution_references.py +++ b/tests/test_solution_references.py @@ -1,5 +1,8 @@ from bs4 import BeautifulSoup import pytest +import sphinx + +SPHINX_VERSION = f".sphinx{sphinx.version_info[0]}" @pytest.mark.sphinx("html", testroot="mybook") @@ -29,7 +32,7 @@ def test_reference(app, idir, file_regression): excs += f"{ref}\n" file_regression.check( - str(excs[:-1]), basename=idir.split(".")[0], extension=".html" + str(excs[:-1]), basename=idir.split(".")[0], extension=f"{SPHINX_VERSION}.html" ) diff --git a/tests/test_solution_references/_linked_ref_enum.sphinx7.html b/tests/test_solution_references/_linked_ref_enum.sphinx7.html new file mode 100644 index 0000000..447ca24 --- /dev/null +++ b/tests/test_solution_references/_linked_ref_enum.sphinx7.html @@ -0,0 +1,2 @@ +<p>referencing: <a class="reference internal" href="_linked_enum.html#sol-number"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_enum.html#sol-number"><span class="std std-ref">simple solution with number</span></a>.</p> \ No newline at end of file diff --git a/tests/test_solution_references/_linked_ref_enum.sphinx8.html b/tests/test_solution_references/_linked_ref_enum.sphinx8.html new file mode 100644 index 0000000..c8d1365 --- /dev/null +++ b/tests/test_solution_references/_linked_ref_enum.sphinx8.html @@ -0,0 +1,4 @@ +<p>referencing: <a class="reference internal" href="_linked_enum.html#sol-number"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_enum.html#sol-number"><span class="std std-ref">simple solution with number</span></a>.</p> +<p class="topless"><a href="_linked_ref_unenum_mathtitle2.html" title="previous chapter">_linked_ref_unenum_mathtitle2</a></p> +<p class="topless"><a href="_linked_ref_wronglabel.html" title="next chapter">_linked_ref_wronglabel</a></p> \ No newline at end of file diff --git a/tests/test_solution_references/_linked_ref_unenum_mathtitle.sphinx7.html b/tests/test_solution_references/_linked_ref_unenum_mathtitle.sphinx7.html new file mode 100644 index 0000000..4c295c2 --- /dev/null +++ b/tests/test_solution_references/_linked_ref_unenum_mathtitle.sphinx7.html @@ -0,0 +1,2 @@ +<p>referencing: <a class="reference internal" href="_linked_unenum_mathtitle.html#sol-nonumber-title-math"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_unenum_mathtitle.html#sol-nonumber-title-math"><span class="std std-ref">exercise with nonumber but with inline math title</span></a>.</p> \ No newline at end of file diff --git a/tests/test_solution_references/_linked_ref_unenum_mathtitle.sphinx8.html b/tests/test_solution_references/_linked_ref_unenum_mathtitle.sphinx8.html new file mode 100644 index 0000000..fb0f469 --- /dev/null +++ b/tests/test_solution_references/_linked_ref_unenum_mathtitle.sphinx8.html @@ -0,0 +1,4 @@ +<p>referencing: <a class="reference internal" href="_linked_unenum_mathtitle.html#sol-nonumber-title-math"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_unenum_mathtitle.html#sol-nonumber-title-math"><span class="std std-ref">exercise with nonumber but with inline math title</span></a>.</p> +<p class="topless"><a href="_linked_ref_unenum_title.html" title="previous chapter">_linked_ref_unenum_title</a></p> +<p class="topless"><a href="_linked_ref_unenum_mathtitle2.html" title="next chapter">_linked_ref_unenum_mathtitle2</a></p> \ No newline at end of file diff --git a/tests/test_solution_references/_linked_ref_unenum_mathtitle2.sphinx7.html b/tests/test_solution_references/_linked_ref_unenum_mathtitle2.sphinx7.html new file mode 100644 index 0000000..cfb2b50 --- /dev/null +++ b/tests/test_solution_references/_linked_ref_unenum_mathtitle2.sphinx7.html @@ -0,0 +1,2 @@ +<p>referencing: <a class="reference internal" href="_linked_unenum_mathtitle2.html#sol-nonumber-title-math2"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_unenum_mathtitle2.html#sol-nonumber-title-math2"><span class="std std-ref">exercise with nonumber but with inline math title ex2</span></a>.</p> \ No newline at end of file diff --git a/tests/test_solution_references/_linked_ref_unenum_mathtitle2.sphinx8.html b/tests/test_solution_references/_linked_ref_unenum_mathtitle2.sphinx8.html new file mode 100644 index 0000000..d141d88 --- /dev/null +++ b/tests/test_solution_references/_linked_ref_unenum_mathtitle2.sphinx8.html @@ -0,0 +1,4 @@ +<p>referencing: <a class="reference internal" href="_linked_unenum_mathtitle2.html#sol-nonumber-title-math2"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_unenum_mathtitle2.html#sol-nonumber-title-math2"><span class="std std-ref">exercise with nonumber but with inline math title ex2</span></a>.</p> +<p class="topless"><a href="_linked_ref_unenum_mathtitle.html" title="previous chapter">_linked_ref_unenum_mathtitle</a></p> +<p class="topless"><a href="_linked_ref_enum.html" title="next chapter">_linked_ref_enum</a></p> \ No newline at end of file diff --git a/tests/test_solution_references/_linked_ref_unenum_notitle.sphinx7.html b/tests/test_solution_references/_linked_ref_unenum_notitle.sphinx7.html new file mode 100644 index 0000000..8e3dc3c --- /dev/null +++ b/tests/test_solution_references/_linked_ref_unenum_notitle.sphinx7.html @@ -0,0 +1,2 @@ +<p>referencing: <a class="reference internal" href="_linked_unenum_notitle.html#sol-nonumber-notitle"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_unenum_notitle.html#sol-nonumber-notitle"><span class="std std-ref">ex with nonumber and notitle</span></a>.</p> \ No newline at end of file diff --git a/tests/test_solution_references/_linked_ref_unenum_notitle.sphinx8.html b/tests/test_solution_references/_linked_ref_unenum_notitle.sphinx8.html new file mode 100644 index 0000000..1911f9e --- /dev/null +++ b/tests/test_solution_references/_linked_ref_unenum_notitle.sphinx8.html @@ -0,0 +1,4 @@ +<p>referencing: <a class="reference internal" href="_linked_unenum_notitle.html#sol-nonumber-notitle"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_unenum_notitle.html#sol-nonumber-notitle"><span class="std std-ref">ex with nonumber and notitle</span></a>.</p> +<p class="topless"><a href="_linked_wrong_targetlabel.html" title="previous chapter">_linked_wrong_targetlabel</a></p> +<p class="topless"><a href="_linked_ref_unenum_title.html" title="next chapter">_linked_ref_unenum_title</a></p> \ No newline at end of file diff --git a/tests/test_solution_references/_linked_ref_unenum_title.sphinx7.html b/tests/test_solution_references/_linked_ref_unenum_title.sphinx7.html new file mode 100644 index 0000000..62de13e --- /dev/null +++ b/tests/test_solution_references/_linked_ref_unenum_title.sphinx7.html @@ -0,0 +1,2 @@ +<p>referencing: <a class="reference internal" href="_linked_unenum_title.html#sol-nonumber-title"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_unenum_title.html#sol-nonumber-title"><span class="std std-ref">exercise with nonumber but with title</span></a>.</p> \ No newline at end of file diff --git a/tests/test_solution_references/_linked_ref_unenum_title.sphinx8.html b/tests/test_solution_references/_linked_ref_unenum_title.sphinx8.html new file mode 100644 index 0000000..ab4d3d4 --- /dev/null +++ b/tests/test_solution_references/_linked_ref_unenum_title.sphinx8.html @@ -0,0 +1,4 @@ +<p>referencing: <a class="reference internal" href="_linked_unenum_title.html#sol-nonumber-title"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_unenum_title.html#sol-nonumber-title"><span class="std std-ref">exercise with nonumber but with title</span></a>.</p> +<p class="topless"><a href="_linked_ref_unenum_notitle.html" title="previous chapter">_linked_ref_unenum_notitle</a></p> +<p class="topless"><a href="_linked_ref_unenum_mathtitle.html" title="next chapter">_linked_ref_unenum_mathtitle</a></p> \ No newline at end of file diff --git a/tox.ini b/tox.ini index 87a2dac..4d09544 100644 --- a/tox.ini +++ b/tox.ini @@ -8,22 +8,23 @@ # `tox -r` [tox] -envlist = py{311,312} +envlist = py{311,312,313}-sphinx{6,7,8} skip_missing_interpreters = true [testenv] usedevelop=true recreate = false -[testenv:py{311,312}-pre-commit] +[testenv:py{311,312,313}-pre-commit] extras = code_style commands = pre-commit run {posargs} -[testenv:py{311,312}-sphinx{5,6}] +[testenv:py{311,312,313}-sphinx{6,7,8}] extras = testing deps = - sphinx5: sphinx>=5,<6 - sphinx5: sphinx>=6,<7 + sphinx6: sphinx>=6.1,<7 + sphinx7: sphinx>=7,<8 + sphinx8: sphinx>=8,<9 commands = pytest --verbose {posargs} [testenv:docs-{update,clean}] From 23bbb21eaa2463dbaeaf09bcdee5f26e157e275c Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Tue, 21 Oct 2025 15:52:05 +1100 Subject: [PATCH 02/16] Fix MatplotlibDeprecationWarning in test code and update CHANGELOG - Update CHANGELOG.md with v1.0.0 and v1.0.1 release information - Fix deprecated matplotlib.axes.Axes.cohere() API usage in test files - Change from positional args to keyword args (NFFT=, Fs=) - Eliminates MatplotlibDeprecationWarning from test output - Regenerate Sphinx 8 test fixtures to reflect corrected test code - All 110 tests passing with only external myst_nb warnings remaining --- CHANGELOG.md | 19 +++++++++++++++++++ .../solution-exercise-gated.md | 4 ++-- .../test-gateddirective/solution-exercise.md | 4 ++-- .../solution-exercise-0.sphinx8.html | 6 +----- .../solution-exercise-1.sphinx8.html | 6 +----- .../solution-exercise-gated-0.sphinx8.html | 6 +----- .../solution-exercise-gated-1.sphinx8.html | 6 +----- .../solution-exercise-gated.sphinx8.xml | 10 ++-------- .../solution-exercise.sphinx8.xml | 10 ++-------- 9 files changed, 31 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebcbd16..61fbbc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,25 @@ # Changelog +## [v1.0.1](https://github.com/executablebooks/sphinx-exercise/tree/v1.0.1) (2024-07-01) + +### Improved 👌 + +- Updates to testing infrastructure and minor bug fixes +- Fixed JupyterBuilder handling in test suite + +## [v1.0.0](https://github.com/executablebooks/sphinx-exercise/tree/v1.0.0) (2024-01-15) + +### Improved 👌 + +- Added support for Sphinx 7 +- Updated build and CI infrastructure +- Fixed deprecation warnings for Sphinx 7 compatibility +- Improved type hints throughout codebase +- Fixed doctree node mutation issues by copying nodes +- Updated codecov to version 3 +- Pinned matplotlib to 3.7.* for testing stability + ## [v0.4.1](https://github.com/executablebooks/sphinx-exercise/tree/v0.4.1) (2023-1-23) ### Improved 👌 diff --git a/tests/books/test-gateddirective/solution-exercise-gated.md b/tests/books/test-gateddirective/solution-exercise-gated.md index 7fb42c1..0929241 100644 --- a/tests/books/test-gateddirective/solution-exercise-gated.md +++ b/tests/books/test-gateddirective/solution-exercise-gated.md @@ -42,7 +42,7 @@ axs[0].set_xlabel('time') axs[0].set_ylabel('s1 and s2') axs[0].grid(True) -cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) +cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) axs[1].set_ylabel('coherence') fig.tight_layout() @@ -87,7 +87,7 @@ axs[0].set_xlabel('time') axs[0].set_ylabel('s1 and s2') axs[0].grid(True) -cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) +cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) axs[1].set_ylabel('coherence') fig.tight_layout() diff --git a/tests/books/test-gateddirective/solution-exercise.md b/tests/books/test-gateddirective/solution-exercise.md index 176bb6f..a223099 100644 --- a/tests/books/test-gateddirective/solution-exercise.md +++ b/tests/books/test-gateddirective/solution-exercise.md @@ -42,7 +42,7 @@ axs[0].set_xlabel('time') axs[0].set_ylabel('s1 and s2') axs[0].grid(True) -cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) +cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) axs[1].set_ylabel('coherence') fig.tight_layout() @@ -85,7 +85,7 @@ axs[0].set_xlabel('time') axs[0].set_ylabel('s1 and s2') axs[0].grid(True) -cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) +cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) axs[1].set_ylabel('coherence') fig.tight_layout() diff --git a/tests/test_gateddirective/solution-exercise-0.sphinx8.html b/tests/test_gateddirective/solution-exercise-0.sphinx8.html index b6fc437..91a66e3 100644 --- a/tests/test_gateddirective/solution-exercise-0.sphinx8.html +++ b/tests/test_gateddirective/solution-exercise-0.sphinx8.html @@ -26,7 +26,7 @@ <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> -<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="mi">256</span><span class="p">,</span> <span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="n">NFFT</span><span class="o">=</span><span class="mi">256</span><span class="p">,</span> <span class="n">Fs</span><span class="o">=</span><span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> <span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> @@ -35,10 +35,6 @@ </div> </div> <div class="cell_output docutils container"> -<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) -</pre></div> -</div> <img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> </div> </div> diff --git a/tests/test_gateddirective/solution-exercise-1.sphinx8.html b/tests/test_gateddirective/solution-exercise-1.sphinx8.html index 64d29f5..07a29e9 100644 --- a/tests/test_gateddirective/solution-exercise-1.sphinx8.html +++ b/tests/test_gateddirective/solution-exercise-1.sphinx8.html @@ -26,7 +26,7 @@ <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> -<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="mi">256</span><span class="p">,</span> <span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="n">NFFT</span><span class="o">=</span><span class="mi">256</span><span class="p">,</span> <span class="n">Fs</span><span class="o">=</span><span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> <span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> @@ -35,10 +35,6 @@ </div> </div> <div class="cell_output docutils container"> -<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) -</pre></div> -</div> <img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> </div> </div> diff --git a/tests/test_gateddirective/solution-exercise-gated-0.sphinx8.html b/tests/test_gateddirective/solution-exercise-gated-0.sphinx8.html index e8229c0..6850101 100644 --- a/tests/test_gateddirective/solution-exercise-gated-0.sphinx8.html +++ b/tests/test_gateddirective/solution-exercise-gated-0.sphinx8.html @@ -26,7 +26,7 @@ <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> -<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="mi">256</span><span class="p">,</span> <span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="n">NFFT</span><span class="o">=</span><span class="mi">256</span><span class="p">,</span> <span class="n">Fs</span><span class="o">=</span><span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> <span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> @@ -35,10 +35,6 @@ </div> </div> <div class="cell_output docutils container"> -<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) -</pre></div> -</div> <img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> </div> </div> diff --git a/tests/test_gateddirective/solution-exercise-gated-1.sphinx8.html b/tests/test_gateddirective/solution-exercise-gated-1.sphinx8.html index 96c2fc3..21815e5 100644 --- a/tests/test_gateddirective/solution-exercise-gated-1.sphinx8.html +++ b/tests/test_gateddirective/solution-exercise-gated-1.sphinx8.html @@ -26,7 +26,7 @@ <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> -<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="mi">256</span><span class="p">,</span> <span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="n">NFFT</span><span class="o">=</span><span class="mi">256</span><span class="p">,</span> <span class="n">Fs</span><span class="o">=</span><span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> <span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> @@ -35,10 +35,6 @@ </div> </div> <div class="cell_output docutils container"> -<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) -</pre></div> -</div> <img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> </div> </div> diff --git a/tests/test_gateddirective/solution-exercise-gated.sphinx8.xml b/tests/test_gateddirective/solution-exercise-gated.sphinx8.xml index 4ae085a..88d1f0b 100644 --- a/tests/test_gateddirective/solution-exercise-gated.sphinx8.xml +++ b/tests/test_gateddirective/solution-exercise-gated.sphinx8.xml @@ -35,15 +35,12 @@ axs[0].set_ylabel('s1 and s2') axs[0].grid(True) - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) axs[1].set_ylabel('coherence') fig.tight_layout() plt.show() <container classes="cell_output" nb_element="cell_code_output"> - <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> - /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) <container nb_element="mime_bundle"> <container mime_type="text/plain"> <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> @@ -90,15 +87,12 @@ axs[0].set_ylabel('s1 and s2') axs[0].grid(True) - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) axs[1].set_ylabel('coherence') fig.tight_layout() plt.show() <container classes="cell_output" nb_element="cell_code_output"> - <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> - /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) <container nb_element="mime_bundle"> <container mime_type="text/plain"> <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> diff --git a/tests/test_gateddirective/solution-exercise.sphinx8.xml b/tests/test_gateddirective/solution-exercise.sphinx8.xml index ba8c92d..f9c4e51 100644 --- a/tests/test_gateddirective/solution-exercise.sphinx8.xml +++ b/tests/test_gateddirective/solution-exercise.sphinx8.xml @@ -35,15 +35,12 @@ axs[0].set_ylabel('s1 and s2') axs[0].grid(True) - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) axs[1].set_ylabel('coherence') fig.tight_layout() plt.show() <container classes="cell_output" nb_element="cell_code_output"> - <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> - /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) <container nb_element="mime_bundle"> <container mime_type="text/plain"> <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> @@ -88,15 +85,12 @@ axs[0].set_ylabel('s1 and s2') axs[0].grid(True) - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) axs[1].set_ylabel('coherence') fig.tight_layout() plt.show() <container classes="cell_output" nb_element="cell_code_output"> - <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> - /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) <container nb_element="mime_bundle"> <container mime_type="text/plain"> <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> From d39207bbd2a2b0456be369c4382ca02b1ceaa0b4 Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Tue, 21 Oct 2025 16:00:06 +1100 Subject: [PATCH 03/16] Update myst-nb dependency to >=1.1.0 to eliminate deprecation warnings - Change from myst-nb~=1.0.0 to myst-nb>=1.1.0 - myst-nb v1.1.0+ uses Node.findall() instead of deprecated Node.traverse() - Eliminates PendingDeprecationWarning and RemovedInSphinx90Warning - All 110 tests pass with ZERO warnings --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3c07db1..621712b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,7 @@ code_style = [ "pre-commit", ] rtd = [ - "myst-nb~=1.0.0", + "myst-nb>=1.1.0", "sphinx-book-theme", "sphinx_togglebutton", "sphinx>=6.1,<9", @@ -57,7 +57,7 @@ testing = [ "beautifulsoup4", "coverage", "matplotlib>=3.8", - "myst-nb~=1.0.0", + "myst-nb>=1.1.0", "pytest-cov", "pytest-regressions", "pytest~=8.0.0", From 9e9b7c440f139ad8b0813fdf369934eb0a274804 Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Tue, 21 Oct 2025 16:04:24 +1100 Subject: [PATCH 04/16] Regenerate Sphinx 6 and 7 test fixtures with updated myst-nb - Update fixtures to reflect myst-nb >=1.1.0 output (no warnings) - Remove MatplotlibDeprecationWarning from fixture files --- .../solution-exercise-0.sphinx7.html | 6 +----- .../solution-exercise-1.sphinx7.html | 6 +----- .../solution-exercise-gated-0.sphinx7.html | 6 +----- .../solution-exercise-gated-1.sphinx7.html | 6 +----- .../solution-exercise-gated.sphinx7.xml | 10 ++-------- .../test_gateddirective/solution-exercise.sphinx7.xml | 10 ++-------- 6 files changed, 8 insertions(+), 36 deletions(-) diff --git a/tests/test_gateddirective/solution-exercise-0.sphinx7.html b/tests/test_gateddirective/solution-exercise-0.sphinx7.html index b6fc437..91a66e3 100644 --- a/tests/test_gateddirective/solution-exercise-0.sphinx7.html +++ b/tests/test_gateddirective/solution-exercise-0.sphinx7.html @@ -26,7 +26,7 @@ <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> -<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="mi">256</span><span class="p">,</span> <span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="n">NFFT</span><span class="o">=</span><span class="mi">256</span><span class="p">,</span> <span class="n">Fs</span><span class="o">=</span><span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> <span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> @@ -35,10 +35,6 @@ </div> </div> <div class="cell_output docutils container"> -<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) -</pre></div> -</div> <img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> </div> </div> diff --git a/tests/test_gateddirective/solution-exercise-1.sphinx7.html b/tests/test_gateddirective/solution-exercise-1.sphinx7.html index 64d29f5..07a29e9 100644 --- a/tests/test_gateddirective/solution-exercise-1.sphinx7.html +++ b/tests/test_gateddirective/solution-exercise-1.sphinx7.html @@ -26,7 +26,7 @@ <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> -<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="mi">256</span><span class="p">,</span> <span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="n">NFFT</span><span class="o">=</span><span class="mi">256</span><span class="p">,</span> <span class="n">Fs</span><span class="o">=</span><span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> <span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> @@ -35,10 +35,6 @@ </div> </div> <div class="cell_output docutils container"> -<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) -</pre></div> -</div> <img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> </div> </div> diff --git a/tests/test_gateddirective/solution-exercise-gated-0.sphinx7.html b/tests/test_gateddirective/solution-exercise-gated-0.sphinx7.html index e8229c0..6850101 100644 --- a/tests/test_gateddirective/solution-exercise-gated-0.sphinx7.html +++ b/tests/test_gateddirective/solution-exercise-gated-0.sphinx7.html @@ -26,7 +26,7 @@ <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> -<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="mi">256</span><span class="p">,</span> <span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="n">NFFT</span><span class="o">=</span><span class="mi">256</span><span class="p">,</span> <span class="n">Fs</span><span class="o">=</span><span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> <span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> @@ -35,10 +35,6 @@ </div> </div> <div class="cell_output docutils container"> -<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) -</pre></div> -</div> <img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> </div> </div> diff --git a/tests/test_gateddirective/solution-exercise-gated-1.sphinx7.html b/tests/test_gateddirective/solution-exercise-gated-1.sphinx7.html index 96c2fc3..21815e5 100644 --- a/tests/test_gateddirective/solution-exercise-gated-1.sphinx7.html +++ b/tests/test_gateddirective/solution-exercise-gated-1.sphinx7.html @@ -26,7 +26,7 @@ <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> -<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="mi">256</span><span class="p">,</span> <span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="n">NFFT</span><span class="o">=</span><span class="mi">256</span><span class="p">,</span> <span class="n">Fs</span><span class="o">=</span><span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> <span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> @@ -35,10 +35,6 @@ </div> </div> <div class="cell_output docutils container"> -<div class="output stderr highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>/var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) -</pre></div> -</div> <img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> </div> </div> diff --git a/tests/test_gateddirective/solution-exercise-gated.sphinx7.xml b/tests/test_gateddirective/solution-exercise-gated.sphinx7.xml index 4ae085a..88d1f0b 100644 --- a/tests/test_gateddirective/solution-exercise-gated.sphinx7.xml +++ b/tests/test_gateddirective/solution-exercise-gated.sphinx7.xml @@ -35,15 +35,12 @@ axs[0].set_ylabel('s1 and s2') axs[0].grid(True) - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) axs[1].set_ylabel('coherence') fig.tight_layout() plt.show() <container classes="cell_output" nb_element="cell_code_output"> - <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> - /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) <container nb_element="mime_bundle"> <container mime_type="text/plain"> <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> @@ -90,15 +87,12 @@ axs[0].set_ylabel('s1 and s2') axs[0].grid(True) - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) axs[1].set_ylabel('coherence') fig.tight_layout() plt.show() <container classes="cell_output" nb_element="cell_code_output"> - <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> - /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) <container nb_element="mime_bundle"> <container mime_type="text/plain"> <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> diff --git a/tests/test_gateddirective/solution-exercise.sphinx7.xml b/tests/test_gateddirective/solution-exercise.sphinx7.xml index ba8c92d..f9c4e51 100644 --- a/tests/test_gateddirective/solution-exercise.sphinx7.xml +++ b/tests/test_gateddirective/solution-exercise.sphinx7.xml @@ -35,15 +35,12 @@ axs[0].set_ylabel('s1 and s2') axs[0].grid(True) - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) axs[1].set_ylabel('coherence') fig.tight_layout() plt.show() <container classes="cell_output" nb_element="cell_code_output"> - <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> - /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) <container nb_element="mime_bundle"> <container mime_type="text/plain"> <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> @@ -88,15 +85,12 @@ axs[0].set_ylabel('s1 and s2') axs[0].grid(True) - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) + cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) axs[1].set_ylabel('coherence') fig.tight_layout() plt.show() <container classes="cell_output" nb_element="cell_code_output"> - <literal_block classes="output stderr" language="myst-ansi" xml:space="preserve"> - /var/folders/zy/dpt7pvt11fvcm_yxjd7kmv880000gn/T/ipykernel_XXXXX/803402259.py:23: MatplotlibDeprecationWarning: Passing the NFFT parameter of cohere() positionally is deprecated since Matplotlib 3.10; the parameter will become keyword-only in 3.12. - cxy, f = axs[1].cohere(s1, s2, 256, 1. / dt) <container nb_element="mime_bundle"> <container mime_type="text/plain"> <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> From 64fe3eb8fd98f44c907070a91e368591149d8640 Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Tue, 21 Oct 2025 16:13:14 +1100 Subject: [PATCH 05/16] Update pytest dependency from ~=8.0.0 to >=8.0 - Similar to myst-nb update, the ~=8.0.0 constraint was locking pytest to 8.0.x - Latest pytest is 8.4.2 with bug fixes and improvements - All 110 tests passing with pytest 8.4.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 621712b..f26001b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ testing = [ "myst-nb>=1.1.0", "pytest-cov", "pytest-regressions", - "pytest~=8.0.0", + "pytest>=8.0", "sphinx>=6.1,<9", "texsoup", "defusedxml", # Required by sphinx-testing From 7d53b29ff65c199c466edef1f743e55037588dcc Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Tue, 21 Oct 2025 16:25:07 +1100 Subject: [PATCH 06/16] Apply pre-commit formatting fixes - Fix E402: Move sphinx.locale import to top of file in nodes.py - Add newline at end of MANIFEST.in - Apply ruff-format line wrapping for long lines --- MANIFEST.in | 2 +- sphinx_exercise/__init__.py | 1 + sphinx_exercise/nodes.py | 8 +++++--- sphinx_exercise/translations/_convert.py | 9 ++++++++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 7edfdf4..b950eb7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,4 +8,4 @@ recursive-include sphinx_exercise *.css recursive-include sphinx_exercise *.json recursive-include sphinx_exercise *.mo recursive-include sphinx_exercise *.po -recursive-include sphinx_exercise *.py \ No newline at end of file +recursive-include sphinx_exercise *.py diff --git a/sphinx_exercise/__init__.py b/sphinx_exercise/__init__.py index 60ed3b9..c7bf3dc 100644 --- a/sphinx_exercise/__init__.py +++ b/sphinx_exercise/__init__.py @@ -71,6 +71,7 @@ # Callback Functions + def purge_exercises(app: Sphinx, env: BuildEnvironment, docname: str) -> None: """Purge sphinx_exercise registry""" diff --git a/sphinx_exercise/nodes.py b/sphinx_exercise/nodes.py index c34fd36..263428a 100644 --- a/sphinx_exercise/nodes.py +++ b/sphinx_exercise/nodes.py @@ -13,13 +13,12 @@ from docutils import nodes as docutil_nodes from sphinx import addnodes as sphinx_nodes from sphinx.writers.latex import LaTeXTranslator +from sphinx.locale import get_translation from .latex import LaTeXMarkup logger = logging.getLogger(__name__) LaTeX = LaTeXMarkup() - -from sphinx.locale import get_translation MESSAGE_CATALOG_NAME = "exercise" translate = get_translation(MESSAGE_CATALOG_NAME) @@ -54,7 +53,10 @@ class solution_end_node(docutil_nodes.Admonition, docutil_nodes.Element): class exercise_title(docutil_nodes.title): def default_title(self): title_text = self.children[0].astext() - if title_text == f"{translate('Exercise')}" or title_text == f"{translate('Exercise')} %s": + if ( + title_text == f"{translate('Exercise')}" + or title_text == f"{translate('Exercise')} %s" + ): return True else: return False diff --git a/sphinx_exercise/translations/_convert.py b/sphinx_exercise/translations/_convert.py index 882f954..d9943b2 100644 --- a/sphinx_exercise/translations/_convert.py +++ b/sphinx_exercise/translations/_convert.py @@ -5,6 +5,7 @@ MESSAGE_CATALOG_NAME = "exercise" + def convert_json(folder=None): folder = folder or Path(__file__).parent @@ -19,7 +20,13 @@ def convert_json(folder=None): english = data[0]["text"] for item in data[1:]: language = item["symbol"] - out_path = folder / "locales" / language / "LC_MESSAGES" / f"{MESSAGE_CATALOG_NAME}.po" + out_path = ( + folder + / "locales" + / language + / "LC_MESSAGES" + / f"{MESSAGE_CATALOG_NAME}.po" + ) if not out_path.parent.exists(): out_path.parent.mkdir(parents=True) if not out_path.exists(): From 45722f56322020cf9f30d5d567963bd43b444ae5 Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Tue, 21 Oct 2025 16:43:02 +1100 Subject: [PATCH 07/16] Normalize matplotlib image hashes in tests Matplotlib generates platform/version-specific content hashes for images. This causes test failures when comparing fixtures generated on different platforms (macOS vs Linux) or with different package versions. Solution: Add regex pattern to FileRegression to normalize all matplotlib image hashes to 'IMAGEHASH.png', making tests platform-independent. Fixes CI test failures in test_gateddirective.py. --- tests/conftest.py | 2 ++ tests/test_gateddirective/solution-exercise-0.sphinx8.html | 2 +- tests/test_gateddirective/solution-exercise-1.sphinx8.html | 2 +- .../solution-exercise-gated-0.sphinx8.html | 2 +- .../solution-exercise-gated-1.sphinx8.html | 2 +- tests/test_gateddirective/solution-exercise-gated.sphinx8.xml | 4 ++-- tests/test_gateddirective/solution-exercise.sphinx8.xml | 4 ++-- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 9c3c593..f0bd262 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -96,6 +96,8 @@ class FileRegression: ("Link to", "Permalink to"), # Strip ipykernel process IDs (temporary directory paths) (r"ipykernel_\d+", "ipykernel_XXXXX"), + # Normalize matplotlib image hashes (platform/version dependent) + (r"[a-f0-9]{64}\.png", "IMAGEHASH.png"), ) def __init__(self, file_regression): diff --git a/tests/test_gateddirective/solution-exercise-0.sphinx8.html b/tests/test_gateddirective/solution-exercise-0.sphinx8.html index 91a66e3..609f4a5 100644 --- a/tests/test_gateddirective/solution-exercise-0.sphinx8.html +++ b/tests/test_gateddirective/solution-exercise-0.sphinx8.html @@ -35,7 +35,7 @@ </div> </div> <div class="cell_output docutils container"> -<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> +<img alt="_images/IMAGEHASH.png" src="_images/IMAGEHASH.png"/> </div> </div> <p>With some follow up text to the solution</p> diff --git a/tests/test_gateddirective/solution-exercise-1.sphinx8.html b/tests/test_gateddirective/solution-exercise-1.sphinx8.html index 07a29e9..912e9fe 100644 --- a/tests/test_gateddirective/solution-exercise-1.sphinx8.html +++ b/tests/test_gateddirective/solution-exercise-1.sphinx8.html @@ -35,7 +35,7 @@ </div> </div> <div class="cell_output docutils container"> -<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> +<img alt="_images/IMAGEHASH.png" src="_images/IMAGEHASH.png"/> </div> </div> <p>With some follow up text to the solution</p> diff --git a/tests/test_gateddirective/solution-exercise-gated-0.sphinx8.html b/tests/test_gateddirective/solution-exercise-gated-0.sphinx8.html index 6850101..cb426ea 100644 --- a/tests/test_gateddirective/solution-exercise-gated-0.sphinx8.html +++ b/tests/test_gateddirective/solution-exercise-gated-0.sphinx8.html @@ -35,7 +35,7 @@ </div> </div> <div class="cell_output docutils container"> -<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> +<img alt="_images/IMAGEHASH.png" src="_images/IMAGEHASH.png"/> </div> </div> <p>With some follow up text to the solution</p> diff --git a/tests/test_gateddirective/solution-exercise-gated-1.sphinx8.html b/tests/test_gateddirective/solution-exercise-gated-1.sphinx8.html index 21815e5..76bf8b2 100644 --- a/tests/test_gateddirective/solution-exercise-gated-1.sphinx8.html +++ b/tests/test_gateddirective/solution-exercise-gated-1.sphinx8.html @@ -35,7 +35,7 @@ </div> </div> <div class="cell_output docutils container"> -<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> +<img alt="_images/IMAGEHASH.png" src="_images/IMAGEHASH.png"/> </div> </div> <p>With some follow up text to the solution</p> diff --git a/tests/test_gateddirective/solution-exercise-gated.sphinx8.xml b/tests/test_gateddirective/solution-exercise-gated.sphinx8.xml index 88d1f0b..87e88a5 100644 --- a/tests/test_gateddirective/solution-exercise-gated.sphinx8.xml +++ b/tests/test_gateddirective/solution-exercise-gated.sphinx8.xml @@ -46,7 +46,7 @@ <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> <Figure size 640x480 with 2 Axes> <container mime_type="image/png"> - <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> + <image candidates="{'*': '_build/jupyter_execute/IMAGEHASH.png'}" uri="_build/jupyter_execute/IMAGEHASH.png"> <paragraph> With some follow up text to the solution <paragraph> @@ -98,7 +98,7 @@ <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> <Figure size 640x480 with 2 Axes> <container mime_type="image/png"> - <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> + <image candidates="{'*': '_build/jupyter_execute/IMAGEHASH.png'}" uri="_build/jupyter_execute/IMAGEHASH.png"> <paragraph> With some follow up text to the solution <section ids="references-to-solutions" names="references\ to\ solutions"> diff --git a/tests/test_gateddirective/solution-exercise.sphinx8.xml b/tests/test_gateddirective/solution-exercise.sphinx8.xml index f9c4e51..29cd9d9 100644 --- a/tests/test_gateddirective/solution-exercise.sphinx8.xml +++ b/tests/test_gateddirective/solution-exercise.sphinx8.xml @@ -46,7 +46,7 @@ <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> <Figure size 640x480 with 2 Axes> <container mime_type="image/png"> - <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> + <image candidates="{'*': '_build/jupyter_execute/IMAGEHASH.png'}" uri="_build/jupyter_execute/IMAGEHASH.png"> <paragraph> With some follow up text to the solution <paragraph> @@ -96,7 +96,7 @@ <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> <Figure size 640x480 with 2 Axes> <container mime_type="image/png"> - <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> + <image candidates="{'*': '_build/jupyter_execute/IMAGEHASH.png'}" uri="_build/jupyter_execute/IMAGEHASH.png"> <paragraph> With some follow up text to the solution <section ids="references" names="references"> From 3625fe921bb2128a242109dd1d7d61745b6cf416 Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Tue, 21 Oct 2025 16:45:40 +1100 Subject: [PATCH 08/16] Update CI to test all Python and Sphinx combinations Match CI test matrix to tox configuration: - Python versions: 3.11, 3.12, 3.13 - Sphinx versions: 6, 7, 8 - Total: 9 test combinations This ensures CI tests the same environments as local tox testing, providing better coverage and catching version-specific issues. --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5d6735..ba25a01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.11", "3.12"] + python-version: ["3.11", "3.12", "3.13"] + sphinx-version: ["6", "7", "8"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -34,16 +35,17 @@ jobs: run : | python -m pip install --upgrade pip pip install -e.[testing] + pip install "sphinx>=${{ matrix.sphinx-version }},<${{ matrix.sphinx-version == '6' && '7' || matrix.sphinx-version == '7' && '8' || '9' }}" - name: Run pytest run: | pytest --durations=10 --cov=sphinx_exercise --cov-report=xml --cov-report=term-missing - name: Create cov run: coverage xml - name: Upload to Codecov - if: false && (matrix.python-version == '3.11') + if: false && (matrix.python-version == '3.11' && matrix.sphinx-version == '8') uses: codecov/codecov-action@v4 with: - name: sphinx-exercise-pytest-py3.11 + name: sphinx-exercise-pytest-py3.11-sphinx8 token: "${{ secrets.CODECOV_TOKEN }}" flags: pytests file: ./coverage.xml From 5441af026e79dd060744279c38531b0463bd57da Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Tue, 21 Oct 2025 16:55:36 +1100 Subject: [PATCH 09/16] Add Sphinx version compatibility for strip_escape_sequences The function strip_escape_sequences was removed from sphinx.util.console in later versions. Add try/except import with fallback implementation. Also update tox.ini to properly install Sphinx version-specific dependencies by explicitly listing all testing dependencies in deps rather than using the 'testing' extra which includes a broad Sphinx version range. Fixes CI failure on Python 3.13 + Sphinx 6 combination. --- tests/test_gateddirective.py | 12 +++++++++++- tox.ini | 13 ++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/test_gateddirective.py b/tests/test_gateddirective.py index 3bdc616..8edbe70 100644 --- a/tests/test_gateddirective.py +++ b/tests/test_gateddirective.py @@ -1,11 +1,21 @@ import os import pytest +import re import shutil import sphinx from bs4 import BeautifulSoup from sphinx.errors import ExtensionError from pathlib import Path -from sphinx.util.console import strip_escape_sequences as strip_escseq + +# strip_escape_sequences was removed in Sphinx 7 +try: + from sphinx.util.console import strip_escape_sequences as strip_escseq +except ImportError: + # Fallback for Sphinx 7+: simple ANSI escape sequence stripper + def strip_escseq(text: str) -> str: + """Remove ANSI escape sequences from text.""" + return re.sub(r"\x1b\[[0-9;]*m", "", text) + SPHINX_VERSION = f".sphinx{sphinx.version_info[0]}" diff --git a/tox.ini b/tox.ini index 4d09544..8e41c93 100644 --- a/tox.ini +++ b/tox.ini @@ -20,11 +20,22 @@ extras = code_style commands = pre-commit run {posargs} [testenv:py{311,312,313}-sphinx{6,7,8}] -extras = testing +skip_install = false +package = editable deps = sphinx6: sphinx>=6.1,<7 sphinx7: sphinx>=7,<8 sphinx8: sphinx>=8,<9 + beautifulsoup4 + coverage + matplotlib>=3.8 + myst-nb>=1.1.0 + pytest-cov + pytest-regressions + pytest>=8.0 + texsoup + defusedxml + sphinx-book-theme commands = pytest --verbose {posargs} [testenv:docs-{update,clean}] From 8e3307e514ce1fb068bff74fd7f26c6e31a35358 Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Tue, 21 Oct 2025 17:01:54 +1100 Subject: [PATCH 10/16] Fix tox to properly install version-specific Sphinx Use constrain_package_deps and use_frozen_constraints to ensure that the Sphinx version specified in tox deps takes precedence over the package's own dependency declaration (sphinx>=6.1). This creates a constraints file that locks the Sphinx version during package dependency installation, preventing pip from upgrading to the latest version. Verified working: - py311-sphinx6: Sphinx 6.2.1 - py311-sphinx7: Sphinx 7.4.7 - py311-sphinx8: Sphinx 8.2.3 --- tox.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tox.ini b/tox.ini index 8e41c93..6b50d3f 100644 --- a/tox.ini +++ b/tox.ini @@ -22,6 +22,10 @@ commands = pre-commit run {posargs} [testenv:py{311,312,313}-sphinx{6,7,8}] skip_install = false package = editable +# Constrain package dependencies to match our Sphinx version requirements +# This ensures the Sphinx version specified in deps takes precedence +constrain_package_deps = true +use_frozen_constraints = true deps = sphinx6: sphinx>=6.1,<7 sphinx7: sphinx>=7,<8 From a973a769fe0d87dfa1bae524263e1fad6539f7da Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Tue, 21 Oct 2025 17:08:22 +1100 Subject: [PATCH 11/16] Simplify tox configuration by using testing extras Now that constrain_package_deps is working correctly, we can use the 'testing' extras from pyproject.toml instead of manually listing all dependencies. This is more maintainable - when testing dependencies change in pyproject.toml, they automatically apply to tox without needing to update both files. The constraints mechanism ensures Sphinx version from deps still takes precedence over the package's sphinx>=6.1,<9 requirement. --- tox.ini | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/tox.ini b/tox.ini index 6b50d3f..e8d324c 100644 --- a/tox.ini +++ b/tox.ini @@ -22,24 +22,15 @@ commands = pre-commit run {posargs} [testenv:py{311,312,313}-sphinx{6,7,8}] skip_install = false package = editable -# Constrain package dependencies to match our Sphinx version requirements +# Use the 'testing' extras from pyproject.toml, but constrain Sphinx version # This ensures the Sphinx version specified in deps takes precedence +extras = testing constrain_package_deps = true use_frozen_constraints = true deps = sphinx6: sphinx>=6.1,<7 sphinx7: sphinx>=7,<8 sphinx8: sphinx>=8,<9 - beautifulsoup4 - coverage - matplotlib>=3.8 - myst-nb>=1.1.0 - pytest-cov - pytest-regressions - pytest>=8.0 - texsoup - defusedxml - sphinx-book-theme commands = pytest --verbose {posargs} [testenv:docs-{update,clean}] From 40a2cfe0e19511be1cf68cfa9fcd8d854e2781a9 Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Tue, 21 Oct 2025 17:55:47 +1100 Subject: [PATCH 12/16] Fix Sphinx 6 compatibility in conftest.py rootdir fixture The sphinx.testing.path.path object in Sphinx <7.2 doesn't have an .absolute() method. The path is already absolute, so we can use it directly without calling .absolute(). This fixes the AttributeError: 'path' object has no attribute 'absolute' error that was causing all 110 tests to fail on Sphinx 6. The version check ensures Sphinx 7.2+ continues to use pathlib.Path with .absolute() as before. --- tests/conftest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index f0bd262..3755088 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -15,7 +15,8 @@ def rootdir(tmpdir): from sphinx.testing.path import path - src = path(__file__).parent.absolute() / "books" + # In Sphinx 6, path objects don't have .absolute() method, but they are already absolute + src = path(__file__).parent / "books" dst = tmpdir.join("books") shutil.copytree(src, dst) yield path(dst) From 095b112cddc1aaf92b20089a70b3c646b0e1d501 Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Tue, 21 Oct 2025 19:01:03 +1100 Subject: [PATCH 13/16] Regenerate Sphinx 7 fixtures with normalized image hashes --- tests/test_gateddirective/solution-exercise-0.sphinx7.html | 2 +- tests/test_gateddirective/solution-exercise-1.sphinx7.html | 2 +- .../solution-exercise-gated-0.sphinx7.html | 2 +- .../solution-exercise-gated-1.sphinx7.html | 2 +- tests/test_gateddirective/solution-exercise-gated.sphinx7.xml | 4 ++-- tests/test_gateddirective/solution-exercise.sphinx7.xml | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_gateddirective/solution-exercise-0.sphinx7.html b/tests/test_gateddirective/solution-exercise-0.sphinx7.html index 91a66e3..609f4a5 100644 --- a/tests/test_gateddirective/solution-exercise-0.sphinx7.html +++ b/tests/test_gateddirective/solution-exercise-0.sphinx7.html @@ -35,7 +35,7 @@ </div> </div> <div class="cell_output docutils container"> -<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> +<img alt="_images/IMAGEHASH.png" src="_images/IMAGEHASH.png"/> </div> </div> <p>With some follow up text to the solution</p> diff --git a/tests/test_gateddirective/solution-exercise-1.sphinx7.html b/tests/test_gateddirective/solution-exercise-1.sphinx7.html index 07a29e9..912e9fe 100644 --- a/tests/test_gateddirective/solution-exercise-1.sphinx7.html +++ b/tests/test_gateddirective/solution-exercise-1.sphinx7.html @@ -35,7 +35,7 @@ </div> </div> <div class="cell_output docutils container"> -<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> +<img alt="_images/IMAGEHASH.png" src="_images/IMAGEHASH.png"/> </div> </div> <p>With some follow up text to the solution</p> diff --git a/tests/test_gateddirective/solution-exercise-gated-0.sphinx7.html b/tests/test_gateddirective/solution-exercise-gated-0.sphinx7.html index 6850101..cb426ea 100644 --- a/tests/test_gateddirective/solution-exercise-gated-0.sphinx7.html +++ b/tests/test_gateddirective/solution-exercise-gated-0.sphinx7.html @@ -35,7 +35,7 @@ </div> </div> <div class="cell_output docutils container"> -<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> +<img alt="_images/IMAGEHASH.png" src="_images/IMAGEHASH.png"/> </div> </div> <p>With some follow up text to the solution</p> diff --git a/tests/test_gateddirective/solution-exercise-gated-1.sphinx7.html b/tests/test_gateddirective/solution-exercise-gated-1.sphinx7.html index 21815e5..76bf8b2 100644 --- a/tests/test_gateddirective/solution-exercise-gated-1.sphinx7.html +++ b/tests/test_gateddirective/solution-exercise-gated-1.sphinx7.html @@ -35,7 +35,7 @@ </div> </div> <div class="cell_output docutils container"> -<img alt="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png" src="_images/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"/> +<img alt="_images/IMAGEHASH.png" src="_images/IMAGEHASH.png"/> </div> </div> <p>With some follow up text to the solution</p> diff --git a/tests/test_gateddirective/solution-exercise-gated.sphinx7.xml b/tests/test_gateddirective/solution-exercise-gated.sphinx7.xml index 88d1f0b..87e88a5 100644 --- a/tests/test_gateddirective/solution-exercise-gated.sphinx7.xml +++ b/tests/test_gateddirective/solution-exercise-gated.sphinx7.xml @@ -46,7 +46,7 @@ <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> <Figure size 640x480 with 2 Axes> <container mime_type="image/png"> - <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> + <image candidates="{'*': '_build/jupyter_execute/IMAGEHASH.png'}" uri="_build/jupyter_execute/IMAGEHASH.png"> <paragraph> With some follow up text to the solution <paragraph> @@ -98,7 +98,7 @@ <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> <Figure size 640x480 with 2 Axes> <container mime_type="image/png"> - <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> + <image candidates="{'*': '_build/jupyter_execute/IMAGEHASH.png'}" uri="_build/jupyter_execute/IMAGEHASH.png"> <paragraph> With some follow up text to the solution <section ids="references-to-solutions" names="references\ to\ solutions"> diff --git a/tests/test_gateddirective/solution-exercise.sphinx7.xml b/tests/test_gateddirective/solution-exercise.sphinx7.xml index f9c4e51..29cd9d9 100644 --- a/tests/test_gateddirective/solution-exercise.sphinx7.xml +++ b/tests/test_gateddirective/solution-exercise.sphinx7.xml @@ -46,7 +46,7 @@ <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> <Figure size 640x480 with 2 Axes> <container mime_type="image/png"> - <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> + <image candidates="{'*': '_build/jupyter_execute/IMAGEHASH.png'}" uri="_build/jupyter_execute/IMAGEHASH.png"> <paragraph> With some follow up text to the solution <paragraph> @@ -96,7 +96,7 @@ <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> <Figure size 640x480 with 2 Axes> <container mime_type="image/png"> - <image candidates="{'*': '_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png'}" uri="_build/jupyter_execute/ff2d6cfc1cb5967111b6c3c5094239ee0b77720b11d3b11f66a32bb897beb13a.png"> + <image candidates="{'*': '_build/jupyter_execute/IMAGEHASH.png'}" uri="_build/jupyter_execute/IMAGEHASH.png"> <paragraph> With some follow up text to the solution <section ids="references" names="references"> From 1fd4506d8e91e79b0dd36a39bb6d3fdfa67120b9 Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Tue, 21 Oct 2025 20:13:47 +1100 Subject: [PATCH 14/16] Add Sphinx 6 fixture files for complete test coverage --- .../_enum_numref_mathtitle.sphinx6.html | 4 + .../_enum_numref_notitle.sphinx6.html | 4 + .../_enum_numref_placeholders.sphinx6.html | 10 + .../_enum_numref_title.sphinx6.html | 4 + .../_enum_ref_mathtitle.sphinx6.html | 2 + .../_enum_ref_notitle.sphinx6.html | 2 + .../_enum_ref_title.sphinx6.html | 2 + .../_unenum_numref_mathtitle.sphinx6.html | 4 + .../_unenum_numref_notitle.sphinx6.html | 4 + .../_unenum_numref_title.sphinx6.html | 4 + .../_unenum_ref_mathtitle.sphinx6.html | 2 + .../_unenum_ref_notitle.sphinx6.html | 2 + .../_unenum_ref_title.sphinx6.html | 2 + .../exercise-gated-0.sphinx6.html | 9 + .../exercise-gated-1.sphinx6.html | 8 + .../exercise-gated.sphinx6.xml | 24 +++ .../solution-exercise-0.sphinx6.html | 43 +++++ .../solution-exercise-1.sphinx6.html | 43 +++++ .../solution-exercise-gated-0.sphinx6.html | 43 +++++ .../solution-exercise-gated-1.sphinx6.html | 43 +++++ .../solution-exercise-gated.sphinx6.xml | 111 +++++++++++ .../solution-exercise.sphinx6.xml | 114 +++++++++++ tests/test_latex/test_latex_build.sphinx6.tex | 181 ++++++++++++++++++ .../_linked_duplicate_label.sphinx6.xml | 10 + tests/test_solution/_linked_enum.sphinx6.xml | 29 +++ .../_linked_enum_class.sphinx6.xml | 10 + .../_linked_missing_arg.sphinx6.xml | 4 + .../_linked_unenum_mathtitle.sphinx6.xml | 24 +++ .../_linked_unenum_mathtitle2.sphinx6.xml | 24 +++ .../_linked_unenum_notitle.sphinx6.xml | 20 ++ .../_linked_unenum_title.sphinx6.xml | 22 +++ .../_linked_wrong_targetlabel.sphinx6.xml | 10 + .../_linked_duplicate_label.sphinx6.xml | 10 + .../solution/_linked_enum.sphinx6.xml | 29 +++ .../solution/_linked_enum_class.sphinx6.xml | 10 + .../solution/_linked_missing_arg.sphinx6.xml | 4 + .../_linked_unenum_mathtitle.sphinx6.xml | 24 +++ .../_linked_unenum_mathtitle2.sphinx6.xml | 24 +++ .../_linked_unenum_notitle.sphinx6.xml | 20 ++ .../solution/_linked_unenum_title.sphinx6.xml | 22 +++ .../_linked_wrong_targetlabel.sphinx6.xml | 10 + .../_linked_ref_enum.sphinx6.html | 2 + .../_linked_ref_unenum_mathtitle.sphinx6.html | 2 + ..._linked_ref_unenum_mathtitle2.sphinx6.html | 2 + .../_linked_ref_unenum_notitle.sphinx6.html | 2 + .../_linked_ref_unenum_title.sphinx6.html | 2 + 46 files changed, 981 insertions(+) create mode 100644 tests/test_exercise_references/_enum_numref_mathtitle.sphinx6.html create mode 100644 tests/test_exercise_references/_enum_numref_notitle.sphinx6.html create mode 100644 tests/test_exercise_references/_enum_numref_placeholders.sphinx6.html create mode 100644 tests/test_exercise_references/_enum_numref_title.sphinx6.html create mode 100644 tests/test_exercise_references/_enum_ref_mathtitle.sphinx6.html create mode 100644 tests/test_exercise_references/_enum_ref_notitle.sphinx6.html create mode 100644 tests/test_exercise_references/_enum_ref_title.sphinx6.html create mode 100644 tests/test_exercise_references/_unenum_numref_mathtitle.sphinx6.html create mode 100644 tests/test_exercise_references/_unenum_numref_notitle.sphinx6.html create mode 100644 tests/test_exercise_references/_unenum_numref_title.sphinx6.html create mode 100644 tests/test_exercise_references/_unenum_ref_mathtitle.sphinx6.html create mode 100644 tests/test_exercise_references/_unenum_ref_notitle.sphinx6.html create mode 100644 tests/test_exercise_references/_unenum_ref_title.sphinx6.html create mode 100644 tests/test_gateddirective/exercise-gated-0.sphinx6.html create mode 100644 tests/test_gateddirective/exercise-gated-1.sphinx6.html create mode 100644 tests/test_gateddirective/exercise-gated.sphinx6.xml create mode 100644 tests/test_gateddirective/solution-exercise-0.sphinx6.html create mode 100644 tests/test_gateddirective/solution-exercise-1.sphinx6.html create mode 100644 tests/test_gateddirective/solution-exercise-gated-0.sphinx6.html create mode 100644 tests/test_gateddirective/solution-exercise-gated-1.sphinx6.html create mode 100644 tests/test_gateddirective/solution-exercise-gated.sphinx6.xml create mode 100644 tests/test_gateddirective/solution-exercise.sphinx6.xml create mode 100644 tests/test_latex/test_latex_build.sphinx6.tex create mode 100644 tests/test_solution/_linked_duplicate_label.sphinx6.xml create mode 100644 tests/test_solution/_linked_enum.sphinx6.xml create mode 100644 tests/test_solution/_linked_enum_class.sphinx6.xml create mode 100644 tests/test_solution/_linked_missing_arg.sphinx6.xml create mode 100644 tests/test_solution/_linked_unenum_mathtitle.sphinx6.xml create mode 100644 tests/test_solution/_linked_unenum_mathtitle2.sphinx6.xml create mode 100644 tests/test_solution/_linked_unenum_notitle.sphinx6.xml create mode 100644 tests/test_solution/_linked_unenum_title.sphinx6.xml create mode 100644 tests/test_solution/_linked_wrong_targetlabel.sphinx6.xml create mode 100644 tests/test_solution/solution/_linked_duplicate_label.sphinx6.xml create mode 100644 tests/test_solution/solution/_linked_enum.sphinx6.xml create mode 100644 tests/test_solution/solution/_linked_enum_class.sphinx6.xml create mode 100644 tests/test_solution/solution/_linked_missing_arg.sphinx6.xml create mode 100644 tests/test_solution/solution/_linked_unenum_mathtitle.sphinx6.xml create mode 100644 tests/test_solution/solution/_linked_unenum_mathtitle2.sphinx6.xml create mode 100644 tests/test_solution/solution/_linked_unenum_notitle.sphinx6.xml create mode 100644 tests/test_solution/solution/_linked_unenum_title.sphinx6.xml create mode 100644 tests/test_solution/solution/_linked_wrong_targetlabel.sphinx6.xml create mode 100644 tests/test_solution_references/_linked_ref_enum.sphinx6.html create mode 100644 tests/test_solution_references/_linked_ref_unenum_mathtitle.sphinx6.html create mode 100644 tests/test_solution_references/_linked_ref_unenum_mathtitle2.sphinx6.html create mode 100644 tests/test_solution_references/_linked_ref_unenum_notitle.sphinx6.html create mode 100644 tests/test_solution_references/_linked_ref_unenum_title.sphinx6.html diff --git a/tests/test_exercise_references/_enum_numref_mathtitle.sphinx6.html b/tests/test_exercise_references/_enum_numref_mathtitle.sphinx6.html new file mode 100644 index 0000000..5d17801 --- /dev/null +++ b/tests/test_exercise_references/_enum_numref_mathtitle.sphinx6.html @@ -0,0 +1,4 @@ +<p>This is a reference <a class="reference internal" href="_enum_mathtitle_label.html#test-exc-label-math"><span class="std std-numref">Exercise 1</span></a>.</p> +<p>This is a second reference <a class="reference internal" href="_enum_mathtitle_label.html#test-exc-label-math"><span class="std std-numref">some text 1</span></a>.</p> +<p>This is a third reference <a class="reference internal" href="_enum_mathtitle_label.html#test-exc-label-math"><span class="std std-numref">some text 1</span></a>.</p> +<p>This is a fourth reference <a class="reference internal" href="_enum_mathtitle_label.html#test-exc-label-math"><span class="std std-numref">some text Exercise</span></a>.</p> \ No newline at end of file diff --git a/tests/test_exercise_references/_enum_numref_notitle.sphinx6.html b/tests/test_exercise_references/_enum_numref_notitle.sphinx6.html new file mode 100644 index 0000000..90a5c54 --- /dev/null +++ b/tests/test_exercise_references/_enum_numref_notitle.sphinx6.html @@ -0,0 +1,4 @@ +<p>This is a reference <a class="reference internal" href="_enum_notitle_label.html#text-exc-notitle"><span class="std std-numref">Exercise 2</span></a>.</p> +<p>This is a second reference <a class="reference internal" href="_enum_notitle_label.html#text-exc-notitle"><span class="std std-numref">some text 2</span></a>.</p> +<p>This is a third reference <a class="reference internal" href="_enum_notitle_label.html#text-exc-notitle"><span class="std std-numref">some text 2</span></a>.</p> +<p>This is a fourth reference <a class="reference internal" href="_enum_notitle_label.html#text-exc-notitle"><span class="std std-numref">some text Exercise</span></a>.</p> \ No newline at end of file diff --git a/tests/test_exercise_references/_enum_numref_placeholders.sphinx6.html b/tests/test_exercise_references/_enum_numref_placeholders.sphinx6.html new file mode 100644 index 0000000..07f2a5a --- /dev/null +++ b/tests/test_exercise_references/_enum_numref_placeholders.sphinx6.html @@ -0,0 +1,10 @@ +<p>This reference does not include math <a class="reference internal" href="_enum_title_class_label.html#test-exc-label"><span class="std std-numref">some 3 text %s test Exercise</span></a>.</p> +<p>This reference does not include math <a class="reference internal" href="_enum_title_class_label.html#test-exc-label"><span class="std std-numref">some 3 text %s test</span></a>.</p> +<p>This reference does not include math <a class="reference internal" href="_enum_title_class_label.html#test-exc-label"><span class="std std-numref">some Exercise text %s test</span></a>.</p> +<p>This reference does not include math <a class="reference internal" href="_enum_title_class_label.html#test-exc-label"><span class="std std-numref">some Exercise text 3 test</span></a>.</p> +<p>This reference does not include math <a class="reference internal" href="_enum_title_class_label.html#test-exc-label"><span class="std std-numref">some 3 text test</span></a>.</p> +<p>This reference includes math <a class="reference internal" href="_enum_mathtitle_label.html#test-exc-label-math"><span class="std std-numref">some 1 text %s test Exercise</span></a>.</p> +<p>This reference includes math <a class="reference internal" href="_enum_mathtitle_label.html#test-exc-label-math"><span class="std std-numref">some 1 text %s test</span></a>.</p> +<p>This reference includes math <a class="reference internal" href="_enum_mathtitle_label.html#test-exc-label-math"><span class="std std-numref">some Exercise text %s test</span></a>.</p> +<p>This reference includes math <a class="reference internal" href="_enum_mathtitle_label.html#test-exc-label-math"><span class="std std-numref">some Exercise text 1 test</span></a>.</p> +<p>This reference includes math <a class="reference internal" href="_enum_mathtitle_label.html#test-exc-label-math"><span class="std std-numref">some 1 text test</span></a>.</p> \ No newline at end of file diff --git a/tests/test_exercise_references/_enum_numref_title.sphinx6.html b/tests/test_exercise_references/_enum_numref_title.sphinx6.html new file mode 100644 index 0000000..c2a4496 --- /dev/null +++ b/tests/test_exercise_references/_enum_numref_title.sphinx6.html @@ -0,0 +1,4 @@ +<p>This is a reference <a class="reference internal" href="_enum_title_class_label.html#test-exc-label"><span class="std std-numref">Exercise 3</span></a>.</p> +<p>This is a second reference <a class="reference internal" href="_enum_title_class_label.html#test-exc-label"><span class="std std-numref">some text 3</span></a>.</p> +<p>This is a third reference <a class="reference internal" href="_enum_title_class_label.html#test-exc-label"><span class="std std-numref">some text 3</span></a>.</p> +<p>This is a fourth reference <a class="reference internal" href="_enum_title_class_label.html#test-exc-label"><span class="std std-numref">some text Exercise</span></a>.</p> \ No newline at end of file diff --git a/tests/test_exercise_references/_enum_ref_mathtitle.sphinx6.html b/tests/test_exercise_references/_enum_ref_mathtitle.sphinx6.html new file mode 100644 index 0000000..508253a --- /dev/null +++ b/tests/test_exercise_references/_enum_ref_mathtitle.sphinx6.html @@ -0,0 +1,2 @@ +<p>This is a reference <a class="reference internal" href="_enum_mathtitle_label.html#test-exc-label-math"><span class="std std-numref">Exercise 1</span></a>.</p> +<p>This is a second reference <a class="reference internal" href="_enum_mathtitle_label.html#test-exc-label-math"><span class="std std-ref">some text</span></a>.</p> \ No newline at end of file diff --git a/tests/test_exercise_references/_enum_ref_notitle.sphinx6.html b/tests/test_exercise_references/_enum_ref_notitle.sphinx6.html new file mode 100644 index 0000000..972f9f9 --- /dev/null +++ b/tests/test_exercise_references/_enum_ref_notitle.sphinx6.html @@ -0,0 +1,2 @@ +<p>This is a reference <a class="reference internal" href="_enum_notitle_label.html#text-exc-notitle"><span class="std std-numref">Exercise 2</span></a>.</p> +<p>This is a second reference <a class="reference internal" href="_enum_notitle_label.html#text-exc-notitle"><span class="std std-ref">some text</span></a>.</p> \ No newline at end of file diff --git a/tests/test_exercise_references/_enum_ref_title.sphinx6.html b/tests/test_exercise_references/_enum_ref_title.sphinx6.html new file mode 100644 index 0000000..5235a0a --- /dev/null +++ b/tests/test_exercise_references/_enum_ref_title.sphinx6.html @@ -0,0 +1,2 @@ +<p>This is a reference <a class="reference internal" href="_enum_title_class_label.html#test-exc-label"><span class="std std-numref">Exercise 3</span></a>.</p> +<p>This is a second reference <a class="reference internal" href="_enum_title_class_label.html#test-exc-label"><span class="std std-ref">some text</span></a>.</p> \ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_numref_mathtitle.sphinx6.html b/tests/test_exercise_references/_unenum_numref_mathtitle.sphinx6.html new file mode 100644 index 0000000..93876d4 --- /dev/null +++ b/tests/test_exercise_references/_unenum_numref_mathtitle.sphinx6.html @@ -0,0 +1,4 @@ +<p>This is a reference <code class="xref std std-numref docutils literal notranslate"><span class="pre">unen-exc-label-math</span></code>.</p> +<p>This is a second reference <code class="xref std std-numref docutils literal notranslate"><span class="pre">some</span> <span class="pre">text</span> <span class="pre">%s</span></code>.</p> +<p>This is a third reference <code class="xref std std-numref docutils literal notranslate"><span class="pre">some</span> <span class="pre">text</span> <span class="pre">{number}</span></code>.</p> +<p>This is a fourth reference <code class="xref std std-numref docutils literal notranslate"><span class="pre">some</span> <span class="pre">text</span> <span class="pre">{name}</span></code>.</p> \ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_numref_notitle.sphinx6.html b/tests/test_exercise_references/_unenum_numref_notitle.sphinx6.html new file mode 100644 index 0000000..a952ce1 --- /dev/null +++ b/tests/test_exercise_references/_unenum_numref_notitle.sphinx6.html @@ -0,0 +1,4 @@ +<p>This is a reference <code class="xref std std-numref docutils literal notranslate"><span class="pre">unen-exc-notitle</span></code>.</p> +<p>This is a second reference <code class="xref std std-numref docutils literal notranslate"><span class="pre">some</span> <span class="pre">text</span> <span class="pre">%s</span></code>.</p> +<p>This is a third reference <code class="xref std std-numref docutils literal notranslate"><span class="pre">some</span> <span class="pre">text</span> <span class="pre">{number}</span></code>.</p> +<p>This is a fourth reference <code class="xref std std-numref docutils literal notranslate"><span class="pre">some</span> <span class="pre">text</span> <span class="pre">{name}</span></code>.</p> \ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_numref_title.sphinx6.html b/tests/test_exercise_references/_unenum_numref_title.sphinx6.html new file mode 100644 index 0000000..0bc31c3 --- /dev/null +++ b/tests/test_exercise_references/_unenum_numref_title.sphinx6.html @@ -0,0 +1,4 @@ +<p>This is a reference <code class="xref std std-numref docutils literal notranslate"><span class="pre">unen-exc-label</span></code>.</p> +<p>This is a second reference <code class="xref std std-numref docutils literal notranslate"><span class="pre">some</span> <span class="pre">text</span> <span class="pre">%s</span></code>.</p> +<p>This is a third reference <code class="xref std std-numref docutils literal notranslate"><span class="pre">some</span> <span class="pre">text</span> <span class="pre">{number}</span></code>.</p> +<p>This is a fourth reference <code class="xref std std-numref docutils literal notranslate"><span class="pre">some</span> <span class="pre">text</span> <span class="pre">{name}</span></code>.</p> \ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_ref_mathtitle.sphinx6.html b/tests/test_exercise_references/_unenum_ref_mathtitle.sphinx6.html new file mode 100644 index 0000000..a4a4bf8 --- /dev/null +++ b/tests/test_exercise_references/_unenum_ref_mathtitle.sphinx6.html @@ -0,0 +1,2 @@ +<p>This is a reference <a class="reference internal" href="_unenum_mathtitle_label.html#unen-exc-label-math"><span class="std std-ref">Exercise</span></a>.</p> +<p>This is a second reference <a class="reference internal" href="_unenum_mathtitle_label.html#unen-exc-label-math"><span class="std std-ref">some text</span></a>.</p> \ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_ref_notitle.sphinx6.html b/tests/test_exercise_references/_unenum_ref_notitle.sphinx6.html new file mode 100644 index 0000000..c20af93 --- /dev/null +++ b/tests/test_exercise_references/_unenum_ref_notitle.sphinx6.html @@ -0,0 +1,2 @@ +<p>This is a reference <a class="reference internal" href="_unenum_notitle_label.html#unen-exc-notitle"><span class="std std-ref">Exercise</span></a>.</p> +<p>This is a second reference <a class="reference internal" href="_unenum_notitle_label.html#unen-exc-notitle"><span class="std std-ref">some text</span></a>.</p> \ No newline at end of file diff --git a/tests/test_exercise_references/_unenum_ref_title.sphinx6.html b/tests/test_exercise_references/_unenum_ref_title.sphinx6.html new file mode 100644 index 0000000..50ea0dd --- /dev/null +++ b/tests/test_exercise_references/_unenum_ref_title.sphinx6.html @@ -0,0 +1,2 @@ +<p>This is a reference <a class="reference internal" href="_unenum_title_class_label.html#unen-exc-label"><span class="std std-ref">Exercise</span></a>.</p> +<p>This is a second reference <a class="reference internal" href="_unenum_title_class_label.html#unen-exc-label"><span class="std std-ref">some text</span></a>.</p> \ No newline at end of file diff --git a/tests/test_gateddirective/exercise-gated-0.sphinx6.html b/tests/test_gateddirective/exercise-gated-0.sphinx6.html new file mode 100644 index 0000000..efd2440 --- /dev/null +++ b/tests/test_gateddirective/exercise-gated-0.sphinx6.html @@ -0,0 +1,9 @@ +<div class="exercise admonition" id="gated-exercise-1"> +<p class="admonition-title"><span class="caption-number">Exercise 3 </span></p> +<section id="exercise-content"> +<p>Replicate this figure using matplotlib</p> +<figure class="align-default"> +<img alt="_images/sphx_glr_cohere_001_2_0x.png" src="_images/sphx_glr_cohere_001_2_0x.png"/> +</figure> +</section> +</div> \ No newline at end of file diff --git a/tests/test_gateddirective/exercise-gated-1.sphinx6.html b/tests/test_gateddirective/exercise-gated-1.sphinx6.html new file mode 100644 index 0000000..bded47e --- /dev/null +++ b/tests/test_gateddirective/exercise-gated-1.sphinx6.html @@ -0,0 +1,8 @@ +<div class="exercise admonition" id="gated-exercise-2"> +<p class="admonition-title"><span class="caption-number">Exercise 4 </span> (Replicate Matplotlib Plot)</p> +<section id="exercise-content"> +<figure class="align-default"> +<img alt="_images/sphx_glr_cohere_001_2_0x.png" src="_images/sphx_glr_cohere_001_2_0x.png"/> +</figure> +</section> +</div> \ No newline at end of file diff --git a/tests/test_gateddirective/exercise-gated.sphinx6.xml b/tests/test_gateddirective/exercise-gated.sphinx6.xml new file mode 100644 index 0000000..40285bf --- /dev/null +++ b/tests/test_gateddirective/exercise-gated.sphinx6.xml @@ -0,0 +1,24 @@ +<document source="exercise-gated.md"> + <section ids="gated-exercises" names="gated\ exercises"> + <title> + Gated Exercises + <paragraph> + Some Gated reference exercises + <exercise_enumerable_node classes="exercise" docname="exercise-gated" hidden="False" ids="gated-exercise-1" label="gated-exercise-1" names="gated-exercise-1" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <section ids="exercise-content"> + <paragraph> + Replicate this figure using matplotlib + <figure> + <image candidates="{'*': 'sphx_glr_cohere_001_2_0x.png'}" uri="sphx_glr_cohere_001_2_0x.png"> + <paragraph> + and another version with a title embedded + <exercise_enumerable_node classes="exercise" docname="exercise-gated" hidden="False" ids="gated-exercise-2" label="gated-exercise-2" names="gated-exercise-2" serial_number="1" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + Replicate Matplotlib Plot + <section ids="exercise-content"> + <figure> + <image candidates="{'*': 'sphx_glr_cohere_001_2_0x.png'}" uri="sphx_glr_cohere_001_2_0x.png"> diff --git a/tests/test_gateddirective/solution-exercise-0.sphinx6.html b/tests/test_gateddirective/solution-exercise-0.sphinx6.html new file mode 100644 index 0000000..609f4a5 --- /dev/null +++ b/tests/test_gateddirective/solution-exercise-0.sphinx6.html @@ -0,0 +1,43 @@ +<div class="solution admonition" id="solution-gated-1"> +<p class="admonition-title">Solution to<a class="reference internal" href="exercise.html#exercise-1"> Exercise 1</a></p> +<section id="solution-content"> +<p>This is a solution to Non-Gated Exercise 1</p> +<div class="cell docutils container"> +<div class="cell_input docutils container"> +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span> +<span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span> + +<span class="c1"># Fixing random state for reproducibility</span> +<span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">19680801</span><span class="p">)</span> + +<span class="n">dt</span> <span class="o">=</span> <span class="mf">0.01</span> +<span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">nse1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 1</span> +<span class="n">nse2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 2</span> + +<span class="c1"># Two signals with a coherent part at 10Hz and a random part</span> +<span class="n">s1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse1</span> +<span class="n">s2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse2</span> + +<span class="n">fig</span><span class="p">,</span> <span class="n">axs</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">s1</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">'time'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> + +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="n">NFFT</span><span class="o">=</span><span class="mi">256</span><span class="p">,</span> <span class="n">Fs</span><span class="o">=</span><span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> + +<span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> +<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> +</pre></div> +</div> +</div> +<div class="cell_output docutils container"> +<img alt="_images/IMAGEHASH.png" src="_images/IMAGEHASH.png"/> +</div> +</div> +<p>With some follow up text to the solution</p> +</section> +</div> \ No newline at end of file diff --git a/tests/test_gateddirective/solution-exercise-1.sphinx6.html b/tests/test_gateddirective/solution-exercise-1.sphinx6.html new file mode 100644 index 0000000..912e9fe --- /dev/null +++ b/tests/test_gateddirective/solution-exercise-1.sphinx6.html @@ -0,0 +1,43 @@ +<div class="solution admonition" id="solution-gated-2"> +<p class="admonition-title">Solution to<a class="reference internal" href="exercise.html#exercise-2"> Exercise 2 (Replicate Matplotlib Plot)</a></p> +<section id="solution-content"> +<p>This is a solution to Non-Gated Exercise 1</p> +<div class="cell docutils container"> +<div class="cell_input docutils container"> +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span> +<span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span> + +<span class="c1"># Fixing random state for reproducibility</span> +<span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">19680801</span><span class="p">)</span> + +<span class="n">dt</span> <span class="o">=</span> <span class="mf">0.01</span> +<span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">nse1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 1</span> +<span class="n">nse2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 2</span> + +<span class="c1"># Two signals with a coherent part at 10Hz and a random part</span> +<span class="n">s1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse1</span> +<span class="n">s2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse2</span> + +<span class="n">fig</span><span class="p">,</span> <span class="n">axs</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">s1</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">'time'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> + +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="n">NFFT</span><span class="o">=</span><span class="mi">256</span><span class="p">,</span> <span class="n">Fs</span><span class="o">=</span><span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> + +<span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> +<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> +</pre></div> +</div> +</div> +<div class="cell_output docutils container"> +<img alt="_images/IMAGEHASH.png" src="_images/IMAGEHASH.png"/> +</div> +</div> +<p>With some follow up text to the solution</p> +</section> +</div> \ No newline at end of file diff --git a/tests/test_gateddirective/solution-exercise-gated-0.sphinx6.html b/tests/test_gateddirective/solution-exercise-gated-0.sphinx6.html new file mode 100644 index 0000000..cb426ea --- /dev/null +++ b/tests/test_gateddirective/solution-exercise-gated-0.sphinx6.html @@ -0,0 +1,43 @@ +<div class="solution admonition" id="gated-exercise-solution-1"> +<p class="admonition-title">Solution to<a class="reference internal" href="exercise-gated.html#gated-exercise-1"> Exercise 3</a></p> +<section id="solution-content"> +<p>This is a solution to Gated Exercise 1</p> +<div class="cell docutils container"> +<div class="cell_input docutils container"> +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span> +<span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span> + +<span class="c1"># Fixing random state for reproducibility</span> +<span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">19680801</span><span class="p">)</span> + +<span class="n">dt</span> <span class="o">=</span> <span class="mf">0.01</span> +<span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">nse1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 1</span> +<span class="n">nse2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 2</span> + +<span class="c1"># Two signals with a coherent part at 10Hz and a random part</span> +<span class="n">s1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse1</span> +<span class="n">s2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse2</span> + +<span class="n">fig</span><span class="p">,</span> <span class="n">axs</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">s1</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">'time'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> + +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="n">NFFT</span><span class="o">=</span><span class="mi">256</span><span class="p">,</span> <span class="n">Fs</span><span class="o">=</span><span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> + +<span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> +<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> +</pre></div> +</div> +</div> +<div class="cell_output docutils container"> +<img alt="_images/IMAGEHASH.png" src="_images/IMAGEHASH.png"/> +</div> +</div> +<p>With some follow up text to the solution</p> +</section> +</div> \ No newline at end of file diff --git a/tests/test_gateddirective/solution-exercise-gated-1.sphinx6.html b/tests/test_gateddirective/solution-exercise-gated-1.sphinx6.html new file mode 100644 index 0000000..76bf8b2 --- /dev/null +++ b/tests/test_gateddirective/solution-exercise-gated-1.sphinx6.html @@ -0,0 +1,43 @@ +<div class="solution admonition" id="gated-exercise-solution-2"> +<p class="admonition-title">Solution to<a class="reference internal" href="exercise-gated.html#gated-exercise-2"> Exercise 4 (Replicate Matplotlib Plot)</a></p> +<section id="solution-content"> +<p>This is a solution to Gated Exercise 2</p> +<div class="cell docutils container"> +<div class="cell_input docutils container"> +<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">numpy</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">np</span> +<span class="kn">import</span><span class="w"> </span><span class="nn">matplotlib.pyplot</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="nn">plt</span> + +<span class="c1"># Fixing random state for reproducibility</span> +<span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">19680801</span><span class="p">)</span> + +<span class="n">dt</span> <span class="o">=</span> <span class="mf">0.01</span> +<span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">nse1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 1</span> +<span class="n">nse2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">t</span><span class="p">))</span> <span class="c1"># white noise 2</span> + +<span class="c1"># Two signals with a coherent part at 10Hz and a random part</span> +<span class="n">s1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse1</span> +<span class="n">s2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="mi">10</span> <span class="o">*</span> <span class="n">t</span><span class="p">)</span> <span class="o">+</span> <span class="n">nse2</span> + +<span class="n">fig</span><span class="p">,</span> <span class="n">axs</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">s1</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">s2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">'time'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'s1 and s2'</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span> + +<span class="n">cxy</span><span class="p">,</span> <span class="n">f</span> <span class="o">=</span> <span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">cohere</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">,</span> <span class="n">NFFT</span><span class="o">=</span><span class="mi">256</span><span class="p">,</span> <span class="n">Fs</span><span class="o">=</span><span class="mf">1.</span> <span class="o">/</span> <span class="n">dt</span><span class="p">)</span> +<span class="n">axs</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">'coherence'</span><span class="p">)</span> + +<span class="n">fig</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span> +<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> +</pre></div> +</div> +</div> +<div class="cell_output docutils container"> +<img alt="_images/IMAGEHASH.png" src="_images/IMAGEHASH.png"/> +</div> +</div> +<p>With some follow up text to the solution</p> +</section> +</div> \ No newline at end of file diff --git a/tests/test_gateddirective/solution-exercise-gated.sphinx6.xml b/tests/test_gateddirective/solution-exercise-gated.sphinx6.xml new file mode 100644 index 0000000..87e88a5 --- /dev/null +++ b/tests/test_gateddirective/solution-exercise-gated.sphinx6.xml @@ -0,0 +1,111 @@ +<document source="solution-exercise-gated.md"> + <section ids="gated-solutions-to-exercise-gated-md" names="gated\ solutions\ to\ exercise-gated.md"> + <title> + Gated Solutions to exercise-gated.md + <paragraph> + A solution using the gated directive + <solution_node classes="solution" docname="solution-exercise-gated" hidden="False" ids="gated-exercise-solution-1" label="gated-exercise-solution-1" names="gated-exercise-solution-1" serial_number="0" target_label="gated-exercise-1" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + This is a solution to Gated Exercise 1 + <container cell_index="1" cell_metadata="{}" classes="cell" exec_count="1" nb_element="cell_code"> + <container classes="cell_input" nb_element="cell_code_source"> + <literal_block language="ipython3" xml:space="preserve"> + import numpy as np + import matplotlib.pyplot as plt + + # Fixing random state for reproducibility + np.random.seed(19680801) + + dt = 0.01 + t = np.arange(0, 30, dt) + nse1 = np.random.randn(len(t)) # white noise 1 + nse2 = np.random.randn(len(t)) # white noise 2 + + # Two signals with a coherent part at 10Hz and a random part + s1 = np.sin(2 * np.pi * 10 * t) + nse1 + s2 = np.sin(2 * np.pi * 10 * t) + nse2 + + fig, axs = plt.subplots(2, 1) + axs[0].plot(t, s1, t, s2) + axs[0].set_xlim(0, 2) + axs[0].set_xlabel('time') + axs[0].set_ylabel('s1 and s2') + axs[0].grid(True) + + cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) + axs[1].set_ylabel('coherence') + + fig.tight_layout() + plt.show() + <container classes="cell_output" nb_element="cell_code_output"> + <container nb_element="mime_bundle"> + <container mime_type="text/plain"> + <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> + <Figure size 640x480 with 2 Axes> + <container mime_type="image/png"> + <image candidates="{'*': '_build/jupyter_execute/IMAGEHASH.png'}" uri="_build/jupyter_execute/IMAGEHASH.png"> + <paragraph> + With some follow up text to the solution + <paragraph> + and then a solution to + <pending_xref refdoc="solution-exercise-gated" refdomain="std" refexplicit="False" reftarget="gated-exercise-2" reftype="ref" refwarn="True"> + <inline classes="xref std std-ref"> + gated-exercise-2 + <paragraph> + A solution using the gated directive + <solution_node classes="solution" docname="solution-exercise-gated" hidden="False" ids="gated-exercise-solution-2" label="gated-exercise-solution-2" names="gated-exercise-solution-2" serial_number="1" target_label="gated-exercise-2" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + This is a solution to Gated Exercise 2 + <container cell_index="3" cell_metadata="{}" classes="cell" exec_count="2" nb_element="cell_code"> + <container classes="cell_input" nb_element="cell_code_source"> + <literal_block language="ipython3" xml:space="preserve"> + import numpy as np + import matplotlib.pyplot as plt + + # Fixing random state for reproducibility + np.random.seed(19680801) + + dt = 0.01 + t = np.arange(0, 30, dt) + nse1 = np.random.randn(len(t)) # white noise 1 + nse2 = np.random.randn(len(t)) # white noise 2 + + # Two signals with a coherent part at 10Hz and a random part + s1 = np.sin(2 * np.pi * 10 * t) + nse1 + s2 = np.sin(2 * np.pi * 10 * t) + nse2 + + fig, axs = plt.subplots(2, 1) + axs[0].plot(t, s1, t, s2) + axs[0].set_xlim(0, 2) + axs[0].set_xlabel('time') + axs[0].set_ylabel('s1 and s2') + axs[0].grid(True) + + cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) + axs[1].set_ylabel('coherence') + + fig.tight_layout() + plt.show() + <container classes="cell_output" nb_element="cell_code_output"> + <container nb_element="mime_bundle"> + <container mime_type="text/plain"> + <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> + <Figure size 640x480 with 2 Axes> + <container mime_type="image/png"> + <image candidates="{'*': '_build/jupyter_execute/IMAGEHASH.png'}" uri="_build/jupyter_execute/IMAGEHASH.png"> + <paragraph> + With some follow up text to the solution + <section ids="references-to-solutions" names="references\ to\ solutions"> + <title> + References to Solutions + <paragraph> + This is a reference to + <pending_xref refdoc="solution-exercise-gated" refdomain="std" refexplicit="False" reftarget="gated-exercise-solution-1" reftype="ref" refwarn="True"> + <inline classes="xref std std-ref"> + gated-exercise-solution-1 diff --git a/tests/test_gateddirective/solution-exercise.sphinx6.xml b/tests/test_gateddirective/solution-exercise.sphinx6.xml new file mode 100644 index 0000000..29cd9d9 --- /dev/null +++ b/tests/test_gateddirective/solution-exercise.sphinx6.xml @@ -0,0 +1,114 @@ +<document source="solution-exercise.md"> + <section ids="gated-solutions-to-exercise-md" names="gated\ solutions\ to\ exercise.md"> + <title> + Gated Solutions to exercise.md + <paragraph> + A solution using the gated directive + <solution_node classes="solution" docname="solution-exercise" hidden="False" ids="solution-gated-1" label="solution-gated-1" names="solution-gated-1" serial_number="0" target_label="exercise-1" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + This is a solution to Non-Gated Exercise 1 + <container cell_index="1" cell_metadata="{}" classes="cell" exec_count="1" nb_element="cell_code"> + <container classes="cell_input" nb_element="cell_code_source"> + <literal_block language="ipython3" xml:space="preserve"> + import numpy as np + import matplotlib.pyplot as plt + + # Fixing random state for reproducibility + np.random.seed(19680801) + + dt = 0.01 + t = np.arange(0, 30, dt) + nse1 = np.random.randn(len(t)) # white noise 1 + nse2 = np.random.randn(len(t)) # white noise 2 + + # Two signals with a coherent part at 10Hz and a random part + s1 = np.sin(2 * np.pi * 10 * t) + nse1 + s2 = np.sin(2 * np.pi * 10 * t) + nse2 + + fig, axs = plt.subplots(2, 1) + axs[0].plot(t, s1, t, s2) + axs[0].set_xlim(0, 2) + axs[0].set_xlabel('time') + axs[0].set_ylabel('s1 and s2') + axs[0].grid(True) + + cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) + axs[1].set_ylabel('coherence') + + fig.tight_layout() + plt.show() + <container classes="cell_output" nb_element="cell_code_output"> + <container nb_element="mime_bundle"> + <container mime_type="text/plain"> + <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> + <Figure size 640x480 with 2 Axes> + <container mime_type="image/png"> + <image candidates="{'*': '_build/jupyter_execute/IMAGEHASH.png'}" uri="_build/jupyter_execute/IMAGEHASH.png"> + <paragraph> + With some follow up text to the solution + <paragraph> + and a solution to + <pending_xref refdoc="solution-exercise" refdomain="std" refexplicit="False" reftarget="exercise-2" reftype="ref" refwarn="True"> + <inline classes="xref std std-ref"> + exercise-2 + <solution_node classes="solution" docname="solution-exercise" hidden="False" ids="solution-gated-2" label="solution-gated-2" names="solution-gated-2" serial_number="1" target_label="exercise-2" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + This is a solution to Non-Gated Exercise 1 + <container cell_index="3" cell_metadata="{}" classes="cell" exec_count="2" nb_element="cell_code"> + <container classes="cell_input" nb_element="cell_code_source"> + <literal_block language="ipython3" xml:space="preserve"> + import numpy as np + import matplotlib.pyplot as plt + + # Fixing random state for reproducibility + np.random.seed(19680801) + + dt = 0.01 + t = np.arange(0, 30, dt) + nse1 = np.random.randn(len(t)) # white noise 1 + nse2 = np.random.randn(len(t)) # white noise 2 + + # Two signals with a coherent part at 10Hz and a random part + s1 = np.sin(2 * np.pi * 10 * t) + nse1 + s2 = np.sin(2 * np.pi * 10 * t) + nse2 + + fig, axs = plt.subplots(2, 1) + axs[0].plot(t, s1, t, s2) + axs[0].set_xlim(0, 2) + axs[0].set_xlabel('time') + axs[0].set_ylabel('s1 and s2') + axs[0].grid(True) + + cxy, f = axs[1].cohere(s1, s2, NFFT=256, Fs=1. / dt) + axs[1].set_ylabel('coherence') + + fig.tight_layout() + plt.show() + <container classes="cell_output" nb_element="cell_code_output"> + <container nb_element="mime_bundle"> + <container mime_type="text/plain"> + <literal_block classes="output text_plain" language="myst-ansi" xml:space="preserve"> + <Figure size 640x480 with 2 Axes> + <container mime_type="image/png"> + <image candidates="{'*': '_build/jupyter_execute/IMAGEHASH.png'}" uri="_build/jupyter_execute/IMAGEHASH.png"> + <paragraph> + With some follow up text to the solution + <section ids="references" names="references"> + <title> + References + <paragraph> + This is a reference to + <pending_xref refdoc="solution-exercise" refdomain="std" refexplicit="False" reftarget="solution-gated-1" reftype="ref" refwarn="True"> + <inline classes="xref std std-ref"> + solution-gated-1 + <paragraph> + This is a reference to + <pending_xref refdoc="solution-exercise" refdomain="std" refexplicit="False" reftarget="solution-gated-2" reftype="ref" refwarn="True"> + <inline classes="xref std std-ref"> + solution-gated-2 diff --git a/tests/test_latex/test_latex_build.sphinx6.tex b/tests/test_latex/test_latex_build.sphinx6.tex new file mode 100644 index 0000000..e9f1510 --- /dev/null +++ b/tests/test_latex/test_latex_build.sphinx6.tex @@ -0,0 +1,181 @@ +\begin{document} + +\ifdefined\shorthandoff + \ifnum\catcode`\=\string=\active\shorthandoff{=}\fi + \ifnum\catcode`\"=\active\shorthandoff{"}\fi +\fi + +\pagestyle{empty} +\sphinxmaketitle +\pagestyle{plain} +\sphinxtableofcontents +\pagestyle{normal} +\phantomsection\label{\detokenize{index::doc}} + + +\sphinxstepscope + + +\chapter{Exercise} +\label{\detokenize{exercise:exercise}}\label{\detokenize{exercise::doc}} +\sphinxAtStartPar +A collection of exercise directives +\phantomsection \label{exercise:exercise-1} + +\begin{sphinxadmonition}{note}{Exercise 1 (\protect\(n!\protect\) factorial)} + + + +\sphinxAtStartPar +Exercise 1 about \(n!\) factorial +\end{sphinxadmonition} +\phantomsection \label{exercise:exercise-2} +\begin{sphinxadmonition}{note}{Exercise (\protect\(n!\protect\) factorial)} + + + +\sphinxAtStartPar +Exercise 2 about \(n!\) factorial +\end{sphinxadmonition} +\phantomsection \label{exercise:exercise-3} + +\begin{sphinxadmonition}{note}{Exercise 2} + + + +\sphinxAtStartPar +Exercise 3 Content with Number +\end{sphinxadmonition} +\phantomsection \label{exercise:exercise-4} +\begin{sphinxadmonition}{note}{Exercise} + + + +\sphinxAtStartPar +Exercise 4 Content with no Number +\end{sphinxadmonition} + + +\section{References} +\label{\detokenize{exercise:references}} + +\subsection{Standard References} +\label{\detokenize{exercise:standard-references}} +\sphinxAtStartPar +This is a link to \DUrole{xref,std,std-ref}{exercise\sphinxhyphen{}no\sphinxhyphen{}title} + +\sphinxAtStartPar +This is a link to \hyperref[exercise:exercise-1]{Exercise 1} + +\sphinxAtStartPar +This is a link to {\hyperref[\detokenize{exercise:exercise-2}]{\sphinxcrossref{\DUrole{std,std-ref}{Exercise}}}} + +\sphinxAtStartPar +This ia another link with custom text \hyperref[exercise:exercise-3]{Exercise 3 Custom Text} + +\sphinxAtStartPar +This ia another link with custom text {\hyperref[\detokenize{exercise:exercise-4}]{\sphinxcrossref{\DUrole{std,std-ref}{Exercise 4 Custom Text}}}} + + +\subsection{Numbered References} +\label{\detokenize{exercise:numbered-references}} +\sphinxAtStartPar +This is a numbered reference to \hyperref[exercise:exercise-1]{Exercise 1} + +\sphinxAtStartPar +This is a numbered reference to \sphinxcode{\sphinxupquote{exercise\sphinxhyphen{}2}} and should be broken as exercise 2 is not an +enumerated exercise node. + +\sphinxAtStartPar +This is a numbered reference to \hyperref[exercise:exercise-3]{Exercise 2} + +\sphinxAtStartPar +This is a numbered reference with custom text to \hyperref[exercise:exercise-3]{Custom Text with a Number 2} + +\sphinxAtStartPar +This is a numbered reference to \sphinxcode{\sphinxupquote{exercise\sphinxhyphen{}4}} and should be broken as exercise 2 is not an +enumerated exercise node. + +\sphinxAtStartPar +This is a numbered reference with custom text to \sphinxcode{\sphinxupquote{Custom Text with a Number \{number\}}} and should be broken as exercise 2 is not an +enumerated exercise node. + +\sphinxstepscope + + +\chapter{Solution} +\label{\detokenize{solution:solution}}\label{\detokenize{solution::doc}} +\sphinxAtStartPar +A collection of solution directives +\phantomsection \label{solution:solution-1} + +\begin{sphinxadmonition}{note}{Solution to Exercise 1 (\protect\(n!\protect\) factorial)} + + + +\sphinxAtStartPar +This is a solution to exercise 1 +\end{sphinxadmonition} +\phantomsection \label{solution:solution-2} + +\begin{sphinxadmonition}{note}{Solution to Exercise (\protect\(n!\protect\) factorial)} + + + +\sphinxAtStartPar +This is a solution to exercise 2 +\end{sphinxadmonition} +\phantomsection \label{solution:solution-3} + +\begin{sphinxadmonition}{note}{Solution to Exercise 2} + + + +\sphinxAtStartPar +This is a solution to exercise 3 +\end{sphinxadmonition} +\phantomsection \label{solution:solution-4} + +\begin{sphinxadmonition}{note}{Solution to Exercise} + + + +\sphinxAtStartPar +This is a solution to exercise 4 +\end{sphinxadmonition} + + +\section{References} +\label{\detokenize{solution:references}} + +\subsection{Standard References} +\label{\detokenize{solution:standard-references}} +\sphinxAtStartPar +This is a link to {\hyperref[\detokenize{solution:solution-1}]{\sphinxcrossref{\DUrole{std,std-ref}{Solution to Exercise 1 (n! factorial)}}}} + +\sphinxAtStartPar +This is a link to {\hyperref[\detokenize{solution:solution-2}]{\sphinxcrossref{\DUrole{std,std-ref}{Solution to Exercise (n! factorial)}}}} + +\sphinxAtStartPar +This is a link to {\hyperref[\detokenize{solution:solution-3}]{\sphinxcrossref{\DUrole{std,std-ref}{Solution to Exercise 2}}}} + +\sphinxAtStartPar +This is a link to {\hyperref[\detokenize{solution:solution-4}]{\sphinxcrossref{\DUrole{std,std-ref}{Solution to Exercise}}}} + +\sphinxAtStartPar +This ia another link to a different {\hyperref[\detokenize{solution:solution-1}]{\sphinxcrossref{\DUrole{std,std-ref}{Solution to Exercise 1 (n! factorial)}}}} + + +\subsection{Numbered References} +\label{\detokenize{solution:numbered-references}} +\sphinxAtStartPar +Solution nodes are not enumerated nodes so these won’t work + +\sphinxAtStartPar +This is a link to \sphinxcode{\sphinxupquote{solution\sphinxhyphen{}1}} + + + +\renewcommand{\indexname}{Index} +\printindex +\end{document} diff --git a/tests/test_solution/_linked_duplicate_label.sphinx6.xml b/tests/test_solution/_linked_duplicate_label.sphinx6.xml new file mode 100644 index 0000000..911fa54 --- /dev/null +++ b/tests/test_solution/_linked_duplicate_label.sphinx6.xml @@ -0,0 +1,10 @@ +<document source="_linked_duplicate_label.rst"> + <section ids="linked-duplicate-label" names="_linked_duplicate_label"> + <title> + _linked_duplicate_label + <solution_node classes="solution" docname="solution/_linked_duplicate_label" hidden="False" ids="sol-duplicate-label" label="sol-duplicate-label" names="sol-duplicate-label" serial_number="0" target_label="ex-nonumber-notitle" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_enum.sphinx6.xml b/tests/test_solution/_linked_enum.sphinx6.xml new file mode 100644 index 0000000..272bd7f --- /dev/null +++ b/tests/test_solution/_linked_enum.sphinx6.xml @@ -0,0 +1,29 @@ +<document source="_linked_enum.rst"> + <section ids="linked-enum" names="_linked_enum"> + <title> + _linked_enum + <exercise_enumerable_node classes="exercise" docname="solution/_linked_enum" hidden="False" ids="ex-number" label="ex-number" names="ex-number" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_enum" hidden="False" ids="sol-number" label="sol-number" names="sol-number" serial_number="1" target_label="ex-number" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <math_block docname="solution/_linked_enum" label="True" nowrap="False" number="True" xml:space="preserve"> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <target refid="equation-ex-math"> + <math_block docname="solution/_linked_enum" ids="equation-ex-math" label="ex-math" nowrap="False" number="1" xml:space="preserve"> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) diff --git a/tests/test_solution/_linked_enum_class.sphinx6.xml b/tests/test_solution/_linked_enum_class.sphinx6.xml new file mode 100644 index 0000000..daa32c8 --- /dev/null +++ b/tests/test_solution/_linked_enum_class.sphinx6.xml @@ -0,0 +1,10 @@ +<document source="_linked_enum_class.rst"> + <section ids="linked-enum-class" names="_linked_enum_class"> + <title> + _linked_enum_class + <solution_node classes="solution test-solution" docname="solution/_linked_enum_class" hidden="False" ids="solution-label" label="solution-label" names="solution-label" serial_number="0" target_label="ex-number" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_missing_arg.sphinx6.xml b/tests/test_solution/_linked_missing_arg.sphinx6.xml new file mode 100644 index 0000000..6ecb8d7 --- /dev/null +++ b/tests/test_solution/_linked_missing_arg.sphinx6.xml @@ -0,0 +1,4 @@ +<document source="_linked_missing_arg.rst"> + <section ids="linked-missing-arg" names="_linked_missing_arg"> + <title> + _linked_missing_arg diff --git a/tests/test_solution/_linked_unenum_mathtitle.sphinx6.xml b/tests/test_solution/_linked_unenum_mathtitle.sphinx6.xml new file mode 100644 index 0000000..d5c931a --- /dev/null +++ b/tests/test_solution/_linked_unenum_mathtitle.sphinx6.xml @@ -0,0 +1,24 @@ +<document source="_linked_unenum_mathtitle.rst"> + <section ids="linked-unenum-mathtitle" names="_linked_unenum_mathtitle"> + <title> + _linked_unenum_mathtitle + <exercise_node classes="exercise" docname="solution/_linked_unenum_mathtitle" hidden="False" ids="ex-nonumber-title-math" label="ex-nonumber-title-math" names="ex-nonumber-title-math" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <math> + \mathbb{R} + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_mathtitle" hidden="False" ids="sol-nonumber-title-math" label="sol-nonumber-title-math" names="sol-nonumber-title-math" serial_number="1" target_label="ex-nonumber-title-math" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_unenum_mathtitle2.sphinx6.xml b/tests/test_solution/_linked_unenum_mathtitle2.sphinx6.xml new file mode 100644 index 0000000..a369002 --- /dev/null +++ b/tests/test_solution/_linked_unenum_mathtitle2.sphinx6.xml @@ -0,0 +1,24 @@ +<document source="_linked_unenum_mathtitle2.rst"> + <section ids="linked-unenum-mathtitle2" names="_linked_unenum_mathtitle2"> + <title> + _linked_unenum_mathtitle2 + <exercise_node classes="exercise" docname="solution/_linked_unenum_mathtitle2" hidden="False" ids="ex-nonumber-title-math2" label="ex-nonumber-title-math2" names="ex-nonumber-title-math2" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <math> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_mathtitle2" hidden="False" ids="sol-nonumber-title-math2" label="sol-nonumber-title-math2" names="sol-nonumber-title-math2" serial_number="1" target_label="ex-nonumber-title-math2" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_unenum_notitle.sphinx6.xml b/tests/test_solution/_linked_unenum_notitle.sphinx6.xml new file mode 100644 index 0000000..8140aec --- /dev/null +++ b/tests/test_solution/_linked_unenum_notitle.sphinx6.xml @@ -0,0 +1,20 @@ +<document source="_linked_unenum_notitle.rst"> + <section ids="linked-unenum-notitle" names="_linked_unenum_notitle"> + <title> + _linked_unenum_notitle + <exercise_node classes="exercise" docname="solution/_linked_unenum_notitle" hidden="False" ids="ex-nonumber-notitle" label="ex-nonumber-notitle" names="ex-nonumber-notitle" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_notitle" hidden="False" ids="sol-nonumber-notitle" label="sol-nonumber-notitle" names="sol-nonumber-notitle" serial_number="1" target_label="ex-nonumber-notitle" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_unenum_title.sphinx6.xml b/tests/test_solution/_linked_unenum_title.sphinx6.xml new file mode 100644 index 0000000..da1dc3f --- /dev/null +++ b/tests/test_solution/_linked_unenum_title.sphinx6.xml @@ -0,0 +1,22 @@ +<document source="_linked_unenum_title.rst"> + <section ids="linked-unenum-title" names="_linked_unenum_title"> + <title> + _linked_unenum_title + <exercise_node classes="exercise" docname="solution/_linked_unenum_title" hidden="False" ids="ex-nonumber-title" label="ex-nonumber-title" names="ex-nonumber-title" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_title" hidden="False" ids="sol-nonumber-title" label="sol-nonumber-title" names="sol-nonumber-title" serial_number="1" target_label="ex-nonumber-title" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/_linked_wrong_targetlabel.sphinx6.xml b/tests/test_solution/_linked_wrong_targetlabel.sphinx6.xml new file mode 100644 index 0000000..b03b9ac --- /dev/null +++ b/tests/test_solution/_linked_wrong_targetlabel.sphinx6.xml @@ -0,0 +1,10 @@ +<document source="_linked_wrong_targetlabel.rst"> + <section ids="linked-wrong-targetlabel" names="_linked_wrong_targetlabel"> + <title> + _linked_wrong_targetlabel + <solution_node classes="solution" docname="solution/_linked_wrong_targetlabel" hidden="False" ids="solution/_linked_wrong_targetlabel-solution-0" label="solution/_linked_wrong_targetlabel-solution-0" names="solution/_linked_wrong_targetlabel-solution-0" serial_number="0" target_label="wrong-ex-label" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_duplicate_label.sphinx6.xml b/tests/test_solution/solution/_linked_duplicate_label.sphinx6.xml new file mode 100644 index 0000000..911fa54 --- /dev/null +++ b/tests/test_solution/solution/_linked_duplicate_label.sphinx6.xml @@ -0,0 +1,10 @@ +<document source="_linked_duplicate_label.rst"> + <section ids="linked-duplicate-label" names="_linked_duplicate_label"> + <title> + _linked_duplicate_label + <solution_node classes="solution" docname="solution/_linked_duplicate_label" hidden="False" ids="sol-duplicate-label" label="sol-duplicate-label" names="sol-duplicate-label" serial_number="0" target_label="ex-nonumber-notitle" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_enum.sphinx6.xml b/tests/test_solution/solution/_linked_enum.sphinx6.xml new file mode 100644 index 0000000..272bd7f --- /dev/null +++ b/tests/test_solution/solution/_linked_enum.sphinx6.xml @@ -0,0 +1,29 @@ +<document source="_linked_enum.rst"> + <section ids="linked-enum" names="_linked_enum"> + <title> + _linked_enum + <exercise_enumerable_node classes="exercise" docname="solution/_linked_enum" hidden="False" ids="ex-number" label="ex-number" names="ex-number" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_enum" hidden="False" ids="sol-number" label="sol-number" names="sol-number" serial_number="1" target_label="ex-number" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <math_block docname="solution/_linked_enum" label="True" nowrap="False" number="True" xml:space="preserve"> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <target refid="equation-ex-math"> + <math_block docname="solution/_linked_enum" ids="equation-ex-math" label="ex-math" nowrap="False" number="1" xml:space="preserve"> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) diff --git a/tests/test_solution/solution/_linked_enum_class.sphinx6.xml b/tests/test_solution/solution/_linked_enum_class.sphinx6.xml new file mode 100644 index 0000000..daa32c8 --- /dev/null +++ b/tests/test_solution/solution/_linked_enum_class.sphinx6.xml @@ -0,0 +1,10 @@ +<document source="_linked_enum_class.rst"> + <section ids="linked-enum-class" names="_linked_enum_class"> + <title> + _linked_enum_class + <solution_node classes="solution test-solution" docname="solution/_linked_enum_class" hidden="False" ids="solution-label" label="solution-label" names="solution-label" serial_number="0" target_label="ex-number" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_missing_arg.sphinx6.xml b/tests/test_solution/solution/_linked_missing_arg.sphinx6.xml new file mode 100644 index 0000000..6ecb8d7 --- /dev/null +++ b/tests/test_solution/solution/_linked_missing_arg.sphinx6.xml @@ -0,0 +1,4 @@ +<document source="_linked_missing_arg.rst"> + <section ids="linked-missing-arg" names="_linked_missing_arg"> + <title> + _linked_missing_arg diff --git a/tests/test_solution/solution/_linked_unenum_mathtitle.sphinx6.xml b/tests/test_solution/solution/_linked_unenum_mathtitle.sphinx6.xml new file mode 100644 index 0000000..d5c931a --- /dev/null +++ b/tests/test_solution/solution/_linked_unenum_mathtitle.sphinx6.xml @@ -0,0 +1,24 @@ +<document source="_linked_unenum_mathtitle.rst"> + <section ids="linked-unenum-mathtitle" names="_linked_unenum_mathtitle"> + <title> + _linked_unenum_mathtitle + <exercise_node classes="exercise" docname="solution/_linked_unenum_mathtitle" hidden="False" ids="ex-nonumber-title-math" label="ex-nonumber-title-math" names="ex-nonumber-title-math" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <math> + \mathbb{R} + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_mathtitle" hidden="False" ids="sol-nonumber-title-math" label="sol-nonumber-title-math" names="sol-nonumber-title-math" serial_number="1" target_label="ex-nonumber-title-math" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_unenum_mathtitle2.sphinx6.xml b/tests/test_solution/solution/_linked_unenum_mathtitle2.sphinx6.xml new file mode 100644 index 0000000..a369002 --- /dev/null +++ b/tests/test_solution/solution/_linked_unenum_mathtitle2.sphinx6.xml @@ -0,0 +1,24 @@ +<document source="_linked_unenum_mathtitle2.rst"> + <section ids="linked-unenum-mathtitle2" names="_linked_unenum_mathtitle2"> + <title> + _linked_unenum_mathtitle2 + <exercise_node classes="exercise" docname="solution/_linked_unenum_mathtitle2" hidden="False" ids="ex-nonumber-title-math2" label="ex-nonumber-title-math2" names="ex-nonumber-title-math2" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <math> + P_t(x, y) = \mathbb 1\{x = y\} + t Q(x, y) + o(t) + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_mathtitle2" hidden="False" ids="sol-nonumber-title-math2" label="sol-nonumber-title-math2" names="sol-nonumber-title-math2" serial_number="1" target_label="ex-nonumber-title-math2" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_unenum_notitle.sphinx6.xml b/tests/test_solution/solution/_linked_unenum_notitle.sphinx6.xml new file mode 100644 index 0000000..8140aec --- /dev/null +++ b/tests/test_solution/solution/_linked_unenum_notitle.sphinx6.xml @@ -0,0 +1,20 @@ +<document source="_linked_unenum_notitle.rst"> + <section ids="linked-unenum-notitle" names="_linked_unenum_notitle"> + <title> + _linked_unenum_notitle + <exercise_node classes="exercise" docname="solution/_linked_unenum_notitle" hidden="False" ids="ex-nonumber-notitle" label="ex-nonumber-notitle" names="ex-nonumber-notitle" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_notitle" hidden="False" ids="sol-nonumber-notitle" label="sol-nonumber-notitle" names="sol-nonumber-notitle" serial_number="1" target_label="ex-nonumber-notitle" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_unenum_title.sphinx6.xml b/tests/test_solution/solution/_linked_unenum_title.sphinx6.xml new file mode 100644 index 0000000..da1dc3f --- /dev/null +++ b/tests/test_solution/solution/_linked_unenum_title.sphinx6.xml @@ -0,0 +1,22 @@ +<document source="_linked_unenum_title.rst"> + <section ids="linked-unenum-title" names="_linked_unenum_title"> + <title> + _linked_unenum_title + <exercise_node classes="exercise" docname="solution/_linked_unenum_title" hidden="False" ids="ex-nonumber-title" label="ex-nonumber-title" names="ex-nonumber-title" serial_number="0" title="Exercise" type="exercise"> + <exercise_title> + Exercise + <exercise_subtitle> + This is a title + <section ids="exercise-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + <paragraph> + Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + <paragraph> + Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + <solution_node classes="solution" docname="solution/_linked_unenum_title" hidden="False" ids="sol-nonumber-title" label="sol-nonumber-title" names="sol-nonumber-title" serial_number="1" target_label="ex-nonumber-title" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution/solution/_linked_wrong_targetlabel.sphinx6.xml b/tests/test_solution/solution/_linked_wrong_targetlabel.sphinx6.xml new file mode 100644 index 0000000..b03b9ac --- /dev/null +++ b/tests/test_solution/solution/_linked_wrong_targetlabel.sphinx6.xml @@ -0,0 +1,10 @@ +<document source="_linked_wrong_targetlabel.rst"> + <section ids="linked-wrong-targetlabel" names="_linked_wrong_targetlabel"> + <title> + _linked_wrong_targetlabel + <solution_node classes="solution" docname="solution/_linked_wrong_targetlabel" hidden="False" ids="solution/_linked_wrong_targetlabel-solution-0" label="solution/_linked_wrong_targetlabel-solution-0" names="solution/_linked_wrong_targetlabel-solution-0" serial_number="0" target_label="wrong-ex-label" title="Solution to" type="solution"> + <solution_title> + Solution to + <section ids="solution-content"> + <paragraph> + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. diff --git a/tests/test_solution_references/_linked_ref_enum.sphinx6.html b/tests/test_solution_references/_linked_ref_enum.sphinx6.html new file mode 100644 index 0000000..447ca24 --- /dev/null +++ b/tests/test_solution_references/_linked_ref_enum.sphinx6.html @@ -0,0 +1,2 @@ +<p>referencing: <a class="reference internal" href="_linked_enum.html#sol-number"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_enum.html#sol-number"><span class="std std-ref">simple solution with number</span></a>.</p> \ No newline at end of file diff --git a/tests/test_solution_references/_linked_ref_unenum_mathtitle.sphinx6.html b/tests/test_solution_references/_linked_ref_unenum_mathtitle.sphinx6.html new file mode 100644 index 0000000..4c295c2 --- /dev/null +++ b/tests/test_solution_references/_linked_ref_unenum_mathtitle.sphinx6.html @@ -0,0 +1,2 @@ +<p>referencing: <a class="reference internal" href="_linked_unenum_mathtitle.html#sol-nonumber-title-math"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_unenum_mathtitle.html#sol-nonumber-title-math"><span class="std std-ref">exercise with nonumber but with inline math title</span></a>.</p> \ No newline at end of file diff --git a/tests/test_solution_references/_linked_ref_unenum_mathtitle2.sphinx6.html b/tests/test_solution_references/_linked_ref_unenum_mathtitle2.sphinx6.html new file mode 100644 index 0000000..cfb2b50 --- /dev/null +++ b/tests/test_solution_references/_linked_ref_unenum_mathtitle2.sphinx6.html @@ -0,0 +1,2 @@ +<p>referencing: <a class="reference internal" href="_linked_unenum_mathtitle2.html#sol-nonumber-title-math2"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_unenum_mathtitle2.html#sol-nonumber-title-math2"><span class="std std-ref">exercise with nonumber but with inline math title ex2</span></a>.</p> \ No newline at end of file diff --git a/tests/test_solution_references/_linked_ref_unenum_notitle.sphinx6.html b/tests/test_solution_references/_linked_ref_unenum_notitle.sphinx6.html new file mode 100644 index 0000000..8e3dc3c --- /dev/null +++ b/tests/test_solution_references/_linked_ref_unenum_notitle.sphinx6.html @@ -0,0 +1,2 @@ +<p>referencing: <a class="reference internal" href="_linked_unenum_notitle.html#sol-nonumber-notitle"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_unenum_notitle.html#sol-nonumber-notitle"><span class="std std-ref">ex with nonumber and notitle</span></a>.</p> \ No newline at end of file diff --git a/tests/test_solution_references/_linked_ref_unenum_title.sphinx6.html b/tests/test_solution_references/_linked_ref_unenum_title.sphinx6.html new file mode 100644 index 0000000..62de13e --- /dev/null +++ b/tests/test_solution_references/_linked_ref_unenum_title.sphinx6.html @@ -0,0 +1,2 @@ +<p>referencing: <a class="reference internal" href="_linked_unenum_title.html#sol-nonumber-title"><span class="std std-ref">Solution to</span></a>.</p> +<p>referencing: <a class="reference internal" href="_linked_unenum_title.html#sol-nonumber-title"><span class="std std-ref">exercise with nonumber but with title</span></a>.</p> \ No newline at end of file From 4d3db760a48c66a979672376a133e274abb8b36d Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Wed, 22 Oct 2025 12:59:21 +1100 Subject: [PATCH 15/16] Replace os.path.splitext with pathlib.Path for consistency Use pathlib.Path.with_suffix('') instead of os.path.splitext()[0] for better consistency with modern Python practices. This removes the os import which was only used for this single operation. --- sphinx_exercise/directive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx_exercise/directive.py b/sphinx_exercise/directive.py index ac83c36..0302c65 100644 --- a/sphinx_exercise/directive.py +++ b/sphinx_exercise/directive.py @@ -8,7 +8,7 @@ :licences: see LICENSE for details """ -import os +from pathlib import Path from typing import List from docutils import nodes @@ -42,7 +42,7 @@ def duplicate_labels(self, label): if not label == "" and label in self.env.sphinx_exercise_registry.keys(): docpath = self.env.doc2path(self.env.docname) - path = os.path.splitext(docpath)[0] + path = str(Path(docpath).with_suffix("")) other_path = self.env.doc2path( self.env.sphinx_exercise_registry[label]["docname"] ) From 4a711c577262c4d67a90fdf5ed0bc0c51574550c Mon Sep 17 00:00:00 2001 From: mmcky <mamckay@gmail.com> Date: Wed, 22 Oct 2025 13:09:33 +1100 Subject: [PATCH 16/16] Replace remaining os.path usage with pathlib across codebase Modernize all remaining os.path operations to use pathlib.Path for consistency: - sphinx_exercise/__init__.py: Use Path for package/locale directory - sphinx_exercise/post_transforms.py: Use Path.with_suffix('') - sphinx_exercise/translations/_convert.py: Use Path.resolve() This completes the migration to pathlib throughout the codebase, keeping only os.sep in tests where it's appropriate for path separator normalization. --- sphinx_exercise/__init__.py | 7 +++---- sphinx_exercise/post_transforms.py | 5 +++-- sphinx_exercise/translations/_convert.py | 5 ++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/sphinx_exercise/__init__.py b/sphinx_exercise/__init__.py index c7bf3dc..837a3b4 100644 --- a/sphinx_exercise/__init__.py +++ b/sphinx_exercise/__init__.py @@ -9,7 +9,6 @@ __version__ = "1.0.1" -import os from pathlib import Path from typing import Any, Dict, Set, Union, cast from sphinx.config import Config @@ -215,9 +214,9 @@ def setup(app: Sphinx) -> Dict[str, Any]: app.add_css_file("exercise.css") # add translations - package_dir = os.path.abspath(os.path.dirname(__file__)) - locale_dir = os.path.join(package_dir, "translations", "locales") - app.add_message_catalog(MESSAGE_CATALOG_NAME, locale_dir) + package_dir = Path(__file__).parent.resolve() + locale_dir = package_dir / "translations" / "locales" + app.add_message_catalog(MESSAGE_CATALOG_NAME, str(locale_dir)) return { "version": "builtin", diff --git a/sphinx_exercise/post_transforms.py b/sphinx_exercise/post_transforms.py index 75063fc..97b79d7 100644 --- a/sphinx_exercise/post_transforms.py +++ b/sphinx_exercise/post_transforms.py @@ -1,4 +1,5 @@ -import os +from pathlib import Path + import sphinx.addnodes as sphinx_nodes from sphinx.transforms.post_transforms import SphinxPostTransform from sphinx.util import logging @@ -196,7 +197,7 @@ def run(self): except AttributeError: docname = self.env.docname # for builder such as JupyterBuilder that don't support current_docname docpath = self.env.doc2path(docname) - path = os.path.splitext(docpath)[0] + path = str(Path(docpath).with_suffix("")) msg = f"undefined label: {target_label}" logger.warning(msg, location=path, color="red") return diff --git a/sphinx_exercise/translations/_convert.py b/sphinx_exercise/translations/_convert.py index d9943b2..dc88dd9 100644 --- a/sphinx_exercise/translations/_convert.py +++ b/sphinx_exercise/translations/_convert.py @@ -1,5 +1,4 @@ import json -import os from pathlib import Path import subprocess @@ -54,9 +53,9 @@ def convert_json(folder=None): subprocess.check_call( [ "msgfmt", - os.path.abspath(path), + str(path.resolve()), "-o", - os.path.abspath(path.parent / f"{MESSAGE_CATALOG_NAME}.mo"), + str((path.parent / f"{MESSAGE_CATALOG_NAME}.mo").resolve()), ] )