How to use the ipdb.set_trace function in ipdb

To help you get started, we’ve selected a few ipdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BerkeleyAutomation / cloth_simulation / temp.py View on Github external
def rollout(env, policy, flag=False, wait=False, render=False):
    observations, actions, rewards = [], [], []
    if flag:
        env = env._wrapped_env
    if wait:
        import ipdb; ipdb.set_trace()
    observation = env.reset()
    total = len(env.simulation.cloth.shapepts)
    while not env.traj_index >= len(env.trajectory) - 1:
        if render:
            env.render()
        action = policy.get_action(np.array(observation))[0]
        actions.append(action)
        observations.append(observation)
        observation, reward, terminal, _ = env.step(action)
        rewards.append(reward)
    print(rewards)
    print "Score", total - len(env.simulation.cloth.shapepts)
    return env.simulation.cloth.evaluate()
github angr / angr / angr / analyses / binary_optimizer.py View on Github external
if (successor1.variable.base == 'sp' and successor1.variable.offset > 0) or \
                                (successor1.variable.base == 'bp' and successor1.variable.offset < 0):
                            # yes it's copied onto the stack!
                            argument_to_local[argument_variable] = successor1

                # if the register is eax, and it's not killed later, it might be the return value of this function
                # in that case, we cannot eliminate the instruction that moves stack argument to that register
                if successors0[0].variable.reg == self.project.arch.registers['eax'][0]:
                    killers = [ s for _, s, data in out_edges if 'type' in data and data['type'] == 'kill']
                    if not killers:
                        # it might be the return value
                        argument_register_as_retval.add(argument_variable)

            else:
                # TODO:
                import ipdb; ipdb.set_trace()

        #import pprint
        #pprint.pprint(argument_to_local, width=160)

        # find local correspondence that are not modified throughout this function
        redundant_stack_variables = [ ]

        for argument, local_var in argument_to_local.items():
            # local_var cannot be killed anywhere
            out_edges = data_graph.out_edges(local_var, data=True)

            consuming_locs = [ ]

            for _, consumer, data in out_edges:
                consuming_locs.append(consumer.location)
                if 'type' in data and data['type'] == 'kill':
github aalitaiga / sim-to-real / scripts / range_variable.py View on Github external
DATASET_PATH = DATASET_PATH_REL + "mujoco_data_pusher3dof_big_backl.h5"
# DATASET_PATH = "/Tmp/alitaiga/mujoco_data_pusher3dof_big_backl.h5"
batch_size = 1
train_data = H5PYDataset(
    DATASET_PATH, which_sets=('train',), sources=('s_transition_obs','r_transition_obs', 'obs', 'actions')
)
stream_train = DataStream(train_data, iteration_scheme=SequentialScheme(train_data.num_examples, train_data.num_examples))
valid_data = H5PYDataset(
    DATASET_PATH, which_sets=('valid',), sources=('s_transition_obs','r_transition_obs', 'obs', 'actions')
)
stream_valid = DataStream(valid_data, iteration_scheme=SequentialScheme(train_data.num_examples, batch_size))

iterator = stream_train.get_epoch_iterator(as_dict=True)

data = next(iterator)
import ipdb; ipdb.set_trace()

## Max, min  mean std obs:
[2.56284189, 2.3500247, 2.39507723, 7.40329409, 9.20471668, 15.37792397]
[-0.12052701, -0.17479207, -0.73818409, -1.25026512, -3.95599413, -4.73272848]
[2.25090551, 1.94997263, 1.6495719, 0.43379614, 0.3314755, 0.43763939]
[0.5295766 ,  0.51998389,  0.57609886,  1.35480666, 1.40806067, 2.43865967]


# max_obs = np.zeros((6,))
# max_sim = np.zeros((6,))
# max_real = np.zeros((6,))
# max_act = np.zeros((3,))
# max_cor = np.zeros((6,))
# j = 0
#
# for i, data in enumerate(iterator):
github madcowswe / ODrive / tools / motion_planning / PlanTrap.py View on Github external
error = True
    if abs(Xi-y[0]) > 0.0001:
        print("---------- Bad Initial Position --------------------")
        error = True
    if abs(Xf-y[-1]) > 0.0001:
        print("---------- Bad Final Position --------------------")
        error = True
    if abs(Vi-yd[0]) > 0.0001:
        print("---------- Bad Initial Velocity --------------------")
        error = True
    if abs(yd[-1]) > 0.0001:
        print("---------- Bad Final Velocity --------------------")
        error = True

    if error:
        import ipdb; ipdb.set_trace()

    return (y, yd, ydd, t_traj)
github enigmampc / catalyst / catalyst / support / issue_216.py View on Github external
context.base_prices = context.candles_close
    cash = context.portfolio.cash
    amount = context.portfolio.positions[context.coin_pair].amount
    price = data.current(context.coin_pair, 'price')
    # order_id = None
    context.last_base_price = context.base_prices[-2]
    context.curr_base_price = context.base_prices[-1]

    # TA calculations
    # ...

    # Sanity checks
    # assert cash >= 0
    if cash < 0:
        import ipdb
        ipdb.set_trace()  # BREAKPOINT

    print_facts(context)
    print_facts_telegram(context)

    # Order management
    # net_shares = 0
    if context.counter == 2:
        pass
        brute_shares = (cash / price) * context.parameters.BUY_PERCENTAGE
        share_commission_fee = brute_shares * context.parameters.COMMISSION_FEE
        net_shares = brute_shares - share_commission_fee
        buy_order_id = order(context.coin_pair, net_shares)
        print(buy_order_id)

    if context.counter == 3:
        pass
github thehub / hubplus / apps / plus_lib / utils.py View on Github external
def g(*args, **kwargs):
        try :
            f(*args,**kwargs)
        except Exception, e :
            import ipdb
            ipdb.set_trace()
    return g
github EdinburghNLP / nematus / session3 / lm.py View on Github external
def pred_probs(f_log_probs, prepare_data, options, iterator, verbose=True):
    probs = []

    n_done = 0

    for x in iterator:
        n_done += len(x)

        x, x_mask = prepare_data(x, n_words=options['n_words'])

        pprobs = f_log_probs(x, x_mask)
        for pp in pprobs:
            probs.append(pp)

        if numpy.isnan(numpy.mean(probs)):
            import ipdb; ipdb.set_trace()

        if verbose:
            print >>sys.stderr, '%d samples computed'%(n_done)

    return numpy.array(probs)
github eBay / bayesian-belief-networks / bayesian / examples / undirected_graphs / monty.py View on Github external
if __name__ == '__main__':

    g = build_bbn(
        f_prize_door,
        f_guest_door,
        f_monty_door,
        domains=dict(
            prize_door=['A', 'B', 'C'],
            guest_door=['A', 'B', 'C'],
            monty_door=['A', 'B', 'C']))

    fg = build_monty_factor_graph_from_bbn(g)
    fg2 = g.convert_to_factor_graph()
    fg.q()
    import ipdb; ipdb.set_trace()
    fg2.q()
github intel / workload-collocation-agent / workloads / wrapper / wrapper / wrapper_main.py View on Github external
def debug():
    """Debug hook to allow entering debug mode in compiled pex.
    Run it as PEX_MODULE=wrapper.wrapper_main:debug
    """
    import warnings
    try:
        import ipdb as pdb
    except ImportError:
        warnings.warn('ipdb not available, using pdb')
        import pdb
    pdb.set_trace()
    main()