From 392186197d54e822e7fb68d293d61d59c3af1a38 Mon Sep 17 00:00:00 2001 From: Daisuke Oyama Date: Sun, 15 Dec 2024 16:03:32 +0900 Subject: [PATCH] Add __repr__ for PolymatrixGame (#749) --- quantecon/game_theory/polymatrix_game.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/quantecon/game_theory/polymatrix_game.py b/quantecon/game_theory/polymatrix_game.py index f95fc5b9..ebfeba3e 100644 --- a/quantecon/game_theory/polymatrix_game.py +++ b/quantecon/game_theory/polymatrix_game.py @@ -39,7 +39,7 @@ # from typing import TypeAlias, Self from numpy.typing import NDArray -from .normal_form_game import NormalFormGame, Player +from .normal_form_game import NormalFormGame, Player, _nums_actions2string def hh_payoff_player( @@ -155,6 +155,10 @@ class PolymatrixGame: Maps each pair of player numbers to a matrix. """ + def __repr__(self): + s = '<{nums_actions} {N}-player PolymatrixGame>' + return s.format(nums_actions=_nums_actions2string(self.nums_actions), + N=self.N) def __str__(self) -> str: str_builder = (