commit
stringlengths
40
40
subject
stringlengths
1
1.49k
old_file
stringlengths
4
311
new_file
stringlengths
4
311
new_contents
stringlengths
1
29.8k
old_contents
stringlengths
0
9.9k
lang
stringclasses
3 values
proba
float64
0
1
fd5ccdb154cc00a1ff58d13043435f7b1927ca68
fix apparent paste-buffer corruption
direct/src/distributed/CRCache.py
direct/src/distributed/CRCache.py
"""CRCache module: contains the CRCache class""" import DirectNotifyGlobal import DistributedObject class CRCache: notify = DirectNotifyGlobal.directNotify.newCategory("CRCache") def __init__(self, maxCacheItems=10): self.maxCacheItems = maxCacheItems self.dict = {} self.fifo = [] ...
"""CRCache module: contains the CRCache class""" import DirectNotifyGlobal import DistributedObject class CRCache: notify = DirectNotifyGlobal.directNotify.newCategory("CRCache") def __init__(self, maxCacheItems=10): self.maxCacheItems = maxCacheItems self.dict = {} self.fifo = [] ...
Python
0.000026
ff0772194bfd216d473f27c6d79746ee0fe8d1bf
Create jobs.py
jobs/jobs.py
jobs/jobs.py
import discord import os import asyncio import datetime from cogs.utils.dataIO import dataIO from discord.ext import commands from __main__ import send_cmd_help from .economy import NoAccount, NegativeValue class Jobs: """Jobs""" def __init__(self, bot): self.bot = bot self.jobs = dataIO.load_...
Python
0.000001
e0bfc2bdff3d44c8839e4c04948e8da824f7b260
Write requests-like get()
spyglass/util.py
spyglass/util.py
from urllib2 import urlopen from collections import namedtuple Response = namedtuple('Response', ['text']) def get(url): return Response(text=urlopen(url).read())
Python
0.004638
96c08b94d40850b5dd703b052943de2827ebf9f9
create command.py and abstract command template
foxybot/command.py
foxybot/command.py
"""Provide a template for making commands and a decorator to register them.""" from abc import abstractmethod, abstractclassmethod, ABCMeta from enum import Enum from registrar import CommandRegistrar def bot_command(cls): command = cls() if not issubclass(command.__class__, AbstractCommand): print(...
Python
0
657620bcb755185244363062b41a3e6b942d1e77
Fix config error on ubuntu machine
module/pych/configuration.py
module/pych/configuration.py
""" Loads and stores pyChapel configuration. """ # pylint: disable=maybe-no-member # The configuration object does have the "__file__" member via the module. # pylint: disable=too-few-public-methods # The configuration wraps around the configuration state, access is provided # through __getitem__ it is perfectly valid ...
""" Loads and stores pyChapel configuration. """ # pylint: disable=maybe-no-member # The configuration object does have the "__file__" member via the module. # pylint: disable=too-few-public-methods # The configuration wraps around the configuration state, access is provided # through __getitem__ it is perfectly valid ...
Python
0.000001
e85d1f0e9b198184103973f198bf1ceddbca6a65
declare the federica rspec schemas
sfa/rspecs/versions/federica.py
sfa/rspecs/versions/federica.py
from sfa.rspecs.versions.pgv2 import PGv2Ad, PGv2Request, PGv2Manifest class FedericaAd (PGv2Ad): enabled = True schema = 'http://sorch.netmode.ntua.gr/ws/RSpec/ad.xsd' namespace = 'http://sorch.netmode.ntua.gr/ws/RSpec' class FedericaRequest (PGv2Request): enabled = True schema = 'http://sorch.ne...
Python
0.998416
c055009077546b22090897f79f4facce8bdb97d5
change module names in hvc/__init__.py
hvc/__init__.py
hvc/__init__.py
""" __init__.py imports key functions from modules to package level """ from .utils.features import load_feature_file from .extract import extract from .predict import predict from .select import select from .parseconfig import parse_config from . import metrics from . import plot
""" __init__.py imports key functions from modules to package level """ from .utils.features import load_feature_file from .featureextract import extract from .labelpredict import predict from .modelselect import select from .parseconfig import parse_config from . import metrics from . import plot
Python
0.000017
67737629c2d507c0e9fc96bb53695d2fbdcc1e8f
point_of_sale : Removed print statement.
addons/point_of_sale/report/pos_invoice.py
addons/point_of_sale/report/pos_invoice.py
# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved # $Id$ # # This program is free software: you can redistribute it and/or modify # ...
# -*- encoding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved # $Id$ # # This program is free software: you can redistribute it and/or modify #...
Python
0.998475
fa375d06128e493f86524e82fa93c892f4d925b7
Add script to find forms missing in ES
corehq/apps/data_pipeline_audit/management/commands/find_sql_forms_not_in_es.py
corehq/apps/data_pipeline_audit/management/commands/find_sql_forms_not_in_es.py
from __future__ import absolute_import from __future__ import division from __future__ import unicode_literals from __future__ import print_function from datetime import datetime from django.core.management.base import BaseCommand import sys from django.db.models import Q, F from django.db.models.functions import Grea...
Python
0.000001
20151dcae4cbbe1294d1c859dc70449bfd3378cc
Create alphabet-tree-checker.py
alphabet-tree-checker.py
alphabet-tree-checker.py
''' Alphabet tree output checker. Takes input as a filename argument, or requests from keyboard if no filename is provided. Reports on whether input matches requirement for the following question: http://codegolf.stackexchange.com/questions/35862/make-me-an-alphabet-tree ''' import string CONNECTIONS = dict(A = [3,...
Python
0.999902
51372b15e9abe4c0ae35294ec51694751fe2ae32
Add a py2exe configuration setup.
src/bin/setup.py
src/bin/setup.py
from distutils.core import setup import py2exe, sys from glob import glob sys.path.append("C:\\Temp\\Microsoft.VC90.CRT") data_files = [("Microsoft.VC90.CRT", glob(r'C:\Temp\Microsoft.VC90.CRT\*.*'))] setup( data_files=data_files, console=['ride.py'])
Python
0
d8521011d5be28812c222b58901a07e8f30e87ac
Add testing code for memory leak.
neuralstyle/testing-train.py
neuralstyle/testing-train.py
from __future__ import print_function import argparse import numpy as np import torch from torch.autograd import Variable from torch.optim import Adam from torch.utils.data import DataLoader from torchvision import transforms from torchvision import datasets from transformernet import TransformerNet from vgg16 impor...
Python
0
5a2308cc98a99e9c74c14611fdb45adf7601d390
prepare bruteforce for http basic authentication; do not forget to create the b64 encoder in zap payload processor;
payload_generator/bruteforce.py
payload_generator/bruteforce.py
# Auxiliary variables/constants for payload generation. INITIAL_VALUE = 0; count = INITIAL_VALUE; user = str('admin'); passfile_path = 'C:\\Users\\user\\Documents\\wordlists\\test.txt'; NUMBER_OF_PAYLOADS = sum(1 for line in open(passfile_path)); passwd = list(); for line in open(passfile_path): # initializing pass...
Python
0
0ced2a66affd65a3dda90dc49bac8bd43e1c6fa7
Remove index on LogRecord.message.
peavy/migrations/0004_drop_message_index.py
peavy/migrations/0004_drop_message_index.py
# encoding: utf-8 from south.db import db from south.v2 import SchemaMigration class Migration(SchemaMigration): def forwards(self, orm): # Removing index on 'LogRecord', fields ['message'] db.delete_index('peavy_logrecord', ['message']) def backwards(self, orm): # Adding index on 'L...
Python
0
f3e91020f0426fedfe229e94bf1ddc69dd64a136
Add new example plot for `match_template`.
doc/examples/plot_template_alt.py
doc/examples/plot_template_alt.py
""" ================= Template Matching ================= In this example, we use template matching to identify the occurrence of an image patch (in this case, a sub-image centered on a single coin). Here, we return a single match (the exact same coin), so the maximum value in the ``match_template`` result corresponds...
Python
0
fc1c0a563f8bd4fd33e63285ab6af79825b8b927
Add a modified terminalcolors.py
bin/terminalcolors.py
bin/terminalcolors.py
#!/usr/bin/env python # Copyright (C) 2006 by Johannes Zellner, <johannes@zellner.org> # modified by mac@calmar.ws to fit my output needs # modified by crncosta@carloscosta.org to fit my output needs # modified by joeyates, 2014 from os import system def foreground(n): system('tput setaf %u' % n) def background(...
Python
0.000001
1de610b2460b3b3bff24b79398d214001097e562
Implement Gmail OAuth 2.0.
notifyhere/dash/api/gmail.py
notifyhere/dash/api/gmail.py
from httplib import HTTPSConnection import json import base import tools import secrets class GmailApi(base.ApiBase): def __init__(self): base.ApiBase.__init__(self, "gmail") self.token = "" def icon_url(self): return "https://mail.google.com/favicon.ico" def oauth_link(self...
Python
0.000055
5f81d53c16816289cf52a5b4118e482b7650defe
Add MaintenanceMiddleware
app/soc/middleware/maintenance.py
app/soc/middleware/maintenance.py
#!/usr/bin/python2.5 # # Copyright 2009 the Melange authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
Python
0
4f1bb01bba0c2241a190bbf7fb21683be630abfa
Create Glyph3D.py
src/Python/Filtering/Glyph3D.py
src/Python/Filtering/Glyph3D.py
#!/usr/bin/env python import vtk def main(): colors = vtk.vtkNamedColors() points = vtk.vtkPoints() points.InsertNextPoint(0,0,0) points.InsertNextPoint(1,1,1) points.InsertNextPoint(2,2,2) polydata = vtk.vtkPolyData() polydata.SetPoints(points) # Create anything you wan...
Python
0.000001
89262fbd2375724ff9120fe01799a036b1c34f6f
add new package at v1.1.6 (#20598)
var/spack/repos/builtin/packages/py-mercantile/package.py
var/spack/repos/builtin/packages/py-mercantile/package.py
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * class PyMercantile(PythonPackage): """Web mercator XYZ tile utilities.""" homepage = "https...
Python
0
41bc3c33cc1442105f019e06c40d189c27f65758
add save_json helper
vsmlib/misc/data.py
vsmlib/misc/data.py
import json def save_json(data, path): # if not os.path.isdir(path): # os.makedirs(path) s = json.dumps(data, ensure_ascii=False, indent=4, sort_keys=True) f = open(path, 'w') f.write(s) f.close()
Python
0.000001
8483a311f75a3d3682e66fba2f805ea20ebf6870
add memory usage beacon
salt/beacons/memusage.py
salt/beacons/memusage.py
# -*- coding: utf-8 -*- ''' Beacon to monitor memory usage. .. versionadded:: :depends: python-psutil ''' # Import Python libs from __future__ import absolute_import import logging import re # Import Salt libs import salt.utils # Import Third Party Libs try: import psutil HAS_PSUTIL = True except ImportErr...
Python
0.000001
16193b302bb07429c604af2a9637850c2e751d1f
Add script to be run as cron job
stoneridge_cronjob.py
stoneridge_cronjob.py
#!/usr/bin/env python # This Source Code Form is subject to the terms of the Mozilla Public License, # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at http://mozilla.org/MPL/2.0/. import argparse import ConfigParser import os import subprocess import sys import tempfile import ...
Python
0.000001
9e6f8768d60d38e69074c5275637deaa62e6fc9e
check how often URL matching would match the right documents in the test corpus
baseline/url_matching.py
baseline/url_matching.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import os from strip_language_from_uri import LanguageStripper import chardet from collections import defaultdict import re import urlparse def has_prefix(prefixes, s): "Returns true if s starts with one of the prefixes" for p in prefixes: if s....
Python
0.000001
d1ffd984bae034076244ac4449632a1aa04d5ffe
Refactor to Linter v2 API
bears/php/PHPLintBear.py
bears/php/PHPLintBear.py
from coalib.bearlib.abstractions.Linter import linter from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY @linter(executable='php', output_format='regex', output_regex=r'(?P<severity>Parse|Fatal) error: (?P<message>.*) in ' r'.* on line (?P<line>\d+)', severity_map=...
import re from coalib.bearlib.abstractions.Lint import Lint from coalib.bears.LocalBear import LocalBear from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY class PHPLintBear(LocalBear, Lint): executable = 'php' arguments = '-l -n -d display_errors=On -d log_errors=Off {filename}' output_regex = r...
Python
0
34560978ee8f33ab8ddc60a1a3525979119a952e
Add run script
profile_compressible_solver/run_profiler.py
profile_compressible_solver/run_profiler.py
from firedrake.petsc import PETSc from argparse import ArgumentParser from driver import run_profliler import sys PETSc.Log.begin() parser = ArgumentParser(description=(""" Profile of 3D compressible solver for the Euler equations (dry atmosphere). """), add_help=False) parser.add_argument("--hybridization", ...
Python
0.000001
55f0e8bbddee976f020628c552eb22d8ed894c1a
question 0001 solved
vvzwvv/0001/0001.py
vvzwvv/0001/0001.py
import uuid def gen(num, len): L = [] for i in range(num): ran = str(uuid.uuid4()).replace('-', '')[:len] if not ran in L: L.append(ran) return L if __name__ == '__main__': for item in gen(200, 16): print(item)
Python
0.999999
ee2a4c1edb6d2f1273bb08080e8fc00b0a0e9074
add pack1/mymodule1.py
python/18-package/parent/pack1/mymodule1.py
python/18-package/parent/pack1/mymodule1.py
#!/usr/bin/env python #-*- coding=utf-8 -*- def function1(): print "function1 running" if __name__ == "__main__": print "mymodule1 running as main program" else: print "mymodule1 initializing"
Python
0.000023
a29e340efa60ecb05d85e9c6d87ec709ba26822f
Add new extractor(closes #14361)
youtube_dl/extractor/bibeltv.py
youtube_dl/extractor/bibeltv.py
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor class BibelTVIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/mediathek/videos/(?:crn/)?(?P<id>\d+)' _TESTS = [{ 'url': 'https://www.bibeltv.de/mediathek/videos/329703-sprachkurs-in-malaiisch', ...
Python
0
76cce82d65868619b096d74a5adb3a616cfe771d
Create new package. (#5810)
var/spack/repos/builtin/packages/r-affyilm/package.py
var/spack/repos/builtin/packages/r-affyilm/package.py
############################################################################## # Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC. # Produced at the Lawrence Livermore National Laboratory. # # This file is part of Spack. # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. # LLNL-CODE-64...
Python
0
da42b3854d85b1df42c67e4e5f3d9131aacecd2c
Turn on template debugging in test settings
{{cookiecutter.project_slug}}/config/settings/test.py
{{cookiecutter.project_slug}}/config/settings/test.py
# -*- coding: utf-8 -*- ''' Test settings - Used to run tests fast on the continuous integration server and locally ''' from .common import * # noqa # DEBUG # ------------------------------------------------------------------------------ # Turn debug off so tests run faster DEBUG = False # But template debugging m...
# -*- coding: utf-8 -*- ''' Test settings - Used to run tests fast on the continuous integration server and locally ''' from .common import * # noqa # DEBUG # ------------------------------------------------------------------------------ # Turn debug off so tests run faster DEBUG = False TEMPLATES[0]['OPTIONS']['d...
Python
0.997035
d7017acef8ed540bb2f3c00d268cd417d75f09e3
add import script for Fareham (closes #858)
polling_stations/apps/data_collection/management/commands/import_fareham.py
polling_stations/apps/data_collection/management/commands/import_fareham.py
from data_collection.management.commands import BaseXpressDemocracyClubCsvImporter class Command(BaseXpressDemocracyClubCsvImporter): council_id = 'E07000087' addresses_name = 'parl.2017-06-08/Version 1/Democracy_Club__08June2017 (1).tsv' stations_name = 'parl.2017-06-08/Version 1/Democracy_Club__08June201...
Python
0
675b87d5bc072d5b6fbd1f9a54ec61d98b1139ac
Add lab2 file.
lab2.py
lab2.py
# -*- coding: utf-8 -*- from math import pow def mymap1(fun, l): res = [] for i in l: res.append(fun(i)) return res #print(mymap1(str, [3, 1, 7, 4, 6, 9])) def mymap2(fun, *l): res = [] for i in zip(*l): print(i) res.append(fun(*i)) return res #print(mymap2(lambda a...
Python
0
bea495bb58146fc3795d2217ef3b27ce0325014b
create the Spider for Israel of McDonalds
locations/spiders/mcdonalds_il.py
locations/spiders/mcdonalds_il.py
# -*- coding: utf-8 -*- import scrapy import json import re from locations.items import GeojsonPointItem class McDonalsILSpider(scrapy.Spider): name = "mcdonalds_il" allowed_domains = ["www.mcdonalds.co.il"] start_urls = ( 'https://www.mcdonalds.co.il/%D7%90%D7%99%D7%AA%D7%95%D7%A8_%D7%9E%D7%A1%D...
Python
0
252925fa998412ac868eb63790fbd515c429ac67
add main entry point (untested, but should be complete now)
main.py
main.py
""" Core namespace. Handles: 1. Call out to hashio to check hashes, save log, and return results 2. Load tweetlog and tweet creds 3. Generate and log tweets for changed files 4. Generate and log tweets for new files 4. Save tweetlog """ import hash, hashio, twitter, json from copy import deepcopy def load_twe...
Python
0
21028c13585fbcd5315efd74ab55f5d03d69c500
add probe nsrl
nsrl.py
nsrl.py
import hashlib from pymongo import MongoClient from lib.irma.common.exceptions import IrmaDatabaseError class NsrlInfo(object): _uri = "mongodb://localhost:27017/" _dbname = "nsrl" _collection = "hashset" def __init__(self): self._dbh = None def _connect(self): try: if...
Python
0.000001
f151d1cc5ddb3b60c6410153e147ccd5c0378904
Add Sequence object
oeis.py
oeis.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ py-oeis A Python library to access the OEIS. Sumant Bhaskaruni v0.1 """ import requests class Sequence(object): """An object to represent a single OEIS sequence. Initializer arguments: number (int): The OEIS sequence ID """ def __init__(s...
Python
0.00001
eb56d833efad16e9a84724d18121528177f37adb
add 41
p041.py
p041.py
import utils primes = utils.primes(7654321) def p(n): sn = str(n) lsn = len(sn) if lsn > 10: return False return set([ int(d) for d in sn ]) == set(range(1, len(sn) + 1)) primes.reverse() for prime in primes: if p(prime): print prime break
Python
0.999998
025103ad59d389981532dbb42332dd2a26e475c5
add torperf2.py script to measure hidden service performance
torperf2.py
torperf2.py
import socket, sys, time, subprocess, threading, signal import TorCtl.TorCtl debug = sys.stderr HOST = '127.0.0.1' PORT = 10951 shared = dict( torprocess = None, torlock = threading.Lock() ) TORRC = """\ SocksListenAddress %s SocksPort %d ControlPort %d CookieAuthentication 1 RunAsDaemon 0 Log info file logfile ...
Python
0
83b64fee60fd77bc80f3dda307c74b53b35f6581
Add an example that uses asyncio.
examples/asyncio_socket_server.py
examples/asyncio_socket_server.py
"""Demo of using urwid with Python 3.4's asyncio. This code works on older Python 3.x if you install `asyncio` from PyPI, and even Python 2 if you install `trollius`! """ from __future__ import print_function import asyncio from datetime import datetime import sys import weakref import urwid from urwid.raw_display i...
Python
0.000004
d433f9926ea14d35a8be9cd258300671051547a5
Add refine_multiple_shards_joint.py
refine_multiple_shards_joint.py
refine_multiple_shards_joint.py
# refine_multiple_shards_joint.py # Imports import argparse import matplotlib.pyplot as plt import numpy as np import visualise_progress as vis from functools import partial from operator import itemgetter from pickle_ import dump from solve import fit_and_colour_shards from time import time # main de...
Python
0.000036
9efa33b28b86feaa204ebb84955022b7716a98ba
resolve conflicts
seqr/migrations/0057_merge_20190513_2009.py
seqr/migrations/0057_merge_20190513_2009.py
# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-05-13 20:09 from __future__ import unicode_literals from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('seqr', '0056_auto_20190513_1621'), ('seqr', '0056_auto_20190424_2059'), ] operatio...
Python
0.00004
6af2adf3257e9cb9130909fed531cc2f6bae8945
Add a Mac-specifc snapshot build archive bisecting tool.
build/build-bisect.py
build/build-bisect.py
#!/usr/bin/python2.5 # Copyright (c) 2009 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Snapshot Build Bisect Tool This script bisects the Mac snapshot archive using binary search. It starts at a bad revision (it wil...
Python
0.000002
ba8d38f278169b5d71e85e4d74a43fcd4a3892ae
Test decorator
99_misc/decorator.py
99_misc/decorator.py
#/usr/bin/env python def my_func1(callback): def func_wrapper(x): print("my_func1: {0} ".format(callback(x))) return func_wrapper @my_func1 def my_func2(x): return x # Actuall call sequence is similar to: # deco = my_func1(my_func2) # deco("test") => func_wrapper("test") my_func2("test") #-------...
Python
0.000002
82d5856b09c42b09f857976075d40b6c6568a7c8
Create gate_chk_aws.py
gate_chk/gate_chk_aws.py
gate_chk/gate_chk_aws.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import nfc import spidev import smbus import re import mysql.connector import time def getid(tag): global id a = '%s' % tag id = re.findall("ID=([0-9A-F]*)",a)[0] con = mysql.connector.connect(user=‘xxxxxxxxxx', password=‘xxxxxxxxxx', host=‘xxxxxxxxxx-xxxxx-...
Python
0.000003
a8266c9ff0526b1ada6f48c849892d1d29907710
Add the workers which compute who receive which notification and where
fmn/consumer/worker.py
fmn/consumer/worker.py
# FMN worker figuring out for a fedmsg message the list of recipient and # contexts import json import logging import time import random import fmn.lib import fmn.rules.utils import fedmsg import fedmsg.meta from fmn.consumer.util import load_preferences from fedmsg_meta_fedora_infrastructure import fasshim impor...
Python
0.000002
870d30a0cb7788055cfc9c22854cdbe6293036fa
create class to list preset and metapreset
settingMod/PresetList.py
settingMod/PresetList.py
#!/usr/bin/python3.4 # -*-coding:Utf-8 -* '''module to manage preset list''' import xml.etree.ElementTree as xmlMod import os class PresetList: '''class to manage preset list''' def __init__(self, xml= None): '''initialize preset list with default value or values extracted from an xml object''' if xml is Non...
Python
0
de743ccb3d4b6556c66765a8cab93729abc22fa5
Add a script for batch provisioning of SecurityMonkey role
scripts/secmonkey_role_setup.py
scripts/secmonkey_role_setup.py
#!/usr/bin/env python # Copyright 2014 Rocket-Internet # Luca Bruno <luca.bruno@rocket-internet.de> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
Python
0
430ca4b6a6f134346efaae430fac2bfaff195fe1
Add files via upload
1stANNrecoded2Python.py
1stANNrecoded2Python.py
#imports here: numpy, os, whatever I need n = 1000 e = (1.0 + 1.0/n)^n #Instantiate a new layer with the number of neurons desired, give the neurons (Q: do neurons have separate values than their weights?) random values. def layerFactory(numberOfNeurons): #create weights between layers (essentially, populate the f...
Python
0
5b098392cee7f6526947d45bfc620573c631e4cf
Create add-P67-wikidata-url
my-ACG/add-P67-wikidata-url/edit.py
my-ACG/add-P67-wikidata-url/edit.py
# -*- coding: utf-8 -*- import argparse import csv import os os.environ['PYWIKIBOT_DIR'] = os.path.dirname(os.path.realpath(__file__)) import pywikibot site = pywikibot.Site() site.login() datasite = site.data_repository() def addWikidataUrl(title, targettitle): print(title) if title[0] == 'Q': my...
Python
0
52fd7e5e6ae5ec6ab7de8a858fd2b132fe0d4081
Create CGOLprintToScreen.py
CGOLprintToScreen.py
CGOLprintToScreen.py
import sys tiles_size = 64 class cell: def __init__(self, location, alive=False): self.alive = alive self.location = location class Rules: def rule(self): # if alive for i in range(tiles_size): for j in range(tiles_size): c = self.neighbourscounter(tile[...
Python
0
9b5f070705de9896c8c6f8347dc0f733ae748793
Add harvesting blog data example
harvesting_blog_data.py
harvesting_blog_data.py
import os import sys import json import feedparser from bs4 import BeautifulSoup FEED_URL = 'http://g1.globo.com/dynamo/rss2.xml' def cleanHtml(html): return BeautifulSoup(html, 'lxml').get_text() fp = feedparser.parse(FEED_URL) print "Fetched %s entries from '%s'" % (len(fp.entries[0].title), fp.feed.title) b...
Python
0
630d857c188259d04794e817f83f7c10e9ce9896
Add OTP testing
test/test_user_otp.py
test/test_user_otp.py
#!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################### # Copyright Kitware Inc. # # Licensed under the Apache License, Version 2.0 ( the "License" ); # you may not use this file except in compliance with the License. # You may obtain a copy of ...
Python
0
f40788bdc60566fc15a7abb46bfca61bb9131823
Test update
test.py
test.py
#!/usr/bin/env python def main(): print "Hello world" if __name__ == "__main__": main()
Python
0
b07ca938d68dff3386007885a6da4f5b2e593941
Add prototype
test.py
test.py
#!/usr/bin/python from construct import * import sys def align4(n): return n + ((n+4) % 4) chunk_atom = Struct("chunk_atom", UBInt32("len"), Array(lambda ctx: ctx.len, PascalString("atom")) ) chunk_expt = Struct("chunk_expt", UBInt32("len"), Array(lambda ctx: ctx.len, Struct("entry", UBInt32("function"), ...
Python
0.000001
d5aecde4806a130550786f21f8fdd13c27996e16
add test.py and copyright comments
test.py
test.py
# encoding: utf-8 from toPersian import * print enToPersianNumb('شماره کلاس 312') print enToPersianNumb(3123123.9012) print enToPersianNumb(123) print enToPersianchar('sghl ]i ofv') print arToPersianNumb('٣٤٥٦') print arToPersianChar(' ك جمهوري اسلامي ايران') ''' شماره کلاس ۳۱۲ ۳۱۲۳۱۲۳.۹۰۱۲ ۱۲۳ سلام چه خبر ۳۴۵۶ ک ج...
Python
0
3a160d3aed9d5eb7cebe2427f9009b4e0e2f07c4
return doi resolver url instead of doi resolver name
searx/plugins/oa_doi_rewrite.py
searx/plugins/oa_doi_rewrite.py
from flask_babel import gettext import re from searx.url_utils import urlparse, parse_qsl from searx import settings regex = re.compile(r'10\.\d{4,9}/[^\s]+') name = gettext('Open Access DOI rewrite') description = gettext('Avoid paywalls by redirecting to open-access versions of publications when available') defaul...
from flask_babel import gettext import re from searx.url_utils import urlparse, parse_qsl from searx import settings regex = re.compile(r'10\.\d{4,9}/[^\s]+') name = gettext('Open Access DOI rewrite') description = gettext('Avoid paywalls by redirecting to open-access versions of publications when available') defaul...
Python
0.003718
995e35c2a66fd51f9216ed5acc829bac0ac3ddeb
add i3-debug-console script to examples
examples/i3-debug-console.py
examples/i3-debug-console.py
#!/usr/bin/env python3 import i3ipc from curses import wrapper from threading import Timer def con_type_to_text(con): if con.type != 'con': return con.type if len(con.nodes): return 'container' else: return 'view' def layout_txt(con): if con.layout == 'splith': return ...
Python
0.000001
1524a8fd55c682bd8b77b52b9d2d5e5c030c9d2d
Add first tests
test/sciluigi_test.py
test/sciluigi_test.py
import sciluigi from nose.tools import with_setup # Make these variables global #shell_task = None def setup(): global shell_task shell_task = sciluigi.shell("cat <i:input> > <o:output:out.txt>") return shell_task def teardown(): global shell_task shell_task = None @with_setup(setup, teardown) d...
Python
0.000001
ed63c9c828cc609d82eb5afb21f6e24b358bc3cf
Add DoubleLinkedQueue
DoubleLinkedQueue.py
DoubleLinkedQueue.py
class _DoubleLinkedList: class _Node: __slots__ = '_element', '_prev', '_next' def __init__(self, element, prev, next): self._element = element self._prev = prev self._next = next def __init__(self): self.header = self._Node(None, None, None) ...
Python
0.000001
42f66ea6e1921040d6e3055c41372b02511e6a5a
Add directory for CYK tests
tests/CYK/__init__.py
tests/CYK/__init__.py
#!/usr/bin/env python """ :Author Patrik Valkovic :Created 31.08.2017 14:50 :Licence GNUv3 Part of pyparsers """
Python
0
4dc6462a0a8231ba4ffca09d5c9546d8b6d0dd6f
Fix bug in config.
DIE/Lib/DieConfig.py
DIE/Lib/DieConfig.py
import logging import os import ConfigParser import idaapi import yaml from attrdict import AttrMap class DIEConfig(object): DEFAULT = os.path.join(os.path.dirname(__file__), "config.yml") def __init__(self): with open(self.DEFAULT, "rb") as f: default = yaml.safe_load(f) self....
import logging import os import ConfigParser import idaapi import yaml from attrdict import AttrMap class DIEConfig(object): DEFAULT = os.path.join(os.path.dirname(__file__), "config.yml") def __init__(self): with open(self.DEFAULT, "rb") as f: default = yaml.safe_load(f) self....
Python
0
5ac4f0be3f9f1179a50670989915bae0d3ae157e
Add globals.ffmpeg module to retrieve ffmpeg executable
source/globals/ffmpeg.py
source/globals/ffmpeg.py
# -*- coding: utf-8 -*- ## \package globals.ffmpeg # # Retrieves the FFmpeg executable # MIT licensing # See: LICENSE.txt import subprocess from subprocess import PIPE from subprocess import STDOUT def GetExecutable(cmd): sp = subprocess.Popen([u'which', cmd,], stdout=PIPE, stderr=STDOUT) output, retur...
Python
0.000001
4ae114dd1da8118cc9d2ee87e30f5e0a1f3324f2
Add some tests for monitor class
tests/test_monitor.py
tests/test_monitor.py
import unittest import Monitors.monitor class TestMonitor(unittest.TestCase): safe_config = {'partition': '/', 'limit': '10G'} one_KB = 1024 one_MB = one_KB * 1024 one_GB = one_MB * 1024 one_TB = one_GB * 1024 def test_MonitorInit(self): m = Monitors.monitor.Monitor(config_options={...
Python
0
b0f0ee685ca525de90fdcd5a57a203c8b42b936a
test for the bootstrap
tests/install_test.py
tests/install_test.py
import urllib2 import sys import os print '**** Starting Test' print '\n\n' is_jython = sys.platform.startswith('java') if is_jython: import subprocess print 'Downloading bootstrap' file = urllib2.urlopen('http://nightly.ziade.org/bootstrap.py') f = open('bootstrap.py', 'w') f.write(file.read()) f.close() # run...
Python
0.000001
f9b2bba394ad6ce31ffae5cf6ccf445dc280ba95
Solve C Mais ou Menos? in python
solutions/beecrowd/2486/2486.py
solutions/beecrowd/2486/2486.py
import sys MIN_VITAMIN_C = 110 MAX_VITAMIN_C = 130 vitamin_c_catalogue = { 'suco de laranja': 120, 'morango fresco': 85, 'mamao': 85, 'goiaba vermelha': 70, 'manga': 56, 'laranja': 50, 'brocolis': 34, } for test in sys.stdin: t = int(test) if not t: break total_c_vit...
Python
1
076fa3fcc50c9c9b236fc3e35e4e32f77f9fadbb
Fix power_spectrum tests
tests/test__signal.py
tests/test__signal.py
import numpy as np from acoustics import Signal import pytest import itertools as it #def test_operator(): #n = 10000 #fs = 5000 class TestSignal(): @pytest.fixture(params=[(1, 88200, 22050), (3, 88200, 22050), (3, 88200, 44100)]) def signal(self, request): return Signal(n...
import numpy as np from acoustics import Signal import pytest import itertools as it #def test_operator(): #n = 10000 #fs = 5000 class TestSignal(): @pytest.fixture(params=[(1, 88200, 22050), (3, 88200, 22050), (3, 88200, 44100)]) def signal(self, request): return Signal(n...
Python
0.000009
9db669a311c10b84799084e1d4ba8101137ec234
Add .ycm_extra_conf.py
.ycm_extra_conf.py
.ycm_extra_conf.py
import os # This file is NOT licensed under the GPLv3, which is the license for the rest # of YouCompleteMe. # # Here's the license text for this file: # # This is free and unencumbered software released into the public domain. # # Anyone is free to copy, modify, publish, use, compile, sell, or # distribute this softw...
Python
0.000017
96c8d93cf1b6a01e867ca8250fee4dea5e870c79
Add files via upload
4ChanWebScraper.py
4ChanWebScraper.py
import requests import os import sys import re from BeautifulSoup import BeautifulSoup from PIL import Image from StringIO import StringIO # try: # opts, args = getopt.getopt(argv, "u:", ["url="]) # except getopt.GetoptError: # print('usage: python 4ChanWebScraper.py...
Python
0
67c90811afb47fa57af6b61b894e6efd78fa699c
Find a key within a dictionary
python/reddit/find_my_key.py
python/reddit/find_my_key.py
def find_key(info, key): value = -1 if isinstance(info, dict): if key in info: print('Found {} in {}'.format(key, info)) return info.get(key) else: for element in info: print('Testing element {}'.format(element)) value = find_ke...
Python
0.999718
59abe41d7795a0f91c4442c0e33bb556e3635b91
Add BEIC-pid-upload.py
BEIC-pid-upload.py
BEIC-pid-upload.py
#!/usr/bin/python # -*- coding: utf-8 -*- """ Script to upload images from BEIC.it to Wikimedia Commons. """ # # (C) Federico Leva, 2015 # # Distributed under the terms of the MIT license. # __version__ = '0.1.0' # import pywikibot import pywikibot.data.api from pywikibot import config from upload import UploadRobot ...
Python
0
27fca35a08278a44bb7ba693f222c6c182061872
Add the enemy file and start it up.
Enemy.py
Enemy.py
import pygame class Enemy(pygame.sprite.Sprite): def __init__(self, x, y): super().__init__() self.image = pygame.image.load("images/enemy.png").convert_alpha() self.rect = self.image.get_rect(center=(x, y)) def
Python
0
8821024705c6500ea998431656b3c604b3066898
Add prototype dotcode generator
tools/make-dotcode.py
tools/make-dotcode.py
import numpy as np import PIL.Image import PIL.ImageChops import sys with open(sys.argv[1], 'rb') as f: data = f.read() size = len(data) blocksize = 104 blocks = size // blocksize height = 36 width = 35 margin = 2 dots = np.zeros((width * blocks + margin * 2 + 1, height + margin * 2), dtype=np.bool) anchor = np....
Python
0
982cd61d7532365d9de56b308c7a4d8308302c15
Add a test to demonstrate issue with django 1.11
tests/testapp/tests/test_model_create_with_generic.py
tests/testapp/tests/test_model_create_with_generic.py
try: from django.contrib.contenttypes.fields import GenericForeignKey except ImportError: # Django 1.6 from django.contrib.contenttypes.generic import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models from django.test import TestCase from django_fsm im...
Python
0
efcda7dad6efb189713b8cebb20b4d8b64a85c71
Add tools/msgpack2json.py
tools/msgpack2json.py
tools/msgpack2json.py
import sys, json, umsgpack json.dump(umsgpack.unpack(sys.stdin.buffer), sys.stdout)
Python
0.000005
0dc5154daa12ea196bb5fdeb1342f6f7b3e6e62b
Add markov model baseline
MarkovModel/model.py
MarkovModel/model.py
''' Markov Model for transportation Ankur Goswami ''' def load_inputs(datafiles): inputs = {} for file in datafiles: with open(file, 'r') as rf: for line in rf: split = line.split('\t', 1) segnum = split[0] if segnum is in inputs: ...
Python
0
fbd8c469184e8040f314d5b9127b0b2f739214fa
test that doesn't fail for issue #949 (#958)
conans/test/integration/install_update_test.py
conans/test/integration/install_update_test.py
import unittest from conans.test.tools import TestClient, TestServer from conans.model.ref import ConanFileReference, PackageReference import os from conans.test.utils.cpp_test_files import cpp_hello_conan_files from conans.util.files import load, save from time import sleep class InstallUpdateTest(unittest.TestCase)...
import unittest from conans.test.tools import TestClient, TestServer from conans.model.ref import ConanFileReference, PackageReference import os from conans.test.utils.cpp_test_files import cpp_hello_conan_files from conans.util.files import load from time import sleep class InstallUpdateTest(unittest.TestCase): ...
Python
0
50bfa56b660d5d39c1dd7b3d426fcd589a9719bb
add univdump.py for extracting password dumps [wip]
univdump.py
univdump.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import re import sys import collections ''' This script tries its best to fvck these various esoteric hard-to-process user database dump or leak files. ''' re_field = re.compile(r'(<\w+>)') RecFormat = collections.namedtuple('RecFormat', ('regex', 'fields')) FORMATS =...
Python
0
b2e27f42b3f8de10e11faf128183ca5fa3c0ea3f
Add 0025
Jimmy66/0025/0025.py
Jimmy66/0025/0025.py
#!/usr/bin/env python3 import speech_recognition as sr import webbrowser # obtain path to "test.wav" in the same folder as this script from os import path WAV_FILE = path.join(path.dirname(path.realpath(__file__)), "test.wav") # use "test.wav" as the audio source r = sr.Recognizer() with sr.WavFile(WAV_FILE) as sour...
Python
0.999934
07f522bed6a285507aadd66df89b14022e1e2a04
add new package : openresty (#14169)
var/spack/repos/builtin/packages/openresty/package.py
var/spack/repos/builtin/packages/openresty/package.py
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * class Openresty(AutotoolsPackage): """ OpenResty is a full-fledged web application server by...
Python
0
20fc164862f72527ef7d06bcbfe9dc4329ef9fa7
add problem, hackerrank 005 plus minus
hackerrank/005_plus_minus.py
hackerrank/005_plus_minus.py
#!/bin/python3 """ https://www.hackerrank.com/challenges/plus-minus?h_r=next-challenge&h_v=zen Given an array of integers, calculate which fraction of its elements are positive, which fraction of its elements are negative, and which fraction of its elements are zeroes, respectively. Print the decimal value of ea...
Python
0.001174
6e0f585a8f8433d4f6800cb1f093f97f8a1d4ff7
Update imports for new functions
imageutils/__init__.py
imageutils/__init__.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Image processing utilities for Astropy. """ # Affiliated packages may add whatever they like to this file, but # should keep this content at the top. # ---------------------------------------------------------------------------- from ._astropy_init im...
Python
0
0573ed88c4de497b2da7088795b0d747bb2bd2ce
Add ICT device
pymodels/middlelayer/devices/ict.py
pymodels/middlelayer/devices/ict.py
#!/usr/bin/env python-sirius from epics import PV class ICT: def __init__(self, name): if name in ['ICT-1', 'ICT-2']: self._charge = PV('LI-01:DI-' + name + ':Charge-Mon') self._charge_avg = PV('LI-01:DI-' + name + 'ICT-1:ChargeAvg-Mon') self._charge_max = PV('LI-01:D...
Python
0.000001
a080713a1dd0dd0c1b9c487f9c5413f3e4419db9
Create MQTT2StepperMotor.py
MQTT2StepperMotor.py
MQTT2StepperMotor.py
# Author: Anton Gustafsson # Released under MIT license #!/usr/bin/python from StepperMotorDriver import MotorControl class
Python
0.000027
d26069ddbb35a10f4a368c855d94d1dde1872a82
Add better solution for etl
etl/etl.better.py
etl/etl.better.py
def transform(d): '''Just reverse the dictionary''' return {l.lower(): p for p, letters in d.items() for l in letters} def transform(strs): result = {} for k,v in strs.items(): for i in v: result.update({i.lower():k}) return dict(result.items())
Python
0.000178
61c2ec9efdf72f0ab02ed12c8486bc9ca8f690e6
Add MLP code
neuralnet.py
neuralnet.py
import numpy as np from scipy.special import expit from constants import * class NeuralNetMLP(object): def __init__(self, layers, random_state=None): """ Initialise the layers as list(input_layer, ...hidden_layers..., output_layer) """ np.random.seed(random_state) self.num_layers = len(layers) self.layers = l...
Python
0.000001
54b94346d2669347cf2a9a2b24df6b657cf80c5b
Mask computation utilities (from nipy).
nisl/mask.py
nisl/mask.py
import numpy as np from scipy import ndimage ############################################################################### # Operating on connect component ############################################################################### def largest_cc(mask): """ Return the largest connected component of a 3D m...
Python
0
8e6c1a296be39c5cd1e75d5ff9974f80449690e3
Add VVT tool class
benchexec/tools/vvt.py
benchexec/tools/vvt.py
""" BenchExec is a framework for reliable benchmarking. This file is part of BenchExec. Copyright (C) 2007-2015 Dirk Beyer All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at ...
Python
0
f333b9c5741a7ffbf49caa0a6130831a834b944f
Add unit tests for recent bugfix and move operation
test_dotfiles.py
test_dotfiles.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import shutil import tempfile import unittest from dotfiles import core def touch(fname, times=None): with file(fname, 'a'): os.utime(fname, times) class DotfilesTestCase(unittest.TestCase): def setUp(self): """Create a temporary hom...
Python
0
2b0e13039dad8d116a5719540004bed317bb6960
Add tests and fixtures for the Organizations API wrapper
tests/api/test_organizations.py
tests/api/test_organizations.py
# -*- coding: utf-8 -*- """pytest Licenses functions, fixtures and tests.""" import pytest import ciscosparkapi # Helper Functions def list_organizations(api, max=None): return list(api.organizations.list(max=max)) def get_organization_by_id(api, orgId): return api.organizations.get(orgId) def is_val...
Python
0
feea11952ceab35523052a93a8ca6ff822d1357c
add 141
vol3/141.py
vol3/141.py
import math def gcd(a, b): if a % b == 0: return b return gcd(b, a % b) def is_square(n): sqrt_n = int(math.sqrt(n)) return n == sqrt_n * sqrt_n if __name__ == "__main__": L = 10 ** 12 s = set() for a in xrange(2, 10000): for b in xrange(1, a): if a * a * a * b...
Python
0.999994
284c29d257b7c6902b5973ca05278ee5b05571e9
test subclassing!
tests/delivery/test_frontend.py
tests/delivery/test_frontend.py
from wizard_builder.tests import test_frontend as wizard_builder_tests class EncryptedFrontendTest(wizard_builder_tests.FrontendTest): secret_key = 'soooooo seekrit' def setUp(self): super().setUp() self.browser.find_element_by_css_selector( '[name="key"]').send_keys(self.secret_k...
Python
0
bd9f509bbd97f3a28eb24740dc08bc153cf82613
add voronoi cell class
order/avc.py
order/avc.py
############################################################################### # -*- coding: utf-8 -*- # Order: A tool to characterize the local structure of liquid water # by geometric order parameters # # Authors: Pu Du # # Released under the MIT License ####################################################...
Python
0.000031
6e199bec3816a4a36d891e72f8de9819848bda65
Define ResourceDuplicatedDefinedError.
electro/errors.py
electro/errors.py
# -*- coding: utf-8 -*- class ResourceDuplicatedDefinedError(Exception): pass
Python
0
f527eeb4792ea5630965d72ae73b0331fd465dea
add indicator migration
indicators/migrations/0002_auto_20170105_0205.py
indicators/migrations/0002_auto_20170105_0205.py
# -*- coding: utf-8 -*- # Generated by Django 1.9.4 on 2017-01-05 10:05 from __future__ import unicode_literals from decimal import Decimal from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('indicators', '0001_initial'), ] operations = [ m...
Python
0
103de382d7c9c0dde7aa4bc2f4756dc71ee45335
define pytest fixture for path to PR2 database
test/conftest.py
test/conftest.py
# content of conftest.py import pytest def pytest_addoption(parser): parser.addoption("--uchime-ref-db-fp", action="store", help="path to PR2 database") @pytest.fixture def uchime_ref_db_fp(request): return request.config.getoption("--uchime-ref-db-fp")
Python
0
d15564cf234def0f37c958915e0d7a99cad439e4
add a test for overflow
tests/test_jnitable_overflow.py
tests/test_jnitable_overflow.py
# run it, and check with Java VisualVM if we are eating too much memory or not! from jnius import autoclass Stack = autoclass('java.util.Stack') i = 0 while True: i += 1 stack = Stack() stack.push('hello')
Python
0.000001
5d3918c885f430e79e8283533ad5eb3a84ffecc7
Add migration code for updating lease status
blazar/db/migration/alembic_migrations/versions/75a74e4539cb_update_lease_status.py
blazar/db/migration/alembic_migrations/versions/75a74e4539cb_update_lease_status.py
# Copyright 2018 OpenStack Foundation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
Python
0.000006
2248590ed1bcf33b17f46e4c61747f5a7cb5e92d
remove mutable argument: when a mutable value as list or dictionary is in a default value for an argument. Default argument values are evaluated only once at function definition time, which means that modifying the default value of the argument will affect all subsequent calls of the function.
src/collectors/tcp/test/testtcp.py
src/collectors/tcp/test/testtcp.py
#!/usr/bin/python ################################################################################ from test import * from diamond.collector import Collector from tcp import TCPCollector ################################################################################ class TestTCPCollector(CollectorTestCase): d...
#!/usr/bin/python ################################################################################ from test import * from diamond.collector import Collector from tcp import TCPCollector ################################################################################ class TestTCPCollector(CollectorTestCase): d...
Python
0
308e34b686686d3c42466012c864d7cc5d0f6799
Create go_fixup_fptrs.py
scripts/go/go_fixup_fptrs.py
scripts/go/go_fixup_fptrs.py
""" when IDA's auto-discovery of functions in 64-bit Windows Go executables fails, scan for global (.rdata) pointers into the code section (.text) and assume these are function pointers. """ import idc import ida_name import ida_auto import ida_bytes import idautils def enum_segments(): for segstart in idautils.S...
Python
0.000001