Esempio n. 1
0
def main(args):
    game, serial = gameio.read_sample_game(json.load(args.input))
    profiles = np.concatenate([serial.from_prof_json(p)[None] for p
                               in scriptutils.load_profiles(args.profiles)])
    bootf, meanf = CHOICES[args.type]
    results = bootf(game, profiles, args.num_bootstraps, args.percentiles,
                    args.processes)
    if args.percentiles is None:
        args.percentiles = np.linspace(0, 100, args.num_bootstraps)
    percentile_strings = [str(p).rstrip('0').rstrip('.')
                          for p in args.percentiles]
    jresults = [{p: v.item() for p, v in zip(percentile_strings, boots)}
                for boots in results]
    if args.mean:
        for jres, mix in zip(jresults, profiles):
            jres['mean'] = meanf(game, mix)

    json.dump(jresults, args.output)
    args.output.write('\n')
Esempio n. 2
0
def test_sample_game_from_json(json_):
    with warnings.catch_warnings():
        warnings.filterwarnings('ignore',
                                message='Truncating observation data')
        gameio.read_sample_game(json_)
Esempio n. 3
0
def test_json_copy_sample_game(game_size, samples):
    base = gamegen.role_symmetric_game(*game_size)
    game1 = gamegen.add_noise(base, 1, samples)
    serial = gamegen.game_serializer(game1)
    game2, _ = gameio.read_sample_game(game1.to_json(serial))
    assert game1 == game2