Esempio n. 1
0
def plot_Delta_Y_sum(Y_off_H, Y_el_H, X_ric, F_ric, fontsize=15):
    plt.figure()

    matplotlib.rc('xtick', labelsize=fontsize - 2)
    matplotlib.rc('ytick', labelsize=fontsize - 2)

    data = [(Y_off_H, 'Offline', 'red'), (Y_el_H, 'Online', 'blue')]
    for Y_H, label, color in data:
        Y_avg_orig = load('Y_avg-' + label + '.pkl')
        Y_std_orig = load('Y_std-' + label + '.pkl')

        Y_avg = Y_avg_orig[0::10] / max(Y_avg_orig)
        Y_std = Y_std_orig[0::10] / max(Y_avg_orig)

        x = range(len(Y_avg))
        plt.plot(x, Y_avg, label=label, color=color)
        plot_error(x, Y_avg, Y_std)

    plt.legend(loc=1, fontsize=fontsize)

    plt.xticks((0, 250, 500, 750, 1000, 1250, 1500, 1750, 2000),
               ('0', '2500', '5000', '7500', '10000', '12500', '15000',
                '17500', '20000'),
               fontsize=10)

    # Configure plot
    plt.ylabel(r'$\Delta Y$', fontsize=fontsize)
    plt.xlabel(r'Episode', fontsize=fontsize)
    plt.grid(True)
    plt.tight_layout(h_pad=0., w_pad=0., pad=2)

    plt.savefig('arm_Y.pdf', bbox_inches='tight')

    plt.close()
Esempio n. 2
0
def remoteLoad(openFile):
    global username
    global password
    global hostname
    global ip
    global files
    global dirs
    global fileName
    global usernameContainer
    global passwordContainer
    global hostnameContainer
    global ipContainer
    global filesContainer
    global dirsContainer
    global fileNameContainer
    global crackSecureContainer
    global sysColor0Container
    global sysColor1Container

    global isRemote
    global globalUsername

    global crackSecure
    global sysColor0
    global sysColor1

    global cwd

    usernameContainer = username
    passwordContainer = password
    hostnameContainer = hostname
    ipContainer = ip
    filesContainer = files
    dirsContainer = dirs
    fileNameContainer = fileName
    crackSecureContainer = crackSecure
    sysColor0Container = sysColor0
    sysColor1Container = sysColor1

    username = file.load(openFile, 'username')
    password = file.load(openFile, 'password')
    hostname = file.load(openFile, 'hostname')
    ip = file.load(openFile, 'ip')
    files = file.load(openFile, 'files')
    remoteDirs = file.load(openFile, 'dirs')
    fileName = openFile
    crackSecure = int(file.load(openFile, 'crackSecure'))
    sysColor0 = file.load(openFile, 'sysColor0')
    sysColor1 = file.load(openFile, 'sysColor1')

    isRemote = True

    cwd = '/'  # So as to prevent it from carrying across local and remote.
Esempio n. 3
0
 def __init__(self, root, n):
     color_map_path = root.root.global_settings['PUZZLE']['COLOR_MAPS'][
         'RUBIKS_CUBE']
     super().__init__(root, color_map_path, COLOR_MAP)
     self.color_map = load(color_map_path)
     self.dimension = n
     self.gen()
Esempio n. 4
0
def telnet(ipTry, tryFile="index.html"):
    global ip
    global globalUsername
    global isRemote
    global username
    found = False
    isRemote = True
    for elem in file.parseLs('files/computers.txt'):
        remoteReset()
        errorLog('iter')
        remoteLoad('saves/%s/%s' % (globalUsername, elem))
        if ip == ipTry:
            savFile = 'saves/%s/%s' % (globalUsername, elem)
            username = file.load(savFile, 'username')
            password = file.load(savFile, 'password')
            loginReturn = cracks.autoLogin('remote', savFile, username,
                                           password)
            load()
            found = True
            cdReturns = []
            cdReturns.append(inputLoop(0, 'cd var'))
            cdReturns.append(inputLoop(0, 'cd www'))
            cdReturns.append(inputLoop(0, 'cd html'))
            for elem in cdReturns:
                if elem == "Operation not permitted; no such directory.":
                    print(
                        "The specified file could not be found at this server."
                    )
                    remoteReset()
                    return 3
            catReturn = cat(tryFile)
            if catReturn[0]:
                print(catReturn[1])
                remoteReset()
                return 0
            else:
                remoteReset()
                print("The specified file could not be found at this server.")
                return 1
    if found == False:
        print("Failed to connect to %s." % ipTry)
        remoteReset()
        return 2
Esempio n. 5
0
def update_data(new_data, day):
    months = new_data_by_month(new_data)
    for month in months:
        f = 'data/%s' % month
        try:
            existing_data = file.load(f)
        except FileNotFoundError:
            existing_data = []
        existing_data.extend(months[month])
        file.dump(f, existing_data)
    config['processed'].append(day)
    file.dump('config.json', config)
Esempio n. 6
0
 def open_config_from_file(self, widget):
     file_name = self.open_file_dialog.get_filename()
     if (file_name):
         start, end, errors = file.load(file_name)
         if len(errors.splitlines()) > 3:
             self.error_label.set_text(errors)
         else:
             self.error_label.set_text("")
             self.start_matrix = start
             self.end_matrix = end
             self.load_configuration_matrix(self.start_matrix, 1)
             self.load_configuration_matrix(self.end_matrix, 2)
             self.configuration_window.show()
 def open_config_from_file(self, widget):
     file_name = self.open_file_dialog.get_filename()
     if (file_name):
         start, end, errors = file.load(file_name)
         if len(errors.splitlines()) > 3:
             self.error_label.set_text(errors)
         else:
             self.error_label.set_text("")
             self.start_matrix = start
             self.end_matrix = end
             self.load_configuration_matrix(self.start_matrix, 1)
             self.load_configuration_matrix(self.end_matrix, 2)
             self.configuration_window.show()
Esempio n. 8
0
class Config:

    # Global app conf
    __DEVICE_PREFERENSES = CONFIG_DIR + '/device_preferences.json'
    __KEYBOARD_MAP = CONFIG_DIR + '/events/keyboard_map.json'
    __STANDART_PALETTE = CONFIG_DIR + '/palettes/standart_palette.json'
    __KDE_PALETTE = CONFIG_DIR + '/palettes/kde_palette.json'

    # Geometry data
    __GRID_DATA = CONFIG_DIR + '/geometry/grid.json'
    __CUBE_DATA = CONFIG_DIR + '/geometry/cube.json'
    __TETRAHEDRON_DATA = CONFIG_DIR + '/geometry/tetrahedron.json'
    __POLYHEDRON_DATA_DIR = CONFIG_DIR + '/geometry/polyhedrons/'

    # Color data
    __RUBIKS_CUBE_COLOR_MAP = CONFIG_DIR + '/maps/rubiks_cube_color_map.json'
    __MIRROR_CUBE_COLOR_MAP = CONFIG_DIR + '/maps/mirror_cube_color_map.json'

    __PUZZLE_COLOR_MAPS = {
        'RUBIKS_CUBE': __RUBIKS_CUBE_COLOR_MAP,
        'MIRROR_CUBE': __MIRROR_CUBE_COLOR_MAP
    }

    __PRIMITIVE_DATA = {
        'REGULAR': {
            'CUBE': load(__CUBE_DATA),
            'GRID': load(__GRID_DATA),
            'TETRAHEDRON': load(__TETRAHEDRON_DATA),
        },
        'POLYHEDRONS': __POLYHEDRON_DATA_DIR
    }

    __VIEWPORT_SETTINGS = {
        'DEVICE': load(__DEVICE_PREFERENSES),
        'PALETTES': {
            'STD': load(__STANDART_PALETTE),
            'KDE': load(__KDE_PALETTE)
        }
    }

    __EVENTS_SETTINGS = {'KEYBOARD': load(__KEYBOARD_MAP)}

    __PUZZLE_SETTINGS = {
        'PRIMITIVES': __PRIMITIVE_DATA,
        'COLOR_MAPS': __PUZZLE_COLOR_MAPS
    }

    GLOBAL_SETTINGS = {
        'VIEWPORT': __VIEWPORT_SETTINGS,
        'PUZZLE': __PUZZLE_SETTINGS,
        'EVENTS': __EVENTS_SETTINGS
    }
Esempio n. 9
0
def load():
    global username
    global password
    global hostname
    global ip
    global files
    global dirs
    global fileName
    global crackSecure
    global sysColor0
    global sysColor1
    username = file.load(fileName, 'username')
    password = file.load(fileName, 'password')
    hostname = file.load(fileName, 'hostname')
    ip = file.load(fileName, 'ip')
    files = file.load(fileName, 'files')
    dirs = file.load(fileName, 'dirs')
    crackSecure = int(file.load(fileName, 'crackSecure'))
    sysColor0 = file.load(fileName, 'sysColor0')
    sysColor1 = file.load(fileName, 'sysColor1')
Esempio n. 10
0
def returnProbe():
    files = file.parseLs("files/computers.txt")
    returnList = []
    for elem in files:
        returnList.append(file.load("defaults/" + elem, 'ip'))
    returnStr = ""
    elems = len(returnList)
    iterations = 0
    for elem in returnList:
        iterations += 1
        if iterations != elems:
            returnStr += elem + '\n'
        else:
            returnStr += elem
    return returnStr
Esempio n. 11
0
 def _extract_todo_info(self, extract_history=False):
     """Read todo.pom and extract todo info (timestamp, shortterm tasks&est&pom&sta, sometime todo)"""
     line_buffer = file.load(self.settings['path_pom'], 'txt')
     line_buffer = [item.rstrip('\n') for item in line_buffer]
     todo_info = {}
     todo_info['buffers'] = self._extract_todo_tbl_buffers(
         line_buffer, extract_history)
     todo_info['date'], todo_info['time'] = self._parse_timestamp_header(
         todo_info['buffers']['timestamp'])
     todo_info['today'] = self._parse_todo_today(
         todo_info['buffers']['today'])
     todo_info['sometime'] = self._parse_todo_sometime(
         todo_info['buffers']['sometime'])
     # self.log.info(todo_info['today'])
     return todo_info
Esempio n. 12
0
 def _add_tasks2menu(self, tasks):
     todo_main_base_menu = file.load(self.settings['path_base_menu'],
                                     'json')
     children = []
     for task in tasks:
         bar = {
             "caption":
             task,
             "children": [{
                 "caption": "Short break",
                 "command": "todo_task_cmd",
                 "id": "todo_menu_short_break",
                 "args": {
                     "task": task,
                     "cmd": "short_break"
                 }
             }, {
                 "caption": "Long break",
                 "command": "todo_task_cmd",
                 "id": "todo_menu_long_break",
                 "args": {
                     "task": task,
                     "cmd": "long_break"
                 }
             }, {
                 "caption": "Ok",
                 "command": "todo_task_cmd",
                 "id": "todo_menu_ok",
                 "args": {
                     "task": task,
                     "cmd": "ok"
                 }
             }]
         }
         children.append(bar)
     tasks_menu = {"caption": "Tasks", 'children': children}
     todo_main_base_menu[0]['children'].insert(0, tasks_menu)
     file.save(todo_main_base_menu, self.settings['path_menu'], 'json')
     return
Esempio n. 13
0
from containers import Databases
from file import load_databases_from_file as load
load()
print(Databases.databases)
Esempio n. 14
0
def init():
    global config
    config = file.load('config.json')
    set_yesterday()
Esempio n. 15
0
    return (
        reduce(
            lambda p, c: ((c[1][0] if request[c[0]] else (1 - c[1][0])) * p)
            / (
                (c[1][0] if request[c[0]] else (1 - c[1][0])) * p
                + (c[1][1] if request[c[0]] else (1 - c[1][1])) * (1 - p)
            ),
            enumerate(evidences[idx]),
            hypothesis,
        )
        for idx, hypothesis in enumerate(hypothesises)
    )


if __name__ == "__main__":
    from file import load
    from db import (
        process,
        evidence_values,
        hypothesis_names,
        hypothesis_values,
    )

    data = process(load("data/db.csv"), ["desease", "ph"], ["symptom", "peh", "penh"])
    res = expertize(
        hypothesis_values(data),
        evidence_values(data),
        (True, False, True, False, True),
    )
    print(dict(zip(hypothesis_names(data), res)))
Esempio n. 16
0
def generate_reports():
    global reports
    data = []
    for f in glob.glob('data/*'):
        for report in file.load(f):
            reports.append(report)
Esempio n. 17
0
        for g in grouped.groups
    }


def hypothesis_names(data):
    return [k[0] for k in data]


def hypothesis_values(data):
    return [k[1] for k in data]


def evidence_names(data):
    return list(dict.fromkeys([v for k in data for v in data[k]]))


def evidence_values(data):
    return [[v for v in data[k].values()] for k in data]


if __name__ == "__main__":
    from file import load

    data = process(load("data/db.csv"), ["desease", "ph"],
                   ["symptom", "peh", "penh"])
    print(data)
    print(hypothesis_names(data))
    print(hypothesis_values(data))
    print(evidence_names(data))
    print(evidence_values(data))
Esempio n. 18
0
from stack import stack
import arm_constants as ac
from file import load
from riccati import riccati
from scipy.io import savemat
from arm_constants import P as P_hardcoded

# Pasta com coisas relacionadas à obtenção por
# contagem/maximização de verossimilhança (2017count)
dir = 'count/'

# P.pkl e P_tilde.pkl foram obtidas de
# cerob/MarkovianSimulator/riccati/1000_iter/loop_loop_iteration_0100.mat
# Git: origin/plot c88519f4d18a719f0fd1401096c22b7600762187
# P_hardcoded foi encontrada no código fonte (consigo ser mais específico?)
Ps = (('P', load(dir + 'P.pkl')), ('P_tilde', load(dir + 'P_tilde.pkl')),
      ('P_hardcoded', P_hardcoded))

for name, P in Ps:
    # Calcular F a partir de P no Python
    args = {
        'T': int(1e6),
        'N': ac.N,
        'A': ac.A,
        'B': ac.B,
        'C': ac.C,
        'D': ac.D,
        'R': P,
        'epsilon': 1e-6,
    }
    [F, _] = riccati(**args)
Esempio n. 19
0
def process(db, key_name, indicator_name):
    def fun(name):
        def _inner(x):
            return len(list(e for e in x if e == name))

        _inner.__name__ = name
        return _inner

    return (db.groupby(key_name)[indicator_name].aggregate([
        fun(g) for g in db[indicator_name].unique()
    ]).transform(lambda x: x / sum(x), axis=1).reset_index())


if __name__ == "__main__":
    from file import load

    print(process(load("data/db.csv"), "intensity", "mark"))