text
stringlengths
1
93.6k
return np.stack(obs), np.stack(rews), np.stack(dones), np.stack(infos)
def exist_rw_allocation(self, path_list):
"""
判断在path_list中是否有可行的分配方案
:param path_list:
:return:
"""
for remote, paths in zip(self.remotes, path_list):
remote.send(('exist_rw_allocation', paths))
results = [remote.recv() for remote in self.remotes]
exist, path_index, wave_index = zip(*results)
return np.stack(exist), np.stack(path_index), np.stack(wave_index)
def k_shortest_paths(self, src_dst):
"""
计算ksp路径
:param src_dst:
:return:
"""
for remote, sd in zip(self.remotes, src_dst):
remote.send(('k_shortest_paths', sd))
result = [remote.recv() for remote in self.remotes]
return result
def close(self):
if self.closed:
return
if self.waiting:
for remote in self.remotes:
remote.recv()
for remote in self.remotes:
remote.send(('close', None))
for p in self.processes:
p.join()
self.closed = True
class CloudpickleWrapper(object):
"""
Uses cloudpickle to serialize contents (otherwise multiprocessing tries to use pickle)
"""
def __init__(self, x):
self.x = x
def __getstate__(self):
import cloudpickle
return cloudpickle.dumps(self.x)
def __setstate__(self, ob):
import pickle
self.x = pickle.loads(ob)
# <FILESEP>
#!/usr/bin/env python
import datetime
from threading import Thread
import tkinter as tk
from tkinter import messagebox
import tkinter.ttk as ttk
from utils import InputValidator, Database, load_icon, callback
import sys
__version__ = '1.2.0'
class CreditsTool(tk.Toplevel):
"""Opens a new window providing credits"""
def __init__(self, master=None, *args, **kwargs):
"""Initializes Toplevel object and builds credit interface."""
super().__init__(master, *args, **kwargs)
# hide window in background during drawing and load, to prevent flickering and glitches during frame load
self.withdraw()
# build and draw the window
self.build()
# unhide the Toplevel window immediately after draw and load
self.after(0, self.deiconify)
def build(self):
"""Initializes and builds application widgets."""
text_credits = 'POCKINT\nversion {ver}\n copyright © {year}' \
''.format(year=datetime.datetime.now().year,
ver=__version__)
author_info = "Written with ♥ by\nNetEvert"
# create main credits label
self.lbl_info = tk.Label(self, text=text_credits,
font=('courier', 10, 'normal'))
self.lbl_author = tk.Label(self, text=author_info,
font=('courier', 10, 'normal'), cursor="hand2")
self.lbl_info.grid(row=0, column=0, sticky='w', padx=1, pady=1)
self.lbl_author.grid(row=1, column=0, sticky='w', padx=1, pady=1)
self.lbl_author.bind("<Button-1>", lambda e: callback("https://twitter.com/netevert"))
class SaveTool(tk.Toplevel):
"""Opens a window to store investigation data"""
def __init__(self, master=None, investigation_id=None, data=None, *args, **kwargs):
"""Initializes Toplevel object and builds interface"""