How to use dotmap - 10 common examples

To help you get started, we’ve selected a few dotmap 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 smlbansal / Visual-Navigation-Release / tests / test_spline.py View on Github external
goal_pos_nk2 = tf.concat([goal_posx_nk1, goal_posy_nk1], axis=2)
    goal_heading_nk1 = tf.ones((n, 1, 1), dtype=tf.float32) * target_state[2]
    goal_speed_nk1 = tf.ones((n, 1, 1), dtype=tf.float32) * vf

    start_config = SystemConfig(dt, n, 1, speed_nk1=start_speed_nk1, variable=False)
    goal_config = SystemConfig(dt, n, 1, position_nk2=goal_pos_nk2,
                               speed_nk1=goal_speed_nk1, heading_nk1=goal_heading_nk1,
                               variable=True)

    start_nk5 = start_config.position_heading_speed_and_angular_speed_nk5()
    start_n5 = start_nk5[:, 0]

    goal_nk5 = goal_config.position_heading_speed_and_angular_speed_nk5()
    goal_n5 = goal_nk5[:, 0]

    p = DotMap(spline_params=DotMap(epsilon=1e-5))
    ts_nk = tf.tile(tf.linspace(0., dt*k, k)[None], [n, 1])
    spline_traj = Spline3rdOrder(dt=dt, k=k, n=n, params=p.spline_params)
    spline_traj.fit(start_config, goal_config, factors=None)
    spline_traj.eval_spline(ts_nk, calculate_speeds=True)

    pos_nk3 = spline_traj.position_and_heading_nk3()
    v_nk1 = spline_traj.speed_nk1()
    start_pos_diff = (pos_nk3 - start_n5[:, None, :3])[:, 0]
    goal_pos_diff = (pos_nk3 - goal_n5[:, None, :3])[:, -1]
    assert(np.allclose(start_pos_diff, np.zeros((n, 3)), atol=1e-6))
    assert(np.allclose(goal_pos_diff, np.zeros((n, 3)), atol=1e-6))

    start_vel_diff = (v_nk1 - start_n5[:, None, 3:4])[:, 0]
    goal_vel_diff = (v_nk1 - goal_n5[:, None, 3:4])[:, -1]
    assert(np.allclose(start_vel_diff, np.zeros((n, 1)), atol=1e-6))
    assert(np.allclose(goal_vel_diff, np.zeros((n, 1)), atol=1e-6))
github smlbansal / Visual-Navigation-Release / tests / test_dynamics.py View on Github external
def create_system_dynamics_params():
    p = DotMap()

    p.v_bounds = [0.0, .6]
    p.w_bounds = [-1.1, 1.1]

    p.simulation_params = DotMap(simulation_mode='ideal',
                                 noise_params = DotMap(is_noisy=False,
                                                       noise_type='uniform',
                                                       noise_lb=[-0.02, -0.02, 0.],
                                                       noise_ub=[0.02, 0.02, 0.],
                                                       noise_mean=[0., 0., 0.],
                                                       noise_std=[0.02, 0.02, 0.]))
    return p
github smlbansal / Visual-Navigation-Release / tests / test_goal_angle_objective.py View on Github external
def create_params():
    p = DotMap()
    # Angle Distance parameters
    p.goal_angle_objective = DotMap(power=1,
                                    angle_cost=25.0)
    p.obstacle_map_params = DotMap(obstacle_map=SBPDMap,
                                   map_origin_2=[0., 0.],
                                   sampling_thres=2,
                                   plotting_grid_steps=100)
    p.obstacle_map_params.renderer_params = create_renderer_params()

    return p
github smlbansal / Visual-Navigation-Release / tests / test_data_gen.py View on Github external
p = DotMap()
    p.seed = 1
    p.n = 1
    p.k = 15
    p.map_bounds = [[-2.0, -2.0], [2.0, 2.0]]
    p.dx, p.dt = .05, .1
      
    p.lqr_coeffs = DotMap({'quad' : [1.0, 1.0, 1.0, 1e-10, 1e-10],
                                    'linear' : [0.0, 0.0, 0.0, 0.0, 0.0]})
    p.ctrl = 1.

    p.avoid_obstacle_objective = DotMap(obstacle_margin=0.3,
                                        power=2,
                                        obstacle_cost=25.0)
    # Angle Distance parameters
    p.goal_angle_objective = DotMap(power=1,
                                    angle_cost=25.0)
    # Goal Distance parameters
    p.goal_distance_objective = DotMap(power=2,
                                       goal_cost=25.0)

    return p
github drgrib / dotmap / dotmap / __init__.py View on Github external
m.recursive = m
    print(m.recursive.recursive.recursive)
    print(m)
    print(m.toDict())

    # kwarg
    print('\n== kwarg ==')
    def test(**kwargs):
        print(kwargs)
    class D:
        def keys(self):
            return ['a', 'b']
        def __getitem__(self, key):
            return 0
    a = {'1':'a', '2':'b'}
    b = DotMap(a, _dynamic=False)
    o = OrderedDict(a)
    test(**a)
    test(**b.toDict())
    test(**o)
    test(**D())

    # ordering
    print('\n== ordering ==')
    m = DotMap()
    m.alpha = 1
    m.bravo = 2
    m.charlie = 3
    m.delta = 4
    for k,v in m.items():
        print(k,v)
github thulio / dict-to-csv / dict_to_csv / __init__.py View on Github external
import collections
import functools
import typing  # noqa: F401
from contextlib import closing
from io import StringIO

from dotmap import DotMap


def empty_str(_):
    # type: (typing.Any) -> typing.Text
    return ""


DotMap.__str__ = empty_str


def recursive_mapping_iterator(nested_mapping):
    # type: (typing.Mapping) -> typing.Generator[typing.Tuple[typing.Text, typing.Any], None, None]  # noqa: E501
    for key, value in nested_mapping.items():
        if isinstance(value, collections.Mapping):
            for inner_key, inner_value in recursive_mapping_iterator(value):
                yield key + '.' + inner_key, inner_value
        else:
            yield key, value


def recursive_getattr(obj, attributes):
    # type: (typing.Any, typing.Text) -> typing.Any
    return functools.reduce(getattr, [obj] + attributes.split('.'))
github smlbansal / Visual-Navigation-Release / params / renderer_params.py View on Github external
def create_params():
    p = DotMap()
    p.dataset_name = 'sbpd'
    p.building_name = 'area4'
    p.flip = False

    p.camera_params = DotMap(modalities=['occupancy_grid'],  # occupancy_grid, rgb, or depth
                             width=64,
                             height=64,  # the remaining params are for rgb and depth only
                             z_near=.01,
                             z_far=20.0,
                             fov_horizontal=90.,
                             fov_vertical=90.,
                             img_channels=3,
                             im_resize=1.)
    
    # The robot is modeled as a solid cylinder
    # of height, 'height', with radius, 'radius',
github smlbansal / Visual-Navigation-Release / params / system_dynamics / turtlebot_dubins_v2_params.py View on Github external
def create_params():
    p = DotMap()
    p.system = TurtlebotDubinsV2
    p.dt = .05
    p.v_bounds = [0.0, .6]
    p.w_bounds = [-1.1, 1.1]

    # Set the acceleration bounds such that
    # by default they are never hit
    p.linear_acc_max = 10e7
    p.angular_acc_max = 10e7

    p.simulation_params = DotMap(simulation_mode='realistic',
                                 noise_params = DotMap(is_noisy=False,
                                                       noise_type='uniform',
                                                       noise_lb=[-0.02, -0.02, 0.],
                                                       noise_ub=[0.02, 0.02, 0.],
                                                       noise_mean=[0., 0., 0.],
github quanvuong / handful-of-trials-pytorch / config / default.py View on Github external
# Add possible overrides
    type_map.ctrl_cfg.prop_cfg.model_init_cfg.model_dir = str
    type_map.ctrl_cfg.prop_cfg.model_init_cfg.load_model = make_bool

    type_map.ctrl_cfg.prop_cfg.model_train_cfg = DotMap(
        batch_size=int, epochs=int,
        holdout_ratio=float, max_logging=int
    )

    ctrl_cfg.prop_cfg.mode = "TSinf"
    ctrl_cfg.prop_cfg.npart = 20
    # Finish setting model class

    # Setting MPC cfg
    ctrl_cfg.opt_cfg.mode = "CEM"
    type_map.ctrl_cfg.opt_cfg.cfg = DotMap(
        max_iters=int,
        popsize=int,
        num_elites=int,
        epsilon=float,
        alpha=float
    )
    ctrl_cfg.opt_cfg.cfg = cfg_module.OPT_CFG[ctrl_cfg.opt_cfg.mode]
github ConvLab / ConvLab / convlab / modules / word_dst / multiwoz / sumbt / sumbt_config.py View on Github external
from dotmap import DotMap


args = DotMap()

args.max_label_length = 32
args.max_turn_length = 22
args.hidden_dim = 100
args.num_rnn_layers = 1
args.zero_init_rnn = False
args.attn_head = 4
args.do_eval = True
args.do_train = False
args.do_lower_case = False
args.distance_metric = 'cosine'
args.train_batch_size = 4
args.dev_batch_size = 1
args.eval_batch_size  = 16
args.learning_rate = 5e-5
args.num_train_epochs = 3

dotmap

ordered, dynamically-expandable dot-access dictionary

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis

Similar packages