def inspect_mp(df, preprocessing=None, seed=1):
    if preprocessing is None:
        print("Assembling preprocessing pipeline...")

        def preprocessing(dsv):
            for function in inspect.pipeline:
                dsv = function(dsv)
            return dsv

    print("Splitting dataset...")
    groups = split_to_groups(df)
    dsvs = []
    for group, group_name in zip(groups, group_names):
        print("Preprocessing group %s..." % group_name)
        columns = list(group.columns)
        columns.pop(columns.index('client_id'))
        dsv = group[columns].to_numpy()
        dsv = preprocessing(dsv)
        dsvs.append(dsv)
    print("Projecting...")
    pool = mp.Pool(6)
    projections = pool.map(partial(project, seed=seed), dsvs)
    pool.close()
    print("Plotting...")
    fig, axs = plt.subplots(2, 3)
    for projection, group_name, ax in zip(projections, group_names,
                                          axs.flatten()):
        ax.scatter(*projection)
        ax.set_title(group_name)
    plt.show()
    cache = []
    for projection, dsv in zip(projections, dsvs):
        cache.append((__signature__project(dsv, seed, 30), projection))
    save_data(dict(cache), "projection_cache")
Exemple #2
0
def pop_up_help():
    h, w = 100, 100

    # manual = curses.newpad(h, w)
    manual = curses.newpad(h, w)
    manual.box()
    manual.addstr(1,2,'{:30}'.format("Linux-Sheets User Manual") + "press 'b' to go back")
    manual.addstr(3,2,"Navigation:")
    manual.addstr(4,2,'{:30}'.format("Basic Movement") + "arrow keys")
    manual.addstr(5,2,'{:30}'.format("Quick scroll(up)") + key_mappings.QUICK_UP)
    manual.addstr(6,2,'{:30}'.format("Quick scroll(down)") + key_mappings.QUICK_DOWN)
    manual.addstr(7,2,'{:30}'.format("Quick scroll(left)") + key_mappings.QUICK_LEFT)
    manual.addstr(8,2,'{:30}'.format("Quick scroll(right)") + key_mappings.QUICK_RIGHT)

    manual.addstr(10,2,"Features:")
    manual.addstr(11,2,'{:30}'.format("Insert data") + key_mappings.INSERT)
    manual.addstr(12,2,'{:30}'.format("Delete cell") + key_mappings.DELETE_CELL)
    manual.addstr(13,2,'{:30}'.format("Insert row") + key_mappings.INSERT_ROW)
    manual.addstr(14,2,'{:30}'.format("Insert column") + key_mappings.INSERT_COL)
    manual.addstr(15,2,'{:30}'.format("Delete row") + key_mappings.DELETE_ROW)
    manual.addstr(16,2,'{:30}'.format("Delete column") + key_mappings.DELETE_COL)
    manual.addstr(17,2,'{:30}'.format("Copy") + key_mappings.COPY)
    manual.addstr(18,2,'{:30}'.format("Paste") + key_mappings.PASTE)
    manual.addstr(19,2,'{:30}'.format("Undo") + key_mappings.UNDO)
    manual.addstr(20,2,'{:30}'.format("Redo") + key_mappings.REDO)
    manual.addstr(21,2,'{:30}'.format("Search") + key_mappings.SEARCH)
    manual.addstr(22,2,'{:30}'.format("Visual mode") + key_mappings.VISUAL_MODE)
    manual.addstr(23,2,'{:30}'.format("Help") + key_mappings.HELP)

    manual.addstr(25,2,"Commands that start with ':'")
    manual.addstr(26,2,'{:30}'.format("Go to") + "type: 'row, column'")
    manual.addstr(27,2,'{:30}'.format("Quit") + key_mappings.QUIT)
    manual.addstr(28,2,'{:30}'.format("Save and quit") + key_mappings.SAVE_AND_QUIT)

    manual.refresh(0, 0, 0, 0, settings.h - 1, settings.w - 1)

    exit_menu = False
    manual_y = 0
    manual_x = 0
    while True:
        key = settings.stdscr.getch()
        if key == ord(':'):
            from Clark_Sheets import write_to_bottom
            command = write_to_bottom(':')
            if command == key_mappings.SAVE_AND_QUIT:
                settings.user_exited = True
                save_data()
                break
            elif command == key_mappings.QUIT:
                settings.user_exited = True
                break
        elif key == ord('b'): #escape key
            settings.stdscr.clear()
            break
        elif key == curses.KEY_RESIZE:
            from Clark_Sheets import handle_resize
            handle_resize(key)
        manual.refresh(0, 0, 0, 0, settings.h - 1, settings.w - 1)
Exemple #3
0
def handle_colon_commands(command):
    # handle all big commands with ':'
    if command == key_mappings.SAVE_AND_QUIT:
        settings.user_exited = True
        save_data()
    elif command == key_mappings.QUIT:
        settings.user_exited = True
    elif ',' in command:
        y, x = str_to_coordinates(command)
        if y != -1 and x != -1:
            go_to(y, x)
def main():
    data = d.get_data()
    d.save_data(data)
    decrypted = c.decrypt(data['cifrado'], data['numero_casas'])

    hashed = hashlib.sha1(decrypted.encode())

    data['decifrado'] = decrypted
    data['resumo_criptografico'] = hashed.hexdigest()

    d.save_data(data)
    d.post_file()
def data_comparing_test():
    ballId = p.loadURDF("sphere2red.urdf", [0.5, 0, 0], globalScaling=0.1, useFixedBase=True)
    joints = [0]*7
    pos = [0]*3
    orn = [0]*4
    target_pos = [0] * 3
    target_orn = [0] * 4
    for i in range(10000):
        joints, target_pos, target_orn = generate_pos(kukaId, joints, target_pos, target_orn, i)
        p.setJointMotorControlArray(kukaId, range(numjoints), p.POSITION_CONTROL, targetPositions=joints, targetVelocities=[0,0,0,0,0,0,0])
        #   print_joint_states(kukaId)
        for _ in range(1000):
            p.stepSimulation()
        # vykradeno z https://github.com/bulletphysics/bullet3/issues/1616
        # pos, orn, _, _, _, _ = p.getLinkState(kukaId, numjoints - 1)
        # view_matrix, camera_vector = calc_view_matrix(pos, orn)
        # img = p.getCameraImage(192, 128, view_matrix, projection_matrix)
        # img, pos, camera_vector = img_wrapper(kukaId)
        pos, orn = my_getLinkState(kukaId)
        view_matrix, camvec = calc_view_matrix(pos, orn)
        p.resetBasePositionAndOrientation(ballId, pos + 0.2 * camvec, p.getQuaternionFromEuler((0, 0, 0)))
        img = my_getCameraImage(view_matrix, projection_matrix)
        # img, pos, camera_vector = img_wrapper(kukaId)
        print()
        print(f"------------- iteration {i} over")
        print(f"positions are {joints}")
        save_data(kukaId, 42)

        print(target_pos)
        print(target_orn)
        print(f"--- camera position comparison for iteration = {i}")
        for j in range(len(pos)):
            diff = target_pos[j] - pos[j]
            print(f"pos[{j}]: target: {target_pos[j]:.4}     real: {pos[j]:.4}     difference: {diff:.4f}")

        for j in range(len(orn)):
            diff = target_orn[j] - orn[j]
            print(f"orn[{j}]: target: {target_orn[j]:.4}     real: {orn[j]:.4}     difference: {diff:.4}")

        print(f"--- Joints comparison for iteration = {i}")
        compare_joints(kukaId, 'data42')
        print()
        time.sleep(1)
Exemple #6
0
def create_dataset():
    img = p.loadURDF("img.urdf", [x_img, y_img, z_img],
                     globalScaling=1,
                     useFixedBase=True)
    textureId = p.loadTexture("pls.png")  #nefunguje mi (Míra)
    p.changeVisualShape(img, -1, textureUniqueId=textureId)

    # joints = p.calculateInverseKinematics(kukaId, 6, [x_img, y_img, z_img + arm_distance],
    #                                       p.getQuaternionFromEuler([np.pi, 0, 0]), maxNumIterations=100)
    # joints = np.array([0, 0.5, 0, -1.5, 0, 1.15, -math.pi/2])
    # move(joints)

    joints = np.array([0, 0.5, 0, -1.5, 0, 1.15, -math.pi / 2])
    move(joints)
    # img_data, pos1, camera_vector = img_wrapper(kukaId)
    # time.sleep(10)
    # d.save_data(kukaId, num=999999, img_data=img_data)
    # return

    X, Y, Z = gnr.generate_position(x_img, x_width, y_img, y_width,
                                    z_img + arm_distance, z_width, sample_size)
    oriantations = gnr.generate_camera_angles(sigma=angles_width,
                                              sample_size=sample_size)

    for k in range(sample_size):
        pos = (X[k], Y[k], Z[k])
        orn = oriantations[k]

        joints = p.calculateInverseKinematics(kukaId,
                                              6,
                                              pos,
                                              orn,
                                              maxNumIterations=100)
        move(joints)

        # view_matrix, camvec = calc_view_matrix(pos, orn)
        img_data, pos1, camera_vector = img_wrapper(kukaId)

        d.save_data(kukaId, num=k, img_data=img_data)
Exemple #7
0
def create_dataset():
    length_img = 0.15
    width_img = 0.10

    x_img = 0.58
    y_img = 0
    z_img = 0.25

    # 20cm:
    domain = 0.1
    mean = 0
    step = 0.01

    iter_num = (int)(domain * 2 / step)

    img = p.loadURDF("img.urdf", [x_img, y_img, z_img],
                     globalScaling=1,
                     useFixedBase=True)

    #   random_texture(img)

    joints = np.array([0, 0.5, 0, -1.5, 0, 1.15, -math.pi / 2])

    move(joints)

    for i in range(3):
        print("----------Interation", i)

        pos, orn = my_getLinkState(kukaId)

        pos = np.array(pos)
        orn = np.array(orn)

        print(orn)
        if i == 0:
            pos[0] = pos[0] + 0.015
            pos[2] = pos[2] - 0.03

        if i < 2:
            joints = p.calculateInverseKinematics(kukaId,
                                                  6,
                                                  pos,
                                                  orn,
                                                  maxNumIterations=100)
            #          add_const(joints)

            view_matrix, camvec = calc_view_matrix(pos, orn)
            #      img = my_getCameraImage(view_matrix, projection_matrix)
            img, pos, camera_vector = img_wrapper(kukaId)

            move(joints)
            time.sleep(1)

    #       d.save_data(kukaId, i)

        if i >= 2:
            #         X,Y,Z = py_bivariate_normal_pdf(0.15, 0, .01)#30cm
            X, Y, Z = py_bivariate_normal_pdf(domain, mean, step)

            for k in range(iter_num + 2):
                pos, orn = my_getLinkState(kukaId)
                pos = np.array(pos)
                vys = pos[2] - z_img
                ax = abs(pos[1] - y_img)
                x = calc_angle(ax, vys)

                for j in range(iter_num + 2):
                    pos, orn = my_getLinkState(kukaId)
                    pos = np.array(pos)

                    pos[0] = X[k][j] + x_img
                    pos[1] = Y[k][j] + y_img
                    pos[2] = Z[k][j] + z_img + 0.07 - 0.5921  #-0.4968752
                    #    orn = [0.70710607, -0.70709531, -0.0029381,   0.00293214]

                    vys = pos[2] - z_img

                    az = abs(pos[0] - x_img)
                    ax = abs(pos[1] - y_img)

                    z = calc_angle(az, vys)

                    if j == 0:
                        euler = p.getEulerFromQuaternion(orn)
                        euler = np.array(euler)
                        if k == 0:
                            euler0 = euler[0]
                            euler1 = euler[1]
                            x = calc_angle(ax, 0.07)
                        euler[0] = euler0 + z
                        if k <= iter_num / 2:
                            euler[1] = euler1 + x
                        else:
                            euler[1] = euler1 - x
                        orn = p.getQuaternionFromEuler(euler)

                    if j > 0:
                        euler = p.getEulerFromQuaternion(orn)
                        euler = np.array(euler)
                        if j <= iter_num / 2:
                            euler[0] = euler0 + z
                        else:
                            euler[0] = euler0 - z
                        orn = p.getQuaternionFromEuler(euler)

                    joints = p.calculateInverseKinematics(kukaId,
                                                          6,
                                                          pos,
                                                          orn,
                                                          maxNumIterations=100)
                    #          add_const(joints)
                    move(joints)

                    view_matrix, camvec = calc_view_matrix(pos, orn)
                    #         img = my_getCameraImage(view_matrix, projection_matrix)
                    img, pos1, camera_vector = img_wrapper(kukaId)
                    #        time.sleep(3)
                    d.save_data(kukaId, k)
Exemple #8
0
def main(stdscr):
    settings.stdscr = stdscr
    settings.c_manager = command_manager()
    settings.file_name = sys.argv[1]
    # set the format that the program will use (either normal CSV with commas or my own with coordinates)
    # settings.format = "my_format"
    settings.format = "CSV"
    read_data()

    # check if file exceeds max boundaries
    if settings.grid_h_cap < len(
            settings.contents) or settings.grid_w_cap < len(
                settings.contents[0] * settings.cell_w):
        sys.exit("The file you tried to open was too large")

    # determine if we are opening the program or just executing commands and then closing
    # If there are more than 2 arguments, the user is sending in commands to be done on the file
    if len(sys.argv) > 2:
        # set bool to true so when calling big commands, we can pass in commands and it will know to parse them
        settings.passed_commands = True
        testing = sys.argv[2] is "testing"

        if testing:
            # start iterating at the 4th argument and go through all system arguments
            for arg in sys.argv[3:]:
                big_commands(arg)
                save_data(sys.argv[-1])
        else:
            # start iterating at the 3rd argument and go through all system arguments
            for arg in sys.argv[2:]:
                big_commands(arg)
                save_data(sys.argv[1])
    # Otherwise, open the program normally with the specified file
    else:
        # set bool to true so when calling big commands, it parses user inputted command when program is running
        settings.passed_commands = False
        # create color schemes for the top and bottom margins
        curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)

        # get dimensions
        settings.h, settings.w = settings.stdscr.getmaxyx()
        settings.grid_h, settings.grid_w = get_dimensions()

        # initial drawing of grid
        create_without_grid_lines()

        # we might need to resize initial grid
        if settings.grid_total_h < len(settings.contents):
            check_grid_resize(
                len(settings.contents) - settings.grid_total_h, 0)
        if settings.grid_total_w < len(settings.contents[0] * settings.cell_w):
            check_grid_resize(
                0,
                len(settings.contents[0]) * settings.cell_w -
                settings.grid_total_w)

        refresh_grid()

        # main loop
        while settings.user_exited == False:
            # read in user input
            key = settings.stdscr.getch()
            handle_visual_mode(key)
            handle_basic_navigation(key)
            handle_resize(key)
            if not settings.visual_mode:
                handle_help_menu(key)
                handle_inserting(key)
                handle_commands(key)
            handle_big_commands(key)
            handle_grid_update(key)