本文整理汇总了Python中Data类的典型用法代码示例。如果您正苦于以下问题:Python Data类的具体用法?Python Data怎么用?Python Data使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Data类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
def get(self):
qq = self.get_argument('qq', None)
passwd = self.get_argument('skey', None)
email = self.get_argument('email', None)
recaptcha_response_field = self.get_argument('recaptcha_response_field', None)
recaptcha_challenge_field = self.get_argument('recaptcha_challenge_field', None)
print recaptcha_response_field
#block waring need Async!!
ret = libs.captcha.submit(recaptcha_challenge_field, recaptcha_response_field, Config.recaptcha_privatekey, self.request.remote_ip)
print ret.is_valid
tips = ''
while True:
if ret.is_valid == False:
tips = '验证码错误'
break
if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", email) == None:
email = None
if passwd == None or qq == None:
tips = 'SKey or QQ 不合法,重新输入'
break
if email != None:
Data.updateUserEmailData(qq, email)
Data.updateUserData(qq, passwd)
tips = '提交成功,每日0和12点自动签到'
break
self.render("template_taken.html",
title = 'QQ群自动签到',
tips = tips)
示例2: next
def next(self):
if self.f_index >= self.dataset.get_n_files() or self.f_index > self.max_files:
raise StopIteration
else:
self.f_index += 1
f_number = self.file_order[self.f_index - 1]
acoustics_file = self.dataset.get_input_file(f_number)
acoustics = Data.expand_array_in_blocks(acoustics_file, self.dataset.n_frames, self.dataset.frame_shift)
if self.dataset.has_output():
i = 0
output = []
times = self.dataset.get_output_times_file(f_number)
labels = self.dataset.get_output_values_file(f_number)
for j in xrange(
Data.n_blocks(acoustics_file.shape[0], self.dataset.n_frames, self.dataset.frame_shift)
):
while (self.dataset.n_frames // 2 + j) >= times[i][1] and i < len(times) - 1:
i += 1
output.append(labels[i])
x = [acoustics, np.array(output)] # Get label for each t
else:
x = [acoustics]
if self.return_path:
x.append(self.dataset.get_file_path(f_number))
return tuple(x)
示例3: getPredictLabelWithScikit
def getPredictLabelWithScikit(header):
clfScikit = pickle.load(open(r'./RandomForestScikitModel'))
#print 'header:',header
headerVec = GenerateVectorMulLines_everyline.transformHeader2Vector(header[:])
Data.transformVector2LibsvmStyle(headerVec,'./pythonsrc/tmp/tmp.svmdata')
X, y = load_svmlight_file('./pythonsrc/tmp/tmp.svmdata')
y_pred = clfScikit.predict(X)
label = [ '<'+ Data.CLASSIFICATION[int(x)]+'>' for x in y_pred]
return label
示例4: __save
def __save(addToLog=True):
Thread.Lock("Framework.Dict", addToLog=False)
dictToSave = copy.deepcopy(__dict)
global __saveScheduled
__saveScheduled = False
try:
Data.__pickle("%s/Dict" % Data.__dataPath, dictToSave)
if addToLog:
PMS.Log("(Framework) Saved the dictionary file")
finally:
Thread.Unlock("Framework.Dict", addToLog=False)
示例5: close_open
def close_open(self, y):
"""
Logic to load an account.
:param y: string
"""
self.transaction_list = Data.load(str(y))["transactions"]
self.categories = Data.load(str(y))["categories"]
self.amounts = Data.load(str(y))["category_amounts"]
self.s.set(str(y))
self.new_window.destroy()
self.t.set("$" + str(Register.get_total(self.transaction_list)))
self.display_list()
示例6: fill_files_buffer
def fill_files_buffer(self):
self.input_files = []
self.output_files = []
self.srcs = []
buffer_size = 0
index = 0
if self.file_index >= len(self.files_order):
raise StopIteration
# Fill the buffer
while buffer_size < self.max_buffer_size and self.file_index < len(self.files_order): ##TODO add size in bytes
# Get the output and output files
inp = self.dataset.get_input_file(self.files_order[self.file_index])
outp = self.dataset.get_output_values_file(self.files_order[self.file_index])
self.input_files.append(inp)
self.output_files.append(outp)
buffer_size += inp.shape[0] * inp.ctypes.strides[0]
buffer_size += outp.shape[0] * outp.ctypes.strides[0]
inp_src = inp.ctypes.data
outp_src = outp.ctypes.data
times = self.dataset.get_output_times_file(self.files_order[self.file_index])
if self.dataset.has_times:
i = 0
tb0 = 0.5 * (self.dataset.frame_duration + (self.n_frames - 1) * self.dataset.frame_time_shift)
time_step = self.dataset.frame_time_shift * self.frame_shift
for j in xrange(Data.n_blocks(inp.shape[0], self.n_frames, self.frame_shift)):
# Time for the center of the block of frames
t = tb0 + time_step * j
# i is the index in the label file corresponding to that time
while t > times[i][1] and i < len(times) - 1:
i += 1
outp_src += int(self.output_size)
self.srcs.append((inp_src, outp_src))
# Add an entry to the list of addresses
inp_src += int(self.frame_size * self.frame_shift)
else: # Has frame indexes instead of times
i = 0
# for j in xrange(1+self.n_frames//2, Data.n_blocks(inp.shape[0], self.n_frames, self.frame_shift)):
# while j > times[i][1] and i < len(times)-1:
for j in xrange(Data.n_blocks(inp.shape[0], self.n_frames, self.frame_shift)):
# while (self.n_frames//2 + j) > times[i][1] and i < len(times)-1:
while (self.n_frames // 2 + j) >= times[i][1] and i < len(times) - 1:
i += 1
outp_src += int(self.output_size)
self.srcs.append((inp_src, outp_src))
# Add an entry to the list of addresses
inp_src += int(self.frame_size * self.frame_shift)
# Next file and next buffer index
index += 1
self.file_index += 1
if self.shuffle:
random.shuffle(self.srcs)
self.srcs_index = 0
示例7: mark_result
def mark_result():
actualdir = globalData.PATH + '/TestResult/ActualScreenShot/'
diffdir = globalData.PATH + '/TestResult/DifferentScreenShot/'
for i in os.listdir(diffdir):
if(endWith(os.path.join(diffdir, i), '.png')):
moudle = i.split('_')[0]
case = i.split('_')[1].split('.')[0]
Data.setExecutionresult(moudle, int(case), 'Fail')
for j in os.listdir(actualdir):
if(endWith(os.path.join(actualdir, j), '.png')):
if(os.path.exists(os.path.join(diffdir, j)) == False):
moudle = j.split('_')[0]
case = j.split('_')[1].split('.')[0]
Data.setExecutionresult(moudle, int(case), 'Pass')
示例8: main
def main(self):
print
print("Romulus10's Quick Checkbook Register")
print
done = False
while not done:
print(self.account_name)
self.total = self.fin.get_total(self.transactions)
if self.total is None:
print("$0")
else:
print('$' + str(self.total))
cmd = raw_input('> ')
cmd = cmd.split(' ')
while len(cmd) < 4:
cmd.append('')
if cmd[0] == "quit":
done = True
if cmd[0] == "help":
print(self.help)
if cmd[0] == "new":
if cmd[1] != '':
self.transactions = Data.new(cmd[1])
self.account_name = cmd[1]
if cmd[0] == "load":
if cmd[1] != '':
self.transactions = Data.load(cmd[1])["transactions"]
self.categories = Data.load(cmd[1])["categories"]
self.amounts = Data.load(cmd[1])["category_amounts"]
self.account_name = cmd[1]
if cmd[0] == "save":
Data.save(self.account_name, self.transactions)
if cmd[0] == "copy":
Data.copy(cmd[1], cmd[2])
if cmd[0] == "add":
if cmd[1] != '' and cmd[2] != '' and cmd[3] != '':
self.add(cmd)
if cmd[0] == "delete":
if cmd[1] != '':
x = None
for y in self.transactions:
if y.number == int(cmd[1]):
x = y
self.transactions.remove(x)
if cmd[0] == "print":
t = PrettyTable(["Number", "Name", "Category", "Date", "Amount"])
for x in self.transactions:
t.add_row([x.number, x.name, x.category, x.date, ('$' + str(x.value))])
print(t)
if cmd[0] == "categories":
t = PrettyTable(["Name", "Current Value"])
for i in range(len(self.categories)):
t.add_row([str(self.categories[i]), ('$' + str(self.amounts[i]))])
print(t)
if cmd[0] == "gui":
gui = TKBook()
gui.root.mainloop()
print
print
示例9: __save
def __save():
global __saveScheduled
Thread.Lock("Framework.HTTPCache", addToLog=False)
try:
# Save the cache
Data.__pickle("%s/HTTPCache" % Data.__dataPath, __cache)
# Save the cookie jar
if __cookieJar is not None:
__cookieJar.save("%s/HTTPCookies" % Data.__dataPath)
finally:
__saveScheduled = False
Thread.Unlock("Framework.HTTPCache", addToLog=False)
PMS.Log("(Framework) Saved shared HTTP data")
示例10: __init__
def __init__(self, master=None):
"""the main constructor of the frame. As it is quite big,
i split it up into subfunctions for the various ui parts.
Might be worth to instead use children classes instead.
The main app window will have a status bar at the bottom with
progress messages and stuff. The main window will be
the square matplotlib canvas on the right and a narrowish bar
with samples, sliders, etc on the right
"""
tk.Frame.__init__(self, master, relief=tk.SUNKEN)
self.master = master
self.d = Data(self)
self.c = Config(O)
self.canvas = dict()
self.d.sList = []
self.d.oList = []
self.init_canvas_hyperbolas()
self.init_canvas_pwp(active=True)
self.init_sample_frame()
#self.init_statusbar()
self.init_slider_frame()
self.init_menubar()
#enable expansion
tk.Grid.rowconfigure(self,1,weight=10)
tk.Grid.rowconfigure(self,2,weight=1)
tk.Grid.columnconfigure(self,1,weight=1)
tk.Grid.columnconfigure(self,2,weight=1)
tk.Grid.columnconfigure(self,0,weight=2)
示例11: main
def main():
tickers = Data.readTickerFile(Config.TickerFilePath)
year, month, day = map(int, Config.TimeBegin.split('-'))
tsBeg = datetime(year, month, day)
year, month, day = map(int, Config.TimeEnd.split('-'))
tsEnd = datetime(year, month, day)
for t in tickers:
ts = Data.getStockPrices(t, tsBeg, tsEnd)
ts = ts['Adj Close']
#res = Analyzer.adfullerTest(ts)
#print t + ' Ad Fuller Test = '
#print res
res = Hurst.hurst(ts)
print t + ' Hurst = %f' %res
return 0
示例12: feedforward
def feedforward(x):
for i, l in enumerate(layers):
if i == 0:
blocks = Data.expand_array_in_blocks(x, dataset.n_frames, dataset.frame_shift)
x = l.feedforward(blocks.T).T.copy()
else:
x = l.feedforward(x.T).T.copy()
return x
示例13: get_serial
def get_serial(line):
# print 'line', line
try:
if line[0] is ' ':
print line[1:]
return
else:
vals = line.split(',')
if vals[0] is '':
print 'return', vals
return
if vals[0] in 'AGMDE':
# global angles
#print 'AGMDE', vals
Data.set_angle(vals[0], map(int, vals[1:]))
#
# if len( logs[vals[0]] ) > 1024:
# logs[vals[0]].pop(0)
#
# logs[vals[0]].append( map( int, vals[1:] ) )
elif vals[0] in 'T':
Data.set_timings(map(int, vals[1:]))
elif vals[0] in 'P':
Data.set_ratios(map(float, vals[1:]))
elif vals[0] in 'R':
Data.set_rx(map(int, vals[1:]))
elif vals[0] in 'abcd':
global motors
Data.set_pid(vals[0], map(int, vals[1:]))
# motors[vals[0]].put(map( int,vals[1:]) )
else:
print 'line', line,
except Exception as e:
print 'serial error:',
print line
print e.message
示例14: checkend
def checkend(self):
if self.user[2] <= 0: #zero health!
print "OH NO. You lost..."
print "Going to main menu."
time.sleep(3)
Data.start_game(self.original_stats)
if self.mons[1] <= 0:
print "You won!"
gain = random.randint(1, 5)
if gain > 2:
print "Gained stats!"
self.original_stats[2] += gain ##todo: stat changing per level gain?
self.original_stats[3] += gain
self.original_stats[4] += gain
self.original_stats[5] += gain
time.sleep(2)
Data.start_game(self.original_stats)
示例15: test_Data
def test_Data(self):
gs = self.gs
t_s = time.time()
t_data_s = time.time()
data = Data(gs)
t_data_e = time.time()
# print data
t_parse_s = time.time()
data.parse(gs)
t_parse_e = time.time()
# print data
print "data diff: %d ms" % (int((t_data_e - t_data_s) * 1000))
print "pars diff: %d ms" % (int((t_parse_e - t_parse_s) * 1000))
bots = []
t_bots_s = time.time()
bots.append(NextBot(data, 30))
# bots.append(SendToNext(data, 5))
# bots.append(RndBot(data, 5))
# ots.append(RndBot(data, 7))
bots.append(RndBot(data, 30))
for bot in bots:
bot.calc()
t_bots_e = time.time()
print "bots diff: %d ms" % (int((t_bots_e - t_bots_s) * 1000))
for bot in bots:
bot.run()
t_e = time.time()
for bot in bots:
s1, s2, s3, r, a, n = bot.get()
print str(s1) + ", " + str(s2) + ", " + str(s3) + ", " + str(a) + ", " + str(n) + "\n"
print "-" * 80
bot = data.getBest(bots)
print bot.get()
bot.correction(data)
print "-" * 80
for i, c in enumerate(data.camps):
if c[C_OWNER] == 1:
print "id: ", i, " ", c[0:5]
print "-" * 80
for i, c in enumerate(bot.camps):
if c[C_OWNER] == 1:
print "id: ", i, " ", c[0:5]
print "all diff: %d ms" % (int((t_e - t_s) * 1000))