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
6f7fd163106ec5f4346eaaef04ed9726a3289801
add wrong reversesubstring problem solution
problems/reversesubstring.py
problems/reversesubstring.py
import sys test = "aabbbbababaaabbab" """ Find a) the first occurrence of b in string b) the longest list of only as in string, store final index """ def solution(string): firstB = string.find('b') print ((string, firstB)) if(firstB == -1): return (0, 0) longestA = 0 longestAIndex = ...
Python
0.995257
9ff1b6ffa297199dc73042382c369fc7af0813fc
Create stress_test1.py
home/moz4r/Test/stress_test1.py
home/moz4r/Test/stress_test1.py
# stress test from time import sleep import random leftPort = "COM3" i01 = Runtime.createAndStart("i01", "InMoov") sleep(1) i01.startMouth() i01.startHead(leftPort) i01.startLeftHand(leftPort) i01.head.jaw.map(0,180,85,110) i01.startMouthControl(leftPort) i01.leftHand.thumb.setVelocity(random.randint(100,300)) M...
Python
0.000033
a183922bd275414259800e75fd78db980604fa20
create thread3
threading/thread3_join.py
threading/thread3_join.py
import threading import time def thread_job(): print('T1 start\n') for i in range(10): time.sleep(0.1) print('T1 finish\n') def T2_job(): print('T2 start\n') print('T2 finish\n') def main(): added_thread = threading.Thread(target=thread_job, name='T1') thread2 = threading.Thread(ta...
Python
0
143dbdb6d0d9840c4991eadbb2f5459398a6ddae
Add a 'cache' which only caches ETOPO1 files.
joerd/store/cache.py
joerd/store/cache.py
from joerd.mkdir_p import mkdir_p from joerd.plugin import plugin from os import link import os.path class CacheStore(object): """ Every tile that gets generated requires ETOPO1. Rather than re-download it every time (it's 446MB), we cache that file only. This is a bit of a hack, and would be better ...
Python
0
679ae2966f44a071630934c7b7d9eeb550a59223
Create balance_array.py
balance_array.py
balance_array.py
''' `Balance Array` Find i in array A where: A[1] + A[2]...A[i-1] = A[i+1] + A[i+2]...A[len(A)] Write a `balanceSum` function which take an integer array as input, it should return the smallest i, where i is an index in the array such that the sum of elements to its left is equal to the sum of elements to its right. ...
Python
0.000521
19dd8b925b188bc09eb85952db1f9f11db4c570e
add batch pics
batch_cut_pic.py
batch_cut_pic.py
#!/usr/bin/env python # -*- coding: utf-8 -*- #function: 剪切更改图片尺寸大小 import os import os.path import sys, getopt, argparse from PIL import Image from change_pic_size_by_cut import CutImage def main(): argc = len(sys.argv) cmdargs = str(sys.argv) parser = argparse.ArgumentParser(description="Tool for batch cut the ...
Python
0
41933fa83138f3572b899839a721b95b877d09e6
Sample code for create customer payment profile
CustomerProfiles/create-customer-payment-profile.py
CustomerProfiles/create-customer-payment-profile.py
from authorizenet import apicontractsv1 from authorizenet.apicontrollers import * merchantAuth = apicontractsv1.merchantAuthenticationType() merchantAuth.name = '5KP3u95bQpv' merchantAuth.transactionKey = '4Ktq966gC55GAX7S' creditCard = apicontractsv1.creditCardType() creditCard.cardNumber = "4111111111111111" credit...
Python
0.996976
a4c71bcefa255e3f2ec4fcbcd77e614669190250
Set up change set delta lambda
cd/lambdas/change-set-delta-notification/lambda_function.py
cd/lambdas/change-set-delta-notification/lambda_function.py
# Invoked by: CodePipeline # Returns: Error or status message # # Published messages about deltas between a CloudFormation stack change set and # the current version of the stack. The stack parameter values for both the # stack and change set are queried, compared, and the differences are sent as a # message to the Sla...
Python
0.000001
f36a0d1d53b4a15d8ead51a54260946f293a8718
add mac free memory script
mac_free.py
mac_free.py
#!/usr/bin/python ''' Created on Jun 1, 2014 @author: jay ''' import subprocess import re # Get process info ps = subprocess.Popen(['ps', '-caxm', '-orss,comm'], stdout=subprocess.PIPE).communicate()[0] vm = subprocess.Popen(['vm_stat'], stdout=subprocess.PIPE).communicate()[0] # Iterate processes processLines ...
Python
0
27921a107ef0e6a88755ae897998cab0095cf039
Create mafengwo.py
mafengwo.py
mafengwo.py
# -*- coding: utf-8 -*- import urllib import urllib2 import re from platform import python_version class HtmlTools: BngCharToNoneRex = re.compile(r'(\t|\n| |<a.*?>|<img.*?>)') EndCharToNoneRex = re.compile(r'<.*?>') BngPartRex = re.compile(r'<p.*?>') CharToNewLineRex = re.compile(r'(<br/>|</p>|)<tr>|</?div>') Cha...
Python
0.000003
d9be75200af8c63a4457b6fb6ee107f4e8aa1048
Create medium_BinaryConverter.py
medium_BinaryConverter.py
medium_BinaryConverter.py
""" Convert from binary string to integer """ def BinaryConverter(str): return int(str,2) print BinaryConverter(raw_input())
Python
0.000001
73cfd55b6db4e8623ff7c5f8d0df7433e694f8c4
Split dottable-dict logic into separate class.
metadatastore/document.py
metadatastore/document.py
import six import mongoengine from mongoengine.base.datastructures import BaseDict, BaseList from mongoengine.base.document import BaseDocument from bson.objectid import ObjectId from datetime import datetime from itertools import chain from collections import MutableMapping def _normalize(in_val): """ Helper...
import six import mongoengine from mongoengine.base.datastructures import BaseDict, BaseList from mongoengine.base.document import BaseDocument from bson.objectid import ObjectId from datetime import datetime from itertools import chain from collections import MutableMapping def _normalize(in_val): """ Helper...
Python
0
b9034ca499ae8c0366ac8cd5ee71641f39c0ffba
Add taxonomy model and initiation
website/project/taxonomies/__init__.py
website/project/taxonomies/__init__.py
import json import os from website import settings from modularodm import fields, Q from modularodm.exceptions import NoResultsFound from framework.mongo import ( ObjectId, StoredObject, utils as mongo_utils ) @mongo_utils.unique_on(['id', '_id']) class Subject(StoredObject): _id = fields.StringFie...
Python
0.000001
e747714e16250f3c2e85d09520f36953b1c417c3
Create HeapSort.py
Algorithms/Sort_Algorithms/Heap_Sort/HeapSort.py
Algorithms/Sort_Algorithms/Heap_Sort/HeapSort.py
# Python program for implementation of heap Sort # To heapify subtree rooted at index i. # n is size of heap def heapify(arr, n, i): largest = i # Initialize largest as root l = 2 * i + 1 # left = 2*i + 1 r = 2 * i + 2 # right = 2*i + 2 # See if left child of root exists and is # greate...
Python
0.000001
5c0730d7caef6503e3f97849d9df6825c289e9a0
Fix check for valid emoji.
zerver/views/reactions.py
zerver/views/reactions.py
from __future__ import absolute_import from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ from typing import Text from zerver.decorator import authenticated_json_post_view,\ has_request_variables, REQ, to_non_negative_int from zerver.lib.actions import do_add_reac...
from __future__ import absolute_import from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ from typing import Text from zerver.decorator import authenticated_json_post_view,\ has_request_variables, REQ, to_non_negative_int from zerver.lib.actions import do_add_reac...
Python
0.000062
122f24b24f16ab9ece5707919255371002929e8d
ADD RegisterTensorService
apps/domain/src/main/core/services/tensor_service.py
apps/domain/src/main/core/services/tensor_service.py
# stdlib import secrets from typing import List from typing import Type from typing import Union # third party from nacl.signing import VerifyKey # syft relative from syft.core.node.abstract.node import AbstractNode from syft.core.node.common.service.auth import service_auth from syft.core.node.common.service.node_se...
Python
0
17fcfd6d1962b23429d48a8a45dfb0944c2f1453
Add constraints.py
conference_scheduler/constraints.py
conference_scheduler/constraints.py
from typing import Callable, List, Dict class Constraint(NamedTuple): function: Callable args: List kwargs: Dict operator: Callable value: int
Python
0.000003
e9efb5e2ba19fcda77e35d0efdaa03b13d025df0
create model of a feature
devmine/app/models/feature.py
devmine/app/models/feature.py
from sqlalchemy import ( Column, Integer, String ) from devmine.app.models import Base class Feature(Base): """Model of a feature.""" __tablename__ = 'features' id = Column(Integer, primary_key=True) name = Column(String, nullable=False, unique=True) def __init__(self): pas...
Python
0.000001
7491f500c75850c094158b4621fdef602bce3d27
Add benchmarks for custom generators
benchmarks/benchmarks/benchmark_custom_generators.py
benchmarks/benchmarks/benchmark_custom_generators.py
from tohu.v6.primitive_generators import Integer, HashDigest, FakerGenerator from tohu.v6.derived_generators import Apply, Lookup, SelectOne, SelectMultiple from tohu.v6.custom_generator import CustomGenerator from .common import NUM_PARAMS mapping = { 'A': ['a', 'aa', 'aaa', 'aaaa', 'aaaaa'], 'B': ['b', 'bb...
Python
0
63d45b975d33227b65e79644622773a49dd7ccc6
Add new package: libxcrypt (#18783)
var/spack/repos/builtin/packages/libxcrypt/package.py
var/spack/repos/builtin/packages/libxcrypt/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 Libxcrypt(AutotoolsPackage): """libxcrypt is a modern library for one-way hashing of passw...
Python
0
465b83e394c2bb90a85580946e291d0249fc754e
Fix model fields label
apps/accounts/migrations/0005_auto_20160101_1840.py
apps/accounts/migrations/0005_auto_20160101_1840.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('accounts', '0004_auto_20151227_1553'), ] operations = [ migrations.AlterField( model_name='userprofile', ...
Python
0.000001
6c599caaf8a4daadfe287898901cad54fda37875
add Post model
XdaPy/model/post.py
XdaPy/model/post.py
# Copyright (C) 2014 cybojenix <anthonydking@slimroms.net> # # This file is part of XdaPy. # # XdaPy 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 l...
Python
0
698e46f7842e16124235365a180ddee7532d11ff
Create 2017-02-20-fundamentaltheoremofarithmetic.py
_posts/2017-02-20-fundamentaltheoremofarithmetic.py
_posts/2017-02-20-fundamentaltheoremofarithmetic.py
#Fundamental theorem of arithmetic states that:every positive integer greater #than one can be expressed as unique product of primes.for ex,90=2*3*3*5 #Following is an application of above theorem def primefactors(n): i=0 factors=[] #here primelist is list of all primes of a given no p=primelist[i] whil...
Python
0.000001
201ca88243bf8d0736c5f61b64abeacba82e7da7
Add memory.py
bandit/memory.py
bandit/memory.py
import numpy as np class Memory(object): """ This is a memory saver for contextual bandit """ def __init__(self): pass
Python
0.000065
d720f0a50dce424ddbb319fd8cd518cc7adb3a1f
Add LBlock impementation
lblockSimple.py
lblockSimple.py
#!/usr/bin/env python3 """ POC implementation of LBlock Cipher (http://eprint.iacr.org/2011/345.pdf) """ s0 = [14, 9, 15, 0, 13, 4, 10, 11, 1, 2, 8, 3, 7, 6, 12, 5] s1 = [4, 11, 14, 9, 15, 13, 0, 10, 7, 12, 5, 6, 2, 8, 1, 3] s2 = [1, 14, 7, 12, 15, 13, 0, 6, 11, 5, 9, 3, 2, 4, 8, 10] s3 = [7, 6, 8, 11, 0, 15, 3, 14, ...
Python
0.000001
f72af94f29a1797f9f23dbfe3431ec66ff36e6b4
add example
examples/py/wazirx-create-cancel-orders.py
examples/py/wazirx-create-cancel-orders.py
# -*- coding: utf-8 -*- import os import sys from pprint import pprint root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.append(root + '/python') import ccxt # noqa: E402 print('CCXT Version:', ccxt.__version__) exchange = ccxt.wazirx({ 'enableRateLimit': True, ...
Python
0.000002
48eb4604673513b771b6def05a1652ae1b66d4d0
Add a script for storing a config variable
scripts/add_ssm_config.py
scripts/add_ssm_config.py
#!/usr/bin/env python # -*- encoding: utf-8 """ Store a config variable in SSM under the key structure /{project_id}/config/{label}/{config_key} This script can store a regular config key (unencrypted) or an encrypted key. """ import sys import boto3 import click ssm_client = boto3.client("ssm") @click.com...
Python
0.000003
e85c07cfe614813180d9795e1fa4deda00e6b84e
add manual replication script my Max Dornseif
couchdb/tools/manual_replication.py
couchdb/tools/manual_replication.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2009 Maximillian Dornseif <md@hudora.de> # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. """ This script replicates databases from one CouchDB server to an other. This is mainly f...
Python
0
cd38a1a8845ade346f4532fa944f58dde4a64a27
add multiple wr port config for RegisterFile
new_pmlib/RegisterFile.py
new_pmlib/RegisterFile.py
#======================================================================= # RegisterFile.py #======================================================================= from new_pymtl import * #======================================================================= # RegisterFile #=========================================...
#======================================================================= # RegisterFile.py #======================================================================= from new_pymtl import * #======================================================================= # RegisterFile #=========================================...
Python
0
1e4deb7bb91a66ce1bc20c7201a5053d7b5659fd
Move module loader to python logging
module_loader.py
module_loader.py
# # This file is part of Plinth. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero 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 distribute...
# # This file is part of Plinth. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero 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 distribute...
Python
0.000001
cf469dcba17d3a93bd4bb1651fff6a22de4bc5ba
add code to access database
louis-html-analyzer/database.py
louis-html-analyzer/database.py
import MySQLdb class database: def __init__(self, hostName="localhost", userName="root", password="", database="wbm"): self.db = MySQLdb.connect(host = hostName, user = userName, passwd = password, db = database) self.db.autocommit(True) self.cur = self.db....
Python
0.000001
97f66afad570e068d8585700121a3cbf6afa59b9
Add UtfGridComposite that can composite UtfGrid tiles (MapnikGrid)
TileStache/Goodies/Providers/UtfGridComposite.py
TileStache/Goodies/Providers/UtfGridComposite.py
""" Composite Provider for UTFGrid layers https://github.com/mapbox/mbtiles-spec/blob/master/1.1/utfgrid.md Combines multiple UTFGrid layers to create a single result. The given layers will be added to the result in the order they are given. Therefore the last one will have the highest priority. Sample configuration:...
Python
0
4158b54244cda38b5643f07d9ad825877c7ff2d7
Make subset module callable
Lib/fontTools/subset/__main__.py
Lib/fontTools/subset/__main__.py
from __future__ import print_function, division, absolute_import from fontTools.misc.py23 import * from fontTools.subset import main main()
Python
0.000013
e5b891f6cc2d1e2d362038df90fa42d2e8fb1133
Create derpderpderp.py
derpderpderp.py
derpderpderp.py
import psycopg2 class DataSource: def __init__(self): psw = 'meow372pony' dbn = 'luoj' usn = 'luoj' comm = psycopg2.connect(database = dbn, user=usn, password=psw) self.cursor = comm.cursor() self.mainDatabaseName = 'majorcounts' self.major...
Python
0.000002
bdfa3e67606e3bae243a64ad1e502edf552d2fdf
add problem 17
euler017.py
euler017.py
#!/usr/bin/env python # this barely works, but does output correct words up to 1000 def num2words(n): onesteens = { 1 : "one", 2 : "two", 3 : "three", 4 : "four", 5 : "five", 6 : "six", 7 : "seven", 8 : ...
Python
0.00153
50dded21e316b6b8e6cb7800b17ed7bd92624946
Add toy example of reading a large XML file
xml_to_json.py
xml_to_json.py
#!/usr/bin/env python import xml.etree.cElementTree as ET from sys import argv input_file = argv[1] NAMESPACE = "{http://www.mediawiki.org/xml/export-0.10/}" with open(input_file) as open_file: in_page = False for _, elem in ET.iterparse(open_file): # Pull out each revision if elem.tag == NA...
Python
0
d1178f9d6467ccf8fd9681ad5ef47614ab80882e
Add new command to check blobs logged missing
corehq/blobs/management/commands/check_blob_logs.py
corehq/blobs/management/commands/check_blob_logs.py
import json import logging import casexml.apps.case.models as cases import couchforms.models as xform from couchdbkit.exceptions import ResourceNotFound from couchexport.models import SavedBasicExport from django.core.management import BaseCommand, CommandError import corehq.apps.app_manager.models as apps from coreh...
Python
0
8176e8784247262d32e1adad5f86b181c1a202ca
Test echo sql
airflow/settings.py
airflow/settings.py
import logging import os import sys from sqlalchemy.orm import scoped_session, sessionmaker from sqlalchemy import create_engine from airflow.configuration import conf HEADER = """\ ____________ _____________ ____ |__( )_________ __/__ /________ __ ____ /| |_ /__ ___/_ /_ __ /_ __ \_ | /| / ...
import logging import os import sys from sqlalchemy.orm import scoped_session, sessionmaker from sqlalchemy import create_engine from airflow.configuration import conf HEADER = """\ ____________ _____________ ____ |__( )_________ __/__ /________ __ ____ /| |_ /__ ___/_ /_ __ /_ __ \_ | /| / ...
Python
0.000022
17558f8f494627c287262ac2d5151d99fb9303e2
Create getrekthagin.py
getrekthagin.py
getrekthagin.py
Python
0
ab7324ba674038dde4581bcb5645c1dd828aa31f
Add seatgeek spider code.
crawler/crawling/spiders/seatgeek_spider_example.py
crawler/crawling/spiders/seatgeek_spider_example.py
import scrapy from scrapy.http import Request from lxmlhtml import CustomLxmlLinkExtractor as LinkExtractor from scrapy.conf import settings from crawling.items import RawResponseItem from redis_spider import RedisSpider class SeatGeekSpider(RedisSpider): ''' A spider that walks all links from the requested...
Python
0
70815d8ac3ff8648b5db9ad6e38b1eb3be6fd0cb
Create examples.py
examples.py
examples.py
import pandas as pd
Python
0
86658f310d0c6579c706bce1013e08a42d507609
Fix for multiple camera switches naming of entity (#14028)
homeassistant/components/switch/amcrest.py
homeassistant/components/switch/amcrest.py
""" Support for toggling Amcrest IP camera settings. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/switch.amcrest/ """ import asyncio import logging from homeassistant.components.amcrest import DATA_AMCREST, SWITCHES from homeassistant.const import ( ...
""" Support for toggling Amcrest IP camera settings. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/switch.amcrest/ """ import asyncio import logging from homeassistant.components.amcrest import DATA_AMCREST, SWITCHES from homeassistant.const import ( ...
Python
0.000001
e0acea07d77d86313ee2436cdfc96a6258c1991c
Add admin for MembershipPersonRole
amy/fiscal/admin.py
amy/fiscal/admin.py
from django.contrib import admin from fiscal.models import MembershipPersonRole class MembershipPersonRoleAdmin(admin.ModelAdmin): list_display = ("name", "verbose_name") search_fields = ("name", "verbose_name") admin.site.register(MembershipPersonRole, MembershipPersonRoleAdmin)
Python
0
71e66eaebab2dcb6f37ab6c1409bdd357b60db68
Add create-DB script
createDb.py
createDb.py
from ummbNet import * db.create_all()
Python
0.000001
6b0f13d9d5a067c116a2f2b17381eadf322dd05b
Add more tests
tests/test_evaluation/test_TopListEvaluator.py
tests/test_evaluation/test_TopListEvaluator.py
from nose.tools import assert_equal, assert_greater from otdet.evaluation import TopListEvaluator class TestAddResult: def setUp(self): self.sample_result = [(5.0, True), (4.0, False), (3.0, True), (2.0, False), (1.0, False)] self.M = len(self.sample_result) ...
Python
0
60b01719e5780f9adb2cc25e3da60201822bb966
Add SAT object code
SATObject.py
SATObject.py
# # SAT object that will have work done onto class SATObject(object): """ """ # SATObject has only a list of variables (for refrence) and a clause list def __init__(self): # Dictionary in case variable is greater than total number of variables self.varDict = {} # List of clause...
Python
0
0a42c1144fbd7f89914aad2f05f7f1fba7aa3890
Add cuds tests
simphony/cuds/tests/test_cuds.py
simphony/cuds/tests/test_cuds.py
"""Tests for CUDS data structure.""" import unittest import uuid from simphony import CUDS from simphony.cuds.particles import Particle, Particles class CUDSTestCase(unittest.TestCase): """CUDS class tests.""" def setUp(self): self.cuds = CUDS() # TODO: use generated components class...
Python
0
63f9f87a3f04cb03c1e286cc5b6d49306f90e352
Add solution for problem 4
python/004_largest_palindrome_product/palindrome_product.py
python/004_largest_palindrome_product/palindrome_product.py
from itertools import combinations_with_replacement from operator import mul three_digit_numbers = tuple(range(100, 1000)) combinations = combinations_with_replacement(three_digit_numbers, 2) products = [mul(*x) for x in combinations] max_palindrome = max([x for x in products if str(x)[::-1] == str(x)])
Python
0.001666
43e9e18b9ebaf5318d742d9347e94a6a483ec5ff
add the log-likelihood to the ridge regression function.
scikits/learn/bayes/bayes.py
scikits/learn/bayes/bayes.py
import numpy as np import scipy.linalg def fast_logdet(A): """ Compute log(det(A)) for A symmetric Equivalent to : np.log(nl.det(A)) but more robust It returns -Inf if det(A) is non positive Copyright : A. Gramfort 2010 """ from math import exp,log ld = np.sum(np.log(np.diag(A))...
import numpy as np import scipy.linalg def bayesian_ridge( X , Y, step_th=300,th_w = 1.e-6, verbose = True) : """ Bayesian ridge regression. Optimize the regularization parameter alpha within a simple bayesian framework (MAP). Notes ----- See Bishop p 345-348 for more details. Parameters ...
Python
0.999999
634d703f207d81f817c5bd834e6695d6a439e9a8
fix ImportError with pytest.mark.tf2 (#6050)
python/chronos/test/bigdl/chronos/forecaster/tf/__init__.py
python/chronos/test/bigdl/chronos/forecaster/tf/__init__.py
# # Copyright 2016 The BigDL 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 law or agreed to in ...
Python
0
186442a5b50e760f0a3c814cb272c909606ad91a
Create find_factors_down_to_limit.py
find_factors_down_to_limit.py
find_factors_down_to_limit.py
#Kunal Gautam #Codewars : @Kunalpod #Problem name: Find Factors Down to Limit #Problem level: 8 kyu def factors(integer, limit): return [x for x in range(limit,(integer//2)+1) if not integer%x] + ([integer] if integer>=limit else [])
Python
0.000022
aeeb0e6819439db84f3f7e16ac3f85fd36441315
add unit test
stomp/test/utils_test.py
stomp/test/utils_test.py
import unittest from stomp.utils import * class TestUtils(unittest.TestCase): def testReturnsTrueWhenLocalhost(self): self.assertEquals(1, is_localhost(('localhost', 8000))) self.assertEquals(1, is_localhost(('127.0.0.1', 8000))) self.assertEquals(2, is_localhost(('192.168.1.92', 8000)))
Python
0.000001
e9e06a0b85656eb8ce70aff1ac81737a7ffaece3
Add migration for extended feedback; #909
judge/migrations/0083_extended_feedback.py
judge/migrations/0083_extended_feedback.py
# -*- coding: utf-8 -*- # Generated by Django 1.11.15 on 2019-03-15 23:18 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('judge', '0082_remove_profile_name'), ] operations = [ migrations.AddField(...
Python
0
d410fb26d3fb8bbd843234e90891bee5a5fff7e7
Add local dev settings module
halaqat/settings/local_settings.py
halaqat/settings/local_settings.py
from .base_settings import * DEBUG = True LANGUAGE_CODE = 'en' TIME_FORMAT = [ '%I:%M %p', '%H:%M %p', ] TIME_INPUT_FORMATS = [ '%I:%M %p', '%H:%M %p' ]
Python
0
ce6c7a9e474c876829597861ce35b797b2509d42
Add conftest.py for pytest
conftest.py
conftest.py
# This file must exist for pytest to add this directory to `sys.path`.
Python
0.000007
cca26b50f02f098d3157501bd64e9f990fc061e2
Create solution.py
leetcode/easy/valid_anagram/py/solution.py
leetcode/easy/valid_anagram/py/solution.py
# # Anagram definition: # https://en.wikipedia.org/wiki/Anagram # # Classic solution to the anagram problem. # Sort both strings and check if they are equal. # class Solution(object): def isAnagram(self, s, t): """ :type s: str :type t: str :rtype: bool """ return ...
Python
0.000018
477a57b108499184acb4d74f7aa14b7a8e10f6d8
Create naturalreaderspeech-test.py
home/CheekyMonkey/naturalreaderspeech-test.py
home/CheekyMonkey/naturalreaderspeech-test.py
# cycle through NaturalReaderSpeech voices # with i2c connected jaw servo # Author: Acapulco Rolf # Date: October 4th 2017 # Build: myrobotlab development build version 2555 from time import sleep from org.myrobotlab.service import Speech lang="EN" #for NaturalReaderSpeech Voice="Ryan" voiceType = Voice speech = Run...
Python
0.000018
2875ee60f30ca47a8dc957250125be505e5aee07
Add build script
build.py
build.py
#!/usr/bin/env python3 # Copyright (c) 2014, Ruslan Baratov # All rights reserved. import argparse import os import re import shutil import subprocess import sys parser = argparse.ArgumentParser(description="Script for building") parser.add_argument( '--toolchain', choices=[ 'libcxx', 'xcode'...
Python
0.000001
53dcffd4677987e6186182484e58fccde1e93d60
change file name
h2o-py/test_hadoop/pyunit_hadoop.py
h2o-py/test_hadoop/pyunit_hadoop.py
import sys sys.path.insert(1,"../") import h2o from tests import pyunit_utils from h2o.estimators.glm import H2OGeneralizedLinearEstimator import os def test_hadoop(): ''' Test H2O read and write to hdfs ''' hdfs_name_node = os.getenv("NAME_NODE") h2o_data = h2o.import_file("hdfs://" + hdfs_name_n...
Python
0.000008
8edf8bbd341c8b3e8395784667da5c577aba7ac6
Add betting.py program
ibm-ponder-this/2015-05/betting.py
ibm-ponder-this/2015-05/betting.py
from __future__ import print_function import itertools import collections import sys class BettingGame(object): def __init__(self, max_value=256, num_players=3): self.max_value = max_value self.num_players = num_players self.STOP_STATE = tuple(0 for i in xrange(self.num_players)) def ...
Python
0.000001
61822398dbd2a3819a15b8c33f1cd69ff2953b5a
Move animation.fill from BiblioPixelAnimation
bibliopixel/animation/fill.py
bibliopixel/animation/fill.py
from . animation import BaseAnimation from .. util import colors class Fill(BaseAnimation): """ Fill the screen with a single color. """ def __init__(self, *args, color='black', **kwds): super().__init__(*args, preclear=False, **kwds) is_numpy = hasattr(self.color_list, 'dtype') ...
Python
0
eb49c28b790bbf6ce6042f657beaf328a9e6b33f
Add inline sources
arx/sources/inline.py
arx/sources/inline.py
from collections import Container, Mapping, OrderedDict, Sequence import math from sh import chmod, Command, mkdir, tar from ..err import Err from ..decorators import signature from . import onepath, Source, twopaths class Inline(Source): @onepath def cache(self, cache): """Caching for inline source...
Python
0.000001
38651a6f690e39f5d5f64cdd389b031d653dcf95
add migration for credit app status
src/wellsfargo/migrations/0028_auto_20190401_1213.py
src/wellsfargo/migrations/0028_auto_20190401_1213.py
# Generated by Django 2.2 on 2019-04-01 16:13 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('wellsfargo', '0027_auto_20190208_1635'), ] operations = [ migrations.AlterField( model_name='cacreditapp', name='statu...
Python
0
0cfb4591a7754bcc08edddd17629006b5096d94d
Add handler for /sync API
synapse/handlers/sync.py
synapse/handlers/sync.py
import collections SyncConfig = collections.namedtuple("SyncConfig", [ "user", "device", "since", "limit", "gap", "sort" "backfill" "filter", ) RoomSyncResult = collections.namedtuple("RoomSyncResult", [ "room_id", "limited", "published", "prev_batch", "events", ...
Python
0.000001
954b6d2152df52c330d59fe2b3b1cf65f5dd22cf
Create Str2Int_001.py
leetcode/008-String-to-Integer/Str2Int_001.py
leetcode/008-String-to-Integer/Str2Int_001.py
#@author: cchen #Terrible code, and it will be updated and simplified later. class Solution: # @param {string} str # @return {integer} def extractnum(self, ss): num = 0 for i in range(len(ss)): if ss[i].isdigit() == False: break else: ...
Python
0.000334
af6fb23f87651d5cdce3730d2cf2f2b10b571837
test script for ngram matrix creation
dsl/features/create_ngram_matrix.py
dsl/features/create_ngram_matrix.py
from sys import argv from featurize import Tokenizer, Featurizer def main(): N = int(argv[1]) if len(argv) > 1 else 3 t = Tokenizer() f = Featurizer(t, N=N) docs = f.featurize_in_directory(argv[2]) m = f.to_dok_matrix(docs) print m.shape if __name__ == '__main__': main()
Python
0
15ff98ef08fd45354f0df4b4566c240ad84d1c31
add ProductCategory model test
eca_catalogue/tests/models_tests.py
eca_catalogue/tests/models_tests.py
from django.test import TestCase from eca_catalogue.tests.models import ProductCategory class ProductCategoryTestCase(TestCase): def test_model(self): obj = ProductCategory.add_root(name="cat1", slug="cat1") self.assertTrue(obj.pk)
Python
0.000001
ad74605039052c3dd7d343c84dd1ac24f068b34f
Bump version to 0.3.15
coil/__init__.py
coil/__init__.py
# Copyright (c) 2005-2006 Itamar Shtull-Trauring. # Copyright (c) 2008-2009 ITA Software, Inc. # See LICENSE.txt for details. """Coil: A Configuration Library.""" __version_info__ = (0,3,15) __version__ = ".".join([str(x) for x in __version_info__]) __all__ = ['struct', 'parser', 'tokenizer', 'errors'] from coil.par...
# Copyright (c) 2005-2006 Itamar Shtull-Trauring. # Copyright (c) 2008-2009 ITA Software, Inc. # See LICENSE.txt for details. """Coil: A Configuration Library.""" __version_info__ = (0,3,14) __version__ = ".".join([str(x) for x in __version_info__]) __all__ = ['struct', 'parser', 'tokenizer', 'errors'] from coil.par...
Python
0
54a0ea2024cbfb4924642b5c23c321a0ae083e9e
Add epgen.py
epgen/epgen.py
epgen/epgen.py
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' epgen runtime ~~~~~~~~~~~~~ :copyright: (c) 2016 by Jihoon Kang <kang@ghoon.net> :license: Apache 2, see LICENSE for more details ''' import os import argparse from cpgen import * from confgen import * from prgen import * class EpgenRuntime: TMPL_DIR = ...
Python
0.000032
3498ddd7817e72b3f6f0b851fa94e82047cb9129
Create the config file if doesn't exist
chubby/config.py
chubby/config.py
import os def create_if_not_exists(): """ Create the config file if doesn't exist already. """ # check if it exists if not os.path.exists(os.path.join(os.path.expand("~"), '.chubby')): os.chdir(os.path.expand("~")) # create file with open(".chubby", 'a'): pass
Python
0.000002
7a4d2139e34b234f596dea67a8fc8becf526a24e
convert unsatisfied file dependencies to trove dependencies (CNP-184)
policy/resolvefiledeps.py
policy/resolvefiledeps.py
# # Copyright (c) 2009 rPath, Inc. # # This program is distributed under the terms of the Common Public License, # version 1.0. A copy of this license should have been distributed with this # source file in a file called LICENSE. If it is not present, the license # is always available at http://www.rpath.com/permanent/...
Python
0
96476a32e545184908f64aac41b23987255138e2
Create new package. (#6623)
var/spack/repos/builtin/packages/py-htseq/package.py
var/spack/repos/builtin/packages/py-htseq/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
5503e1f54298a5b6121e35794d43c6642b3af6e0
Add lc0340_longest_substring_with_at_most_k_distinct_characters.py
lc0340_longest_substring_with_at_most_k_distinct_characters.py
lc0340_longest_substring_with_at_most_k_distinct_characters.py
"""Leetcode 340. Longest Substring with At Most K Distinct Characters Hard URL: https://leetcode.com/problems/longest-substring-with-at-most-k-distinct-characters/ Given a string, find the length of the longest substring T that contains at most k distinct characters. Example 1: Input: s = "eceba", k = 2 Output: 3 Ex...
Python
0.998744
6da928b7e113e30af0da0aa5b18d48c9584a631d
add script
ditto.py
ditto.py
#!/usr/local/bin/python3 """ The purpose of this script is to update dot files somewhere. It works in the following way. Two locations are set dothome : ($HOME) absolute path to the set the dotfiles dotarchive : ($HOME/.dotarchive) absolute path to the dot files (usually some git archive) Then symlinks are...
Python
0.000001
db06d0c08fe4364314f17174e9685b44a95c874f
Use a "Session Factory" instead simply creating Session objects
demos/logging_proxy.py
demos/logging_proxy.py
#!/usr/bin/env python # # logging_proxy.py: Demonstrates how to inherit the Session class so that we can easily get notifications of I/O events . # The idea - by overriding 6 simple function, we get all the I/O events we need in order to fully monitor # the connection (new connnectio...
Python
0
0d0bf5b67f432fd4ee182b9026ea6e319babf9bd
Create ChamBus_create_database.py
ChamBus_create_database.py
ChamBus_create_database.py
# coding: utf-8 # https://github.com/ChamGeeks/GetAroundChamonix/blob/master/www/js/services/TripPlanner.js import datetime, os, requests, sqlite3 db_filename = 'ChamBus.db' db_url = 'https://chx-transit-db.herokuapp.com/api/export/sql' if os.path.exists(db_filename): exit(db_filename + ' already exists. R...
Python
0.000003
a7b31346835c8fdd1724432596650a6de137fe3f
test read_meta
test/Python/test_Func.py
test/Python/test_Func.py
import os, sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../bin'))) from file_def import read_meta import unittest class BasicTestSuite(unittest.TestCase): def test_read_meta(self): meta_file = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../data/SraRunTable.t...
Python
0.000001
c8d48e9996f048b1844258ef427c4359645521c6
Create solution.py
leetcode/easy/length_of_last_word/py/solution.py
leetcode/easy/length_of_last_word/py/solution.py
class Solution(object): def lengthOfLastWord(self, s): """ :type s: str :rtype: int """ words = s.split() if len(words) > 0: return len(words[-1]) return 0
Python
0.000018
a84f965e16e68cb8973d6cc91fbacec56bb92a64
add lottery.py
ext/lottery.py
ext/lottery.py
import decimal import logging import discord from discord.ext import commands from .common import Cog log = logging.getLogger(__name__) PERCENTAGE_PER_TAXBANK = (0.2 / 100) TICKET_PRICE = 20 class Lottery(Cog): """Weekly lottery. The lottery works with you buying a 20JC lottery ticket. Every Saturday...
Python
0.999723
210429b1acbb099479c06f5bd4ceddfabfa6ee5c
Create qualysguard_remediation_ignore_non-running_kernels.py
qualysguard_remediation_ignore_non-running_kernels.py
qualysguard_remediation_ignore_non-running_kernels.py
#!/usr/bin/env python
Python
0.000002
c92954f240ef990eae06967c12426367f0eb6319
Add migration
readthedocs/donate/migrations/0003_add-impressions.py
readthedocs/donate/migrations/0003_add-impressions.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('donate', '0002_dollar-drop-choices'), ] operations = [ migrations.CreateModel( name='SupporterImpressions', ...
Python
0.000002
dc7cf288c5c5c9733a59184770fbaa26db036833
Add basic tests for custom_urls system
tests/unit_project/test_core/test_custom_urls.py
tests/unit_project/test_core/test_custom_urls.py
# -*- coding: utf-8 -*- from djangosanetesting import UnitTestCase from django.http import Http404 from ella.core.custom_urls import DetailDispatcher # dummy functions to register as views def view(request, bits, context): return request, bits, context def custom_view(request, context): return request, cont...
Python
0
861120c5ba7e6e126cac13497a489bc035d27026
add partition show
bin/partition_show.py
bin/partition_show.py
#!/usr/bin/python import datetime import MySQLdb import json import os CONFIG_FILE="partition.json" # ----------------------------------- def config_read(filename): config = json.load(open(filename)) return config # ----------------------------------- def date_show_all_partitions(conn, tablename): lists...
Python
0
480d29bfc92b8dcee3fc02a05e5588085f1bd3bc
new tool: tools/skqp/find_commit_with_best_gold_results
tools/skqp/find_commit_with_best_gold_results.py
tools/skqp/find_commit_with_best_gold_results.py
#! /usr/bin/env python # Copyright 2019 Google LLC. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import json import os import re import subprocess import sys import threading import urllib import urllib2 assert '/' in [os.sep, os.altsep] skia_directory = os....
Python
0.999916
c50a7189e730fc3e95eb209eed00ebdcd7001bde
Create ImgurStorage.py
ImgurStorage.py
ImgurStorage.py
import base64 import os import tempfile from django.core.exceptions import SuspiciousFileOperation from django.core.files import File from django.utils._os import safe_join import requests from django.core.files.storage import Storage from imgurpython import ImgurClient class ImgurStorage(Storage): """ Uses ...
Python
0.000001
e5347530923208abec844e3c41ae3f6680ec42e5
Add Ironic module
lib/ansible/modules/cloud/openstack/os_ironic.py
lib/ansible/modules/cloud/openstack/os_ironic.py
#!/usr/bin/python # coding: utf-8 -*- # (c) 2014, Hewlett-Packard Development Company, L.P. # # This module 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 optio...
Python
0
c153bc9422308599d1354abf782273ca7bd78952
Add a few unit tests for libvirt_conn.
nova/tests/virt_unittest.py
nova/tests/virt_unittest.py
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # # Copyright 2010 OpenStack LLC # # 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...
Python
0
07500dbd92aa15540ddf77b96a7072c5f66d34b2
Add files via upload
heat_map.py
heat_map.py
# -*- coding: utf-8 -*- """ Created on Wed Jun 21 17:27:18 2017 @author: DWyatt """ import pandas as pd import seaborn as sns import sys df_train = pd.read_csv('train.csv') target = 'SalePrice' variables = [column for column in df_train.columns if column!=target] corr = df_train.corr() sns_heat= sns.h...
Python
0
e755977ee0ada391149e55d3331bf2ffe045d243
Add a build configuration test for zlib, for #187
examples/tests/test_build_config.py
examples/tests/test_build_config.py
#! /usr/bin/env python # -*- coding: utf-8 -*- # vi:ts=4:et import pycurl import zlib try: from io import BytesIO except ImportError: try: from cStringIO import StringIO as BytesIO except ImportError: from StringIO import StringIO as BytesIO c = pycurl.Curl() c.setopt(c.URL, 'http://pycurl...
Python
0
9f1c5612c717bac3690d093a27a0a362ff4793b4
add parameters class for fitting data
nsls2/fitting/parameters.py
nsls2/fitting/parameters.py
# Copyright (c) Brookhaven National Lab 2O14 # All rights reserved # BSD License # See LICENSE for full text # @author: Li Li (lili@bnl.gov) # created on 07/20/2014 class ParameterBase(object): """ base class to save data structure for each fitting parameter """ def __init__(self): sel...
Python
0
17de6f90ce081984cab528526fcf9d9e7008be14
Create beta_scraping_get_users_honor.py
Solutions/beta/beta_scraping_get_users_honor.py
Solutions/beta/beta_scraping_get_users_honor.py
from bs4 import BeautifulSoup as BS from urllib.request import urlopen Url = 'https://www.codewars.com/users/leaderboard' def get_honor(username): html = urlopen(Url).read().decode('utf-8') soup = BS(html, 'html.parser') for i in soup.find_all('tr'): try: a = str(i).split('</t...
Python
0.000001
8c737c22ae5d896f5445995660d664d959ce1c08
add ctc reader
fluid/ocr_recognition/ctc_reader.py
fluid/ocr_recognition/ctc_reader.py
import os import cv2 import numpy as np from paddle.v2.image import load_image class DataGenerator(object): def __init__(self): pass def train_reader(self, img_root_dir, img_label_list): ''' Reader interface for training. :param img_root_dir: The root path of the image for trainin...
Python
0
90c7f90a8d409fd68ebe20ed4ac35fd378abfee5
Create flush.py
flush.py
flush.py
f = open('out.log', 'w+') f.write('output is ') # some work s = 'OK.' f.write(s) f.write('\n') f.flush() # some other work f.write('done\n') f.flush() f.close()
Python
0.000004
ea11ae8919139eae8eaa6b9b1dfe256726d3c584
Copy SBSolarcell tests into individual file
test/test_SBSolarcell.py
test/test_SBSolarcell.py
# -*- coding: utf-8 -*- import numpy as np import ibei from astropy import units import unittest temp_sun = 5762. temp_earth = 288. bandgap = 1.15 input_params = {"temp_sun": temp_sun, "temp_planet": temp_earth, "bandgap": bandgap, "voltage": 0.5,} class CalculatorsRe...
Python
0
a973b1daca340031c671070e0f102a6114f58fab
add files
mysite/wordclips/ventriloquy/test_ventriloquy.py
mysite/wordclips/ventriloquy/test_ventriloquy.py
from django.test import TestCase from wordclips.ventriloquy.ventriloquy import Ventriloquy from wordclips.models import Wordclip class VentriloquyTestCase(TestCase): def setUp(self): self.ventriloquy = Ventriloquy() # Put dummy object in databse for testing purpose Wordclip.objects.create(...
Python
0.000002
8fd466ecd16db736177104902eb84f661b2b62cc
Create sitemap for google news
opps/sitemaps/googlenews.py
opps/sitemaps/googlenews.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from django.contrib.sitemaps import GenericSitemap from django.contrib.sites.models import Site class GoogleNewsSitemap(GenericSitemap): # That's Google News limit. Do not increase it! limit = 1000 sitemap_template = 'sitemap_googlenews.xml' def get_urls(...
Python
0.000095
2a106a12db2a59ccb0517a13db67b35f475b3ef5
Add args to survey_data url
apps/survey/urls.py
apps/survey/urls.py
from django.conf.urls.defaults import * from . import views urlpatterns = patterns('', url(r'^profile/$', views.profile_index, name='survey_profile'), url(r'^profile/electric/$', views.profile_electric, name='survey_profile_electric'), url(r'^main/$', views.main_index), url(r'^group_management/$', vie...
from django.conf.urls.defaults import * from . import views urlpatterns = patterns('', url(r'^profile/$', views.profile_index, name='survey_profile'), url(r'^profile/electric/$', views.profile_electric, name='survey_profile_electric'), url(r'^main/$', views.main_index), url(r'^group_management/$', vie...
Python
0.000002
b85b8915b73433f74d8ee5c6f6ef9f88d8b82bd8
add original py script
genSongbook.py
genSongbook.py
#!/usr/bin/python import os f = open('songbook.tex', 'w') s = """% songbook.tex %\documentclass[11pt,a4paper]{article} % article format \documentclass[11pt,a4paper,openany]{book} % book format \usepackage[margin=0.7in]{geometry} %\usepackage[utf8]{inputenc} % tildes \usepackage{graphics} \usepackage[dvips]{graph...
Python
0
ac5b1181ff73b9d12c09731a646dac7fa23c342b
Add Weatherbit module
desertbot/modules/commands/weather/Weatherbit.py
desertbot/modules/commands/weather/Weatherbit.py
from collections import OrderedDict from datetime import datetime from twisted.plugin import IPlugin from zope.interface import implementer from desertbot.moduleinterface import IModule from desertbot.modules.commands.weather.BaseWeatherCommand import BaseWeatherCommand, getFormattedWeatherData, \ getFormattedFor...
Python
0
8822eba1c4351f8cc575fdb33c15bcd6a27bf21c
allow for nodePort to be None in case of ClusterIP
kubernetes/models/v1/ServicePort.py
kubernetes/models/v1/ServicePort.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # This file is subject to the terms and conditions defined in # file 'LICENSE.md', which is part of this source code package. # from kubernetes.utils import is_valid_string class ServicePort(object): VALID_PROTOCOLS = ['TCP', 'UDP'] def __init__(self, name=N...
#!/usr/bin/env python # -*- coding: utf-8 -*- # # This file is subject to the terms and conditions defined in # file 'LICENSE.md', which is part of this source code package. # from kubernetes.utils import is_valid_string class ServicePort(object): VALID_PROTOCOLS = ['TCP', 'UDP'] def __init__(self, name=N...
Python
0.000398