Skip to content

Commit 88d1274

Browse files
committed
Fix up ruff of notebooks.
1 parent 5441311 commit 88d1274

3 files changed

Lines changed: 32 additions & 22 deletions

File tree

doc/tutorials/01_quickstart.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"outputs": [],
4545
"source": [
4646
"import numpy as np\n",
47-
"import pygambit as gbt"
47+
"\n",
48+
"import pygambit as gbt\n"
4849
]
4950
},
5051
{
@@ -472,7 +473,7 @@
472473
],
473474
"metadata": {
474475
"kernelspec": {
475-
"display_name": "gambitvenv313",
476+
"display_name": "Python 3 (ipykernel)",
476477
"language": "python",
477478
"name": "python3"
478479
},

doc/tutorials/03_poker.ipynb

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"outputs": [],
6060
"source": [
6161
"g = gbt.Game.new_tree(\n",
62-
" players=[\"Alice\", \"Bob\"], \n",
62+
" players=[\"Alice\", \"Bob\"],\n",
6363
" title=\"One card poker\"\n",
6464
")"
6565
]
@@ -327,23 +327,25 @@
327327
},
328328
{
329329
"cell_type": "code",
330-
"execution_count": 61,
330+
"execution_count": 1,
331331
"id": "3293e818",
332332
"metadata": {},
333333
"outputs": [
334334
{
335-
"data": {
336-
"text/plain": [
337-
"pygambit.gambit.MixedBehaviorProfileRational"
338-
]
339-
},
340-
"execution_count": 61,
341-
"metadata": {},
342-
"output_type": "execute_result"
335+
"ename": "NameError",
336+
"evalue": "name 'eqm' is not defined",
337+
"output_type": "error",
338+
"traceback": [
339+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
340+
"\u001b[31mNameError\u001b[39m Traceback (most recent call last)",
341+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[1]\u001b[39m\u001b[32m, line 2\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;66;03m# MixedBehaviorProfileRational is a subclass of MixedBehaviorProfile that uses rational numbers for probabilities.\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m2\u001b[39m \u001b[38;5;28mtype\u001b[39m(\u001b[43meqm\u001b[49m)\n",
342+
"\u001b[31mNameError\u001b[39m: name 'eqm' is not defined"
343+
]
343344
}
344345
],
345346
"source": [
346-
"# Note: MixedBehaviorProfileRational is a subclass of MixedBehaviorProfile that uses rational numbers for probabilities.\n",
347+
"# MixedBehaviorProfileRational is a subclass of MixedBehaviorProfile that uses\n",
348+
"# rational numbers for probabilities.\n",
347349
"type(eqm)"
348350
]
349351
},
@@ -602,7 +604,7 @@
602604
"# Remember that Bob has a single information set\n",
603605
"for action in g.players[\"Bob\"].infosets[0].actions:\n",
604606
" print(\n",
605-
" f\"When Bob plays {action.label} he can expect the payoff: {eqm.action_value(action)}\"\n",
607+
" f\"When Bob plays {action.label} his expected payoff is {eqm.action_value(action)}\"\n",
606608
" )"
607609
]
608610
},
@@ -636,7 +638,8 @@
636638
"source": [
637639
"for node in g.players[\"Bob\"].infosets[0].members:\n",
638640
" print(\n",
639-
" f\"Bob's belief in reaching the {node.parent.prior_action.label} -> {node.prior_action.label} node is: {eqm.belief(node)}\"\n",
641+
" f\"Bob's belief in reaching the {node.parent.prior_action.label} -> \"\n",
642+
" f\"{node.prior_action.label} node is: {eqm.belief(node)}\"\n",
640643
" )"
641644
]
642645
},
@@ -700,8 +703,9 @@
700703
"source": [
701704
"for node in g.players[\"Bob\"].infosets[0].members:\n",
702705
" print(\n",
703-
" f\"The probability that the node {node.parent.prior_action.label} -> {node.prior_action.label} is reached is: {eqm.realiz_prob(node)}. \",\n",
704-
" f\"Bob's expected payoff conditional on reaching this node is: {eqm.node_value(\"Bob\", node)}\"\n",
706+
" f\"The probability that the node {node.parent.prior_action.label} -> \"\n",
707+
" f\"{node.prior_action.label} is reached is: {eqm.realiz_prob(node)}. \",\n",
708+
" f\"Bob's expected payoff conditional on reaching this node is {eqm.node_value('Bob', node)}\"\n",
705709
" )"
706710
]
707711
},
@@ -1227,7 +1231,10 @@
12271231
}
12281232
],
12291233
"source": [
1230-
"gbt.nash.liap_solve(g.mixed_behavior_profile(), maxregret=1.0e-4).equilibria[0].max_regret() / (g.max_payoff - g.min_payoff)"
1234+
"(\n",
1235+
" gbt.nash.liap_solve(g.mixed_behavior_profile(), maxregret=1.0e-4)\n",
1236+
" .equilibria[0].max_regret() / (g.max_payoff - g.min_payoff)\n",
1237+
")"
12311238
]
12321239
},
12331240
{
@@ -1260,7 +1267,10 @@
12601267
" outcome[\"Alice\"] = outcome[\"Alice\"] * 2\n",
12611268
" outcome[\"Bob\"] = outcome[\"Bob\"] * 2\n",
12621269
"\n",
1263-
"gbt.nash.liap_solve(g.mixed_behavior_profile(), maxregret=1.0e-4).equilibria[0].max_regret() / (g.max_payoff - g.min_payoff)"
1270+
"(\n",
1271+
" gbt.nash.liap_solve(g.mixed_behavior_profile(), maxregret=1.0e-4)\n",
1272+
" .equilibria[0].max_regret() / (g.max_payoff - g.min_payoff)\n",
1273+
")"
12641274
]
12651275
},
12661276
{
@@ -1603,7 +1613,7 @@
16031613
],
16041614
"metadata": {
16051615
"kernelspec": {
1606-
"display_name": "gambitvenv313",
1616+
"display_name": "Python 3 (ipykernel)",
16071617
"language": "python",
16081618
"name": "python3"
16091619
},

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ Changelog = "https://github.com/gambitproject/gambit/blob/master/ChangeLog"
4242
line-length = 99
4343
indent-width = 4
4444
target-version = "py39"
45-
include = ["setup.py", "src/pygambit/**/*.py", "tests/**/*.py"]
46-
exclude = ["contrib/**.py"]
45+
include = ["setup.py", "src/pygambit/**/*.py", "tests/**/*.py, doc/tutorials/*.ipynb"]
4746

4847
[tool.ruff.lint]
4948
select = [

0 commit comments

Comments
 (0)