# Path: util/visdom_util.py
# def visdom_initialize(args):
# def visdom_plot_curve(it, val, viz_win=None, title=''):
# def visdom_print_info(str_list, mytitle):
# def viz_line(i, vals, viz_win=None, 
#              title='', xlabel='', ylabel='', 
#              legend=None):
# def vis_stem_as_hist(samples):
# def vis_hist_plot(i, samples, viz_win=None, title='', numbin=20):
#     X = [np.array([i]) for _ in range(data_num)]
#     Y = [np.array([val]) for val in vals]
#         X = np.column_stack(X)
#         Y = np.column_stack(Y)
#         X = X[-1]
#         Y = Y[-1]


import init_path
import os
import numpy as np
import argparse
import json
import glob
from pprint import pprint
from util import visdom_util
    from html_visual import vis_tree


        # getting all the parent's id
        p_id_list = curr_data['PrtID']
        prev_gen_spc = prev_data['SpcID']

        species_needed = [(curr_data['SpcID'][j], x) \
            for j, x in enumerate(p_id_list) \
            if x in prev_gen_spc 
        ]

        # create the reward
        p_r, c_r = [], []
        for pc_pair in species_needed:
            child, parent = pc_pair
            p_r.append(prev_data['AvgRwd'][prev_data['SpcID'].index(parent)])
            c_r.append(curr_data['AvgRwd'][curr_data['SpcID'].index(child)])

        pc_performance_list.append( (sum(p_r)/len(p_r), sum(c_r)/len(c_r)) )

    # use visdom to plot the line
    win1 = None
    win2 = None
    for i, val in enumerate(pc_performance_list):
        v1, v2 = val
        win1 = visdom_util.viz_line(i, [v1, v2], viz_win=win1,
            title='Avg Parent-child performance comparison',
            xlabel='Generation', ylabel='Average Reward',
            legend=['Parent', 'Child']
        )

# Path: util/visdom_util.py
# def visdom_initialize(args):
# def visdom_plot_curve(it, val, viz_win=None, title=''):
# def visdom_print_info(str_list, mytitle):
# def viz_line(i, vals, viz_win=None, 
#              title='', xlabel='', ylabel='', 
#              legend=None):
# def vis_stem_as_hist(samples):
# def vis_hist_plot(i, samples, viz_win=None, title='', numbin=20):
#     X = [np.array([i]) for _ in range(data_num)]
#     Y = [np.array([val]) for val in vals]
#         X = np.column_stack(X)
#         Y = np.column_stack(Y)
#         X = X[-1]
#         Y = Y[-1]


# Path: html_visual/vis_spc_tree.py
import init_path
import os
import numpy as np
import argparse
import json
import glob
from pprint import pprint
from util import visdom_util
    from html_visual import vis_tree



        # getting all the parent's id
        p_id_list = curr_data['PrtID']
        prev_gen_spc = prev_data['SpcID']

        species_needed = [(curr_data['SpcID'][j], x) \
            for j, x in enumerate(p_id_list) \
            if x in prev_gen_spc 
        ]

        # create the reward
        p_r, c_r = [], []
        for pc_pair in species_needed:
            child, parent = pc_pair
            p_r.append(prev_data['AvgRwd'][prev_data['SpcID'].index(parent)])
            c_r.append(curr_data['AvgRwd'][curr_data['SpcID'].index(child)])

        pc_performance_list.append( (sum(p_r)/len(p_r), sum(c_r)/len(c_r)) )

    # use visdom to plot the line
    win1 = None
    win2 = None
    for i, val in enumerate(pc_performance_list):
        v1, v2 = val
        win1 = visdom_util.viz_line(i, [v1, v2], viz_win=win1,
            title='Avg Parent-child performance comparison',
            xlabel='Generation', ylabel='Average Reward',
            legend=['Parent', 'Child']
        )

        win2 = visdom_util.viz_line(i, [ (v2 - v1) / v1 ], viz_win=win2,