Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
cd dist
sdist=$(ls pygambit-*.tar.gz)
pip install -v "${sdist}[test,doc]"
pip install "draw-tree @ git+https://github.com/gambitproject/draw_tree.git@v0.9.1"
pip install "gtdraw @ git+https://github.com/gambitproject/gtdraw.git@main"
- name: Run tests
run: pytest --run-tutorials

Expand All @@ -53,7 +53,7 @@ jobs:
- name: Build extension
run: |
python -m pip install -v .[test,doc]
pip install "draw-tree @ git+https://github.com/gambitproject/draw_tree.git@v0.9.1"
pip install "gtdraw @ git+https://github.com/gambitproject/gtdraw.git@main"
- name: Run tests
run: pytest --run-tutorials

Expand All @@ -76,7 +76,7 @@ jobs:
- name: Build extension
run: |
python -m pip install -v .[test,doc]
pip install "draw-tree @ git+https://github.com/gambitproject/draw_tree.git@v0.9.1"
pip install "gtdraw @ git+https://github.com/gambitproject/gtdraw.git@main"
- name: Run tests
run: pytest --run-tutorials

Expand All @@ -100,6 +100,6 @@ jobs:
shell: bash
run: |
python -m pip install -v .[test,doc]
pip install "draw-tree @ git+https://github.com/gambitproject/draw_tree.git@v0.9.1"
pip install "gtdraw @ git+https://github.com/gambitproject/gtdraw.git@main"
- name: Run tests
run: pytest --run-tutorials
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build:
- pdf2svg
jobs:
post_install:
- pip install "draw-tree @ git+https://github.com/gambitproject/draw_tree.git@v0.9.1"
- pip install "gtdraw @ git+https://github.com/gambitproject/gtdraw.git@main"
# Create RST for catalog table in docs
- $READTHEDOCS_VIRTUALENV_PATH/bin/python build_support/catalog/update.py

Expand Down
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
- `Game.new_table` no longer creates an outcome for every contingency; a new strategic game has no outcomes,
and every contingency is initially null. Outcomes are created as they are needed;
games built by `Game.from_arrays` and `Game.from_dict` are unaffected. (#1061)
- Tutorial notebooks that use `gtdraw` to draw game trees now degrade gracefully if it isn't
installed: the drawing cells print a short note instead of raising `ImportError`, so the rest
of the tutorial (which doesn't otherwise depend on `gtdraw`) still runs. `gtdraw` depends on a
LaTeX installation, so this lets the tutorials be run without that heavier local setup.

### Removed
- `gtdraw` is no longer part of the `doc` optional-dependency group. Install it separately
(`pip install gtdraw`) to run tutorials locally or build the documentation.
- `Game.contingencies` now yields contingencies as a mapping from player label to strategy
label, rather than a list of per-player strategy indices.
- `Player.strategies` now iterates strategy labels (`str`) rather than `Strategy` objects;
Expand Down
5 changes: 4 additions & 1 deletion doc/developer.build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,13 @@ Use `pip` to install from the **root directory of the source tree**:
python -m venv venv
source venv/bin/activate
python -m pip install ".[test,doc]"
pip install gtdraw

.. tip::

The "test" and "doc" optional dependencies are useful for developers wishing to run the test suite or build this documentation locally.
The "test" and "doc" optional dependencies are useful for developers wishing to run the test suite or build this documentation locally. `gtdraw <https://github.com/gambitproject/gtdraw>`_, used to
draw game trees in the tutorials and the games catalog, is installed separately rather than as
part of the "doc" extra, since it is not needed by the installed `pygambit` package itself.


Once installed, simply ``import pygambit`` in your Python shell or
Expand Down
1 change: 1 addition & 0 deletions doc/developer.catalog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Currently supported representations are:
.. code-block:: bash

pip install -e ".[doc]"
pip install gtdraw

1. **Create or edit a game file:**

Expand Down
12 changes: 10 additions & 2 deletions doc/tutorials/02_extensive_form.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"- If the Seller chooses **Abuse**, the Buyer receives a payoff of `-1` and the Seller receives a payoff of `2`.\n",
"\n",
"In addition to `pygambit`, this tutorial introduces the `gtdraw` package, which can be used to draw extensive form games in Python.\n",
"If you're running this tutorial on your local machine, you'll need to install the requirements for [gtdraw](https://www.gambit-project.org/gtdraw/), which include LaTeX, in order to run the `gtdraw` cells.\n",
"`gtdraw` is optional here; if it isn't available, the drawing cells below print a short note.\n",
"To install `gtdraw`, see [gtdraw](https://www.gambit-project.org/gtdraw/).\n",
"Another option for visualising extensive form games is to install the Gambit GUI and use it to load the EFG file generated at the end of this tutorial."
]
},
Expand All @@ -36,7 +37,14 @@
"metadata": {},
"outputs": [],
"source": [
"from gtdraw import draw\n",
"try:\n",
" from gtdraw import draw\n",
"except ImportError:\n",
" def draw(*args, **kwargs):\n",
" print(\n",
" \"gtdraw is not installed, so the game tree cannot be drawn here; \"\n",
" \"see https://www.gambit-project.org/gtdraw/ to install it.\"\n",
" )\n",
"\n",
"import pygambit as gbt"
]
Expand Down
14 changes: 11 additions & 3 deletions doc/tutorials/03_stripped_down_poker.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
" - If she has a King, then she wins the pot.\n",
" - If she has a Queen, then Bob wins the pot.\n",
"\n",
"In addition to `pygambit`, this tutorial uses the `gtdraw` package, which can be used to draw extensive form games in Python.\n",
"If you're running this tutorial on your local machine, you'll need to install the requirements for [gtdraw](https://www.gambit-project.org/gtdraw/), which include LaTeX, in order to run the `gtdraw` cells.\n",
"In addition to `pygambit`, this tutorial introduces the `gtdraw` package, which can be used to draw extensive form games in Python.\n",
"`gtdraw` is optional here; if it isn't available, the drawing cells below print a short note.\n",
"To install `gtdraw`, see [gtdraw](https://www.gambit-project.org/gtdraw/).\n",
"Another option for visualising extensive form games is to install the Gambit GUI and use it to load a saved EFG file."
]
},
Expand All @@ -44,7 +45,14 @@
"metadata": {},
"outputs": [],
"source": [
"from gtdraw import draw\n",
"try:\n",
" from gtdraw import draw\n",
"except ImportError:\n",
" def draw(*args, **kwargs):\n",
" print(\n",
" \"gtdraw is not installed, so the game tree cannot be drawn here; \"\n",
" \"see https://www.gambit-project.org/gtdraw/ to install it.\"\n",
" )\n",
"\n",
"import pygambit as gbt"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,22 @@
"id": "5142d6ba-da13-4500-bca6-e68b608bfae9",
"metadata": {},
"outputs": [],
"source": "from gtdraw import draw\n\nimport pygambit as gbt\n\ng = gbt.catalog.load(\"books/myerson1991/fig4_2\")\ndraw(g)"
"source": [
"# gtdraw is optional: it depends on a LaTeX installation; without it, draw() prints a note.\n",
"try:\n",
" from gtdraw import draw\n",
"except ImportError:\n",
" def draw(*args, **kwargs):\n",
" print(\n",
" \"gtdraw is not installed, so the game tree cannot be drawn here; \"\n",
" \"see https://www.gambit-project.org/gtdraw/ to install it.\"\n",
" )\n",
"\n",
"import pygambit as gbt\n",
"\n",
"g = gbt.catalog.load(\"books/myerson1991/fig4_2\")\n",
"draw(g)"
]
},
{
"cell_type": "markdown",
Expand Down
10 changes: 9 additions & 1 deletion doc/tutorials/interoperability_tutorials/openspiel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,15 @@
"metadata": {},
"outputs": [],
"source": [
"from gtdraw import draw\n",
"# gtdraw is optional: it depends on a LaTeX installation; without it, draw() prints a note.\n",
"try:\n",
" from gtdraw import draw\n",
"except ImportError:\n",
" def draw(*args, **kwargs):\n",
" print(\n",
" \"gtdraw is not installed, so the game tree cannot be drawn here; \"\n",
" \"see https://www.gambit-project.org/gtdraw/ to install it.\"\n",
" )\n",
"\n",
"draw(\n",
" gbt_hanabi_game,\n",
Expand Down
5 changes: 5 additions & 0 deletions doc/tutorials/running_locally.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ The tutorials are available as Jupyter notebooks and can be run interactively us

pip install .[doc]

Several tutorials also use `gtdraw <https://github.com/gambitproject/gtdraw>`_ to draw game
trees. `gtdraw` is installed separately::

pip install gtdraw

.. warning::
Windows users wishing to run the "Using Gambit with OpenSpiel" tutorial will need to install OpenSpiel manually; see the `OpenSpiel installation instructions <https://openspiel.readthedocs.io/en/latest/windows.html>`_ for details.

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ doc = [
"pyyaml",
"sphinxcontrib-bibtex",
"myst-parser",
"gtdraw",
]

[project.urls]
Expand Down
Loading