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
9fe4ce918456a3470cf4eb50212af9a487c03ce4
add tests for utils
corehq/apps/auditcare/tests/test_auditcare_migration.py
corehq/apps/auditcare/tests/test_auditcare_migration.py
from django.test.testcases import TransactionTestCase from corehq.apps.auditcare.models import AuditcareMigrationMeta from datetime import datetime from unittest.mock import patch from django.test import SimpleTestCase from corehq.apps.auditcare.management.commands.copy_events_to_sql import Command from corehq.apps.au...
Python
0
cee2683d3c0a60739b8e4f1c1dbaa74981a42392
add class skeleton for schedule generator
angular_flask/classtime/scheduler.py
angular_flask/classtime/scheduler.py
class Scheduler(object): """ Helper class which builds optimal schedules out of class listings. Use static methods only - do not create instances of the class. """ def __init__(self): pass @staticmethod def generate_schedule(classtimes): """ Generates one g...
Python
0
82e4c67bd7643eed06e7cd170ca1d0de41c70912
Add a data analyzer class.
core/data/DataAnalyzer.py
core/data/DataAnalyzer.py
""" DataAnalyzer :Authors: Berend Klein Haneveld """ class DataAnalyzer(object): """ DataAnalyzer """ def __init__(self): super(DataAnalyzer, self).__init__() @classmethod def histogramForData(cls, data, nrBins): """ Samples the image data in order to create bins for making a histogram of the data. ...
Python
0
3f85610873d88592970c64661e526b2a576e300f
Add new sms message generator
sms_generator.py
sms_generator.py
def generate_new_procedure_message(procedure, ward, timeframe, doctor): unique_reference = str(1) message = str.format("{0} is available on {1}. Attend the ward in {2} and meet {3} in the junior doctors' office. " "To accept this opportunity reply with {4}", pro...
Python
0.000003
926631d068a223788714cd645ae5336881c6853f
Update messageable.py
praw/models/reddit/mixins/messageable.py
praw/models/reddit/mixins/messageable.py
"""Provide the MessageableMixin class.""" from ....const import API_PATH class MessageableMixin: """Interface for classes that can be messaged.""" def message(self, subject, message, from_subreddit=None): """ Send a message to a redditor or a subreddit's moderators (mod mail). :param...
"""Provide the MessageableMixin class.""" from ....const import API_PATH class MessageableMixin: """Interface for classes that can be messaged.""" def message(self, subject, message, from_subreddit=None): """ Send a message to a redditor or a subreddit's moderators (mod mail). :param...
Python
0.000001
73bd8200f6ad23c60a05831e3b79497b830f19cd
Update old lithium comments about llvm-symbolizer 3.6 to 3.8 versions.
interestingness/envVars.py
interestingness/envVars.py
#!/usr/bin/env python # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/. import copy import os import platform isLinux = (platform.system() == 'Linux') isMac = (platfor...
#!/usr/bin/env python # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/. import copy import os import platform isLinux = (platform.system() == 'Linux') isMac = (platfor...
Python
0
378cb69d413eb8ffaf811b607fc037be923a2aba
Write tests for SSLRedirectMiddleware
iogt/tests/test_middleware.py
iogt/tests/test_middleware.py
from django.test import ( TestCase, Client, RequestFactory, override_settings, ) from molo.core.tests.base import MoloTestCaseMixin from molo.core.models import Main from iogt.middleware import SSLRedirectMiddleware PERMANENT_REDIRECT_STATUS_CODE = 301 @override_settings(HTTPS_PATHS=['admin']) cla...
Python
0
e0ac456eae45a1b7e1482ff712be600b384f94b3
Include new example to show group circle connectivity.
examples/connectivity/plot_custom_grouped_connectivity_circle.py
examples/connectivity/plot_custom_grouped_connectivity_circle.py
#!/usr/bin/env python """ Example how to create a custom label groups and plot grouped connectivity circle with these labels. Author: Praveen Sripad <pravsripad@gmail.com> Christian Kiefer <ch.kiefer@fz-juelich.de> """ import matplotlib.pyplot as plt from jumeg import get_jumeg_path from jumeg.connectivity i...
Python
0
f50efeb78d9b503a7d6e97db8b1cd68b429aa2c4
allow to run tox as 'python -m tox', which is handy on Windoze
tox/__main__.py
tox/__main__.py
from tox._cmdline import main main()
Python
0
f7e504652707b09c0a0b7e7b1691094ef6d35509
add proper tomography example
examples/solvers/conjugate_gradient_tomography.py
examples/solvers/conjugate_gradient_tomography.py
# Copyright 2014-2016 The ODL development group # # This file is part of ODL. # # ODL 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. #...
Python
0.998527
236d7d885dadcb681357212a5c6b53c28eac0aa1
Create d1-1.py
2018/d1-1.py
2018/d1-1.py
with open("completed/input_c1-1.txt", "r") as f: line = "0" sum = 0 while line: sum += int(line) line = f.readline() print("Final Frequency: {}", sum)
Python
0.000001
8de92e74317a74b53991bdcbb3594f0e94e4cf17
Add Monty Hall simulation
montyhall.py
montyhall.py
import random import sys def game(): # Place car behind one door car = random.randint(1, 3) # Player selects a door first_choice = random.randint(1, 3) reveal_options = [1, 2, 3] # Don't reveal the car reveal_options.remove(car) # Don't reveal the player's choice if first_choice in...
Python
0
b177a0f2e9b42347f56c4499aaa080af97e0e530
add validity check
2018/04.10/python/jya_gAPIclass.2.py
2018/04.10/python/jya_gAPIclass.2.py
import requests, base64 import config id = config.GAPI_CONFIG['client_id'] secret = config.GAPI_CONFIG['client_secret'] type = config.GAPI_CONFIG['grant_type'] class GapiClass: def __init__(self, host='https://gapi.gabia.com'): self.__host = host self.__headers = self.__encoded_token() sel...
Python
0.000001
8e8e11990e430302eca24d32ba0b88dcc66233d6
Add connect2 wifi via pyobjc
clburlison_scripts/connect2_wifi_pyobjc/connect2_wifi_pyobjc.py
clburlison_scripts/connect2_wifi_pyobjc/connect2_wifi_pyobjc.py
#!/usr/bin/python """ I didn't create this but I'm storing it so I can reuse it. http://stackoverflow.com/a/34967364/4811765 """ import objc SSID = "MyWifiNetwork" PASSWORD = "MyWifiPassword" objc.loadBundle('CoreWLAN', bundle_path='/System/Library/Frameworks/CoreWLAN.framework', modul...
Python
0
2c8370f164525f6d6045836dbc20e4279b5c90fc
Create fme-python-shutdown-script.py
upload-geospatial-data/fme/fme-python-shutdown-script.py
upload-geospatial-data/fme/fme-python-shutdown-script.py
import fme import os import shutil import zipfile import boto3 # fuction to upload your data to aws S3 def UploadFile(source_file, bucket, bucket_key, aws_key, aws_secret): fname = str(source_file).split('\\')[-1:][0] session = boto3.session.Session(aws_access_key_id=aws_key, aws_secret_access_key=aws_secr...
Python
0.000016
a6d6b833e33dc465b0fa828018e2cbba748f8282
Add utility class for evaluation
pygraphc/evaluation/EvaluationUtility.py
pygraphc/evaluation/EvaluationUtility.py
class EvaluationUtility(object): @staticmethod def convert_to_text(graph, clusters): # convert clustering result from graph to text new_clusters = {} for cluster_id, nodes in clusters.iteritems(): for node in nodes: members = graph.node[node]['member'] ...
Python
0
a2a2d6ab7edaa6fab9d2fb95586fde8f1f74b1cc
add new package (#24672)
var/spack/repos/builtin/packages/py-aniso8601/package.py
var/spack/repos/builtin/packages/py-aniso8601/package.py
# Copyright 2013-2021 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 PyAniso8601(PythonPackage): """A library for parsing ISO 8601 strings.""" homepage = ...
Python
0
0ee3990781488c54b3d45c722b843a06a28da235
Add test that explores exploitability of tilted agents
verification/action_tilted_agents_exploitability_test.py
verification/action_tilted_agents_exploitability_test.py
import unittest import numpy as np import os import matplotlib.pyplot as plt import acpc_python_client as acpc from tools.constants import Action from weak_agents.action_tilted_agent import create_agent_strategy_from_trained_strategy, TiltType from tools.io_util import read_strategy_from_file from evaluation.exploita...
Python
0.000001
f9a8642e3c5cfbce2e949c019dce3d538eefcd43
Juan Question
JuanQuestion/Juan.py
JuanQuestion/Juan.py
from string import uppercase from string import lowercase if __name__ == '__main__': asking = True print("Juan Questions") print("Presione 1 para salir") while asking == True: response = input("Pregunta algo: ") if response.endswith("?") : print("Ofi") ...
Python
0.999983
0c9c3a801077c241cc32125ab520746935b04f89
Create LAElectionResults.py
LAElectionResults.py
LAElectionResults.py
# The MIT License (MIT) # Copyright (C) 2014 Allen Plummer, https://www.linkedin.com/in/aplummer # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limit...
Python
0
6a6abadc2395810076b89fb38c759f85426a0304
Add framework for own SVM from scratch
supportVectorMachine/howItWorksSupportVectorMachine.py
supportVectorMachine/howItWorksSupportVectorMachine.py
# -*- coding: utf-8 -*- """Support Vector Machine (SVM) classification for machine learning. SVM is a binary classifier. The objective of the SVM is to find the best separating hyperplane in vector space which is also referred to as the decision boundary. And it decides what separating hyperplane is the 'best' because...
Python
0
020779ae0f8a13b70981f174d6391a2cf3b6593a
Add tests for api model validation and default values.
st2common/tests/unit/test_api_model_validation.py
st2common/tests/unit/test_api_model_validation.py
# Licensed to the StackStorm, Inc ('StackStorm') under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use th...
Python
0
2e1c257c0215f398e4ac5cc7d2d20ffa62492817
Create NewChatAlert.pyw
NewChatAlert.pyw
NewChatAlert.pyw
# TODO: Check for cookie expiration # TODO: Check for failed request # TODO: Check for rejected cookie # TODO: Get Cookie from other browsers (IE and Firefox) # - See https://bitbucket.org/richardpenman/browser_cookie (and perhaps contribute)? from os import getenv from sqlite3 import connect from win32crypt imp...
Python
0
1d4938232aa103ea2a919796e9fa35e2699d41d9
Create PythonAnswer2.py
PythonAnswer2.py
PythonAnswer2.py
def fibonacci(x): a = 0 #first number b = 1 #second number for x in range(x - 1): a, b = b, a + b #a becomes b and b becomes a and b added together return a #returns the next number in the sequence print "Fibonacci Answer" for x in range(1, 35): #number of times I need the sequenc...
Python
0.999202
a6887ccd608b90b9f78fa4422850752686ed3897
set no proxy for querying the triplestore
QueryLauncher.py
QueryLauncher.py
#! /usr/bin/env python # -*- coding: utf-8 -*- import os, time, tempfile from pprint import pformat from SPARQLWrapper import SPARQLWrapper, JSON import requests import logging import urllib.request from askomics.libaskomics.ParamManager import ParamManager class SPARQLError(RuntimeError): """ The SPARQLError...
Python
0
5c60be411e61d5edfbf658509b437973d596a3ba
Create server.py
Networking/server.py
Networking/server.py
# -*- coding: utf-8 -*- import socket, math # demarrage du serveur server = "127.0.0.1" port = 55042 mysock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) mysock.bind((server, port)) JOG_IP = [None,None,None,None,None,None,None,None,None,None] JOG_coordinates= [None,None,None,None,None,None,None,None,None,None] ...
Python
0.000001
92ec849fc18d7cb610839abe2213ce30ceced46b
Add ci settings file for postgresql database
InvenTree/InvenTree/ci_postgresql.py
InvenTree/InvenTree/ci_postgresql.py
""" Configuration file for running tests against a MySQL database. """ from InvenTree.settings import * # Override the 'test' database if 'test' in sys.argv: eprint('InvenTree: Running tests - Using MySQL test database') DATABASES['default'] = { # Ensure postgresql backend is being used '...
Python
0
f7db5d9cac80432a7016043a1b2781fbaa7f040e
Create new package. (#6891)
var/spack/repos/builtin/packages/r-rappdirs/package.py
var/spack/repos/builtin/packages/r-rappdirs/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
6d2efcea281775c31cd1df29eac63054e3fe51df
Create solution.py
data_structures/linked_list/problems/delete_n_after_m/py/solution.py
data_structures/linked_list/problems/delete_n_after_m/py/solution.py
import LinkedList # Problem description: # Solution time complexity: # Comments: # Linked List Node inside the LinkedList module is declared as: # # class Node: # def __init__(self, val, nxt=None): # self.val = val # self.nxt = nxt # def DeleteNAfterMNodes(head: Li...
Python
0.000018
c84ce4b2494771c48890c122420e4665828ac4f8
Solve Code Fights different rightmost bit problem
CodeFights/differentRightmostBit.py
CodeFights/differentRightmostBit.py
#!/usr/local/bin/python # Code Different Right-most Bit (Core) Problem def differentRightmostBit(n, m): return (n ^ m) & -(n ^ m) def main(): tests = [ [11, 13, 2], [7, 23, 16], [1, 0, 1], [64, 65, 1], [1073741823, 1071513599, 131072], [42, 22, 4] ] f...
Python
0.00005
8d0d564eae53a10b98b488b8c13eb952134cfc5e
Create 0408_country_body_part.py
2018/0408_country_body_part.py
2018/0408_country_body_part.py
#!/usr/bin/python ''' NPR 2018-04-08 http://www.npr.org/puzzle Name part of the human body, insert a speech hesitation, and you'll name a country โ€” what is it? ''' from nltk.corpus import gazetteers import nprcommontools as nct #%% BODY_PARTS = nct.get_category_members('body_part') # COUNTRIES COUNTRIES = frozenset...
Python
0.000023
61ec74a685deec0b1ddc0a9274e5df0a597c6b6b
Create TweetStreamer.py
TweetStreamer.py
TweetStreamer.py
import tweepy from tweepy import Stream from tweepy import OAuthHandler from tweepy.streaming import StreamListener import json from elasticsearch import Elasticsearch import datetime from watson_developer_cloud import NaturalLanguageUnderstandingV1 import watson_developer_cloud.natural_language_understanding.features....
Python
0.000001
3345dc2f1ac15f06d3e95b5ead894ee9d3a27d9e
Add file writer utility script
piwrite.py
piwrite.py
#!/bin/env python import argparse import sys import os parser = argparse.ArgumentParser(description="Write multiple svgs from stdin to files") parser.add_argument('-o', '--outfile', metavar='OUTFILE', default='output.svg') args = parser.parse_args() base, extension = os.path.splitext(args.outfile) def write_files...
Python
0.000001
7147dfc237acb64a8e655e63681a387282043994
Add lc0031_next_permutation.py
lc0031_next_permutation.py
lc0031_next_permutation.py
"""Leetcode 31. Next Permutation Medium URL: https://leetcode.com/problems/next-permutation/ Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascen...
Python
0.000001
46d5b197e022815c2074fbc94ca324d31d470dd0
Implement a fasttext example (#3446)
examples/imdb_fasttext.py
examples/imdb_fasttext.py
'''This example demonstrates the use of fasttext for text classification Based on Joulin et al's paper: Bags of Tricks for Efficient Text Classification https://arxiv.org/abs/1607.01759 Can achieve accuracy around 88% after 5 epochs in 70s. ''' from __future__ import print_function import numpy as np np.random.see...
Python
0
dde0efeec1aca8ed3ec2e444bbb4c179be89fec5
Create MooreNeightbourhood.py
Checkio/MooreNeightbourhood.py
Checkio/MooreNeightbourhood.py
def count_neighbours(grid, row, col): neig = 0 if (col - 1 >= 0): if (grid[row][col - 1] == 1): neig += 1 if (col - 1 >= 0 and row - 1 >= 0): if (grid[row - 1][col -1] == 1): neig += 1 if (row - 1 >= 0): if (grid[row - 1][col] == 1): neig += 1 ...
Python
0
5dd5bf4b189d7a9af64ebad29cfdaceb013a9e6f
Create Classes.py
Sharing/reports/Classes.py
Sharing/reports/Classes.py
import pprint # Allows Pretty Print of JSON ############################################# # Define a Class to represent a group ############################################# class Group: def __init__(self): self.group_name = '' self.group_members = '' self.group_permission = '' self.gr...
Python
0
a3df0567c295f0b2879c9a4f095a31108359d531
Add missing migration for invoice status
nodeconductor/billing/migrations/0003_invoice_status.py
nodeconductor/billing/migrations/0003_invoice_status.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('billing', '0002_pricelist'), ] operations = [ migrations.AddField( model_name='invoice', name='statu...
Python
0
269a34e87797a3271013e23d504a6f6a159ae48e
Index testgroup_test.test_id
migrations/versions/3a3366fb7822_index_testgroup_test.py
migrations/versions/3a3366fb7822_index_testgroup_test.py
"""Index testgroup_test.test_id Revision ID: 3a3366fb7822 Revises: 139e272152de Create Date: 2014-01-02 22:20:55.132222 """ # revision identifiers, used by Alembic. revision = '3a3366fb7822' down_revision = '139e272152de' from alembic import op def upgrade(): op.create_index('idx_testgroup_test_test_id', 'tes...
Python
0.000011
7b40a4902d1dc43c73a7858fc9286a641b3a9666
Add validation function removed from main script.
assess_isoform_quantification/options.py
assess_isoform_quantification/options.py
from schema import Schema def validate_file_option(file_option, msg): msg = "{msg} '{file}'.".format(msg=msg, file=file_option) return Schema(open, error=msg).validate(file_option)
Python
0
d04118acc5421d4b48e31c78874a740eb469c3d7
fix boan1244 'Boรƒยซng'
migrations/versions/506dcac7d75_fix_boan1244_mojibake.py
migrations/versions/506dcac7d75_fix_boan1244_mojibake.py
# coding=utf-8 """fix boan1244 mojibake Revision ID: 506dcac7d75 Revises: 4513ba6253e1 Create Date: 2015-04-15 19:20:59.059000 """ # revision identifiers, used by Alembic. revision = '506dcac7d75' down_revision = '4513ba6253e1' import datetime from alembic import op import sqlalchemy as sa def upgrade(): id,...
Python
0.000001
85e4a327ba641fbe9c275b4760c60683ca215d61
Add unit tests.
test_pto.py
test_pto.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """Tests for PTO.""" import unittest import pto import time _TIMEOUT = 5 _FUZZ_FACTOR = 1 class SlowClass(object): @pto.timeout(_TIMEOUT) def slow_instance_method(self): cut_off = time.time() + _TIMEOUT while time.time() < cut_off + _FUZZ_FACTO...
Python
0
2067bdb9d0f9947a674cb94d0c988049f3038ea4
create test stubs
test_viz.py
test_viz.py
def test_create_distance_matrix(): pass def test_get_translation_table(): pass def test_naive_backtranslate(): pass def test_get_peptide_index(): pass def test_demo_dna_features_viewer(): pass def test_ngrams(): pass def test_make_trigrams(): pass def test_nucleotide_distribution(): ...
Python
0.000002
e304aae71617cdba0ffcb720a24406375fb866a1
Copy of Ryan's PCMToWave component.
Sketches/MH/audio/ToWAV.py
Sketches/MH/audio/ToWAV.py
from Axon.Component import component import string import struct from Axon.Ipc import producerFinished, shutdown class PCMToWave(component): def __init__(self, bytespersample, samplingfrequency): super(PCMToWave, self).__init__() self.bytespersample = bytespersample self.samplingfrequency =...
Python
0.000002
19b283e2810b98da275ff60d0e0632e2337f4375
Add vde evaluate script.
test/vde.py
test/vde.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # std import import sys import argparse import os.path from collections import defaultdict import csv import re def main(): """ The main function of vde no argument """ enable_input = [name.split("2")[0] for name in globals().keys() if name....
Python
0
16275938769c16c79b89349612e8e7b2891de815
Add migration for user manager
kolibri/auth/migrations/0008_auto_20180222_1244.py
kolibri/auth/migrations/0008_auto_20180222_1244.py
# -*- coding: utf-8 -*- # Generated by Django 1.9.13 on 2018-02-22 20:44 from __future__ import unicode_literals import kolibri.auth.models from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('kolibriauth', '0007_auto_20171226_1125'), ] operations = [ ...
Python
0.000001
74450edae5d327659ec618f7e160bc5dd37bd512
ๆทปๅŠ ๅœจPython2DWrapperไธญไฝฟ็”จ็š„Pythonๆ–‡ไปถ
PluginSDK/BasicRecon/Python/Py2C.py
PluginSDK/BasicRecon/Python/Py2C.py
from PIL import Image import numpy as np import matplotlib """ This is Module Py2C for c++ """ class A: pass class B: pass def ShowImage(image, width, height): img = [[]] * width for x in range(width): for y in range(height): img[x] = img[x] + [image[x*width...
Python
0
883aac8a282d4525e82d3eb151ea293c5577424c
Add data migration to create gesinv
core/migrations/0002_auto_20141008_0853.py
core/migrations/0002_auto_20141008_0853.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations def create_extra_users(apps, schema_editor): user = apps.get_model("auth.User").objects.create(username='GesInv-ULL') apps.get_model("core", "UserProfile").objects.create(user=user, ...
Python
0
eceffd58e62378287aacab29f4849d0a6e983e49
Factor out the timestamp-related functionality to a class that outputs json strings
src/Timestamp.py
src/Timestamp.py
#!/usr/bin/python import time class Timestamp: hour = -1 minute = -1 def __init__(self, date): self.year = int(date[0:4]) self.month = int(self.month_name_to_num(date[5:8])) self.day = int(date[9:11]) try: self.hour = int(date[12:14]) self.minute = int(date[15:17]) except ValueError...
Python
0.999997
e6181c5d7c95af23ee6d51d125642104782f5cf1
Add solution for 136_Single Number with XOR operation.
Python/136_SingleNumber.py
Python/136_SingleNumber.py
class Solution(object): def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ #Using XOR to find the single number. #Because every number appears twice, while N^N=0, 0^N=N, #XOR is cummutative, so the order of elements does not matter. ...
Python
0
83ebfe1ff774f8d5fb5ae610590ca8fca1c87100
add migration for on_delete changes
app/backend/wells/migrations/0034_auto_20181127_0230.py
app/backend/wells/migrations/0034_auto_20181127_0230.py
# Generated by Django 2.1.3 on 2018-11-27 02:30 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('wells', '0033_auto_20181119_1857'), ] operations = [ migrations.AlterField( model_name='activit...
Python
0
59c62bb0f13be7910bf2280126a0909ffbe716f0
Create simple_trie.py
simple_trie.py
simple_trie.py
class Trie: def __init__(self): self.node = {} self.word = None def add(self,string): node = self.node currentNode = None for char in string: currentNode = node.get(char, None) if not currentNode: node[char] = Trie() ...
Python
0.000002
983f041b25b0de77f3720378e12b22e7d8f2e040
Create same_first_last.py
Python/CodingBat/same_first_last.py
Python/CodingBat/same_first_last.py
# http://codingbat.com/prob/p179078 def same_first_last(nums): return ( len(nums) >= 1 and nums[0] == nums[-1] )
Python
0.00113
ae6c6f3aa0863b919e0f00543cab737ae9e94129
Add bubblesort as a placeholder for a refactored implementation
bubblesort.py
bubblesort.py
#!/usr/bin/env python # TBD: Sort animation could take a pattern that it assumed to be "final", # shuffle it, then take a sort generator that produced a step in the sort # algorithm at every call. It would be sorting shuffled indices that the # animation would use to construct each frame. from blinkytape import blink...
Python
0
3852ae6fcf6271ef19a182e5dfb199e4539536a1
Create 6kyu_spelling_bee.py
Solutions/6kyu/6kyu_spelling_bee.py
Solutions/6kyu/6kyu_spelling_bee.py
from itertools import zip_longest as zlo def how_many_bees(hive): return sum(''.join(x).count('bee') + ''.join(x).count('eeb') for x in hive) + \ sum(''.join(y).count('bee') + ''.join(y).count('eeb') for y in zlo(*hive, fillvalue = '')) if hive else 0
Python
0.000103
ddb58206a52ef46f5194bf6f5c11ac68b16ab9a8
Create minimum-window-subsequence.py
Python/minimum-window-subsequence.py
Python/minimum-window-subsequence.py
# Time: O(S * T) # Space: O(S) class Solution(object): def minWindow(self, S, T): """ :type S: str :type T: str :rtype: str """ dp = [[None for _ in xrange(len(S))] for _ in xrange(2)] for i, c in enumerate(S): if c == T[0]: dp[0]...
Python
0.00046
eaca815937ebd1fbdd6ec5804dc52257d2775181
Create time-gui.py
time-gui.py
time-gui.py
from tkinter import * import time import sys import datetime as dt from datetime import timedelta def validateTextInputSize(event): """ Method to Validate Entry text input size """ global TEXT_MAXINPUTSIZE if (event.widget.index(END) >= TEXT_MAXINPUTSIZE - 1): event.widget.delete(TEXT_MAX...
Python
0.000002
077d4b8954918ed51c43429efd74b4911083c4f4
Add instance_id field.
kolibri/content/migrations/0002_auto_20160630_1959.py
kolibri/content/migrations/0002_auto_20160630_1959.py
# -*- coding: utf-8 -*- # Generated by Django 1.9.1 on 2016-06-30 19:59 from __future__ import unicode_literals from django.db import migrations, models import kolibri.content.models import uuid class Migration(migrations.Migration): dependencies = [ ('content', '0001_initial'), ] operations = ...
Python
0
48172fa94043fb004dfaf564afac42e632be2bc0
add test for DataManager
mpf/tests/test_DataManager.py
mpf/tests/test_DataManager.py
"""Test the bonus mode.""" import time from unittest.mock import mock_open, patch from mpf.file_interfaces.yaml_interface import YamlInterface from mpf.core.data_manager import DataManager from mpf.tests.MpfTestCase import MpfTestCase class TestDataManager(MpfTestCase): def testSaveAndLoad(self): YamlIn...
Python
0
8d0f6ed81377e516c5bb266894a8cf39b6852383
add multiple rsi sample
examples/multi_rsi.py
examples/multi_rsi.py
# ๅฏไปฅ่‡ชๅทฑimportๆˆ‘ไปฌๅนณๅฐๆ”ฏๆŒ็š„็ฌฌไธ‰ๆ–นpythonๆจกๅ—๏ผŒๆฏ”ๅฆ‚pandasใ€numpy็ญ‰ใ€‚ import talib import numpy as np import math import pandas # ๅœจ่ฟ™ไธชๆ–นๆณ•ไธญ็ผ–ๅ†™ไปปไฝ•็š„ๅˆๅง‹ๅŒ–้€ป่พ‘ใ€‚contextๅฏน่ฑกๅฐ†ไผšๅœจไฝ ็š„็ฎ—ๆณ•็ญ–็•ฅ็š„ไปปไฝ•ๆ–นๆณ•ไน‹้—ดๅšไผ ้€’ใ€‚ def init(context): #้€‰ๆ‹ฉๆˆ‘ไปฌๆ„Ÿๅ…ด่ถฃ็š„่‚ก็ฅจ context.s1 = "000001.XSHE" context.s2 = "601988.XSHG" context.s3 = "000068.XSHE" context.stocks = [context.s1,con...
Python
0
859b3de112549f070e7b56901b86d40e8b8c1f51
update scorer
lib/scorer.py
lib/scorer.py
import numpy as np import pandas as pd import json #from SPARQLWrapper import SPARQLWrapper, JSON from collections import defaultdict from operator import itemgetter from sklearn.metrics.pairwise import cosine_similarity, linear_kernel import optparse from ranking import ndcg_at_k, average_precision def scorer(embed...
Python
0.000001
3dcfc2f7e9a2ed696a2b4a006e4d8a233a494f2f
move sitemap to core
djangobb_forum/sitemap.py
djangobb_forum/sitemap.py
from django.contrib.sitemaps import Sitemap from djangobb_forum.models import Forum, Topic class SitemapForum(Sitemap): priority = 0.5 def items(self): return Forum.objects.all() class SitemapTopic(Sitemap): priority = 0.5 def items(self): return Topic.objects.all()
Python
0
a6f26893189376f64b6be5121e840acc4cfeebae
ADD utils.py : model_to_json / expand_user_database methods
packages/syft/src/syft/core/node/common/tables/utils.py
packages/syft/src/syft/core/node/common/tables/utils.py
# grid relative from .groups import Group from .usergroup import UserGroup from .roles import Role def model_to_json(model): """Returns a JSON representation of an SQLAlchemy-backed object.""" json = {} for col in model.__mapper__.attrs.keys(): if col != "hashed_password" and col != "salt": ...
Python
0.000004
d7d0af678a52b357ecf479660ccee1eab43c443f
Add gender choices model
accelerator/models/gender_choices.py
accelerator/models/gender_choices.py
# MIT License # Copyright (c) 2017 MassChallenge, Inc. from __future__ import unicode_literals import swapper from accelerator_abstract.models import BaseGenderChoices class GenderChoices(BaseGenderChoices): class Meta(BaseGenderChoices.Meta): swappable = swapper.swappable_setting( BaseGen...
Python
0.000534
f64fbffcaab11f9532880c55c89c0bb0bd42cec8
Add missing images
nclxd/nova/virt/lxd/images.py
nclxd/nova/virt/lxd/images.py
# Copyright (c) 2015 Canonical Ltd # # 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 ...
Python
0.000002
95edeaa711e8c33e1b431f792e0f2638126ed461
Add test case for dynamic ast
pymtl/tools/translation/dynamic_ast_test.py
pymtl/tools/translation/dynamic_ast_test.py
#======================================================================= # verilog_from_ast_test.py #======================================================================= # This is the test case that verifies the dynamic AST support of PyMTL. # This test is contributed by Zhuanhao Wu through #169, #170 of PyMTL v2. #...
Python
0.000002
49cab51aa8697a56c7cf74e45b77d9a20ad1a178
add topk/gen.py
topk/gen.py
topk/gen.py
#!/usr/bin/python import random word_len = 5 alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-' output = open('word_count', 'w') words = set() N = 1000*1000 for x in xrange(N): arr = [random.choice(alphabet) for i in range(word_len)] words.add(''.join(arr)) print len(words) for wo...
Python
0
c5da52c38d280873066288977f021621cb9653d0
Apply orphaned migration
project/apps/api/migrations/0010_remove_chart_song.py
project/apps/api/migrations/0010_remove_chart_song.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('api', '0009_auto_20150722_1041'), ] operations = [ migrations.RemoveField( model_name='chart', name=...
Python
0
ab5d1fd5728b9c2f27d74c2896e05a94b061f3f9
add config.py
config.py
config.py
# twilio account details account = "" token = ""
Python
0.000002
42cc2864f03480e29e55bb0ef0b30e823c11eb2f
complete check online window
check_online_window.py
check_online_window.py
import tkinter as tk import tkinter.messagebox as tkmb from online_check import CheckSomeoneOnline class open_check_online_window(): def __init__(self, x, y): self.co = tk.Tk() self.co.title('enter ip to check') self.co.resizable(False, False) self.co.wm_attributes("-toolwindow", 1)...
Python
0
956da3bc7ff7971b9b6cc76495fcb5b2e4145d6e
Handle smtplib.SMTPRecipientsRefused and defer the message properly.
mailerdev/mailer/engine.py
mailerdev/mailer/engine.py
import time import smtplib from lockfile import FileLock from socket import error as socket_error from models import Message, DontSendEntry, MessageLog from django.core.mail import send_mail as core_send_mail ## configuration settings # @@@ eventually move to settings.py # when queue is empty, how long to wait (in ...
import time from lockfile import FileLock from socket import error as socket_error from models import Message, DontSendEntry, MessageLog from django.core.mail import send_mail as core_send_mail ## configuration settings # @@@ eventually move to settings.py # when queue is empty, how long to wait (in seconds) before...
Python
0.000377
05b9859fb7d4577dfa95ec9edd3a6f16bf0fd86e
Create __init__.py
fade/fade/__init__.py
fade/fade/__init__.py
Python
0.000429
f9b5ac91ae53f643c8aca2bab7eb0cb8b6a997cd
add script to split text in sentences
add_sentences.py
add_sentences.py
# -*- coding: utf-8 -*- import os import argparse from lxml import etree import fnmatch import time import json import nltk def timeit(method): """Time methods.""" def timed(*args, **kw): ts = time.time() result = method(*args, **kw) te = time.time() print('%r %2.2f sec' % ...
Python
0.000087
1b6fecb5819fbead0aadcc1a8669e915542c5ea0
Add script for gameifying testing
other/testing-game.py
other/testing-game.py
#!/usr/bin/python # -*- coding: utf-8 -*- import argparse import os import subprocess import re parser = argparse.ArgumentParser() parser.add_argument('-d', '--directory', help='The directory to search for files in', required=False, default=os.getcwd()) args = parser.parse_args() names = {} for root, dirs, files in...
Python
0
908013aa5e64589b6c1c6495812a13109244a69a
add dottests testconfig, but leave it deactivted yet. lots of import failures, since no imports are declared explicitly
src/icalendar/tests/XXX_test_doctests.py
src/icalendar/tests/XXX_test_doctests.py
from interlude import interact import doctest import os.path import unittest OPTIONFLAGS = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS DOCFILES = [ 'example.txt', 'groupscheduled.txt', 'multiple.txt', 'recurrence.txt', 'small.txt' ] DOCMODS = [ 'icalendar.caselessdict', 'icalendar.cal...
Python
0
4a99dcd629a830ad1ec0c658f312a4793dec240b
add basic file for parser
RedBlue/Parser3.py
RedBlue/Parser3.py
class Parser(object): @classmethod def read_html(cls, html): pass
Python
0.000001
3fee2399901bfc91b5eb5dfc71d17b008dd4b7fb
Add limit protection tests
keystone/tests/unit/protection/v3/test_limits.py
keystone/tests/unit/protection/v3/test_limits.py
# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # d...
Python
0.000002
0648ca26ba195e4d5ce55d801975a161907e655f
Add test for translation
aldryn_faq/tests/test_aldryn_faq.py
aldryn_faq/tests/test_aldryn_faq.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.test import TestCase # , TransactionTestCase # from django.utils import translation from hvad.test_utils.context_managers import LanguageOverride from aldryn_faq.models import Category, Question EN_CAT_NAME = "Example" EN_CAT_SLUG = "examp...
Python
0.000001
d1f71e1c6468799247d07d810a6db7d0ad5f89b0
add support for jinja2 template engine
alaocl/jinja2.py
alaocl/jinja2.py
from alaocl import * #__all__ = ( # 'addOCLtoEnvironment', #) _FILTERS = { 'asSet': asSet, 'asBag': asBag, 'asSeq': asSeq, } _GLOBALS = { 'floor': floor, 'isUndefined': isUndefined, 'oclIsUndefined': oclIsUndefined, 'oclIsKindOf': oclIsKindOf, 'oclIsTypeOf': oclIsTypeOf, 'isColl...
Python
0
04142e3bd0c09e6f712669529e780a18c11c7076
Add script to validate files are valid DocBook.
validate.py
validate.py
#!/usr/bin/env python ''' Usage: validate.py [path] Validates all xml files against the DocBook 5 RELAX NG schema. Options: path Root directory, defaults to <repo root>/doc/src/doc/docbkx Ignores pom.xml files and subdirectories named "target". Requires Python 2.7 or greater (for argparse) and the lxml...
Python
0.000001
7cb62f554fa293a2ba4d0456ed8d04e8f277d2c1
Add migrations/0146_clean_lexeme_romanised_3.py
ielex/lexicon/migrations/0146_clean_lexeme_romanised_3.py
ielex/lexicon/migrations/0146_clean_lexeme_romanised_3.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals, print_function from django.db import migrations def forwards_func(apps, schema_editor): Lexeme = apps.get_model("lexicon", "Lexeme") replaceMap = { 'ฮป': 'สŽ', 'ฯ†': 'ษธ' } for lexeme in Lexeme.objects.all(): if l...
Python
0
8f1b1ef01e74782f57da9c9489a3a7f6555bbee6
Add tests for reports views.
annotran/reports/test/views_test.py
annotran/reports/test/views_test.py
# -*- coding: utf-8 -*- import mock import pytest from pyramid import httpexceptions from annotran.reports import views _SENTINEL = object()
Python
0
691ae15cb0f46400762c27305fb74f57fa1ffccf
Implement account.py
src/account.py
src/account.py
from datetime import datetime from hashlib import md5 from re import match, search, DOTALL from requests.sessions import Session from bs4 import BeautifulSoup BASE_URL = 'https://usereg.tsinghua.edu.cn' LOGIN_PAGE = BASE_URL + '/do.php' INFO_PAGE = BASE_URL + '/user_info.php' class Account(object): """Tsinghua Ac...
Python
0.000009
940299a7bfd967653899b176ce76e6f1cf02ca83
Add script to generate pairs of LIWC categories
liwcpairs2es.py
liwcpairs2es.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from elasticsearch import Elasticsearch, helpers from collections import Counter from datetime import datetime def find_pairs(list1, list2): pairs = [] if list1 and list2: for item1 in list1: for item2 in list2: pairs.append(u'{...
Python
0
73292532767d736a77ec8b122cfd4ff19b7d991b
Create Account dashboard backend
UI/account_dash.py
UI/account_dash.py
# -*- coding: utf-8 -*- import threading from PyQt4 import QtCore, QtGui from qt_interfaces.account_dash_ui import Ui_AccountDash from engine import StorjEngine from utilities.tools import Tools # Synchronization menu section # class AccountDashUI(QtGui.QMainWindow): def __init__(self, parent=None,): QtG...
Python
0.000001
53258a9ffd869dd958fd818874b2c8406acca143
add pytest for util.store
pytests/util/test_store.py
pytests/util/test_store.py
import pytest import util.store @pytest.fixture def emptyStore(): return util.store.Store() @pytest.fixture def store(): return util.store.Store() def test_get_of_unset_key(emptyStore): assert emptyStore.get("any-key") == None assert emptyStore.get("any-key", "default-value") == "default-value" ...
Python
0
5bde5b5904abc30506e56865cd58fd88a97942aa
Add `deprecated` decorator
linux/keyman-config/keyman_config/deprecated_decorator.py
linux/keyman-config/keyman_config/deprecated_decorator.py
#!/usr/bin/python3 # based on https://stackoverflow.com/a/40301488 import logging string_types = (type(b''), type(u'')) def deprecated(reason): if isinstance(reason, string_types): # The @deprecated is used with a 'reason'. def decorator(func1): def new_func1(*args, **kwargs): ...
Python
0.000001
f6519493dd75d7f5a8b65a952b5d7048bd101ec4
Create locationanalysis.py
locationanalysis.py
locationanalysis.py
import json print 'test' f = open('location.json', 'r') jsoncontent = f.read() print jsoncontent location = json.loads(jsoncontent) print len(location)
Python
0.000001
f6d417e69efa4554008bc441a5c82a5b9f93a082
Add sql.conventions.objects.Items
garage/sql/conventions/objects.py
garage/sql/conventions/objects.py
__all__ = [ 'Items', ] from garage.functools import nondata_property from garage.sql.utils import insert_or_ignore, make_select_by class Items: """A thin layer on top of tables of two columns: (id, value)""" def __init__(self, table, id_name, value_name): self.table = table self.value_na...
Python
0.003446
313f5c8c54002a736a323410c5d9ec96fcc2f50b
Create RespostaVer.py
backend/Models/Predio/RespostaVer.py
backend/Models/Predio/RespostaVer.py
from Framework.Resposta import Resposta from Models.Campus.Campus import Campus as ModelCampus class RespostaVer(Resposta): def __init__(self,campus): self.corpo = ModelCampus(campus)
Python
0
95f5b7cd2325a61f537bffb783e950b30c97da5f
Add a demo about learning the shape parameter of gamma dist
bayespy/demos/gamma_shape.py
bayespy/demos/gamma_shape.py
from bayespy import nodes from bayespy.inference import VB def run(): a = nodes.GammaShape(name='a') b = nodes.Gamma(1e-5, 1e-5, name='b') tau = nodes.Gamma(a, b, plates=(1000,), name='tau') tau.observe(nodes.Gamma(10, 20, plates=(1000,)).random()) Q = VB(tau, a, b) Q.update(repeat=1000)...
Python
0
d90bab60bf5f5423a7fee57ece8cd44acba113c1
setup the environment and print the 'Hello World'
Base/D_00_HelloWorld.py
Base/D_00_HelloWorld.py
__author__ = 'James.Hongnian.Zhang' # This is my first Python program. # This means I have setup the environment for Python. # Download it from https://www.python.org and install it. # Then add it to your PATH # That's it. print 'Hello World'
Python
0.999999
3c618e8424e64a62168c2a2c683748d2496ef7cb
Add Urban Dictionary module.
modules/urbandictionary.py
modules/urbandictionary.py
"""Looks up a term from urban dictionary @package ppbot @syntax ud <word> """ import requests import json from modules import * class Urbandictionary(Module): def __init__(self, *args, **kwargs): """Constructor""" Module.__init__(self, kwargs=kwargs) self.url = "http://www.urbandictiona...
Python
0
d8fff759f2bff24f20cdbe98370ede9e5f3b7b13
Add 2D helmholtz convergence test
convergence_tests/2D_helmholtz.py
convergence_tests/2D_helmholtz.py
from __future__ import absolute_import, division from firedrake import * import numpy as np def helmholtz_mixed(x, V1, V2): # Create mesh and define function space mesh = UnitSquareMesh(2**x, 2**x) V1 = FunctionSpace(mesh, *V1, name="V") V2 = FunctionSpace(mesh, *V2, name="P") W = V1 * V2 # D...
Python
0
c98109af519241a28c40217e8378a19903d4db0b
fix broken logic for fluff calcs using indicator_calculator
corehq/fluff/calculators/xform.py
corehq/fluff/calculators/xform.py
from datetime import timedelta from corehq.fluff.calculators.logic import ANDCalculator, ORCalculator import fluff def default_date(form): return form.received_on # operators EQUAL = lambda input, reference: input == reference NOT_EQUAL = lambda input, reference: input != reference IN = lambda input, reference_li...
from datetime import timedelta from corehq.fluff.calculators.logic import ANDCalculator, ORCalculator import fluff def default_date(form): return form.received_on # operators EQUAL = lambda input, reference: input == reference NOT_EQUAL = lambda input, reference: input != reference IN = lambda input, reference_li...
Python
0.000001
5206a15d59bc8881629c48bb4136bb1a9cb7b4d0
Create ms_old_identifiers.py
identifiers/ms_old_identifiers.py
identifiers/ms_old_identifiers.py
from identifier import * import collections CFBInfo = collections.namedtuple('CFBInfo', ['name', 'descripion', 'pattern']) OFFICE_PATTERNS = [ 'D0 CF 11 E0 A1 B1 1A E1' ] FILE_PATTERNS = [ CFBInfo('DOC', 'Microsoft Word 97-2003', bytes.fromhex('EC A5 C1 20')), CFBInfo('XLS', 'Microsoft Excel 97-2003',...
Python
0.000111
835a7b9bea1b006b5a096665d706b64b778d45ab
fix default param
python/federatedml/ensemble/test/hack_encrypter.py
python/federatedml/ensemble/test/hack_encrypter.py
class HackDecrypter(): def encrypt(self, val): return val def decrypt(self, val): return val
Python
0.000002
aeb671484bc8e68a8aba3eaa80523ae153b8e9c9
Add files via upload
youtube_list.py
youtube_list.py
from apiclient.discovery import build from apiclient.errors import HttpError from oauth2client.tools import argparser import pafy DEVELOPER_KEY = "AIzaSyCsrKjMf7_mHYrT6rIJ-oaA6KL5IYg389A" YOUTUBE_API_SERVICE_NAME = "youtube" YOUTUBE_API_VERSION = "v3" def youtube_search(options): youtube = build(YOUTUBE_API_SERVIC...
Python
0
0770fab7c4985704e2793ab98150c9f1a2729e01
Create easy_17_ArrayAdditionI.py
easy_17_ArrayAdditionI.py
easy_17_ArrayAdditionI.py
import itertools ################################################# # This function will see if there is any # # possible combination of the numbers in # # the array that will give the largest number # ################################################# def ArrayAdditionI(arr): #sort, remove last ele...
Python
0.000034
1cc15f3ae9a0b7fa5b2dae4bcdd9f0f3c061ce4d
Fix relate_name on Bug model
reclama/sprints/migrations/0002_auto_20150130_1751.py
reclama/sprints/migrations/0002_auto_20150130_1751.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('sprints', '0001_initial'), ] operations = [ migrations.AlterField( model_name='bug', name='event', ...
Python
0