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
9266e24e616174cc37b5e6f7926dfda81471abb5
Initialize PracticeQuestions
books/CrackingCodesWithPython/Chapter13/PracticeQuestions.py
books/CrackingCodesWithPython/Chapter13/PracticeQuestions.py
# Chapter 13 Practice Questions # 1. What do the following expressions evaluate to? print(17 % 1000) print(5 % 5) # 2. What is the GCD of 10 and 15? # Don't do this - imports should be at the top of the file from books.CrackingCodesWithPython.Chapter13.cryptomath import gcd print(gcd(10, 15)) # 3. What does spam con...
Python
0
c9e90ef5413bd560422e915d213df73ad88dffd7
Add apigateway integration test for PutIntegration
tests/integration/test_apigateway.py
tests/integration/test_apigateway.py
# Copyright 2015 Amazon.com, Inc. or its affiliates. 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. A copy of # the License is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file accompa...
Python
0
1b7b8ff8b6e33bc25323bc700e3e244758ee1a2d
add initial index code
maras/ind/hash_index.py
maras/ind/hash_index.py
''' A hash based index ''' # Import python libs import struct import os # Import maras libs import maras.utils # Import third party libs import msgpack class HashIndex(object): ''' Hash index ''' def __init__( self, name, dbpath, hash_limit=0xfffff, ...
Python
0.000002
4ce7a1932d9cde635263a4fe5a80af57589e1cfa
add NASM 2.13.02 Conan package recipe
build_env/Conan/packages/NASM/2.13.02/conanfile.py
build_env/Conan/packages/NASM/2.13.02/conanfile.py
import os from conans import ConanFile, AutoToolsBuildEnvironment, tools class NASM(ConanFile): name = "NASM" version = "2.13.02" url = "http://www.nasm.us" settings = {"os": ["Linux"]} def getSubdirectories(self, d): return [ f for f in os.listdir(d) if os.path.isdir(f) ] def source(self): self.outp...
Python
0
9fb564d8f02d92432a62be02c906e3b227f48c10
Create add_results_new.py
run_tests/shaker_run/add_results_new.py
run_tests/shaker_run/add_results_new.py
custom_res1 = [{'status_id': 5, 'content': 'Check [Operations per second Median; iops]', 'expected': '88888', 'actual': '7777'},{'status_id': 5, 'content': 'Check [deviation; %]', 'expected': '5555', 'actual': '9999'}] res1 = {'test_id': test_4kib_read, 'status_id': 5, 'custom_test_case_steps_results': custom_res1} res...
Python
0.000004
729f1c5147e4d4ce242d73731c8e455b2a50fca3
add 188
vol4/188.py
vol4/188.py
def tetration(a, b, m): t0 = 1 for i in range(b): t1 = pow(a, t0, m) if t0 == t1: break t0 = t1 return t0 if __name__ == "__main__": print tetration(1777, 1855, 10 ** 8)
Python
0.999986
247bb7b5beb58eaa70bbd54488214d19ccb380b1
read dicom files and write out metadata to a CSV/json
dcm/export_metadata.py
dcm/export_metadata.py
# This script sxtracts meta-data from DICOMs and place it into two files: # (1) for sequence data, output it as a json # (2) for tabular data, output it as a CSV (readable by pandas) # Note that the function does *not* output values if they are longer than 100 characters. # This avoids outputting look up tables. impor...
Python
0.000001
98c1ff71d57749168f0ca35d97dbe77a8a67e082
Add module for utilities related to xgboost
mltils/xgboost/utils.py
mltils/xgboost/utils.py
xgb_to_sklearn = { 'eta': 'learning_rate', 'num_boost_round': 'n_estimators', 'alpha': 'reg_alpha', 'lambda': 'reg_lambda', 'seed': 'random_state', } def to_sklearn_api(params): return { xgb_to_sklearn.get(key, key): value for key, value in params.items() }
Python
0
bbb10ba41db6f70512fe6bcb5207377606a22455
Create Mordecai_Output.py
Geoparser_Comparison/English/Mordecai_Output.py
Geoparser_Comparison/English/Mordecai_Output.py
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Download and run Mordecai from following link: "https://github.com/openeventdata/mordecai" To change the corpus, just change the name in main function. """ import xml.etree.ElementTree as et import re import json, sys import requests #reload(sys) #...
Python
0.000198
9d98c3280d4e9dc6dda172d11e02922fc9958471
add homwork01_v0.2.py
01/homwork01_v0.2.py
01/homwork01_v0.2.py
#!/usr/bin/env python #coding=utf-8 num_list = [1,2,3,2,12,3,1,3,21,2,2,3,4111,22,3333,444,111,4,5,777,65555,45,33,45] max2 = max1 = num_list[0] # print max1, max2 # max1 bigger than max2 # 1. n>max1 and n>max2 # 2. n<=max1 and n>max2 # 3. n<max1 and n<=max2 for n in num_list: if n > max2: if n > max1: ...
Python
0.000065
104cefdb55a89ac89984363cb1930bdc3ef054e9
Add 01_GPy_regression.py to the repository. This is a kind of sandbox file
01_GPy_regression.py
01_GPy_regression.py
# -*- coding: utf-8 -*- # <nbformat>3.0</nbformat> # <headingcell level=1> # Using GPy package to perform Gaussian Processes regression on SN lightcurves # <rawcell> # https://gpy.readthedocs.org/en/latest/tuto_GP_regression.html # <codecell> import numpy as np import pylab as pb pb.ion() import GPy import pickle...
Python
0
fbbe551b1347f158bf44350574ca7001a887d824
Add sfp_gravatar
modules/sfp_gravatar.py
modules/sfp_gravatar.py
#------------------------------------------------------------------------------- # Name: sfp_gravatar # Purpose: SpiderFoot plug-in to search Gravatar API for an email address # and retrieve user information, including username, name, phone # numbers, additional email addresses, and...
Python
0.000054
7b27f4cdb8135e7d5fd18ff11e2eae9325e6f17a
Move METROPOLIS_FORK_BLKNUM
ethereum/config.py
ethereum/config.py
from rlp.utils import decode_hex from ethereum import utils from ethereum.db import BaseDB default_config = dict( # Genesis block difficulty GENESIS_DIFFICULTY=131072, # Genesis block gas limit GENESIS_GAS_LIMIT=3141592, # Genesis block prevhash, coinbase, nonce GENESIS_PREVHASH=b'\x00' * 32, ...
from rlp.utils import decode_hex from ethereum import utils from ethereum.db import BaseDB default_config = dict( # Genesis block difficulty GENESIS_DIFFICULTY=131072, # Genesis block gas limit GENESIS_GAS_LIMIT=3141592, # Genesis block prevhash, coinbase, nonce GENESIS_PREVHASH=b'\x00' * 32, ...
Python
0.000005
73bc2dbfe40db224a38725f4412e33b1b5accac6
Add script example.
examples/script.py
examples/script.py
# Copyright (c) 2013 Jordan Halterman <jordan.halterman@gmail.com> # See LICENSE for details. import sys, os sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) # The Active Redis API provides native support for Redis server-side # Lua scripting. from active_redis import Script class PushMany(Script): ""...
Python
0
68ba389a4b6cefe70864577bcc195f14012e224d
Add UK flag example
examples/ukflag.py
examples/ukflag.py
import math import omnicanvas def create_union_flag(height): # The union flag is twice as wide as it is high canvas = omnicanvas.Canvas(height * 2, height, background_color="#000066") #This is the length of the diagonal of the flag, with Pythagoras diagonal_length = math.sqrt((height ** 2) + ((height ...
Python
0.000001
3ab0e590479fabb024937e52eab02e2311033448
Implement a function to map chord segments to STFT blocks.
time_intervals.py
time_intervals.py
import pandas as pd import numpy as np import collections def block_labels(df_blocks, df_labels): ''' Given fixed-size overlapping blocks and variable-sized non-overlapping labels select most suitable label for each block. This can be useful eg. to assign chord labels to audio blocks. All times ar...
Python
0
fbaca2f2a0ceaa77606d9c24846a1a1b045dc460
remove deleted files from manifest
addons/l10n_lu/__openerp__.py
addons/l10n_lu/__openerp__.py
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # Copyright (C) 2011 Thamini S.à.R.L (<http://www.thamini.com>) # Copyright (C) 2011 ADN Consultants S.à...
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # Copyright (C) 2011 Thamini S.à.R.L (<http://www.thamini.com>) # Copyright (C) 2011 ADN Consultants S.à...
Python
0
c0ee3bb87a26a57bc7dc1bd4e1aaf6136f94bc17
Add missing filters.py file in organizations
ain7/organizations/filters.py
ain7/organizations/filters.py
# -*- coding: utf-8 """ ain7/organizations/filters.py """ # # Copyright © 2007-2015 AIn7 Devel Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or...
Python
0.000001
f56181aaf6df758abb988d10c757c6eba72d5025
write beginning of method for storing probabilities in a hash
parser.py
parser.py
import re probabilityHash = {[], ""} #[word1, word2], count def parseIntoProbabilityHash(text): stripPunctuation = re.sub(ur"[^\w\d'\s]+",' ',text) wordsInText = stripPunctuation.split() n = 0 for word in wordsInText: probabilityHash[wordsInText[n]] = 1 return probabilityHash
Python
0.000011
5e54e5ebf9add6d8bd879d963803ee57fd591f4b
Write new Preparation tests
whats_fresh/whats_fresh_api/tests/views/entry/test_new_preparation.py
whats_fresh/whats_fresh_api/tests/views/entry/test_new_preparation.py
from django.test import TestCase from django.core.urlresolvers import reverse from whats_fresh_api.models import * from django.contrib.gis.db import models import json class NewPreparationTestCase(TestCase): """ Test that the New Preparation page works as expected. Things tested: URLs reverse cor...
Python
0.000001
4d92b111eecd3ce938676edee36b288c42484905
test scraper for UKÄ
statscraper/scrapers/uka_scraper.py
statscraper/scrapers/uka_scraper.py
# encoding: utf-8 u""" A scraper to fetch Swedish university application statistics from the Swedish Higher Education Authority (Universitetskanslerämbetet, UKÄ), at http://statistik.uka.se """ from statscraper import BaseScraper, Dataset, Dimension, Result, Collection import requests from bs4 import BeautifulSoup ...
Python
0
d2762f81a9f8ed405ca5fc9d567004af182d137b
add importer for delimited data
python/delim_import.py
python/delim_import.py
from json_generator import JsonGenerator, writeTrackEntry def delimImport(file, skipLines, colNames, dataDir, trackLabel, key = None, delim = "\t", chunkBytes = 200000, compress = True, config = {'style': {'className': 'feature2'}} ): fh = open(file, 'r') data = [line.split(deli...
Python
0
319af4e5cfad516f0c68bdbb8adabed19b0b82b6
Add backend "multi_tcp".
src/backend/multi_tcp.py
src/backend/multi_tcp.py
# coding: UTF-8 import errno import socket from collections import defaultdict DEFAULT_PORT = 4194 DEFAULT_BLOCKSIZE = 8192 DEFAULT_NUMBER = 5 class MultiTCPBackend(object): def __init__(self, number, blocksize): self.number = number self.blocksize = blocksize self.send_bufs = [b"" ...
Python
0
de456b7e6397d775bd244b7e20eb1d675ca1bde0
Add logging to attrib plugin
nose2/plugins/attrib.py
nose2/plugins/attrib.py
import logging from unittest import TestSuite from nose2.events import Plugin log = logging.getLogger(__name__) undefined = object() # TODO: eval attribs class AttributeSelector(Plugin): """TODO: document""" def __init__(self): self.attribs = [] self.addOption(self.attribs, "A", "attr", "At...
from unittest import TestSuite from nose2.events import Plugin undefined = object() # TODO: eval attribs class AttributeSelector(Plugin): """TODO: document""" def __init__(self): self.attribs = [] self.addOption(self.attribs, "A", "attr", "Attribulate") def startTestRun(self, event): ...
Python
0
5bcdb4c7a0184c76bedc0843bac11981234bad77
add some tests for dashboard views
tests/plans/test_dashboard_views.py
tests/plans/test_dashboard_views.py
import pytest from django.conf import settings from django.urls import reverse from adhocracy4.test.helpers import redirect_target from meinberlin.apps.plans.models import Plan from meinberlin.test.helpers import assert_template_response @pytest.mark.django_db def test_initiator_can_edit(client, plan_factory): p...
Python
0
51a5c7626b634687be57c3e6ed05ea07f6468ad0
add analyzer test
timeside/tests/api/test_analyzer.py
timeside/tests/api/test_analyzer.py
# -*- coding: utf-8 -*- import timeside from sys import stdout import os.path import numpy class TestAnalyzer: graphers = timeside.core.processors(timeside.api.IGrapher) decoders = timeside.core.processors(timeside.api.IDecoder) encoders= timeside.core.processors(timeside.api.IEncoder) analyzers...
Python
0.000001
b634e5966c48299eda8cc9a3dcd4e8f769df6812
Create 5kyu_tree_to_list.py
Solutions/5kyu/5kyu_tree_to_list.py
Solutions/5kyu/5kyu_tree_to_list.py
class Node: def __init__(self, data, child_nodes=None): self.data = data self.child_nodes = child_nodes def tree_to_list(tr): call = to_list(tr, 0, []) return call def to_list(tr, depth, res): res.append([tr.data, depth]) if tr.child_nodes: for i in tr.child_nodes: ...
Python
0.000002
f1cb1cb0cdcf7ef3d5d0e286bfbd9d9664239098
Create 6kyu_alphabetized.py
Solutions/6kyu/6kyu_alphabetized.py
Solutions/6kyu/6kyu_alphabetized.py
def alphabetized(s): return ''.join(s for s in sorted(s, key=lambda s: s.lower()) if s.isalpha())
Python
0.000033
0f55bd7e100dca1ef94dfe2f47b0f46774197e3f
Create cbus.py
cbus.py
cbus.py
#!/usr/bin/python3 #console command for lighting control of c-bus network #add command line switches for changing the default ip and port #add option for immediate return i.e. dont wait for return codes #cbus on 6, cbus off 7, cbus ramp 7m 100 #parse command line, convert time to closest value # Copyright 2014 Darre...
Python
0
2eddc73e2d7b78fbfac521eb1e6014ca26421510
Add forgotten migration
osmdata/migrations/0012_auto_20170829_1539.py
osmdata/migrations/0012_auto_20170829_1539.py
# -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-08-29 15:39 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('osmdata', '0011_auto_20170824_1521'), ] operations...
Python
0.000004
d00243d9500118400f7e08409d9564b15b2b4148
Add trivial CLI example
examples/cliExample.py
examples/cliExample.py
# Very Simple CLI example from OTXv2 import OTXv2 import IndicatorTypes import argparse # Your API key API_KEY = '' OTX_SERVER = 'https://otx.alienvault.com/' otx = OTXv2(API_KEY, server=OTX_SERVER) parser = argparse.ArgumentParser(description='Description of your program') parser.add_argument('-i', '--ip', help='IP...
Python
0.000004
ecc8a93ddda784102311ebfd4c3c93624f356778
Add migration to add strip_html sql function
cnxarchive/sql/migrations/20160723123620_add_sql_function_strip_html.py
cnxarchive/sql/migrations/20160723123620_add_sql_function_strip_html.py
# -*- coding: utf-8 -*- def up(cursor): cursor.execute("""\ CREATE OR REPLACE FUNCTION strip_html(html_text TEXT) RETURNS text AS $$ import re return re.sub('<[^>]*?>', '', html_text, re.MULTILINE) $$ LANGUAGE plpythonu IMMUTABLE; """) def down(cursor): cursor.execute("DROP FUNCTION IF EXISTS stri...
Python
0
0f5b15a1f909c79b40a3f2655d00bc7852d41847
add missing migration
conversion_service/conversion_job/migrations/0003_auto_20151120_1528.py
conversion_service/conversion_job/migrations/0003_auto_20151120_1528.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('conversion_job', '0002_auto_20151119_1332'), ] operations = [ migrations.AlterField( model_name='conversionjob',...
Python
0.000258
ed45aa20bc54714c6eb355417520c3d90a6b47fc
Add init.py
init.py
init.py
#!/usr/bin/env python import os import sys import django os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'readthedocs.settings.dev') sys.path.append(os.getcwd()) django.setup() from django.contrib.auth.models import User admin = User.objects.create_user('admin', '', 'admin') admin.is_superuser = True admin.is_staff ...
Python
0.000063
67d86229279e979d8ef5ac54e5ed8ca85c32ff2e
add another sample script (multiple.py).
demos/multiple.py
demos/multiple.py
#!/usr/bin/env python from Exscript import Host from Exscript.util.interact import read_login from Exscript.util.template import eval_file from Exscript.util.start import start def one(conn): conn.open() conn.authenticate() conn.autoinit() conn.execute('show ip int brie') def two(conn...
Python
0
3704654e704c0595e933f4ab2832e945816afde8
Add setup.py file
TimeSeries/PublicApis/Python/setup.py
TimeSeries/PublicApis/Python/setup.py
from setuptools import setup setup( name="aquarius-timeseries-client", py_modules=["timeseries_client"], version="0.1", description="Python client for Aquarius TimeSeries API", long_description=open("README.md").read(), long_description_content_type="text/markdown", url="https://github.com/...
Python
0.000001
42e1447db973cce539353912eada05b26870bae6
Add serial test connection.
experiment_control/test_serial_connection.py
experiment_control/test_serial_connection.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2014, Niklas Hauser # All rights reserved. # # The file is part of my bachelor thesis and is released under the 3-clause BSD # license. See the file `LICENSE` for the full license governing this code. # ------------------------------------------------------...
Python
0
da22d8dffadbb4713e715aca7918942f445090c9
embed video form and model fields
embed_video/fields.py
embed_video/fields.py
from django.db import models from django import forms from django.utils.translation import ugettext_lazy as _ from .base import detect_backend __all__ = ('EmbedVideoField', 'EmbedVideoFormField') class EmbedVideoField(models.URLField): def formfield(self, **kwargs): defaults = {'form_class': EmbedVideoF...
Python
0
b81028067cf65b2ee3a155d081e7983a1de70d5f
Add mistakenly omitted migrations
opentreemap/treemap/migrations/0005_auto_20150729_1046.py
opentreemap/treemap/migrations/0005_auto_20150729_1046.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('treemap', '0004_auto_20150720_1523'), ] operations = [ migrations.AlterField( model_name='fieldpermission', ...
Python
0
1fa74f6a6a5faeb9579c889df32e4bfe8d6908df
Add migration
fat/migrations/0059_event_extra_sponsored.py
fat/migrations/0059_event_extra_sponsored.py
# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2016-08-08 10:16 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('fat', '0058_auto_20160808_1007'), ] operations = [ migrations.AddField( ...
Python
0.000002
62c70b301ffc1e178c3bd54bd81291876b3883ea
Add simple linear interpolation filling.
analysis/03-fill-dropouts-linear.py
analysis/03-fill-dropouts-linear.py
#!/usr/bin/env python from __future__ import division import climate import lmj.cubes import lmj.cubes.fill import numpy as np import pandas as pd logging = climate.get_logger('fill') def fill(dfs, window): '''Complete missing marker data using linear interpolation. This method alters the given `dfs` in-pl...
Python
0
7942254131bcf005d5a5f1bb33ca7d1ffff1b311
Create keyAllCtrls.py
af_scripts/blendshapes/keyAllCtrls.py
af_scripts/blendshapes/keyAllCtrls.py
import maya.cmds as cmds import maya.mel as mel cmds.select(cmds.ls('*:*.faceCtrl', o=1)) mel.eval('doSetKeyframeArgList 6 { "4","0","0","0","1","0","0","animationList","0","1","0" };')
Python
0.000002
f51c4abc95fda5504e7c7a5ad87355698798ddd1
create temporary streaming solution
temp_vidstream.py
temp_vidstream.py
import picamera with picamera.PiCamera() as camera: camera.resolution = (640, 480) camera.start_recording('vidstream.mp4') camera.wait_recording(60) camera.stop_recording()
Python
0
89d27dd0a28f84c99930c0f1dad496e525f62272
migrate to namespace table
migrations/versions/28c0d6c2f887_add_namespaces.py
migrations/versions/28c0d6c2f887_add_namespaces.py
"""Add namespaces Revision ID: 28c0d6c2f887 Revises: 4323056c0b78 Create Date: 2013-10-14 22:18:29.705865 """ # revision identifiers, used by Alembic. revision = '28c0d6c2f887' down_revision = '4323056c0b78' from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import mysql def upgrade(): ###...
Python
0.000002
55f2325354724cfe8b90324038daf2c1acaa916a
Add unit tests for OpenStack config defaults
teuthology/openstack/test/test_config.py
teuthology/openstack/test/test_config.py
from teuthology.config import config class TestOpenStack(object): def setup(self): self.openstack_config = config['openstack'] def test_config_clone(self): assert 'clone' in self.openstack_config def test_config_user_data(self): os_type = 'rhel' os_version = '7.0' ...
Python
0
526d58fb917a4e098018f733b4c0b254417140b4
Add @log_route decorator
keeper/logutils.py
keeper/logutils.py
"""Logging helpers and utilities. """ __all__ = ['log_route'] from functools import wraps from timeit import default_timer as timer import uuid from flask import request, make_response import structlog def log_route(): """Route decorator to initialize a thread-local logger for a route. """ def decorato...
Python
0.00001
3f3115a0a9c7407820b3b10c06dcfa4f92ac6e57
Add owned book scaffold
goodreads_api_client/resources/owned_book.py
goodreads_api_client/resources/owned_book.py
# -*- coding: utf-8 -*- """Module containing owned book resource class.""" from goodreads_api_client.exceptions import OauthEndpointNotImplemented from goodreads_api_client.resources.base import Resource class OwnedBook(Resource): def create(self): raise OauthEndpointNotImplemented('owned_book.compare') ...
Python
0
5d99b7c2dfbfbb776716f2258d560bab2602531f
Create main.py
main.py
main.py
# -*- coding: utf-8 -*- #Backlog Manager #programmed by Ian Hitterdal (otend) #licensed under MIT license import work import random def addWork(medium): #input: valid medium string #user input: work title string #output: none #user output: none, really global workDict global mediumList if medium not in me...
Python
0.000001
f75d321b200217514cde901cc15cc2b798e3dcfe
Add new hipchat module
bumblebee/modules/hipchat.py
bumblebee/modules/hipchat.py
"""Displays the unread messages count for an HipChat user Requires the following library: * requests Parameters: * hipchat.token: HipChat user access token, the token needs to have the 'View Messages' scope. * hipchat.interval: Refresh interval in minutes (defaults to 5) """ import time import functools ...
Python
0
786ed1d37ae5285bce1178d401d487233d4bd5b1
Add greater/less than tests
test/osa_tests.py
test/osa_tests.py
#!/usr/bin/env python # Copyright 2016, Rackspace US, 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 the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
Python
0.000001
0a3488915938de418ab0675f4cc051769b470927
Fix tab switching test on reference builds.
tools/perf/measurements/tab_switching.py
tools/perf/measurements/tab_switching.py
# Copyright 2013 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. """The tab switching measurement. This measurement opens pages in different tabs. After all the tabs have opened, it cycles through each tab in sequence, an...
# Copyright 2013 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. """The tab switching measurement. This measurement opens pages in different tabs. After all the tabs have opened, it cycles through each tab in sequence, an...
Python
0.998504
01d9134067852a1f9dfecf75f730f9fba14434e0
Add test_gradient_checker.py
python/paddle/v2/framework/tests/test_gradient_checker.py
python/paddle/v2/framework/tests/test_gradient_checker.py
import unittest import numpy from paddle.v2.framework.op import Operator from gradient_checker import GradientChecker from gradient_checker import get_numeric_gradient class GetNumericGradientTest(unittest.TestCase): def test_add_op(self): add_op = Operator('add_two', X="X", Y="Y", Out="Z") x = nu...
Python
0.000005
9779fc585d8d8d87580a47139742eb25bc52facd
Add new decorators module, move deprecated from utils over here
kiwi/decorators.py
kiwi/decorators.py
# # Kiwi: a Framework and Enhanced Widgets for Python # # Copyright (C) 2005 Async Open Source # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (a...
Python
0
9258451157de31f3ece7e18fcb8ae43c433239f4
add example to post files to Portals File System
portals_api/upload_files_to_portals_file_system.py
portals_api/upload_files_to_portals_file_system.py
# Example that uploads a file to the Portals File System using Portals API # Access Level- Portals Domain Administrator # Note: Uses Python 'Requests' module for calling API # APIs: # - http://docs.exosite.com/portals/#update-file-content import requests import getpass directory = "images" #default directory name do...
Python
0
425d8ef0f439e9580c85e0dc04e5fe0c93cffddf
add 16
p016.py
p016.py
# 2**15 = 32768 and the sum of its digits is 3+2+7+6+8=26 # what is the sum of the digits of the number 2**1000? def f(n): return sum([ int(c) for c in str(2**n)]) print f(1000)
Python
0.999998
2b73467ccfbf6e29047223f1c1e3250916b6ffdb
add 23
p023.py
p023.py
from itertools import combinations_with_replacement def divisors(n): r = set() for i in range(1, n / 2): if n % i == 0: r.add(i) r.add(n / i) r.discard(n) return r abundant = filter(lambda n: sum(divisors(n)) > n, range(2, 29000)) u = set(range(1, 29000)) for i in com...
Python
0.999986
351f2779549add63963d4103fbe1b058dde59d85
Add stupid test to make Jenkins happy.
zipline/test/test_sanity.py
zipline/test/test_sanity.py
from unittest2 import TestCase class TestEnviroment(TestCase): def test_universe(self): # first order logic is working today. Yay! self.assertTrue(True != False)
Python
0.000006
67f5e754a5f90903e09a6a876d858d002c513f8a
Add initial draft of posterior models
abcpy/posteriors.py
abcpy/posteriors.py
import scipy as sp from .utils import stochastic_optimization class BolfiPosterior(): def __init__(self, model, threshold, priors=None): self.threshold = threshold self.model = model self.priors = [None] * model.n_var self.ML, ML_val = stochastic_optimization(self._neg_unnormalize...
Python
0
8131bb276a467d7df00f7452616869d20d312eb7
add api_view test
apps/api/tests/tests_view.py
apps/api/tests/tests_view.py
import datetime from django.test import TestCase from django.test.client import Client from apps.pages.models import Page, Page_translation class MySmileApiTestCase(TestCase): def setUp(self): some_page = Page.objects.create(id=1, slug='index', color='#FDA13...
Python
0
6104fdc57931151f6cf3c8cd517f5efee17fe826
Update repost_stock_for_deleted_bins_for_merging_items.py
erpnext/patches/v7_1/repost_stock_for_deleted_bins_for_merging_items.py
erpnext/patches/v7_1/repost_stock_for_deleted_bins_for_merging_items.py
from __future__ import unicode_literals import frappe from erpnext.stock.stock_balance import repost_stock def execute(): frappe.reload_doc('manufacturing', 'doctype', 'production_order_item') frappe.reload_doc('manufacturing', 'doctype', 'production_order') modified_items = frappe.db.sql_list(""" select name f...
from __future__ import unicode_literals import frappe from erpnext.stock.stock_balance import repost_stock def execute(): frappe.reload_doc('manufacturing', 'doctype', 'production_order_item') modified_items = frappe.db.sql_list(""" select name from `tabItem` where is_stock_item=1 and modified >= '2016-10-31'...
Python
0
3acf451435e1978fcfdd5c5d8f0386e87460039e
Add zerg(ling) rush example
examples/zerg_rush.py
examples/zerg_rush.py
import random import sc2 from sc2 import Race, Difficulty, ActionResult from sc2.player import Bot, Computer class ZergRushBot(sc2.BotAI): def __init__(self): self.drone_counter = 0 self.overlord_counter = 0 self.extractor_started = False self.spawning_pool_started = False ...
Python
0.000002
142ec5bdca99d11236f2d479cf4dafbc7e8962a3
test of the nis module
Lib/test/test_nis.py
Lib/test/test_nis.py
import nis verbose = 0 if __name__ == '__main__': verbose = 1 maps = nis.maps() for nismap in maps: if verbose: print nismap mapping = nis.cat(nismap) for k, v in mapping.items(): if verbose: print ' ', k, v if not k: continue if nis.match(k, nismap) <> v: print "NIS match failed...
Python
0
a35a6b715670e985c0bd711a4cb55df2a267e018
Create downloader.py
3.下载缓存/downloader.py
3.下载缓存/downloader.py
import urlparse import urllib2 import random import time from datetime import datetime, timedelta import socket DEFAULT_AGENT = 'wswp' DEFAULT_DELAY = 5 DEFAULT_RETRIES = 1 DEFAULT_TIMEOUT = 60 class Downloader: def __init__(self, delay=DEFAULT_DELAY, user_agent=DEFAULT_AGENT, proxies=None, num_retries=DEFAULT_...
Python
0.000001
6bf4f7491bdfe8a5afd5eb8cdb4a8fcb2af78b36
Add commands/findCognateClassesCrossingMeanings.py
ielex/lexicon/management/commands/findCognateClassesCrossingMeanings.py
ielex/lexicon/management/commands/findCognateClassesCrossingMeanings.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals, print_function from collections import defaultdict from django.core.management import BaseCommand from ielex.lexicon.models import CognateJudgement, Lexeme class Command(BaseCommand): help = "Compiles a list of cognate classes,"\ "\nw...
Python
0
b7dd7f75f655f4fbcb34d8f9ec260a6f18e8f617
Add utility to create administrative users.
backend/scripts/adminuser.py
backend/scripts/adminuser.py
#!/usr/bin/env python import rethinkdb as r from optparse import OptionParser import sys def create_group(conn): group = {} group['name'] = "Admin Group" group['description'] = "Administration Group for Materials Commons" group['id'] = 'admin' group['owner'] = 'admin@materialscommons.org' grou...
Python
0
a1c4eb2183e3d3920e992b0753392d987b518bcf
add unit-test for tablegenerator.util.split_string_at_suffix
benchexec/tablegenerator/test_util.py
benchexec/tablegenerator/test_util.py
# BenchExec is a framework for reliable benchmarking. # This file is part of BenchExec. # # Copyright (C) 2007-2016 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 Lic...
Python
0.000001
8d32947304d72a13ed8e27d41d35028a904072e9
Add libpq package
libpq/conanfile.py
libpq/conanfile.py
from conans import ConanFile, AutoToolsBuildEnvironment, tools import os class LibpqConn(ConanFile): name = "libpq" version = "9.6.3" license = "PostgreSQL license https://www.postgresql.org/about/licence/" url = "https://github.com/trigger-happy/conan-packages" description = "C library for interfa...
Python
0.000001
e59c03f0bad78c9cb1db86f2fb0ac29009c8474e
add rll
reverse-linked-list.py
reverse-linked-list.py
# https://leetcode.com/problems/reverse-linked-list/ # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @param {ListNode} head # @return {ListNode} def reverseList(self, head): last, current = None, hea...
Python
0.000001
0c17398f68597eae175ad6a37945cf37e95e1809
Reset invalid default quotas for CloudServiceProjectLink [WAL-814]
nodeconductor/structure/migrations/0050_reset_cloud_spl_quota_limits.py
nodeconductor/structure/migrations/0050_reset_cloud_spl_quota_limits.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.contrib.contenttypes import models as ct_models from django.db import migrations, models from nodeconductor.quotas.models import Quota from nodeconductor.structure.models import CloudServiceProjectLink def reset_cloud_spl_quota_limits(apps,...
Python
0
63ae0b619ea50b1e234abc139becaeb84c703302
add player class
MellPlayer/player.py
MellPlayer/player.py
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Netease Music Player Created on 2017-02-20 @author: Mellcap ''' class Player(object): def __init__(self): pass def start(self): pass def pause(self): pass def start_or_pause(self): pass def switch_song(self, a...
Python
0
602db58ff01ef7ea2718d713a5b2026377023b8d
Create context_processors.py
commons/context_processors.py
commons/context_processors.py
from os import environ from {{ project_name }} import __version__ import uuid def metainfo(request): metainfo = { 'uuid': unicode(uuid.uuid4()), 'version': __version__, 'static_version': "?v={}".format(uuid), 'branch': environ['BRANCH'] } return metainfo
Python
0.000577
6ac6f936a12fcc1578db3fed629ec3a8bc471dcb
remove print
src/you_get/extractor/acfun.py
src/you_get/extractor/acfun.py
#!/usr/bin/env python __all__ = ['acfun_download'] from ..common import * from .qq import qq_download_by_id from .sina import sina_download_by_vid from .tudou import tudou_download_by_iid from .youku import youku_download_by_vid import json, re def get_srt_json(id): url = 'http://comment.acfun.com/%s.json' % i...
#!/usr/bin/env python __all__ = ['acfun_download'] from ..common import * from .qq import qq_download_by_id from .sina import sina_download_by_vid from .tudou import tudou_download_by_iid from .youku import youku_download_by_vid import json, re def get_srt_json(id): url = 'http://comment.acfun.com/%s.json' % i...
Python
0.000001
4152b6a10610aa364e901f062a8611b94f65b3de
Create e.py
at/abc126/e.py
at/abc126/e.py
# 并查集 read = input n, m = map(int, read().split()) f = [-1 for i in range(n + 1)] # 1 ~ n def find(x): if f[x]<0: return x else : f[x] = find(f[x]) return f[x] for i in range(m): x,y,z = map(int, read().split()) if abs(x) < abs(y): #合并到x上,保证x是大集合 x,y = y,x fx = find(x...
Python
0.000001
2057ebd9bae44b232b133ca0c0f76e11d4ca3b5f
Add missing file
conary/server/wsgi_adapter.py
conary/server/wsgi_adapter.py
# # Copyright (c) rPath, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the h...
Python
0.000006
38cec6e7806e55d957e9810d1bb861054ae4842b
add useful methods
useful_methods.py
useful_methods.py
# encoding utf-8 def bisect_right(data, target, lo, hi): """ Given a sorted array, returns the insertion position of target If the value is already present, the insertion post is to the right of all of them >>> bisect_right([1,1,2,3,4,5], 1, 0, 6) 2 >>> bisect_right([1,1,2,3,4,5], 0, 0, 6) ...
Python
0.000036
aef33a2c8f34d164bba18741a3cf6e5b71a60a99
Add stub file for extract_csv.py
extract_csv.py
extract_csv.py
def extract_csv(filename): # TODO: connect to sqlite database and extract a csv of the rows. pass if __name__ == '__main__': extract_csv('data.csv')
Python
0.000001
f99eb9a2397f571f045f6a5f663a42878e94b3ea
Create Euler_003.py
Euler_003.py
Euler_003.py
# x, num = 2, 600851475143 while num != x: if num % x == 0: num = num / x; x = 2 else: x += 1 print x
Python
0.000169
411ef30db7431e9df1af02cd68a6ae0b9d874af0
add a first draft for the test of canal metrics
dipy/reconst/tests/test_canal_metrics.py
dipy/reconst/tests/test_canal_metrics.py
import numpy as np from dipy.reconst.dsi import DiffusionSpectrumModel from dipy.data import get_data from dipy.core.gradients import gradient_table from numpy.testing import (assert_almost_equal, run_module_suite) from dipy.reconst.canal import ShoreModel, SHOREmatrix from dipy.sims.voxel im...
Python
0
1072b8e28e75cf41a35302c9febd1ec22473e966
Add code/analyse_chain_growth.py
code/analyse_chain_growth.py
code/analyse_chain_growth.py
#!/usr/bin/env python import sys import os import os.path import argparse parser = argparse.ArgumentParser() parser.add_argument('dirs', type=str, nargs='+', help='directories containing simulation files') parser.add_argument('--rate', type=float, default=0.1) parser.add_argument('--sites', type=...
Python
0.000111
bd15388aa877f32ebc613511ad909b311ed3bcf0
Add tests
sympy/concrete/tests/test_dispersion.py
sympy/concrete/tests/test_dispersion.py
from sympy.core import Symbol, S, oo from sympy.concrete.dispersion import * def test_dispersion(): x = Symbol("x") fp = S(0).as_poly(x) assert sorted(dispersionset(fp)) == [0] fp = S(2).as_poly(x) assert sorted(dispersionset(fp)) == [0] fp = (x + 1).as_poly(x) assert sorted(dispersions...
Python
0.000001
6ed3b62efe24aa8aeaedd314bb4e472628713bac
Create deft_opportunist.py
tpdatasrc/tpgamefiles/scr/tpModifiers/deft_opportunist.py
tpdatasrc/tpgamefiles/scr/tpModifiers/deft_opportunist.py
#Deft Opportunist: Complete Adventurer, p. 106 from templeplus.pymod import PythonModifier from toee import * import tpdp print "Registering Deft Opportunist" def DOAOO(attachee, args, evt_obj): if attachee.has_feat("Deft Opportunist") != 0: #Check if it's an AOO, if so add 4 to the Attack Roll if evt_obj.att...
Python
0.001698
52f8daf63644fde1efd1c132d6b02ac6670ef0a4
Add migrations merge
temba/channels/migrations/0038_merge.py
temba/channels/migrations/0038_merge.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('channels', '0037_auto_20160905_1537'), ('channels', '0033_auto_20160623_1438'), ] operations = [ ]
Python
0.000001
1b538aba890c8a81fc7bf66f2c35519608fbd6be
Create drivers.py
chips/analog/mock/drivers.py
chips/analog/mock/drivers.py
# This code has to be added to the corresponding __init__.py DRIVERS["analogmock"] = ["ANALOG", "PUUM"]
Python
0.000001
528de5a29d7beb743e5e80775a349f931e71262f
add test that triggers previous error
test/workflows/test_base.py
test/workflows/test_base.py
import json import fmriprep.workflows.base as base import re import unittest import mock class TestBase(unittest.TestCase): def test_fmri_preprocess_single(self): ''' Tests that it runs without errors ''' # NOT a test for correctness # SET UP INPUTS test_settings = { 'o...
Python
0
0e02a9de3599e726b5a4dffd17f92a0cd0d2aaee
add import script for Wyre
polling_stations/apps/data_collection/management/commands/import_wyre.py
polling_stations/apps/data_collection/management/commands/import_wyre.py
from data_collection.management.commands import BaseXpressWebLookupCsvImporter class Command(BaseXpressWebLookupCsvImporter): council_id = 'E07000128' addresses_name = 'WyrePropertyPostCodePollingStationWebLookup-2017-03-08 2.CSV' stations_name = 'WyrePropertyPostCodePollingStationWebLookup-2017-03...
Python
0
4e9ecd13cedc069e53e6acc941f643ad0f8cf6b0
fix cleanup command
corehq/apps/callcenter/management/commands/remove_callcenter_form_data.py
corehq/apps/callcenter/management/commands/remove_callcenter_form_data.py
from __future__ import print_function from optparse import make_option from django.core.management.base import BaseCommand from sqlalchemy.engine import create_engine from sqlalchemy.orm.session import sessionmaker from corehq.apps.callcenter.utils import get_call_center_domains, get_or_create_mapping from ctable.model...
from __future__ import print_function from optparse import make_option from django.core.management.base import BaseCommand from sqlalchemy.engine import create_engine from sqlalchemy.orm.session import sessionmaker from corehq.apps.callcenter.utils import get_call_center_domains, get_or_create_mapping from ctable.model...
Python
0.000006
b14fb988321076f4cf17cebec7635fd209e08465
Create video.py
client/video.py
client/video.py
# Capture video with OpenCV import numpy as np import cv2 import time cap = cv2.VideoCapture('serenity.mp4') while(cap.isOpened()): ret, frame = cap.read() # time.sleep(.25) cv2.rectangle(frame,(384,0),(510,128),(0,255,0),3) cv2.imshow('frame',frame) if cv2.waitKey(5) & 0xFF == ord('q'): break ...
Python
0.000001
18a356c9fa49f32627481f312b03aa34ff711456
Revert "Define the tests as grpc_cc_test to automatically test against all po…"
test/core/bad_client/generate_tests.bzl
test/core/bad_client/generate_tests.bzl
#!/usr/bin/env python2.7 # Copyright 2015 gRPC 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 la...
#!/usr/bin/env python2.7 # Copyright 2015 gRPC 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 la...
Python
0
59ac83e45116a97cfbdd7522f967337e73d51766
add cargo deny test
tests/integration_tests/build/test_dependencies.py
tests/integration_tests/build/test_dependencies.py
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 """Enforces controls over dependencies.""" import os import framework.utils as utils def test_licenses(): """Ensure license compatibility for Firecracker. For a list of currently allowed licenses ...
Python
0
b03078362d171854a7438c335821363e4010a7db
add Expect_Geometry_Not_to_Overlap (#4642)
contrib/experimental/great_expectations_experimental/expectations/expect_column_values_geometry_not_to_overlap.py
contrib/experimental/great_expectations_experimental/expectations/expect_column_values_geometry_not_to_overlap.py
import json from typing import Optional import geopandas import numpy as np import rtree from shapely.geometry import LineString, Point, Polygon from great_expectations.core.expectation_configuration import ExpectationConfiguration from great_expectations.exceptions import InvalidExpectationConfigurationError from gr...
Python
0
c3f01d8b365e6d367b1a565e5ce59cf04eb1bac3
fix build
get_version.py
get_version.py
"""Return the short version string.""" from mpfmonitor._version import __short_version__ print("{}.x".format(__short_version__))
Python
0.000001
15d3692aee84432b6b7f8306505b3f59649fd6f9
Remove mimetype from the module_files table
cnxarchive/sql/migrations/20160128111115_mimetype_removal_from_module_files.py
cnxarchive/sql/migrations/20160128111115_mimetype_removal_from_module_files.py
# -*- coding: utf-8 -*- """\ - Move the mimetype value from ``module_files`` to ``files``. - Remove the ``mimetype`` column from the ``module_files`` table. """ from __future__ import print_function import sys def up(cursor): # Move the mimetype value from ``module_files`` to ``files``. cursor.execute("UPDAT...
Python
0.000001
67b5cd3f00ca57c4251dab65c5a6e15ab2be8a42
Create result.py
aiorucaptcha/result.py
aiorucaptcha/result.py
class ResultObject: def __init__(self, code, task_id): self.code = code self.task_id = task_id def __str__(self): return self.code
Python
0.000002
4a7a15359763cbd6956bd30bde7cd68b05b2b4a2
test _compare_and_pop_smallest
tests/test_huffman_codes.py
tests/test_huffman_codes.py
import sys import os sys.path.append(os.path.abspath(os.path.dirname(__file__) + '../..')) import unittest from huffman_codes import huffman_codes, Node, Queue, _compare_and_pop_smallest, \ _traverse_children_and_assign_codes class TestHuffmanCodes(unittest.TestCase): def test_compare_an...
Python
0.00006
43d3158e536b7cae3f427f655b08aa8b4c24fe96
Add an iter_entry_points style test
tests/test_spicedham_api.py
tests/test_spicedham_api.py
from unittest import TestCase from spicedham import Spicedham from mock import Mock, patch class TestSpicedHamAPI(TestCase): @patch('spicedham.Spicedham._classifier_plugins') def test_classify(self, mock_plugins): sh = Spicedham() plugin0 = Mock() plugin0.classify.return_value = .5 ...
Python
0
ba49a66b401bc32e57abede6adc5a0f933e8834a
Add tests for view helpers
tests/test_views_helpers.py
tests/test_views_helpers.py
from django.test import RequestFactory from django_cas_ng.views import ( _service_url, _redirect_url, _login_url, _logout_url, ) # # _service_url tests # def test_service_url_helper(): factory = RequestFactory() request = factory.get('/login/') actual = _service_url(request) expected...
Python
0
3f84a3cb50e18ce9df96a9173d0be180633aad0d
Add polynomial learning example
Examples/polynomial_approximation.py
Examples/polynomial_approximation.py
""" Example of neural network learning a polynomial equation. Test polynomial is f(x) = (6x^2 + 3x) ÷ (3x) Training is run on x values from 1.0 to 100.0 """ from mazex import MazeX import numpy as np import random import math import matplotlib.pyplot as plt # Create list to store how close networks guesses are graph_...
Python
0.01065
abe40e3c82ef1f351275a59b2e537f43530caa0c
Clean up db script (remove articles older than two days).
app/cleanup_stories.py
app/cleanup_stories.py
from pymongo import MongoClient from fetch_stories import get_mongo_client, close_mongo_client from bson import ObjectId from datetime import datetime, timedelta def remove_old_stories(): client = get_mongo_client() db = client.get_default_database() article_collection = db['articles'] two_days_ag...
Python
0
4bc3d5fb8197502c6eaddc055babd9ce679909bd
Move make_topicspace.py to outer folder.
make_topicspace.py
make_topicspace.py
import os, sys, logging, scipy, joblib import math import argparse from toolset.corpus import Corpus from gensim import corpora, models, matutils from sklearn.cluster import MiniBatchKMeans as mbk from toolset import mogreltk def make_topicspace(data_file_path, stopwords_file_path=None, n_topics=...
Python
0
ba590d28810409fa57783e6d29a651790f865e5c
create base api exceptions module
apps/api/exceptions.py
apps/api/exceptions.py
import json from tastypie.exceptions import TastypieError from tastypie.http import HttpResponse class CustomBadRequest(TastypieError): """ This exception is used to interrupt the flow of processing to immediately return a custom HttpResponse. """ def __init__(self, success=False, code="", messa...
Python
0