-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Annotate normal_form_game.py #576
base: main
Are you sure you want to change the base?
Conversation
Hello @rht! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
Will fix the line too long issues later. |
There is never such case, from the way |
In |
Yes, it happens when There are two options:
Maybe option 1? |
There is a |
Maybe it is safer to tell the user there is a problem instead of |
@@ -233,7 +240,7 @@ def delete_action(self, action, player_idx=0): | |||
payoff_array_new = np.delete(self.payoff_array, action, player_idx) | |||
return Player(payoff_array_new) | |||
|
|||
def payoff_vector(self, opponents_actions): | |||
def payoff_vector(self, opponents_actions: npt.ArrayLike) -> np.ndarray: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opponents_actions
should have been IntOrArray
, which is Union[int, npt.ArrayLike]
.
But doing so will cause problem in
reduce_last_player(payoff_vector, opponents_actions[i]) |
Union[int, ...]
type generally can't be indexed. Alternative solution to my current version is to use cast()
before the indexing to cast opponents_actions
into an indexable.
Note that int
is also part of npt.ArrayLike
, since np.array(1)
works.
thanks @rht sorry for my slow response.
@oyamad should we add an exception if |
Actually, this function |
So your annotations are correct. |
|
@oyamad are you happy with these annotations? |
I think it is safe to replace all of QuantEcon.py/quantecon/game_theory/normal_form_game.py Lines 258 to 261 in 538bf7c
|
np.ndarray
is a catch-all type for all ndarrays regardless of its dtype, and so, is unfortunately less specific than the docstring that specifies ndarray.action_profile
since the functions using it are not documented.normal_form_game.py:921: error: Missing return statement
inQuantEcon.py/quantecon/game_theory/normal_form_game.py
Line 931 in 6ffbe57
None
instead ofint
when the if condition is never satisfied.