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
f874c337e0d0bb8cce8cfe6523c0d06c37b93198
add basic setup.py definition
setup.py
setup.py
from distutils.core import setup setup( name='SaasyDjangoRestFramework', version='0.1dev', packages=[], license='Creative Commons Attribution-Noncommercial-Share Alike license', description="SaaS plugin for the django rest framework", )
Python
0.000001
63143c94cef353d7bae13f7b13650801bb901c94
Test for explicit start/end args to str methods for unicode.
tests/unicode/unicode_pos.py
tests/unicode/unicode_pos.py
# str methods with explicit start/end pos print("Привет".startswith("П")) print("Привет".startswith("р", 1)) print("абвба".find("а", 1)) print("абвба".find("а", 1, -1))
Python
0
e0b17a1778fb8946adff14614098ba6d34014746
add some more testing
test/test_route.py
test/test_route.py
import unittest import bottle from tools import api from bottle import _re_flatten class TestReFlatten(unittest.TestCase): def test_re_flatten(self): self.assertEqual(_re_flatten(r"(?:aaa)(_bbb)"), '(?:aaa)(?:_bbb)') self.assertEqual(_re_flatten(r"(aaa)(_bbb)"), '(?:aaa)(?:_bbb)') self.as...
import unittest import bottle from tools import api class TestRoute(unittest.TestCase): @api('0.12') def test_callback_inspection(self): def x(a, b): pass def d(f): def w(): return f() return w route = bottle.Route(None, None, None, d(x...
Python
0
5a3971a3048adec420796ad5a781f0a84eca7d31
Remove transifex-client dev dependency
setup.py
setup.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import io import re import sys from setuptools import setup, find_packages # requirements setup_requirements = ['pytest-runner'] if {'pytest', 'test', 'ptr'}.intersection(sys.argv) else [] install_requirements = ['guessit>=2.0.1', 'babelfish>=0.5.2', 'enzyme>=0.4.1', 'b...
#!/usr/bin/env python # -*- coding: utf-8 -*- import io import re import sys from setuptools import setup, find_packages # requirements setup_requirements = ['pytest-runner'] if {'pytest', 'test', 'ptr'}.intersection(sys.argv) else [] install_requirements = ['guessit>=2.0.1', 'babelfish>=0.5.2', 'enzyme>=0.4.1', 'b...
Python
0
601fd8a7b4fea5db2f23741735e6e7f1332b4417
Fix issue #949 - Add mock as dependency
setup.py
setup.py
#!/usr/bin/env python from __future__ import unicode_literals from setuptools import setup, find_packages install_requires = [ "Jinja2>=2.8", "boto>=2.36.0", "boto3>=1.2.1", "cookies", "requests>=2.0", "xmltodict", "dicttoxml", "six", "werkzeug", "pyaml", "pytz", "python...
#!/usr/bin/env python from __future__ import unicode_literals from setuptools import setup, find_packages install_requires = [ "Jinja2>=2.8", "boto>=2.36.0", "boto3>=1.2.1", "cookies", "requests>=2.0", "xmltodict", "dicttoxml", "six", "werkzeug", "pyaml", "pytz", "python...
Python
0
84c1ee14e1717ec63782dd5a159fe5848fce1cc4
Add Python 3.6 and 3.7 to PyPI page
setup.py
setup.py
#!/usr/bin/env python import sys try: from setuptools import setup except ImportError: from distutils.core import setup if sys.version_info < (2, 7): raise NotImplementedError("Sorry, you need at least Python 2.7 or Python 3.2+ to use bottle.") import bottle setup(name='bottle', version=bottle.__v...
#!/usr/bin/env python import sys try: from setuptools import setup except ImportError: from distutils.core import setup if sys.version_info < (2, 7): raise NotImplementedError("Sorry, you need at least Python 2.7 or Python 3.2+ to use bottle.") import bottle setup(name='bottle', version=bottle.__v...
Python
0
f539736b563fb6859a6bffb03aed42b57880744f
create module
test_vbn_parser.py
test_vbn_parser.py
import networkx as nx import matplotlib.pyplot as plt import vbn_parser as p # initialize G = nx.Graph() link = 'http://vbn.aau.dk/da/organisations/antennas-propagation-and-radio-networking(c2c38bb3-3d28-4b2c-8bc4-949211d2d486)/publications.rss?altordering=publicationOrderByPublicationYearThenCreated&pageSize=500' # ...
Python
0.000001
30fc52d77170844c5b3820d997286df744eb56db
Add setup.py for packaging and PyPI submission.
setup.py
setup.py
from setuptools import setup name = 'hsalf' setup( name=name, version='0.0.1', author='Nam T. Nguyen', author_email='namn@bluemoon.com.vn', url='https://bitbucket.org/namn/hsalf/overview', description='Hsalf is a pure Python library to read and write Flash files (SWF).', long_descri...
Python
0
d433d16a0375669c1664bbe8f20a8db5924fa92e
Add basic benchmark for length
tests/benchmark.py
tests/benchmark.py
from random import choice from string import ascii_lowercase import timeit import grapheme def random_ascii_string(n): return "".join(choice(ascii_lowercase) for i in range(n)) long_ascii_string = random_ascii_string(1000) statements = [ "len(long_ascii_string)", "grapheme.length(long_ascii_string)", ] ...
Python
0.000026
dd015a7bf9c69e2f96488c9239be694303b30176
Create setup.py
setup.py
setup.py
import setuptools with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="deepctr", version="0.1.3", author="Weichen Shen", author_email="wcshen1994@163.com", description="DeepCTR is a Easy-to-use,Modular and Extendible package of deep-learning based CTR models ...
Python
0.000001
5a2a2aa33a2e206042b3d28a830d00bdae2f5ad8
Add setup.py for distribution
setup.py
setup.py
from ez_setup import use_setuptools use_setuptools() from setuptools import setup, find_packages setup( name = "rw", version = "0.0.1", packages = find_packages(), scripts = ['scripts/rw'], install_requires = ['docopt'], author = "Ben Pringle", author_email = "ben.pringle@gmail.com", ...
Python
0
91affa8b785e0b5261f69448c1c08de429460bb9
Add setup.py
setup.py
setup.py
from setuptools import setup setup( name='django-yadt', packages=( 'django_yadt', 'django_yadt.management', 'django_yadt.management.commands', ), )
Python
0.000001
090568a6e31fd8de1975d0e2cecb2fcd559acd3e
Add natsort to setup.py
setup.py
setup.py
#!/usr/bin/env python # ----------------------------------------------------------------------------- # Copyright (c) 2013, The Qiita Development Team. # # Distributed under the terms of the BSD 3-clause License. # # The full license is in the file LICENSE, distributed with this software. # ---------------------------...
#!/usr/bin/env python # ----------------------------------------------------------------------------- # Copyright (c) 2013, The Qiita Development Team. # # Distributed under the terms of the BSD 3-clause License. # # The full license is in the file LICENSE, distributed with this software. # ---------------------------...
Python
0
631afff160077cc629054613d59cb47747f6c20d
Fix setup to exclude tests
setup.py
setup.py
#!/usr/bin/env python # -*- coding: utf-8; -*- # # This file is part of Superdesk. # # Copyright 2013, 2014, 2015 Sourcefabric z.u. and contributors. # # For the full copyright and license information, please see the # AUTHORS and LICENSE files distributed with this source code, or # at https://www.sourcefabric.org/sup...
#!/usr/bin/env python # -*- coding: utf-8; -*- # # This file is part of Superdesk. # # Copyright 2013, 2014, 2015 Sourcefabric z.u. and contributors. # # For the full copyright and license information, please see the # AUTHORS and LICENSE files distributed with this source code, or # at https://www.sourcefabric.org/sup...
Python
0.000001
5b251911d112abea610477a3f552a78be6b5b1e1
add utils module
utils.py
utils.py
from flask import Response, request def add_basic_auth(blueprint, username, password, realm='RQ Dashboard'): '''Add HTTP Basic Auth to a blueprint. Note this is only for casual use! ''' @blueprint.before_request def basic_http_auth(*args, **kwargs): auth = request.authorization if ...
Python
0
70ad81a24e218fd2b5fed03224611eae63e0d58f
add main argument processing file
boxes/argsParse.py
boxes/argsParse.py
import argparse
Python
0
a633cc0b4ee376ff02af101154e60b8b33dfda08
add migration for old logs
scripts/migrate_preprint_logs.py
scripts/migrate_preprint_logs.py
import sys import logging from datetime import datetime from modularodm import Q from modularodm.exceptions import NoResultsFound from website.app import init_app from website.models import NodeLog, PreprintService logger = logging.getLogger(__name__) def main(dry): if dry: logging.warn('DRY mode runni...
Python
0
caf2d7108d7329da562a012775bac0a87d4c62b6
Create db_create.py
fade/db_create.py
fade/db_create.py
#!flask/bin/python """ See LICENSE.txt file for copyright and license details. """ from migrate.versioning import api from config import SQLALCHEMY_DATABASE_URI from config import SQLALCHEMY_MIGRATE_REPO from app import db import os.path db.create_all() if not os.path.exists(SQLALCHEMY_MIGRATE_REPO): api.crea...
Python
0.000011
f6f75172b1b8a41fc5ae025416ea665258d4ff4c
Add script for updating favicon from gh avatar
favicon-update.py
favicon-update.py
from PIL import Image import requests from io import BytesIO # This whole script was done using Google and StackOverflow # How to generate ico files # https://stackoverflow.com/a/36168447/1697953 # How to get GitHub avatar location from username # https://stackoverflow.com/a/36380674/1697953 # How to read image data f...
Python
0
75031595de8726dcd21535b13385c4e6c89aa190
Add run meter task
datastore/tasks.py
datastore/tasks.py
from __future__ import absolute_import from celery import shared_task from datastore.models import Project @shared_task def run_meter(project_pk): project = Project.objects.get(pk=project_pk): project.run_meter()
Python
0.999872
3ed6a0e337c99d12fb4abd96b2230e13388289e7
Add tests for Process functionality.
jarn/mkrelease/tests/test_process.py
jarn/mkrelease/tests/test_process.py
import unittest import os from jarn.mkrelease.process import Process from jarn.mkrelease.testing import JailSetup from jarn.mkrelease.testing import quiet class PopenTests(unittest.TestCase): @quiet def test_simple(self): process = Process() rc, lines = process.popen('echo "Hello world"') ...
Python
0
27c5a09ddbe2ddf14b2f4c84ebb668adbdfd7070
ADD example.basicserver for test
example/basicserver.py
example/basicserver.py
from wood import Wood w = Wood(__name__,debug=True) IndexHandler = w.empty(uri='/',name='IndexHandler') @IndexHandler.get def index_page(self): self.write('滑稽,这里什么都没有\n(HuajiEnv)') if __name__ == '__main__': w.start(port=6000)
Python
0
537bb46c6806ef69ab3022641a76f50f97630e11
Add first migration: Create the database tables.
boson/db/sqlalchemy/alembic/versions/1f22e3c5ff66_initial_revision.py
boson/db/sqlalchemy/alembic/versions/1f22e3c5ff66_initial_revision.py
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2012 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/...
Python
0
8049e2f0bb0a12bb301ab4390c3e4da3d90f0369
Move stagingsettings to new 'cosmos' project tree
cosmos/platform/frontend/src/bdp_fe/conf/stagingsettings.py
cosmos/platform/frontend/src/bdp_fe/conf/stagingsettings.py
""" Module testsettings These settings allow Django unittests to setup a temporary databse and run the tests of the installed applications. """ DEBUG = True TEMPLATE_DEBUG = DEBUG from bdp_fe.conf.base_settings import * DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': ...
Python
0
1b8edd0d6ce3f66c8bacad8bad62de0d40284799
Add dodge game example
examples/dodge_game.py
examples/dodge_game.py
""" Dodge game Get the player back and forth across the screen while dodging the enemy """ from microbit import * import music class Enemy: """ Enemy which moves vertically down the screen """ def __init__(self): self.x, self.y = 2, -1 def get_positions(self): return ((self.x, s...
Python
0
70d912bfb1ccec03edfe92b9b2c87610346c8f42
Add blocking migration for new domain db
corehq/doctypemigrations/migrations/0006_domain_migration_20151118.py
corehq/doctypemigrations/migrations/0006_domain_migration_20151118.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations from corehq.doctypemigrations.djangomigrations import assert_initial_complete from corehq.doctypemigrations.migrator_instances import domains_migration class Migration(migrations.Migration): dependencies = [ ...
Python
0
c76028ee46c3ea5d1021dcb87a78dec98d032367
Add file level transformation tests
data/file_level_transformation_test.py
data/file_level_transformation_test.py
# Copyright 2020 Google 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 # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
Python
0
0378f8cde69a18d954341b861a724592ef7a5949
Extend RANSAC example with comparison to BaggingRegressor
examples/linear_model/plot_ransac.py
examples/linear_model/plot_ransac.py
""" =========================================== Robust linear model estimation using RANSAC =========================================== In this example we see how to robustly fit a linear model to faulty data using the RANSAC algorithm. """ import numpy as np from matplotlib import pyplot as plt from sklearn import ...
""" =========================================== Robust linear model estimation using RANSAC =========================================== In this example we see how to robustly fit a linear model to faulty data using the RANSAC algorithm. """ import numpy as np from matplotlib import pyplot as plt from sklearn import ...
Python
0
d0e5ea752912b10e473b2a05da9196800eb6ca86
Add an example for the RedisLock
examples/redis_lock.py
examples/redis_lock.py
import random from diesel import fork, quickstop, quickstart, sleep from diesel.protocols.redis import RedisClient, RedisTransactionError, RedisLock, LockNotAcquired """Implement the Redis INCR command using a lock. Obviously this is inefficient, but it's a good example of how to use the RedisLock class""" key = 't...
Python
0.000003
1d77849b048c424ebc042a61c047c2c74e27277f
minus 1
leetcode_python/zigzag_conversion.py
leetcode_python/zigzag_conversion.py
class Solution: # @return a string def convert(self, s, nRows): if nRows == 1: return s result = [[] for i in range(nRows)] for i, c in enumerate(s): if (i / (nRows - 1)) % 2 == 0: result[i % (nRows - 1)].append(c) else: ...
Python
0.999994
d0b8c68ae3c8acbc3d5dfe13842e3c41a198b978
Add script to fix all notions
fix_notions_db.py
fix_notions_db.py
from alignements_backend.db import DB from alignements_backend.notion import Notion for notion in DB.scan_iter(match='notion:*'): n = Notion(list(DB.sscan_iter(notion)))
Python
0.000001
ad6e0bad22b0c5b0e6f97ceb13694ab804041443
Add model resources.
tracker/api.py
tracker/api.py
from tastypie.resources import ModelResource from tracker.models import Task, WorkSession from django.contrib.auth.models import User from tastypie import fields class UserResource(ModelResource): class Meta: queryset = User.objects.all() resource_name = 'user' class TaskResource(ModelResource):...
Python
0
8f05695a153eef415f752c42c2f737de3f120b55
Create dgen_red_a.py
bin/dgen_red_a.py
bin/dgen_red_a.py
#!/usr/bin/env python """ Created on March 4, 2016 @author: Gus Segura """ # imports import time import random import base64 import os import sys import math import json import redis from collections import OrderedDict # redis server connection # Connection to Database: this is how we work with Redis database = redis...
Python
0.000011
c97680113fb25ed43e96c26d02bfd57e15e427b8
Add missing migrations
nodeconductor/billing/migrations/0004_invoice_usage_pdf.py
nodeconductor/billing/migrations/0004_invoice_usage_pdf.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('billing', '0003_invoice_status'), ] operations = [ migrations.AddField( model_name='invoice', name='...
Python
0
e456e4799f5cee13ce1b5f93a9cc91b28059db16
Remove tests that use real data from the individual inferred test
emission/individual_tests/TestMetricsInferredSections.py
emission/individual_tests/TestMetricsInferredSections.py
from __future__ import unicode_literals from __future__ import print_function from __future__ import division from __future__ import absolute_import from future import standard_library standard_library.install_aliases() from builtins import * import unittest import logging import arrow import os import emission.core.g...
Python
0.000005
3d19606b83f6a4a7906f88b15c6e215620394560
Implemented the Ford-Fulkerson algorithm
ford_fulkerson.py
ford_fulkerson.py
#!/usr/bin/env python #coding: UTF-8 # # Implementation of the Ford-Fulkerson algorithm to solve the maximum flow problem. # # Copyright (c) 2013 Samuel Groß # from graph import * from basics import depth_first_search def solve_max_flow_ff(graph, s, t): """ Solves the maximum flow prolem using the ford-fulke...
Python
0.998064
321463a5d7f102431ed286d57d1a8fa8c576cca7
add plotting fns
terrapin/plot.py
terrapin/plot.py
import matplotlib.pyplot as plt def flow_grid(dem, angles): pass
Python
0.000001
72013d0dba1bd75cab86f00a5a23496f87b66dca
First work on the rhythm version
0-03_rhythm.py
0-03_rhythm.py
from music import * from random import * from itertools import * # --- INPUT --- # Note there's currently very little flexibility in the input file structure # open the file and read the lines as one chord per line fname = "Autumn.txt" with open(fname) as f: all_chords = f.readlines() # Remove the 'newl...
Python
0.997938
ed23fb301503d331af243a37d1b0a934d5d2f21c
add laser plugin object
mythril/laser/ethereum/plugins/plugin.py
mythril/laser/ethereum/plugins/plugin.py
from mythril.laser.ethereum.svm import LaserEVM class LaserPlugin: """ Base class for laser plugins Functionality in laser that the symbolic execution process does not need to depend on can be implemented in the form of a laser plugin. Laser plugins implement the function initialize(symbolic_vm) whi...
Python
0
550469032843eb2af3b4a9faaed34d9754f00700
Add command to test managers emails
geotrek/common/management/commands/test_managers_emails.py
geotrek/common/management/commands/test_managers_emails.py
from django.core.mail import mail_managers from django.core.management.base import BaseCommand class Command(BaseCommand): help = "Test if email settings are OK by sending mail to site managers" def execute(self, *args, **options): subject = u'Test email for managers' message = u'If you rece...
Python
0.000002
edb9500824faffd9f1d0d1b59ca29966e3b18282
Customize behave formatter to output json
modules/formatter_record.py
modules/formatter_record.py
from behave.formatter.json import PrettyJSONFormatter from pprint import pprint class RecordFormatter(PrettyJSONFormatter): name = "super" description = "Formatter for adding REST calls to JSON output." jsteps = {} # Contains an array of features, that contains array of steps in each feature # Overrid...
Python
0.000001
def7e3aeaf3b0cd1a6486c72c68a3baad77ef3e5
Create leetcode-50.py
python_practice/leetCode/leetcode-50.py
python_practice/leetCode/leetcode-50.py
class Solution: def myPow(self, x: 'float', n: 'int') -> 'float': return x**n def myPow2(self, x: 'float', n: 'int') -> 'float': if n == 0: return 1 if n < 0: n = 0-n x = 1/x return x**(n%2)*myPow2(x*x, n//2)
Python
0.000004
71e431a5eccc6483847888fb0f8f5f30f182913a
add a script to convert xml documentation into json
doc/xmldoc2json.py
doc/xmldoc2json.py
#!/usr/bin/python import sys import xml.etree.ElementTree as ET import json def parseClass(data): dictCls = dict(data.attrib) dictCls['brief_description'] = data.find("brief_description").text.strip() dictCls['description'] = data.find("description").text.strip() dictCls['methods'] = [] for m in da...
Python
0.000003
4ca8d43d8e6ec243d9812bb313a8e7a21ad781ea
Add DB exercise.
Exercise/DB.py
Exercise/DB.py
import mysql.connector conn = mysql.connector.connect(user='root', password='blue', database='test') cursor = conn.cursor() cursor.execute('create table user (id varchar(20) primary key, name varchar(20))') cursor.execute('insert into user (id, name) values (%s, %s)', ['1', 'Dai']) print(cursor.rowcount) conn.commit(...
Python
0
c4e1e034a3f0be3590dc78c5683d9deaf44d696f
add example of escape character
scripts/escape/backslash.py
scripts/escape/backslash.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import json ''' This tests the acceptance of backslashes \\f should be okay \f is not necessarily okay, because json.dumps will not dump this ''' print json.dumps({ "foogroup": { "hosts": [ "foobar" ] }, "_meta": { "hostvars...
Python
0.000001
c5c0d3f447b1295bdbbda60c38c4123f2e8d871c
add gnucash2ledger converter
gnucash2ledger.py
gnucash2ledger.py
#!/usr/bin/env python import sys import codecs import gnucash out = codecs.getwriter('UTF-8')(sys.stdout) if len(sys.argv) == 1: sys.stderr.write("Invocation: %s gnucash_filename\n" % sys.argv[0]) sys.exit(1) data = gnucash.read_file(sys.argv[1]) def format_commodity(commodity): mnemonic = commodity.mnemonic try:...
Python
0.000002
bfbd2c792aacd307f8d7ed68ea0f2a7db681431d
add functions that generate mask image of the target bin
jsk_apc2016_common/python/jsk_apc2016_common/mask_bin.py
jsk_apc2016_common/python/jsk_apc2016_common/mask_bin.py
#!/usr/bin/env python import numpy as np from matplotlib.path import Path import jsk_apc2016_common.segmentation_helper as helper from tf2_geometry_msgs import do_transform_point def get_mask_img(transform, target_bin, camera_model): """ :param point: point that is going to be transformed :type point: Po...
Python
0.000003
852c6639bb0a71b9ef2dd81b2830193d0c9fe23d
Create FractalPoke.py
FractalPoke.py
FractalPoke.py
bl_info = { "name": "FractalPoke", "author": "Christopher Kopic", "version": (1, 0), "blender": (2, 7, 8), "location": "", "description": "Iterative Poking inspired by Simon Holmedal's Always Forever", "warning": "", "wiki_url": "", "tracker_url": "", "category": "Mesh"} import bpy from bpy.types import Ope...
Python
0.000001
2dff378e7f446e83aa7c105bded3f3330fe9fa20
Add a script to generate a Javascript file encoding_<enc>.js containing encoding and decoding tables for the specified <enc> encoding. Uses Unicode table at location http://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/<enc>.TXT. Related to issue #1541.
scripts/make_encoding_js.py
scripts/make_encoding_js.py
"""Create a Javascript script to encode / decode for a specific encoding described in a file available at http://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/<ENCODING>.TXT """ import os import re import json import urllib.request line_re = re.compile("^(0x[A-Z0-9]+)\s+(0x[A-Z0-9]+)*", re.M) tmpl = "http://uni...
Python
0
f1c65cf208b4a6275214d82a765ad75c47c75715
add example of how to use KT without defines
examples/cuda-c++/vector_add_defines.py
examples/cuda-c++/vector_add_defines.py
#!/usr/bin/env python """ This is the example demonstrates how to use Kernel Tuner to insert tunable parameters into template arguments without using any C preprocessor defines """ import numpy as np import kernel_tuner as kt def tune(): kernel_string = """ template<typename T, int blockSize> __global__ ...
Python
0
00cc1f17796897ca2f4351bbea74ee22aad98f14
Create quadrants_HH_HL_LH_LL.py
quadrants_HH_HL_LH_LL.py
quadrants_HH_HL_LH_LL.py
# python3 for categorizing data into 4 quadrants from 2 numerical fields # this case is for vis minoirty + avg income in Toronto census tracts import csv import statistics as st # just the toronto cts tor_cts = [] with open('ct_tor.csv', 'r') as csvfile: reader = csv.DictReader(csvfile) for row in reader: ...
Python
0.999018
9dae55d2ef2e786799554ec2121cf9ecfe59eb62
Rename file
dnsdiff/dnsdiff.py
dnsdiff/dnsdiff.py
'''Module to quickly look up and compare NS records for differences''' import dns.resolver import pprint import sys pp = pprint.PrettyPrinter(indent=4) def compare_dns(nameservers, domain): '''Compares records between nameservers using dnspython''' responses = {} resolver = dns.resolver.Resolver(configure=False)...
Python
0.000002
bef5333edf60779f645603b3d4c7611867ad7382
Day25 and final day! yaaaay
day25/code_generator.py
day25/code_generator.py
row = 2978 column = 3083 x = 1 y = 1 value = 20151125 step = 1 while x <= column or y <= row: if x == step and y == 1: step += 1 y = step x = 1 else: x += 1 y -= 1 value = (value * 252533) % 33554393 if x == column and y == row: print 'The code for the machine is:', value
Python
0.999998
d3b4d53e84bdb1f50b244b282d6cb1b3b0d10ee3
Add scraper
project/scrape.py
project/scrape.py
import requests import re from bs4 import BeautifulSoup def main(): department_list = scrape() department_scrape(department_list) def scrape(): # Set up pull requests and soup object front_html = requests.get("http://general-catalog.berkeley.edu/catalog/gcc_search_menu") soup = BeautifulSoup(front_html.conte...
Python
0.000002
be189d9d01f916af87b45f36ac36f7c5d302dbbf
add an experimental command for setting the login background image
kolibri/content/management/commands/background.py
kolibri/content/management/commands/background.py
from __future__ import absolute_import from __future__ import print_function from __future__ import unicode_literals import logging import os import shutil from django.conf import settings from django.core.management.base import BaseCommand logger = logging.getLogger(__name__) class Command(BaseCommand): def a...
Python
0
1f48fee7ffcef3eefa6aaedb5ca963c10bb7c58c
Add test case for user creation form
{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/test_forms.py
{{cookiecutter.repo_name}}/{{cookiecutter.repo_name}}/users/test_forms.py
from django.test import TestCase from users.forms import ZionsUserCreationForm from users.models import User class {{cookiecutter.project_camel_name}}UserCreationTestCase(TestCase): def setUp(self): self.test_user = User.objects.create( username='testuser', email='test@test.com', ...
Python
0.000001
616bb27db3daef8939fe706d1c41cf79f35b40fa
set of default rules in common module
common.py
common.py
#/usr/bin/python # -*- coding: utf-8 -*- # Copyright (c) 2012 Denis Zalevskiy # Licensed under MIT License import string from parser import * def vspace(): return '\n\r', ignore def hspace(): return ' \t', ignore def eol(): return choice(eof, vspace), ignore def space(): return ' \n\r\t', ignore def spaces(): retur...
Python
0
b8c4fdc1ebba18ab832160bece4ce8b391a15b7a
add sampled stochastic games serialization tests
open_spiel/python/tests/sampled_stochastic_games_test.py
open_spiel/python/tests/sampled_stochastic_games_test.py
# Copyright 2019 DeepMind Technologies Ltd. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
Python
0
ed9d640a11c02ca4b42e62d975e4ae9a2bd33093
add tests for simtk!
openpathsampling/experimental/storage/test_simtk_unit.py
openpathsampling/experimental/storage/test_simtk_unit.py
import pytest import numpy as np from ..simstore.custom_json import JSONSerializerDeserializer, DEFAULT_CODECS from .simtk_unit import * try: from simtk import unit except ImportError: HAS_SIMTK = False else: HAS_SIMTK = True class TestSimtkUnitCodec(object): def setup(self): pytest.importor...
Python
0
4d85702561c000824083544de98693e244c8aab7
Add test for decoder stack
tests/test_decoding_stack.py
tests/test_decoding_stack.py
#! /usr/bin/env python from __future__ import division from timeside.decoder import FileDecoder from timeside.analyzer import AubioPitch from timeside.core import ProcessPipe import numpy as np from unit_timeside import * import os.path #from glib import GError as GST_IOError # HINT : to use later with Gnonlin only...
Python
0.000001
15815f0c63b29fabe42e9abe2bfae736012d9b9f
Initialize descentmethods testing
tests/test_descentmethods.py
tests/test_descentmethods.py
import ML.descentmethods as descentmethods import ML.regression as regression import data import numpy as np import pytest @pytest.fixture def gradient(): def grad(X, y, weights): hypothesis = np.dot(X, weights) - y gradient = np.dot(np.transpose(X), hypothesis) / np.size(y) return gradien...
Python
0.000003
40bf8d4773eb659ac2ac22aef50c2f63084924be
add profiler test case
rfcs/20200624-pluggable-device-for-tensorflow/sample/test_profiler.py
rfcs/20200624-pluggable-device-for-tensorflow/sample/test_profiler.py
#!/usr/bin/env python # coding=utf-8 import tensorflow as tf import numpy as np import os tf.compat.v1.disable_eager_execution() profile_options = tf.profiler.experimental.ProfilerOptions( host_tracer_level = 3, devic...
Python
0.000002
1670438ac9becf93e9ba428065e4b19b219e8ffc
Add WebSockets and SSL supports with Twisted :)
helenae/server.py
helenae/server.py
import sys from json import dumps, loads import sqlalchemy from sqlalchemy.orm import sessionmaker from db.create_db import Users from twisted.internet import reactor, ssl from twisted.python import log from twisted.web.server import Site from twisted.web.static import File from autobahn.twisted.websocket import We...
Python
0
3d0827fa805a08eaaaa07e037f6ce3da6d8e1c4e
add guess module
yoink/guess.py
yoink/guess.py
import numpy as np from scipy import ndimage try: from skimage.feature import corner_harris from skimage.measure import approximate_polygon except ImportError: from yoink.mini_skimage import corner_harris, approximate_polygon def guess_corners(bw): """ Infer the corners of an image using a Sobel ...
Python
0.000001
4224761522c1e058979f3901f9af1d037398576c
Add cache_key method to be used by Django 1.7
django_mobile/loader.py
django_mobile/loader.py
import hashlib from django.template import TemplateDoesNotExist from django.template.loader import find_template_loader, BaseLoader from django.template.loader import get_template_from_string from django.template.loaders.cached import Loader as DjangoCachedLoader from django_mobile import get_flavour from django_mobile...
import hashlib from django.template import TemplateDoesNotExist from django.template.loader import find_template_loader, BaseLoader from django.template.loader import get_template_from_string from django.template.loaders.cached import Loader as DjangoCachedLoader from django_mobile import get_flavour from django_mobile...
Python
0
4ef2344b3abf3d8c0542ffd97425557ae092f21d
handle ZeroDivisionError
tensorflow/python/data/experimental/benchmarks/map_defun_benchmark.py
tensorflow/python/data/experimental/benchmarks/map_defun_benchmark.py
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
Python
0.000006
ef96c4e1a27289f5cdad5de78ee2a2dfc1b91bd0
Create network-delay-time.py
Python/network-delay-time.py
Python/network-delay-time.py
# Time: O((|E| + |V|) * log|V|) # Space: O(|E| + |V|) # Dijkstra's algorithm class Solution(object): def networkDelayTime(self, times, N, K): """ :type times: List[List[int]] :type N: int :type K: int :rtype: int """ min_heap = [] adj = [[] for _ in ...
Python
0.000037
842d7337f236d94d1b7ed70aaa98eff73b4000cd
Create pyside_houdini.py
pyside_houdini.py
pyside_houdini.py
""" This module helps you use PyQt in Houdini's GUI by integrating PyQt's event loop into Houdini's. Replace calls to QApplication.exec_() in your code with calls to pyqt_houdini.exec_(app). """ from email.mime import image import hou from PySide import QtCore from PySide import QtGui class IntegratedEventLoop(object...
Python
0
90ef0ed82a4d22f277ccc0c3275f0a07189fadc0
Make title pictures.
title_pics.py
title_pics.py
# -*- coding: utf-8 -*- # # title_pics.py # # purpose: Create map and time-series for title # author: Filipe P. A. Fernandes # e-mail: ocefpaf@gmail # web: http://ocefpaf.github.io/ # created: 20-Jan-2015 # modified: Tue 20 Jan 2015 11:18:15 AM BRT # # obs: # import matplotlib import numpy as np import car...
Python
0.000006
cf95ab6ee1bf53ff1a998824dc3718c1ae19336e
Create train_dots.py
train_dots.py
train_dots.py
#!/bin/python import pylab as pl import cPickle import matplotlib.pyplot as plt from sklearn import svm, metrics import numpy as np import sys square = 13 imgloc = '../images/v012-penn.10-1hA5D1-cropb.png' resd={'dot':0,'noise':1,'vein':2} currimg=plt.imread(imgloc) pkl_file=open('dots.pkl', 'r') dots = cPickle.load...
Python
0
84153b0be78998ab8ec6914df8623c99255457b5
Improve code for creating temporary locustfiles that can be used in tests
locust/test/mock_locustfile.py
locust/test/mock_locustfile.py
import os import random import time from contextlib import contextmanager MOCK_LOUCSTFILE_CONTENT = ''' """This is a mock locust file for unit testing""" from locust import HttpLocust, TaskSet, task, between def index(l): l.client.get("/") def stats(l): l.client.get("/stats/requests") class UserTasks(T...
Python
0
fea7f350ce711d183fd9011c43ca68fff88400eb
Add cython compile util
utils/cython_compile_libs.py
utils/cython_compile_libs.py
#!/bin/env python from __future__ import division, absolute_import, with_statement, print_function, unicode_literals import os import sys import shutil from pyximport.pyxbuild import pyx_to_dll WD = os.path.dirname(os.path.dirname((os.path.abspath(__file__)))) LIBS = os.path.join(WD, 'libs') # Adds the libs directory t...
Python
0.000001
d31f63a914877fe12d66497bdbc7dd6d871672fc
add solution for Best Time to Buy and Sell Stock
src/bestTimeToBuyAndSellStock.py
src/bestTimeToBuyAndSellStock.py
class Solution: # @param prices, a list of integer # @return an integer def maxProfit(self, prices): n = len(prices) if n < 2: return 0 min_price = prices[0] res = 0 for i in xrange(1, n): res = max(res, prices[i]-min_price) min_pr...
Python
0
595c8fad76696240f96e61d9a2299de3d6cda16a
Add utility for walking etree and yielding nodes if options class type match.
skcode/utility/walketree.py
skcode/utility/walketree.py
""" SkCode utility for walking across a document tree. """ def walk_tree_for_cls(tree_node, opts_cls): """ Walk the tree and yield any tree node matching the given options class. :param tree_node: The current tree node instance. :param opts_cls: The options class to search for. """ # Check th...
Python
0
4e50597100b5e84b1ed3c304a3a7323e7bab7918
Create removeSequence.py
removeSequence.py
removeSequence.py
#!/usr/bin/python ############################################################################### # # removeSequence.py version 1.0 # # Removes a specified nucleotide sequence from the beginning of a larger sequence # # Useful for preparing FASTA files for certain processing pipelines that do not # all...
Python
0.000001
b7d15547bd88c6304c5d8ceb1f74481cb4d162e7
Add parser hacking example
repeat_n_times.py
repeat_n_times.py
# -*- encoding: utf-8 -*- from jinja2 import Environment from jinja2.ext import Extension from jinja2 import nodes class RepeatNTimesExtension(Extension): tags = {"repeat"} def parse(self, parser): lineno = next(parser.stream).lineno index = nodes.Name("_", "store", lineno=lineno) h...
Python
0.000002
e3365aa8d9f5e49d3aff732d169c22a46ef22904
Create viriback_tracker.py (#452)
plugins/feeds/public/viriback_tracker.py
plugins/feeds/public/viriback_tracker.py
import logging from dateutil import parser from datetime import timedelta, datetime from core import Feed from core.errors import ObservableValidationError from core.observables import Url, Ip class ViriBackTracker(Feed): default_values = { "frequency": timedelta(hours=24), "name": "ViriBackTrack...
Python
0
5a5c30e701220cc874d08a442af0e81d2020aacf
bump dev version
symposion/__init__.py
symposion/__init__.py
__version__ = "1.0b1.dev43"
__version__ = "1.0b1.dev42"
Python
0
85336dfed46145c36307f218612db7c4d8dbf637
bump version
symposion/__init__.py
symposion/__init__.py
__version__ = "1.0b1.dev18"
__version__ = "1.0b1.dev17"
Python
0
c642a32b1aff0c9adc8e62aad8ceb7e0396512ed
bump version
symposion/__init__.py
symposion/__init__.py
__version__ = "1.0b1.dev14"
__version__ = "1.0b1.dev13"
Python
0
c36a954dbdfcca6e520dca6b96c1c97f496880ca
Add test for forcefield_labeler
smarty/tests/test_forcefield_labeler.py
smarty/tests/test_forcefield_labeler.py
from functools import partial import smarty import openeye from openeye.oechem import * import os from smarty.utils import get_data_filename import numpy as np from smarty.forcefield_labeler import * def test_read_ffxml(): """Test reading of ffxml files. """ labeler = ForceField_labeler(get_data_filename(...
Python
0
7d1fde66e0fd6b3b8cc9876e0d3271d6776b347f
convert tiffs to video added
image_to_video.py
image_to_video.py
# -*- coding: utf-8 -*- """ Created on Tue May 15 16:11:55 2018 @author: LaVision """ #!/usr/local/bin/python3 import cv2 import argparse import os # Construct the argument parser and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-ext", "--extension", required=False, default='png', help="exten...
Python
0.001017
f67514bf9ed193c0a8ac68c2258913bb54df8a88
Create save_py_source.py
save_py_source.py
save_py_source.py
import datetime, os, zipfile exts = '.py pyui'.split() zip_file_name = 'aa_source_code_%Y_%m_%d_%H_%M_%S.zip' zip_file_name = datetime.datetime.strftime(datetime.datetime.now(), zip_file_name) def get_filenames(in_dir=None): def visit(_, dirname, names): for name in names: filename = os.path.j...
Python
0
2519e7c8289a6045208013b0958fc4c9f49ff39a
lexographic permutations: python
lexographic_permutations/python/lexographic_permutations.py
lexographic_permutations/python/lexographic_permutations.py
import itertools def permute(input): if len(input) == 2: return [input, input[::-1]] permutations = [] for i in range(0,len(input)): permutations.append(map(lambda x: input[i]+x, permute(input[:i]+input[i+1:]))) return sum(permutations, []) def prepend(str1, str2): return str1+str2 print permute("012345678...
Python
0.999828
c7c02febb43eb2466484f5c99d6dcc2d60e67e09
add docker.py
zblogsite/settings/docker.py
zblogsite/settings/docker.py
from .base import * DEBUG = True DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'zblog', # Or path to database file if using sqlite3. # The following settings are not used wi...
Python
0.000004
f60f31c73deef7768af5eb45046a8848f2dc40c4
Create draw_neural_net.py
draw/draw_neural_net.py
draw/draw_neural_net.py
import matplotlib.pyplot as plt def draw_neural_net(ax, left, right, bottom, top, layer_sizes): ''' Draw a neural network cartoon using matplotilb. :usage: >>> fig = plt.figure(figsize=(12, 12)) >>> draw_neural_net(fig.gca(), .1, .9, .1, .9, [4, 7, 2]) :parameters: - a...
Python
0.000023
041b55f3a9ded360146f6e2dda74a6b20b3e6f7e
Add scrape_results
scrape_results.py
scrape_results.py
from selenium import webdriver from time import sleep from bs4 import BeautifulSoup driver = webdriver.Firefox() driver.get("http://www.nitt.edu/prm/ShowResult.htm") driver.get("javascript:(function(){document.getElementsByName('main')[0].contentWindow.document.getElementById('TextBox1').value=110113006;}());") dri...
Python
0
5745bf81a32915cb85a60093dc2a7123e5814767
Add personal problem 001
problems/001_parse_navs_from_markdown.py
problems/001_parse_navs_from_markdown.py
"""从 Markdown 文本中解析出目录信息 现在有格式如下的文档: ```markdown * [目录 1](chapter1/1.md) * [目录 1.1](chapter1/1-1.md) * [目录 1.1.1](chapter1/1-1-1.md) * [目录 2](chapter2/1.md) ``` 要求写一个解析器,解析返回所有目录信息,并包含层级关系。返回的示例数据如下。 ```python [ { 'name': '目录 1', 'path': 'chaper1/1.md', 'chapters': [ {...
Python
0.999571
dc52b5914c4d0024458eefeb3b3576aa58692345
Remove print
organizations/decorators.py
organizations/decorators.py
# encoding: utf-8 from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, HttpResponse from seaserv import get_user_current_org def org_staff_required(func): """ Decorator for views that checks the user is org staff. """ def _decorated(request, *args, **kwargs): ...
# encoding: utf-8 from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, HttpResponse from seaserv import get_user_current_org def org_staff_required(func): """ Decorator for views that checks the user is org staff. """ def _decorated(request, *args, **kwargs): ...
Python
0.000016
55bf42057bcd9e14d964b2064f9322c164ba91ff
Test request construction (#91)
test/test_requests.py
test/test_requests.py
import unittest import requests import requests_mock import tableauserverclient as TSC class RequestTests(unittest.TestCase): def setUp(self): self.server = TSC.Server('http://test') # Fake sign in self.server._site_id = 'dad65087-b08b-4603-af4e-2887b8aafc67' self.server._auth_t...
Python
0
69c3e33df15dca13cf310062216525dfbe98639e
add spectandus for index analysis
spectandus.py
spectandus.py
#!/usr/bin/env python # Author: Eben Olson <eben.olson@gmail.com> # Licensed under the MIT license <http://opensource.org/licenses/MIT> import logging from colorlog import ColoredFormatter import plac import sys import json from fs import zipfs from collections import defaultdict formatter = ColoredFormatter( "%(...
Python
0
35f98c14a74e207c616fcb57538bb176842c0d1e
Add procfile and wsgi entrypoint
nhs/wsgi.py
nhs/wsgi.py
""" WSGI config for Nhs Prescriptions project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPL...
Python
0
ebd41d7f264de92be19347042749ef48d5820b7d
add inner product demo
study/language_core_and_lib/function/functional_example.py
study/language_core_and_lib/function/functional_example.py
def demo_inner_product(): vec0 = range(10) vec1 = [i ** 2 for i in range(10)] print 'inner product:', reduce(lambda l, r: l + r, map(lambda ele: ele[0] * ele[1], zip(vec0, vec1)), 0) print 'verify:', sum([i ** 3 for i in range(10)]) if __name__ == '__main__': demo_inner_product()
Python
0
1193f4b234ec4c7d3f390dbaa39883b4d4d41802
Create multi_threaded_head_request.py
multi_threaded_head_request.py
multi_threaded_head_request.py
#!/usr/bin/env python ''' Author: Christopher Duffy Date: April 2015 Name: multi_threaded.py Purpose: To identify live web applications with a list of IP addresses, using concurrent processes ''' import urllib2, argparse, sys, math, threading, logging, Queue, time queue = Queue.Queue() lock = threading.Lock() class A...
Python
0
7bd3d26427c08cf38f2f7dedbf075e1335447f70
add config for database
config/database.py
config/database.py
mongorc = { 'host': '127.0.0.1', 'port': 27017, 'db': 'demo' }
Python
0.000001
f3325695a78f528af6f3c2adb6024dc71405af8f
Create kaynaksız_sil.py
kaynaksız_sil.py
kaynaksız_sil.py
# -*- coding: utf-8 -*- # !/usr/bin/python from bs4 import BeautifulSoup import requests import mavri import re import random xx= mavri.login('tr.wikipedia','Mavrikant Bot') wiki='tr.wikipedia' template='Şablon:Kaynaksız' ticontinue = '' while ticontinue != 'DONE': allpages= requests.get('https://' + wiki + '....
Python
0.000032
118e47c2bc307d8de447e9d37973feca44763ab5
Create __init__.py
packs/astral/actions/lib/__init__.py
packs/astral/actions/lib/__init__.py
from .BaseAction import BaseAction
Python
0.000429
f5c56152771fbafc5ac9161ccd453a240bfca5cc
Add get_history example.
examples/get_history.py
examples/get_history.py
import sys sys.path.append('../') import zabbix from datetime import datetime from datetime import timedelta from calendar import timegm # read config file config = {} execfile("config.py", config) # new api instance server = config["server"] api = zabbix.Api(server) # log in username = config["user"] password = co...
Python
0
26afdc032087693d274966a803a6bb3c77d17549
add request example
examples/request/req.py
examples/request/req.py
from app import Application def dump(request): text = """ Method: {0.method} Path: {0.path} Version: {0.version} Headers: {0.headers} Match: {0.match_dict} Body: {0.body} QS: {0.query_string} query: {0.query} mime_type: {0.mime_type} encoding: {0.encoding} form: {0.form} keep_alive: {0.keep_alive} route: {0.route}...
Python
0
b84a2667b5071ede3eb983364195c3a2d3c97543
Create MQTTstage.py
MQTTstage.py
MQTTstage.py
#!/usr/bin/python #Check if the def CheckDirectories():
Python
0.000006