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 |
|---|---|---|---|---|---|---|---|---|
a68699fbea88b541c6ce8bd519c3886b0fa8f197 | Add a script for EtherBone transfers profiling | antmicro/litex-rowhammer-tester,antmicro/litex-rowhammer-tester,antmicro/litex-rowhammer-tester | scripts/etherbone_perf.py | scripts/etherbone_perf.py | import time
import cProfile
import argparse
from utils import memread, memwrite
def run(wb, rw, n, *, burst, profile=True):
datas = list(range(n))
ctx = locals()
ctx['wb'] = wb
ctx['memread'] = memread
ctx['memwrite'] = memwrite
fname = 'tmp/profiling/{}_0x{:x}_b{}.profile'.format(rw, n, bu... | apache-2.0 | Python | |
49997157e722c7c6b3b6379043e04f4f897e2f2b | Create fetch-wms-urls.py | tri-state-epscor/wcwave_adaptors,tri-state-epscor/wcwave_adaptors,VirtualWatershed/vw-py,VirtualWatershed/vw-py | scripts/fetch-wms-urls.py | scripts/fetch-wms-urls.py | #!/usr/bin/python
import requests
import json
host = raw_input('Hostname or IP Address: ')
model_run_uuid = raw_input('Enter the model_run_uuid: ')
model_set = "outputs"
model_set_type = "vis"
protocal = "http://"
search = "/apps/my_app/search/datasets.json?version=3"
uuid = "&model_run_uuid=" + model_run_uuid
ms... | bsd-2-clause | Python | |
62bbd685a62abb56e59777cc6b5e1bd33bb60d4a | add 'attr_or_default' filter | serge-name/myansible,serge-name/myansible,serge-name/myansible | filter_plugins/attr_or_default.py | filter_plugins/attr_or_default.py | from jinja2.runtime import Undefined, StrictUndefined
class FilterModule(object):
''' A comment '''
def filters(self):
return {
'attr_or_default': self.attr_or_default,
}
def attr_or_default(self, input_value, name, default):
if type(input_value) not in (StrictUndefine... | mit | Python | |
5c5ec934e540ab13f8d153d6855c23a06d0c0f3d | Add sample thrift client | voidabhi/python-scripts,voidabhi/python-scripts,voidabhi/python-scripts,voidabhi/python-scripts,voidabhi/python-scripts | thrift-client.py | thrift-client.py |
import logging
import thriftpy
from thriftpy.rpc import make_client
logging.basicConfig(level=logging.DEBUG)
pingpong_thrift = thriftpy.load("pingpong.thrift",
module_name="pingpong_thrift")
client = make_client(pingpong_thrift.PingPong, '127.0.0.1', 6000)
print(client.ping())
| mit | Python | |
95d3971b625091d9d750d0d2a861e7d61cc5bf49 | add example of 8 queens code for Python 3 which uses "yield from" | ContinuumIO/pycosat,ContinuumIO/pycosat,sandervandorsten/pycosat,sandervandorsten/pycosat | examples/8queens_py3k.py | examples/8queens_py3k.py | import pycosat
N = 8
def v(i, j):
return N * i + j + 1
def to_cnf(vs, eq=False):
if eq:
yield vs
for v1 in vs:
for v2 in vs:
if v1 < v2:
yield [-v1, -v2]
def queens_clauses():
# rows and columns
for i in range(N):
yield from to_cnf([v(i, j) fo... | mit | Python | |
26b04db5e3bb803d96f0d3e42b8048d49c7c8486 | Add activity_version support | godiard/sugar-toolkit-gtk3,godiard/sugar-toolkit-gtk3,i5o/sugar-toolkit-gtk3,gusDuarte/sugar-toolkit-gtk3,samdroid-apps/sugar-toolkit-gtk3,tchx84/debian-pkg-sugar-toolkit-gtk3,quozl/sugar-toolkit-gtk3,i5o/sugar-toolkit-gtk3,puneetgkaur/sugar-toolkit-gtk3,sugarlabs/sugar-toolkit-gtk3,sugarlabs/sugar-toolkit-gtk3,quozl/s... | sugar/activity/bundle.py | sugar/activity/bundle.py | import logging
import os
from ConfigParser import ConfigParser
class Bundle:
"""Info about an activity bundle. Wraps the activity.info file."""
def __init__(self, path):
self._name = None
self._icon = None
self._service_name = None
self._show_launcher = False
self._valid = True
self._path = path
self.... | import logging
import os
from ConfigParser import ConfigParser
class Bundle:
"""Info about an activity bundle. Wraps the activity.info file."""
def __init__(self, path):
self._name = None
self._icon = None
self._service_name = None
self._show_launcher = False
self._valid = True
self._path = path
info... | lgpl-2.1 | Python |
3c96d56cca8c93676194efc9c9830eb7eb143a7c | add migration for notification tables | uwcirg/true_nth_usa_portal,uwcirg/true_nth_usa_portal,uwcirg/true_nth_usa_portal,uwcirg/true_nth_usa_portal | portal/migrations/versions/458dd2fc1172_.py | portal/migrations/versions/458dd2fc1172_.py | from alembic import op
import sqlalchemy as sa
"""empty message
Revision ID: 458dd2fc1172
Revises: 8ecdd6381235
Create Date: 2017-12-21 16:38:49.659073
"""
# revision identifiers, used by Alembic.
revision = '458dd2fc1172'
down_revision = '8ecdd6381235'
def upgrade():
# ### commands auto generated by Alembic... | bsd-3-clause | Python | |
c788bee5cbc6306e8d5a14252f724709af272845 | add script that can allow you to re-queue background jobs | DOAJ/doaj,DOAJ/doaj,DOAJ/doaj,DOAJ/doaj | portality/scripts/requeue_background_job.py | portality/scripts/requeue_background_job.py | from portality import models
from portality.lib import dates
from portality.tasks.ingestarticles import IngestArticlesBackgroundTask
from portality.tasks.suggestion_bulk_edit import SuggestionBulkEditBackgroundTask
from portality.tasks.sitemap import SitemapBackgroundTask
from portality.tasks.read_news import ReadNews... | apache-2.0 | Python | |
ff6e16330974bf9a8487bf01959afc7445c5313e | add an example for dependencies | pombredanne/inferno,oldmantaiter/inferno,chango/inferno | inferno/example_rules/chain.py | inferno/example_rules/chain.py | from inferno.lib.rule import chunk_json_stream, json_reduce_output_stream
from inferno.lib.rule import InfernoRule
AUTORUN = True
def count(parts, params):
parts['count'] = 1
yield parts
def processor(iter, **params):
with open("/tmp/tst_copy_of_results", 'a') as f:
for k, v in iter:
... | mit | Python | |
43914c4c890a2b33730b9b760eda156d15eb89bc | Make the cookie-flood fit in 256KB. | smishenk/blink-crosswalk,kurli/blink-crosswalk,crosswalk-project/blink-crosswalk-efl,hgl888/blink-crosswalk-efl,Pluto-tv/blink-crosswalk,Bysmyyr/blink-crosswalk,Pluto-tv/blink-crosswalk,smishenk/blink-crosswalk,crosswalk-project/blink-crosswalk-efl,modulexcite/blink,hgl888/blink-crosswalk-efl,hgl888/blink-crosswalk-efl... | LayoutTests/http/tests/websocket/cookie-flood_wsh.py | LayoutTests/http/tests/websocket/cookie-flood_wsh.py | # Copyright (C) 2013 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the ... | # Copyright (C) 2013 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the ... | bsd-3-clause | Python |
0277a1f1fc5ff63100b10d4e427c267e19330cbc | Create second-minimum-node-in-a-binary-tree.py | tudennis/LeetCode---kamyu104-11-24-2015,kamyu104/LeetCode,kamyu104/LeetCode,tudennis/LeetCode---kamyu104-11-24-2015,tudennis/LeetCode---kamyu104-11-24-2015,yiwen-luo/LeetCode,yiwen-luo/LeetCode,yiwen-luo/LeetCode,kamyu104/LeetCode,yiwen-luo/LeetCode,tudennis/LeetCode---kamyu104-11-24-2015,kamyu104/LeetCode,kamyu104/Lee... | Python/second-minimum-node-in-a-binary-tree.py | Python/second-minimum-node-in-a-binary-tree.py | # Time: O(n)
# Space: O(h)
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def findSecondMinimumValue(self, root):
"""
:type root: TreeNode
:rt... | mit | Python | |
0881a132bff37cabdbd0f4c44b8d19e5f13c05fc | Create strBinaryXOR.py | NendoTaka/CodeForReference,NendoTaka/CodeForReference,NendoTaka/CodeForReference | Codingame/Python/Clash/strBinaryXOR.py | Codingame/Python/Clash/strBinaryXOR.py | import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
n_1, n_2 = input().split()
for x in range(len(n_1)):
if (n_1[x] == '1' or n_2[x] == '1') and n_1[x] != n_2[x]:
print('1',end='')
else:
print('0',end='')
# Write... | mit | Python | |
d38705c7ac79d289b1a7dfc523206cd3e475d6f8 | Introduce relationship builder. | vdragan1993/serbian-document-network | src/relationship_builder.py | src/relationship_builder.py | # coding=utf-8
__author__ = "Dragan Vidakovic"
import reader
import os
import writer
from collections import OrderedDict
from operator import itemgetter
def load_doc_num(file_path):
lines = reader.read_file_line(file_path)
doc_num_mapper = {}
num_doc_mapper = {}
clean_lines = [line[:-2] for line in li... | apache-2.0 | Python | |
62529b40aff31ec92ae3af5bba00ee7dc4513398 | add examples tests | lorehov/json-rpc,clach04/json-rpc | jsonrpc/tests/test_examples.py | jsonrpc/tests/test_examples.py | """ Exmples of usage with tests.
Tests in this file represent examples taken from JSON-RPC specification.
http://www.jsonrpc.org/specification#examples
"""
import unittest
import json
from ..jsonrpc import JSONRPCResponseManager
def isjsonequal(json1, json2):
return json.loads(json1) == json.loads(json2)
clas... | mit | Python | |
2cf562437aeb25cb72db7c48a6f11ada30d03321 | Create robot_joystick | CSavvy/python | extras/robot_joystick.py | extras/robot_joystick.py | # This program lets a user control a robot with a joystick and
# test taking pictures and making the robot beep
# This function checks if a point is inside the joystick circle
def checkIfInCircle(x, y):
from math import *
if fabs((x - 250)*(x - 250) + (y - 250)*(y - 250)) <= 245*245:
return True
e... | mit | Python | |
a6d5640b3ac1ad84591313b8d1588d1082eba322 | add initial transducer library | karansag/transducers-py | transducers.py | transducers.py | from itertools import chain
def mapper(f):
def tducer(reducer):
def reduce_applier(result, item):
return reducer(result, f(item))
return reduce_applier
return tducer
def filterer(f):
def tducer(reducer):
def reduce_applier(result, item):
return reducer(res... | mit | Python | |
5c50f133de0cc4ca1fc2716eeda3d61f79abba72 | create switch.py | mrjoh3/raspberrypi | switch.py | switch.py | # from: http://razzpisampler.oreilly.com/ch07.html
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP) # or try 16
while True:
input_state = GPIO.input(21)
if input_state == False:
print('Button Pressed')
time.sleep(0.2)
| mit | Python | |
0a75aa4bbb9396c448b4cef58a42068d30933a95 | Add tests for formatter raw | eiri/echolalia-prototype | tests/formatter/test_rawer.py | tests/formatter/test_rawer.py | import unittest, argparse
from echolalia.formatter.rawer import Formatter
class RawerTestCase(unittest.TestCase):
def setUp(self):
self.parser = argparse.ArgumentParser()
self.data = [{chr(i): i - 96} for i in xrange(97, 123)]
self.formatter = Formatter()
def test_add_args(self):
self.assertEqual... | mit | Python | |
1d462c4c0a86890a00f2411064f30adce38ebb88 | Add first mmtl unit tests | HazyResearch/metal,HazyResearch/metal | tests/metal/mmtl/test_mmtl.py | tests/metal/mmtl/test_mmtl.py | import unittest
from collections import defaultdict
import numpy as np
import torch
import torch.nn as nn
from metal.mmtl.data import MmtlDataLoader, MmtlDataset
from metal.mmtl.metal_model import MetalModel
from metal.mmtl.payload import Payload
from metal.mmtl.task import ClassificationTask
from metal.mmtl.trainer ... | apache-2.0 | Python | |
e1d15d3a0683cf98ecc7f7705d8f0695f86da7ca | refactor new example, find image tag | afunTW/dsc-crawling,afunTW/dsc-crawling | Section_3/Lab_0_image_crawling/step_0_get_img_tag.py | Section_3/Lab_0_image_crawling/step_0_get_img_tag.py | import requests
from bs4 import BeautifulSoup
# 取得目標網頁
response = requests.get('https://gushi.tw/hu-shih-memorial-hall/')
# 透過 Beautifulsoup 解析網頁
soup = BeautifulSoup(response.text, 'lxml')
# 取得所有的 p tag 與 img tag
text = soup.find_all('p')
image = soup.find_all('img')
# 檢查第四個 p tag 內容
print(u'文字 tag:')
print(text[... | apache-2.0 | Python | |
c62cff6538775382f5e2acbee59bda8c4ae2316b | add problem 065 | smrmkt/project_euler | problem_065.py | problem_065.py | #!/usr/bin/env python
#-*-coding:utf-8-*-
'''
The square root of 2 can be written as an infinite continued fraction.
The infinite continued fraction can be written, √2 = [1;(2)],
(2) indicates that 2 repeats ad infinitum. In a similar way, √23 = [4;(1,3,1,8)].
It turns out that the sequence of partial values of conti... | mit | Python | |
546bc7ffab0a0ca287550d97946d3e8b12b6c59a | Add script to copy the files to their correct location (e.g. during testing) | khenderick/zfs-snap-manager,tylerjl/zfs-snap-manager | tools/distribute.py | tools/distribute.py | #!/usr/bin/python2
# Copyright (c) 2015 Kenneth Henderick <kenneth@ketronic.be>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
... | mit | Python | |
165e96a56f6b1ac2d6387163f7b834dc20fe49cb | Create Sum_areas_rectangle.py | ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovs... | greedy/sum_areas_rectangle/python/Sum_areas_rectangle.py | greedy/sum_areas_rectangle/python/Sum_areas_rectangle.py | # Python3 code to find sum
# of all area rectangle
# possible
# Function to find
# area of rectangles
def MaxTotalRectangleArea(a, n) :
# sorting the array in
# descending order
a.sort(reverse = True)
# store the final sum of
# all the rectangles area
# possible
sum = 0
flag = False
# temporar... | cc0-1.0 | Python | |
2ded865419c9d7047ce75fab868a27b9307f1e92 | Add initial SyntaxController tests. | pySUMO/pysumo,pySUMO/pysumo | test/lib/syntaxcontroller.py | test/lib/syntaxcontroller.py | import unittest
from pysumo.syntaxcontroller import SyntaxController
from pysumo.indexabstractor import IndexAbstractor
from pysumo.parser import Ontology, kifparse
class syntaxTestCase(unittest.TestCase):
def setUp(self):
self.sumo = Ontology('data/Merge.kif', name='SUMO')
self.milo = Ontology('d... | bsd-2-clause | Python | |
1c02bec953220fce3d6f07be829ea39eb664ad50 | Add missing flatten function | dleehr/cwltool,chapmanb/cwltool,ohsu-computational-biology/common-workflow-language,common-workflow-language/schema_salad,hmenager/common-workflow-language,common-workflow-language/common-workflow-language,SciDAP/cwltool,hmenager/common-workflow-language,dleehr/common-workflow-language,hmenager/common-workflow-language... | schema_salad/flatten.py | schema_salad/flatten.py | # http://rightfootin.blogspot.com/2006/09/more-on-python-flatten.html
def flatten(l, ltypes=(list, tuple)):
if l is None:
return []
if not isinstance(l, ltypes):
return [l]
ltype = type(l)
l = list(l)
i = 0
while i < len(l):
while isinstance(l[i], ltypes):
if... | apache-2.0 | Python | |
550f7e697527c7e8dba150ed7b133c987c86c750 | Add keras callback | polyaxon/polyaxon,polyaxon/polyaxon,polyaxon/polyaxon | polyaxon_client/contrib/keras.py | polyaxon_client/contrib/keras.py | # -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
from polyaxon_client.exceptions import PolyaxonClientException
try:
from keras.callbacks import Callback
except ImportError:
try:
from tensorflow.python.keras.callbacks import Callback
except ImportError:
... | apache-2.0 | Python | |
60125c0852780d88ec29757c8a11a5846a4e1bba | Upgrade script to add many:many relationship between orgs and rps. | uwcirg/true_nth_usa_portal,uwcirg/true_nth_usa_portal,uwcirg/true_nth_usa_portal,uwcirg/true_nth_usa_portal | portal/migrations/versions/63262fe95b9c_.py | portal/migrations/versions/63262fe95b9c_.py | from alembic import op
import sqlalchemy as sa
"""empty message
Revision ID: 63262fe95b9c
Revises: 13a45e9375d7
Create Date: 2018-02-28 13:17:47.248361
"""
# revision identifiers, used by Alembic.
revision = '63262fe95b9c'
down_revision = '13a45e9375d7'
def upgrade():
# ### commands auto generated by Alembic... | bsd-3-clause | Python | |
bc65922593a09c1542fb255fe4e3601fbb23b02c | fix server | snower/forsun,snower/forsun | forsun/servers/server.py | forsun/servers/server.py | # -*- coding: utf-8 -*-
# 15/6/10
# create by: snower
import logging
import threading
from tornado.ioloop import IOLoop, asyncio
from tornado.httpserver import HTTPServer
from thrift.protocol.TBinaryProtocol import TBinaryProtocolAcceleratedFactory
from torthrift.transport import TIOStreamTransportFactory
from torthri... | mit | Python | |
cd2cd08a8434ef50fd01c6e10d8bafed9de1a82a | Add conftest file missing from previous commit. | nylas/sync-engine,Eagles2F/sync-engine,closeio/nylas,closeio/nylas,Eagles2F/sync-engine,nylas/sync-engine,Eagles2F/sync-engine,ErinCall/sync-engine,gale320/sync-engine,jobscore/sync-engine,closeio/nylas,wakermahmud/sync-engine,wakermahmud/sync-engine,jobscore/sync-engine,jobscore/sync-engine,nylas/sync-engine,nylas/syn... | tests/scheduling/conftest.py | tests/scheduling/conftest.py | from tests.util.base import dbloader, db, default_account
| agpl-3.0 | Python | |
d61862b138858721d6baf06ab2ad29ebb566f09b | Add test to check when an acceptor name is bad | frenche/mod_auth_gssapi,frenche/mod_auth_gssapi,frenche/mod_auth_gssapi,frenche/mod_auth_gssapi | tests/t_bad_acceptor_name.py | tests/t_bad_acceptor_name.py | #!/usr/bin/python
# Copyright (C) 2015 - mod_auth_gssapi contributors, see COPYING for license.
import os
import requests
from stat import ST_MODE
from requests_kerberos import HTTPKerberosAuth, OPTIONAL
if __name__ == '__main__':
sess = requests.Session()
url = 'http://%s/bad_acceptor_name/' % os.environ['N... | mit | Python | |
b0b5e3c19023445da5ee4df5600638bdf8d6aad3 | Add unittest coverage | Antlos/pycontextbroker | tests/test_context_broker.py | tests/test_context_broker.py | from pycontextbroker.pycontextbroker import ContextBrokerClient
import unittest
class PycontextbrokerTestCase(unittest.TestCase):
def setUp(self):
self.cbc = ContextBrokerClient('192.168.99.100', '1026')
def test_get_version_data(self):
version_data = self.cbc.get_version_data()
self... | mit | Python | |
fcf04ce5960679dd4a939f0a3328d314350b5c09 | Add existing PKLprod to solution | MikaelFuresjo/ImundboQuant | src/IQ19j_PKLprod_01.py | src/IQ19j_PKLprod_01.py | """
MIT License
Copyright (c) [2016] [Mikael Furesjö]
Software = Python Scripts in the [Imundbo Quant v1.9] series
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including w... | mit | Python | |
57cd6ebe631d6d659a969790c5ec6155273bea8b | Create s_percep.py | ghost9023/DeepLearningPythonStudy | DeepLearning/DeepLearning/04_Deep_LeeWJ/s_percep.py | DeepLearning/DeepLearning/04_Deep_LeeWJ/s_percep.py | import numpy as np
def AND_GATE(x):
vec_x = np.array(x)
w = [0.5, 0.5]
vec_w = np.array(w)
b = -0.7
dot_product = np.sum(vec_x * vec_w)
net_value = dot_product + b
return False if net_value <= 0 else True
print(AND_GATE([0, 1]))
def NAND_GATE(x):
vec_x = np.array(x)
w = [-0.5, ... | mit | Python | |
2ca883b3ad0a0d4c3a3fba82693066f36e34e7fa | Create stone-game.py | kamyu104/LeetCode,kamyu104/LeetCode,tudennis/LeetCode---kamyu104-11-24-2015,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 | Python/stone-game.py | Python/stone-game.py | # Time: O(n^2)
# Space: O(n)
# Alex and Lee play a game with piles of stones.
# There are an even number of piles arranged in a row,
# and each pile has a positive integer number of stones piles[i].
#
# The objective of the game is to end with the most stones.
# The total number of stones is odd, so there are no ties... | mit | Python | |
1fb0ef51b6f994e210eee70c63af1bccee8f578d | Refactor tests - try and use a standard scenario | pkimber/login,pkimber/login,pkimber/login | login/tests/scenario.py | login/tests/scenario.py | from django.contrib.auth.models import User
from login.tests.model_maker import (
make_superuser,
make_user,
)
def get_fred():
return User.objects.get(username='fred')
def get_sara():
return User.objects.get(username='sara')
def user_default():
# superuser
make_superuser('admin')
# me... | apache-2.0 | Python | |
80ed06574c98c738fb0ce5d6cb69f5542bafa9bf | Add separate node for uscs messages | EndPointCorp/lg_ros_nodes,EndPointCorp/lg_ros_nodes,EndPointCorp/lg_ros_nodes,EndPointCorp/lg_ros_nodes,EndPointCorp/lg_ros_nodes,EndPointCorp/lg_ros_nodes | rfid_scanner/scripts/sqlite_uscs_storage.py | rfid_scanner/scripts/sqlite_uscs_storage.py | #!/usr/bin/env python
import sqlite3
import json
from std_msgs.msg import String
import rospy
class MockPub(object):
def publish(self, *args, **kwargs):
pass
class RfidStorage(object):
def __init__(self, database_path, state_set_pub=MockPub(),
error_pub=MockPub(), table_name="RFID_... | apache-2.0 | Python | |
c53c13cff5900c6f3279076ae84a8794f230def2 | Create question4.py | pythonzhichan/DailyQuestion,pythonzhichan/DailyQuestion | dingshubo/question4.py | dingshubo/question4.py | #!/user/bin/env python
#_*_coding:utf-8_*_
try:
num_input=int(raw_input('请输入你想获得n+2位的斐波那契数列):')) #输出斐波那契数列个数,2为初始位
num_feb=[0,1] #初始位
while num_input<=0:
print('你所输入的不是一个有效整数!')
break
for i in range(0,num_input):
num_feb.append(num_feb[-2]+num_feb[-1])
print('所想获得的斐波那契数列为%r')%num_feb
e... | mit | Python | |
1870cc1f25426bee9b1b4a66f2167c5cd474cd23 | Add functional tests for DVR router. | stackforge/python-openstacksdk,dtroyer/python-openstacksdk,dtroyer/python-openstacksdk,briancurtin/python-openstacksdk,briancurtin/python-openstacksdk,openstack/python-openstacksdk,stackforge/python-openstacksdk,openstack/python-openstacksdk | openstack/tests/functional/network/v2/test_dvr_router.py | openstack/tests/functional/network/v2/test_dvr_router.py | # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under t... | apache-2.0 | Python | |
1c9b9955a2c89e0b67288c56fdac0af8272d19a5 | Add FP-Tree | qiyuangong/Machine_Learning_in_Action_QYG,qiyuangong/Machine_Learning_in_Action_QYG | fpGrowth.py | fpGrowth.py |
class treeNode:
def __init__(self, nameValue, numOccur, parentNode):
self.name = nameValue
self.count = numOccur
self.nodeLink = None
self.parent = parentNode
self.children = {}
def inc(self, numOccur):
self.count += numOccur
def disp(self, ind=1):
... | mit | Python | |
49f60efd807d0e0d7f825bc92cd199d458586c09 | add 98 | EdisonAlgorithms/ProjectEuler,EdisonAlgorithms/ProjectEuler,zeyuanxy/project-euler,zeyuanxy/project-euler,zeyuanxy/project-euler,EdisonAlgorithms/ProjectEuler,zeyuanxy/project-euler,EdisonAlgorithms/ProjectEuler | vol2/98.py | vol2/98.py | import urllib2, itertools
def sq(n):
x = int(''.join(y[letter_set[i]] for i in n))
return x if int(x ** 0.5) ** 2 == x else False
if __name__ == "__main__":
file_url = "https://projecteuler.net/project/resources/p098_words.txt"
words = [(w[1:-1], sorted(w[1:-1]))
for w in urllib2.urlopen(file_... | mit | Python | |
4f7c9ee055a4812ec70c3236d530ab1cdfc2db92 | Add unittest for condition decorators | jnishi/chainer,hvy/chainer,jnishi/chainer,okuta/chainer,cupy/cupy,keisuke-umezawa/chainer,tscohen/chainer,woodshop/chainer,okuta/chainer,chainer/chainer,muupan/chainer,chainer/chainer,ronekko/chainer,tereka114/chainer,jfsantos/chainer,aonotas/chainer,sinhrks/chainer,yanweifu/chainer,benob/chainer,chainer/chainer,ktnyt/... | tests/testing_tests/test_condition.py | tests/testing_tests/test_condition.py | import unittest
from chainer.testing import condition
# The test fixtures of this TestCase is used to be decorated by
# decorator in test. So we do not run them alone.
class MockUnitTest(unittest.TestCase):
counter = 0
def failure_case(self):
self.fail()
def success_case(self):
self.as... | mit | Python | |
cc03be92c4039429dd5eb62305bf08b21a3cff9d | allow for empty creds | praekelt/django-google-credentials | google_credentials/models.py | google_credentials/models.py | from django.db import models
from oauth2client.django_orm import CredentialsField
class Credentials(models.Model):
client_id = models.CharField(
max_length=128
)
credentials = CredentialsField(
editable=False,
blank=True,
null=True,
)
| from django.db import models
from oauth2client.django_orm import CredentialsField
class Credentials(models.Model):
client_id = models.CharField(
max_length=128
)
credentials = CredentialsField(
editable=False
)
| bsd-3-clause | Python |
a8a3299a02574f597fad7a495fe5ed8e9002ca9d | add tests for version specs on yotta in module.json | ARMmbed/yotta,autopulated/yotta,ARMmbed/yotta,autopulated/yotta | yotta/test/cli/test_minversion.py | yotta/test/cli/test_minversion.py | #!/usr/bin/env python
# Copyright 2015 ARM Limited
#
# Licensed under the Apache License, Version 2.0
# See LICENSE file for details.
# standard library modules, , ,
import unittest
import copy
# internal modules:
from yotta.test.cli import cli
from yotta.test.cli import util
Test_Min_Version_Insufficient = copy.cop... | apache-2.0 | Python | |
b9d77b07640ae36607d313b4aba2ad88edae1e3b | Add clique.assemble unit tests. | 4degrees/clique | test/unit/test_clique.py | test/unit/test_clique.py | # :coding: utf-8
# :copyright: Copyright (c) 2013 Martin Pengelly-Phillips
# :license: See LICENSE.txt.
import re
import pytest
import clique
def test_assemble():
'''Assemble collections from arbitrary items.'''
items = [
'file.ext',
'single.1.ext',
'1', '3',
'001', '003',
... | apache-2.0 | Python | |
b7b18cfc9ffad3f37a34697b3bc331541c7e7149 | Add update script | DofMod/MarketPlace | update.py | update.py | #!python
import urllib2
import json
outPath = "modules.json"
if __name__ == "__main__" :
try:
result = urllib2.urlopen("https://api.github.com/users/dofmod/repos")
except urllib2.HTTPError:
print("Repositories request error")
exit()
repositories = json.loads(result.read())
modsInfos = []
for repository i... | mit | Python | |
b58a8699b7e1ef7e0d0aef889f3f51e24ac108b9 | Add specialized worker script | Cal-CS-61A-Staff/ok,Cal-CS-61A-Staff/ok,Cal-CS-61A-Staff/ok,Cal-CS-61A-Staff/ok,Cal-CS-61A-Staff/ok | worker.py | worker.py | #!/usr/bin/env python3
import os
from flask_rq import get_worker
from raven import Client
from raven.transport.http import HTTPTransport
from rq.contrib.sentry import register_sentry
from server import create_app
if __name__ == '__main__':
# default to dev config
env = os.environ.get('OK_ENV', 'dev')
app... | apache-2.0 | Python | |
44d621b6f3c4f0f4d06056072d91807f2d9fb1e4 | Implement generic registry metaclass for pluggable architectures | edgedb/edgedb,edgedb/edgedb,edgedb/edgedb | edgedb/lang/common/functional/plugin.py | edgedb/lang/common/functional/plugin.py | ##
# Copyright (c) 2012 Sprymix Inc.
# All rights reserved.
#
# See LICENSE for details.
##
class PluginError(TypeError):
pass
class PluginMeta(type):
"""Generic plugin registry.
A base metaclass used to support pluggable architectures where
interface implementaitons are loosely coupled and the spe... | apache-2.0 | Python | |
5a489f679ef05a62872282a0c995275abd1f18e7 | Create capturing_non_capturing_groups.py | costincaraivan/hackerrank,costincaraivan/hackerrank | regex/grouping/python3/capturing_non_capturing_groups.py | regex/grouping/python3/capturing_non_capturing_groups.py | Regex_Pattern = r'(ok){3,}' # Do not delete 'r'.
| mit | Python | |
f62c0ec8bd12504a0a7b24696a9b68ebe17d8222 | add test 1 for block_PDE | ratnania/pigasus | tests/test_1_blockPDE.py | tests/test_1_blockPDE.py | # -*- coding: UTF-8 -*-
#! /usr/bin/python
from pigasus.utils.manager import context
# ...
try:
from matplotlib import pyplot as plt
PLOT=True
except ImportError:
PLOT=False
# ...
import numpy as np
import sys
import inspect
filename = inspect.getfile(inspect.currentframe()) # script filenam... | mit | Python | |
6dcb46fe6172d8c08d84bc41bcd06d23a8025c4f | Add some scale tests | thatch45/sorbic,s0undt3ch/sorbic | tests/unit/test_scale.py | tests/unit/test_scale.py | # -*- coding: utf-8 -*-
# Import sorbic libs
import sorbic.db
# Import python libs
import os
import unittest
import tempfile
class TestScale(unittest.TestCase):
'''
'''
def test_many_top(self):
w_dir = tempfile.mkdtemp()
root = os.path.join(w_dir, 'db_root')
db = sorbic.db.DB(root... | apache-2.0 | Python | |
bf0928b84d3670e3f3217d4bf6342b420c19de56 | add app.py | XiaoChengOMG/Practice | www/app.py | www/app.py | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
__author__ = ""
'''
'''
| apache-2.0 | Python | |
72eb44bb88f9a80161071218571d28a34b788840 | make i18n module thread safe | siongui/pali,siongui/pali,wisperwinter/pali,siongui/pali,wisperwinter/pali,wisperwinter/pali,siongui/pali | common/gae/libs/i18n.py | common/gae/libs/i18n.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
References:
http://docs.python.org/2/library/gettext.html
http://jinja.pocoo.org/docs/extensions/
http://webpy.org/cookbook/i18n_support_in_template_file
http://webpy.org/cookbook/runtime-language-switch
https://code.google.com/p/webapp-improved/source/browse/webapp2_ex... | #!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
References:
http://docs.python.org/2/library/gettext.html
http://jinja.pocoo.org/docs/extensions/
http://webpy.org/cookbook/i18n_support_in_template_file
http://webpy.org/cookbook/runtime-language-switch
https://code.google.com/p/webapp-improved/source/browse/webapp2_ex... | unlicense | Python |
b1476b5e9eea6fc9b8ccacc838f702020ca2a17e | Fix contexto __del__ and remove unnecessary | ArvinPan/pyzmq,swn1/pyzmq,yyt030/pyzmq,dash-dash/pyzmq,Mustard-Systems-Ltd/pyzmq,dash-dash/pyzmq,ArvinPan/pyzmq,dash-dash/pyzmq,Mustard-Systems-Ltd/pyzmq,caidongyun/pyzmq,Mustard-Systems-Ltd/pyzmq,caidongyun/pyzmq,caidongyun/pyzmq,yyt030/pyzmq,swn1/pyzmq,ArvinPan/pyzmq,swn1/pyzmq,yyt030/pyzmq | zmq/cffi_core/context.py | zmq/cffi_core/context.py | # coding: utf-8
from ._cffi import C, ffi, strerror
from .socket import *
from .constants import *
from zmq.error import ZMQError
_instance = None
class Context(object):
zmq_ctx = None
iothreads = None
_closed = None
n_sockets = None
max_sockets = None
_sockets = None
def __init__(self... | # coding: utf-8
from ._cffi import C, ffi, strerror
from .socket import *
from .constants import *
from zmq.error import ZMQError
_instance = None
class Context(object):
zmq_ctx = None
iothreads = None
_closed = None
n_sockets = None
max_sockets = None
_sockets = None
def __init__(self... | bsd-3-clause | Python |
f27382d63224f55998320e496a82aea32d82319b | Add tests for summing sector ids. | machinelearningdeveloper/aoc_2016 | 04/test_sum_sector_ids.py | 04/test_sum_sector_ids.py | import unittest
from sum_sector_ids import (extract_checksum,
create_checksum,
is_valid_checksum,
extract_sector_id,
sum_sector_ids)
class TestSumSectorIds(unittest.TestCase):
def setUp(self):
s... | mit | Python | |
8776f3e5bd82b704e402b8a52270f56eb11fdb8f | Add tests for redirection after login | comic/comic-django,comic/comic-django,comic/comic-django,comic/comic-django,comic/comic-django | app/tests/profiles_tests/test_views.py | app/tests/profiles_tests/test_views.py | import pytest
from rest_framework import status
from django.conf import settings
from grandchallenge.subdomains.utils import reverse
from tests.factories import UserFactory
@pytest.mark.django_db
class TestLoginRedirect:
def test_default_redirect(self, client):
url = reverse("login_redirect")
re... | apache-2.0 | Python | |
d2f5e6e67bdd6d58c4098591084cef6d58565682 | add solution for 2019 day 8 part 1 | kmcginn/advent-of-code | 2019/day08/space_image.py | 2019/day08/space_image.py | #! python3
"""
from: https://adventofcode.com/2019/day/8
--- Day 8: Space Image Format ---
The Elves' spirits are lifted when they realize you have an opportunity to reboot one of their Mars
rovers, and so they are curious if you would spend a brief sojourn on Mars. You land your ship near
the rover.
When you reach t... | mit | Python | |
7e6ad089c00054f3316227775c20b82c49a56790 | add global notice plugin | GLolol/PyLink | plugins/global.py | plugins/global.py | # global.py: Global Noticing Plugin
__authors__ = [("Ken Spencer", "Iota <ken@electrocode.net>")]
__version__ = "0.0.1"
from pylinkirc import conf, utils, world
from pylinkirc.log import log
from pylinkirc.coremods import permissions
def g(irc, source, args):
"""<message text>
Sends out a Instance-wide ... | mpl-2.0 | Python | |
7c5d09929b4f31321caed4c6393ac4cac3000f8a | Add __init.py | funilrys/A-John-Shots | a-john-shots/__init__.py | a-john-shots/__init__.py | #!/bin/env python
| mit | Python | |
238c550d8131f3b35dae437182c924191ff08b72 | Add tool to find scan roots. | google/perfetto,google/perfetto,google/perfetto,google/perfetto,google/perfetto,google/perfetto,google/perfetto,google/perfetto | tools/find_scan_roots.py | tools/find_scan_roots.py | #!/usr/bin/env python
# Copyright (C) 2018 The Android Open Source Project
#
# 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 requi... | apache-2.0 | Python | |
64b7e4450bba6ac14f02e919235ca218d022efe1 | index tests for bills | mileswwatkins/billy,openstates/billy,openstates/billy,loandy/billy,loandy/billy,sunlightlabs/billy,sunlightlabs/billy,loandy/billy,mileswwatkins/billy,openstates/billy,sunlightlabs/billy,mileswwatkins/billy | billy/tests/importers/test_indexing.py | billy/tests/importers/test_indexing.py | from billy.core import db
from billy.importers.bills import ensure_indexes as bill_indexes
def _assert_index(query, name_piece=None):
cursor = query.explain()['cursor']
if name_piece:
assert name_piece in cursor, ("%s not in cursor %s" % (name_piece,
... | bsd-3-clause | Python | |
7be89de845cd86855e1d0c867fcb3ef51f5030a7 | Create drivers.py | ariegg/webiopi-drivers,ariegg/webiopi-drivers | chips/sensor/honxxxpressure/drivers.py | chips/sensor/honxxxpressure/drivers.py | # This code has to be added to the corresponding __init__.py
DRIVERS["honXXXpressure"] = ["HONXSCPI", "HONXSCPTI", "HONXSCPS", "HONXSCPTS", "HONABPPI", "HONABPPTI", "HONABPPS", "HONABPPTS"]
| apache-2.0 | Python | |
121f0d3d3e792690b31f4a6d858a697129d91c26 | add main | muhasaho/RPi-Motion | main.py | main.py | #Raspberry Pi Motion Example
#Author: Muhammed Saho
import RPi.GPIO as gpio
#setup pin
pin = 7
gpio.setmode(gpio.BCM)
gpio.setup(pin, gpio.IN)
# this function will be called when motion detected
def Motion(pin):
print "Motion Detected !!"
# watch for motion
gpio.add_event_detect(pin,gpio.RISING,callback=Moti... | mit | Python | |
c758126255bb01a0b27e8b49607ae8fc4fa23989 | Create main.py | chulderman/stellar-avarice | main.py | main.py | import os, sys
import urllib2
manifest_location = "http://1.webseed.robertsspaceindustries.com/FileIndex/sc-alpha-2.0.0/"
dir_contents = [f for f in os.listdir('.') if os.path.isfile(f)]
for item in dir_contents:
last_num = 0
if item.split('.')[-1] == 'json':
item_num = item.split('.')[0]
if last_num < item_num... | mit | Python | |
58335968be08a809913476bab73bc903b542c4a3 | add image converter | ysasaki6023/NeuralNetworkStudy | data_cifar10/convert_to_jpg.py | data_cifar10/convert_to_jpg.py | import numpy as np
import cPickle as pickle
import matplotlib.pyplot as plt
from PIL import Image
fName = "test.pickle"
with open(fName,"rb") as f:
d = pickle.load(f)
imgList = d["data"]
imgList = imgList.reshape((10000,3,32,32)).transpose(0,2,3,1)
for i in range(len(imgList)):
if i%100==0: print i
pImg... | mit | Python | |
7eac12bb8fe31b397c8598af14973f2337ca8c53 | Add python test for notes length validation | ministryofjustice/cla_public,ministryofjustice/cla_public,ministryofjustice/cla_public,ministryofjustice/cla_public | cla_public/apps/contact/tests/test_notes.py | cla_public/apps/contact/tests/test_notes.py | import unittest
from werkzeug.datastructures import MultiDict
from cla_public.app import create_app
from cla_public.apps.contact.forms import ContactForm
def submit(**kwargs):
return ContactForm(MultiDict(kwargs), csrf_enabled=False)
class NotesTest(unittest.TestCase):
def setUp(self):
app = crea... | mit | Python | |
27928e7eaac52e2803cbc6e054f84f4ddd95fe8b | Create __init__.py | googleinterns/smart-content-summary,googleinterns/smart-content-summary,googleinterns/smart-content-summary | classifier/official_transformer/__init__.py | classifier/official_transformer/__init__.py | apache-2.0 | Python | ||
ce9ed9b965960d0e12dee584c8d07bcd164a4fe0 | Add tests.py for unit tests. | djkartsa/django-add-another,djkartsa/django-add-another,djkartsa/django-add-another | add_another/tests.py | add_another/tests.py | from django.test import TestCase
# Create your tests here.
| mit | Python | |
d07468a28df7100251332865332f2412eafe6f31 | Add mode tf2mlir that exports MLIR (#1006) | google/automl,google/automl | efficientnetv2/mlir.py | efficientnetv2/mlir.py | # Copyright 2021 Google Research. 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 applicable law... | apache-2.0 | Python | |
e794a886ef503df088f4489ab22b7955efb6b940 | Add __main__.py to allow running `python -m youtube_dl_server` | jaimeMF/youtube-dl-api-server,apllicationCOM/youtube-dl-api-server,jaimeMF/youtube-dl-api-server,apllicationCOM/youtube-dl-api-server,apllicationCOM/youtube-dl-api-server,jaimeMF/youtube-dl-api-server | youtube_dl_server/__main__.py | youtube_dl_server/__main__.py | import sys
from .server import main
if __name__ == '__main__':
sys.exit(main())
| unlicense | Python | |
cf71bc66051b9e46b927989b92dc4cec4b1dbb9e | Add parallel module with alternative implementations using dask. | danielballan/photomosaic | photomosaic/parallel.py | photomosaic/parallel.py | import warnings
import glob
from skimage.io import imread
import colorspacious
import dask.bag
from dask.diagnostics import ProgressBar
from .photomosaic import (options, standardize_image, sample_pixels,
dominant_color)
def make_pool(glob_string, *, pool=None, skip_read_failures=True,
... | bsd-3-clause | Python | |
8b7a0a5801057020d14f6f38ef9a5ee5fd4f28de | Add an async_intro module with the basic intro async example. | Workiva/furious,andreleblanc-wf/furious,beaulyddon-wf/furious,rosshendrickson-wf/furious,beaulyddon-wf/furious,andreleblanc-wf/furious,Workiva/furious,mattsanders-wf/furious,mattsanders-wf/furious,rosshendrickson-wf/furious | example/async_intro.py | example/async_intro.py | #
# Copyright 2012 WebFilings, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing... | apache-2.0 | Python | |
7a28362ee15a11c001631eb0f649f6aa1c706fff | Add packet dump example. | ainoniwa/pppcap | example/recv_sample.py | example/recv_sample.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from ctypes import *
from optparse import OptionParser
from pppcap.pppcap import *
version = u'%prog 1.1'
def dev_discovery():
alldevs = POINTER(pcap_if_t)()
errbuf = create_string_buffer(PCAP_ERRBUF_SIZE)
pcap_findalldevs(byref(alldevs), errbuf)
dev_cou... | mit | Python | |
f7771a86dc5edd1119ff4e720c6493477f9b6eec | Create secant.py | ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovski/al-go-rithms,ZoranPandovs... | root_finding_technique/secant.py | root_finding_technique/secant.py | #python3
#program to calculate roots of a polynomial with error of .0001
def f(x):
return x*x - x - 1
print("Enter values of a and b on separate line ")
a = float(input())
b = float(input())
e = .0001
m = (a*f(b)-b*f(a))/(f(b)-f(a))
i=1
print (a,b,m,f(m),i)
while abs(f(m))>e :
m = (b*f(m)-m*f(b))/... | cc0-1.0 | Python | |
36dd9c8b7ebaf386348c9b684e589982484c4141 | Add iter_chains(n) to new file matrices2.py. | jfine2358/py-linhomy | py/linhomy/matrices2.py | py/linhomy/matrices2.py | '''New approach based on rank and {i}
Arises from
C^r{CD_1 ... } + {C^rD_1C ...} = {C^rCD_1 ...}
>>> for chain in iter_chains(6):
... str(' ').join(map(CD_from_word, chain))
'CDCCC CCDCC CCCDC'
>>> for chain in iter_chains(8):
... str(' ').join(map(CD_from_word, chain))
'CDCCCCC CCDCCCC CCCDCCC CCCCDCC CCC... | mit | Python | |
8f24dafd4e674e20bebff951ddb411639290914d | Create protect-templates-in-mediawiki-ns | Xi-Plus/Xiplus-Wikipedia-Bot,Xi-Plus/Xiplus-Wikipedia-Bot | protect-templates-in-mediawiki-ns/protect.py | protect-templates-in-mediawiki-ns/protect.py | #!/usr/bin/env python
# coding: utf-8
import json
import os
import re
import pymysql
os.environ['PYWIKIBOT_DIR'] = os.path.dirname(os.path.realpath(__file__))
import pywikibot
from config import config_page_name, host, password, user # pylint: disable=E0611,W0614
site = pywikibot.Site('zh', 'wikipedia')
site.logi... | mit | Python | |
75e1ad179cdfd320ea1b6ceb7e5b0bbe0ecded72 | implement cmd script for plotting single trip | e-mission/e-mission-server,joshzarrabi/e-mission-server,yw374cornell/e-mission-server,shankari/e-mission-server,sdsingh/e-mission-server,e-mission/e-mission-server,joshzarrabi/e-mission-server,shankari/e-mission-server,yw374cornell/e-mission-server,shankari/e-mission-server,shankari/e-mission-server,sunil07t/e-mission-... | CFC_WebApp/utils/plot_trip.py | CFC_WebApp/utils/plot_trip.py | from main import gmap_display
from pymongo import MongoClient
import pygmaps
import webbrowser
import sys
import os
db = MongoClient().Stage_database
if __name__ == '__main__':
if len(sys.argv) != 2:
print "USAGE: %s trip_id\n" % sys.argv[0]
print "COLOR SCHEME FOR THE PLOT:\n"
print "wal... | bsd-3-clause | Python | |
b82d5a61223f19c09d1c570f3c12868dde72e25e | add package | phanib4u/streamparse,crohling/streamparse,msmakhlouf/streamparse,phanib4u/streamparse,Parsely/streamparse,msmakhlouf/streamparse,scrapinghub/streamparse,hodgesds/streamparse,scrapinghub/streamparse,msmakhlouf/streamparse,petchat/streamparse,scrapinghub/streamparse,scrapinghub/streamparse,crohling/streamparse,petchat/st... | pystorm/ext/__init__.py | pystorm/ext/__init__.py | """pystorm.ext package"""
| apache-2.0 | Python | |
64eac24e4a3afa4edcc8db2234944b155fc1a78e | Create __init__.py | Fillll/reddit2telegram,Fillll/reddit2telegram | reddit2telegram/channels/engrish/__init__.py | reddit2telegram/channels/engrish/__init__.py | # hehe
| mit | Python | |
1a49365b3751669c6dfc691a6c654628f283715c | Create problem9.py | CptDemocracy/Python | Project-Euler/Problem9/problem9.py | Project-Euler/Problem9/problem9.py | """
[ref.href] https://projecteuler.net/problem=9
A Pythagorean triplet.
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which:
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""... | mit | Python | |
a73e043c6501b54400b41b3c521dc6968f90d7d1 | Create oo_run_singles_convolution.py | rupertsmall/machine-learning,rupertsmall/machine-learning | Convolution_Neural_Networks/oo_run_singles_convolution.py | Convolution_Neural_Networks/oo_run_singles_convolution.py | #
# optimise a neural network for image recognition
# rupert small, august 2015
#
from numpy import genfromtxt
from oo_dr_singles_convolution import *
from get_overlaps import *
import threading
# initiate data
data = genfromtxt('train2.csv', delimiter=',')
num_cpus = 30 # multi-threading
y_vals = data[:,0] # output... | mit | Python | |
da069ec69ff35d37413dd7b4ae361fba40911e19 | Add argument type examples | winkidney/cmdtree,winkidney/cmdtree | src/examples/arg_types.py | src/examples/arg_types.py | from cmdtree import command, argument, INT, entry, Choices
@command("run")
@argument("host", type=Choices(("host1", "host2", "host3")))
@argument("port", type=INT)
def run_docker(host, port):
print(
"docker daemon api runs on {ip}:{port}".format(
ip=host,
port=port,
)
)... | mit | Python | |
2924496de7f17ea630a507c51fd17665759a8135 | Create TestBattleground.py | Gabriel-Araujo/Arena-RPG | src/TestBattleground.py | src/TestBattleground.py | #!/usr/bin/python
from Battleground import Battleground
import unittest
class TestBattleground(unittest.TestCase):
def setUp(self):
self.arena = Battleground('Thunderdome', 20, 20)
def test_arena(self):
self.assertEqual(self.arena.name, 'Thunderdome')
self.assertEqual(self.ar... | mit | Python | |
d15fbfe41f74525567633489bbbc78a5654184cb | Add script to validate mvn repositories | baishuo/elasticsearch_v2.1.0-baishuo,baishuo/elasticsearch_v2.1.0-baishuo,baishuo/elasticsearch_v2.1.0-baishuo,strapdata/elassandra-test,strapdata/elassandra-test,baishuo/elasticsearch_v2.1.0-baishuo,baishuo/elasticsearch_v2.1.0-baishuo,strapdata/elassandra-test,strapdata/elassandra-test,strapdata/elassandra-test,baish... | dev-tools/validate-maven-repository.py | dev-tools/validate-maven-repository.py | # Licensed to Elasticsearch under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except... | apache-2.0 | Python | |
1c779d97ed1db766a0bed41ac6beef75ebb4f5db | Test on initial migration with sqlite3 #2 | ahitrin/SiebenApp | siebenapp/tests/test_database.py | siebenapp/tests/test_database.py | # coding: utf-8
import sqlite3
def test_initial_migration():
conn = sqlite3.connect(':memory:')
cur = conn.cursor()
cur.execute('create table migrations (version integer)')
cur.execute('insert into migrations values (0)')
conn.commit()
cur.execute('select version from migrations')
version ... | mit | Python | |
47f0372ff1568e65cc7742229aa5bf0ed599d25f | Add directory for tests | PatrikValkovic/grammpy | tests/__init__.py | tests/__init__.py | #!/usr/bin/env python
"""
:Author Patrik Valkovic
:Created 23.06.2017 16:39
:Licence GNUv3
Part of grammpy-transforms
""" | mit | Python | |
e980ddba4a02abbf2a0a46a95fffb6b5ea3b6aea | Deal with IOB tagging. | YigengZhang/DL4SRL | Preprocess/IOB_extract.py | Preprocess/IOB_extract.py | # -*- coding: utf-8 -*-
import numpy as np
import string
redundancy = 2
with open('/home/yigengzhang/workspace/PreProcess/ALLinOne2.txt', 'w') as finaltxt:
for doc in range(1,22278):
# print doc
sentence = np.loadtxt('/home/yigengzhang/workspace/PreProcess/SplitedData/train-' + str(doc) + '.txt', delimiter=' ... | apache-2.0 | Python | |
7f0dae30d7d554bf096419096f9542bfea4aa64d | add B, F, C Combinator test | esehara/skiski | tests/bfc_test.py | tests/bfc_test.py | import pytest
from skiski.bfc import B
def test_composite_function():
a = lambda x: x * 5
b = lambda x: x - 3
assert B(a).dot(b).dot(5).w() == 10
def test_sksk_is_b():
a = lambda x: x * 5
b = lambda x: x - 3
b_comb = B(a).dot(b).dot(5).w()
sksk = B.to_ski().dot(a).w().dot(b).dot(5).w()
... | mit | Python | |
82c21bbab01b3ce330e51873c898ef7f15749de7 | Test for module object constructing. | pfalcon/micropython,pfalcon/micropython,pfalcon/micropython,pfalcon/micropython,pfalcon/micropython | tests/import/module_constructor.py | tests/import/module_constructor.py | import sys
mod_type = type(sys)
try:
mod1 = mod_type("sys")
except TypeError:
print("SKIP")
raise SystemExit
print(mod1)
# Should be a new module, not existing sys or something
print(len(dir(mod1)) < 6)
mod1.var = 123
print(mod1.var)
# Should be a new module again
mod2 = mod_type("sys")
print(mod1 is... | mit | Python | |
7f4de89928de1580dceedff3c1a581660e70f954 | Add test exhibiting cursor failure | BayanGroup/sentry,kevinlondon/sentry,imankulov/sentry,fotinakis/sentry,BuildingLink/sentry,BuildingLink/sentry,mvaled/sentry,fuziontech/sentry,nicholasserra/sentry,fotinakis/sentry,jean/sentry,kevinlondon/sentry,ngonzalvez/sentry,mitsuhiko/sentry,ifduyue/sentry,fotinakis/sentry,alexm92/sentry,zenefits/sentry,alexm92/se... | tests/sentry/utils/test_cursors.py | tests/sentry/utils/test_cursors.py | from __future__ import absolute_import
from mock import Mock
from sentry.utils.cursors import build_cursor, Cursor
def build_mock(**attrs):
obj = Mock()
for key, value in attrs.items():
setattr(obj, key, value)
obj.__repr__ = lambda x: repr(attrs)
return obj
def test_build_cursor():
ev... | bsd-3-clause | Python | |
c6d0156499b10ab69f3eb7fcefc59af24983ac43 | Test valid_repository | hackebrot/cookiecutter,terryjbates/cookiecutter,audreyr/cookiecutter,terryjbates/cookiecutter,pjbull/cookiecutter,michaeljoseph/cookiecutter,luzfcb/cookiecutter,hackebrot/cookiecutter,luzfcb/cookiecutter,stevepiercy/cookiecutter,audreyr/cookiecutter,dajose/cookiecutter,stevepiercy/cookiecutter,michaeljoseph/cookiecutte... | tests/vcs/test_valid_repository.py | tests/vcs/test_valid_repository.py | # -*- coding: utf-8 -*-
from cookiecutter.repository import valid_repository
import pytest
def test_valid_repository():
assert valid_repository('tests/fake-repo')
@pytest.fixture(params=[
'tests/fake-repo-bad',
'tests/unknown-repo',
])
def invalid_repository(request):
return request.param
def tes... | bsd-3-clause | Python | |
30b98f8814184e1e5ca3659861671ff3b094a5be | Add files via upload | pnisarg/ABSA,pnisarg/ABSA | eval_aspect_term_extraction.py | eval_aspect_term_extraction.py | # -*- coding: utf-8 -*-
'''
Run a task from the terminal::
>>> python eval_aspect_term_extraction.py predicted_aspect_terms_input_filename correct_aspect_terms_csv_filename
'''
import csv
import io
import json
import ast
import sys
import argparse
def aspect_extraction():
b=1
count = 0
... | mit | Python | |
90f9bde41b6e1247722df7eb76d4f6c0cc4a2e2d | add decoder for pcap data | bucko909/powerpod,bucko909/powerpod | wireshark-reader.py | wireshark-reader.py | # pcap the USB, and filter it to just your device.
# Now do <pcapfile tshark --disable-protocol ppp --disable-protocol prp -Y 'usb.data_flag == "present (0)" && usb.transfer_type == 0x03' -e frame.time_epoch -e usb.endpoint_number.direction -e usb.capdata -Tfields -r - | python -u wireshark-reader.py 2>&1 | less
# Now ... | bsd-2-clause | Python | |
dd287c4edfb29e848eaaba93c769ebfaab0db58c | Add test for communicating with the interoperability server. This will allow us to verify we can make connection with the judges' server at competition | FlintHill/SUAS-Competition,FlintHill/SUAS-Competition,FlintHill/SUAS-Competition,FlintHill/SUAS-Competition,FlintHill/SUAS-Competition | tests/non_nose_tests/test_interop_client.py | tests/non_nose_tests/test_interop_client.py | from time import sleep
from SUASSystem import InteropClientConverter
if __name__ == '__main__':
interop_client = InteropClientConverter()
while True:
print(interop_client.get_obstacles())
sleep(1)
| mit | Python | |
fbd5cfc3aae0aa3d73e75c01a802d2ef26017630 | define the function to return habitat quality based on years since last fire | yasserglez/pymdptoolbox,sawcordwell/pymdptoolbox,silgon/pymdptoolbox,McCabeJM/pymdptoolbox,silgon/pymdptoolbox,yasserglez/pymdptoolbox,sawcordwell/pymdptoolbox,McCabeJM/pymdptoolbox | src/examples/firemdp.py | src/examples/firemdp.py | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 9 17:20:30 2014
@author: Steven A W Cordwell
"""
import mdptoolbox as mdp
def getHabitatQuality(time):
"""The habitat quality of a patch according to the time since last fire.
The habitat quality is low immediately after a fire, rises rapidly until
fiv... | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 9 17:20:30 2014
@author: steve
"""
| bsd-3-clause | Python |
3ef101dc8f20bd6c01c38db8c2574884d2017d4f | Add pos tag and noun phrase features | Rostlab/nalaf | nala/features/parsing.py | nala/features/parsing.py | from textblob import TextBlob
from textblob.en.np_extractors import FastNPExtractor
from nala.features import FeatureGenerator
class PosTagFeatureGenerator(FeatureGenerator):
"""
"""
def __init__(self):
self.punctuation = ['.', ',', ':', ';', '[', ']', '(', ')', '{', '}', '”', '“', '–', '"', '#'... | apache-2.0 | Python | |
75f51971409b7c920e66e075adffbda1317bdaf0 | test the app. | douban/brownant | tests/test_app.py | tests/test_app.py | from __future__ import absolute_import, unicode_literals
from pytest import fixture, raises
from mock import Mock
from brownant.app import BrownAnt
from brownant.exceptions import NotSupported
class StubEndpoint(object):
name = __name__ + ".StubEndpoint"
def __init__(self, request, id_):
self.requ... | bsd-3-clause | Python | |
9db20f7b7aa90ddabe5ccb1fb913c25d612dfe0f | Add basic localization support. | zesik/zkb | zkb/localization.py | zkb/localization.py | # -*- coding: utf-8 -*-
"""
zkb.localization
~~~~~~~~~~~~~~~~
Localization information for ZKB.
:Copyright: Copyright 2014 Yang LIU <zesikliu@gmail.com>
:License: BSD, see LICENSE for details.
"""
import yaml
import pkg_resources
_CACHE = {}
class LocalizationData(object):
@classmethod
def from_locale(cl... | bsd-3-clause | Python | |
93a71eee693c61c5e1000d6943fdfa07d6272443 | Add tests for SecurityGroupEgress | 7digital/troposphere,ikben/troposphere,johnctitus/troposphere,ikben/troposphere,7digital/troposphere,horacio3/troposphere,pas256/troposphere,cloudtools/troposphere,cloudtools/troposphere,horacio3/troposphere,johnctitus/troposphere,pas256/troposphere | tests/test_ec2.py | tests/test_ec2.py | import unittest
import troposphere.ec2 as ec2
class TestEC2(unittest.TestCase):
def test_securitygroupegress(self):
egress = ec2.SecurityGroupEgress(
'egress',
ToPort='80',
FromPort='80',
IpProtocol="tcp",
GroupId="id",
CidrIp="0.0.0... | bsd-2-clause | Python | |
4702bf5edabcbd07cf824a940794e4a5c1dd009c | read in a .pyc file and disassemble the code objects | sk-/python2.7-type-annotator,sk-/python2.7-type-annotator,sk-/python2.7-type-annotator | Tools/compiler/dumppyc.py | Tools/compiler/dumppyc.py | #! /usr/bin/env python
import marshal
import dis
import types
def dump(obj):
print obj
for attr in dir(obj):
print "\t", attr, repr(getattr(obj, attr))
def loadCode(path):
f = open(path)
f.read(8)
co = marshal.load(f)
f.close()
return co
def walk(co, match=None):
if match is ... | mit | Python | |
e56c1f27390470ddee3b669dc49dfe78738b76f0 | Create lc972.py | FiveEye/ProblemSet,FiveEye/ProblemSet | LeetCode/lc972.py | LeetCode/lc972.py | def f(si, sn, sr):
i = int(si)
if len(sn) > 0:
n = int(sn)
else:
n = 0
if len(sr) > 0:
r = int(sr)
lr = len(sr)
else:
r = 0
lr = 1
a = (10 ** len(sn))
b = (10 ** lr)
c = a * b
x = (i * c + n * b + r) - (i * a + n)
y = (c - a)
z ... | mit | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.