Open endolith opened 5 years ago
I think all of these functions could accept 3D arrays of shape (n_voters, n_cands, n_elections) or (n_elections, n_voters, n_cands), whichever makes more sense, and return a list of winners for each election.
(n_voters, n_cands, n_elections)
(n_elections, n_voters, n_cands)
np.array((impartial_culture(5, 4), impartial_culture(5, 4))) Out[16]: array([[[1, 2, 0, 3], [2, 1, 3, 0], [3, 0, 1, 2], [3, 1, 2, 0], [2, 3, 0, 1]], [[0, 2, 3, 1], [2, 3, 1, 0], [1, 3, 2, 0], [2, 1, 0, 3], [0, 2, 3, 1]]], dtype=uint8) _.shape Out[17]: (2, 5, 4)
Huge elections would run out of memory, but still would be faster than processing them in a loop.
a = np.empty((100000, 10000, 10), dtype=np.uint8) MemoryError
Need to
I think all of these functions could accept 3D arrays of shape
(n_voters, n_cands, n_elections)
or(n_elections, n_voters, n_cands)
, whichever makes more sense, and return a list of winners for each election.