def test_random_identity_rsym(_): num_strats = rand.randint(2, 20) profile = rand.randint(20, size=num_strats)[None] reduced_players = profile.sum() while reduced_players < 2: profile[0, rand.randint(num_strats)] += 1 # pragma: no cover reduced_players += 1 # pragma: no cover full_players = rand.randint(reduced_players + 1, reduced_players ** 2) game = rsgame.BaseGame(reduced_players, num_strats) rp = np.array([reduced_players]) fp = np.array([full_players]) full_profile = reduction._expand_rsym_profiles(game, profile, fp, rp) red_profile, valid = reduction._reduce_rsym_profiles(game, full_profile, fp, rp) assert np.all(valid), \ "reduction wasn't valid, but it definitely was:\n{}\n{}".format( profile, full_profile) assert np.all(red_profile == profile), \ "reduction was valid, but not identity:\n{}\n{}\n{}".format( profile, full_profile, red_profile)
def expand(prof, full, red): return reduction._expand_rsym_profiles( rsgame.BaseGame(1, len(prof)), np.asarray(prof)[None], np.array([full]), np.array([red]))