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
470085c992a393522a13a5b6d8243f30fff57a80
add activate_this.py
env/Scripts/activate_this.py
env/Scripts/activate_this.py
"""By using execfile(this_file, dict(__file__=this_file)) you will activate this virtualenv environment. This can be used when you must use an existing Python interpreter, not the virtualenv bin/python """ try: __file__ except NameError: raise AssertionError( "You must run this like execfile('path/to/...
Python
0.000001
7e3fb49043503dc6aa5375c4e27ea770052e615c
Add audiofile_source example
examples/audiofile_source.py
examples/audiofile_source.py
import sys from time import sleep import librosa import numpy as np from audiostream import get_output from audiostream.sources.thread import ThreadSource class MonoAmplitudeSource(ThreadSource): """A data source for float32 mono binary data, as loaded by libROSA/soundfile.""" def __init__(self, stream, data,...
Python
0.000002
9dbd9d7b409afe18677a69d72339d040043a9087
add urls to the audio appl
armstrong/apps/audio/urls.py
armstrong/apps/audio/urls.py
from django.conf.urls.defaults import * from armstrong.apps.audio import views as AudioViews urlpatterns = patterns('', url(r'^$', AudioViews.AudioPublicationList.as_view(), name='audio_list'), url(r'^upload/$', AudioViews.AudioPublicationCreateView.as_view(), name='audio_uplo...
Python
0.000001
914f06c999f5c540c2feb6ab8825c1ced4246ed2
Support sessions
muffin/plugins/session.py
muffin/plugins/session.py
import base64 import hashlib import hmac import time import asyncio import ujson as json from . import BasePlugin class SessionPlugin(BasePlugin): """ Support sessions. """ name = 'session' defaults = { 'secret': 'InsecureSecret', } def setup(self, app): """ Initialize the app...
Python
0
977ec87292c10e21b22f9fe77b248ee83a87147d
Add basic tests
tests/tests.py
tests/tests.py
import unittest from textinator import calculate_size class CalculateSizeTestCase(unittest.TestCase): """Tests for calculate_size()""" def test_width_no_height(self): self.assertEqual(calculate_size((1920, 1080), (20, None)), (20, 11)) self.assertEqual(calculate_size((500, ...
Python
0.000001
a36606beffbd65dc5e09e89aea312e6be2552be0
Create sort_date.py
apps/camera/file_sweeper/sort_date.py
apps/camera/file_sweeper/sort_date.py
#-*-coding:utf8-*- #!/usr/bin/python # Author : Jeonghoonkang, github.com/jeonghoonkang
Python
0.000075
2fa7048351f249b3731d15e04cfb917083074eca
add arabic morphological analysis demo
arabic-morphological-analysis-demo.py
arabic-morphological-analysis-demo.py
# coding: utf-8 import sys ################################################################## def usage(): print 'Usage: ', sys.argv[0], '<inputfile> <outputfile>' ################################################################## if len(sys.argv) < 3: usage(); sys.exit(2) ''' Demo of Arabic morphological analysis...
Python
0.000006
46200af23e98aefbde2140cd63d850d7ae5c5632
Create EuclideanAlgorithm.py
EuclideanAlgorithm.py
EuclideanAlgorithm.py
trueA = input('Larger number: ') trueB = input('Smaller number: ') a = trueA b = trueB while a % b != 0: oldA = a equation = str(a) + ' = ' + str(a/b) + ' * ' + str(b) + ' + ' + str(a%b) print(equation) a = b b = oldA % b gcf = b print('The GCF is: ' + str(gcf))
Python
0.99957
e9ed96d606e2fc8db1e9e36978b48d725f925bb0
Add octogit.__main__ for testing
octogit/__main__.py
octogit/__main__.py
from . import cli cli.begin()
Python
0
c10d60911d870910d389668f6c99df694e9d914c
add registry test
sncosmo/tests/test_registry.py
sncosmo/tests/test_registry.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Test registry functions.""" import numpy as np import sncosmo def test_register(): disp = np.array([4000., 4200., 4400., 4600., 4800., 5000.]) trans = np.array([0., 1., 1., 1., 1., 0.]) band = sncosmo.Bandpass(disp, trans, name='tophatg') ...
Python
0
872dcfd02b9c136d781abf15df38c71a234f82c0
remove unneeded sleep
mzalendo/hansard/tests.py
mzalendo/hansard/tests.py
import os import datetime import time from django.test import TestCase from hansard.models import Source class HansardTest(TestCase): def setUp(self): source = Source( name = 'Test Source', url = 'http://www.mysociety.org/robots.txt', date = datetime.date( 2001, 11, 1...
import os import datetime import time from django.test import TestCase from hansard.models import Source class HansardTest(TestCase): def setUp(self): source = Source( name = 'Test Source', url = 'http://www.mysociety.org/robots.txt', date = datetime.date( 2001, 11, 1...
Python
0.001585
910358e7cf3d8b996593c5d8eedf5c97bd0c6b67
Test template for Monitor
azure-mgmt/tests/test_mgmt_monitor.py
azure-mgmt/tests/test_mgmt_monitor.py
# coding: utf-8 #------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. #---------------------------------------------------------------------...
Python
0
cf4829ae46ef994c9f558dcc2f08743833b8a6fb
Add mineTweets.py
mineTweets.py
mineTweets.py
import json import tweepy from tweepy import OAuthHandler from tweepy import Stream from tweepy.streaming import StreamListener #App credentials consumer_key = "" consumer_secret = "" access_token = "" access_secret = "" auth = OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_sec...
Python
0
fc919fecd5af80d27d3352b80fce5ed214ca4d41
True False
task_14.py
task_14.py
#!user/bin/env python # -*- coding: utf-8 -*- """docstring""" IS_TRUE = True IS_FALSE = False IS_NONE = None print IS_TRUE == 1, IS_FALSE and 0 INTEGER_EQUIV = 'True False'
Python
0.999999
0d56fb071628dc3f33c90d7f806371c076303551
add autoGonk -- hopefully our self-determining "brain" to automate this
autoGonk.py
autoGonk.py
""" autoGonk -- testing out auto-determining which interfaces serve which function """ class ArpTable(): arpTable = {} pass class RouteTable(): routeTable = {} pass class IP(): pass
Python
0
9d7d043a36f6e5a2fc599287a087eb806a58d73a
test to_xml survey
testXml.py
testXml.py
from xml.etree import ElementTree from xml.etree.ElementTree import Element from xml.etree.ElementTree import SubElement import xml.etree.cElementTree as ET from app import db, models from app.models import Section, Survey, Consent, Question, QuestionText, QuestionLikertScale def surveyXml(surveyData): survey = El...
Python
0
3d35a84d92123fcf530cb366d60de0f2c45d1c18
test python interpreter
test/test_interpreter_layer.py
test/test_interpreter_layer.py
# This code is so you can run the samples without installing the package import sys import os sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) # import cocos from cocos.director import director import pyglet if __name__ == "__main__": director.init() interpreter_layer = cocos.layer....
Python
0.000062
1d089833b47fe740d6dfaea89f94b1c9d1946c1e
enable evented based on socket
openerp/__init__.py
openerp/__init__.py
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. """ OpenERP core library.""" #---------------------------------------------------------- # Running mode flags (gevent, prefork) #---------------------------------------------------------- def is_server_running_with_geve...
# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. """ OpenERP core library.""" #---------------------------------------------------------- # Running mode flags (gevent, prefork) #---------------------------------------------------------- # Is the server running with ge...
Python
0
74a22516a368d98c8c71818c39d84208c9ecca66
add buildbot.py
buildbot.py
buildbot.py
#!/usr/bin/env python # encodingsak: utf-8 import os import sys import json import subprocess project_name = 'hex' def run_command(args): print("Running: {}".format(args)) sys.stdout.flush() subprocess.check_call(args) def get_tool_options(properties): options = [] if 'tool_options' in proper...
Python
0.000001
95b5d52eaafedd7b967e30cabad0e64dca6f40ab
Create IC_Property.py
pyicic/IC_Property.py
pyicic/IC_Property.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from ctypes import * from IC_GrabberDLL import IC_GrabberDLL from IC_Exception import IC_Exception class IC_Property(object): @property def available(self): """ """ # returns boolean value iav = self._avail_funcs[self._prop_type](...
Python
0.000001
0bc48dc1dd66178bec8d9bb3dc86a26baad240ee
use module-level function instead of a factory class
rap/servicefactory.py
rap/servicefactory.py
""" Factory of RoutingService classes """ import json from .mb import MapboxRouter from .graphhopper import GraphHopperRouter # from . import mapzen # from . import google # from . import here # from . import tomtom """ Factory method of creating concrete routing service instances """ VALID_ROUTING_SERVICES = [ '...
Python
0
162e7dd6595b0d9303ecb1da66893ee353ba413b
Add a first small file watcher that counts words
tracker.py
tracker.py
import os import sys import time import logging from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler from watchdog.events import FileModifiedEvent class GamificationHandler(FileSystemEventHandler): def __init__(self, filename): FileSystemEventHandler.__init__(self) self.fi...
Python
0.000001
6c10f4d98443b23424a01659afd5194c3edff141
Add conflict inspector script
inspect_conflicts.py
inspect_conflicts.py
import oursql import sys import simplejson as json from wikidataeditor import Site config = json.load(open('config.json', 'r')) db = oursql.connect(host="wikidatawiki.labsdb", db="wikidatawiki_p", read_default_file="~/replica.my.cnf") cur = db.cursor() wd = Site('DanmicholoBot (+http://tools.wmflabs.org/danmicholob...
Python
0.000001
c4c52c98f4c8596b4f19c88fb64e1b0af4f9c4cd
Add New Test Which Monitors Output
tests/test_monitor_progress.py
tests/test_monitor_progress.py
pytest_plugins = "pytester" def test_simple_example(testdir): """ Run the simple example code in a python subprocess and then compare its stderr to what we expect to see from it. We run it in a subprocess to best capture its stderr. We expect to see match_lines in order in the output. Th...
Python
0.000001
94c2f4ef1c553e3dd0a543bcaf01cd176c97e551
fix `get_function_from_rule()`
gittip/utils/i18n.py
gittip/utils/i18n.py
from __future__ import print_function, unicode_literals import os import re from aspen.utils import utcnow from babel.dates import format_timedelta import babel.messages.pofile from babel.numbers import ( format_currency, format_decimal, format_number, format_percent ) ternary_re = re.compile(r' *(.*) *\? *(.*)...
from __future__ import print_function, unicode_literals import os import re from aspen.utils import utcnow from babel.dates import format_timedelta import babel.messages.pofile from babel.numbers import ( format_currency, format_decimal, format_number, format_percent ) ternary_re = re.compile(r'(.*)\?(.*):(.*)'...
Python
0.000008
2a47a563d5cc16f14edc0fb56a1af2848eccde57
Add simple wrapper for a heap.
txrudp/heap.py
txrudp/heap.py
"""Simple heap used as reorder buffer for received messages.""" import collections import heapq class EmptyHeap(Exception): """Raised when popping from empty heap.""" class Heap(collections.Sequence): """ A min-heap for objects implementing total ordering. The object with the minium order number...
Python
0
06c3086401e8cb221a1a665598fe75a1886d7f37
test python script for test-NN added.
example/test-NN/test_nn.py
example/test-NN/test_nn.py
#!/usr/bin/env python """ Test pmd run about NN potential. Usage: test_nn.py [options] Options: -h, --help Show this message and exit. """ from __future__ import print_function import os from docopt import docopt import unittest __author__ = "RYO KOBAYASHI" __version__ = "170122" def get_init_epot(fname='out....
Python
0
bc356875eaf52bca2b1c04548a51e0372e7948aa
Create tcpServer_SocketServer.py
tcpServer_SocketServer.py
tcpServer_SocketServer.py
#/bin/python import SocketServer import socket SERVER_ADDRESS = ("0.0.0.0", 8888) class EchoHandler(SocketServer.BaseRequestHandler): def handle(self): print "Received a connection from: ", self.client_address data = "start" while len(data): data = self.request.recv(1024) self.request.s...
Python
0.000021
d1ac022d3823480e105621bd181f669dcc57c123
Add class_schedule example
examples/class_schedule.py
examples/class_schedule.py
import sys import os import logging from collections import defaultdict sys.path.append(os.environ["PWD"]) from pyga import * population_size = 100 elite_count = 5 crossover_points = 2 crossover_probability = 0.2 mutate_probability = 0.5 max_day_span = 2 max_hour_span = 8 teachers = [ ['Anna'], ['Susan'], ...
Python
0.000001
d680d6a20890d3bbce96792fa1e86df28956a859
Add a thread helper module
helpers/threading.py
helpers/threading.py
from threading import Thread, Lock list_lock = Lock() def run_in_thread(app): def wrapper(fn): def run(*args, **kwargs): app.logger.info('Starting thread: {}'.format(fn.__name__)) t = Thread(target=fn, args=args, kwargs=kwargs) t.start() return t r...
Python
0.000001
0d22cad3e34e7834e96e37b0268f624b45e7296f
add tests for outdoor shops
test/674-outdoor-shops.py
test/674-outdoor-shops.py
#http://www.openstreetmap.org/node/3056897308 assert_has_feature( 16, 11111, 25360, 'pois', { 'kind': 'fishing', 'min_zoom': 16 }) #http://www.openstreetmap.org/node/1467729495 assert_has_feature( 16, 10165, 24618, 'pois', { 'kind': 'hunting', 'min_zoom': 16 }) #http://www.openstreetmap.org/node/76620...
Python
0
3a9960849d1c9c7b519c9eb88aa3dc58c60b1eb3
Create 3-blink.py
Code/3-blink.py
Code/3-blink.py
#Import Libraries import time #A collection of time related commands import RPi.GPIO as GPIO #The GPIO commands #Set the GPIO pin naming mode GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) #Set pins 18, 23 and 24 to be output GPIO.setup(18,GPIO.OUT) GPIO.setup(23,GPIO.OUT) GPIO.setup(24,GPIO.OUT) #Turn L...
Python
0.000007
0ec1a3f3760b5977c036bc092b8b88647b3d4674
Allow LogDevice to build without Submodules (#71)
build/fbcode_builder/specs/rocksdb.py
build/fbcode_builder/specs/rocksdb.py
#!/usr/bin/env python # Copyright (c) Facebook, Inc. and its affiliates. from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals def fbcode_builder_spec(builder): builder.add_option("rocksdb/_build:cmake_defines", { ...
Python
0.000002
26fa3f083468acb2155d811ce65d4d4d6aafe53b
Integrate LLVM at llvm/llvm-project@4b33ea052ab7
third_party/llvm/workspace.bzl
third_party/llvm/workspace.bzl
"""Provides the repository macro to import LLVM.""" load("//third_party:repo.bzl", "tf_http_archive") def repo(name): """Imports LLVM.""" LLVM_COMMIT = "4b33ea052ab7fbceed4c62debf1145f80d66b0d7" LLVM_SHA256 = "b6c61a6c81b1910cc34ccd9800fd18afc2dc1b9d76c640dd767f9e550f94c8d6" tf_http_archive( ...
"""Provides the repository macro to import LLVM.""" load("//third_party:repo.bzl", "tf_http_archive") def repo(name): """Imports LLVM.""" LLVM_COMMIT = "58a47508f03546b4fce668fad751102b94feacfd" LLVM_SHA256 = "b3106ecc8ad56ecf9cd72c8a47117342e7641ef5889acb1d9093bcd0f2920d59" tf_http_archive( ...
Python
0.000001
0cf2ce2331120c20de0cab384c5fdec763c25c68
Add a simple markov chain to compare output with RNN
min-char-rnn/markov-model.py
min-char-rnn/markov-model.py
# Simple Markov chain model for character-based text generation. # # Only tested with Python 3.6+ # # Eli Bendersky (http://eli.thegreenplace.net) # This code is in the public domain from __future__ import print_function from collections import defaultdict, Counter import random import sys STATE_LEN = 4 def weight...
Python
0
80c749e8b8395f20305c04c480fbf39400f1b5a4
Add failing test for index route
features/tests/test_index.py
features/tests/test_index.py
from django.test import TestCase class TestIndex(TestCase): """Verify the index page is served properly""" def test_root(self): # Fetch page from '/' reponse = self.client.get('/') # Should respond OK self.assertEqual(reponse.status_code, 200) # Should be rendered from ...
Python
0
3f7b54496826f496863de545a601c23c2c06427a
Add first-party JavaScript build rule library
shipyard2/shipyard2/rules/javascripts.py
shipyard2/shipyard2/rules/javascripts.py
"""Helpers for writing rules for first-party JavaScript packages.""" __all__ = [ 'define_package', 'find_package', ] import dataclasses import logging import foreman from g1 import scripts from g1.bases.assertions import ASSERT from shipyard2 import rules LOG = logging.getLogger(__name__) @dataclasses.d...
Python
0.000001
18b98aff76c0b69748b5dd4b8ca27bd8d8b8aec8
Add PassiveAggressiveClassifier to benchmark
model_code/PassiveAggressiveClassifier.py
model_code/PassiveAggressiveClassifier.py
import sys import pandas as pd from sklearn.linear_model import PassiveAggressiveClassifier from sklearn.cross_validation import StratifiedShuffleSplit from sklearn.preprocessing import StandardScaler import itertools dataset = sys.argv[1] # Read the data set into memory input_data = pd.read_csv(dataset, compression=...
Python
0.000003
6a74915c3f197ef197a34514c7ff313ac0a68d2f
Add migration to delete existing cache values
corehq/apps/fixtures/migrations/0002_rm_blobdb_domain_fixtures.py
corehq/apps/fixtures/migrations/0002_rm_blobdb_domain_fixtures.py
# -*- coding: utf-8 -*- # Generated by Django 1.10.7 on 2017-09-08 10:23 from __future__ import unicode_literals from django.db import migrations from corehq.blobs import get_blob_db from corehq.sql_db.operations import HqRunPython FIXTURE_BUCKET = 'domain-fixtures' def rm_blobdb_domain_fixtures(apps, schema_edito...
Python
0.000001
e184b806c6170aad2bdee87c051ea6400e1d954e
Add unit tests for the Document class
tests/parser_test.py
tests/parser_test.py
import unittest from clippings.parser import Document class DocumentTest(unittest.TestCase): def test_create_document(self): title = 'Haunted' authors = ['Chuck Palahniuk'] document = Document(title, authors) self.assertEqual(title, document.title) self.assertEqual(autho...
Python
0
98006f7b27195153c1eb5d19b5902b60b0ffd963
add unit tests for events.py
tests/test_events.py
tests/test_events.py
#!/usr/bin/env python # vim: set sts=4 sw=4 et: import unittest import events import rpc class TestEventsRPC(unittest.TestCase): def testEvent(self, cls=None): cls = events.Event e = cls() e2 = rpc.rpc_decode(cls, rpc.rpc_encode(e)) self.assert_(isinstance(e2, cls)) self.assertE...
Python
0
e9cfb095ac4261c8bf959d1c9b904256c267178f
Add basic unit test about /variables endpoint
openfisca_web_api/tests/test_variables.py
openfisca_web_api/tests/test_variables.py
# -*- coding: utf-8 -*- import json from nose.tools import assert_equal, assert_greater, assert_in, assert_is_instance from webob import Request from . import common def setup_module(module): common.get_or_load_app() def test_basic_call(): req = Request.blank('/api/1/variables', method = 'GET') res ...
Python
0.000001
bcfccc8d7b19895f793e63289dcbbf9bf1ed834b
add unittest for home view
commute_together/commute_together/tests/test_views.py
commute_together/commute_together/tests/test_views.py
from datetime import timedelta, datetime from django.test import TestCase from django.core.urlresolvers import reverse from django.contrib.auth.models import User from commute_together.models import MeetingModel, StationModel class HomePageTest(TestCase): fixtures = ['StationModel.json'] def test_home_page_rende...
Python
0
ff673561c87bd16938a7c3f4d7609f91afbe9078
add a script to perform the event averaging for the HBT correlation function
ebe_scripts/average_event_HBT_correlation_function.py
ebe_scripts/average_event_HBT_correlation_function.py
#! /usr/bin/env python """ This script performs event averaging for the HBT correlation function calculated from event-by-event simulations """ from sys import argv, exit from os import path from glob import glob from numpy import * # define colors purple = "\033[95m" green = "\033[92m" blue = "\033[94m" ye...
Python
0
c23d2711757a68f1348f8353aba7b3ec2d17a1d6
Structure prediction boilerplate
smact/structure_prediction/prediction.py
smact/structure_prediction/prediction.py
"""Structure prediction implementation.""" from typing import Generator, List, Tuple, Optional from .database import StructureDB from .mutation import CationMutator from .structure import SmactStructure class StructurePredictor: """Provides structure prediction functionality. Implements a statistically-bas...
Python
0.000001
f49b6ad21ed9c8646c402a37015a80258fb79a68
ADD EVALUATE PROCESS
evaluate_model.py
evaluate_model.py
import tensorflow as tf import os import glob import vng_model as md import numpy as np import csv FLAGS = tf.app.flags.FLAGS tf.app.flags.DEFINE_string('checkpoint_dir', '', """Direction where the trained weights of model is save""") tf.app.flags.DEFINE_string('eval_data_path', '', ...
Python
0.999976
3d5955767d81f45e796ab2af0707533375681774
add runtests-windows.py script
tests/runtests-windows.py
tests/runtests-windows.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys import glob import unittest os.environ['PYGTK_USE_GIL_STATE_API'] = '' sys.path.insert(0, os.path.dirname(__file__)) sys.argv.append('--g-fatal-warnings') import gobject gobject.threads_init() SKIP_FILES = ['runtests', 'test_gio', ...
Python
0
fffb2a38870afd0c9a6d1ab5efd36b75f98c9a9a
test the deprecation class.
tests/test_deprecation.py
tests/test_deprecation.py
from brownant import Brownant, BrownAnt def test_deprecation(recwarn): app = BrownAnt() warning = recwarn.pop(DeprecationWarning) assert isinstance(app, Brownant) assert issubclass(warning.category, DeprecationWarning) assert "Brownant" in str(warning.message) assert "app.py" in warning.filen...
Python
0.000001
404c9b70cf9b6c27e0fb16be1556d01b5077a4f4
Add test cases for 500 error with slow responses
tests/test_regressions.py
tests/test_regressions.py
""" """ import time import logging import unittest from flask import Flask import mock from flask.ext.limiter.extension import C, Limiter class RegressionTests(unittest.TestCase): def build_app(self, config={}, **limiter_args): app = Flask(__name__) for k,v in config.items(): app.c...
Python
0
5e67c16d06786e5ed5e74e40a2c29131ec011748
rename app to doc
corehq/apps/domainsync/management/commands/copy_doc.py
corehq/apps/domainsync/management/commands/copy_doc.py
from couchdbkit import Database from dimagi.utils.couch.database import get_db from django.core.management.base import LabelCommand, CommandError from corehq.apps.domainsync.config import DocumentTransform, save class Command(LabelCommand): help = "Copy any couch doc" args = '<sourcedb> <doc_id> (<domain>)' ...
from couchdbkit import Database from dimagi.utils.couch.database import get_db from django.core.management.base import LabelCommand, CommandError from corehq.apps.domainsync.config import DocumentTransform, save class Command(LabelCommand): help = "Copy any couch doc" args = '<sourcedb> <doc_id> (<domain>)' ...
Python
0.000008
bd00e5ae48c81ee96d843675d76520f9e8bcab4c
Add COAP ping script
coapping.py
coapping.py
#!/usr/bin/env python2 # COAP ping implementation # 0x4000 0001 <--> 0x7000 0001 # 0x4000 0002 <--> 0x7000 0002 # 0x4000 0003 <--> 0x7000 0003 import socket import struct import sys from time import sleep, time from optparse import OptionParser # Parse Options if __name__ == '__main__': parser = OptionParser...
Python
0
e56a0ca2d788bc3b865f6d18ad42e5feadb47566
添加新的数据格式,增加uuid实现
upgrade/upgrade_from_3.py
upgrade/upgrade_from_3.py
import hashlib import json import shutil import uuid from common import file def add_id(list_item): list_item["uuid"] = str(uuid.uuid4()) return list_item def main(): shutil.copyfile("./config/page.json", "./config/page.json.bak") page_list = json.loads(file.read_file("./config/page.json")) pag...
Python
0
91b8239d858d60bbcd70e17870648a87b2d6da02
add wip installer
local/bin/dotfiles.py
local/bin/dotfiles.py
#!/usr/bin/env python3 import os import sys def exec_hook(hook): with open(hook) as f: exec(compile(f.read(), config_file, 'exec'), globals(), locals()) #def generate_hook(dotfile): def install_hook(dotfile, dotfilesdir): # Fix relpath output if dotfile.startswith('./'): dotfile = os.path.basename(dot...
Python
0.000001
83041a8b132ce61910fdd0b6d9c24d020e857a04
add test for compute_disparity_map timeout
tests/block_matching_test.py
tests/block_matching_test.py
import os import pytest import s2p from tests_utils import data_path def test_compute_disparity_map_timeout(timeout=1): """ Run a long call to compute_disparity_map to check that the timeout kills it. """ img = data_path(os.path.join("input_pair", "img_01.tif")) disp = data_path(os.path.join("tes...
Python
0.000001
e8b09ed22bfe19c355b3dc315f0e831ac43f0c0d
Update code.py
code.py
code.py
import web import json urls = ( '/', 'index' ) class index: def GET(self): db = web.database(dbn='mysql', user='user', pw='password', db='test') table = db.select('pw_policy') return json.dumps(table[0]) + " hello world2" if __name__ == "__main__": app = web.application(urls, glo...
Python
0.000001
e8bcdebaa9af0affa152a91ad489447d1cc4ba8f
Create main.py
main.py
main.py
# Released under MIT License # Created By Agneeth Mazumdar from PIL import Image from pptx import Presentation from pptx.util import Inches import urllib import os import csv prs = Presentation() def read_csv(): names = [] urls = [] with open('your_csv_file_here.csv', 'rb') as names_images_data: ...
Python
0.000001
45111a2caced3f70882e32ba67ecc5d644eaa2ce
Add main.py
main.py
main.py
import sys import os import getpass import time import json from boj import BOJ from git import Git from option import Option ERROR_FORMAT = '\n* ERROR: [%s] [%s]\n' PRINT_FORMAT = '* %s\n' DEFAULT_OPTION_FILE = 'option.json' class Main: def __init__(self, boj, git, option): self.boj = boj self...
Python
0.000008
e2955477f8d3dde879ecdd8f8f75f438a8905661
Add dots.py
dots.py
dots.py
import sys RIGHT = 0 LEFT = 0 INC = 2 DEC = 3 LOOP_START = 4 LOOP_END = 5 GETC = 6 PUTC = 7 def compile_file(source_file): program_n = 0 try: with open(source_file, "r") as f: eof = False while not eof: c = f.read(1) if le...
Python
0.000206
72f43fc9c8aecc9fd8f240cfc37500cad4bc7858
Test for math.assert_close()
tests/commit/math/test__functions.py
tests/commit/math/test__functions.py
from unittest import TestCase from phi import math def assert_not_close(*tensors, rel_tolerance, abs_tolerance): try: math.assert_close(*tensors, rel_tolerance, abs_tolerance) raise BaseException(AssertionError('1 != 0')) except AssertionError: pass class TestMathFunctions(TestCase)...
Python
0.000015
27f187d3cc5725b6ed912e15ecafb38a44cc4992
Add unit tests for new service util
tests/unit/utils/test_win_service.py
tests/unit/utils/test_win_service.py
# Import Python Libs import os # Import Salt Libs import salt.utils.platform # Import Salt Testing Libs from tests.support.mock import patch, MagicMock from tests.support.unit import TestCase, skipIf try: import salt.utils.win_service as win_service from salt.exceptions import CommandExecutionError except Ex...
Python
0
60b9041f76a88dddaf627458d98a357974a6a302
Add __init__.py
__init__.py
__init__.py
Python
0.006636
482218b20ea6281c49be7edd66370c778b301c7f
Create __init__.py
__init__.py
__init__.py
Python
0.000429
fa5ffd2f2f51607703912209b5876cb8f951df88
Add simple testing driver
test.py
test.py
import parser p = parser.Parser() input = ['-c mango', '--create mango', 'c mango', '--create kiwi c guava lemon', '--create'] for i in input: ret = p.parse(i) print('--------') print(i) print(ret) print('--------')
Python
0.000002
775edf9fec8bbe32dceef3efc1e1cffc642ae61c
Create __init__.py
__init__.py
__init__.py
__all__ = ["SINGLE"] import SINGLE #from SINGLE import SINGLE #from choose_h import * #from fitSINGLE import *
Python
0.000429
9065b9f5baedfc1895c612a7995f15878144d3e7
Create test.py
test.py
test.py
#coding: utf-8 import operator import re import sys import time import urlparse import fhp.api.five_hundred_px as _fh import fhp.helpers.authentication as _a from fhp.models.user import User _TREG = re.compile('^(\d+)-(\d+)-(\d+).*?(\d+):(\d+):(\d+).*') _URL = 'http://500px.com/' _HTML_BEGIN = '''<!DOCTYPE HTML PUBLI...
Python
0.000005
a0705902dcf335cadeee717fbbdcbb247bc14645
Move wsgi.py to project directory
wsgi.py
wsgi.py
""" WSGI config for backstage project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SET...
Python
0
b9283871a8be5ee0f289cb6181023a8366f530bd
modify response example
examples/middleware/modify_response/modify_response.py
examples/middleware/modify_response/modify_response.py
#!/usr/bin/env python import sys import logging import json logging.basicConfig(filename='middleware.log', level=logging.DEBUG) logging.debug('Middleware is called') def main(): data = sys.stdin.readlines() # this is a json string in one line so we are interested in that one line payload = data[0] l...
Python
0.000002
4e18da98f3398e1cc3b4c8f76bc8f81529baff3c
Add doc modification script
docs.py
docs.py
import glob for filename in glob.glob("target/doc/serenity/**/*.html"): print('Parsing {}'.format(filename)) with open(filename) as f: content = f.read() new_content = content.replace('<nav class="sidebar">\n', '<nav class="sidebar"><img src="https://docs.austinhellyer.me/serenity.rs/docs_header.p...
Python
0
94cfd557b604947a1e2ce23fc67bf82c508439ff
change request.base_payout from float to numeric (decimal)
evesrp/migrate/versions/4198a248c8a_.py
evesrp/migrate/versions/4198a248c8a_.py
"""Move from using floats for ISK to numeric types. Revision ID: 4198a248c8a Revises: 45024170cf6 Create Date: 2014-06-18 14:34:25.967159 """ # revision identifiers, used by Alembic. revision = '4198a248c8a' down_revision = '45024170cf6' from decimal import Decimal from alembic import op import sqlalchemy as sa fro...
Python
0
314b195160d539101dd3c3fa53e6f870fd2ee083
add beautiful-triplets
contest/world-codesprint-april/beautiful-triplets/beautiful-triplets.py
contest/world-codesprint-april/beautiful-triplets/beautiful-triplets.py
# -*- coding: utf-8 -*- # @Author: Zeyuan Shang # @Date: 2016-04-30 19:35:03 # @Last Modified by: Zeyuan Shang # @Last Modified time: 2016-04-30 19:38:26 if __name__ == "__main__": n, d = map(int, raw_input().split()) a = map(int, raw_input().split()) ele = set() for x in a: ele.add(x) ans = 0 for x in a:...
Python
0.999144
69f323bba974ea73963c8da63a3c3b8326fffc6e
Create RevLinkedList_002.py
leetcode/206-Reverse-Linked-List/RevLinkedList_002.py
leetcode/206-Reverse-Linked-List/RevLinkedList_002.py
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def reverseList(self, head): """ :type head: ListNode :rtype: ListNode """ dummy = ListNode(0) dummy....
Python
0
ced07a1f5d0d5c3c460bda1de29381ba7aff0c87
add knn
4/KNN.py
4/KNN.py
# -*- coding: utf-8 -*- import csv import random import math import operator import os def loadDataSet(fileName, split, trainingSet=[], testSet=[]): with open(fileName, "rb") as csvFile: lines = csv.reader(csvFile) dataSet = list(lines) for x in range(len(dataSet) - 1): for y in...
Python
0.999999
f1268d95f224b0bb3df00f3a76c92074f0db037a
Update utils.py
tendrl/commons/central_store/utils.py
tendrl/commons/central_store/utils.py
from tendrl.commons.etcdobj import fields def to_etcdobj(cls_etcd, obj): for attr, value in vars(obj).iteritems(): if value is None: continue if attr.startswith("_"): continue if attr in ["attrs", "enabled", "obj_list", "obj_value", "atoms", "flo...
from tendrl.commons.etcdobj import fields def to_etcdobj(cls_etcd, obj): for attr, value in vars(obj).iteritems(): if attr.startswith("_"): continue if attr in ["attrs", "enabled", "obj_list", "obj_value", "atoms", "flows", "value", "list"]: continue ...
Python
0.000001
71bbd57214cd8be6ac8583884eb1fc2e5b270eb8
Add conf file for Emmaus Ideasbox in France
ideascube/conf/idb_fra_emmaus.py
ideascube/conf/idb_fra_emmaus.py
# -*- coding: utf-8 -*- """Ideaxbox for Emmaus, France""" from .idb import * # noqa from django.utils.translation import ugettext_lazy as _ IDEASCUBE_NAME = u"Emmaus" IDEASCUBE_PLACE_NAME = _("city") COUNTRIES_FIRST = ['FR'] TIME_ZONE = None LANGUAGE_CODE = 'fr' LOAN_DURATION = 14 MONITORING_ENTRY_EXPORT_FIELDS = ['s...
Python
0
f7f76bc7eb217e4c7b81e58afec41726f0dd2848
Add another dip example
examples/dip2.py
examples/dip2.py
#!/usr/bin/env python3 # Copyright (c) 2015 Matthew Earl # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify...
Python
0
60a6b98d0bc3f8e55414dd1f6461ad863bcfd12a
Create matching_ending_items.py
hacker_rank/regex/repetitions/matching_ending_items.py
hacker_rank/regex/repetitions/matching_ending_items.py
Regex_Pattern = r'^[a-zA-Z]*[s]$' # Do not delete 'r'.
Python
0.000017
4822b3c55478bd76b66d5afbfabf0c9ec51a9c8e
Add an example ('move.py').
examples/move.py
examples/move.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import pydynamixel.packet as pk import pydynamixel.connection import pydynamixel.instruction_packet as ip import time def main(): serial_connection = pydynamixel.connection.Connection() # Goto to 180° instruction_packet = ip.InstructionPacket(_id=pk.BROADC...
Python
0.00009
1e9b1c2270d8dfc722f92b8b046581ce6172016a
update divergence
utils/divergences.py
utils/divergences.py
""" Author: Rahul G. Krishnan File containing divergences used between probability measures """ import theano.tensor as T def KL(mu_1,cov_1,mu_2,cov_2): """ Estimate the KL divergence between two gaussians with diagonal covariance KL(q||p) 0.5*(log|Sigma_2| - log |Sigma_1| """ diff = mu_2-mu_1 ...
Python
0.000001
ee633ae9576ee1d2c0edd55551319879a9c32864
Add initial version of fit_sota_model
fit_sota_model.py
fit_sota_model.py
#!/usr/bin/env python from __future__ import division import numpy as np SOTA2013_FIT = [0.18, 0.99, -0.49, # Scale -1.49, 0.89, 0.28] # Offset if 'data' not in globals(): import cPickle as pickle with open('data/mini_acq_table.pkl', 'r') as fh: data = pickle.load(fh) data...
Python
0
0c19f71cc090b03787533d3262ec0f0f635136f9
Add module for visualization of SubjectInfo
lib_common/src/d1_common/cert/subject_info_renderer.py
lib_common/src/d1_common/cert/subject_info_renderer.py
# -*- coding: utf-8 -*- # This work was created by participants in the DataONE project, and is # jointly copyrighted by participating institutions in DataONE. For # more information on DataONE, see our web site at http://dataone.org. # # Copyright 2009-2016 DataONE # # Licensed under the Apache License, Version 2.0 ...
Python
0
ae553ef472d63e6b05d87f1ad28c604e0fb67347
Fix Docstring: "inject" can be an action too
pathod/language/writer.py
pathod/language/writer.py
import time from netlib.exceptions import TcpDisconnect BLOCKSIZE = 1024 # It's not clear what the upper limit for time.sleep is. It's lower than the # maximum int or float. 1 year should do. FOREVER = 60 * 60 * 24 * 365 def send_chunk(fp, val, blocksize, start, end): """ (start, end): Inclusive lower bo...
import time from netlib.exceptions import TcpDisconnect BLOCKSIZE = 1024 # It's not clear what the upper limit for time.sleep is. It's lower than the # maximum int or float. 1 year should do. FOREVER = 60 * 60 * 24 * 365 def send_chunk(fp, val, blocksize, start, end): """ (start, end): Inclusive lower bo...
Python
0.000039
4ea892fe28b3045ab265cfd9fd5aa6a2b7c1ee52
add report related to the fix contaminant
sequana/report_fix.py
sequana/report_fix.py
import easydev import os from .report_main import BaseReport # a utility from external reports package from reports import HTMLTable import pandas as pd def _get_template_path(name): # Is it a local directory ? if os.path.exists(name): return name else: template_path = easydev.get_...
Python
0
9c67d72fbbdec53e2adc5ff2718bae8b3493b219
add a simple test for celery config
ichnaea/tests/test_worker.py
ichnaea/tests/test_worker.py
from unittest2 import TestCase class TestWorkerConfig(TestCase): def _get_target(self): from ichnaea.worker import celery return celery def test_config(self): celery = self._get_target() self.assertTrue(celery.conf['CELERY_ALWAYS_EAGER']) self.assertEqual(celery.conf[...
Python
0.000001
a990292ec2d3e2ebc74dd548cfc9ee55427bf5f0
Create news_url.py
news_url.py
news_url.py
""" PROJECT SCRAPER """ '''GET URL FROM BBC NEWS''' from bs4 import BeautifulSoup import urllib2 url='http://www.bbc.com/news' web=urllib2.urlopen(url) soup=BeautifulSoup(web,'html.parser') with open('news_url.txt','w') as file: for tag in soup.find_all('a',{'class':'title-link'}): url=tag.get('href') file.wr...
Python
0.000002
4d747b0ff0f700e41ff31b028618163d180301fa
Add Utils
Utils.py
Utils.py
""" Holds various common functions and variables which will be useful in general by the other classes. """ def log(*args, **kwargs): print(" COALA -", *args, **kwargs)
Python
0
dbc64554694f117dfe2def082acaeb60117a4f1e
add template for classifier test
weiss/tests/test_dialogue.py
weiss/tests/test_dialogue.py
from django.test import TestCase class StateTestCase(TestCase): def setUp(self): pass def test_classifier(self): pass
Python
0.000001
c193b4718a707f16b436d62f6b6a26882b742251
test for branching and shas
ws-tests/test_integration.py
ws-tests/test_integration.py
#!/usr/bin/env python from opentreetesting import test_http_json_method, config import datetime import codecs import json import sys import os study_id = '9' DOMAIN = config('host', 'apihost') #A full integration test, with GET, PUT, POST, MERGE and a merge conflict, #test get and save sha data = {'output_nexml2j...
Python
0
ffe374bd1fc40aab3dcdbc37141a068af81465de
Create onmodify.timetrack.py
onmodify.timetrack.py
onmodify.timetrack.py
#!/usr/bin/env python # # Writes task effort log to LEDGERFILE. Format is: # 2015/03/22,e28087e9-525e-403c-9c4b-1aed53809092,9,no project,test3 # Date,UID,Seconds effort, Project name (or 'no project'), task description # # You need to adjust LEDGERFILE, or set the TIMELOG environment variable. # Based on https://gist...
Python
0.000001
4641195df10da114b896fbe16c89324954833d22
Create main.py
web/src/main.py
web/src/main.py
from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run()
Python
0.000001
a4af8609686386d3371289ea24e019a897ca13bd
introduce a new kind of exception: RedirectWarning (warning with an additional redirection button)
openerp/exceptions.py
openerp/exceptions.py
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2011 OpenERP s.a. (<http://openerp.com>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the G...
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2011 OpenERP s.a. (<http://openerp.com>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the G...
Python
0.000001
7e7f0585971f472c25fda3b6370e37eb4d8d0ea5
test import of ssh.tunnel
zmq/tests/test_imports.py
zmq/tests/test_imports.py
# Copyright (C) PyZMQ Developers # Distributed under the terms of the Modified BSD License. import sys from unittest import TestCase class TestImports(TestCase): """Test Imports - the quickest test to ensure that we haven't introduced version-incompatible syntax errors.""" def test_toplevel(self): ...
# Copyright (C) PyZMQ Developers # Distributed under the terms of the Modified BSD License. import sys from unittest import TestCase class TestImports(TestCase): """Test Imports - the quickest test to ensure that we haven't introduced version-incompatible syntax errors.""" def test_toplevel(self): ...
Python
0.000001
4e8da16d761c507f9cb2a2ad2635903f90390c5c
Add python implementation for problem 38.
python/038.py
python/038.py
''' Pandigital Multiples =================== Take the number 192 and multiply it by each of 1, 2, and 3: 192 × 1 = 192 192 × 2 = 384 192 × 3 = 576 By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 a...
Python
0
df9fc9f64b5450851abef90b50804e56e0d152bf
add fragment reaction class
afm/reaction.py
afm/reaction.py
class FragmentReaction(object): def __init__(self, index=-1, reactants=None, products=None, kinetics=None, reversible=False, pairs=None, family=None ): self.index = index self.reactants = reactants self.products = products self.kinetics = kinetics self.reversible = rever...
Python
0
9192fe92621d6f79b0f99802f50014d27c967d26
Add alg_knapsack.py
alg_knapsack.py
alg_knapsack.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function def main(): wt_cap = 10 wt = [1, 2, 4, 2, 5] val = [5, 3, 5, 3, 2] if __name__ == '__main__': main()
Python
0.998627
a101bd9ccb280348e6da32b3f2c0540ca6c65807
Implement String field
polygraph/types/fields.py
polygraph/types/fields.py
from collections import OrderedDict from graphql.type.definition import GraphQLField, GraphQLNonNull from graphql.type.scalars import GraphQLString from marshmallow import fields class String(fields.String): def __init__(self, description, nullable=False, args=None, deprecation_reason=None, **ad...
Python
0.000196
f0033f87e0b4082e55dd3641282e65369e03c03e
Create natural_sort.py (#3286)
sorts/natural_sort.py
sorts/natural_sort.py
from __future__ import annotations import re def natural_sort(input_list: list[str]) -> list[str]: """ Sort the given list of strings in the way that humans expect. The normal Python sort algorithm sorts lexicographically, so you might not get the results that you expect... >>> example1 = ['2 f...
Python
0
bba04c867055715bb93e2fc2736538337b9f26ac
Add caesar cipher
CaesarCipher.py
CaesarCipher.py
class CaesarCipher: def encrypt(self, plain, n): rst = [None] * len(plain) for i in range(len(plain)): rst[i] = chr((ord(plain[i]) - ord('A') + n) % 26 + ord('A')) return ''.join(rst) def decrypt(self, encrypted, n): rst = [None] * len(encrypted) f...
Python
0.999999
e5442b54f172afdca477d34e6396556689b87951
Calculator task done
01/if-elif-else/calculator.py
01/if-elif-else/calculator.py
a = input("Enter a: ") a = int(a) b = input("Enter b: ") b = int(b) oper = input("Enter operation: ") if oper == "+": result = a + b elif oper == "-": result = a - b elif oper == "*": result = a * b elif oper == "/": result = a / b else: print "Error" result = False if result != False: print("...
Python
0.999904
4fef2ff44b2f195a9a135ba3ca5c70bb08572d39
Add sphinx configuration
zeppelin-docs/src/main/spinx/conf.py
zeppelin-docs/src/main/spinx/conf.py
# # 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 writing, software # distributed under ...
Python
0.000003
f2252de974e1bf3b40f8dce0e768597e31ac2a05
Add Aggregate object model
nova/objects/aggregate.py
nova/objects/aggregate.py
# Copyright 2013 IBM Corp. # # 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 agree...
Python
0.000002