Skip to content

Commit cd552f5

Browse files
committed
NormalFormGame: Make payoff_array's C contiguous
when payoff_profile_array is passed to NormalFormGame
1 parent af3e0ec commit cd552f5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

quantecon/game_theory/normal_form_game.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,16 @@ def __init__(self, data, dtype=None):
475475
'size of innermost array must be equal to ' +
476476
'the number of players'
477477
)
478-
self.players = tuple(
479-
Player(
478+
payoff_arrays = tuple(
479+
np.empty(data.shape[i:-1]+data.shape[:i], dtype=data.dtype)
480+
for i in range(N)
481+
)
482+
for i, payoff_array in enumerate(payoff_arrays):
483+
payoff_array[:] = \
480484
data.take(i, axis=-1).transpose(list(range(i, N)) +
481485
list(range(i)))
482-
) for i in range(N)
486+
self.players = tuple(
487+
Player(payoff_array) for payoff_array in payoff_arrays
483488
)
484489
self.dtype = data.dtype
485490

0 commit comments

Comments
 (0)