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 |
|---|---|---|---|---|---|---|---|---|
1c6ea402b918ee23c13fc6dc5bef80b97f6f9d67 | Add check_tar script. | mjs/juju,mjs/juju,mjs/juju,mjs/juju,mjs/juju,mjs/juju,mjs/juju | check_tar.py | check_tar.py | #!/usr/bin/env python3
from argparse import ArgumentParser
import logging
import os
import tarfile
import sys
class TarfileNotFound(Exception):
"""Raised when specified tarfile cannot be found."""
class TestedDirNotFound(Exception):
"""Raised when specified tested text dir cannot be found."""
def get_fpc_... | agpl-3.0 | Python | |
bd1ad829908f0f0a029e4e00bdd2f12512fff297 | add formaction class | RasaHQ/rasa_core,RasaHQ/rasa_nlu,RasaHQ/rasa_core,RasaHQ/rasa_nlu,RasaHQ/rasa_core,RasaHQ/rasa_nlu | rasa_core/actions/forms.py | rasa_core/actions/forms.py | # -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from rasa_core.actions.action import Action
from rasa_core.dispatcher import Button
from rasa_core.events import ConversationPaused, SlotSet
impo... | apache-2.0 | Python | |
4836db9ba6686557ed005b8518098b9dd1a302e1 | Add drown* to offensive regex | hugovk/CyberPrefixer,molly/CyberPrefixer | offensive.py | offensive.py | import re
offensive = re.compile(
r"\b(deaths?|dead(ly)?|die(s|d)?|hurts?|(sex|child)[ -]?(abuse|trafficking)|injur(e|i?es|ed|y)|"
r"kill(ing|ed|er|s)?s?|wound(ing|ed|s)?|fatal(ly|ity)?|shoo?t(s|ing|er)?s?|crash(es|ed|ing)?|"
r"attack(s|ers?|ing|ed)?|murder(s|er|ed|ing)?s?|hostages?|rap(e|es|ed|ing)|assaul... | import re
offensive = re.compile(
r"\b(deaths?|dead(ly)?|die(s|d)?|hurts?|(sex|child)[ -]?(abuse|trafficking)|injur(e|i?es|ed|y)|"
r"kill(ing|ed|er|s)?s?|wound(ing|ed|s)?|fatal(ly|ity)?|shoo?t(s|ing|er)?s?|crash(es|ed|ing)?|"
r"attack(s|ers?|ing|ed)?|murder(s|er|ed|ing)?s?|hostages?|rap(e|es|ed|ing)|assaul... | mit | Python |
fdc31769208dc3a6fc81758083de1d98a968262b | Add new py-asserts package (#14038) | LLNL/spack,iulian787/spack,LLNL/spack,iulian787/spack,LLNL/spack,iulian787/spack,LLNL/spack,LLNL/spack,iulian787/spack,iulian787/spack | var/spack/repos/builtin/packages/py-asserts/package.py | var/spack/repos/builtin/packages/py-asserts/package.py | # Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class PyAsserts(PythonPackage):
"""Stand-alone Assertions."""
homepage = "https://github.co... | lgpl-2.1 | Python | |
e101665e5e206c66198a9f30fcdf2a2ff53a128b | Update version to 1.5 (#5524) | skosukhin/spack,matthiasdiener/spack,krafczyk/spack,tmerrick1/spack,skosukhin/spack,tmerrick1/spack,matthiasdiener/spack,lgarren/spack,mfherbst/spack,mfherbst/spack,tmerrick1/spack,lgarren/spack,skosukhin/spack,iulian787/spack,EmreAtes/spack,mfherbst/spack,tmerrick1/spack,LLNL/spack,skosukhin/spack,lgarren/spack,krafcz... | var/spack/repos/builtin/packages/r-jsonlite/package.py | var/spack/repos/builtin/packages/r-jsonlite/package.py | ##############################################################################
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-64... | ##############################################################################
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-64... | lgpl-2.1 | Python |
85a8741564266fae7f7e4b1ccd518324277ad58a | Create diss.py | Sitryk/Sitryk-Cogs | diss/diss.py | diss/diss.py | from __main__ import send_cmd_help
from discord.ext import commands
from random import choice
import discord
class Diss:
"""Example cog for dissing or respecting a user"""
def __init__(self, bot):
self.bot = bot
self.users = { 'name1' : ['disses', 'disses2'], 'name2' : ['more disses', 'another... | mit | Python | |
a244ffe1814e8ad7966f90b212faebfaf35424be | Initialize P01_tablePrinter | JoseALermaIII/python-tutorials,JoseALermaIII/python-tutorials | books/AutomateTheBoringStuffWithPython/Chapter06/PracticeProjects/P01_tablePrinter.py | books/AutomateTheBoringStuffWithPython/Chapter06/PracticeProjects/P01_tablePrinter.py | # This program displays a list of strings in a table
#
# Write a function named printTable() that takes a list of lists of strings and
# displays it in a well-organized table with each column right-justified. Assume
# that all the inner lists will contain the same number of strings.
#
# For example, the value could loo... | mit | Python | |
feae414803ba3a6458660314f212e5e20820d979 | add core codes for distances | tech-teach/microservice-topology,tech-teach/microservice-topology,tech-teach/microservice-topology,tech-teach/microservice-topology | core/core.py | core/core.py | # internal libraries
import multiprocessing
from time import time
import csv
import sys
# external libraries
from sklearn.metrics import pairwise, accuracy_score
import numpy as np
NOT_BOOL_METRICS = [
'euclidean',
'l2',
'l1',
'manhattan',
'minkowski',
'canberra',
'cosine',
'cityblock'... | mit | Python | |
7c750650961a6aac4e189b46e1353a3ec003dd56 | add test-send-file-ipv6.py but disabled for now because of Python bug | freedesktop-unofficial-mirror/telepathy__telepathy-salut,freedesktop-unofficial-mirror/telepathy__telepathy-salut,freedesktop-unofficial-mirror/telepathy__telepathy-salut,freedesktop-unofficial-mirror/telepathy__telepathy-salut | tests/twisted/avahi/test-send-file-ipv6.py | tests/twisted/avahi/test-send-file-ipv6.py | import avahi
from saluttest import exec_test
from avahitest import AvahiAnnouncer, get_host_name
from xmppstream import setup_stream_listener6
from file_transfer_helper import SendFileTest, CHANNEL_TYPE_FILE_TRANSFER, FT_STATE_PENDING, \
FT_STATE_CHANGE_REASON_NONE, FT_STATE_OPEN
print "FIXME: This is disabled bec... | lgpl-2.1 | Python | |
bec2f43e9e6a6f858c97ae19c07eb35cd912457c | Create 3_flickrlikes_assembledata_directory.py | sharathchandra92/flickrapi_downloadfavorites,sharathchandra92/flickrapi_downloadfavorites | 3_flickrlikes_assembledata_directory.py | 3_flickrlikes_assembledata_directory.py | #!/usr/bin/env python
"""
This will create train and test txt files and a directory named images in flickr_likes parent directory,
where all the folders exist. Then, run following commands to copy all files into the images directory
# find ./ -name '*.jpg' -exec cp '{}' ./ \; To copy all images in subdirectories into ... | mit | Python | |
bb7abbcd87bdce4709b37d83742289fbf9a155a3 | Add student dilemma pb | eliemichel/IRL | student.py | student.py | """
This module implements the "student dilemma" as briefly presented in RL lecture
as a gym module.
"""
# code structure is from https://github.com/openai/gym/blob/master/gym/envs/classic_control/cartpole.py
import sys
import gym
from gym import spaces
from gym.utils import seeding
import numpy as np
class StudentD... | mit | Python | |
9acd61f160035c240d6db3fca97821f08d397a02 | Add this one more train/validation data generator | kranthikumar/exercises-in-programming-style,crista/exercises-in-programming-style,crista/exercises-in-programming-style,crista/exercises-in-programming-style,kranthikumar/exercises-in-programming-style,kranthikumar/exercises-in-programming-style,kranthikumar/exercises-in-programming-style,crista/exercises-in-programmin... | 36-dnn/generate_c2w_data.py | 36-dnn/generate_c2w_data.py | import os, sys
import collections
import numpy as np
import re, string
MAX_LINE_SIZE = 80
MAX_WORDS_IN_LINE = 20
all_chars = ""
with open('pride-and-prejudice.txt') as f:
all_chars = f.read().replace('\n', ' ')
all_words = re.findall('[a-z]{2,}', all_chars.lower())
words = list(set(all_words))
def generate_pair(... | mit | Python | |
68942512cd5bb9ea1c15a3dc663b8ea1a08df8f4 | Update the deprecation message of PageSet. | axinging/chromium-crosswalk,Pluto-tv/chromium-crosswalk,chuan9/chromium-crosswalk,Just-D/chromium-1,TheTypoMaster/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,hgl888/chromium-crosswalk,hgl888/chromium-crosswalk,axinging/chromium-crosswalk,Chilledheart/chromium,Chilledheart/chromium,Chilledheart/chromium,axinging... | tools/telemetry/telemetry/page/page_set.py | tools/telemetry/telemetry/page/page_set.py | # Copyright 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.
import os
from telemetry.page import page as page_module
from telemetry import decorators
from telemetry import story
PUBLIC_BUCKET = story.PUBLIC_BUCKET
P... | # Copyright 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.
import os
from telemetry.page import page as page_module
from telemetry import decorators
from telemetry import story
PUBLIC_BUCKET = story.PUBLIC_BUCKET
P... | bsd-3-clause | Python |
e8c8464d36e91c9a8d61db0531a2e73dcdee88b7 | Add a test for check_inputs. | jason-neal/companion_simulations,jason-neal/companion_simulations | utilities/tests/test_simulation_utils.py | utilities/tests/test_simulation_utils.py | from utilities.simulation_utilities import check_inputs
import pytest
import numpy as np
@pytest.mark.parametrize("input,expected", [
(None, np.ndarray([0])),
([0], np.array([0])),
(1, np.array([1])),
(range(5), np.array([0,1,2,3,4]))
])
def test_check_inputs(input, expected):
assert np.allclose(... | mit | Python | |
0c5cbacab1c2925ed0a00d3af0415b76f50c1eec | Create wikipedia.py | fnielsen/dasem,fnielsen/dasem | dasem/wikipedia.py | dasem/wikipedia.py | """Wikipedia interface."""
| apache-2.0 | Python | |
ecef0ea7743f25326183d09622949682ce6feb3c | Test traverses a TS file quickly | johnoneil/arib,johnoneil/arib | test/ts.py | test/ts.py | #!/usr/bin/env python
'''
Module: test
Desc: Test to see how quickly I can parse TS es packets
Author: John O'Neil
Email: oneil.john@gmail.com
DATE: Thursday, October 20th 2016
'''
import os
import sys
import argparse
PACKET_SIZE = 188
SYNC_BYTE = 'G'
#generator
def next_packet(filename):
with open(filename, 'rb')... | apache-2.0 | Python | |
2bbd2ac9b4620f33189fa202ee17dee7f7481330 | Create start.py | googleinterns/automated-windows-vms,googleinterns/automated-windows-vms | master_server/start.py | master_server/start.py | import os
import threading
import sys
port=5000
def new_serve():
global port
port=port + 1
os.system('python dummy_vm_server.py '+str(port))
def master_server():
os.system('python master_server.py')
if __name__ == '__main__':
t=threading.Thread(target=master_server)
t.start()
z=int(sys.argv[1])
for i i... | apache-2.0 | Python | |
b5c6e37bdcb88545d187ad1e3adbbbe1d466f874 | Add py solution for 688. Knight Probability in Chessboard | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | py/knight-probability-in-chessboard.py | py/knight-probability-in-chessboard.py | from collections import Counter
from math import log, exp
class Solution(object):
def knightProbability(self, N, K, r, c):
"""
:type N: int
:type K: int
:type r: int
:type c: int
:rtype: float
"""
p = Counter()
p[r, c] += 1
ds = [(-1, -... | apache-2.0 | Python | |
b6ec697d0dd8baa8866fb6619275d556e8b0165a | Add clear_cache command to clear cache | scdoshi/djutils | djutils/management/commands/clear_cache.py | djutils/management/commands/clear_cache.py | ###############################################################################
## Imports
###############################################################################
# Django
from django.core.management.base import BaseCommand
from django.core.cache import cache
##################################################... | bsd-3-clause | Python | |
2d663cf136b3bb2954ea1a53b17d70a28bfbd62f | add kattis/addingwords | mjenrungrot/competitive_programming,mjenrungrot/algorithm,mjenrungrot/competitive_programming,mjenrungrot/competitive_programming,mjenrungrot/competitive_programming | Kattis/addingwords.py | Kattis/addingwords.py | """
Problem: addingwords
Link: https://open.kattis.com/problems/addingwords
Source: Kattis
"""
import sys
lines = sys.stdin
memory = dict()
def define(variable, value):
memory[variable] = value
def calc(args):
for i in range(0, len(args), 2):
if args[i] not in memory:
re... | mit | Python | |
f80acf05f7d492f3716be961b88c4e82d332500c | Create class to update instances with offering | globocom/database-as-a-service,globocom/database-as-a-service,globocom/database-as-a-service,globocom/database-as-a-service | dbaas/util/update_instances_with_offering.py | dbaas/util/update_instances_with_offering.py | # coding: utf-8
class UpdateInstances(object):
@staticmethod
def do():
from dbaas_cloudstack.models import DatabaseInfraOffering
from dbaas_cloudstack.models import PlanAttr
from physical.models import Instance
infra_offerings = DatabaseInfraOffering.objects.all()
fo... | bsd-3-clause | Python | |
e6afab39aaf263525c5abf67d46a85ff13418340 | Add default_settings.py | pakal/django-compat-patcher,pakal/django-compat-patcher | django_compat_patcher/default_settings.py | django_compat_patcher/default_settings.py |
DCP_INCLUDE_FIXER_IDS = None
DCP_INCLUDE_FIXER_FAMILIES = None
DCP_EXCLUDE_FIXER_IDS = None
DCP_EXCLUDE_FIXER_FAMILIES = None | mit | Python | |
445b6f254ed1fa6193b1c29a9012fe38d9bc768f | Create ClassStaticRegularMethods.py | madhurilalitha/Python-Projects | EmployeeManagementSystem/Findings/ClassStaticRegularMethods.py | EmployeeManagementSystem/Findings/ClassStaticRegularMethods.py | #class methods vs regular methods vs static methods
#regular methods -automatically take the instance as the first argument ("self" by convention)
#class methods - takes "cls" as the first argument ("a decorator class-method should be used)
#static methods - dont pass anything automatically - behave just like regular f... | mit | Python | |
febc64250995cc3e110b553697f615213c1c4d1f | implement RGBAColor | missionpinball/mpf,missionpinball/mpf | mpf/core/rgba_color.py | mpf/core/rgba_color.py | """RGBA Color."""
from typing import Tuple, Union
from mpf.core.rgb_color import RGBColor
class RGBAColor(RGBColor):
"""RGB Color with alpha channel."""
def __init__(self, color: Union[RGBColor, Tuple[int, int, int, int]]):
"""Initialise RGBA color."""
if isinstance(color, RGBColor):
... | mit | Python | |
fa244afcbd9d7f76f473c5deac8f1852cb04eda9 | add ODEProblem class and parser | theosysbio/means,lukauskas/means | MEA_package/ProgramFiles/ode_problem.py | MEA_package/ProgramFiles/ode_problem.py |
import sympy
class ODEProblem(object):
"""
Stores the left and right hand side equations to be simulated
"""
# These are private (as indicated by __, the code is a bit messier, but we can ensure immutability this way)
__right_hand_side = None
__left_hand_side = None
__moment_dic = None
... | mit | Python | |
c0137e888f3ea073fcca7b4abe05e8a52357b75d | Add base.py | lltk/Koko,lltk/Koko | Koko/base.py | Koko/base.py | #!/usr/bin/python
# -*- coding: UTF-8 -*-
__author__ = 'Markus Beuckelmann'
__author_email__ = 'email@markus-beuckelmann.de'
__version__ = '0.0.1'
DEBUG = True
HOST = '127.0.0.1'
PORT = 5002
NAME = 'Koko'
from flask import Flask
app = Flask(NAME)
if __name__ == '__main__':
if DEBUG:
# Run the development serv... | agpl-3.0 | Python | |
689fe4b59e339f15de7e8e1fd6bc9ed1a2588cf3 | Create two_sum.py | schana/random-hacking,lambeau/random-hacking,schana/random-hacking,schana/random-hacking | two_sum.py | two_sum.py | import random
items = [random.randint(-50, 50) for i in range(100)]
expected = 27
print(items)
seen = set()
for i in items:
if expected - i in seen:
print(i, expected - i)
seen.add(i)
print(seen)
| apache-2.0 | Python | |
2e2f48ca37d18386a0faba23cbbdd94fff5727b2 | Añade model para event | migonzalvar/alpha,migonzalvar/alpha,abertal/alpha,abertal/alpha,abertal/alpha,migonzalvar/alpha,abertal/alpha,migonzalvar/alpha | core/migrations/0018_event.py | core/migrations/0018_event.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-04-26 14:41
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0017_auto_20170426_1007'),
]
operations = [
migrations.CreateModel(
... | bsd-3-clause | Python | |
73ff8eb3a994741bb19384ae839f41a5125e3c7a | Add create_dev_account_roles | stencila/hub,stencila/hub,stencila/hub,stencila/hub,stencila/hub | director/scripts/create_dev_account_roles.py | director/scripts/create_dev_account_roles.py | """
Assign account roles to the test users.
"""
from django.contrib.auth.models import User
from django.conf import settings
from accounts.models import Account, AccountUserRole, AccountRole
def run(*args):
# Ensure that this is only used in development
assert settings.DEBUG
for user in User.objects.al... | apache-2.0 | Python | |
38b26f038fb7855a6b4d80fad897997acd4f0ef2 | handle double deletion caused by httpretty | okomestudio/moto,ZuluPro/moto,kennethd/moto,william-richard/moto,whummer/moto,botify-labs/moto,william-richard/moto,zonk1024/moto,Brett55/moto,jotes/moto,dbfr3qs/moto,silveregg/moto,Brett55/moto,ZuluPro/moto,jrydberg/moto,kefo/moto,dbfr3qs/moto,Affirm/moto,andresriancho/moto,rocky4570/moto,heddle317/moto,botify-labs/mo... | moto/route53/models.py | moto/route53/models.py | from moto.core import BaseBackend
from moto.core.utils import get_random_hex
class FakeZone:
def __init__(self, name, id):
self.name = name
self.id = id
self.rrsets = {}
def add_rrset(self, name, rrset):
self.rrsets[name] = rrset
def delete_rrset(self, name):
sel... | from moto.core import BaseBackend
from moto.core.utils import get_random_hex
class FakeZone:
def __init__(self, name, id):
self.name = name
self.id = id
self.rrsets = {}
def add_rrset(self, name, rrset):
self.rrsets[name] = rrset
def delete_rrset(self, name):
del... | apache-2.0 | Python |
bc17847b9e9cc71ea7ba45ef7292547384c70883 | Create Remove_Nth_Node_From_End_of_List.py | UmassJin/Leetcode | Array/Remove_Nth_Node_From_End_of_List.py | Array/Remove_Nth_Node_From_End_of_List.py | 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 1->2->3->5.
Note:
Given n will always be valid.
Try to do this in one pass
# Definition for singly-l... | mit | Python | |
112e3516d7c77f23edfed704651e8c5e7f7d75e4 | Add example heat map script for data | akrherz/iem,akrherz/iem,akrherz/iem,akrherz/iem,akrherz/iem | scripts/DEV/adm/heatmap.py | scripts/DEV/adm/heatmap.py | import numpy as np
import numpy.ma as ma
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from pyiem.plot import MapPlot
import sys
year = int(sys.argv[1])
x = []
y = []
for linenum, line in enumerate(open('visit_history_093013_st12.csv')):
if linenum == 0:
continue
tokens = line.split(",")
... | mit | Python | |
a2ff82db981aa6fd29f0b2d2d66e7cb02fb1813c | Create ctci-connected-cell-in-a-grid.py | OursRonchon/hackerrank,OursRonchon/hackerrank | cracking-the-coding-interview/ctci-connected-cell-in-a-grid.py | cracking-the-coding-interview/ctci-connected-cell-in-a-grid.py | def getBiggestRegion(grid,m,n):
def size(i,j):
if 0 <= i < len(grid) and 0 <= j < len(grid[i]) and grid[i][j] == 1:
grid[i][j] = 0
return 1 + sum(size(i2,j2) for i2 in range(i - 1,i + 2) for j2 in range(j - 1,j + 2))
return 0
return max(size(i,j) for i in range(n) for j i... | mit | Python | |
fe4e1eb3cc4485af9a1a48bfb02be4f651b23b1d | add config/ | T620/globe,T620/globe,T620/globe | config/config.py | config/config.py | #SECRETS
print "[INFO] Env config vars loaded"
#DATABASE_URL is defined in the environment of the machine running the app
#for instance, if running locally, DATABASE_URL is set doing:
#export DATABASE_URL="psql://epb/" etc
#for the time being
DEBUG=True
DEVELOPMENT=True
BCRYPT_LOG_ROUNDS = 5
SQLALCHEMY_TRACK_MODIFIC... | mit | Python | |
f59bc6d034438ca85f4a9f55033523ac238c9e98 | Create Prototype.py | Xustyx/RouteSimulator | Prototype.py | Prototype.py | from math import radians, cos, sin, asin, sqrt
from random import randint
def haversine(point1, point2):
lon1 = point1['lon']
lat1 = point1['lat']
lon2 = point2['lon']
lat2 = point2['lat']
# Convert decimal degrees to radians
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
# Haversine formula... | mit | Python | |
62a860112db8c263d26eb9e4cdb67d23ce61848a | Add a snippet (Python OpenCV). | jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets | python/opencv/opencv_2/write_image.py | python/opencv/opencv_2/write_image.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2015 Jérémie DECOCK (http://www.jdhp.org)
"""
OpenCV - Write image: write an image given in arguments
Required: opencv library (Debian: aptitude install python-opencv)
See: https://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_i... | mit | Python | |
fa0752a319ba7412c438a5501a54446aa6f61bc7 | Create xgboost.py | Diyago/Machine-Learning-scripts,Diyago/Machine-Learning-scripts | xgboost.py | xgboost.py | # Imports
# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load in
from __future__ import division
import matplotlib.pyplot as plt
import numpy ... | apache-2.0 | Python | |
f49cc16d96b5a833293ebbc777b4268142d07bd1 | ADD example | Teekuningas/mne-python,mne-tools/mne-python,cjayb/mne-python,jaeilepp/mne-python,cmoutard/mne-python,nicproulx/mne-python,mne-tools/mne-python,teonlamont/mne-python,alexandrebarachant/mne-python,rkmaddox/mne-python,pravsripad/mne-python,mne-tools/mne-python,wmvanvliet/mne-python,rkmaddox/mne-python,bloyl/mne-python,pra... | examples/visualization/plot_report_slider.py | examples/visualization/plot_report_slider.py | """
=======================================
Plot Time-Series Slider with MNE-Report
=======================================
In this example, MEG evoked data are plotted in an html slider.
"""
# Authors: Teon Brooks <teon.brooks@gmail.com
#
# License: BSD (3-clause)
from mne.report import Report
from mne.datasets imp... | bsd-3-clause | Python | |
50c3fca5576237a1757574b6b24b259567c1bee1 | Fix committed real DBHOSTNAME. | joshk/FrameworkBenchmarks,hamiltont/FrameworkBenchmarks,valyala/FrameworkBenchmarks,zapov/FrameworkBenchmarks,ratpack/FrameworkBenchmarks,sanjoydesk/FrameworkBenchmarks,greenlaw110/FrameworkBenchmarks,sxend/FrameworkBenchmarks,sxend/FrameworkBenchmarks,sgml/FrameworkBenchmarks,xitrum-framework/FrameworkBenchmarks,psfbl... | flask/app.py | flask/app.py | from flask import Flask, jsonify, request
from flask.ext.sqlalchemy import SQLAlchemy
from sqlalchemy import create_engine
from random import randint
try:
import MySQLdb
mysql_schema = "mysql:"
except ImportError:
mysql_schema = "mysql+pymysql:"
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI']... | from flask import Flask, jsonify, request
from flask.ext.sqlalchemy import SQLAlchemy
from sqlalchemy import create_engine
from random import randint
try:
import MySQLdb
mysql_schema = "mysql:"
except ImportError:
mysql_schema = "mysql+pymysql:"
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI']... | bsd-3-clause | Python |
dcf49377defe8ce3debadc8d0c09b683663f7b73 | Add migration for the new PrivateAPIKey model (Bravo Nils !) | UrLab/incubator,UrLab/incubator,UrLab/incubator,UrLab/incubator | space/migrations/0011_privateapikey.py | space/migrations/0011_privateapikey.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
from django.conf import settings
import uuid
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('space', '0010_auto_20151129_2... | agpl-3.0 | Python | |
0460c3d8e25e6f060b42e19bdfdd8213e02d6c7b | Add Exercise 9.11. | skidzo/pydy,skidzo/pydy,Shekharrajak/pydy,skidzo/pydy,Shekharrajak/pydy,jcrist/pydy,oliverlee/pydy,Shekharrajak/pydy,skidzo/pydy,oliverlee/pydy,jcrist/pydy,oliverlee/pydy,Shekharrajak/pydy,jcrist/pydy,jcrist/pydy,jcrist/pydy,jcrist/pydy,jcrist/pydy | Kane1985/Chapter5/Ex9.11.py | Kane1985/Chapter5/Ex9.11.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Exercise 9.11 from Kane 1985."""
from __future__ import division
from sympy import Dummy
from sympy import collect, expand, sin, cos, symbols
from sympy.physics.mechanics import ReferenceFrame, Point
from sympy.physics.mechanics import dynamicsymbols
from util import ms... | bsd-3-clause | Python | |
bd080d7cb36c5471ba1d13700f0a1a4debb07b82 | add tests for ext changes | TheTrain2000/async2rewrite | async2rewrite/tests/test_ext_changes.py | async2rewrite/tests/test_ext_changes.py | import async2rewrite
def test_remove_pass_context_true():
converted_code = async2rewrite.from_text("@bot.command(pass_context=True)\nasync def test(ctx):\n pass")
assert converted_code == "@bot.command()\nasync def test(ctx):\n pass"
def test_dont_remove_pass_context_false():
converted_code = asyn... | mit | Python | |
f4628678066c72309d3fd121af1aaf54d9905ca3 | Make sure xla_client is always imported before TPU client extension. | frreiss/tensorflow-fred,freedomtan/tensorflow,freedomtan/tensorflow,karllessard/tensorflow,petewarden/tensorflow,davidzchen/tensorflow,tensorflow/tensorflow-pywrap_saved_model,petewarden/tensorflow,paolodedios/tensorflow,paolodedios/tensorflow,frreiss/tensorflow-fred,tensorflow/tensorflow-pywrap_saved_model,gautam1858/... | tensorflow/compiler/xla/python/tpu_driver/client/tpu_client.py | tensorflow/compiler/xla/python/tpu_driver/client/tpu_client.py | # Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | # Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | apache-2.0 | Python |
e78e56e38dfa7bfac79bc3a699ca76236d700e2a | Add tests creation of grammar with terminals as parameters | PatrikValkovic/grammpy | tests/grammar_term-nonterm_test/TerminalAddWhenCreatingTest.py | tests/grammar_term-nonterm_test/TerminalAddWhenCreatingTest.py | #!/usr/bin/env python
"""
:Author Patrik Valkovic
:Created 23.06.2017 16:39
:Licence GNUv3
Part of grammpy
"""
from unittest import TestCase
from grammpy import Grammar
from grammpy.Terminal import Terminal
class TerminalAddWhenCreatingTest(TestCase):
def test_addOneInArray(self):
gr = Grammar(terminals=... | mit | Python | |
7d604af457a17fdf6cb433ce46a3f691ad566658 | Implement client side component of b0wser | Karthikeyan-kkk/ooni-probe,juga0/ooni-probe,kdmurray91/ooni-probe,hackerberry/ooni-probe,juga0/ooni-probe,kdmurray91/ooni-probe,juga0/ooni-probe,Karthikeyan-kkk/ooni-probe,0xPoly/ooni-probe,0xPoly/ooni-probe,Karthikeyan-kkk/ooni-probe,0xPoly/ooni-probe,lordappsec/ooni-probe,hackerberry/ooni-probe,lordappsec/ooni-probe,... | ooni/plugins/b0wser.py | ooni/plugins/b0wser.py | """
This is a self genrated test created by scaffolding.py.
you will need to fill it up with all your necessities.
Safe hacking :).
"""
from zope.interface import implements
from twisted.python import usage
from twisted.plugin import IPlugin
from twisted.internet import protocol, endpoints
from ooni.plugoo.tests impor... | bsd-2-clause | Python | |
0fc65182b269de4975eba9060a1afe7a5ecacd67 | add empty shell for tests | patochectp/navitia,patochectp/navitia,xlqian/navitia,pbougue/navitia,antoine-de/navitia,kadhikari/navitia,antoine-de/navitia,xlqian/navitia,xlqian/navitia,Tisseo/navitia,pbougue/navitia,CanalTP/navitia,CanalTP/navitia,Tisseo/navitia,Tisseo/navitia,kinnou02/navitia,kinnou02/navitia,pbougue/navitia,Tisseo/navitia,CanalTP... | source/jormungandr/tests/schema_tests.py | source/jormungandr/tests/schema_tests.py | # Copyright (c) 2001-2014, Canal TP and/or its affiliates. All rights reserved.
#
# This file is part of Navitia,
# the software to build cool stuff with public transport.
#
# Hope you'll enjoy and contribute to this project,
# powered by Canal TP (www.canaltp.fr).
# Help us simplify mobility and open public tr... | agpl-3.0 | Python | |
a32b033b8c30fa038ce8845333c1560059475f39 | Add regression test for #4002 | spacy-io/spaCy,spacy-io/spaCy,explosion/spaCy,explosion/spaCy,spacy-io/spaCy,explosion/spaCy,spacy-io/spaCy,honnibal/spaCy,honnibal/spaCy,explosion/spaCy,explosion/spaCy,spacy-io/spaCy,honnibal/spaCy,spacy-io/spaCy,honnibal/spaCy,explosion/spaCy | spacy/tests/regression/test_issue4002.py | spacy/tests/regression/test_issue4002.py | # coding: utf8
from __future__ import unicode_literals
import pytest
from spacy.matcher import PhraseMatcher
from spacy.tokens import Doc
@pytest.mark.xfail
def test_issue4002(en_vocab):
"""Test that the PhraseMatcher can match on overwritten NORM attributes.
"""
matcher = PhraseMatcher(en_vocab, attr="N... | mit | Python | |
03f2440374a69aa9194891b0e8a9cbf0355b034f | Rename the former test settings file to be 'test_settings'. This settings file is used to run unit tests. | penzance/ab-testing-tool,penzance/ab-testing-tool,penzance/ab-testing-tool,penzance/ab-testing-tool | ab_testing_tool/settings/test_settings.py | ab_testing_tool/settings/test_settings.py | from .base import *
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
STATIC_ROOT = normpath(join(SITE_ROOT, 'http_static'))
LOGGING = {
'version': 1,
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'lo... | mit | Python | |
8f8a1b4d3613908ed7b26af04ec83f27f1f095fb | add solution for Summary Ranges | zhyu/leetcode,zhyu/leetcode | algorithms/summaryRanges/summaryRanges.py | algorithms/summaryRanges/summaryRanges.py | class Solution:
# @param {integer[]} nums
# @return {string[]}
def summaryRanges(self, nums):
res = []
for num in nums:
if not res or num-res[-1][-1] > 1:
res += [],
res[-1][1:] = num,
return ['->'.join(map(str, r)) for r in res]
| mit | Python | |
e97d98aba638cd58d9f0822cf486aad7f85c23c6 | Add 04-nodes.py | dustalov/watset,dustalov/watset | 04-nodes.py | 04-nodes.py | #!/usr/bin/env python
import csv
import sys
synsets, index = {}, {}
with open('03-cw.txt') as f:
reader = csv.reader(f, delimiter='\t', quoting=csv.QUOTE_NONE)
for row in reader:
synsets[int(row[0])] = [word for word in row[2].split(', ') if word]
for word in row[2].split(', '):
i... | mit | Python | |
f46bd0f572698689fdef6b777cecd8219c542ef5 | Create 20_lines.py | johnowhitaker/turtle-frac | 20_lines.py | 20_lines.py | #Same as fractastic.py but squeezed down to 20 lines
import turtle
max_iterations = 500
bob = turtle.Turtle()
bob.speed(0)
def mandel(zx, zy):
z = zx + zy * 1j
c = z
for i in xrange(max_iterations):
if abs(z) > 2.0: break
z = z * z + c
return i
def draw_plot(xstart, ystart, xsize, ysize, xa, xb, ya, yb):
... | mit | Python | |
a2216c5a8626fb7d18e9c1f16870123aabbde389 | Fix so MindReader can player against itself | mojones/Axelrod,drvinceknight/Axelrod,risicle/Axelrod,uglyfruitcake/Axelrod,bootandy/Axelrod,uglyfruitcake/Axelrod,emmagordon/Axelrod,mojones/Axelrod,risicle/Axelrod,kathryncrouch/Axelrod,kathryncrouch/Axelrod,emmagordon/Axelrod,bootandy/Axelrod | axelrod/strategies/mindreader.py | axelrod/strategies/mindreader.py | from axelrod import Player, RoundRobin, Game
import copy
import inspect
class MindReader(Player):
"""A player that looks ahead at what the opponent will do and decides what to do."""
name = 'Mind Reader'
max_look_ahead = 200
def strategy(self, opponent):
"""Pretends to play the opponent 50 ti... | from axelrod import Player, RoundRobin, Game
import copy
import inspect
class MindReader(Player):
"""A player that looks ahead at what the opponent will do and decides what to do."""
name = 'Mind Reader'
def strategy(self, opponent):
"""Pretends to play the opponent 50 times before each match.
... | mit | Python |
7f2a598f70ac45af00395faa64e91e51de0cab47 | Update storage tests | b-mueller/mythril,b-mueller/mythril,b-mueller/mythril,b-mueller/mythril | tests/laser/state/storage_test.py | tests/laser/state/storage_test.py | import pytest
from mythril.laser.smt import symbol_factory
from mythril.laser.ethereum.state.account import Storage
from mythril.laser.smt import Expression
BVV = symbol_factory.BitVecVal
storage_uninitialized_test_data = [({}, 1), ({1: 5}, 2), ({1: 5, 3: 10}, 2)]
@pytest.mark.parametrize("initial_storage,key", sto... | mit | Python | |
629553ec992c59500ef64b04b8fc9fb0500bcaee | Add tests for cookie verification | pjotrp/genenetwork2,genenetwork/genenetwork2,genenetwork/genenetwork2,genenetwork/genenetwork2,zsloan/genenetwork2,pjotrp/genenetwork2,zsloan/genenetwork2,pjotrp/genenetwork2,zsloan/genenetwork2,zsloan/genenetwork2,genenetwork/genenetwork2,pjotrp/genenetwork2,pjotrp/genenetwork2 | wqflask/tests/wqflask/test_user_session.py | wqflask/tests/wqflask/test_user_session.py | """Test cases for some methods in user_session.py"""
import unittest
from wqflask.user_session import verify_cookie
class TestUserSession(unittest.TestCase):
def test_verify_cookie(self):
"""
Test cookie verification
"""
self.assertEqual(
"3f4c1dbf-5b56-4260-87d6-f3544... | agpl-3.0 | Python | |
f4e2135f23f768da2923b48b4d3567071c386148 | Add Google backend | comandrei/django-template-shortcuts | template_shortcuts/providers/google.py | template_shortcuts/providers/google.py | from provider import CDNProvider
class Google(CDNProvider):
base_url = "//ajax.googleapis.com/ajax/libs/%s/%s/%s"
def angular(self, version):
return self._build_js_url("angularjs", version, "angular")
def chrome_frame(self, version):
return self._build_js_url("chrome-frame", version, "CF... | bsd-3-clause | Python | |
8957ad97b560251e02c857683a5b77301ee49293 | add performance test for a few client server queries | storborg/manhattan | manhattan/tests/perf/test_clientserver.py | manhattan/tests/perf/test_clientserver.py | import time
from manhattan.client import Client
client = Client()
def test(f, trials=500):
start = time.time()
for ii in range(trials):
f()
end = time.time()
elapsed = end - start
print ("Ran %d trials, %0.2f ms each" %
(trials, ((1000. * elapsed) / trials)))
def get_result... | mit | Python | |
d3712e9f567ba0924810768e5c6e1d208fd99816 | Add visualize_filters.py | aidiary/keras_examples,aidiary/keras_examples | cnn/cifar10/visualize_filters.py | cnn/cifar10/visualize_filters.py | import os
import json
import matplotlib.pyplot as plt
from keras.models import model_from_json
if __name__ == '__main__':
model_file = os.path.join('result', 'model.json')
weight_file = os.path.join('result', 'model.h5')
with open(model_file, 'r') as fp:
model = model_from_json(fp.read())
mod... | mit | Python | |
4d30dd240e3b66cf3c35bbac24a2ae6043a7a081 | Add accuracy test | ttakamura/chainer,rezoo/chainer,benob/chainer,chainer/chainer,AlpacaDB/chainer,pfnet/chainer,wkentaro/chainer,chainer/chainer,benob/chainer,kikusu/chainer,woodshop/complex-chainer,kashif/chainer,okuta/chainer,ikasumi/chainer,ysekky/chainer,chainer/chainer,minhpqn/chainer,masia02/chainer,okuta/chainer,okuta/chainer,wood... | tests/functions_tests/test_accuracy.py | tests/functions_tests/test_accuracy.py | from unittest import TestCase
import numpy
from chainer import cuda, Variable
from chainer.cuda import to_cpu, to_gpu
from chainer.gradient_check import assert_allclose
from chainer.functions import accuracy
cuda.init()
class TestAccuracy(TestCase):
def setUp(self):
self.x = numpy.random.uniform(-1, 1, (1... | mit | Python | |
932d6c10af549307547aeb5c920283ae68a0c114 | Create ShinyeiPPD42.py | nejohnson2/ShinyeiPPD42 | pigpio/ShinyeiPPD42.py | pigpio/ShinyeiPPD42.py | import pigpio
import time
class Shinyei(object):
def __init__(self, pi, gpio):
self.pi = pi
self.gpio = gpio
self._start_tick = None
self._last_tick = None
self._low_ticks = 0
self._high_ticks = 0
pi.set_mode(gpio, pigpio.INPUT)
self._cb = pi.callback(gpio, pigpio.EITHER_EDGE, self._cbf)
def read... | mit | Python | |
7bf3337a1b632590cf22ecb99c1cb3d97cf35af6 | Implement test_build_pawn | LogicalDash/LiSE,LogicalDash/LiSE | ELiDE/ELiDE/tests/test_sprite_builder.py | ELiDE/ELiDE/tests/test_sprite_builder.py | from pprint import pprint
from ..pallet import Pallet
from .util import ELiDEAppTest, idle_until, window_with_widget
class TestSpriteBuilder(ELiDEAppTest):
def test_build_pawn(self):
app = self.app
win = window_with_widget(app.build())
app.manager.current = 'pawncfg'
idle_until(la... | agpl-3.0 | Python | |
06d4a93ecbce90e752712f69b8ffd435019337b2 | Create metric_table script for comparing metrics | kdelwat/LangEvolve,kdelwat/LangEvolve,kdelwat/LangEvolve | app/scripts/metric_table.py | app/scripts/metric_table.py | from tabulate import tabulate
import csv
import yaml
import sys
import os.path as path
base_directory = path.dirname(path.dirname(path.abspath(__file__)))
sys.path.append(base_directory)
import parse
import deparse
import metrics
def main():
target_words = ['bːɒtl', 'b\u02D0ɒtl']
with open(path.join(base_d... | mit | Python | |
428d57040b35b3d644cda05c3c9cbdb630622146 | Create Udpclient.py | saifeldinhesham/ClientServerModel | Udpclient.py | Udpclient.py | import socket #for sockets
import sys #for exit
from random import randint
import time
from thread import *
import threading
from threading import Thread, current_thread
host ="172.20.10.3";
port = 6667;
def sentthread(num):
# create dgram udp socket
try:
s = socket.socket(socket.AF_INET, socket.SOC... | unlicense | Python | |
a4f86e11bbdcf2f478fd9cfb8df33a150f8a086e | Add poolstat api example to project root. | benjiboi214/mmpl-wagtail,benjiboi214/mmpl-wagtail,benjiboi214/mmpl-wagtail | poolstatapi-example.py | poolstatapi-example.py | import requests
import hmac
import hashlib
import base64
PUBLIC_KEY = '##'
PRIVATE_KEY = '##'
URL = 'https://www.poolstat.net.au/restapi/v1/ladders'
digest = hmac.new(PRIVATE_KEY, URL, digestmod=hashlib.sha256).hexdigest()
# signature = base64.b64encode(digest).decode()
print digest
#print signature
headers = {
... | mit | Python | |
da36f32893b3ba58bfecdaa819bb780845e94747 | add script to extract annotations from csv dumps | CKrawczyk/python-reducers-for-caesar | bin/extract_panoptes_csv.py | bin/extract_panoptes_csv.py | #!/usr/bin/env python
import argparse
from panoptes_aggregation import extractors
import json
import pandas
import progressbar
parser = argparse.ArgumentParser(description="extract data from panoptes classifications based on the workflow")
parser.add_argument("classification_csv", help="the classificaiton csv file co... | apache-2.0 | Python | |
dc386a432e23425667f05a8b2ff943d12e44dac8 | bump version to 0.8.19 | aatchison/mycroft-core,linuxipho/mycroft-core,forslund/mycroft-core,linuxipho/mycroft-core,Dark5ide/mycroft-core,MycroftAI/mycroft-core,MycroftAI/mycroft-core,forslund/mycroft-core,Dark5ide/mycroft-core,aatchison/mycroft-core | mycroft/version/__init__.py | mycroft/version/__init__.py | # Copyright 2016 Mycroft AI, Inc.
#
# This file is part of Mycroft Core.
#
# Mycroft Core is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later versio... | # Copyright 2016 Mycroft AI, Inc.
#
# This file is part of Mycroft Core.
#
# Mycroft Core is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later versio... | apache-2.0 | Python |
3a48a8919b633a1244024d96445f880f9d03247b | add problem0002.py | Furisuke/ProjectEuler,Furisuke/ProjectEuler,Furisuke/ProjectEuler | python3/problem0002.py | python3/problem0002.py | from itertools import takewhile
def fibonacci(first=1, second=2):
'''yields fibonacci sequence'''
x = first
x_ = second
yield first
yield second
while True:
x__ = x + x_
yield x__
x = x_
x_ = x__
if __name__ == '__main__':
print(sum(n for n in takewhile(lam... | mit | Python | |
64bfcf8e87ef8186a446bce0ec73502e48b3b9a4 | Create construct-binary-tree-from-string.py | kamyu104/LeetCode,jaredkoontz/leetcode,kamyu104/LeetCode,yiwen-luo/LeetCode,yiwen-luo/LeetCode,tudennis/LeetCode---kamyu104-11-24-2015,tudennis/LeetCode---kamyu104-11-24-2015,yiwen-luo/LeetCode,jaredkoontz/leetcode,tudennis/LeetCode---kamyu104-11-24-2015,tudennis/LeetCode---kamyu104-11-24-2015,jaredkoontz/leetcode,kamy... | Python/construct-binary-tree-from-string.py | Python/construct-binary-tree-from-string.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 str2tree(self, s):
"""
:type s: str
:rtype: TreeNode
"""... | mit | Python | |
55ccaad47c2e3a1432b012218c72bca28fe06d73 | Create a GreetingsPlugin as a sample plugin | dnif/fnExchange-sample-plugin | greetings.py | greetings.py | from fnexchange.core.plugins import AbstractPlugin
class GreetingsPlugin(AbstractPlugin):
"""
GreetingsPlugin provides an interface to generate greetings in different languages
for given users (provided their names and locales).
At this time, only the following locales are supported: "en-us", "hi-in"
... | apache-2.0 | Python | |
0b83d7baf6cd02fb673aaf9a9e7b4b7498f4240a | Create rsa_monitor.py | sh0wrun/RSA_status_check | rsa_monitor.py | rsa_monitor.py | #!/usr/bin/env python
import os
log=file('RSA_check.log','a')
def check_rsa_result(rsa_server):
''' use os.putenv to set shell env is very important used in cron'''
os.putenv('HOME','/root/')
os.putenv('USER','root')
os.putenv('USERNAME','root')
tocken_f=os.popen('/usr/local/stocken/bin/stoken')
... | apache-2.0 | Python | |
1cccfd3eb0ea34450555fab444eb055ff56a7dd6 | Move decorators to special file | daurer/afnumpy,FilipeMaia/afnumpy | afnumpy/decorators.py | afnumpy/decorators.py | import afnumpy
def outufunc(func):
def wrapper(*args, **kws):
out = kws.pop('out', None)
ret = func(*args, **kws)
if out is not None:
out[:] = ret
return ret
return wrapper
def iufunc(func):
def wrapper(*args, **kws):
if all(isinstance(A, afnumpy.ndarray... | bsd-2-clause | Python | |
be8b7c27b25b60540c2e53504ce42543724577df | Add utilities for the clients | napalm-automation/napalm-logs,napalm-automation/napalm-logs | napalm_logs/utils/__init__.py | napalm_logs/utils/__init__.py | # -*- coding: utf-8 -*-
'''
napalm-logs utilities
'''
from __future__ import absolute_import
from __future__ import unicode_literals
# Import pythond stdlib
import ssl
import socket
# Import python stdlib
import umsgpack
import nacl.secret
import nacl.signing
import nacl.encoding
from nacl.exceptions import CryptoErr... | apache-2.0 | Python | |
1ecb594b945bff57ad60c703740cdbb8d8509d9d | Add systemd utils module | saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt | salt/utils/systemd.py | salt/utils/systemd.py | '''
Contains systemd related help files
'''
# import python libs
import os
def sd_booted(context):
'''
Return True if the system was booted with systemd, False otherwise.
Pass in the loader context "__context__", this function will set the
systemd.sd_booted key to represent if systemd is running
'... | apache-2.0 | Python | |
848b5f0984844eb2d1d32d0cf96038e597a634eb | add automobile csv_upload | paul-rs/amaas-core-sdk-python,nedlowe/amaas-core-sdk-python,nedlowe/amaas-core-sdk-python,amaas-fintech/amaas-core-sdk-python,paul-rs/amaas-core-sdk-python,amaas-fintech/amaas-core-sdk-python | amaascore/csv_upload/assets/automobile.py | amaascore/csv_upload/assets/automobile.py | import logging.config
import csv
from amaascore.tools.csv_tools import csv_stream_to_objects
from amaascore.assets.automobile import Automobile
from amaascore.assets.interface import AssetsInterface
from amaasutils.logging_utils import DEFAULT_LOGGING
class AutomobileUploader(object):
def __init__(self):
... | apache-2.0 | Python | |
52e087c20cacc4b664fbfc781eafecfebe0cf43c | Add views to display list of current projects accepted in the program. | rhyolight/nupic.son,rhyolight/nupic.son,rhyolight/nupic.son | app/soc/modules/gsoc/views/projects_list.py | app/soc/modules/gsoc/views/projects_list.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 | |
b9d4ad23eb1bd08cae006350dc6c219f838ecdd7 | add tests | saklar13/Meowth,uaprom-summer-2015/Meowth,saklar13/Meowth,uaprom-summer-2015/Meowth,saklar13/Meowth,saklar13/Meowth,uaprom-summer-2015/Meowth,uaprom-summer-2015/Meowth | project/tests/test_mail.py | project/tests/test_mail.py | from sqlalchemy.exc import StatementError
from project.models import MailTemplate
from project.tests.utils import ProjectTestCase
class TestMailTemplateBl(ProjectTestCase):
def test_get(self):
mail1 = MailTemplate.bl.get(MailTemplate.MAIL.CV)
mail2 = MailTemplate.query.filter(
MailTem... | bsd-3-clause | Python | |
6d76193a9f6e8beee29d92ec3c79efb4f6218e86 | Add IslaAukate and IslaAukateColor | webcomics/dosage,webcomics/dosage,peterjanes/dosage,peterjanes/dosage | dosagelib/plugins/i.py | dosagelib/plugins/i.py | # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2017 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function
from re import compile, escape
from ..scraper import _BasicScraper, _Pars... | # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2017 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function
from re import compile, escape
from ..scraper import _BasicScraper
from .... | mit | Python |
afaaef761ca394f1db4516252ffb89789c606890 | Add search.py | irqed/octokit.py | octokit/resources/search.py | octokit/resources/search.py | # encoding: utf-8
"""Methods for the Search API
http://developer.github.com/v3/search/
"""
| mit | Python | |
df4b47b02cd0d8a24e3939457d6787f6a203539e | Create WebUtils.py | Soncrates/stock-study,Soncrates/stock-study | data/WebUtils.py | data/WebUtils.py | class WebUtils(object) :
@staticmethod
def invoke_url(url,headers=None, raw=False) :
import requests
if headers is not None :
ret = requests.get(url, headers=headers)
else :
ret = requests.get(url)
if not raw : ret = ret.text
else : ret = ret.content
r... | lgpl-2.1 | Python | |
26f153877ad141032bc78e2ca89026cf125c71d7 | Create PedidoCadastrar.py | AEDA-Solutions/matweb,AEDA-Solutions/matweb,AEDA-Solutions/matweb,AEDA-Solutions/matweb,AEDA-Solutions/matweb | backend/Models/Matricula/PedidoCadastrar.py | backend/Models/Matricula/PedidoCadastrar.py | from Framework.Pedido import Pedido
from Framework.ErroNoHTTP import ErroNoHTTP
class PedidoCadastrar(Pedido):
def __init__(self,variaveis_do_ambiente):
super(PedidoCadastrar, self).__init__(variaveis_do_ambiente)
try:
self.ano = self.corpo['ano']
self.nome = self.corpo['nome']
self.periodo = self.corpo... | mit | Python | |
80261391bf75c4904825d97ae7b3168e4652463a | Create most_digits.py | Kunalpod/codewars,Kunalpod/codewars | most_digits.py | most_digits.py | #Kunal Gautam
#Codewars : @Kunalpod
#Problem name: Most digits
#Problem level: 7 kyu
def find_longest(arr):
return arr[[len(str(x)) for x in arr].index(max([len(str(x)) for x in arr]))]
| mit | Python | |
986ee0ffae416cf1dc833f581a89d718dc2ff2fe | Add a first draft of the evaluation module. | johnmartinsson/bird-species-classification,johnmartinsson/bird-species-classification | bird/evaluate.py | bird/evaluate.py | from models.cuberun import CubeRun
import numpy as np
import utils
import loader
nb_classes = 19
input_shape = (257, 624, 1)
(cols, rows, chs) = input_shape
image_shape = (cols, rows)
batch_size=32
def evaluate(model, data_filepath, file2labels_filepath):
model.compile(loss='binary_crossentropy', optimizer='adam'... | mit | Python | |
c59a08d60e42f56be628d36e4572772fb5707c98 | Create pyblitzle.py | filinger/blitzle,filinger/blitzle,filinger/blitzle | pyblitzle.py | pyblitzle.py | import argparse
import cv2
class FilterValue(object):
def __init__(self, x, y, z):
super(FilterValue, self).__init__()
self.x = x
self.y = y
self.z = z
def set_x(self, x):
self.x = x
def set_y(self, y):
self.y = y
def set_z(self, z):
self.z = ... | mit | Python | |
ff4b6b7ac283f8828c6c268c9b4072ff72171776 | add Digital Filter class | pylayers/pylayers,dialounke/pylayers,dialounke/pylayers,pylayers/pylayers | pylayers/signal/DF.py | pylayers/signal/DF.py | #!/usr/bin/python
# -*- coding: latin1 -*-
from numpy import *
from scipy import io
from scipy.signal import *
from pylab import *
from EnergyDetector import *
class DF(object):
""" Digital Filter Class
Methods
-------
filter : flilter a signal
"""
def __init__(self,b=array([1]),a=array([1,... | mit | Python | |
020f78b6aa265f925db6a21435a074f6ca1a3cbf | update ipython notebook runner to accomodate specific usages of matplotlib (i.e. import matplotlib.pyplot as plt) and ipython magic functions (ignore them) within the demo testing framework. | YzPaul3/h2o-3,kyoren/https-github.com-h2oai-h2o-3,mathemage/h2o-3,madmax983/h2o-3,h2oai/h2o-dev,spennihana/h2o-3,datachand/h2o-3,pchmieli/h2o-3,mathemage/h2o-3,spennihana/h2o-3,tarasane/h2o-3,datachand/h2o-3,kyoren/https-github.com-h2oai-h2o-3,datachand/h2o-3,datachand/h2o-3,h2oai/h2o-dev,junwucs/h2o-3,junwucs/h2o-3,ju... | h2o-py/tests/utils/ipynb_demo_runner.py | h2o-py/tests/utils/ipynb_demo_runner.py | import json
import os
def ipy_notebook_exec(path,save_and_norun=False):
notebook = json.load(open(path))
program = ''
for block in ipy_code_blocks(notebook):
for line in ipy_valid_lines(block):
if "h2o.init" not in line:
program += line if '\n' in line else line + '\n'
... | import json
import os
def ipy_notebook_exec(path,save_and_norun=False):
notebook = json.load(open(path))
program = ''
for block in ipy_blocks(notebook):
for line in ipy_lines(block):
if "h2o.init" not in line:
program += line if '\n' in line else line + '\n'
if save_... | apache-2.0 | Python |
944d0ff3995916d80e871e47d73d9b9df7848e6e | Add wsgi | ML42/facemash,ML42/facemash,ML42/facemash | server/wsgi.py | server/wsgi.py | from main import app as application
if __name__ == "__main__":
application.run()
| bsd-3-clause | Python | |
5c2461ca9dced8099eb67d80fdd118d1ec012b2d | add amendment content type | ecreall/nova-ideo,ecreall/nova-ideo,ecreall/nova-ideo,ecreall/nova-ideo,ecreall/nova-ideo | novaideo/content/amendment.py | novaideo/content/amendment.py | import colander
import deform
from zope.interface import implementer
from persistent.list import PersistentList
from pyramid.threadlocal import get_current_request
from substanced.interfaces import IUserLocator
from substanced.principal import DefaultUserLocator
from substanced.content import content
from substanced.s... | agpl-3.0 | Python | |
34979240ae3cd9ed617a358a0097376badfdc229 | add announcement view | Scifabric/pybossa,Scifabric/pybossa,PyBossa/pybossa,PyBossa/pybossa | pybossa/view/announcements.py | pybossa/view/announcements.py | # -*- coding: utf8 -*-
# This file is part of PYBOSSA.
#
# Copyright (C) 2017 Scifabric LTD.
#
# PYBOSSA 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 | |
546c38310ff49af4f9490ba32ce3ab2cfc4d5e8d | Create sherpa_test.py | kelceydamage/sherpa,kelceydamage/sherpa | sherpa_test.py | sherpa_test.py | #!/usr/bin/env python
import optparse
from sherpa import Sherpa
from sherpa_helpers import debug_results, distribution, quartermaster
from perf import *
parser = optparse.OptionParser()
parser.add_option('-p', '--packages', dest='packages', help='specify the minimum number of packages to ship')
parser.add_option('-r'... | apache-2.0 | Python | |
21d73b5afc04a718c0db2bff899e7d1f4020deb3 | set blank=True on editoritem.licence | numbas/editor,numbas/editor,numbas/editor | editor/migrations/0019_auto_20160601_1528.py | editor/migrations/0019_auto_20160601_1528.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('editor', '0018_site_broadcasts'),
]
operations = [
migrations.AlterField(
model_name='editoritem',
n... | apache-2.0 | Python | |
5e401d2f2a2f9c874667a4aa372fd07755ab9c31 | add Brain.save_movie() example | diego0020/PySurfer,bpinsard/PySurfer,haribharadwaj/PySurfer,mwaskom/PySurfer,effigies/PySurfer,nipy/PySurfer,Eric89GXL/PySurfer | examples/save_movie.py | examples/save_movie.py | """
Create movie from MEG inverse solution
=======================================
Data were computed using mne-python (http://martinos.org/mne)
"""
print __doc__
import os
import numpy as np
from surfer import Brain
from surfer.io import read_stc
"""
create Brain object for visualization
"""
brain = Brain('fsave... | bsd-3-clause | Python | |
a482ac3b96e4c8b72d1055b7f29a474c85101f67 | Create solution.py | lilsweetcaligula/Online-Judges,lilsweetcaligula/Online-Judges,lilsweetcaligula/Online-Judges | leetcode/easy/power_of_two/py/solution.py | leetcode/easy/power_of_two/py/solution.py | class Solution(object):
def isPowerOfTwo(self, n):
"""
:type n: int
:rtype: bool
"""
return n > 0 and (n & (n - 1)) == 0
| mit | Python | |
4b0221ca503be9450919e4ed4e6a75ce92cd2d63 | Create new module for continuous design variables | csdms/dakota,csdms/dakota | csdms/dakota/variables/continuous_design.py | csdms/dakota/variables/continuous_design.py | """Implementation of a Dakota continous design variable."""
from .base import VariableBase
classname = 'ContinuousDesign'
class ContinuousDesign(VariableBase):
"""Define attributes for Dakota continous design variables."""
def __init__(self,
variables=('x1', 'x2'),
initi... | mit | Python | |
9f8f5e731d0cd9096e230c78b40a60be7eceef56 | update : minor changes | black-perl/ptop | ptop/plugins/disk_sensor.py | ptop/plugins/disk_sensor.py | '''
Disk Sensor Plugin
'''
from ptop.core import Plugin
import psutil
class DiskSensor(Plugin):
def __init__(self,**kwargs):
super(DiskSensor,self).__init__(**kwargs)
# overriding the update method
def update(self):
# there can be many text (key,value) pairs to display corresponding to... | mit | Python | |
6064f3897699903b85a469a9ee77e44116f7df4c | add a network utility to check for ipv6 | ceph/radosgw-agent,ceph/radosgw-agent | radosgw_agent/util/network.py | radosgw_agent/util/network.py | import socket
def is_ipv6(address):
"""
Check if an address is an IPV6 one, but trim commonly used brackets as the
``socket`` module complains about them.
"""
if not isinstance(address, str):
return False
if address.startswith('['): # assume we need to split on possible port
... | mit | Python | |
0a4984fa49ec53ae5b2908e0518b4e72c031fc1b | add python3 encoder for bytes and sets | Caleydo/caleydo_server,phovea/phovea_server,phovea/phovea_server,Caleydo/caleydo_server,phovea/phovea_server,phovea/phovea_server | phovea_server/python3_encoder.py | phovea_server/python3_encoder.py | """
This encoder is required to handle changes of data types in Python 3.7 by decoding bytes objects to strings and adding list() to set().
"""
class Python3Encoder(object):
def __contains__(self, obj):
if isinstance(obj, bytes):
return True
if isinstance(obj, set):
return True
return False
... | bsd-3-clause | Python | |
9b1b66f72b3e9ca383d2396a368f8ce5e85d9e7c | Add a snippet (python/matplotlib). | jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets,jeremiedecock/snippets | python/matplotlib/plot2d.py | python/matplotlib/plot2d.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import numpy as np
import matplotlib.pyplot as plt
def main():
x_vec = np.arange(-10, 10, 0.01)
y_vec = np.sin(2 * 2 * np.pi * x_vec) * 1/np.sqrt(2*np.pi) * np.exp(-(x_vec**2)/2)
fig = plt.figure(figsize=(16.0, 10.0))
ax = fig.add_subplot(111)... | mit | Python | |
dd53b54fbf64a51231a35f0f87ed6b543a8666fe | add genia cache | text-machine-lab/CliNER,text-machine-lab/CliNER | clicon/features_dir/genia/genia_cache.py | clicon/features_dir/genia/genia_cache.py | import cPickle as pickle
import os
class GeniaCache:
def __init__(self):
try:
prefix = os.path.dirname(__file__)
self.filename = os.path.join( prefix, 'genia_cache' )
self.cache = pickle.load( open( self.filename , "rb" ) ) ;
except IOError:
self.cach... | apache-2.0 | Python | |
2fbec137ba9efcbfc657a469856507ea8da079e3 | Create draw_shapes_gui.py | CSavvy/python | draw_shapes_gui.py | draw_shapes_gui.py | # Import Myro library and connect to the robot
from Myro import *
init("/dev/tty.Fluke2-0216-Fluke2")
# We also need to import the graphics library!
from Graphics import *
# Print the current battery level
print("Battery level:", getBattery())
# Make a graphics window with the title below and dimensions 500x500
win ... | mit | Python | |
17146ea739f714ffe2ad2a4c6f6b65f866f3f401 | Create heuristic1.py | ahadmushir/whatsCooking | heuristic1.py | heuristic1.py | import csv
import pandas
import json
import operator
def preprocess():
trainHandle = open('train.json').read()
j = json.loads(trainHandle)
#######################################
unqCus = list()
tempInList = list()
try:
count = 0
while True:
a = j[count]['cuisine']
if a not in unqCus:
unqCus.a... | apache-2.0 | Python | |
ed03e44ec58b6f757b0e62d25ea8f2bf822c0498 | Create LongComPrefix_002.py | cc13ny/algo,cc13ny/Allin,Chasego/cod,Chasego/cod,Chasego/codi,Chasego/codi,cc13ny/Allin,Chasego/codi,cc13ny/Allin,Chasego/codirit,Chasego/cod,cc13ny/Allin,cc13ny/algo,Chasego/codi,cc13ny/algo,Chasego/cod,cc13ny/algo,cc13ny/Allin,Chasego/cod,Chasego/codirit,Chasego/codi,Chasego/codirit,Chasego/codirit,Chasego/codirit,cc... | leetcode/014-Longest-Common-Prefix/LongComPrefix_002.py | leetcode/014-Longest-Common-Prefix/LongComPrefix_002.py | #author: cchen
class Solution:
# @param {string[]} strs
# @return {string}
def longestCommonPrefix(self, strs):
res = ''
if strs == []:
return res
lens = [len(s) for s in strs]
mi = min(lens)
for i in range(mi):
a = set([s[i] for ... | mit | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.