Пример #1
0
def quick():

    print('Welcome to my Whatsapp parser and analysier!\n\n')
    print('Currently this works for android phones only! \n(other phones use a different syntax \nif you could let me know what that is, that would be useful and probably a trivial extension to the parser)\n')
    
    path=raw_input('Please type in the path of the text file containing your whatsapp messages\n')
    
    first=raw_input('What comes first day or month: type day if day/month/year and month if otherway round\n')
    print('\n\n\n')
    if first=='month':
        f=False
    else:
        f=True
    
    df=wp.what_parse(path,dayfirst=f)
    t=v.visual(df,'hour')
    t.plot()
    t=v.visual(df,'month')
    t.plot_split_year()
    t=v.visual(df,'weekday')
    t.plot()
    t=v.visual(df,'week')
    t.plot()
    t=v.visual(df,'year')
    t.plot_split_year()
Пример #2
0
def main(targets):
    '''
    Runs the main project pipeline logic, given the targets.
    targets must contain: 'data', 'analysis', 'model'. 
    `main` runs the targets in order of data=>analysis=>model.
    '''
    with open('config/data-params.json') as fh:
        data_cfg = json.load(fh)
    get_data(**data_cfg)

    with open('config/eda-params.json') as fh:
        eda_cfg = json.load(fh)
    do_eda(**eda_cfg)

    with open('config/auto-params.json') as fh:
        auto_cfg = json.load(fh)
    autophrase(**auto_cfg)

    with open('config/visual-params.json') as fh:
        visual_cfg = json.load(fh)
    visual(**visual_cfg)

    # with open('config/example-params.json') as fh:
    #     example_cfg = json.load(fh)
    # example(**example_cfg)

    return
Пример #3
0
def quick():

    print('\nWelcome!\n')

    path = raw_input(
        'Please type the path of the text file containing your whatsapp messages:\n'
    )

    first = raw_input(
        'What is the date format in your whatsapp text file? \nType day if day/month/year and month if month/day/year.\n'
    )
    print('\n\n\n')
    if first == 'month':
        f = False
    else:
        f = True

    df = wp.what_parse(path, dayfirst=f)
    t = v.visual(df, 'hour')
    t.plot()
    t = v.visual(df, 'month')
    t.plot_split_year()
    t = v.visual(df, 'weekday')
    t.plot()
    t = v.visual(df, 'week')
    t.plot()
    t = v.visual(df, 'year')
    t.plot_split_year()
Пример #4
0
def show_trail_present():
    sbox = [12, 5, 6, 11, 9, 0, 10, 13, 3, 14, 15, 8, 4, 7, 1, 2]

    # Trail from the
    pbox = [x % 63 for x in (np.arange(64) * 16)]
    pbox[63] = 63
    print(pbox)
    visual.visual("0000000000000011", 2, 30, 16, sbox, pbox, "Differential",
                  True, [], [], 1, [])
    exit()
 def gera_imagem_soluc(self):
     for i in range(len(grande_frente_pareto)):
         visual(G, grande_frente_pareto[i].fluxo_aresta)
         grande_frente_pareto[i].pega_modulos()
         print('------Solucao', i + 1, '--------')
         for j in range(len(G.arestas)):
             print('fluxo: ', grande_frente_pareto[i].fluxo_aresta[j],
                   'capacidade instalada',
                   grande_frente_pareto[i].lista_modulos[j])
         print('----------------------------')
     pass
Пример #6
0
def creatediff():
    sBox = [6, 4, 12, 5, 0, 7, 2, 14, 1, 15, 3, 13, 8, 10, 9, 11]
    pBox = [0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15]
    #pBox = [0,1,2,3,4,5,6,7,8,9,10,11]

    pbox = [x % 63 for x in (np.arange(64) * 16)]
    pbox[63] = 63
    print(pbox)
    inputString = "0700000000000700"
    visual.visual(inputString, 2, 30, len(inputString),
                  [12, 5, 6, 11, 9, 0, 10, 13, 3, 14, 15, 8, 4, 7, 1, 2], pbox,
                  "Differential", True, [], [], 1, [])
Пример #7
0
def show_trail_gift():
    sbox = [1, 10, 4, 12, 6, 15, 3, 9, 2, 13, 11, 7, 5, 0, 8, 14]
    pbox = [
        0, 17, 34, 51, 48, 1, 18, 35, 32, 49, 2, 19, 16, 33, 50, 3, 4, 21, 38,
        55, 52, 5, 22, 39, 36, 53, 6, 23, 20, 37, 54, 7, 8, 25, 42, 59, 56, 9,
        26, 43, 40, 57, 10, 27, 24, 41, 58, 11, 12, 29, 46, 63, 60, 13, 30, 47,
        44, 61, 14, 31, 28, 45, 62, 15
    ]

    visual.visual("0000000000001010", 2, 30, 16, sbox, pbox, "Differential",
                  True, [], [], 1, [])

    exit()
Пример #8
0
    def __init__(self, hatch):
        self.hatch = hatch
        self.FORMAT = pyaudio.paInt16
        # mono
        self.CHANNELS = 1
        self.pa = pyaudio.PyAudio()
        self.queue = multiprocessing.JoinableQueue()
        self.running = True
        self.visual = visual.visual()

        if (self.hatch.get('debug') == True):
            defaultCapability = self.pa.get_default_host_api_info()
            print defaultCapability

        self.stream = self.pa.open(format=self.FORMAT,
                                   channels=self.CHANNELS,
                                   rate=config.SAMPLE_RATE,
                                   input=True,
                                   output=False,
                                   frames_per_buffer=config.CHUNK)

        self.buffering = buffering.buffering(self.hatch, self.queue)
        if (hatch.get('infile') == None):
            self.recording()
        else:
            self.readfromfile()
Пример #9
0
 def __init__(self, debug, plot, wave, dict):
     self.debug = debug
     self.plot = plot
     self.wave = wave
     self.dict = dict
     self.visual = visual.visual()
     self.util = util.util(debug, wave)
     self.filter = filter.filtering(debug, plot, dict, wave)
     self.silence = 0
     self.reset()
     self.plot_buffer = [ ]
Пример #10
0
 def spawnVisuals(self):
     #self.visuals['firsttry'] = FirstTry(self.loader, self.render, self.snd)
     self.visuals['placeholder'] = visual(self.loader, self.render, self.snd)
     self.visuals['backgroundbeat'] = BackgroundBeat(self.loader, self.render, self.snd)
     self.visuals['backgroundbeat1'] = BackgroundBeat(self.loader, self.render, self.snd)
     self.visuals['cardquad'] = CardQuad(self.loader, self.render, self.snd)
     self.visuals['enterprise'] = Enterprise(self.loader, self.render, self.snd)
     self.visuals['enterprise'] = Enterprise(self.loader, self.render, self.snd)
     #self.visuals['texturecard'] = TextureCard(self.loader, self.render, self.snd)
     #self.visuals['skatesculp1'] = SkateRampOne(self.loader, self.render, self.snd)
     #self.visuals['vrclight'] = VRCLight(self.loader, self.render, self.snd)
     self.visuals['skull'] = Skull(self.loader, self.render, self.snd)
     self.visuals['P90'] = P90(self.loader, self.render, self.snd)
     self.visuals['stars'] = Stars(self.loader, self.render, self.snd)
Пример #11
0
def Run():
    try:
        b = Phan(13, 5)
        board = Omokgame.startphan()
        b.board = np.copy(board)
        display = visual(13, 5)
        display.prepare_display()
        f = fight(13, 5)
        human_move = f.Act(b.board)

        best_model = nn.loading("folder", "model1")
        best_mcts = mcts(Omokgame(13, 5), best_model)

    except KeyboardInterrupt:
        print("error")
Пример #12
0
 def __init__(self, hatch):
     self.hatch = hatch
     self.visual = visual.visual()
     self.util = util.util(self.hatch.get('debug'))
     self.filter = filter.filtering(self.hatch)
     self.silence = 0
     self.force = False
     self.counter = 0
     self.token_start = False
     self.new_token = False
     self.new_word = False
     self.token_counter = 0
     self.buffer = []
     self.peaks = []
     self.token_peaks = []
     self.last_low_pos = 0
     self.force = False
     self.entered_silence = False
Пример #13
0
 def __init__(self, queue, debug, plot, dict, wave):
     multiprocessing.Process.__init__(self, name="worker for prepared queue")
     self.queue = queue
     self.debug = debug
     self.plot = plot
     self.dict = dict
     self.wave = wave
     self.visual = visual.visual()
     self.condense = condense.packing()
     self.util = util.util(debug, None)
     self.analyze = analyze.analyze(debug)
     self.characteristic = characteristics.characteristic(debug)
     self.running = True
     self.counter = 0
     self.reset_counter = 0
     self.rawbuf = [ ]
     self.reset()
     self.DICT = self.util.getDICT()
     self.start()
Пример #14
0
 def __init__(self, hatch, queue):
     multiprocessing.Process.__init__(self, name="worker for filtered data")
     self.hatch = hatch
     self.queue = queue
     self.visual = visual.visual()
     self.util = util.util(self.hatch.get('debug'))
     self.analyze = analyze.analyze(self.hatch.get('debug'))
     self.compare = comparator.compare(self.hatch.get('debug'), self.util)
     self.running = True
     self.counter = 0
     self.plot_counter = 0
     self.reset_counter = 0
     self.rawbuf = [ ]
     self.rawfft = [ ]
     self.raw = [ ]
     self.fft = [ ]
     self.word_tendency = None
     self.character = [ ]
     self.raw_character = [ ]
     self.uid = str(uuid.uuid4())
     self.start()
Пример #15
0
 def __init__(self, debug, plot, wave, dict):
     self.debug = debug
     self.plot = plot
     self.wave = wave
     self.dict = dict
     self.visual = visual.visual()
     self.util = util.util(debug)
     self.filter = filter.filtering(debug, plot, dict, wave)
     self.silence = 0
     self.force = False
     self.counter = 0
     self.token_start = False
     self.new_token = False
     self.new_word = False
     self.token_counter = 0
     self.buffer = []
     self.peaks = []
     self.token_peaks = []
     self.last_low_pos = 0
     self.force = False
     self.plot_buffer = []
     self.entered_silence = False
Пример #16
0
 def __init__(self, queue, debug, plot, dict, wave):
     multiprocessing.Process.__init__(self, name="worker for filtered data")
     self.queue = queue
     self.debug = debug
     self.plot = plot
     self.dict = dict
     self.wave = wave
     self.visual = visual.visual()
     self.util = util.util(debug)
     self.analyze = analyze.analyze(debug)
     self.compare = comparator.compare(debug, self.util)
     self.running = True
     self.counter = 0
     self.plot_counter = 0
     self.reset_counter = 0
     self.rawbuf = []
     self.rawfft = []
     self.raw = []
     self.fft = []
     self.word_tendency = None
     self.character = []
     self.raw_character = []
     self.uid = str(uuid.uuid4())
     self.start()
modelo.optimize()
custo = modelo.getObjective(0)
hops = modelo.getObjective(1)
print('custo gurobi::::', custo.getValue())
print('hops gurobi::::', hops.getValue())
capacidade_aresta = [0.0 for i in range(len(G.arestas))]
for e in range(len(G.arestas)):
    cap = 0.0
    for t in range(len(G.arestas[e].module_list)):
        cap += G.arestas[e].module_list[t].capacidade * y[e, t].getAttr(
            GRB.Attr.X)
    capacidade_aresta[e] = cap + G.arestas[e].pre_installed_capacity

fluxo_aresta = [0.0 for i in range(len(G.arestas))]
for k in range(len(G.caminhos)):
    for u in range(len(G.caminhos[k])):
        for e in range(len(G.caminhos[k][u])):
            if G.caminhos[k][u][e] == 1:
                fluxo_aresta[e] += x[k, u].getAttr(
                    GRB.Attr.X) * G.demandas[k].routing_value

for e in range(len(G.arestas)):
    if fluxo_aresta[e] > capacidade_aresta[e]:
        print('vish mano estourou a aresta')
print('terminou')
solution_edges = []
print('-------------------------', len(fluxo_aresta))
for e in range(len(fluxo_aresta)):
    solution_edges.append([e, fluxo_aresta[e], capacidade_aresta[e]])
vis = visual(G, fluxo_aresta)
Пример #18
0
pygame.init()
screen=pygame.display.set_mode(SCREEN_SIZE, pygame.DOUBLEBUF | pygame.HWSURFACE | pygame.FULLSCREEN)


#Main Game Loop:
FPS=60
clock=pygame.time.Clock()



#initialisations
keyboard=Keyboard()
scale=Scale()
goals=Goals()
visual=visual()
chordbox=Chordbox()
chordrec=ChordRec()
sound=Sound()


screen.fill((255,255,255))
pygame.draw.rect(screen, (0,0,0), pygame.Rect(0,HEIGHT*.8, WIDTH*.75, HEIGHT*.2), 2)
pygame.draw.rect(screen, (0,0,0), pygame.Rect(WIDTH*.75,HEIGHT*.75, WIDTH*.25, HEIGHT*.25), 2)
pygame.draw.rect(screen, (0,0,0), pygame.Rect(WIDTH*.75,0, WIDTH*.25, HEIGHT*.75), 2)
pygame.draw.rect(screen, (0,0,0), pygame.Rect(0,HEIGHT*.1, WIDTH*.75, HEIGHT*.7), 2)
pygame.draw.rect(screen, (0,0,0), pygame.Rect(WIDTH*.125,0, WIDTH*.5, HEIGHT*.1), 2)
scroll=0
while True:
    keydown=[]
    keyup=[]
Пример #19
0
#获取期货数据,参考链接https://blog.csdn.net/dodo668/article/details/82382675?utm_medium=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase


if __name__ == "__main__":
    #入口函数
    new_settings = settings()
    
    #请求数据
    
    #for key,value in new_settings.dict.items(): #字典迭代
    for key,value in new_settings.single.items(): #单个合约代码

        new_request = request(key)
        new_request_content = new_request.get()

        #清洗数据
        new_clean = clean(new_request_content)

        #数据重整
        new_transfer = transfer(new_clean.clean())
        new_transfer.trans()

    
    
    new_visual = visual()

        #可视化
        #数学分析

    
Пример #20
0
model.summary()

model.compile(
    optimizer='adam',
    loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
    metrics=['accuracy'])

EPOCHS = 6

history = model.fit(train_batches,
                    epochs=EPOCHS,
                    validation_data=validation_batches)

## Results visualization
visual(history)

## Defining and testing the second models

# Transfer learning Using the Inception v3 model

IMAGE_RES = 299

URL = "https://tfhub.dev/google/tf2-preview/inception_v3/feature_vector/4"
feature_extractor = hub.KerasLayer(URL,
                                   input_shape=(IMAGE_RES, IMAGE_RES, 3),
                                   trainable=False)

model_inception = tf.keras.Sequential(
    [feature_extractor, tf.keras.layers.Dense(num_classes)])
Пример #21
0
import diff
import trails
#from sage.all import *

if __name__ == "__main__":
    args = sys.argv
    if len(args) > 1:
        if args[1] == "present":
            print("hey")

            pbox = [x % 63 for x in (np.arange(64) * 16)]
            pbox[63] = 63
            print(pbox)
            inputString = "4004000000000000"
            visual.visual(
                inputString, 2, 30, len(inputString),
                [12, 5, 6, 11, 9, 0, 10, 13, 3, 14, 15, 8, 4, 7, 1, 2], pbox,
                "Differential", True, [], [], 1, [])
            exit()

        if args[1] == "check_trail_present":
            print("Checking trail for PRESENT")
            sbox = [12, 5, 6, 11, 9, 0, 10, 13, 3, 14, 15, 8, 4, 7, 1, 2]

            #Trail from the
            pbox = [x % 63 for x in (np.arange(64) * 16)]
            pbox[63] = 63
            print(pbox)
            print(diff.check_trail(trails.trail_diff2, sbox, pbox, False))
            exit()

        if args[1] == "check_trail_gift":
Пример #22
0
def createlin():
    sBox = [15, 14, 11, 12, 6, 13, 7, 8, 0, 3, 9, 10, 4, 2, 1, 5]
    pBox = [11, 12, 15, 6, 0, 9, 5, 3, 4, 14, 8, 7, 10, 1, 2, 13]
    visual.visual("0000110011110011", 2, 6, 4, sBox, pBox, "Linear", True, [],
                  [], 1, [])
Пример #23
0
def create():
    #Get the input string
    inputString = input.get()

    #check linear/differential selected
    if (not type.get()):
        popupmsg("Please select the type of cryptanalysis you want to use")
        return

    #check written fields not blank
    if (inputString == ""):
        popupmsg("You have a blank input field")
        return
    pattern = re.compile("([abcdefABCDEF][0-9])*")
    if (type.get() == "Differential" and not (pattern.match(inputString))):
        popupmsg(
            "A hexadecimal string is required for Differential Cryptanalysis, of the type \"0a3d\""
        )
        return

    if (type.get() == "Linear" and
        (len(inputString) != 16 or not (all(c in '01'
                                            for c in str(inputString))))):
        popupmsg("A 16 bit binary string is required for Linear Cryptanalysis")
        return
    #NOT DELETE needed for any number boxes
    if (int(boxes.get()) == 0):
        popupmsg("Please select the number of P-boxes")
        return
    if (type.get() == "Differential"
            and not (len(inputString) == int(boxes.get()))):
        popupmsg(
            "The number of P-boxes has to be 4 times the length of the input")
        return
    if (type.get() == "Linear" and not (len(inputString) == 16)):
        popupmsg(
            "The number of P-boxes has to be the same size as the S-box for a linear cryptanalysis"
        )
        return
    #Get the pBox
    pbox = []
    for en in pBox:
        #checks to correct values
        if (en.get() == ""):
            popupmsg("Empty P-box value")
        #NOT DELETE
        if (int(en.get()) < 0 or int(en.get()) > 4 * int(boxes.get())):
            popupmsg("pbox values out of range, these must be from 0 to " +
                     str(4 * int(boxes.get())))
            return
        if (int(en.get()) in pbox):
            popupmsg("Repeated pbox values")
            return
        pbox.append(int(en.get()))

    #Get the sbox
    sbox = []

    for en in entries:
        #checks for correct values
        if (en.get() == ""):
            popupmsg("Empty S-box value")
        if (int(en.get()) < 0 or int(en.get()) > 15):
            popupmsg("sbox values out of range")
            return
        if (int(en.get()) in sbox):
            popupmsg("Repeated sbox values")
            return
        sbox.append(int(en.get()))

    if (type.get() == "Linear"):
        visual.visual(inputString, 2, rounds.get(), int(len(inputString) / 4),
                      sbox, pbox, type.get(), True, [], [], 1, [])
    if (type.get() == "Differential"):
        visual.visual(inputString, 2, rounds.get(), len(inputString), sbox,
                      pbox, type.get(), True, [], [], 1, [])