def gen_sparse_matrix(save=True, mail=True, store=pd.HDFStore('/Volumes/HDD/Users/tom/DataStorage/Patents/patents.h5')): """ Testing """ start = datetime.now() net = store['cites'] tech = filter(net, get_tech_patents(store)) # Comes close to paging out. idx = pd.Series(np.union1d(tech['citing'].unique(), tech['cited'].unique())) d = idx.to_dict() # d : Z -> Patents inv_d = {v: k for k, v in d.iteritems()} # inv_d : Patents -> Z rows = [] cols = [] final = tech.index[-1] print(len(tech.index)) for k in tech.index: i = inv_d[tech.ix[k]['citing']] j = inv_d[tech.ix[k]['cited']] rows.append(i) cols.append(j) if k % 10000 == 0: print(k / final) rows = np.array(rows) cols = np.array(cols) data = np.ones(len(tech)) N = np.max([cols.max(), rows.max()]) sp = sparse.coo_matrix((data, (rows, cols)), shape=(N + 1, N + 1)) if save: try: save_(save, sp) except IOError: save_('/Users/tom/tom/DataStorage/Patents/sparse_out.mat', sp) if mail: try: time = str(datetime.now() - start) gmail.mail('*****@*****.**', 'Results', time) except: print(str(datetime.now() - start)) return sp
def register(): form = RegisterForm(request.form) if form.validate_on_submit(): gmail.mail(form.email.data, form.username.data) newUser = Table(username=form.username.data, email=form.email.data, password=form.password.data, phoneNo=form.number.data) try: db.session.add(newUser) db.session.commit() flash( "You are Registered Server Side. Please check your mail for further instructions." ) return redirect('/login') except: return 'error saving name' return render_template('register.html', form=form)
def test_gmail(): s=gmail.mail("hai","*****@*****.**") assert s=="success"
t_net['cited'].unique())) d = t_idx.to_dict() inv_d = {v:k for k, v in d.iteritems()} ### Full iterative rows = [] cols = [] for k in t_net.index: i = inv_d[t_net.ix[k]['citing']] j = inv_d[t_net.ix[k]['cited']] rows.append(i) cols.append(j) if k % 1000 == 0: print k rows = np.array(rows) cols = np.array(cols) data = np.ones(len(t_net)) N = np.max([cols.max(), rows.max()]) sp = sparse.coo_matrix((data, (rows, cols)), shape=(N + 1, N + 1)) savemat('/Users/tom/tom/DataStorage/Patents/sparse_out.mat', {'A': sp}) try: time = str(datetime.now() - start) gmail.mail('*****@*****.**', 'Results', time) except: print(str(datetime.now() - start))
t_idx = pd.Series(np.union1d(t_net['citing'].unique(), t_net['cited'].unique())) d = t_idx.to_dict() inv_d = {v: k for k, v in d.iteritems()} ### Full iterative rows = [] cols = [] for k in t_net.index: i = inv_d[t_net.ix[k]['citing']] j = inv_d[t_net.ix[k]['cited']] rows.append(i) cols.append(j) if k % 1000 == 0: print k rows = np.array(rows) cols = np.array(cols) data = np.ones(len(t_net)) N = np.max([cols.max(), rows.max()]) sp = sparse.coo_matrix((data, (rows, cols)), shape=(N + 1, N + 1)) savemat('/Users/tom/tom/DataStorage/Patents/sparse_out.mat', {'A': sp}) try: time = str(datetime.now() - start) gmail.mail('*****@*****.**', 'Results', time) except: print(str(datetime.now() - start))
import gmail, time #import modules x = 1 #set variable while True: gmail.mail(0) time.sleep(10)