Skip to content

Commit

Permalink
NormalFormGame: Make payoff_array's C contiguous
Browse files Browse the repository at this point in the history
when payoff_profile_array is passed to NormalFormGame
  • Loading branch information
oyamad committed Oct 20, 2016
1 parent af3e0ec commit cd552f5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions quantecon/game_theory/normal_form_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,16 @@ def __init__(self, data, dtype=None):
'size of innermost array must be equal to ' +
'the number of players'
)
self.players = tuple(
Player(
payoff_arrays = tuple(
np.empty(data.shape[i:-1]+data.shape[:i], dtype=data.dtype)
for i in range(N)
)
for i, payoff_array in enumerate(payoff_arrays):
payoff_array[:] = \
data.take(i, axis=-1).transpose(list(range(i, N)) +
list(range(i)))
) for i in range(N)
self.players = tuple(
Player(payoff_array) for payoff_array in payoff_arrays
)
self.dtype = data.dtype

Expand Down

0 comments on commit cd552f5

Please sign in to comment.