# Path: lfd/rapprentice/eval_util.py
# class EvalStats(object):
#     def __init__(self, **kwargs):
# def get_indexed_items(itemsfile, task_list=None, task_file=None, i_start=-1, i_end=-1):
# def add_obj_to_group(group, k, v):
# def group_or_dataset_to_obj(group_or_dataset):
# def save_results_args(fname, args):
# def load_results_args(fname):
# def save_task_results_step(fname, task_index, step_index, results):
# def load_task_results_step(fname, task_index, step_index):
# def traj_collisions(sim_env, full_traj, collision_dist_threshold, upsample=0):
# def traj_is_safe(sim_env, full_traj, collision_dist_threshold, upsample=0):


import argparse
import h5py
from lfd.rapprentice import eval_util

def estimate_performance(fname):
    results_file = h5py.File(fname, 'r')
    loadresult_items = eval_util.get_indexed_items(results_file)

    num_knots = 0
    num_misgrasps = 0
    num_infeasible = 0
    action_time = 0
    exec_time = 0

    for i_task, task_info in loadresult_items:
        knot_exists = False
        infeasible = False
        misgrasp = False

        for i_step in range(len(task_info)):

# Path: lfd/rapprentice/eval_util.py
# class EvalStats(object):
#     def __init__(self, **kwargs):
# def get_indexed_items(itemsfile, task_list=None, task_file=None, i_start=-1, i_end=-1):
# def add_obj_to_group(group, k, v):
# def group_or_dataset_to_obj(group_or_dataset):
# def save_results_args(fname, args):
# def load_results_args(fname):
# def save_task_results_step(fname, task_index, step_index, results):
# def load_task_results_step(fname, task_index, step_index):
# def traj_collisions(sim_env, full_traj, collision_dist_threshold, upsample=0):
# def traj_is_safe(sim_env, full_traj, collision_dist_threshold, upsample=0):


# Path: scripts/auto_performance.py
import argparse
import h5py
from lfd.rapprentice import eval_util


def estimate_performance(fname):
    results_file = h5py.File(fname, 'r')
    loadresult_items = eval_util.get_indexed_items(results_file)

    num_knots = 0
    num_misgrasps = 0
    num_infeasible = 0
    action_time = 0
    exec_time = 0

    for i_task, task_info in loadresult_items:
        knot_exists = False
        infeasible = False
        misgrasp = False

        for i_step in range(len(task_info)):

            results = eval_util.load_task_results_step(fname, i_task, i_step)