Skip to content

Add doctest examples to the public SCS API and run them in CI - #243

Closed
tschm wants to merge 1 commit into
bodono:masterfrom
tschm:fix/240-doctests
Closed

tschm wants to merge 1 commit into
bodono:masterfrom
tschm:fix/240-doctests

Conversation

@tschm

@tschm tschm commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Closes #240

Every public symbol carried prose documentation but zero runnable examples, so nothing verified that what the docstrings claim is still true — the failure mode where a docstring keeps rendering perfectly long after the behaviour beneath it changed.

33 examples added:

Symbol Examples
LinearSolver 3
SCS (new class docstring) 6
SCS.solve 9
SCS.update 8
solve (legacy) 7

Each is self-contained and deterministic — tight eps_abs/eps_rel, verbose=False, values rounded before printing — so they run standalone rather than depending on an earlier example's state.

This also fills two gaps in the same file: SCS had no class docstring at all, and the public legacy solve() had only a # comment above it rather than a docstring.

test/test_doctests.py runs them against the installed package (what users import) and asserts attempted > 0 as well as failed == 0, so a module that silently loses its examples fails rather than passes. I negative-tested that guard: injecting a wrong expected value gives attempted: 31 failed: 1.

The test takes capsys, which pytest-run-parallel auto-detects as thread-unsafe, so it serialises correctly under the free-threading job's --parallel-threads=4.

Full suite after the change: 397 passed, 67 skipped.

🤖 Generated with Claude Code

The package carried prose docstrings on every public symbol but zero runnable
examples, so nothing verified that what they claim is still true — the failure
mode where a docstring keeps rendering perfectly after the behaviour beneath it
changes.

33 examples across `LinearSolver`, `SCS`, `SCS.solve`, `SCS.update` and the
legacy `solve()`. Each is self-contained and deterministic: tight eps_abs/eps_rel,
verbose=False, values rounded before printing.

Also fills two gaps in the same file: `SCS` had no class docstring, and the
public legacy `solve()` had only a `#` comment above it.

`test/test_doctests.py` runs them against the installed package and asserts
`attempted > 0` as well as `failed == 0`, so a module that silently loses its
examples fails rather than passes.

Closes bodono#240

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@bodono

bodono commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Thanks for the work, but as noted on #240 we're not adding doctests to the docstrings or a doctest job to CI. Closing.

@bodono bodono closed this Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add doctest examples to the public SCS API (0 runnable examples today)

2 participants