def benchmod(module=None, filename=None, output=sys.stdout, format="text", profile=False): if module is None: if filename is None: module = sys.modules.get("__main__") else: filename = str(Path(filename).resolve()) if not filename.endswith(".py"): error = "{0!r} is not a Python file" raise ValueError(error.format(filename)) sys.insert(0, filename.dirname()) try: module = __import__(filename.namebase) except ImportError: error = "unable to import {0!r}" raise ValueError(error.format(filename)) finally: del sys.path[0] results = benchmark(module) if profile: dir = Path("profiles") if dir.exists(): if not dir.is_dir(): raise OSError("'profiles' is not a directory") else: dir.mkdir(parents=True, exist_ok=True) import docbench docbench.profile(module, output_dir=str(dir)) if format == "text": content = table(results) elif format == "json": content = json.dumps(results) else: raise ValueError("unknown format {0!r}".format(format)) if output is not None: output.write(content) try: output.flush() except AttributeError: pass return results
import sys sys.insert(0, 'monodepth_files/') from utils.functions import * from monodepth_model import * import tensorflow as tf import numpy as np import argparse import os import time import math import utils.losses as losses #import pickle def get_net(params, checkpoint_file, batch_size): size = [256, 512] input_image = tf.placeholder(shape=[batch_size, size[0], size[1], 3], dtype='float32', name='input_image') # initializing adversarial image adv_image = tf.Variable(tf.random_uniform([1, size[0], size[1], 3], minval=-10 / 256.0, maxval=10 / 256.0), name='noise_image', dtype='float32') # clipping for imperceptibility constraint adv_image = tf.clip_by_value(adv_image, -10 / 256.0, 10 / 256.0) input_batch = tf.add(input_image, adv_image) model = MonodepthModel(params, input_batch)
import sys from os import path widget_path = path.join(path.dirname(path.abspath(__file__)), '../') sys.insert(0, widget_path)
from __future__ import print_function import sys sys.insert(0, '.') import os import time import numpy as np import torch import torch.nn as nn import torch.optim as optim from torch.optim import lr_scheduler import torch.nn.functional as F import torchvision from torchvision import datasets, models, transforms import torchvision.models as models from vgg import VGG learning_rate = 1e-3 batch_size = 16 epoches = 30 data_dir = 'dataset' save_path = 'final.pth' train = 'train' test = 'val' def trainval(dataloders, model, optimizer, scheduler, criterion, dataset_sizes, phase='train'): for epoch in range(epoches): print('Epoch {}/{}'.format(epoch, epoches - 1)) print('-' * 10)
import sys import numpy as np import matplotlib.pyplot as plt sys.insert('/path/to/caffe/python') import caffe caffe.set_device(0) caffe.set_mode_gpu()
#!/usr/bin/python #-*- coding:utf-8 -*- ################################################ #File Name: FindPromoterMutationFromExome.py #Author: C.J. Liu #Mail: [email protected] #Created Time: Mon 31 Oct 2016 01:13:37 PM CDT ################################################ import os, sys import argparse sys.insert( 0, '/home/cliu18/liucj/projects/1.Mutation_calling_in_non-condig_region_through_EXOME/0.scripts' ) import callVariantsOfNoncodingRegion import IntegrativeRecurrencyProcessing def usage(): description = '''Task: Find Non-coding region mutation by exome sequencing, and find recurency of mutation in one tumor. Exome sequencing protocol is to captures all exon regions of human genome, besides, it can capture some other parts of genome such as 5'utr, 3'utr, non coding regions et al. I got all regulatory feature region of human from Ensembl, and use GATK -L paramter to call mutation only on these region. Annotation of mutation site is provided. The final result of scripts are the recurent mutation site. ''' usage = """%(prog)s -i <bam_dir> -o <output_dir> -n <number_of_threads""" parser = argparse.ArgumentParser(description=description, usage=usage) parser.add_argument( "-i", dest="input", type=str,
import sys sys.insert(0, './lib') import tkinter as tk from tkinter import commondialog from tkinter.commondialog import Dialog from tkinter import Canvas from tkinter import * from tkinter.ttk import * # class Game(tk.Frame): # def __init__(self): # tk.Frame.__init__(self) # self.grid() # self.master.title('My game of Chance') main = tk.Tk() canvas = tk.Canvas(main, height= 700, width=700, bg='black') canvas.pack() frame = tk.Frame(main, bg='red') frame.place(relheight=0.5, relwidth=0.5 ) restart_message = tk.messagebox.askquestion(main, title=start_game, message="choice" command=restart) restart_message.pack() main.mainloop()