Skip to content

Add library usage tutorials in docs - #30

Merged
rahulsavani merged 11 commits into
gambitproject:mainfrom
nataliemes:docs/tutorials
Oct 24, 2026
Merged

rahulsavani merged 11 commits into
gambitproject:mainfrom
nataliemes:docs/tutorials

Conversation

@nataliemes

@nataliemes nataliemes commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Main changes

#26 mentioned two separate pages: getting started (tutorials) and worked examples, but since they had overlapping content, I decided to make one dedicated place for tutorials. There are three new tutorial pages for:

  1. solving LCPs,
  2. finding equilibria for bimatrix games,
  3. visualizing random priors on a simplex (randomstart module).

You can view them here.

Also, I thought the CLI examples should be included in the CLI page (which I will add shortly), therefore these tutorials show only the library usage examples.

Let me know if you think another way of organizing examples/tutorials is better.

Other related changes

  • Since some doctests were failing due to the difference in trailing whitespaces, columnprint.py was updated to strip the whitespaces at the end of the strings.
  • In lemke.py, the PrintingCallback constructor used stream=sys.stdout as a default argument. Python evaluates defaults once at definition time, so the callback kept a reference to the original stdout from import time. Anything that later replaced sys.stdout (like doctest) was silently bypassed, so the output reached the real console but was not captured, therefore doctests saw empty output.
    The default was changed to None and sys.stdout is resolved when the stream is used (so the current sys.stdout is respected).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Default doctest collection includes API examples with missing input files, causing the doctest build to fail.

4 open issues
What changed in this PR

Adds library-focused tutorials alongside the API documentation, covering LCP solving, bimatrix equilibria, and random-prior visualization.

Changes:

  • Adds three tutorials and documentation navigation.
  • Enables doctests and embedded plots.
  • Adjusts output formatting and callback stream initialization.
File Description
src/​lemke/​lemke.py Resolves default stdout when constructing callbacks.
src/​lemke/​columnprint.py Removes trailing output whitespace.
examples/​lcp_2x2 Adds tutorial input data.
doc/​tutorials/​randomstart.rst Explains simplex sampling and visualization.
doc/​tutorials/​lcp.rst Demonstrates solving LCPs and using callbacks.
doc/​tutorials/​index.rst Organizes tutorial navigation.
doc/​tutorials/​bimatrix.rst Demonstrates equilibrium-finding methods.
doc/​index.rst Links tutorials from the documentation homepage.
doc/​conf.py Enables doctests and configures plots.

Review effort: Balanced

Comment thread doc/conf.py
Comment thread doc/tutorials/bimatrix.rst Outdated
Comment thread doc/tutorials/lcp.rst Outdated
Comment thread doc/tutorials/lcp.rst Outdated

@rahulsavani rahulsavani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this looks good to me, just a few thing copilot picked up to deal with.

nataliemes and others added 4 commits October 23, 2026 20:19
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
# Conflicts:
#	doc/index.rst

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Only a minor documented-output mismatch remains, with no blocking issues identified.

1 open issue
4 resolved since last review

Review effort: Balanced

Comment thread doc/tutorials/randomstart.rst Outdated
rahulsavani and others added 2 commits October 24, 2026 10:25
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@rahulsavani rahulsavani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I just made one minor edit.

@rahulsavani
rahulsavani merged commit 95732d6 into gambitproject:main Oct 24, 2026
9 checks passed
@nataliemes
nataliemes deleted the docs/tutorials branch October 24, 2026 13:14
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.

3 participants