function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def owner(*paths, **kwargs): """ .. versionadded:: 2014.7.0 Return the name of the package that owns the file. Multiple file paths can be passed. Like :mod:`pkg.version <salt.modules.aptpkg.version>`, if a single path is passed, a string will be returned, and if multiple paths are passed, a dic...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def _add(ret, pkginfo): name = pkginfo.pop("Package", None) version = pkginfo.pop("Version", None) if name is not None and version is not None: ret.setdefault(name, {}).setdefault(version, {}).update(pkginfo)
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def info_installed(*names, **kwargs): """ Return the information of the named package(s) installed on the system. .. versionadded:: 2015.8.1 names The names of the packages for which to return information. failhard Whether to throw an exception if none of the packages are installe...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def list_downloaded(root=None, **kwargs): """ .. versionadded:: 3000? List prefetched packages downloaded by apt in the local disk. root operate on a different root directory. CLI Example: .. code-block:: bash salt '*' pkg.list_downloaded """ CACHE_DIR = "/var/cache/...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def setUp(self): self.test_dir = os.path.join(os.path.dirname(__file__), "test-data")
kubeflow/testing
[ 63, 84, 63, 14, 1517406352 ]
def _split_camelcase(text): return re.sub(r"(?<=\w)([A-Z])", r" \1", text)
googlefonts/gftools
[ 195, 61, 195, 113, 1507681124 ]
def _unique_id(version, vendor_id, filename): # Glyphsapp style 2.000;MYFO;Arsenal-Bold # version;vendorID;filename return '%s;%s;%s' % (version, vendor_id, filename)
googlefonts/gftools
[ 195, 61, 195, 113, 1507681124 ]
def _full_name(family_name, style_name): style_name = _mac_subfamily_name(style_name) full_name = '%s %s' % (family_name, style_name) return full_name
googlefonts/gftools
[ 195, 61, 195, 113, 1507681124 ]
def _win_subfamily_name(style_name): name = style_name if 'BoldItalic' == name: return 'Bold Italic' elif 'Italic' in name: return 'Italic' elif name == 'Bold': return 'Bold' else: return 'Regular'
googlefonts/gftools
[ 195, 61, 195, 113, 1507681124 ]
def set_macStyle(style_name): return MACSTYLE[style_name]
googlefonts/gftools
[ 195, 61, 195, 113, 1507681124 ]
def nametable_from_filename(filepath): """Generate a new nametable based on a ttf and the GF Spec""" font = TTFont(filepath) old_table = font['name'] new_table = newTable('name') filename = ntpath.basename(filepath)[:-4] family_name, style_name = filename.split('-') family_name = _split_camelcase(family_...
googlefonts/gftools
[ 195, 61, 195, 113, 1507681124 ]
def main(): args = parser.parse_args() for font_path in args.fonts: nametable = nametable_from_filename(font_path) font = TTFont(font_path) font_filename = ntpath.basename(font_path) font['name'] = nametable style = font_filename[:-4].split('-')[-1] font['OS/2'].usWeightClass = set_usWeigh...
googlefonts/gftools
[ 195, 61, 195, 113, 1507681124 ]
def add_aroma(self): root = BoxLayout(orientation='vertical', spacing=20) btn_layout = GridLayout(cols=2, row_force_default=True, row_default_height=50, spacing=25) add = Button(text='Add', size_hint_x=None, width=150) cancel = Button(text='Cancel', size_hint_x=None, width=150) root.add_widget(Label...
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def callback(instance): try: pathtofile = '%s/Aroma/Aroma.zip' % (Tools) destpath = '%s/META-INF/com/google/android' % (Rom) z = zipfile.ZipFile(pathtofile) z.extractall(destpath) f = open(UScript) text = f.read() f.close() ...
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def aroma(self): self.panel_layout.clear_widgets() title = Label(text='[b][color=#22A0D6][size=20]Custom Aroma Configuration[/size][/color][/b]', markup = True, pos_hint={'x':-.05, 'y':.20}) name_lbl = Label(text='[b][color=ffffff][size=12]Set Rom Name :[/size][/color][/b]', markup = True, pos_hint={'x':-.3...
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def name_enter(self): processing_change = False for line in fileinput.input(Aroma, inplace=1): if line.startswith('ini_set("rom_name", "'): processing_change = True else: if processing_change: print r'ini_set("rom_na...
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def ver_enter(self): processing_change = False
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def dev_enter(self): processing_change = False for line in fileinput.input(Aroma, inplace=1): if line.startswith(r'ini_set("rom_author", "'): processing_change = True else: if processing_change: print 'ini_set("rom_aut...
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def dev_name(self): fin = open(EdsIni) for line in fin: if line.startswith("uname ="): l = line[7:-1].rstrip('\r\n') processing_change=False for line in fileinput.input(Aroma, inplace=1): if line.startswith(r'ini_set("rom_author", "'): processing_change...
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def device(self): fin = open(BuildProp) for line in fin: if line.startswith("ro.product.device="): l = line[18:-1].rstrip('\r\n') processing_change=False for line in fileinput.input(Aroma, inplace=1): if line.startswith(r'ini_set("rom_device", "'): proce...
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def today(self): today = datetime.date.today() processing_change = False for line in fileinput.input(Aroma, inplace=1): if line.startswith(r' "\t\tUPDATED\t: <#080>'): processing_change = True else: if processing_change: print r' "\t\tUPDATED\t: ...
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def boot_img(self): self.panel_layout.clear_widgets() title = Label(text='[b][color=#22A0D6][size=20]Boot.img Tools[/size][/color][/b]', markup = True, pos_hint={'x':-.05, 'y':.20}) unpack = CustomButton(text='Unpack Boot.img', pos_hint={'x':.05, 'y':.550}, size_hint=(.40, .06)) build = CustomButton(tex...
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def deodex(self): self.panel_layout.clear_widgets() deodex_lbl = Label(text='[b][color=#22A0D6][size=20]Deodex Options[/size][/color][/b]', markup = True, pos_hint={'x':-.05, 'y':.20}) self.panel_layout.add_widget(deodex_lbl)
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def odex(self): self.panel_layout.clear_widgets() push_layout = GridLayout(cols=2, row_force_default=True, row_default_height=40, spacing=10, pos_hint={'x':-.02, 'y':-.525}) shell_layout = GridLayout(cols=2, row_force_default=True, row_default_height=40, spacing=10, pos_hint={'x':-.02, 'y':-.825}) odex_...
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def odex_now(self): os.chdir(Tools) comm = "./adb remount" output = os.popen(comm).read() print output comm = "./adb push " + Odex + '/dexo ' + '/system/bin' output = os.popen(comm).read() print output comm = "./adb push " +...
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def sys_remount(self): os.chdir(Tools) comm = "./adb remount" output = os.popen(comm).read() print output
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def push_dexo(self): os.chdir(Tools) comm = "./adb push " + Odex + '/dexo ' + '/system/bin' output = os.popen(comm).read() print output
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def push_dexopt(self): os.chdir(Tools) comm = "./adb push " + Odex + '/dexopt-wrapper ' + '/system/bin' output = os.popen(comm).read() print output
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def push_zip(self): os.chdir(Tools) comm = "./adb push " + Odex + '/zip' + '/system/xbin' output = os.popen(comm).read() print output
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def push_zipalign(self): os.chdir(Tools) comm = "./adb push " + Odex + '/zipalign' + '/system/xbin' output = os.popen(comm).read() print output
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def push_busybox(self): os.chdir(Tools) comm = "./adb push " + Odex + '/busybox ' + '/system/xbin' output = os.popen(comm).read() print output
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def change_perms(self): os.chdir(Tools) comm = "./adb shell chmod 755 /system/bin/dexo /system/bin/dexopt-wrapper /system/xbin/zip /system/xbin/zipalign /system/xbin/busybox" output = os.popen(comm).read() print output
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def ins_busybox(self): os.chdir(Tools) comm = "./adb shell busybox --install /system/xbin" output = os.popen(comm).read() print output
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def run_dexo(self): os.chdir(Tools) comm = "./adb shell dexo" output = os.popen(comm).read() print output
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def pull_frame(self): os.chdir(Home) os.mkdir('%s/Desktop/framework' % Home) os.chdir('%s/Desktop/framework' % Home) os.chdir(Tools) comm = "./adb pull /system/framework %s/Desktop/framework" % Home output = os.popen(comm).read() print ...
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def pull_app(self): os.chdir(Home) os.mkdir('%s/Desktop/app' % Home) os.chdir('%s/Desktop/app' % Home) os.chdir(Tools) comm = "./adb pull /system/app %s/Desktop/app" % Home output = os.popen(comm).read() print output
wes342/EasyDevStudio
[ 2, 1, 2, 5, 1342553500 ]
def manager_and_vm(request, ssh_key, module_tmpdir, test_config, logger): hosts = Hosts(ssh_key, module_tmpdir, test_config, logger, request, 2) hosts.instances[0] = VM('master', test_config) hosts.instances[1] = VM('centos_7', test_config) manager, vm = hosts.instances passed = ...
cloudify-cosmo/cloudify-system-tests
[ 7, 18, 7, 3, 1396352657 ]
def example(manager_and_vm, ssh_key, tmpdir, logger, test_config): manager, vm = manager_and_vm example = get_example_deployment( manager, ssh_key, logger, 'inplace_restore', test_config, vm) try: yield example finally: if example.installed: example.uninstall()
cloudify-cosmo/cloudify-system-tests
[ 7, 18, 7, 3, 1396352657 ]
def load_mnist_dataset(shape=(-1,784), path="data/mnist/"): """Automatically download MNIST dataset and return the training, validation and test set with 50000, 10000 and 10000 digit images respectively. Parameters ---------- shape : tuple The shape of digit images, defaults to (-1,784)...
zjuela/LapSRN-tensorflow
[ 102, 44, 102, 7, 1508356267 ]
def unpickle(file): fp = open(file, 'rb') if sys.version_info.major == 2: data = pickle.load(fp) elif sys.version_info.major == 3: data = pickle.load(fp, encoding='latin-1') fp.close() return data
zjuela/LapSRN-tensorflow
[ 102, 44, 102, 7, 1508356267 ]
def load_ptb_dataset(path='data/ptb/'): """Penn TreeBank (PTB) dataset is used in many LANGUAGE MODELING papers, including "Empirical Evaluation and Combination of Advanced Language Modeling Techniques", "Recurrent Neural Network Regularization". It consists of 929k training words, 73k validation words...
zjuela/LapSRN-tensorflow
[ 102, 44, 102, 7, 1508356267 ]
def load_imdb_dataset(path='data/imdb/', nb_words=None, skip_top=0, maxlen=None, test_split=0.2, seed=113, start_char=1, oov_char=2, index_from=3): """Load IMDB dataset Parameters ---------- path : : string Path to download data to, defaults to data/imdb/ Exampl...
zjuela/LapSRN-tensorflow
[ 102, 44, 102, 7, 1508356267 ]
def load_wmt_en_fr_dataset(path='data/wmt_en_fr/'): """It will download English-to-French translation data from the WMT'15 Website (10^9-French-English corpus), and the 2013 news test from the same site as development set. Returns the directories of training data and test data. Parameters -----...
zjuela/LapSRN-tensorflow
[ 102, 44, 102, 7, 1508356267 ]
def save_npz(save_list=[], name='model.npz', sess=None): """Input parameters and the file name, save parameters into .npz file. Use tl.utils.load_npz() to restore. Parameters ---------- save_list : a list Parameters want to be saved. name : a string or None The name of the .npz file...
zjuela/LapSRN-tensorflow
[ 102, 44, 102, 7, 1508356267 ]
def load_npz(path='', name='model.npz'): """Load the parameters of a Model saved by tl.files.save_npz(). Parameters ---------- path : a string Folder path to .npz file. name : a string or None The name of the .npz file. Returns -------- params : list A list of p...
zjuela/LapSRN-tensorflow
[ 102, 44, 102, 7, 1508356267 ]
def assign_params(sess, params, network): """Assign the given parameters to the TensorLayer network. Parameters ---------- sess : TensorFlow Session. Automatically run when sess is not None. params : a list A list of parameters in order. network : a :class:`Layer` class The netw...
zjuela/LapSRN-tensorflow
[ 102, 44, 102, 7, 1508356267 ]
def save_any_to_npy(save_dict={}, name='file.npy'): """Save variables to .npy file. Examples --------- >>> tl.files.save_any_to_npy(save_dict={'data': ['a','b']}, name='test.npy') >>> data = tl.files.load_npy_to_any(name='test.npy') >>> print(data) ... {'data': ['a','b']} """ np.sav...
zjuela/LapSRN-tensorflow
[ 102, 44, 102, 7, 1508356267 ]
def npz_to_W_pdf(path=None, regx='w1pre_[0-9]+\.(npz)'): """Convert the first weight matrix of .npz file to .pdf by using tl.visualize.W(). Parameters ---------- path : a string or None A folder path to npz files. regx : a string Regx for the file name. Examples -------- ...
zjuela/LapSRN-tensorflow
[ 102, 44, 102, 7, 1508356267 ]
def load_file_list(path=None, regx='\.npz', printable=True): """Return a file list in a folder by given a path and regular expression. Parameters ---------- path : a string or None A folder path. regx : a string The regx of file name. printable : boolean, whether to print the fi...
zjuela/LapSRN-tensorflow
[ 102, 44, 102, 7, 1508356267 ]
def exists_or_mkdir(path, verbose=True): """Check a folder by given name, if not exist, create the folder and return False, if directory exists, return True. Parameters ---------- path : a string A folder path. verbose : boolean If True, prints results, deaults is True Retu...
zjuela/LapSRN-tensorflow
[ 102, 44, 102, 7, 1508356267 ]
def _download(filename, working_directory, url_source): def _dlProgress(count, blockSize, totalSize): if(totalSize != 0): percent = float(count * blockSize) / float(totalSize) * 100.0 sys.stdout.write("\r" "Downloading " + filename + "...%d%%" % percent) ...
zjuela/LapSRN-tensorflow
[ 102, 44, 102, 7, 1508356267 ]
def __init__(self): """Object mapper starts off with empty value.""" self.value = None self.seen = set()
GoogleCloudPlatform/appengine-config-transformer
[ 7, 16, 7, 4, 1435336968 ]
def see(self, key): if key in self.seen: raise yaml_errors.DuplicateAttribute("Duplicate attribute '%s'." % key) self.seen.add(key)
GoogleCloudPlatform/appengine-config-transformer
[ 7, 16, 7, 4, 1435336968 ]
def __init__(self): """Object sequencer starts off with empty value.""" self.value = [] self.constructor = None
GoogleCloudPlatform/appengine-config-transformer
[ 7, 16, 7, 4, 1435336968 ]
def __init__(self, default_class): """Initialize validated object builder. Args: default_class: Class that is instantiated upon the detection of a new document. An instance of this class will act as the document itself. """ self.default_class = default_class
GoogleCloudPlatform/appengine-config-transformer
[ 7, 16, 7, 4, 1435336968 ]
def BuildDocument(self): """Instantiate new root validated object. Returns: New instance of validated object. """ return self.default_class()
GoogleCloudPlatform/appengine-config-transformer
[ 7, 16, 7, 4, 1435336968 ]
def EndMapping(self, top_value, mapping): """When leaving scope, makes sure new object is initialized. This method is mainly for picking up on any missing required attributes. Args: top_value: Parent of closing mapping object. mapping: _ObjectMapper instance that is leaving scope. """ ...
GoogleCloudPlatform/appengine-config-transformer
[ 7, 16, 7, 4, 1435336968 ]
def MapTo(self, subject, key, value): """Map key-value pair to an objects attribute. Args: subject: _ObjectMapper of object that will receive new attribute. key: Key of attribute. value: Value of new attribute. Raises: UnexpectedAttribute when the key is not a validated attribute o...
GoogleCloudPlatform/appengine-config-transformer
[ 7, 16, 7, 4, 1435336968 ]
def BuildObjects(default_class, stream, loader=yaml.loader.SafeLoader): """Build objects from stream. Handles the basic case of loading all the objects from a stream. Args: default_class: Class that is instantiated upon the detection of a new document. An instance of this class will act as the docume...
GoogleCloudPlatform/appengine-config-transformer
[ 7, 16, 7, 4, 1435336968 ]
def __init__(self, bot): self.bot = bot print('Addon "{}" loaded'.format(self.__class__.__name__))
916253/Kurisu
[ 60, 102, 60, 34, 1476594488 ]
def option(): return options.copy()
openweave/happy
[ 41, 22, 41, 7, 1504117462 ]
def __init__(self, opts=options): HappyNode.__init__(self) self.quiet = opts["quiet"] self.add = opts["add"] self.delete = opts["delete"] self.dns = opts["dns"] self.node_id = opts["node_id"]
openweave/happy
[ 41, 22, 41, 7, 1504117462 ]
def __add_node_dns(self, node_id): nspath = self.nsroot + "/" + self.uniquePrefix(node_id) resolv_path = nspath + "/" + "resolv.conf" if not os.path.isdir(nspath): cmd = "mkdir -p " + nspath cmd = self.runAsRoot(cmd) ret = self.CallAtHost(cmd) if not...
openweave/happy
[ 41, 22, 41, 7, 1504117462 ]
def __update_nodes_dns(self): if self.node_id: nodes = [self.node_id] else: nodes = self.getNodeIds() for node_id in nodes: if self.add: self.__add_node_dns(node_id) else: self.__remove_node_dns(node_id)
openweave/happy
[ 41, 22, 41, 7, 1504117462 ]
def metric_fn(labels, logits): """Record metrics for evaluation.""" predictions = tf.argmax(logits, 1) return { "accuracy": tf.metrics.precision(labels=labels, predictions=predictions) }
GoogleCloudPlatform/healthcare
[ 332, 163, 332, 30, 1519345980 ]
def get_input_fn(filename): """Returns an `input_fn` for training and evaluation.""" def input_fn(params): # Retrieves the batch size for the current shard. The number of shards is # computed according to the input pipeline deployment. See # https://www.tensorflow.org/api_docs/python/tf/contrib/tpu/Run...
GoogleCloudPlatform/healthcare
[ 332, 163, 332, 30, 1519345980 ]
def toFileName(text, max_length=1000): return text.replace("/","_").replace("\\","_").replace("'","_").replace('"',"_").replace(".","_").replace(":","_").replace("__","_").replace(" ","_")[:max_length]
FirstDraftGIS/firstdraft
[ 10, 1, 10, 14, 1441325314 ]
def generate_map_from_sources(job, data_sources, metadata_sources, debug=False): try: print("starting generate_map_from_sources w job") key = job['key'] max_seconds = int(job.get('max_seconds', 10)) countries = job.get('countries', []) admin1limits = job.get('admin1limits',...
FirstDraftGIS/firstdraft
[ 10, 1, 10, 14, 1441325314 ]
def named_set(self, elem): self.named_del(elem.name) self.append(elem)
hicknhack-software/buildbot-inplace-config
[ 5, 1, 5, 1, 1427118672 ]
def named_get(self, name): for elem in self: if elem.name == name: return elem
hicknhack-software/buildbot-inplace-config
[ 5, 1, 5, 1, 1427118672 ]
def names(self): return map(lambda elem: elem.name, self)
hicknhack-software/buildbot-inplace-config
[ 5, 1, 5, 1, 1427118672 ]
def __init__(self, **kwargs): super(Wrapper, self).__init__(**kwargs) self._inplace_workers = NamedList() self._projects = NamedList()
hicknhack-software/buildbot-inplace-config
[ 5, 1, 5, 1, 1427118672 ]
def builders(self): return self.named_list('builders')
hicknhack-software/buildbot-inplace-config
[ 5, 1, 5, 1, 1427118672 ]
def schedulers(self): return self.named_list('schedulers')
hicknhack-software/buildbot-inplace-config
[ 5, 1, 5, 1, 1427118672 ]
def change_source(self): return self.named_list('change_source')
hicknhack-software/buildbot-inplace-config
[ 5, 1, 5, 1, 1427118672 ]
def workers(self): return self.named_list('workers')
hicknhack-software/buildbot-inplace-config
[ 5, 1, 5, 1, 1427118672 ]
def inplace_workers(self): return self._inplace_workers
hicknhack-software/buildbot-inplace-config
[ 5, 1, 5, 1, 1427118672 ]
def projects(self): return self._projects
hicknhack-software/buildbot-inplace-config
[ 5, 1, 5, 1, 1427118672 ]
def load_workers(self, path): Worker.load(path, self.inplace_workers, self.workers)
hicknhack-software/buildbot-inplace-config
[ 5, 1, 5, 1, 1427118672 ]
def setup_inplace(self): self.builders.clear() self.schedulers.clear() builder_name = self.DUMMY_NAME trigger_name = self.DUMMY_TRIGGER worker_names = self.inplace_workers.names self.builders.named_set(BuilderConfig(name=builder_name, workernames=worker_names, factory=Bui...
hicknhack-software/buildbot-inplace-config
[ 5, 1, 5, 1, 1427118672 ]
def setup_project_inplace(self, project): self.setup_inplace() for worker in self.inplace_workers: log.msg("Got worker '%s' for platform %s and setups %s" % (worker.name, pformat(worker.platforms), pformat(worker.setups)), system='Inplace Config') ...
hicknhack-software/buildbot-inplace-config
[ 5, 1, 5, 1, 1427118672 ]
def test_assert_output(self): def f(): print('abc') print('123') sys.stderr.writelines(['def\n', '456\n']) self.assertOutput('abc\n123\n', 'def\n456\n', f)
mogproject/mog-commons-python
[ 2, 1, 2, 2, 1444292691 ]
def f(): print('abc') print('123') sys.stderr.writelines(['def\n', '456\n'])
mogproject/mog-commons-python
[ 2, 1, 2, 2, 1444292691 ]
def test_assert_system_exit(self): self.assertSystemExit(123, lambda: sys.exit(123)) self.assertSystemExit(234, lambda x: sys.exit(x), 234)
mogproject/mog-commons-python
[ 2, 1, 2, 2, 1444292691 ]
def test_with_bytes_output_types(self): # accepts unicode def f(data, expected): with self.withBytesOutput() as (out, err): for d in data: out.write(d) self.assertEqual(out.getvalue(), expected) f(['γ‚γ„γ†γˆγŠ'], 'γ‚γ„γ†γˆγŠ'.encode('utf-8')) ...
mogproject/mog-commons-python
[ 2, 1, 2, 2, 1444292691 ]
def f(text): with self.withAssertOutputFile(os.path.join('tests', 'resources', 'utf8_ja.txt')) as out: out.write(text.encode('utf-8'))
mogproject/mog-commons-python
[ 2, 1, 2, 2, 1444292691 ]
def test_assert_raises_message(self): class MyException(Exception): pass def f(msg): raise MyException(msg) self.assertRaisesMessage(MyException, 'γ‚γ„γ†γˆγŠ', f, 'γ‚γ„γ†γˆγŠ') self.assertRaisesMessage(AssertionError, 'MyException not raised', ...
mogproject/mog-commons-python
[ 2, 1, 2, 2, 1444292691 ]
def onDeviceEvent(self, Event, Gizmo = None): """ Called from Base Class' onEvent method. See GizmodDispatcher.onEvent documention for an explanation of this function """ # if the event isn't from the remote we're interested in don't handle it if Event.Remote not in USES_LIRC_REMOTES: return False # ...
jtriley/gizmod
[ 11, 4, 11, 2, 1319048459 ]
def onEvent(self, Event, Gizmo = None): """ Overloading Base Class' onEvent method! Make sure to call it! """
jtriley/gizmod
[ 11, 4, 11, 2, 1319048459 ]
def __init__(self): """ Default Constructor """
jtriley/gizmod
[ 11, 4, 11, 2, 1319048459 ]
def __init__(self): self.parser = argparse.ArgumentParser() self.parser.add_argument( '-c', '--config', help="magma web config file (default: production.ini)", default="production.ini", type=str) sp = self.parser.add_subparsers() sc_add = sp.add_parse...
NLeSC/MAGMa
[ 12, 5, 12, 7, 1348147214 ]
def update(self, args): "Update user data" user = User.by_id(args.userid) if 'user' in args: user.userid = args.user for job in user.jobs: job.owner = args.user JobMeta.add(job) if 'name' in args: user.displayname = args...
NLeSC/MAGMa
[ 12, 5, 12, 7, 1348147214 ]
def owner(self, args): """Alter owner of job""" job = self.job_factory.fromId(args.job) job.meta.owner = args.user JobMeta.add(job.meta) commit()
NLeSC/MAGMa
[ 12, 5, 12, 7, 1348147214 ]
def configure(self, config_file): config_url = 'config:' + config_file cwd = os.getcwd() self.config = appconfig(config_url, 'MAGMaWeb', relative_to=cwd) engine = engine_from_config(self.config) init_user_db(engine) self.job_factory = make_job_factory(self.config)
NLeSC/MAGMa
[ 12, 5, 12, 7, 1348147214 ]
def __init__(self, gamma_neg=4, gamma_pos=1, clip=0.05, eps=1e-8, disable_torch_grad_focal_loss=False): super(AsymmetricLossMultiLabel, self).__init__()
rwightman/pytorch-image-models
[ 23978, 3956, 23978, 96, 1549086672 ]
def forward(self, x, y): """" Parameters ---------- x: input logits y: targets (multi-label binarized vector) """
rwightman/pytorch-image-models
[ 23978, 3956, 23978, 96, 1549086672 ]
def __init__(self, gamma_pos=1, gamma_neg=4, eps: float = 0.1, reduction='mean'): super(AsymmetricLossSingleLabel, self).__init__()
rwightman/pytorch-image-models
[ 23978, 3956, 23978, 96, 1549086672 ]
def forward(self, inputs, target, reduction=None): """" Parameters ---------- x: input logits y: targets (1-hot vector) """
rwightman/pytorch-image-models
[ 23978, 3956, 23978, 96, 1549086672 ]
def test_split(self): assert split_command_line('foo') == ['foo'] assert split_command_line(['foo']) == ['foo'] assert split_command_line('foo bar') == ['foo', 'bar'] assert split_command_line(['foo bar']) == ['foo', 'bar']
mbedmicro/pyOCD
[ 883, 424, 883, 228, 1382710205 ]
def test_split_whitespace(self): assert split_command_line('a b') == ['a', 'b'] assert split_command_line('a\tb') == ['a', 'b'] assert split_command_line('a\rb') == ['a', 'b'] assert split_command_line('a\nb') == ['a', 'b'] assert split_command_line('a \tb') == ['a', 'b']
mbedmicro/pyOCD
[ 883, 424, 883, 228, 1382710205 ]