commit stringlengths 40 40 | subject stringlengths 4 1.73k | repos stringlengths 5 127k | old_file stringlengths 2 751 | new_file stringlengths 2 751 | new_contents stringlengths 1 8.98k | old_contents stringlengths 0 6.59k | license stringclasses 13
values | lang stringclasses 23
values |
|---|---|---|---|---|---|---|---|---|
e624dd6c6e8d5a3216a25d8ec12343a453721d20 | test utils added | WladimirSidorenko/DiscourseSenser | tests/test_utils.py | tests/test_utils.py | #!/usr/bin/env python
# -*- coding: utf-8; mode: python; -*-
##################################################################
# Imports
from __future__ import absolute_import
from dsenser.constants import CONNECTIVE, TOK_LIST
from dsenser.utils import singleton, is_explicit
#######################################... | mit | Python | |
fecc7ae7925780b03c9aca3285df2b4f12995f47 | Add package __main__ and argparser | tietokilta-saato/tikplay,tietokilta-saato/tikplay,tietokilta-saato/tikplay,tietokilta-saato/tikplay | tikplay/__main__.py | tikplay/__main__.py | import audio
import cache
import argparse
from statics import USAGE, INTERNAL_ERROR
from flask import Flask
__author__ = 'Jami Lindh'
_tikserver = Flask('tikplay')
_argparser = argparse.ArgumentParser()
_argparser.add_argument('-df', '--debug-flask', help='Enable flask debug mode', type=bool, nargs='?', default=Fal... | mit | Python | |
3e70cab812e29e504f714c782c71bc4b79793686 | Add elasticsearch_tools module | genenetwork/genenetwork2,DannyArends/genenetwork2,zsloan/genenetwork2,DannyArends/genenetwork2,DannyArends/genenetwork2,genenetwork/genenetwork2,pjotrp/genenetwork2,pjotrp/genenetwork2,genenetwork/genenetwork2,zsloan/genenetwork2,pjotrp/genenetwork2,genenetwork/genenetwork2,DannyArends/genenetwork2,zsloan/genenetwork2,... | wqflask/utility/elasticsearch_tools.py | wqflask/utility/elasticsearch_tools.py | from elasticsearch import Elasticsearch, TransportError
from utility.tools import ELASTICSEARCH_HOST, ELASTICSEARCH_PORT
es = Elasticsearch([{
"host": ELASTICSEARCH_HOST
, "port": ELASTICSEARCH_PORT
}])
def get_user_by_unique_column(column_name, column_value):
user_details = None
try:
respons... | agpl-3.0 | Python | |
8ea49c43e2463bf0db85bdba05fb85228163b97e | Add basic REST client | ahri/pycurlbrowser | rest_client.py | rest_client.py | # coding: utf-8
from browser import Browser
import pycurl
import simplejson
class RestClient(Browser):
def __init__(self, base):
super(RestClient, self).__init__()
self._curl.setopt(pycurl.USERAGENT, "pycurl.rest_client 0.1")
self.base = base
def go(self, obj, uid=None):
url = ... | agpl-3.0 | Python | |
fcf6883b0953e5f6d909e5a8192ddea3ecd398b1 | Add first version 019-remove-nth-node-from-end-of-list.py, only Your runtime beats 14.48% of python submissions. | mvj3/leetcode | 019-remove-nth-node-from-end-of-list.py | 019-remove-nth-node-from-end-of-list.py | """
Question:
Remove Nth Node From End of List My Submissions Question Solution
Given a linked list, remove the nth node from the end of list and return its head.
For example,
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the end, the linked list becomes ... | mit | Python | |
f16506033ec6180a63646b4c6b2a0c68f1b05b61 | Create apps.py | furious-luke/django-address,furious-luke/django-address,furious-luke/django-address | address/apps.py | address/apps.py | from django.apps import AppConfig
class AddressConfig(AppConfig):
"""
Define config for the member app so that we can hook in signals.
"""
name = 'address'
def ready(self):
import signals
| bsd-3-clause | Python | |
9a2a8100b566d2332db958979b776a10ac59f38a | Add Alexa top 1 Million fetcher to push into RabbitMQ | seiflotfy/compatipede,seiflotfy/compatipede,seiflotfy/compatipede,seiflotfy/compatipede | alexa_parser.py | alexa_parser.py | import csv
import requests
import zipfile
import os
import pika
from os.path import expanduser
BASEPATH = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
ALEXA_FILE = BASEPATH + "/alexa.zip"
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
chann... | mpl-2.0 | Python | |
5b59fa72f7d5200869823bf5d14dacdfcb531ba1 | Add Original Code of Lenet TensorFlow Example (#4645) | intel-analytics/BigDL,intel-analytics/BigDL,yangw1234/BigDL,yangw1234/BigDL,yangw1234/BigDL,intel-analytics/BigDL,yangw1234/BigDL,intel-analytics/BigDL | python/nano/example/tensorflow/lenet/lenet.py | python/nano/example/tensorflow/lenet/lenet.py | #
# Copyright 2016 The BigDL Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | apache-2.0 | Python | |
8510d648730059518ca6953aa716d59cc9f853ca | Add gradient and reshape functions to match Matlab | jabooth/menpo-archive,yuxiang-zhou/menpo,grigorisg9gr/menpo,jabooth/menpo-archive,mozata/menpo,patricksnape/menpo,grigorisg9gr/menpo,jabooth/menpo-archive,patricksnape/menpo,mozata/menpo,grigorisg9gr/menpo,menpo/menpo,menpo/menpo,mozata/menpo,yuxiang-zhou/menpo,menpo/menpo,jabooth/menpo-archive,patricksnape/menpo,yuxia... | pybug/matlab/__init__.py | pybug/matlab/__init__.py | from numpy import gradient as np_gradient, reshape as np_reshape
def gradient(f, *varargs):
"""
Return the gradient of an N-dimensional array.
The gradient is computed using central differences in the interior and first differences at
the boundaries. The returned gradient hence has the same shape as ... | bsd-3-clause | Python | |
dd95bd67379bca72f340585bfc959f8a8f296609 | Add MarkerTrackerLoader first pass | RasaHQ/rasa_nlu,RasaHQ/rasa_nlu,RasaHQ/rasa_nlu | rasa/core/evaluation/marker_tracker_loader.py | rasa/core/evaluation/marker_tracker_loader.py | import random
from rasa.shared.core.trackers import DialogueStateTracker
from typing import Any, Iterable, List, Text, Optional
from rasa.core.tracker_store import TrackerStore
class MarkerTrackerLoader:
"""Represents a wrapper around a `TrackerStore` that loads trackers in a configurable access pattern."""
... | apache-2.0 | Python | |
d17688974a1b8ff1ed08912f8970caddb42ad1dd | Create __init__.py | jguidry/SPIS15-Project-Web-Les-Wyatt,pconrad/heroku-try-file-upload,pconrad/heroku-try-file-upload,jguidry/SPIS15-Project-Web-Les-Wyatt | app/__init__.py | app/__init__.py | import os
# We'll render HTML templates and access data sent by POST
# using the request object from flask. Redirect and url_for
# will be used to redirect the user once the upload is done
# and send_from_directory will help us to send/show on the
# browser the file that the user just uploaded
from flask import Flask, ... | mit | Python | |
df30a497b5b7be77055ea95e932b644e337c6737 | Add python script to read the hello client trace in httpd. | jfclere/AC2014scripts,jfclere/AC2014scripts | scripts/ssl.py | scripts/ssl.py | #!/usr/bin/python3
# To decode TLS 1.3 Hello Client packet trace from mod_ssl
import sys
def main():
print(f"Arguments count: {len(sys.argv)}")
for i, arg in enumerate(sys.argv):
filename = {arg}
print(f"Argument {i:>6}: {arg}")
with open(arg) as file:
msg = bytearray()
for line in file:
... | apache-2.0 | Python | |
80966a18fbe92839370c90271d1118a0ac621501 | Add a small program for checking whether SEG Y files roundtrip through the data structure flawlessly. | hohogpb/segpy,Kramer477/segpy,kwinkunks/segpy,abingham/segpy,kjellkongsvik/segpy,asbjorn/segpy | examples/check_equal.py | examples/check_equal.py | #!/usr/bin/env python3
from segpy.reader import create_reader
from segpy.trace_header import TraceHeaderRev1
from segpy.types import Int16
from segpy.writer import write_segy
from segpy.header import are_equal, field
class CustomTraceHeader(TraceHeaderRev1):
unassigned_1 = field(
Int16, offset=2... | agpl-3.0 | Python | |
6cc0636869aca1dcd32dde84c6fc3064935cdadc | Add data processing script | sjbarag/ECE-C433,sjbarag/ECE-C433,sjbarag/ECE-C433 | proj2/procData.py | proj2/procData.py | #!/usr/bin/python2
# Processes data produced by p1c.c/p1d.c into a format appropriate for gnuplot
# Author: Sean Barag <sjb89@drexel.edu>
# read data
data = []
f = open("timing_data.txt", "r")
for line in f:
data.append(float(line.strip()))
f.close()
# normalize data to time since first packet
init = data[0]
data = ... | bsd-3-clause | Python | |
c8ef0014a3d0e34b4f53503916cddd9e7ce80b13 | Create match_one_more_repetitions.py | costincaraivan/hackerrank,costincaraivan/hackerrank | regex/repetitions/python3/match_one_more_repetitions.py | regex/repetitions/python3/match_one_more_repetitions.py | Regex_Pattern = r'^\d+[A-Z]+[a-z]+$' # Do not delete 'r'.
| mit | Python | |
6576aea87774b9a363fce61617d3179010c65c96 | Enable UserProfile in admin | jicksy/oneanddone_test,VarnaSuresh/oneanddone,tessie/oneanddone,akatsoulas/oneanddone,bobsilverberg/oneanddone,bobsilverberg/oneanddone,tessie/oneanddone,adini121/oneanddone,VarnaSuresh/oneanddone,jicksy/oneanddone_test,akatsoulas/oneanddone,bobsilverberg/oneanddone,m8ttyB/oneanddone,glogiotatidis/oneanddone,tessie/one... | oneanddone/users/admin.py | oneanddone/users/admin.py | from django.contrib import admin
from oneanddone.users import models
class UserProfileAdmin(admin.ModelAdmin):
list_display = ('name', 'username', 'privacy_policy_accepted')
readonly_fields = ('name', 'username')
admin.site.register(models.UserProfile, UserProfileAdmin)
| mpl-2.0 | Python | |
e35892e16abbe07bdf006cedeb183b6a4040e711 | add context configurator interface | openprocurement/openprocurement.api | src/openprocurement/api/interfaces.py | src/openprocurement/api/interfaces.py | # -*- coding: utf-8 -*-
from zope.interface import Interface
class IContextConfigurator(Interface):
""" Context configurator """
| apache-2.0 | Python | |
a1ee2e2bfe25d8405cceda142f9f9a1e3e103796 | test to trigger import from treebase | OpenTreeOfLife/phylesystem-api,OpenTreeOfLife/phylesystem-api,OpenTreeOfLife/phylesystem-api | ws-tests/test_study_create_treebase.py | ws-tests/test_study_create_treebase.py | #!/usr/bin/env python
from opentreetesting import test_http_json_method, config
import datetime
import codecs
import json
import sys
import os
DOMAIN = config('host', 'apihost')
SUBMIT_URI = DOMAIN + '/v1/study/'
# refresh a timestamp so that the test generates a commit
data = { 'import_method' : 'import-method-TREEBA... | bsd-2-clause | Python | |
68c3ee25d505c680a08ef53de24c4b920099e081 | Add migration script to clear invalid unclaimed records | danielneis/osf.io,bdyetton/prettychart,petermalcolm/osf.io,CenterForOpenScience/osf.io,jnayak1/osf.io,lamdnhan/osf.io,icereval/osf.io,icereval/osf.io,zkraime/osf.io,icereval/osf.io,cldershem/osf.io,chrisseto/osf.io,dplorimer/osf,doublebits/osf.io,MerlinZhang/osf.io,DanielSBrown/osf.io,kwierman/osf.io,hmoco/osf.io,lynds... | scripts/clear_invalid_unclaimed_records.py | scripts/clear_invalid_unclaimed_records.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Script to remove unclaimed records for confirmed users. Once a user has
confirmed their email address, all their unclaimed records should be cleared
so that their full name shows up correctly on all projects.
To run: ::
$ python -m scripts.clear_invalid_unclaimed_r... | apache-2.0 | Python | |
d9679627965634b95e7372f9fc3a1a10224b9d03 | add missing data generator file | annarev/benchmarks,tensorflow/benchmarks,tensorflow/benchmarks,annarev/benchmarks | scripts/keras_benchmarks/data_generator.py | scripts/keras_benchmarks/data_generator.py | """ Generates input and label data for training models. """
import numpy as np
def generate_img_input_data(input_shape, num_classes):
"""Generates training data and target labels.
# Arguments
input_shape: input shape in the following format
(num_samples,channels, x, y)
num_classes: ... | apache-2.0 | Python | |
da59602eef42413a3fc24fbd7c4723dc2d44372b | add a new class EventsWithBranchAddressAccess | alphatwirl/alphatwirl,alphatwirl/alphatwirl,alphatwirl/alphatwirl,TaiSakuma/AlphaTwirl,alphatwirl/alphatwirl,TaiSakuma/AlphaTwirl | AlphaTwirl/EventsWithBranchAddressAccess.py | AlphaTwirl/EventsWithBranchAddressAccess.py | # Tai Sakuma <tai.sakuma@cern.ch>
import array
##____________________________________________________________________________||
class EventsWithBranchAddressAccess(object):
def __init__(self, tree, brancheNames, maxEvents = -1):
self.file = tree.GetDirectory() # so a file won't close
self.tree = tr... | bsd-3-clause | Python | |
1f0bd29009f4844dc25876ad6e0751310ca2be32 | add SingleActiveObjectMixin and Manager | byteweaver/django-singleactiveobject | singleactiveobject/models.py | singleactiveobject/models.py | from django.db import models
from django.utils.translation import ugettext as _
class SingleActiveObjectManager(models.Manager):
def get_active_object(self):
try:
return self.get(active=True)
except models.ObjectDoesNotExist:
return None
class SingleActiveObjectMixin(mode... | bsd-3-clause | Python | |
1073485bc5ceadf771b09501e3302b792de75691 | Correct crv baseline questionnaire rank w/ migration (FKs prevent site_persistence fix from working) | uwcirg/true_nth_usa_portal,uwcirg/true_nth_usa_portal,uwcirg/true_nth_usa_portal,uwcirg/true_nth_usa_portal | portal/migrations/versions/9ebdfeb28bef_.py | portal/migrations/versions/9ebdfeb28bef_.py | """Correct rank of CRV baseline
Revision ID: 9ebdfeb28bef
Revises: a679f493bcdd
Create Date: 2017-10-09 10:16:40.584279
"""
from alembic import op
from sqlalchemy.orm import sessionmaker
from portal.models.questionnaire_bank import QuestionnaireBank
# revision identifiers, used by Alembic.
revision = '9ebdfeb28bef'... | bsd-3-clause | Python | |
a98d8816550f516197ab790c2a6a3e123ea0ceaf | add tests for sugared env | dankilman/pysource,dankilman/pysource | pysource/tests/test_sugared_env.py | pysource/tests/test_sugared_env.py | # Copyright 2014 Dan Kilman
#
# 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, softw... | apache-2.0 | Python | |
ef039b4a3750d858a856ee737ccf58ad46f4047c | add npmi tool | jasonwbw/NLPbasic | nlp_basic/basic/npmi.py | nlp_basic/basic/npmi.py | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# This is a simple NPMI tool based on inverted_index
#
# Reference: http://en.wikipedia.org/wiki/Pointwise_mutual_information
# Paper: Normalized(Pointwise) Mutual Information in Collocation Extraction
#
# @author: Jason Wu (Jasonwbw@yahoo.com)
from pmi import PMI
impor... | mit | Python | |
1c6a80a4a18456d98159cbf985cadcffbdb0c2d9 | Add files via upload | maykraembow/python-scripts | lotter.py | lotter.py | #Mayk Rambeau
# using Python 3.5.2
import random, os
x = 0
print ("Welcome to lottery numbers, random numbers generated " + '\n')
trynow = input("do you want to generate numbers (yes/no) "+ '\n')
trynow.lower()
while trynow == "yes":
for x in range(6):
# while x < 6:
lotterynumbers = []
lott... | mit | Python | |
91abe26fd0b06339b3283d1dbe096edfdc52dadb | Add numpy array of tuples | cmey/surprising-snippets,cmey/surprising-snippets | numpy-array-of-tuple.py | numpy-array-of-tuple.py | # Numpy converts a list of tuples *not* into an array of tuples, but into a 2D
# array instead.
list_of_tuples = [(1, 2), (3, 4)]
import numpy as np
print('list of tuples:', list_of_tuples, 'type:', type(list_of_tuples))
A = np.array(list_of_tuples)
print('numpy array of tuples:', A, 'type:', type(A))
# It makes comp... | mit | Python | |
ed23bf92ba48749c905282f7b2a3f145dc3982a9 | add missing fstab module | Ubuntu-Solutions-Engineering/glance-simplestreams-sync-charm,Ubuntu-Solutions-Engineering/glance-simplestreams-sync-charm | hooks/charmhelpers/core/fstab.py | hooks/charmhelpers/core/fstab.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Jorge Niedbalski R. <jorge.niedbalski@canonical.com>'
import os
class Fstab(file):
"""This class extends file in order to implement a file reader/writer
for file `/etc/fstab`
"""
class Entry(object):
"""Entry class represents a non... | agpl-3.0 | Python | |
9c4ea7f385285f1c47d44e701ca25bab1bf0bcb6 | add script for convert encoding (fix firefox XML Parsing Error) | wisperwinter/pali,siongui/pali,siongui/pali,siongui/pali,wisperwinter/pali,siongui/pali,wisperwinter/pali | common/pytools/fixFirefoxXMLParsingError.py | common/pytools/fixFirefoxXMLParsingError.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
import os, re, xml.dom.minidom
#errorXMLInfo = [['zh_TW', '3', 's0101m.mul1.xml'],
# ['zh_TW', '3', 's0102m.mul2.xml'],
# ['zh_TW', '3', 's0102m.mul8.xml'],
# ['zh_TW', '3', 's0103m.mul7.xml'],
# ['zh_TW', '3', 's... | unlicense | Python | |
45c4b092a7753c3a5dd7c36baf2bcfc17b32a871 | Add python data transmission example. | Blinkinlabs/BlinkyTape,Blinkinlabs/BlinkyTape,Blinkinlabs/BlinkyTape | blink_strip/python_example/flash_example.py | blink_strip/python_example/flash_example.py | import serial
import time
class blinkyBoard:
def init(self, port, baud):
self.serial = serial.Serial(port, baud)
self.serial.open()
def sendPixel(self,r,g,b):
data = bytearray()
data.append(0x80 | (r>>1))
data.append(0x80 | (g>>1))
data.append(0x80 | (b>>1))
self.serial.write(data)
... | apache-2.0 | Python | |
4bf03eaf81f8d4c28e3b3b89c7442a787361eb5e | Add a script which structures the mlsp2013 data | johnmartinsson/bird-species-classification,johnmartinsson/bird-species-classification | scripts/structure_mlsp2013_dataset.py | scripts/structure_mlsp2013_dataset.py | import csv
def test():
with open("CVfolds_2.txt", newline='') as id2set, open("rec_id2filename.txt", newline='') as id2file, open("rec_labels_test_hidden.txt", newline='') as id2label:
with open("file2label.csv", 'w', newline='') as file2label:
readId2Label = csv.reader(id2label)
re... | mit | Python | |
9193a3492d512ac137624da38d1a2dd64f34243f | Implement vectors and basic operations | mxbi/algin | vec.py | vec.py | class v(object):
def __init__(self, coor):
try:
if not coor:
raise ValueError
self.coor = tuple(coor)
self.dim = len(coor)
except KeyboardInterrupt:
raise
except ValueError:
raise ValueError('The co-ordinates must c... | mit | Python | |
26e5c25bf80c28cdfca1b7f52b14e4ba4f090eec | Create compare-to-Snp.py | Soncrates/stock-study,Soncrates/stock-study | data/transforms/compare-to-Snp.py | data/transforms/compare-to-Snp.py | import pandas as pd
def one_month_many_years(key,dataSeries):
lastday = getLastDay(key[0],key[1])
days = range(1,lastday+1)
ret=dict.fromkeys(days,None)
for x in sorted(dataSeries.index) :
ret[x.day]=dataSeries[x]
return ret
def gen_normalize_by_month_a(stock,pct,month):
pct=pct.ix[pct.i... | lgpl-2.1 | Python | |
7348bf975c5f72feb078bbb6598aa7d0baacefa0 | Add keybar.util.security. | keybar/keybar | src/keybar/utils/security.py | src/keybar/utils/security.py | import ssl
from django.conf import settings
# Verify we can use all feature we require.
assert ssl.HAS_ECDH
assert ssl.HAS_SNI
def get_server_context():
"""Our TLS configuration for the server"""
server_ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
server_ctx.set_ecdh_curve('prime256v1')
server_ctx.ver... | bsd-3-clause | Python | |
9b307d30daed45c02e5110fd1cfea5834bd6599b | create package bottleauth | avelino/bottle-auth | bottleauth/__init__.py | bottleauth/__init__.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
__version__ = '0.1.0'
__author__ = "Thiago Avelino"
__email__ = "thiago@avelino.xxx"
| mit | Python | |
e74db662cbba56f8c192586ca4ac34d5e5330376 | Add test case for *_boundaries functions | almarklein/scikit-image,ClinicalGraphics/scikit-image,newville/scikit-image,ofgulban/scikit-image,Hiyorimi/scikit-image,robintw/scikit-image,chintak/scikit-image,youprofit/scikit-image,dpshelio/scikit-image,rjeli/scikit-image,vighneshbirodkar/scikit-image,almarklein/scikit-image,almarklein/scikit-image,youprofit/scikit... | skimage/segmentation/tests/test_boundaries.py | skimage/segmentation/tests/test_boundaries.py | import numpy as np
from numpy.testing import assert_array_equal
from skimage.segmentation import find_boundaries, mark_boundaries
def test_find_boundaries():
image = np.zeros((10, 10))
image[2:7, 2:7] = 1
ref = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
... | bsd-3-clause | Python | |
dc399c7834b918ea99baa92d1cdededa43623d87 | Add missing migrations for last commit | OpenVolunteeringPlatform/django-ovp-projects,OpenVolunteeringPlatform/django-ovp-projects | ovp_projects/migrations/0033_auto_20170208_2118.py | ovp_projects/migrations/0033_auto_20170208_2118.py | # -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-08 21:18
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ovp_projects', '0032_auto_20170206_1905'),
]
operations = [
migrations.Alte... | agpl-3.0 | Python | |
14bbb30423d318f9b410b0a7dd46e705ac0dd061 | Create test_expr module | cjdrake/pyeda,pombredanne/pyeda,karissa/pyeda,sschnug/pyeda,karissa/pyeda,karissa/pyeda,GtTmy/pyeda,GtTmy/pyeda,cjdrake/pyeda,pombredanne/pyeda,sschnug/pyeda,GtTmy/pyeda,sschnug/pyeda,pombredanne/pyeda,cjdrake/pyeda | pyeda/test/test_expr.py | pyeda/test/test_expr.py | """
Test expressions
"""
from pyeda.expr import (
var,
Or, And, Not, Xor, Xnor, Equal, Implies,
Nor, Nand, OneHot0, OneHot,
f_xor, f_xnor, f_equal, f_implies,
)
def test_xor():
a, b, c = map(var, 'abc')
assert Xor() == 0
assert Xor(a).equivalent(a)
assert Xor(0, 0) == 0
assert Xo... | bsd-2-clause | Python | |
d8eafc567d842cae12ee29b1a1de665d3e0916c5 | Add myfuse.py | matthiasvegh/fusepp,matthiasvegh/fusepp,matthiasvegh/fusepp | myfuse.py | myfuse.py | #!/usr/bin/env python
from __future__ import with_statement
import subprocess
import inspect
import os
import sys
import errno
import fuse
#from fuse import Fuse, FuseOSError
class Passthrough(fuse.Operations):
def __init__(self, root):
self.root = root
# Helpers
# =======
def _full_path... | mit | Python | |
a29e51b41b7709c9c3bd066e5d7307be3ee8c51c | Move default permissions (and e-mail templates) into common constants | wtsi-hgi/CoGS-Webapp,wtsi-hgi/CoGS-Webapp,wtsi-hgi/CoGS-Webapp | cogs/common/constants.py | cogs/common/constants.py | """
Copyright (c) 2017 Genome Research Ltd.
Authors:
* Christopher Harrison <ch12@sanger.ac.uk>
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your op... | agpl-3.0 | Python | |
eaa5fc3f5a4a771255bb20ca5d0dff2829dae6f7 | Create numeric_func.py | vsamov/sidewinder,vsamov/sidewinder,vsamov/sidewinder | sidewinder/scientific/numeric_func.py | sidewinder/scientific/numeric_func.py | #!/usr/bin/env python2.7
# coding=utf-8
# generate the number with 0's
numbers = ['{0:012}'.format(i) for i in range(281)]
print numbers
| mit | Python | |
4fe9b901f4920dc64c16d410b3c67f6b4e4f270a | Put logging in verbose_print | opps/opps-feedcrawler,jeanmask/opps-feedcrawler | opps/feedcrawler/processors/base.py | opps/feedcrawler/processors/base.py | # coding: utf-8
import logging
from opps.feedcrawler.models import Entry, ProcessLog
logger = logging.getLogger()
class BaseProcessor(object):
def __init__(self, feed, entry_model=None, log_model=None,
verbose=False, *args, **kwargs):
self.feed = feed
self.entry_model = entry_mo... | # coding: utf-8
from opps.feedcrawler.models import Entry, ProcessLog
class BaseProcessor(object):
def __init__(self, feed, entry_model=None, log_model=None,
verbose=False, *args, **kwargs):
self.feed = feed
self.entry_model = entry_model or Entry
self.log_model = log_mod... | mit | Python |
e349a9d095061ec4f90314a664ad3af1865297fb | test main text-entry search | bopen/ckanext-mapsearch,bopen/ckanext-mapsearch | tests/test_search.py | tests/test_search.py | import unittest
from time import sleep
from random import choice
from selenium import webdriver
from helpers import wait_for_ajaxes_to_complete
from helpers import display_javascript_notice
class TestExtents(unittest.TestCase):
def setUp(self):
try:
self.driver = webdriver.Firefox()
... | agpl-3.0 | Python | |
059cabbad4a7d69410abe95bf70778cb0808e0d4 | Add tests for houston.utils.parse_endpoint | thedrow/houston | tests/utils_tests.py | tests/utils_tests.py | """
Tests for houston.utils
"""
try:
import unittest2 as unittest
except ImportError:
import unittest
from houston import utils
class ParseEndpointTests(unittest.TestCase):
def test_http_with_default_port(self):
value = 'http://consul.ec2.local'
expectation = {'scheme': 'http',
... | bsd-3-clause | Python | |
58bda5be1e6bffdd499a08f429beb42e77212129 | add abstract HDLStatement class | brunosmmm/hdltools,brunosmmm/hdltools | hdltools/abshdl/stmt.py | hdltools/abshdl/stmt.py | """General statements."""
from . import HDLObject
class HDLStatement(HDLObject):
"""Program statement."""
pass
| mit | Python | |
29adfe9c98033d5b7c55d99fae310fa499e5ed29 | use ns.py | community-ssu/telepathy-gabble,Ziemin/telepathy-gabble,jku/telepathy-gabble,mlundblad/telepathy-gabble,community-ssu/telepathy-gabble,mlundblad/telepathy-gabble,Ziemin/telepathy-gabble,community-ssu/telepathy-gabble,jku/telepathy-gabble,mlundblad/telepathy-gabble,Ziemin/telepathy-gabble,Ziemin/telepathy-gabble,jku/tele... | tests/twisted/olpc/change-notifications.py | tests/twisted/olpc/change-notifications.py | """
test OLPC Buddy properties change notifications
"""
# FIXME: merge this file to other tests ?
import dbus
from servicetest import call_async, EventPattern
from gabbletest import exec_test, make_result_iq, acknowledge_iq
from twisted.words.xish import domish, xpath
from util import announce_gadget, send_buddy_ch... | """
test OLPC Buddy properties change notifications
"""
# FIXME: merge this file to other tests ?
import dbus
from servicetest import call_async, EventPattern
from gabbletest import exec_test, make_result_iq, acknowledge_iq
from twisted.words.xish import domish, xpath
from util import announce_gadget, send_buddy_ch... | lgpl-2.1 | Python |
50a6f382a062b553f03e7d7696212a2cb3e6cccf | Add a full-blown example of Qt embedding, exposing a Traits view in a QWidget. | liulion/mayavi,dmsurti/mayavi,liulion/mayavi,alexandreleroux/mayavi,dmsurti/mayavi,alexandreleroux/mayavi | examples/mayavi/interactive/qt_embedding.py | examples/mayavi/interactive/qt_embedding.py | """
This example demonstrates using Mayavi as a component of a large Qt
application.
For this use, Mayavi is embedded in a QWidget. To understand this
example, please read section :ref`builing-applications`.
"""
# First, and before importing any Enthought packages, set the ETS_TOOLKIT
# environment variable to qt4, ... | bsd-3-clause | Python | |
e03084707cc3b019d78e0f0763dc964c0cd1271d | Test unittest.TestSuite | zzz0072/Python_Exercises,zzz0072/Python_Exercises | 06_test/my_calc_class.py | 06_test/my_calc_class.py | #/usr/bin/env python
import unittest
class my_calc:
def my_add(self, x, y):
return x + y
def my_sub(self, x, y):
return x - y
def my_mul(self, x, y):
return x * y
def my_div(self, x, y):
return x / y
class test_func(unittest.TestCase):
def setUp(self):
self.m... | bsd-2-clause | Python | |
a7944b9f50a637027cc9cb7035ba87bd7638ba52 | select k of n, permutate and iterate | fbcom/project-euler | 098_anagramic_squares.py | 098_anagramic_squares.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# A Solution to "Anagramic squares" – Project Euler Problem No. 98
# by Florian Buetow
#
# Sourcecode: https://github.com/fbcom/project-euler
# Problem statement: https://projecteuler.net/problem=98
import itertools
def load_words(filename):
with open(filename) as f... | mit | Python | |
d2bbf28fe0151a1e8968fa3c4516182bb166fe88 | Create OpenNI.py | MyRobotLab/pyrobotlab,sstocker46/pyrobotlab,MyRobotLab/pyrobotlab,mecax/pyrobotlab,MyRobotLab/pyrobotlab,mecax/pyrobotlab,MyRobotLab/pyrobotlab,sstocker46/pyrobotlab,MyRobotLab/pyrobotlab,sstocker46/pyrobotlab | service/OpenNI.py | service/OpenNI.py |
openni = Runtime.start("openni", "OpenNI");
openni.startUserTracking();
| apache-2.0 | Python | |
8c1f121e3c37204248fa1b5454b0b40cb1c2be0d | add api interface | diogo149/simbo,diogo149/simbo,diogo149/simbo | simbo/base/api.py | simbo/base/api.py | import abc
import json
import flask
class ApiBase(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def add_feature(self, feature_name, distribution, **kwargs):
return
@abc.abstractmethod
def remove_feature(self, feature_name, **kwargs):
return
@abc.abstractmethod
... | mit | Python | |
156e71d7128fb3e4914a11736ee47e30598ce5fc | Create longest-word-in-dictionary.py | tudennis/LeetCode---kamyu104-11-24-2015,tudennis/LeetCode---kamyu104-11-24-2015,tudennis/LeetCode---kamyu104-11-24-2015,kamyu104/LeetCode,tudennis/LeetCode---kamyu104-11-24-2015,kamyu104/LeetCode,kamyu104/LeetCode,kamyu104/LeetCode,tudennis/LeetCode---kamyu104-11-24-2015,kamyu104/LeetCode | Python/longest-word-in-dictionary.py | Python/longest-word-in-dictionary.py | # Time: O(n), n is the total sum of the lengths of words
# Space: O(t), t is the number of nodes in trie
# Given a list of strings words representing an English Dictionary,
# find the longest word in words that can be built one character at a time by other words in words.
# If there is more than one possible answer, ... | mit | Python | |
b74b561fdc822ad68719c60f2d8862b546410d3b | Add gdocs helper to gdata_apis helpers. | rhyolight/nupic.son,rhyolight/nupic.son,rhyolight/nupic.son | app/soc/views/helper/gdata_apis/docs.py | app/soc/views/helper/gdata_apis/docs.py | #!/usr/bin/env python2.5
#
# Copyright 2011 the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applic... | apache-2.0 | Python | |
5ed5c59d3a26e68fdfe7081401b8fab3fa0ae47f | update webview incompatible license list. | nacl-webkit/chrome_deps,zcbenz/cefode-chromium,jaruba/chromium.src,fujunwei/chromium-crosswalk,markYoungH/chromium.src,hgl888/chromium-crosswalk-efl,TheTypoMaster/chromium-crosswalk,ChromiumWebApps/chromium,ondra-novak/chromium.src,crosswalk-project/chromium-crosswalk-efl,krieger-od/nwjs_chromium.src,krieger-od/nwjs_ch... | android_webview/tools/known_incompatible.py | android_webview/tools/known_incompatible.py | # Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""List of known-incompatibly-licensed directories for Android WebView.
This is not used by the webview_licenses tool itself; it is effectively a
"cache... | # Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""List of known-incompatibly-licensed directories for Android WebView.
This is not used by the webview_licenses tool itself; it is effectively a
"cache... | bsd-3-clause | Python |
d4af0ced41f353e8a9e9e69e87a97cfc33702036 | test for pca transform | theislab/scanpy,theislab/scanpy | scanpy/tests/test_pca.py | scanpy/tests/test_pca.py | import scanpy as sc
import numpy as np
import pytest
from scipy.sparse import csr_matrix
A = [
[0, 0, 7, 0, 0],
[8, 5, 0, 2, 0],
[6, 0, 0, 2, 5],
[0, 0, 0, 1, 0],
[8, 8, 2, 1, 0],
[0, 0, 0, 4, 5]
]
A_pca = np.array([
[-4.4783009 , 5.55508466, 1.73111572, -0.06029139, 0.17292555],
[ ... | bsd-3-clause | Python | |
f320ff11f74de4df9933fc25db6e9fabbcb89f81 | Add tests for followup bot. | verma-varsha/zulip,eeshangarg/zulip,vabs22/zulip,punchagan/zulip,tommyip/zulip,vaidap/zulip,synicalsyntax/zulip,vabs22/zulip,punchagan/zulip,kou/zulip,vabs22/zulip,timabbott/zulip,vaidap/zulip,amanharitsh123/zulip,andersk/zulip,shubhamdhama/zulip,jrowan/zulip,rht/zulip,Galexrt/zulip,rht/zulip,rht/zulip,andersk/zulip,br... | api/bots/followup/test_followup.py | api/bots/followup/test_followup.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
import os
import sys
our_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.normpath(os.path.join(our_dir)))
# For dev setups, we can find the API in the repo itself.
if os.path.exists(os.path.... | apache-2.0 | Python | |
0f9697c94c75e86edacfaa7982a5128779ee82e7 | Add a migration script that reindex the contents | ideascube/ideascube,ideascube/ideascube,ideascube/ideascube,ideascube/ideascube | ideascube/search/migrations/0002_reindex.py | ideascube/search/migrations/0002_reindex.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
from ideascube.search.utils import create_index_table
reindex = lambda *args: create_index_table(force=True)
class Migration(migrations.Migration):
dependencies = [('search', '0001_initial')]
operations = [
... | agpl-3.0 | Python | |
64ae44e975b72562aecf9b4c668b8ce51d7b1083 | Create plugin.py | Myselfminer/nCuberPlug | plugin.py | plugin.py | import urllib2,zipfile
import nID
import os
import download as get
import sys
def get_fields_from_repo(repository_nid, field):
list_of_all=[]
a=nID.parse(repository_nid,"all_url")
text=download(a)
try:
split=text.split("\n")#split the downloaded data
except:
print("Could not parse do... | apache-2.0 | Python | |
42369393e1634441346a63baecf00b6dc9551c01 | Create vexing_flanker.py | GrognardsFromHell/TemplePlus,GrognardsFromHell/TemplePlus,GrognardsFromHell/TemplePlus,GrognardsFromHell/TemplePlus,GrognardsFromHell/TemplePlus | tpdatasrc/tpgamefiles/scr/tpModifiers/vexing_flanker.py | tpdatasrc/tpgamefiles/scr/tpModifiers/vexing_flanker.py | #Vexing Flanker: Player's Handbook II, p. 85
from templeplus.pymod import PythonModifier
from toee import *
import tpdp
print "Registering Vexing Flanker"
def VFing(attachee, args, evt_obj):
if attachee.has_feat("Vexing Flanker") != 0:
#Vexing Flanker
target = evt_obj.attack_packet.target
if evt_obj.attack_... | mit | Python | |
feb9901fe405f6a3144d7a4a38f0f19d32c52aa6 | test para parser.py | AliGhahraei/nao-classroom | prueba.py | prueba.py | #!/usr/bin/python
import sys
def parser( fileToParse, lineToParse, stringToParse):
stringToParse = stringToParse.lower()
stringToParse = stringToParse.replace(' ','')
stringToParse = stringToParse.replace('\n', '')
f = open(fileToParse)
txt = f.readlines()
x = txt[lineToParse]
x = x.lower()
x = x.replace('\n'... | mit | Python | |
abcfa3326f8357a36bff9c3cc617c428d3e5cbe1 | print list | dojojon/pygame,dojojon/pygame | week2/print_list.py | week2/print_list.py | #! /usr/bin/env python
import pygame
import os
pygame.init()
screen = pygame.display.set_mode((640, 400))
pygame.font.init() # you have to call this at the start,
# try changing the size, Roboto
myfont = pygame.font.SysFont("Comic Sans MS", 30)
clock = pygame.time.Clock()
running = True
# try adding more text he... | mit | Python | |
bb1fc03377d900ff144399cd18cecf0bb497cca4 | Create plysnd.py | powerboat9/PUDT,powerboat9/PUDT | plysnd.py | plysnd.py | import pygame
def play(data, doWait):
if v == None:
pygame.mixer.init()
v = pygame.mixer.get_init()
SAMPLE_RATE = v[0]
transmitSound = pygame.mixer.Sound(data)
transmitSound.play()
if doWait:
time.sleep(transmitSound.get_length())
| mit | Python | |
a54d69fe2048e3b300c7e58b77ecee79316e2ebb | Use Python Logging #10 Some test. | antoinecarme/pyaf,antoinecarme/pyaf,antoinecarme/pyaf | tests/func/test_ozone_with_logging.py | tests/func/test_ozone_with_logging.py | import pandas as pd
import numpy as np
import pyaf.ForecastEngine as autof
import pyaf.Bench.TS_datasets as tsds
import logging
import logging.config
#logging.config.fileConfig('logging.conf')
logging.basicConfig(level=logging.INFO)
#get_ipython().magic('matplotlib inline')
b1 = tsds.load_ozone()
df = b1.mPastData... | bsd-3-clause | Python | |
cc7fddedbce966c7dbd9ff26e5d99c5e5bcf5b99 | Add a new stream_stats management command. | firstblade/zulip,brainwane/zulip,atomic-labs/zulip,MariaFaBella85/zulip,susansls/zulip,shaunstanislaus/zulip,Frouk/zulip,atomic-labs/zulip,arpitpanwar/zulip,nicholasbs/zulip,verma-varsha/zulip,reyha/zulip,ericzhou2008/zulip,johnnygaddarr/zulip,dotcool/zulip,noroot/zulip,dxq-git/zulip,MayB/zulip,m1ssou/zulip,umkay/zulip... | zephyr/management/commands/stream_stats.py | zephyr/management/commands/stream_stats.py | import datetime
import pytz
from django.core.management.base import BaseCommand
from django.db.models import Q
from zephyr.models import Realm, Stream, Message, Subscription, Recipient
class Command(BaseCommand):
help = "Generate statistics on the streams for a realm."
def handle(self, *args, **options):
... | apache-2.0 | Python | |
e96a18aa0b128422b7786acd7b55f0442f1a9b28 | add dummy test for paramiko ssh | veloutin/papas,veloutin/papas | lib6ko/tests/test_paramikossh.py | lib6ko/tests/test_paramikossh.py | import unittest
from lib6ko.architectures.paramiko_ssh import (
ParamikoConsole,
InteractiveWrapper,
InteractiveParamikoConsole,
)
class Test_ParamikoSSH(unittest.TestCase):
def test_create_dumb(self):
p = ParamikoConsole()
ip = InteractiveParamikoConsole()
i = InteractiveWr... | agpl-3.0 | Python | |
93642ed71a2a0ec8fe96858b20c319c061706f39 | Add little script to do basic cleanup after git svn clone | develersrl/git-externals,develersrl/git-externals,develersrl/git-externals | cleanup_repo.py | cleanup_repo.py | #!/usr/bin/env python
import subprocess
import os.path
import sys
import re
from contextlib import contextmanager
TAGS_RE = re.compile('.+/tags/(.+)')
def git(*args):
p = subprocess.Popen(['git'] + list(args), stdout=subprocess.PIPE)
output = p.communicate()[0]
if p.returncode != 0:
raise Exce... | mit | Python | |
46d6edf1e9e094f83dbd5734434e800fdf03a679 | add request emulator | nogizhopaboroda/musfinder,nogizhopaboroda/musfinder,nogizhopaboroda/musfinder | scripts/spider_request_emulator.py | scripts/spider_request_emulator.py | #usage: heroku local:run python scripts/spider_request_emulator.py <sh_id>
import urllib, urllib2
import pdb
import json
import sys
import os
SH_TOKEN = os.environ["STORAGE_KEY"]
SH_KEY = sys.argv[1]
SH_URL = "https://storage.scrapinghub.com/items/{0}?apikey={1}&format=json".format(SH_KEY, SH_TOKEN)
#MIGHTYGOOSE_URL... | mit | Python | |
ec5c652ca902818ab5c81958f8525742d6ad23ce | Revert of https://codereview.chromium.org/126823002/ Reason for revert: breaks license checker | dednal/chromium.src,Just-D/chromium-1,fujunwei/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,dushu1203/chromium.src,TheTypoMaster/chromium-crosswalk,crosswalk-project/chromium-crosswalk-efl,mohamed--abdel-maksoud/chromium.src,fujunwei/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,markYoungH/chromium.src,Chi... | third_party/fontconfig/fontconfig.gyp | third_party/fontconfig/fontconfig.gyp | # Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets': [
{
'target_name': 'fontconfig',
'type': '<(component)',
'dependencies' : [
'../zlib/zlib.gyp:zlib',
'..... | # Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets': [
{
'target_name': 'fontconfig',
'type': '<(component)',
'dependencies' : [
'../zlib/zlib.gyp:zlib',
'..... | bsd-3-clause | Python |
92ac4b1656ccea26f2b37315849b41976d22b9f8 | trim sequences out | linsalrob/EdwardsLab,linsalrob/EdwardsLab,linsalrob/EdwardsLab,linsalrob/EdwardsLab,linsalrob/EdwardsLab | manipulate_genomes/trim_fasta.py | manipulate_genomes/trim_fasta.py | """
Trim a sequence in a fasta file to a user-defined position
"""
import os
import sys
import argparse
from roblib import stream_fasta
def trim_seq(faf, start=0, end=None, seqid=None, verbose=False):
"""
Trim a sequence from start to end.
If start is not provided we use the first base.
If end is not... | mit | Python | |
a01c310398c70fa2e9f40c375f6f4c7d38b41b26 | return proper json | ddworken/pyethereum,karlfloersch/pyethereum,vaporry/pyethereum,ethereum/pyethereum,pipermerriam/pyethereum,shahankhatch/pyethereum,harlantwood/pyethereum,ethermarket/pyethereum,karlfloersch/pyethereum,shahankhatch/pyethereum,ckeenan/pyethereum,pipermerriam/pyethereum,inzem77/pyethereum,ethereum/pyethereum,jnnk/pyethere... | pyethereum/pyethtool.py | pyethereum/pyethtool.py | #!/usr/bin/python
import processblock
import transactions
import blocks
import utils
import json
def sha3(x):
return utils.sha3(x).encode('hex')
def privtoaddr(x):
if len(x) == 64:
x = x.decode('hex')
return utils.privtoaddr(x)
def mkgenesis(*args):
return genesis(*args)
def genesis(*arg... | #!/usr/bin/python
import processblock
import transactions
import blocks
import utils
def sha3(x):
return utils.sha3(x).encode('hex')
def privtoaddr(x):
if len(x) == 64:
x = x.decode('hex')
return utils.privtoaddr(x)
def mkgenesis(*args):
return genesis(*args)
def genesis(*args):
if l... | mit | Python |
3055bc1e261c4f3eef7eb24d704cb9c19a8d4723 | Reformat source files, add some docstrings. | sfepy/sfepy,sfepy/sfepy,vlukes/sfepy,BubuLK/sfepy,BubuLK/sfepy,vlukes/sfepy,sfepy/sfepy,BubuLK/sfepy,rc/sfepy,rc/sfepy,vlukes/sfepy,rc/sfepy | sfepy/discrete/dg/dg_conditions.py | sfepy/discrete/dg/dg_conditions.py | from __future__ import absolute_import
import numpy as nm
from sfepy.base.base import basestr, Container, Struct
from sfepy.discrete.functions import Function
from sfepy.discrete.conditions import Condition, PeriodicBC, EssentialBC
import six
class DGPeriodicBC(PeriodicBC):
...
class DGEssentialBC(EssentialBC)... | bsd-3-clause | Python | |
21d738933b7766173bcf3b10d0b1910d73dc7657 | Create ValAnagram_002.py | Chasego/cod,cc13ny/algo,Chasego/cod,Chasego/cod,Chasego/codi,Chasego/codi,cc13ny/Allin,cc13ny/Allin,Chasego/cod,Chasego/codirit,Chasego/codirit,Chasego/codirit,cc13ny/algo,cc13ny/Allin,Chasego/codi,cc13ny/algo,cc13ny/algo,cc13ny/Allin,cc13ny/Allin,Chasego/codi,Chasego/codirit,cc13ny/algo,Chasego/cod,Chasego/codirit,Cha... | leetcode/242-Valid-Anagram/ValAnagram_002.py | leetcode/242-Valid-Anagram/ValAnagram_002.py | class Solution:
# @param {string} s
# @param {string} t
# @return {boolean}
def anaRepresentation(self, s):
p = {}
for c in s:
if c in p:
p[c] += 1
else:
p[c] = 1
return p
def isAnagram(self, s, t):
if l... | mit | Python | |
5fa29ee744ec02933260f17004ec46336822aba4 | Test ArticulationConverter. #33 | project-schumann/vmf-converter | tests/articulation_converter_test.py | tests/articulation_converter_test.py | import unittest
from music21.articulations import Staccato, Staccatissimo, StrongAccent, Accent, Tenuto
from vmf_converter_core.articulation_converter import ArticulationConverter
class ArticulationConverterTest(unittest.TestCase):
"""Test Class for ArticulationConverter module"""
def test_articulation_to_vm... | mit | Python | |
10fc0e0b85edb04c676fd75e95ab539084063d13 | Solve lisa workbook w/ too many nested loops | rootulp/hackerrank,rootulp/hackerrank,rootulp/hackerrank,rootulp/hackerrank,rootulp/hackerrank,rootulp/hackerrank | python/lisa_workbook.py | python/lisa_workbook.py | chapters, problems_per_page = list(map(int, input().strip().split(' ')))
problems_per_chapter = list(map(int, input().strip().split(' ')))
pages = [[]]
special_problems = 0
for chapter, problems in enumerate(problems_per_chapter):
current_problem = 1
if len(pages[-1]) != 0:
pages.append([])
while ... | mit | Python | |
a4d29a6495704a247922a3868570a98e894caa14 | Add regtest python peg-in test | martindale/elements,martindale/elements,martindale/elements,martindale/elements,martindale/elements,martindale/elements | qa/rpc-tests/pegging.py | qa/rpc-tests/pegging.py | #!/usr/bin/env python2
from test_framework.authproxy import AuthServiceProxy
import os
import random
import sys
import time
import subprocess
import shutil
if len(sys.argv) != 3:
print("paths to bitcoind and sidechain daemon must be included as arguments")
sys.exit(0)
print(sys.argv[1])
print(sys.argv[2])
fe... | mit | Python | |
7e9427a6e7f51954bfed49579d7c6f20c3d73dc1 | Add script to remove broken YT descs. | eloquence/unisubs,ReachingOut/unisubs,norayr/unisubs,ReachingOut/unisubs,wevoice/wesub,norayr/unisubs,ujdhesa/unisubs,eloquence/unisubs,ofer43211/unisubs,ujdhesa/unisubs,pculture/unisubs,pculture/unisubs,eloquence/unisubs,ofer43211/unisubs,norayr/unisubs,ujdhesa/unisubs,ofer43211/unisubs,ReachingOut/unisubs,pculture/un... | apps/videos/management/commands/remove_youtube_credit.py | apps/videos/management/commands/remove_youtube_credit.py | # Amara, universalsubtitles.org
#
# Copyright (C) 2013 Participatory Culture Foundation
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your op... | agpl-3.0 | Python | |
bfd0e6da1b85fd7baa5fcf89d2e8f396147a3d48 | Define instance variables for base class | McGillX/edx_data_research,McGillX/edx_data_research,McGillX/edx_data_research | reporting_scripts/base.py | reporting_scripts/base.py | from pymongo import MongoClient
class BaseEdX(object):
def __init__(self, args):
self.url = args.url
client = MongoClient(self.url)
self.db = client[args.db_name]
self.collections = None
self.output_directory = args.output_directory
self.row_limit = args.row_limit
... | mit | Python | |
ef6accecdfbc87c664593cbad939cf1071cdf60d | Add merge migration | cyanfish/heltour,cyanfish/heltour,cyanfish/heltour,cyanfish/heltour | heltour/tournament/migrations/0088_merge.py | heltour/tournament/migrations/0088_merge.py | # -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-09-03 19:21
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('tournament', '0087_season_nominations_open'),
('tournament', '0087_navitem'),
]
oper... | mit | Python | |
f88e5b7438617fdd10a25951fc442f59a8def1ca | Add missing no-op migration for realm_emoji. | joyhchen/zulip,sharmaeklavya2/zulip,vaidap/zulip,timabbott/zulip,ahmadassaf/zulip,mohsenSy/zulip,arpith/zulip,AZtheAsian/zulip,zulip/zulip,niftynei/zulip,rht/zulip,dhcrzf/zulip,vabs22/zulip,vaidap/zulip,calvinleenyc/zulip,calvinleenyc/zulip,umkay/zulip,synicalsyntax/zulip,SmartPeople/zulip,KingxBanana/zulip,niftynei/zu... | zerver/migrations/0018_realm_emoji_message.py | zerver/migrations/0018_realm_emoji_message.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.core.validators
class Migration(migrations.Migration):
dependencies = [
('zerver', '0017_userprofile_bot_type'),
]
operations = [
migrations.AlterField(
mod... | apache-2.0 | Python | |
43f48997810879199e93bbf5dbf5c6764625c418 | Add swiftly.__main__, allowing for invocation via runpy. | gholt/swiftly | swiftly/__main__.py | swiftly/__main__.py | import swiftly.cli
if __name__ == '__main__':
raise SystemExit(swiftly.cli.CLI()())
| apache-2.0 | Python | |
fc51b8567c790596c98f2a218b96f992955a8bb6 | Create predictor.py | nevmenandr/thai-language | tagger/predictor.py | tagger/predictor.py | # -*- coding: utf-8 -*-
import codecs
import nltk
import dill
import lxml.etree
with open('my_tagger.dill', 'rb') as f:
hmm_tagger = dill.load(f)
def predict_untagged(filename):
f=codecs.open(filename, 'r', 'utf-8')
text=f.read()
f.close()
arr=[]
result=''
root = lxml.etree.fromstring(exem... | cc0-1.0 | Python | |
0df9d6523479e312d36fff4f86cb1776a7dfb9e2 | add managers.py | encorehu/hublog | blog/managers.py | blog/managers.py | # -*- coding: utf-8 -*-
# python.
#
# ------------------------------------------------------------
# django.
from django.db import models
from django.db.models import Q
# ------------------------------------------------------------
# 3dpart.
#
# ------------------------------------------------------------
# blog.
#... | mit | Python | |
d6fb34cc5bd107547da62b0994e32d19c9d6017b | Set order to status COMPLETED if payment was received and marked manually in the backend | schacki/django-shop,awesto/django-shop,chriscauley/django-shop,schacki/django-shop,khchine5/django-shop,dwx9/test,jrief/django-shop,katomaso/django-shop,rfleschenberg/django-shop,pjdelport/django-shop,jrief/django-shop,khchine5/django-shop,divio/django-shop,creimers/django-shop,jrutila/django-shop,khchine5/django-shop,... | shop/admin/orderadmin.py | shop/admin/orderadmin.py | #-*- coding: utf-8 -*-
from django.contrib import admin
from django.contrib.admin.options import ModelAdmin
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from shop.order_signals import completed
from shop.admin.mixins import LocalizeDecimalFieldsMixin
from shop.models.ordermod... | #-*- coding: utf-8 -*-
from django.contrib import admin
from django.contrib.admin.options import ModelAdmin
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from shop.admin.mixins import LocalizeDecimalFieldsMixin
from shop.models.ordermodel import (Order, OrderItem,
Orde... | bsd-3-clause | Python |
5126c2397ac092062f0ec3bb7a8081789f482a34 | Create server.py | bboalimoe/D_Server | server.py | server.py | __author__ = 'zhanghengyang'
from flask import Flask
import os
import json
from flask import request
import uuid
import numpy as np
import cv2
import json
import _process_image as pi
#from _process_image import CRect, Cvec4i
import time
import random
import string
#from preprocessing import proc
def proc(res):
if ... | mit | Python | |
acdb3190e11e0ecef37633ad8f39b30f8c26fc81 | Create server.py | imapi/flask_parser | server.py | server.py | import csv
from os import listdir
from os.path import isfile, join
from flask import Flask
from flaskext.jsonify import jsonify
app = Flask(__name__)
@app.route('/')
def index():
return app.send_static_file('index.html')
@app.route('/data')
@jsonify
def logs():
dict = []
for file in files():
f = o... | mit | Python | |
3f1f6ed6acbb3b6cf6dc717c7439e00deeb06c27 | Add AppConfig for microblogging app | amarandon/smeuhsocial,amarandon/smeuhsocial,amarandon/smeuhsocial | apps/microblogging/apps.py | apps/microblogging/apps.py | from django.apps import AppConfig
class MicrobloggingAppConfig(AppConfig):
name = "microblogging"
| mit | Python | |
40abe4a1434727105dfb29a19dfab6c9263df7d5 | add build_protoci.py for making protoci packages of all OS / python versions | ContinuumIO/ProtoCI,ContinuumIO/ProtoCI | build_protoci.py | build_protoci.py | """
build_protoci.py creates conda packages of
protoci for all operating systems and python versions.
Usage:
anaconda login
python build_protoci.py path anaconda_user
where:
conda build . is run at path
and
anaconda_user is the upload user
"""
import os
import shutil
from subprocess import *
import sys
... | bsd-3-clause | Python | |
5968c21c2c2b0e8305229fe5976d9d13786390e5 | Add notification for schedule being posted | fangeugene/the-blue-alliance,phil-lopreiato/the-blue-alliance,nwalters512/the-blue-alliance,synth3tk/the-blue-alliance,verycumbersome/the-blue-alliance,the-blue-alliance/the-blue-alliance,verycumbersome/the-blue-alliance,1fish2/the-blue-alliance,josephbisch/the-blue-alliance,tsteward/the-blue-alliance,tsteward/the-blue... | notifications/schedule_posted.py | notifications/schedule_posted.py | from consts.notification_type import NotificationType
from notifications.base_notification import BaseNotification
class SchedulePostedNotification(BaseNotification):
def __init__(self, event):
self.event = event
def _build_dict(self):
data = {}
data['message_type'] = NotificationTyp... | mit | Python | |
5f5336d75c569841581da45af57e1c1b60555195 | Create diff.py | radical-cybertools/radical.ensemblemd,radical-cybertools/radical.ensemblemd | src/radical/ensemblemd/kernel_plugins/misc/diff.py | src/radical/ensemblemd/kernel_plugins/misc/diff.py | #!/usr/bin/env python
"""A kernel that compares two ASCII files and outputs the differences in a detailed
format.
"""
__author__ = "Ioannis Paraskevakos <i.paraskev@rutgers.edu>"
__copyright__ = "Copyright 2014, http://radical.rutgers.edu"
__license__ = "MIT"
from copy import deepcopy
from radical.ensemblem... | mit | Python | |
577aef2cbac79a65095b57036cda3a3175ff54be | Add some tests for EmailTemplate behavior | caktus/django-opendebates,ejucovy/django-opendebates,ejucovy/django-opendebates,ejucovy/django-opendebates,caktus/django-opendebates,ejucovy/django-opendebates,caktus/django-opendebates,caktus/django-opendebates | opendebates/tests/test_emails.py | opendebates/tests/test_emails.py | from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test.utils import override_settings
from django.core import mail
from opendebates_emails.models import EmailTemplate
from .factories import CategoryFactory, UserFactory, VoterFactory
@override_settings(EMAIL_BACKEND='django.co... | apache-2.0 | Python | |
3062ef8363db36ce385c913ec32eca6b02aa9867 | Add runapp to run a devel server | Storj/downstream-node,Storj/downstream-node | runapp.py | runapp.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Runs the development server of the downstream_node app.
# Not for production use.
from downstream_node.startup import app
def main():
app.run(debug=True)
if __name__ == '__main__':
main() | mit | Python | |
74dc26aa7180f7df26c5b975d7cd6a0443d04d78 | Fix test on windows. | M4rtinK/pyside-android,IronManMark20/pyside2,pankajp/pyside,M4rtinK/pyside-bb10,IronManMark20/pyside2,RobinD42/pyside,BadSingleton/pyside2,gbaty/pyside2,M4rtinK/pyside-bb10,qtproject/pyside-pyside,M4rtinK/pyside-android,enthought/pyside,M4rtinK/pyside-bb10,qtproject/pyside-pyside,enthought/pyside,PySide/PySide,RobinD42... | tests/QtGui/qinputcontext_test.py | tests/QtGui/qinputcontext_test.py |
import unittest
from PySide.QtCore import Qt
from PySide.QtGui import QPushButton
from helper import UsesQApplication
class QInputContextTest(UsesQApplication):
def testSetFocusWidget(self):
widget = QPushButton()
widget.show()
context = self.app.inputContext()
self.assertEqual(... |
import unittest
from PySide.QtCore import Qt
from PySide.QtGui import QPushButton
from helper import UsesQApplication
class QInputContextTest(UsesQApplication):
def testSetFocusWidget(self):
widget = QPushButton()
widget.show()
if not widget.testAttribute(Qt.WA_InputMethodEnabled):
... | lgpl-2.1 | Python |
e0e9b046b566ba4d688bd26a9f489ae9188f50a8 | add minimal naive WTA-Hash implementation | coblo/isccbench | iscc_bench/algos/wta.py | iscc_bench/algos/wta.py | # -*- coding: utf-8 -*-
"""WTA-Hash - Winner Takes All
A sparse embedding method based on rank correlation measures.
As presented in:
The Power of Comparative Reasoning
by Jay Yagnik, Dennis Strelow, David A. Ross, Ruei-sung Lin
DOI:10.1109/ICCV.2011.6126527
https://dblp.org/rec/conf/iccv/YagnikSRL11
"""
def wta_ha... | bsd-2-clause | Python | |
a002ad4503312d17e4aa6328b68dc7b4762261dd | send message to user without id | wkentaro/slacker-cli,juanpabloaj/slacker-cli,crackleware/slacker-cli,beni55/slacker-cli | slacker_cli/__init__.py | slacker_cli/__init__.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Send message to Slack from command line
"""
from slacker import Slacker
import argparse
import sys
import os
def id_from_list_dict(list_dict, key_name):
for d in list_dict:
if d['name'] == key_name:
return d['id']
def post_message(token,... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Send message to Slack from command line
"""
from slacker import Slacker
import argparse
import sys
import os
def id_from_list_dict(list_dict, key_name):
for d in list_dict:
if d['name'] == key_name:
return d['id']
def post_message(token,... | mit | Python |
a50110c6c6e29b6e15f76e305765a023f93dddbb | add a simple python sample using modelDB | mitdbg/modeldb,mitdbg/modeldb,mitdbg/modeldb,mitdbg/modeldb,mitdbg/modeldb | client/python/samples/sklearn/SimpleSampleWithModelDB.py | client/python/samples/sklearn/SimpleSampleWithModelDB.py | import pandas as pd
from sklearn.cross_validation import train_test_split
from sklearn import linear_model
from sklearn.metrics import accuracy_score
from modeldb.sklearn_native.ModelDbSyncer import *
from modeldb.sklearn_native import SyncableMetrics
DATA_PATH = '../../../../data/'
'''
Source: http://archive.ics.uc... | mit | Python | |
4aa37bafa437614542c58f6d8ad40d9d8670df95 | Add test cases for the logger | thombashi/pytablewriter | test/test_logger.py | test/test_logger.py | # encoding: utf-8
"""
.. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
"""
from __future__ import print_function
from __future__ import unicode_literals
import logbook
from pytablewriter import (
set_logger,
set_log_level,
)
import pytest
class Test_set_logger(object):
@pytest.mark.para... | mit | Python | |
3cabe517b581284f5e507b100e2738ddfb7afd15 | Add celeryconfig file | alessandroHenrique/coinpricemonitor,alessandroHenrique/coinpricemonitor,alessandroHenrique/coinpricemonitor | bitcoinmonitor/celeryconfig.py | bitcoinmonitor/celeryconfig.py | from celery import Celery
from celery.decorators import periodic_task
from celery.utils.log import get_task_logger
from celery.task.schedules import crontab
from django.conf import settings
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bitcoinmonitor.settings')
app = Celery('bitcoinmonitor', broker='red... | mit | Python | |
71cd3709ba08bf87825816099e203eae57c05752 | Add script that creates an addendum to the english superset, to account for new dictionaries being added. Ensures we don't already have the english words in the existing set before adding them in | brendandc/multilingual-google-image-scraper | dictionaries/scripts/create_english_superset_addendum.py | dictionaries/scripts/create_english_superset_addendum.py | import optparse
import os
optparser = optparse.OptionParser()
optparser.add_option("-n", "--new_files", dest="new_files", default="", help="Comma separated list of new files")
optparser.add_option("-d", "--directory", dest="directory", default="dictionaries/", help="Directory with dictionaries")
optparser.add_option("... | mit | Python | |
7142f5c2566976f09236a1f1eb92f8c5fb48ce8d | test for initial state | doy/libvt100-python,doy/libvt100-python | t/init_test.py | t/init_test.py | from . import VT100Test
class InitTest(VT100Test):
def test_init(self):
assert self.vt.rows == 24
assert self.vt.cols == 80
row, col = self.vt.cursor_pos()
assert row == 0
assert col == 0
cell = self.vt.cell(0, 0)
assert cell.contents() == ""
cell =... | mit | Python | |
7ba3ae09ab58052fab8cdc78ad76d2429b4bc411 | Add coord_transform.py | Neurita/boyle | boyle/nifti/coord_transform.py | boyle/nifti/coord_transform.py | # coding=utf-8
#-------------------------------------------------------------------------------
#Author: Alexandre Manhaes Savio <alexsavio@gmail.com>
#Grupo de Inteligencia Computational <www.ehu.es/ccwintco>
#Universidad del Pais Vasco UPV/EHU
#
#2013, Alexandre Manhaes Savio
#Use this at your own risk!
#-----------... | bsd-3-clause | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.