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
08fcba713315b4ac29ed30f437b7c5c0b1da5a9d
Create make_upper_case.py
make_upper_case.py
make_upper_case.py
def sillycase(string): half = round(len(string)/2) // Find the half index return string[:half].lower() + string[half:].upper() // If you only want certain letters to be upper case //
Python
0.000391
9e986214aaf6beef5b1778254cc348006a828c04
Create MaximalSquare_001.py
leetcode/221-Maximal-Square/MaximalSquare_001.py
leetcode/221-Maximal-Square/MaximalSquare_001.py
# brute force, optimized later class Solution(object): def maximalSquare(self, matrix): """ :type matrix: List[List[str]] :rtype: int """ if len(matrix) == 0 or len(matrix[0]) == 0: return 0 maxv = 0 for i in range(len(matrix)): ...
Python
0.000018
6b6c5b836b282c53fc5a337942d187769d0a87ed
Add cli module.
fapistrano/cli.py
fapistrano/cli.py
# -*- coding: utf-8 -*- import click import yaml from fabric.api import env as fabenv, local, execute from fapistrano.app import init_cli from fapistrano.utils import with_configs, register_role, register_env, _apply_env_role_config from fapistrano import deploy @click.group() @click.option('-d', '--deployfile', defa...
Python
0
8c8fd14e320038d67bddd536cdd68f2aa4e73a59
Add main source file
fcm_playground.py
fcm_playground.py
#!/usr/bin/python3 #TODO Clicks außerhalb des Wertebereichs behandeln! import tkinter as tk from tkinter import ttk import matplotlib matplotlib.use("TkAgg") from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg from matplotlib.figure import Figure import numpy as np import os cla...
Python
0
9341d2192da8cbaea734641aec9567a1035aa1ee
Add suffix list
scripts/update-suffixlist.py
scripts/update-suffixlist.py
#!/usr/bin/env python import os import urllib2 as urllib import anyjson as json URL_LIST = "http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/src/effective_tld_names.dat?raw=1" # generate json print 'downloading suffix list..' rules = {} lst = urllib.urlopen(URL_LIST).read() print 'processing list..' lines =...
Python
0.000004
a1d95beccd0f0f332005cd133bdd660fbe649467
Add a benchmarking script.
benchmarking/perf_cmp.py
benchmarking/perf_cmp.py
#!/usr/bin/env python """ TODO: Change the module doc. """ from __future__ import division __author__ = "shyuepingong" __version__ = "0.1" __maintainer__ = "Shyue Ping Ong" __email__ = "shyuep@gmail.com" __status__ = "Beta" __date__ = "11/19/12" import numpy as np from scipy.spatial import Delaunay from pyhull.qco...
Python
0
8de30c6d4b5784af406d75e04feeb7c6431243d6
add fermi setup
astroquery/fermi/setup_package.py
astroquery/fermi/setup_package.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import os def get_package_data(): paths_test = [os.path.join('data', '*.html')] return { 'astroquery.fermi.tests': paths_test, }
Python
0
fc32e0d04569dab20cfc1b3b991bfbd8b067d62e
Add the manager to persist the data received from the OSM adapters
moveon/managers.py
moveon/managers.py
from django.db import models from moveon.models import Line, Station, Node class OSMLineManager(models.Manager): def __init__(self, osmline): self.osmline = osmline self.stations = dict() self.routes = [] self.nodes = dict() self.stretches = dict() def save(self): ...
Python
0.99898
59a05f592ffc4423023f1803efcf427896ab5d41
Add lc0695_max_area_of_island.py
lc0695_max_area_of_island.py
lc0695_max_area_of_island.py
"""Leetcode 695. Max Area of Island Medium URL: https://leetcode.com/problems/max-area-of-island/ Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. Find...
Python
0.000004
b8b191a380ef4ab0701793c2e0ac664b05c4c505
Add simple word2vec to train model
analysis/word2vec.py
analysis/word2vec.py
import numpy as np import re from nltk.corpus import stopwords import nltk import logging from gensim.models import word2vec def get_dataset(): files = ['./analysis/input/negative_tweets.txt', './analysis/input/neutral_tweets.txt', './analysis/input/positive_tweets.txt'] x = [] for file in files: ...
Python
0.000011
a0333aa80dd6a6baeb24e32deeecd0288419328e
Initialize P3_seatingCards
books/AutomateTheBoringStuffWithPython/Chapter17/PracticeProjects/P3_seatingCards.py
books/AutomateTheBoringStuffWithPython/Chapter17/PracticeProjects/P3_seatingCards.py
# Chapter 13 included a practice project to create custom invitations from a list of # guests in a plaintext file. As an additional project, use the pillow module to # create images for custom seating cards for your guests. For each of the guests listed # in the guests.txt, generate an image file with the guest name an...
Python
0.000002
1e45df8375c4e72257defc82137fa570fbb44249
add StringOperation to repository
StringOperation.py
StringOperation.py
#encoding = utf-8 __author__ = 'lg' list1 = ['java','python','ruby','perl','mac'] list2 = ['linux','mac','windows','ruby'] #两个list的交集(法一) 时间复杂度为O(n^2) def intersect(a,b): listRes = [] for i in range(len(a)): for j in range(len(b)): if a[i] == b[j]: if a[i] not in listRes: ...
Python
0
59d55a5911e99a0886b8c3cc48ee92f247e96e0a
add Voronoi
Voronoi/Voronoi.py
Voronoi/Voronoi.py
import numpy as np import matplotlib.pyplot as plt from scipy.spatial import Voronoi, voronoi_plot_2d import csv COUNT_LIMIT = None SAMPLE_LIMIT = 100 Points = [] with open('cell_info.csv', 'r', encoding='utf_8') as obj_file: csv_file = csv.reader(obj_file) for cnt, line in enumerate(csv_file): if CO...
Python
0
de0265b609ab56035544018e368a108b573ae503
define the index of filters to prune by examining the classification activations
tools/prune_with_classification_guidance.py
tools/prune_with_classification_guidance.py
import os.path import numpy as np # define th CLASSES and indices CLASSES = ('__background__', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sof...
Python
0
5068c02e50c54c08a6991e45584c6c9b9bdd5dba
add import script for Midlothian
polling_stations/apps/data_collection/management/commands/import_midlothian.py
polling_stations/apps/data_collection/management/commands/import_midlothian.py
from data_collection.management.commands import BaseScotlandSpatialHubImporter class Command(BaseScotlandSpatialHubImporter): council_id = 'S12000019' council_name = 'Midlothian' elections = ['local.midlothian.2017-05-04'] def district_record_to_dict(self, record): code = str(record[0]).strip(...
Python
0
a1e4a93db7c683f51d42f776f5d48db613127346
add test cases of m9dicts.dicts
m9dicts/tests/dicts.py
m9dicts/tests/dicts.py
# # Copyright (C) 2011 - 2016 Satoru SATOH <ssato @ redhat.com> # # pylint: disable=missing-docstring,invalid-name from __future__ import absolute_import import unittest import m9dicts.dicts as TT class Test_10_UpdateWithReplaceDict(unittest.TestCase): od0 = TT.OrderedDict((("a", 1), ("b", [1, 3]), ("c", "abc"),...
Python
0.000004
db846aaa0f35e8888b0b3423539c0a70c9ae16fa
Add Source Files
source/GoogleSpreadsheets.py
source/GoogleSpreadsheets.py
# -*- coding: utf-8 -*- import sys import requests import easygui def enum(*sequential, **named): enums = dict(zip(sequential, range(len(sequential))), **named) return type('Enum', (), enums) Mode = enum('PREVIEW', 'EDIT', 'REFRESH') mode = 0 size = 0 params = '' key = '' i = 0 for i in range(len(sys.ar...
Python
0.000001
f3594e901e2b43a0f87252dd63df41f370372d04
Create climate_change.py
src/homework2/climate_change.py
src/homework2/climate_change.py
# -*- coding: utf-8 -*- """ Created on Sat Jul 22 16:56:59 2017 """ # climate change project #files required: # 1)data.csv => contains # -station ID => Index[0] # -temperature => Index[3] # 2)site_detail.csv => contains: # -station ID => Index[0] # -Latitude => Index[2] # -Longitude => Index[3] ...
Python
0.001314
c185786a189b2934e69334089e180c725d59a391
Add a test that exposes the association copy/paste issue
tests/test_multiple_associations.py
tests/test_multiple_associations.py
""" Test issues where associations are copied and pasted, deleted, etc. Scenario's: * Class and association are pasted in a new diagramg * Class and association are pasted in a new diagram and original association is deleted * Class and association are pasted in a new diagram and new association is deleted * Associati...
Python
0.000001
107f86c8c20c4d7cc4c81db464ac20607bb31ba9
add DBusTube constants to constants.py
tests/twisted/constants.py
tests/twisted/constants.py
""" Some handy constants for other tests to share and enjoy. """ HT_CONTACT = 1 CHANNEL = "org.freedesktop.Telepathy.Channel" CHANNEL_IFACE_GROUP = CHANNEL + ".Interface.Group" CHANNEL_TYPE_TUBES = CHANNEL + ".Type.Tubes" CHANNEL_IFACE_TUBE = CHANNEL + ".Interface.Tube.DRAFT" CHANNEL_TYPE_STREAM_TUBE = CHANNEL + ".Ty...
""" Some handy constants for other tests to share and enjoy. """ HT_CONTACT = 1 CHANNEL = "org.freedesktop.Telepathy.Channel" CHANNEL_IFACE_GROUP = CHANNEL + ".Interface.Group" CHANNEL_TYPE_TUBES = CHANNEL + ".Type.Tubes" CHANNEL_IFACE_TUBE = CHANNEL + ".Interface.Tube.DRAFT" CHANNEL_TYPE_STREAM_TUBE = CHANNEL + ".Ty...
Python
0
b9b246e1feb728a257b343d4a07fc42ba10bac13
Add a wsgi app to our test tg2 app
moksha/tests/quickstarts/tg2app/tg2app/wsgi.py
moksha/tests/quickstarts/tg2app/tg2app/wsgi.py
import os from paste.deploy import loadapp cfg_path = os.path.join(os.path.dirname(__file__), '..', 'development.ini') application = loadapp('config:' + cfg_path)
Python
0
3299cd9a931e6b564ebb5031a7e515155dab97c9
Create blast.py
blast.py
blast.py
#! /bin/bash/env python from Applications import NcbiblastpCommandline import math import os from decimal import * import settings added = [] class Blaster(object): def __init__(self): pass def blast(self, evalue): # create a database and conduct the all-vs-all BLAST search against it print 'Creating databas...
Python
0.000001
550ce185895a7b32f6bdb0750338ea6d2416ee2a
Add merged migration
organization/projects/migrations/0006_merge.py
organization/projects/migrations/0006_merge.py
# -*- coding: utf-8 -*- # Generated by Django 1.9.7 on 2016-09-07 14:02 from __future__ import unicode_literals from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('organization-projects', '0005_auto_20160907_1046'), ('organization-projects', '0005_auto_2016...
Python
0.000001
f6148d7a4e2d080da93d21de2f13b601465c7528
Add tf.contrib.checkpoint.CheckpointableBase for isinstance checks.
tensorflow/contrib/checkpoint/__init__.py
tensorflow/contrib/checkpoint/__init__.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
7ef03c975566b92fd97b7071b39cf3d8c242e480
Create brick.py
brick.py
brick.py
# Class: Brick # Represents a single brick as displayed on screen. # Used as a target for the Ball to break # Requires pygame import pygame class Brick(pygame.sprite.Sprite): __borderWidth = 2 __hitsRemaining = 1 __position = {"x": 0, "y": 0} __size = 25 __whRatio = {"width": 2, "height": 1} _...
Python
0.000004
e52697b80f771cc5f585c4927199bf95e8f04511
Test for searching questions
test/selenium_src/search_question_test.py
test/selenium_src/search_question_test.py
# -*- coding: utf-8 -*- from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import NoAlertPresentException...
Python
0
c1d3a8d15d3e50a14ff765e7abd063cc1b390063
add new test case TestAssociator
tests/unit/EventReader/test_Associator.py
tests/unit/EventReader/test_Associator.py
from AlphaTwirl.EventReader import Associator import unittest ##____________________________________________________________________________|| class MockReader(object): def __init__(self): self.content = [ ] ##____________________________________________________________________________|| class MockCollect...
Python
0.000001
6a4152e805be0ba061529841fb84442d8a23ff9f
add label transform cpn
python/federatedml/components/label_transform.py
python/federatedml/components/label_transform.py
# # Copyright 2019 The FATE 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 appl...
Python
0
99ab22cf5fcba719dd7d9d87c18c8d93de5591a4
Add IO Class
whitepy/ws_io.py
whitepy/ws_io.py
import readchar import sys class IO(object): def __init__(self, stack): self.stack = stack def i_chr(self, heap): self.stack.push(readchar.readchar()) heap.set() def i_int(self, heap): num = None while type(num) is not int: try: num = i...
Python
0
6279341682ae45a228302972dbd106a2e44e0b12
Add example usage of the JsonTestResponse.
examples/example_test.py
examples/example_test.py
import unittest from flask import Flask from flask_json import json_response, FlaskJSON, JsonTestResponse def our_app(): app = Flask(__name__) app.test_value = 0 FlaskJSON(app) @app.route('/increment') def increment(): app.test_value += 1 return json_response(value=app.test_value)...
Python
0
73ed1a82698964533ffc313e2de68e6a4d63fe74
Manage templates in schemas (#51277)
lib/ansible/modules/network/aci/mso_schema_template.py
lib/ansible/modules/network/aci/mso_schema_template.py
#!/usr/bin/python # -*- coding: utf-8 -*- # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], ...
Python
0
1fd997bc11b62cb760470fb749c2a4f0261b3e00
Add db2es.py to sync data
db2es.py
db2es.py
#!/usr/bin/env python # -*- coding: UTF-8 -*- # from __future__ import unicode_literals, absolute_import import time from elasticsearch.helpers import scan from elasticsearch.exceptions import NotFoundError from oclubs.app import app from oclubs.access import database, elasticsearch, done from oclubs.objs import Ac...
Python
0.000001
43e019ff26e04a6464cad3a10045ba600e98610e
Add __init__.py for monitorlib module.
monitorlib/__init__.py
monitorlib/__init__.py
### -*- coding: utf-8 -*- ### ### © 2012 Krux Digital, Inc. ### Author: Paul Lathrop <paul@krux.com> ### """Library for creating monitoring scripts/plugins."""
Python
0
2427dbad4fc0cfe7685dc2767069748d37262796
Add initial version of identification algorithm
movienamer/identify.py
movienamer/identify.py
import os.path as path import re import Levenshtein from .sanitize import sanitize from .tmdb import search def _gather(filename, directory=None, titles={}): # Sanitize the input filename name, year = sanitize(filename) # Start with a basic search results = search(name, year) if year is not No...
Python
0.000001
2ac52ea39a7a8db6cab756e3af2f65b228bb1c09
Add registration test
test/requests/test-registration.py
test/requests/test-registration.py
import sys import unittest import requests import logging from elasticsearch import Elasticsearch, TransportError #from utility.tools import ELASTICSEARCH_HOST, ELASTICSEARCH_PORT GN2_SERVER = None ES_SERVER = None class TestRegistration(unittest.TestCase): def setUp(self): self.url = GN2_SERVER+"/n...
Python
0
8d93fead7767d75b73917c8f716467ebc153725b
Revert accidental untracking of file.
pyfr/bases/base.py
pyfr/bases/base.py
# -*- coding: utf-8 -*- import re from abc import ABCMeta, abstractmethod, abstractproperty import numpy as np from sympy.mpmath import mp from sympy.utilities.lambdify import lambdastr from pyfr.util import lazyprop, ndrange def lambdify_mpf(dims, exprs): # Perform the initial lambdification ls = [lambd...
Python
0
ee3e0d444dd706858a3a30cf52ebc2a960bcfb56
add a just for funsies pygame renderer
renderer-pygame.py
renderer-pygame.py
import pygame class Palette(): def __init__(self, ppu): self.ppu = ppu self.colors = [(0x7C,0x7C,0x7C),(00,00,0xFC),(00,00,0xBC),(44,28,0xBC),(94,00,84),(0xA8,00,20),(0xA8,10,00),(88,14,00),(50,30,00),(00,78,00),(00,68,00),(00,58,00),(00,40,58),(00,00,00),(00,00,00),(00,00,00),(0xBC,0xBC,0xBC),(00,...
Python
0
669a4880da91b93c0ba00a2c44ce02e583505f6c
Add a script to generate optical flow for vid files.
tools/data/gen_vid_optical_flow.py
tools/data/gen_vid_optical_flow.py
#!/usr/bin/env python import argparse import cv2 import os import glob import sys import numpy as np import scipy.io as sio import time from vdetlib.utils.protocol import proto_load, frame_path_at def cvReadGrayImg(img_path): return cv2.cvtColor(cv2.imread(img_path), cv2.COLOR_BGR2GRAY) def saveOptFlowToImage(flo...
Python
0
75f666ad189c5a799582ce567f0df8b7848066d5
replace spy solved
Lesson3/replace_spy.py
Lesson3/replace_spy.py
# Define a procedure, replace_spy, # that takes as its input a list of # three numbers, and modifies the # value of the third element in the # input list to be one more than its # previous value. spy = [0,0,7] def replace_spy(spy): spy[2] = spy[2] + 1 return spy # In the test below, the first line calls yo...
Python
0.002478
50769782cd3a0c3a26cf57b74ca03309b4e18255
Add fomap.py, WIP Fallout map parser
fomap.py
fomap.py
""" Copyright 2015 darkf 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 distribu...
Python
0
83e136a0e0d93d1dde4966322a3b51f453d0a1ba
Add simple CSV exporter to examples.
tcflib/examples/csv_exporter.py
tcflib/examples/csv_exporter.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import csv from io import StringIO from collections import OrderedDict from tcflib.service import ExportingWorker, run_as_cli class CSVExporter(ExportingWorker): def export(self): columns = OrderedDict() columns['tokenID'] = [token.id for token in...
Python
0
75cedb719385b70d08805483fbeda07222031f98
Add comparison MID generator script.
lumps/dmxgus/comparison.py
lumps/dmxgus/comparison.py
# Generate comparison MIDI file. # # The comparison MIDI is used for testing and tweaking the similarity # groups in the configuration file. In each group, the instruments in # the group should sound broadly similar, and the first in the group # should be able to substitute for any member of the group. # # Each similar...
Python
0
a509828f5d5040b1b005fe602ad0e53675b8cb52
add to test
test/solr_doc_manager_tester.py
test/solr_doc_manager_tester.py
import unittest import time from solr_doc_manager import SolrDocManager from pysolr import Solr class SolrDocManagerTester(unittest.TestCase): def __init__(self): super(SolrDocManagerTester, self).__init__() self.solr = Solr("http://localhost:8080/solr/") def runTest(self): #Invalid...
Python
0
4ca2ca05232357776e64a1e6eb76c0b26663a59e
add semigroup law tester
testers/semigroup_law_tester.py
testers/semigroup_law_tester.py
class SemigroupLawTester: def __init__(self, semigroup, value1, value2, value3): self.semigroup = semigroup self.value1 = value1 self.value2 = value2 self.value3 = value3 def associativity_test(self): x = self.semigroup(self.value1)\ .concat(self.semigr...
Python
0
e0a037a6418b31275b5a00a1f78959e6dc25be17
Add a script to fix bad svn properties
dev/scripts/fix_svn_properties.py
dev/scripts/fix_svn_properties.py
#!/usr/bin/evn python import sys import os import subprocess mapping = { '.c': [['svn:eol-style', 'native']], '.cpp': [['svn:eol-style', 'native']], '.h': [['svn:eol-style', 'native']], '.sh': [['svn:eol-style', 'native'], ['svn:executable', '']], '.cmd': [['svn:mime-type', 'text/plain'...
Python
0.000011
1c5fef3a34ed421610a4e9a38feb07e6545e5d13
Add tests for the `dirty_untar` rule
tests/rules/test_dirty_untar.py
tests/rules/test_dirty_untar.py
import os import pytest import tarfile from thefuck.rules.dirty_untar import match, get_new_command, side_effect from tests.utils import Command @pytest.fixture def tar_error(tmpdir): def fixture(filename): path = os.path.join(str(tmpdir), filename) def reset(path): with tarfile.TarFi...
Python
0.000003
c5276d469b08b3262490047f2372a477814cb2fc
add server test for statelessCompute
tests/stateless_compute_test.py
tests/stateless_compute_test.py
# -*- coding: utf-8 -*- u"""Test statelessCompute API :copyright: Copyright (c) 2021 RadiaSoft LLC. All Rights Reserved. :license: http://www.apache.org/licenses/LICENSE-2.0.html """ from __future__ import absolute_import, division, print_function from pykern.pkcollections import PKDict import pytest def test_madx_c...
Python
0
9b8069f66988ccdbfc76fdbbc7efb78285ed9900
Bump version to S22.1
src/ggrc/settings/default.py
src/ggrc/settings/default.py
# Copyright (C) 2013 Google Inc., authors, and contributors <see AUTHORS file> # Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file> # Created By: dan@reciprocitylabs.com # Maintained By: dan@reciprocitylabs.com DEBUG = False TESTING = False # Flask-SQLAlchemy fix to be less than `wait_time` ...
# Copyright (C) 2013 Google Inc., authors, and contributors <see AUTHORS file> # Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file> # Created By: dan@reciprocitylabs.com # Maintained By: dan@reciprocitylabs.com DEBUG = False TESTING = False # Flask-SQLAlchemy fix to be less than `wait_time` ...
Python
0
6c22f7bf2fe8db39446cddbd0fa9474486101a27
Add __init__, as django test finder isn't very smart
toolkit/diary/tests/__init__.py
toolkit/diary/tests/__init__.py
from __future__ import absolute_import from .test_edit_views import * from .test_mailout_view import * from .test_models import * from .test_public_views import *
Python
0.000013
623ea9e3d050f347eb404094d049a402b2bb367a
Create config.py
dasem/config.py
dasem/config.py
"""config""" from os.path import expanduser, join def data_directory(): return join(expanduser('~'), 'dasem_data')
Python
0.000002
e35586efcfc0af4dcfe02c005a1435767f5ab3ed
add merge_book_lists.py
douban_spider/merge_book_lists.py
douban_spider/merge_book_lists.py
# -*- coding: UTF-8 -*- import bloom_filter import sys # 把str编码由默认ascii(python2为ascii,python3为utf8)改为utf8 reload(sys) sys.setdefaultencoding('utf8') """ Merge book list files into one, using bloom filter to remove duplicate books """ def main(): file_name = 'book_list' bf = bloom_filter.BloomFilter(2000,14) with...
Python
0.000005
62fb38d0860b5feeee39764b6c66f5ceed39b984
Fix versions of protected/unprotected documents
alembic_migration/versions/077ddf78a1f3_fix_protected_docs_versions.py
alembic_migration/versions/077ddf78a1f3_fix_protected_docs_versions.py
"""Fix protected docs versions Revision ID: 077ddf78a1f3 Revises: 9739938498a8 Create Date: 2017-10-30 12:05:51.679435 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = '077ddf78a1f3' down_revision = '9739938498a8' branch_labels = None depends_on = None def upgr...
Python
0
ebd8d2fb86b925f3c75ddfea0bbe9d7ab60b50b7
add notes for subprocess module
abc/sub_process.py
abc/sub_process.py
# -*- coding: UTF-8 -*- __author__ = 'mcxiaoke' import subprocess # 创建子进程并等待它返回,参数是list subprocess.call(['ls', '-a']) # 同上,但是子进程返回值不是0时会抛异常 subprocess.check_call(['ls', '-a']) # subprocess.check_call(['ls2', '-la']) # 同上,但是返回值以字符串的形式返回 # 如果要捕获标准错误输出,可以用stderr=subprocess.STDOUT ret = subprocess.check_output(['ls', '-a...
Python
0
36b4e37972501ce9fa84e9d74a3cfe726681209e
Add tests for numpy array ufuncs
numba/tests/test_ufuncs.py
numba/tests/test_ufuncs.py
from __future__ import print_function import unittest import numpy as np from numba.compiler import compile_isolated, Flags from numba import types, utils from numba.tests import usecases enable_pyobj_flags = Flags() enable_pyobj_flags.set("enable_pyobject") force_pyobj_flags = Flags() force_pyobj_flags.set("force_py...
Python
0.000002
47f61ce40319100b7f226538a466c584d22d4f72
Add character filtering benchmark
iscc_bench/textid/bench_remove.py
iscc_bench/textid/bench_remove.py
# -*- coding: utf-8 -*- """Benchmark Character Removals [Cc] Other, Control [Cf] Other, Format [Cn] Other, Not Assigned (no characters in the file have this property) [Co] Other, Private Use [Cs] Other, Surrogate [LC] Letter, Cased [Ll] Letter, Lowercase [Lm] Letter, Modifier [Lo] Letter, Other [Lt] Letter, Titlecase ...
Python
0.000001
0e6fb27d26d5f0570baa414e679b96d6c3234491
add correct loop file (#8)
looptogetdata2.py
looptogetdata2.py
from urllib2 import Request, urlopen, URLError import json import pandas def getValidTimeseriesKey(timerseries_keys, offering_id): invalid_offering = '9999999999' if offering_id == invalid_offering: return timeseries_keys[1] else: return timeseries_keys[0] requestpoll = Request ('http://dd.eionet.europa.eu/voc...
Python
0
eb46f8046211eff81320faceda0c297b27bb419b
Add a new alert plugin for events from geomodel
alerts/geomodel.py
alerts/geomodel.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/. # Copyright (c) 2015 Mozilla Corporation # # Contributors: # Aaron Meihm <ameihm@mozilla.com> fro...
Python
0
6898b9462823449e767aa75b7ab38c3e87b61cc1
Check for page changes
macro/IsRecent.py
macro/IsRecent.py
# -*- coding: iso-8859-1 -*- u""" IsRecent - Check if a page was recently modified and highlight that fact @copyright: 2012 by Alan Snelson @license: BSD, see LICENSE for details. """ from datetime import datetime from MoinMoin.Page import Page Dependencies = ['pages'] def macro_IsRecent(...
Python
0
e8c64cff4daa8f563a2b19b933f89099f8a1a9b6
Remove socket session_id from all subscribed channels on disconnect.
django_socketio/views.py
django_socketio/views.py
from atexit import register from datetime import datetime from traceback import print_exc from django.http import HttpResponse from django_socketio import events from django_socketio.channels import SocketIOChannelProxy from django_socketio.settings import MESSAGE_LOG_FORMAT # Maps open Socket.IO session IDs to re...
from atexit import register from datetime import datetime from traceback import print_exc from django.http import HttpResponse from django_socketio import events from django_socketio.channels import SocketIOChannelProxy from django_socketio.settings import MESSAGE_LOG_FORMAT # Maps open Socket.IO session IDs to re...
Python
0
fe5369253a79b9ec42d8b438112cd7e0eb61955a
Add multiple viewport example
examples/multiple_viewports/main.py
examples/multiple_viewports/main.py
''' Created on 03/03/2012 @author: adam ''' import math from pyglet.gl import * import pyglet # over-ride the default pyglet idle loop import renderer.idle import renderer.window from renderer.viewport import Viewport from renderer.projection_view_matrix import ProjectionViewMatrix from scene.scene_...
Python
0.000001
6721275f1fcf23fc3dbca60590f010d9ead26a35
Add new module kdeconnector
py3status/modules/kdeconnector.py
py3status/modules/kdeconnector.py
# -*- coding: utf-8 -* """ Display information of your android device over KDEConnector. Configuration parameters: device: the device name, you need this if you have more than one device connected to your PC device_id: alternatively to the device name you can set your device id here format: see...
Python
0.000001
3587666f209a9e88672e9520c033682fcd28035a
add l10n_br_purchase/procurement.py
l10n_br_purchase/procurement.py
l10n_br_purchase/procurement.py
# -*- encoding: utf-8 -*- ############################################################################### # # # Copyright (C) 2014 Renato Lima - Akretion # # ...
Python
0
b1d643afb07cef02ab607943776ce120a7d47013
move unit test for matrix-vector conversion to new superoperator test module
qutip/tests/test_superoperator.py
qutip/tests/test_superoperator.py
# This file is part of QuTIP. # # QuTIP 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. # # QuTIP is distributed in the ...
Python
0
333a32f400697d3b4f4cc405615c9a7e511c959a
add movielens example
examples/movielens.py
examples/movielens.py
""" The script uses real-world data to conduct contextual bandit experiments. Here we use MovieLens 1M Dataset, which is released by GroupLens at 2/2003. Please fist download the dataset from http://grouplens.org/datasets/movielens/, then unzipped the file "ml-1m.zip" to the examples folder. """ import pandas as pd im...
Python
0.000001
b39dd2afea1f4662e17a927e7e6aa41e850f7470
Add a script for generating jamo character table
lib/gen-hangul.py
lib/gen-hangul.py
#!/usr/bin/python3 # Input: https://www.unicode.org/Public/UNIDATA/Jamo.txt import io import re class Builder(object): def __init__(self): pass def read(self, infile): chars = [] for line in infile: if line.startswith('#'): continue line = line...
Python
0
d35c1241600e4430f0f389b0ea4264ac70f6ba8e
Add DocstringSubstituteMeta metaclass and docstring helper functions.
prx/docstring_helpers.py
prx/docstring_helpers.py
# ---------------------------------------------------------------------------- # Copyright (c) 2018, 'prx' developers (see AUTHORS file) # All rights reserved. # # Distributed under the terms of the MIT license. # # The full license is in the LICENSE file, distributed with this software. # -----------------------------...
Python
0
415e3e1ae3a6c5689f3960d2b3f589cf2c733144
Create conf.py
conf.py
conf.py
# -*- coding: utf-8 -*- # import os # on_rtd is whether we are on readthedocs.org on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if not on_rtd: # only import and set the theme if we're building docs locally import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_them...
Python
0.000001
72f1dab3fe50a552480df522f6c8c4a7002a0952
Add TimestampsMixin exmples
examples/timestamp.py
examples/timestamp.py
from __future__ import print_function import time from datetime import datetime import sqlalchemy as sa from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import scoped_session, sessionmaker from sqlalchemy_mixins import TimestampsMixin Base = declarative_base() engine = sa.create_engine("s...
Python
0
7799b7a3ea1b1774ce24376ee918376b422daebd
Create cube.py
cube.py
cube.py
import numpy as np import pandas as pd import keras import pandas as pd import keras.preprocessing.text import somecode as some class Cube: ''' INTENDED USE > to be called through FastText() class. Takes in pandas dataframe with at least two columns where one is the dependent variable, ...
Python
0.000015
67d3b321edab1fe50f666d0ada86c8392be07199
add wire_callback
pyaudio/wire_callback.py
pyaudio/wire_callback.py
#!/usr/bin/env python """ PyAudio Example: Make a wire between input and output (i.e., record a few samples and play them back immediately). This is the callback (non-blocking) version. """ import pyaudio import time WIDTH = 2 CHANNELS = 2 RATE = 44100 p = pyaudio.PyAudio() def callback(in_data, frame_count, tim...
Python
0.000001
34815186871e27b977082d9c35dd0adc76d3af9f
update stencilview doc (128 levels, not 8)
kivy/uix/stencilview.py
kivy/uix/stencilview.py
''' Stencil View ============ .. versionadded:: 1.0.4 :class:`StencilView` limits the drawing of child widgets to the StencilView's bounding box. Any drawing outside the bounding box will be clipped (trashed). The StencilView uses the stencil graphics instructions under the hood. It provides an efficient way to clip...
''' Stencil View ============ .. versionadded:: 1.0.4 :class:`StencilView` limits the drawing of child widgets to the StencilView's bounding box. Any drawing outside the bounding box will be clipped (trashed). The StencilView uses the stencil graphics instructions under the hood. It provides an efficient way to clip...
Python
0
e8798ac01d3baed6785ee0683ec4989b97e47003
Implement local.shell operation
pyinfra/modules/local.py
pyinfra/modules/local.py
# pyinfra # File: pyinfra/modules/local.py # Desc: run stuff locally, within the context of operations from subprocess import Popen, PIPE import gevent from termcolor import colored from pyinfra.api import operation from pyinfra.api.util import read_buffer def _run_local(code, hostname, host, print_output=False, p...
Python
0.00018
a2b9a17927d851b368d3ef8e869a295c8bd2e86b
add test for default clustering order of SELECT
test/cql-pytest/test_clustering_order.py
test/cql-pytest/test_clustering_order.py
# Copyright 2022-present ScyllaDB # # SPDX-License-Identifier: AGPL-3.0-or-later ############################################################################# # Tests for clustering key ordering, namely the WITH CLUSTERING ORDER BY # setting in the table schema, and ORDER BY in select. # # We have many other tests for...
Python
0.000012
b602c3467ee5969bc3292b7e494d60b9ccdbbedb
remove sum or c number
qutip/tests/test_rand.py
qutip/tests/test_rand.py
#This file is part of QuTIP. # # QuTIP 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. # # QuTIP is distributed in the ho...
#This file is part of QuTIP. # # QuTIP 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. # # QuTIP is distributed in the ho...
Python
0.025778
796561ed822d64be6fd2ef299093711a8534d0e9
add package py-lmodule version 0.1.0 (#18856)
var/spack/repos/builtin/packages/py-lmodule/package.py
var/spack/repos/builtin/packages/py-lmodule/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 PyLmodule(PythonPackage): """Lmodule is a Python API for Lmod module system. It's primary ...
Python
0
f3bf91c8a9ba3a043f0ba4a11c2347e9b4a3c8be
Add linkins.script
linkins/script.py
linkins/script.py
import logging import subprocess log = logging.getLogger(__name__) log.propagate = False handler = logging.StreamHandler() fmt = logging.Formatter( fmt='%(script)s: %(stream)s: %(message)s', ) handler.setFormatter(fmt) log.addHandler(handler) def _logscript(fp, **kwargs): for line in fp: line = li...
Python
0
2ff8505db7ee0b4dbf08a2a61d00daaf681f5492
Create dlpp.py
dlpp.py
dlpp.py
#!/usr/bin/env python # dl_poly_parse # If ran as script, takes a DL_POLY OUTPUT file and returns the physical properties as a parsed # file of simple columns, for easy readability by plotting software. # # To do: # * give option to output as csv # * give option to return properties as horizontally or vertically sor...
Python
0.000001
e13ed4cfa39b366685d058501be2e65b5bbf1230
Make language setup compatible with OSX Yosemite's `locale -a` output
dodo.py
dodo.py
import os import fnmatch import locale import subprocess DOIT_CONFIG = { 'default_tasks': ['flake8', 'test'], 'reporter': 'executed-only', } def recursive_glob(path, pattern): """recursively walk path directories and return files matching the pattern""" for root, dirnames, filenames in os.walk(path,...
import os import fnmatch import locale import subprocess DOIT_CONFIG = { 'default_tasks': ['flake8', 'test'], 'reporter': 'executed-only', } def recursive_glob(path, pattern): """recursively walk path directories and return files matching the pattern""" for root, dirnames, filenames in os.walk(path,...
Python
0.000003
8967d4e0c5cd9adad7244cfc2ea78593be14b113
Add regression test template
templates/tests/regression_test.py
templates/tests/regression_test.py
# coding: utf-8 from __future__ import unicode_literals import pytest def test_issueXXX(): """Provide a description of what you're testing for here.""" # to use spaCy components, add the fixture names as arguments to the test # for more info, check out the tests README: # https://github.com/explosio...
Python
0.000001
47734733a7ccbd242979b3c7ac9d792f59ac10d8
Test for HERMES spectra of HD22879
code/test_hd22879.py
code/test_hd22879.py
import cPickle as pickle from stellar_parameters import Star from channel import SpectralChannel class spectrum(object): pass import sick spec = sick.specutils.Spectrum.load("spectra/hermes-sun.fits") blue_channel = spectrum() blue_channel.dispersion = spec.disp blue_channel.flux = spec.flux blue_channel.va...
Python
0
1a6f702b670a4cad2ec1cd4044759ecfc656c9f2
add thread
thread/thread.py
thread/thread.py
#!/usr/bin/env python import thread from time import sleep, ctime def thread0(): print '1 : start @ ', ctime() sleep(4) print '1 : end @ ', ctime() def thread1(): print '2 : start @ ', ctime() sleep(4) print '2 : end @ ', ctime() def main(): print 'starting at:', ctime() thread....
Python
0
2feed8b291fd4c8081bb81458bedd736c08c448e
Add CNN example script.
usr/examples/09-Feature-Detection/cnn.py
usr/examples/09-Feature-Detection/cnn.py
# CMSIS CNN example. import sensor, image, time, os sensor.reset() # Reset and initialize the sensor. sensor.set_contrast(3) sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE) sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240) sensor.set...
Python
0
0080f3a4f93a22b9c563c20d2c93b00ce8b7c382
Set up game structure
game.py
game.py
""" A variant of Conway's Game of Life on a hexagonal grid. Rules: B2/S12 - Dead cells with two live neighbours are born. - Live cells with one or two live neighbours survive. - All other live cells die. """ # Rule Configuration STATES = ('DEAD', 'ALIVE') B = (2,) S = (1, 2) class Game: def...
Python
0.000003
72e69f3535c7e2cd82cdda62636eabd7421ebddf
Add dump script for all hiddens
generative/tests/compare_test/concat_first/dump_hiddens.py
generative/tests/compare_test/concat_first/dump_hiddens.py
from __future__ import division from __future__ import print_function from __future__ import absolute_import import os import subprocess if __name__ == "__main__": for hiddens_dim in [512, 256, 128, 64, 32, 16]: print('Dumping files for (%d)' % hiddens_dim) model_path = '/mnt/visual_communicat...
Python
0
6e0202bb2385821907627046aef28b042961a2be
Create gate.py
gate.py
gate.py
Python
0.000001
49b616ce93ba53bc6029145147a077945c18b604
add async example
examples/asyncexample.py
examples/asyncexample.py
#!/usr/bin/python # Licensed to the Apache Software Foundation (ASF) 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 # "Licens...
Python
0.000001
e20e50c7cb1a22907bc83eec6c595a7bbaf8b8b9
Add test_github.py
tests/core/backends/test_github.py
tests/core/backends/test_github.py
# -*- coding: utf-8 -*- import pytest import requests from kawasemi.backends.github import GitHubChannel from kawasemi.exceptions import HttpError, ImproperlyConfigured config = { "_backend": "kawasemi.backends.github.GitHubChannel", "token": "token", "owner": "ymyzk", "repository": "kawasemi" } @p...
Python
0.000004
aa1ca0b500af4ef89ba7ad7982b89ebe15252c1b
add heguilong answer for question3
question_3/heguilong.py
question_3/heguilong.py
""" File: heguilong.py Author: heguilong Email: hgleagle@gmail.com Github: https://github.com/hgleagle Description: 统计一个文件中每个单词出现的次数,列出出现频率最多的5个单词。 """ import logging import sys import re from collections import Counter logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s \ ...
Python
0.999995
69ba3715c762245e83d6b5388af4b77dfcc43dde
Create dataGenCore.py
bin/dataGenCore.py
bin/dataGenCore.py
#!/usr/bin python import time import random import base64 import os import sys start = time.time() # pwd = os.path.dirname(__file__) # outputpath = os.path.normpath(pwd + '/../sample_data/' + sys.argv[1]) outputpath = os.path.normpath(sys.argv[1]) # print outputpath #run for five minutes # while time.time() < st...
Python
0.000002
df784323d0da737755def4015840d118e3c8e595
Add test that detects censorship in HTTP pages based on HTTP body length
nettests/core/http_body_length.py
nettests/core/http_body_length.py
# -*- encoding: utf-8 -*- # # :authors: Arturo Filastò # :licence: see LICENSE from twisted.internet import defer from twisted.python import usage from ooni.templates import httpt class UsageOptions(usage.Options): optParameters = [ ['url', 'u', None, 'Specify a single URL to test.'], ...
Python
0.000001
e546e055b33c776fddaa244075d59a99978265ea
add reading
vehicles/management/commands/import_reading.py
vehicles/management/commands/import_reading.py
from ciso8601 import parse_datetime from django.utils.timezone import make_aware from django.contrib.gis.geos import Point from busstops.models import Service from ...models import VehicleLocation, VehicleJourney from ..import_live_vehicles import ImportLiveVehiclesCommand class Command(ImportLiveVehiclesCommand): ...
Python
0
3b00930f9c6e6552bef5b5939916a1b8e737287a
Add a snippet.
python/pyaudio/read.py
python/pyaudio/read.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # See http://people.csail.mit.edu/hubert/pyaudio/docs/#example-blocking-mode-audio-i-o import pyaudio import wave CHUNK = 1024 wf = wave.open("test.wav", 'rb') print(wf.getnchannels()) print(wf.getframerate()) p = pyaudio.PyAudio() print(p.get_device_count()) stream...
Python
0.000002
0799f888dd67439fa7ba9a3a26427a21ad804c62
Add XML plist module
scripts/gen/plistxml.py
scripts/gen/plistxml.py
import xml.dom.minidom import xml.dom as dom # The methods you want to use are 'load' and 'dump' # All keys and strings will be unicode # this will FAIL with non Unicode strings # this is intentional class PlistError(ValueError): pass def checkwhite(obj): if obj.nodeType == dom.Node.TEXT_NODE: if obj....
Python
0
f970198596d8c20c89701fbcce38fd5736096e86
Set maximal word length limit
namegen/markov.py
namegen/markov.py
#!/usr/bin/env python """ Module which produces readble name from 256-bit of random data (i.e. sha-256 hash) """ MAXWORDLEN=12 # # Modules which contain problablity dictionaries # generated by genmarkov script # from surname_hash import surname from female_hash import female from male_hash import male # import operat...
Python
0.999808
3601a0dc9d762e17c24e0dbf86ee1ef4a00c49cd
Add tests for the authorize_user function
yithlibraryserver/tests/test_security.py
yithlibraryserver/tests/test_security.py
from pyramid.httpexceptions import HTTPBadRequest, HTTPUnauthorized from yithlibraryserver import testing from yithlibraryserver.security import authorize_user class AuthorizationTests(testing.TestCase): clean_collections = ('access_codes', 'users') def test_authorize_user(self): request = testing...
Python
0.000001
66db96dc523ab838475eb3826766bb4278c18673
Add tests for remove_display_attributes.
tests/test_assess_cloud_display.py
tests/test_assess_cloud_display.py
from tests import TestCase from assess_cloud_display import remove_display_attributes from utility import JujuAssertionError class TestRemoveDisplayAttributes(TestCase): def test_remove_display_attributes(self): cloud = { 'defined': 'local', 'description': 'Openstack Cloud', ...
Python
0
6c12786f74c17ab8328fed9bfebbb003f2e9f282
Add always true entry
zaifbot/rules/entry/always_true_entry.py
zaifbot/rules/entry/always_true_entry.py
from zaifbot.rules.entry.base import Entry class AlwaysTrueEntry(Entry): def __init__(self, currency_pair, amount, action, name=None): super().__init__(currency_pair=currency_pair, amount=amount, action=action, name=name) def can_entry(self): return True
Python
0
34be21749a0e42563c2f1c6912a2ae2a7c26091c
525. Contiguous Array. Array, TLE
p525_array_tle.py
p525_array_tle.py
import unittest def max_length(sums, lo, hi): sum_ = (sums[hi] - sums[lo]) << 1 length = hi - lo if sum_ > length: more = 1 elif sum_ < length: more = 0 else: return length if sums[lo] == more: return max_length(sums, lo + 1, hi) elif sums[hi] == more: ...
Python
0.998773
93f0f573c40ed7878f744a9fee2b2a9e85157d5e
append elevations to GPX from SRTM dataset with gpxelevations util in SRTM.py package
src/gpx_elev_enhancer.py
src/gpx_elev_enhancer.py
# Append elevations to GPX files # 2015-05-08 # Lu LIU # from os import listdir from os.path import isfile, join import srtm import gpxpy gpx_file_dir = "/Users/user/Research/data/GPX/Munich" gpx_files = [f for f in listdir(gpx_file_dir) if isfile(join(gpx_file_dir, f))] for gpx_file in gpx_files: print "add elev...
Python
0
98852758b85c2e6c53cc22dc30b5b4418bece6b5
Add transfer paging unit tests
tests/unit/test_transfer_paging.py
tests/unit/test_transfer_paging.py
import requests import json import six import pytest from globus_sdk.transfer.paging import PaginatedResource from globus_sdk.transfer.response import IterableTransferResponse N = 25 class PagingSimulator(object): def __init__(self, n): self.n = n # the number of simulated items def simulate_get(...
Python
0