Skip to content

Commit 500d8ba

Browse files
Refresh PyGambit user guide and add interactive Jupyter notebook option (#556)
* add new logo * add headers and link * Add livehtml target to Makefile and update build instructions for live server when doing local development to docs * tidy navbar * downgrade Ipython to support current docs build process and add matplotlib * simplify docs landing page * Add external links and icon links to the HTML theme configuration * Update PyGambit documentation for clarity and installation instructions * reorder so pygambit first * add link to older releases * remove download section * move bug reports section * Update developer section to clarify team contributions and provide a link to the team page * pygambit before tools * refactor history section to the bottom * remove empty quickstart doc * add links to docs and site on README * developer docs section * update toc with developer section * add version number to bug report template * add operating system dropdown to bug report template * move issues section to top * add contributing code guidelines to documentation * update requirements.txt to specify package versions * ignore 'doc/**' and '.github/ISSUE_TEMPLATE/**' paths in all workflows * also dont run on README.md changes * Update Python version to 3.11 in Read the Docs configuration * add revised logo * neat centred logo and title * update ipython and jupyter * restore old logo * initial notebook * better game setup * calculate equilibria * use player names and strategy names instead of indices * explain strategy profiles and payoffs * tidy * add how to create a game from arrays * add extensive form example start text * add trust game existing content * explicit API calls * finish equilibrium explanation with TODO questions * rename notebook * initial poker setup with information sets * add outcomes and assign to nodes * explain the outcomes better * rename * move trust game into new notebook * read and save games * explain extensive and normal form game distinction * demo saving efg * add to_arrays * explain labels * remove todos * full notebook content * remove equilibrium computation from this example * reference links * some notes added to the part before computing equlibria * better explanation * better explanation * explain better * explain better * explain belief * explain realiz_prob and node_value * rename var * explain strategy payoff better * explain difference between strategy and behaviour profiles * explain strategy and profile classes and subclasses better * compare both methods * intro for Acceptance criteria for Nash equilibria section * commit before stash * maxregret * end of poker example * add section links * clarify section header * add starting points notebook * tutorial assumptions * tutorials purpose * tutorial 4 * add qre notebook * add links * finish t05 * render tutorials * add pandoc to readthedocs config * add pandoc to documentation requirements * fix typos and improve clarity in contributing documentation * tidy notebooks and add subheader * update tutorial section titles * fix headers * separate docs sections * move tutorials onto pygambit homepage * update homepage link to pygambit * reduce user guide to remaining content not in tutorials * add header and link to it for representation of numerical data of a game * move numerical data representation in pygambit to tutorial 03 * restructure to remove original user guide completely * reorder table and add explanation * remove deprecated user guide link * save the new table * update tutorial explainers * correct no of tutorials * fix up algorithm table * break up the PyGambit page appropriately * refine tutorial titles and sections * refactor developer doc * update running_locally tutorial with detailed setup instructions * update tutorial names * take prisoners dilemma out of summary details tags * move import * final save t01 * use reference not link * rerun cells * tidy top markdown * explain better * typo * explain better * typo * indent episilon equilibria text * rerun notebook cells * tidy t4 and t5 * resave nb outputs * use prior_action.label as node labels * use Node.prior_action.label to set node labels * initial tests * remove old userguide tests * organise imports * refactor: simplify kernel shutdown handling in notebook tests * organise imports again * fix: update dependencies in CI workflow to include nbformat, nbclient, and ipykernel * style: fix indentation in docstrings for tutorial notebook tests * fix: skip notebook test on Python 3.9 in CI * just "games" * move how to run up * split tutorials on main page * move advanced tutorials to their own folder * refer to tutorials properly * move external programs doc which currently isnt linked to anywhere and add todo * fix link to advanced tutorials * add text above advanced tutorials list * refactor: enhance tutorial notebook discovery to include advanced tutorials * fix link to nfg file * Add *.so files to .gitignore * remove tutorial games from git * fix tutorial game paths * comment out the save/load lines * update tutorials to use action labels * remove note * use prior action labels for parent nodes too * update test requirements.txt to include notebook dependencies
1 parent f6cdb55 commit 500d8ba

18 files changed

+3416
-925
lines changed

.github/workflows/python.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Set up dependencies
3030
run: |
3131
python -m pip install --upgrade pip
32-
pip install setuptools build cython pytest pytest-skip-slow wheel lxml numpy scipy
32+
pip install setuptools build cython pytest pytest-skip-slow wheel lxml numpy scipy nbformat nbclient ipykernel
3333
- name: Build source distribution
3434
run:
3535
python -m build
@@ -38,7 +38,13 @@ jobs:
3838
cd dist
3939
pip install -v pygambit*.tar.gz
4040
- name: Run tests
41-
run: pytest
41+
run: |
42+
if [ "${{ matrix.python-version }}" = "3.9" ]; then
43+
# Python 3.9 on linux skips the notebook execution test (notebooks may require newer kernels/deps)
44+
pytest -q -k 'not test_execute_notebook'
45+
else
46+
pytest
47+
fi
4248
4349
macos-13:
4450
runs-on: macos-13
@@ -56,7 +62,7 @@ jobs:
5662
- name: Set up dependencies
5763
run: |
5864
python -m pip install --upgrade pip
59-
pip install cython pytest pytest-skip-slow wheel lxml numpy scipy
65+
pip install cython pytest pytest-skip-slow wheel lxml numpy scipy nbformat nbclient ipykernel
6066
- name: Build extension
6167
run: |
6268
python -m pip install -v .
@@ -79,7 +85,7 @@ jobs:
7985
- name: Set up dependencies
8086
run: |
8187
python -m pip install --upgrade pip
82-
pip install cython pytest pytest-skip-slow wheel lxml numpy scipy
88+
pip install cython pytest pytest-skip-slow wheel lxml numpy scipy nbformat nbclient ipykernel
8389
- name: Build extension
8490
run: |
8591
python -m pip install -v .
@@ -102,7 +108,7 @@ jobs:
102108
- name: Set up dependencies
103109
run: |
104110
python -m pip install --upgrade pip
105-
pip install cython pytest pytest-skip-slow wheel lxml numpy scipy
111+
pip install cython pytest pytest-skip-slow wheel lxml numpy scipy nbformat nbclient ipykernel
106112
- name: Build extension
107113
run: |
108114
python -m pip install -v .

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@ gambit
3838
dist
3939
.venv
4040
*.dmg
41-
Gambit.app/*
41+
Gambit.app/*
42+
*.so
43+
doc/tutorials/games/*.nfg
44+
doc/tutorials/games/*.efg

.readthedocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ build:
1111
python: "3.13"
1212
apt_packages:
1313
- libgmp-dev
14+
- pandoc
1415

1516
python:
1617
install:

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"IPython.sphinxext.ipython_console_highlighting",
2727
"IPython.sphinxext.ipython_directive",
2828
"sphinx_design",
29+
"nbsphinx",
2930
]
3031

3132
# IPython directive configuration

doc/developer.contributing.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,21 @@ You can make changes to the documentation by editing the `.rst` files in the ``d
9696
Creating a pull request with your changes will automatically trigger a build of the documentation via the ReadTheDocs service, which can be viewed online.
9797
You can also build the documentation locally to preview your changes before submitting a pull request.
9898

99-
1. Install the docs dependencies (into the virtual environment where you installed PyGambit): ::
99+
1. `Install Pandoc <https://pandoc.org/installing.html>`_ for your OS
100+
101+
2. Install the docs dependencies (into the virtual environment where you installed PyGambit): ::
100102

101103
pip install -r doc/requirements.txt
102104

103-
2. Navigate to the Gambit repo and build the docs: ::
105+
3. Navigate to the Gambit repo and build the docs: ::
104106

105107
cd doc
106108
make html # or make livehtml for live server with auto-rebuild
107109

108-
3. Open ``doc/_build/html/index.html`` in your browser to view the documentation.
110+
4. Open ``doc/_build/html/index.html`` in your browser to view the documentation.
111+
109112

110113

111-
.. TODO: Add instructions for the GitHub workflow during contributor docs refactoring.
112-
See https://github.com/gambitproject/gambit/issues/541
113114

114115
Recognising contributions
115116
-------------------------
@@ -122,4 +123,4 @@ To add a contributor, comment on a GitHub Issue or Pull Request, asking @all-con
122123

123124
@all-contributors please add @<username> for <contributions>
124125

125-
Refer to the `emoji key <https://allcontributors.org/docs/en/emoji-key>`__ for a list of contribution types.
126+
Refer to the `emoji key <https://allcontributors.org/docs/en/emoji-key>`__ for a list of contribution types.

doc/pygambit.rst

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,68 @@ PyGambit
66

77
See installation instructions in the :ref:`install` section.
88

9+
10+
For newcomers to Gambit, we recommend reading through the PyGambit tutorials, which demonstrate the API's key capabilities for analyzing and solving games.
11+
These tutorials are available to be run interactively as Jupyter notebooks, see :ref:`local_tutorials`.
12+
All of the tutorials assume a basic knowledge of programming in Python.
13+
14+
New user tutorials
15+
------------------
16+
17+
These tutorials assume no prior knowledge of Game Theory or the PyGambit API and provide detailed explanations of the concepts and code.
18+
They are numbered in the order they should be read.
19+
20+
.. toctree::
21+
:maxdepth: 2
22+
23+
tutorials/running_locally
24+
tutorials/01_quickstart
25+
tutorials/02_extensive_form
26+
tutorials/03_poker
27+
28+
Advanced user tutorials
29+
-----------------------
30+
31+
These tutorials assume some familiarity with the PyGambit API and Game Theory terminology and concepts including:
32+
33+
- Nash equilibria
34+
- Pure and mixed strategies
35+
- Simplex representations of available strategies
36+
- Logit quantal response equilibrium (LQRE) correspondence
37+
38+
Advanced tutorials:
39+
40+
.. toctree::
41+
:maxdepth: 2
42+
43+
tutorials/advanced_tutorials/starting_points
44+
tutorials/advanced_tutorials/quantal_response
45+
.. pygambit.external_programs
46+
47+
Algorithms for computing Nash equilibria
48+
----------------------------------------
49+
50+
Interfaces to algorithms for computing Nash equilibria are provided in :py:mod:`pygambit.nash`.
51+
The table below summarizes the available PyGambit functions and the corresponding Gambit CLI commands.
52+
53+
========================================== ========================================
54+
CLI command PyGambit function
55+
========================================== ========================================
56+
:ref:`gambit-enumpure <gambit-enumpure>` :py:func:`pygambit.nash.enumpure_solve`
57+
:ref:`gambit-enummixed <gambit-enummixed>` :py:func:`pygambit.nash.enummixed_solve`
58+
:ref:`gambit-lp <gambit-lp>` :py:func:`pygambit.nash.lp_solve`
59+
:ref:`gambit-lcp <gambit-lcp>` :py:func:`pygambit.nash.lcp_solve`
60+
:ref:`gambit-liap <gambit-liap>` :py:func:`pygambit.nash.liap_solve`
61+
:ref:`gambit-logit <gambit-logit>` :py:func:`pygambit.nash.logit_solve`
62+
:ref:`gambit-simpdiv <gambit-simpdiv>` :py:func:`pygambit.nash.simpdiv_solve`
63+
:ref:`gambit-ipa <gambit-ipa>` :py:func:`pygambit.nash.ipa_solve`
64+
:ref:`gambit-gnm <gambit-gnm>` :py:func:`pygambit.nash.gnm_solve`
65+
========================================== ========================================
66+
67+
API documentation
68+
----------------
69+
970
.. toctree::
1071
:maxdepth: 2
1172

12-
pygambit.user
13-
pygambit.api
73+
pygambit.api

0 commit comments

Comments
 (0)