Skip to content

Commit

Permalink
Specifies nums_actions as tuple. Fixes documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
GautamsGitHub committed Nov 26, 2024
1 parent 8cc3a74 commit d1a20fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion quantecon/game_theory/howson_lcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def polym_lcp_solver(
Returns
-------
tuple[NDArray] or NashResult
tuple(ndarray(float, ndim=1)) or NashResult
The mixed actions at termination, a Nash Equilibrium if
not stopped early by reaching `max_iter`. If `full_output`,
then the number of iterations, whether it has converged,
Expand Down
17 changes: 10 additions & 7 deletions quantecon/game_theory/polymatrix_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from itertools import product
from math import isqrt

from collections.abc import Sequence, Mapping
from collections.abc import Sequence, Mapping, Iterable
# from typing import TypeAlias, Self
from numpy.typing import NDArray

Expand Down Expand Up @@ -145,10 +145,10 @@ class PolymatrixGame:
Attributes
----------
N : int
N : scalar(int)
Number of players.
nums_actions : Sequence[int]
nums_actions : tuple(int)
The number of actions available to each player.
polymatrix : dict[tuple(int), ndarray(float, ndim=2)]
Expand All @@ -171,7 +171,7 @@ def __init__(
tuple[int, int],
Sequence[Sequence[float]]
],
nums_actions: Sequence[int] = None
nums_actions: Iterable[int] = None
) -> None:
"""_summary_
Expand All @@ -182,10 +182,13 @@ def __init__(
inferred from this if `nums_actions` is left None.
This inferrence uses the number of actions they have
against the next player.
nums_actions : Sequence[int], optional
Actions with unspecified payoff are given
payoff of `-np.inf`.
nums_actions : Iterable[int], optional
If desired, nums_actions can be set so that unspecified
matchups in the polymatrix will be filled with matrices
of 0s and unspecified actions give payoff of `-np.inf`.
of 0s (while unspecified actions give payoff
of `-np.inf`).
"""
if nums_actions is None:
self.N = (isqrt(4*len(polymatrix)+1) + 1) // 2
Expand All @@ -195,7 +198,7 @@ def __init__(
)
else:
self.N = len(nums_actions)
self.nums_actions = nums_actions
self.nums_actions = tuple(nums_actions)
matchups = [
(p1, p2)
for p1 in range(self.N)
Expand Down

0 comments on commit d1a20fc

Please sign in to comment.