diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 438c7c64b..8e53f722a 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -34,7 +34,7 @@ jobs: - name: Run tests run: pytest --run-tutorials - macos-13: + macos-14: runs-on: macos-14 if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name strategy: @@ -52,13 +52,14 @@ jobs: python -m pip install --upgrade pip pip install setuptools build cython wheel pip install -r tests/requirements.txt + pip install -r doc/requirements.txt - name: Build extension run: | python -m pip install -v . - name: Run tests - run: pytest + run: pytest --run-tutorials - macos-14: + macos-15: runs-on: macos-15 if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name strategy: diff --git a/doc/tutorials/03_stripped_down_poker.ipynb b/doc/tutorials/03_stripped_down_poker.ipynb index 16507d6ec..7937f092e 100644 --- a/doc/tutorials/03_stripped_down_poker.ipynb +++ b/doc/tutorials/03_stripped_down_poker.ipynb @@ -39,7 +39,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 37, "id": "69cbfe81", "metadata": {}, "outputs": [], @@ -59,7 +59,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 38, "id": "ad6a1119", "metadata": {}, "outputs": [], @@ -80,7 +80,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 39, "id": "841f9f74", "metadata": {}, "outputs": [ @@ -116,7 +116,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 40, "id": "fe80c64c", "metadata": {}, "outputs": [], @@ -130,7 +130,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 41, "id": "867cb1d8-7a5d-45d1-9349-9bbc2a4e2344", "metadata": {}, "outputs": [ @@ -284,7 +284,7 @@ "" ] }, - "execution_count": 5, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -309,7 +309,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 42, "id": "0e3bb5ef", "metadata": {}, "outputs": [], @@ -324,7 +324,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 43, "id": "0c522c2d-992e-48b6-a1f8-0696d33cdbe0", "metadata": {}, "outputs": [ @@ -609,7 +609,7 @@ "" ] }, - "execution_count": 7, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } @@ -638,7 +638,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 44, "id": "dbfa7035", "metadata": {}, "outputs": [], @@ -652,7 +652,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 45, "id": "e85b3346-2fea-4a73-aa72-9efb436c68c1", "metadata": {}, "outputs": [ @@ -986,7 +986,7 @@ "" ] }, - "execution_count": 9, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } @@ -1010,7 +1010,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 46, "id": "87c988be", "metadata": {}, "outputs": [], @@ -1031,7 +1031,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 47, "id": "29aa60a0", "metadata": {}, "outputs": [], @@ -1053,7 +1053,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 48, "id": "fdee7b53-7820-44df-9d17-d15d0b9667aa", "metadata": {}, "outputs": [ @@ -1392,7 +1392,7 @@ "" ] }, - "execution_count": 12, + "execution_count": 48, "metadata": {}, "output_type": "execute_result" } @@ -1414,7 +1414,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 49, "id": "4d92c8d9", "metadata": {}, "outputs": [ @@ -1424,7 +1424,7 @@ "NashComputationResult(method='lcp', rational=True, use_strategic=False, equilibria=[[[[Rational(1, 1), Rational(0, 1)], [Rational(1, 3), Rational(2, 3)]], [[Rational(2, 3), Rational(1, 3)]]]], parameters={'stop_after': 0, 'max_depth': 0})" ] }, - "execution_count": 13, + "execution_count": 49, "metadata": {}, "output_type": "execute_result" } @@ -1448,7 +1448,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 50, "id": "9967d6f7", "metadata": {}, "outputs": [ @@ -1475,7 +1475,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 51, "id": "3293e818", "metadata": {}, "outputs": [ @@ -1485,7 +1485,7 @@ "pygambit.gambit.MixedBehaviorProfileRational" ] }, - "execution_count": 15, + "execution_count": 51, "metadata": {}, "output_type": "execute_result" } @@ -1506,7 +1506,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 52, "id": "4cf38264", "metadata": {}, "outputs": [ @@ -1516,7 +1516,7 @@ "pygambit.gambit.MixedBehavior" ] }, - "execution_count": 16, + "execution_count": 52, "metadata": {}, "output_type": "execute_result" } @@ -1527,7 +1527,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 53, "id": "85e7fdda", "metadata": {}, "outputs": [ @@ -1540,7 +1540,7 @@ "[[Rational(1, 1), Rational(0, 1)], [Rational(1, 3), Rational(2, 3)]]" ] }, - "execution_count": 17, + "execution_count": 53, "metadata": {}, "output_type": "execute_result" } @@ -1565,7 +1565,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 54, "id": "f45a82b6", "metadata": {}, "outputs": [ @@ -1597,7 +1597,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 55, "id": "83bbd3e5", "metadata": {}, "outputs": [ @@ -1630,7 +1630,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 56, "id": "6bf51b38", "metadata": {}, "outputs": [ @@ -1643,7 +1643,7 @@ "[[Rational(2, 3), Rational(1, 3)]]" ] }, - "execution_count": 20, + "execution_count": 56, "metadata": {}, "output_type": "execute_result" } @@ -1666,7 +1666,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 57, "id": "2966e700", "metadata": {}, "outputs": [ @@ -1679,7 +1679,7 @@ "Rational(2, 3)" ] }, - "execution_count": 21, + "execution_count": 57, "metadata": {}, "output_type": "execute_result" } @@ -1698,7 +1698,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 58, "id": "f5a7f110", "metadata": {}, "outputs": [ @@ -1711,7 +1711,7 @@ "Rational(2, 3)" ] }, - "execution_count": 22, + "execution_count": 58, "metadata": {}, "output_type": "execute_result" } @@ -1732,7 +1732,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 59, "id": "a7d3816d", "metadata": {}, "outputs": [ @@ -1767,7 +1767,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 60, "id": "4a54b20c", "metadata": {}, "outputs": [ @@ -1800,7 +1800,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 61, "id": "b250c1cd", "metadata": {}, "outputs": [ @@ -1813,7 +1813,7 @@ "Rational(2, 3)" ] }, - "execution_count": 25, + "execution_count": 61, "metadata": {}, "output_type": "execute_result" } @@ -1832,7 +1832,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 62, "id": "6f01846b", "metadata": {}, "outputs": [ @@ -1864,7 +1864,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 63, "id": "5079d231", "metadata": {}, "outputs": [ @@ -1877,7 +1877,7 @@ "Rational(1, 3)" ] }, - "execution_count": 27, + "execution_count": 63, "metadata": {}, "output_type": "execute_result" } @@ -1888,7 +1888,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 64, "id": "c55f2c7a", "metadata": {}, "outputs": [ @@ -1901,7 +1901,7 @@ "Rational(-1, 3)" ] }, - "execution_count": 28, + "execution_count": 64, "metadata": {}, "output_type": "execute_result" } @@ -1928,7 +1928,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 65, "id": "d4ecff88", "metadata": {}, "outputs": [ @@ -1938,7 +1938,7 @@ "['11', '12', '21', '22']" ] }, - "execution_count": 29, + "execution_count": 65, "metadata": {}, "output_type": "execute_result" } @@ -1962,7 +1962,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 66, "id": "24e4b6e8", "metadata": {}, "outputs": [ @@ -1972,7 +1972,7 @@ "NashComputationResult(method='gnm', rational=False, use_strategic=True, equilibria=[[[0.33333333333866677, 0.6666666666613335, 0.0, 0.0], [0.6666666666559997, 0.3333333333440004]]], parameters={'perturbation': [[1.0, 0.0, 0.0, 0.0], [1.0, 0.0]], 'end_lambda': -10.0, 'steps': 100, 'local_newton_interval': 3, 'local_newton_maxits': 10})" ] }, - "execution_count": 30, + "execution_count": 66, "metadata": {}, "output_type": "execute_result" } @@ -1994,7 +1994,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 67, "id": "d9ffb4b8", "metadata": {}, "outputs": [ @@ -2004,7 +2004,7 @@ "pygambit.gambit.MixedStrategyProfileDouble" ] }, - "execution_count": 31, + "execution_count": 67, "metadata": {}, "output_type": "execute_result" } @@ -2026,7 +2026,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 68, "id": "56e2f847", "metadata": {}, "outputs": [ @@ -2079,7 +2079,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 69, "id": "d18a91f0", "metadata": {}, "outputs": [ @@ -2088,14 +2088,14 @@ "output_type": "stream", "text": [ "Alice's expected payoffs:\n", - "At information set 0, when playing Bet - gnm: 1.6667, lcp: 1.6667\n", - "At information set 0, when playing Fold - gnm: -1.0000, lcp: -1.0000\n", - "At information set 1, when playing Bet - gnm: -1.0000, lcp: -1.0000\n", - "At information set 1, when playing Fold - gnm: -1.0000, lcp: -1.0000\n", + "At information set 0, when playing Bet - gnm: 1.6667, lcp: 5/3\n", + "At information set 0, when playing Fold - gnm: -1.0000, lcp: -1\n", + "At information set 1, when playing Bet - gnm: -1.0000, lcp: -1\n", + "At information set 1, when playing Fold - gnm: -1.0000, lcp: -1\n", "\n", "Bob's expected payoffs:\n", - "At information set 0, when playing Call - gnm: -1.0000, lcp: -1.0000\n", - "At information set 0, when playing Fold - gnm: -1.0000, lcp: -1.0000\n", + "At information set 0, when playing Call - gnm: -1.0000, lcp: -1\n", + "At information set 0, when playing Fold - gnm: -1.0000, lcp: -1\n", "\n" ] } @@ -2110,7 +2110,7 @@ " f\"At information set {action.infoset.number}, \"\n", " f\"when playing {action.label} - \"\n", " f\"gnm: {gnm_eqm.as_behavior().action_value(action):.4f}\"\n", - " f\", lcp: {eqm.action_value(action):.4f}\"\n", + " f\", lcp: {str(eqm.action_value(action))}\"\n", " )\n", " print()" ] @@ -2145,7 +2145,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 70, "id": "0c55f745", "metadata": {}, "outputs": [ @@ -2155,7 +2155,7 @@ "(Rational(2, 1), Rational(-2, 1))" ] }, - "execution_count": 34, + "execution_count": 70, "metadata": {}, "output_type": "execute_result" } @@ -2177,7 +2177,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 71, "id": "101598c6", "metadata": {}, "outputs": [ @@ -2187,7 +2187,7 @@ "1" ] }, - "execution_count": 35, + "execution_count": 71, "metadata": {}, "output_type": "execute_result" } @@ -2199,7 +2199,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 72, "id": "9b142728", "metadata": {}, "outputs": [ @@ -2209,7 +2209,7 @@ "3.987411578698641e-08" ] }, - "execution_count": 36, + "execution_count": 72, "metadata": {}, "output_type": "execute_result" } @@ -2230,7 +2230,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 73, "id": "ff405409", "metadata": {}, "outputs": [ @@ -2240,7 +2240,7 @@ "9.968528946746602e-09" ] }, - "execution_count": 37, + "execution_count": 73, "metadata": {}, "output_type": "execute_result" } @@ -2261,7 +2261,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 74, "id": "31b0143c", "metadata": {}, "outputs": [ @@ -2271,7 +2271,7 @@ "9.395259956013202e-05" ] }, - "execution_count": 38, + "execution_count": 74, "metadata": {}, "output_type": "execute_result" } @@ -2290,7 +2290,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 75, "id": "7cfba34a", "metadata": {}, "outputs": [ @@ -2298,8 +2298,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 8.72 ms, sys: 143 μs, total: 8.86 ms\n", - "Wall time: 8.85 ms\n" + "CPU times: user 9.86 ms, sys: 91 μs, total: 9.95 ms\n", + "Wall time: 9.96 ms\n" ] }, { @@ -2308,7 +2308,7 @@ "NashComputationResult(method='logit', rational=False, use_strategic=False, equilibria=[[[[1.0, 0.0], [0.3338351656285655, 0.666164834417892]], [[0.6670407651644307, 0.3329592348608147]]]], parameters={'first_step': 0.03, 'max_accel': 1.1})" ] }, - "execution_count": 39, + "execution_count": 75, "metadata": {}, "output_type": "execute_result" } @@ -2320,7 +2320,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 76, "id": "6f1809a7", "metadata": {}, "outputs": [ @@ -2328,8 +2328,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 16.7 ms, sys: 234 μs, total: 17 ms\n", - "Wall time: 17 ms\n" + "CPU times: user 18.8 ms, sys: 148 μs, total: 19 ms\n", + "Wall time: 19 ms\n" ] }, { @@ -2338,7 +2338,7 @@ "NashComputationResult(method='logit', rational=False, use_strategic=False, equilibria=[[[[1.0, 0.0], [0.33333338649882943, 0.6666666135011706]], [[0.6666667065407631, 0.3333332934592369]]]], parameters={'first_step': 0.03, 'max_accel': 1.1})" ] }, - "execution_count": 40, + "execution_count": 76, "metadata": {}, "output_type": "execute_result" } @@ -2360,17 +2360,17 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 77, "id": "414b6f65", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "5.509533871672634e-05" + "5.509949805110326e-05" ] }, - "execution_count": 41, + "execution_count": 77, "metadata": {}, "output_type": "execute_result" } @@ -2392,17 +2392,17 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 78, "id": "a892dc2b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "5.509533871672634e-05" + "5.509949805110326e-05" ] }, - "execution_count": 42, + "execution_count": 78, "metadata": {}, "output_type": "execute_result" } @@ -2433,7 +2433,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 79, "id": "2f79695a", "metadata": {}, "outputs": [ @@ -2443,7 +2443,7 @@ "[Rational(1, 3), Rational(1, 3), Rational(1, 3)]" ] }, - "execution_count": 43, + "execution_count": 79, "metadata": {}, "output_type": "execute_result" } @@ -2467,7 +2467,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 80, "id": "5de6acb2", "metadata": {}, "outputs": [ @@ -2477,7 +2477,7 @@ "[Rational(1, 4), Rational(1, 2), Rational(1, 4)]" ] }, - "execution_count": 44, + "execution_count": 80, "metadata": {}, "output_type": "execute_result" } @@ -2500,7 +2500,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 81, "id": "c47d2ab6", "metadata": {}, "outputs": [ @@ -2510,7 +2510,7 @@ "[Decimal('0.25'), Decimal('0.50'), Decimal('0.25')]" ] }, - "execution_count": 45, + "execution_count": 81, "metadata": {}, "output_type": "execute_result" } @@ -2537,7 +2537,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 82, "id": "04329084", "metadata": {}, "outputs": [ @@ -2547,7 +2547,7 @@ "[Rational(1, 4), Rational(1, 2), Rational(1, 4)]" ] }, - "execution_count": 46, + "execution_count": 82, "metadata": {}, "output_type": "execute_result" } @@ -2559,7 +2559,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 83, "id": "9015e129", "metadata": {}, "outputs": [ @@ -2569,7 +2569,7 @@ "[Decimal('0.25'), Decimal('0.50'), Decimal('0.25')]" ] }, - "execution_count": 47, + "execution_count": 83, "metadata": {}, "output_type": "execute_result" } @@ -2594,7 +2594,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 84, "id": "0a019aa5", "metadata": {}, "outputs": [ @@ -2604,7 +2604,7 @@ "[Decimal('0.25'), Decimal('0.5'), Decimal('0.25')]" ] }, - "execution_count": 48, + "execution_count": 84, "metadata": {}, "output_type": "execute_result" } @@ -2624,7 +2624,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 85, "id": "1991d288", "metadata": {}, "outputs": [ @@ -2654,7 +2654,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 86, "id": "b1dc37fd", "metadata": {}, "outputs": [ @@ -2664,7 +2664,7 @@ "1.0" ] }, - "execution_count": 50, + "execution_count": 86, "metadata": {}, "output_type": "execute_result" } @@ -2683,7 +2683,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 87, "id": "dc1edea2", "metadata": {}, "outputs": [ @@ -2693,7 +2693,7 @@ "Decimal('0.3333333333333333')" ] }, - "execution_count": 51, + "execution_count": 87, "metadata": {}, "output_type": "execute_result" } @@ -2712,7 +2712,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 88, "id": "1edd90d6", "metadata": {}, "outputs": [ @@ -2722,7 +2722,7 @@ "Decimal('0.9999999999999999')" ] }, - "execution_count": 52, + "execution_count": 88, "metadata": {}, "output_type": "execute_result" } @@ -2756,7 +2756,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "gambit310", "language": "python", "name": "python3" }, @@ -2770,7 +2770,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.5" + "version": "3.10.19" } }, "nbformat": 4, diff --git a/doc/tutorials/running_locally.rst b/doc/tutorials/running_locally.rst index 87ee766ba..c5457fa9b 100644 --- a/doc/tutorials/running_locally.rst +++ b/doc/tutorials/running_locally.rst @@ -6,7 +6,7 @@ How to run PyGambit tutorials on your computer Running the PyGambit tutorials on your machine requires some familiarity with the basics of Python and how to use Git & GitHub. The tutorials are available as Jupyter notebooks and can be run interactively using any program that supports Jupyter notebooks, such as JupyterLab or VSCode. -.. tip:: Create a virtual environment with Python 3.13 or higher +.. tip:: Create a virtual environment with Python 3.10 or higher. 1. To download the tutorials, open your OS's command prompt and clone the Gambit repository from GitHub, then navigate to the tutorials directory: :: diff --git a/tests/test_tutorials.py b/tests/test_tutorials.py index 85f6decb0..e15171ebe 100644 --- a/tests/test_tutorials.py +++ b/tests/test_tutorials.py @@ -47,9 +47,6 @@ def test_execute_notebook(nb_path): This uses nbclient.NotebookClient to run the notebook in its parent directory so relative paths within the notebook resolve correctly. """ - # Skip notebook execution tests on Python < 3.12 (notebooks may require newer kernels/deps) - if sys.version_info < (3, 12): - pytest.skip("Notebook execution tests require Python 3.12 or newer") # Skip OpenSpiel notebook on Windows # (OpenSpiel is not available on Windows without manual install)