commit stringlengths 40 40 | old_file stringlengths 4 150 | new_file stringlengths 4 150 | old_contents stringlengths 0 3.26k | new_contents stringlengths 1 4.43k | subject stringlengths 15 501 | message stringlengths 15 4.06k | lang stringclasses 4
values | license stringclasses 13
values | repos stringlengths 5 91.5k | diff stringlengths 0 4.35k |
|---|---|---|---|---|---|---|---|---|---|---|
54c26b6d7dbc26b155ace172cebb9a0ac722060b | pymatgen/symmetry/tests/test_spacegroup.py | pymatgen/symmetry/tests/test_spacegroup.py | #!/usr/bin/env python
'''
Created on Mar 12, 2012
'''
from __future__ import division
__author__="Shyue Ping Ong"
__copyright__ = "Copyright 2012, The Materials Project"
__version__ = "0.1"
__maintainer__ = "Shyue Ping Ong"
__email__ = "shyue@mit.edu"
__date__ = "Mar 12, 2012"
import unittest
import os
from pymatg... | Add a unittest for spacegroup. Still very basic. | Add a unittest for spacegroup. Still very basic.
Former-commit-id: d446365ad2622bc7871817613f98cebbefb7125f [formerly dbf71a7f4973d22259e81e095402d39acb823651]
Former-commit-id: a5817cbc15c7c0e6f568773b47b29db34200dd87 | Python | mit | gpetretto/pymatgen,tschaume/pymatgen,czhengsci/pymatgen,dongsenfo/pymatgen,matk86/pymatgen,tallakahath/pymatgen,nisse3000/pymatgen,fraricci/pymatgen,aykol/pymatgen,czhengsci/pymatgen,montoyjh/pymatgen,johnson1228/pymatgen,Bismarrck/pymatgen,gmatteo/pymatgen,ndardenne/pymatgen,richardtran415/pymatgen,gVallverdu/pymatgen... | ---
+++
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+
+'''
+Created on Mar 12, 2012
+'''
+
+from __future__ import division
+
+__author__="Shyue Ping Ong"
+__copyright__ = "Copyright 2012, The Materials Project"
+__version__ = "0.1"
+__maintainer__ = "Shyue Ping Ong"
+__email__ = "shyue@mit.edu"
+__date__ = "Mar 12, 2012... | |
800ed9afbedc83f608c7228de55fc638db79bfdc | modernrpc/tests/test_auth_helpers.py | modernrpc/tests/test_auth_helpers.py | import pytest
import pytest_django
from django.contrib.auth.models import AnonymousUser, Permission
from django.contrib.contenttypes.models import ContentType
from modernrpc.auth import user_is_logged, user_is_superuser, user_has_perm, user_has_perms
def test_user_is_logged(anonymous_user, john_doe, superuser):
... | Create new tests, for auth helpers | Create new tests, for auth helpers
| Python | mit | alorence/django-modern-rpc,alorence/django-modern-rpc | ---
+++
@@ -0,0 +1,50 @@
+import pytest
+import pytest_django
+from django.contrib.auth.models import AnonymousUser, Permission
+from django.contrib.contenttypes.models import ContentType
+
+from modernrpc.auth import user_is_logged, user_is_superuser, user_has_perm, user_has_perms
+
+
+def test_user_is_logged(anonym... | |
d2acba5a6a6d9049e46be89185c6b69803316ed2 | scripts/fcn_learning_movie.py | scripts/fcn_learning_movie.py | #!/usr/bin/env python
import argparse
import glob
import os.path as osp
import re
import subprocess
import tempfile
import scipy.misc
import fcn
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'log_dir', help='Log dir which contains log_XX.png and viz_XX.png')
args = parser.... | Add script to generate gif from images | Add script to generate gif from images
| Python | mit | wkentaro/fcn | ---
+++
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+
+import argparse
+import glob
+import os.path as osp
+import re
+import subprocess
+import tempfile
+
+import scipy.misc
+
+import fcn
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ 'log_dir', help='Log dir which contains l... | |
8825d67bd8913cafcd1ff3215a9ef145a92b18c2 | scripts/impute_names_model.py | scripts/impute_names_model.py | """
"""
from framework.auth.utils import parse_name
from website.app import init_app
from website import models
app = init_app('website.settings', set_backends=True, routes=True)
def impute_names():
for user in models.User.find():
parsed = parse_name(user.fullname)
for field, value in parsed.... | Add script to impute name parts | Add script to impute name parts
| Python | apache-2.0 | mattclark/osf.io,doublebits/osf.io,doublebits/osf.io,crcresearch/osf.io,cwisecarver/osf.io,cosenal/osf.io,cslzchen/osf.io,doublebits/osf.io,chennan47/osf.io,bdyetton/prettychart,bdyetton/prettychart,icereval/osf.io,CenterForOpenScience/osf.io,danielneis/osf.io,cosenal/osf.io,KAsante95/osf.io,icereval/osf.io,jinluyuan/o... | ---
+++
@@ -0,0 +1,23 @@
+"""
+
+"""
+
+from framework.auth.utils import parse_name
+
+from website.app import init_app
+from website import models
+
+app = init_app('website.settings', set_backends=True, routes=True)
+
+def impute_names():
+
+ for user in models.User.find():
+
+ parsed = parse_name(user.fu... | |
15a0bb09b704d4abfbf35ba693f66853c6ed030d | corehq/apps/cleanup/management/commands/republish_forms_rebuild_cases.py | corehq/apps/cleanup/management/commands/republish_forms_rebuild_cases.py | from __future__ import absolute_import, print_function, unicode_literals
import logging
from io import open
from django.core.management.base import BaseCommand
from casexml.apps.case.xform import get_case_ids_from_form
from corehq.form_processor.backends.couch.dbaccessors import FormAccessorCouch
from corehq.form_pr... | Add command to rebuild cases and republish forms | Add command to rebuild cases and republish forms
| Python | bsd-3-clause | dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq | ---
+++
@@ -0,0 +1,69 @@
+from __future__ import absolute_import, print_function, unicode_literals
+
+import logging
+from io import open
+
+from django.core.management.base import BaseCommand
+
+from casexml.apps.case.xform import get_case_ids_from_form
+from corehq.form_processor.backends.couch.dbaccessors import F... | |
5ae3bf220b08c28596729c682c44d2aa9e599f3c | TWLight/users/migrations/0063_check_terms_and_bundle_eligibility.py | TWLight/users/migrations/0063_check_terms_and_bundle_eligibility.py | from django.db import migrations
def remove_bundle_eligibility_on_users_with_unaccepted_terms(apps, schema_editor):
Editor = apps.get_model("users", "Editor")
for editor in Editor.objects.all():
# If a user has not accepted the terms of use and has bundle eligibility,
# remove the eligibility ... | Add migration to remove eligibility is terms are not accepted | Add migration to remove eligibility is terms are not accepted
| Python | mit | WikipediaLibrary/TWLight,WikipediaLibrary/TWLight,WikipediaLibrary/TWLight,WikipediaLibrary/TWLight,WikipediaLibrary/TWLight | ---
+++
@@ -0,0 +1,20 @@
+from django.db import migrations
+
+
+def remove_bundle_eligibility_on_users_with_unaccepted_terms(apps, schema_editor):
+ Editor = apps.get_model("users", "Editor")
+ for editor in Editor.objects.all():
+ # If a user has not accepted the terms of use and has bundle eligibility,... | |
65c97b3ccdafb3df3d3328901541729c553f06df | bump-version.py | bump-version.py | """Bump the version of this project:
Look for likely files: setup.py, doc/conf.py, etc. and update
version strings to whatever's passed in. At present, no check
is made for sanity purposes.
"""
import os, sys
import re
patterns = [
("winshell.py", r'__VERSION__ = "[^"]+"', '__VERSION__ = "%s"'),
("docs/conf.py", ... | Add a way to bump the version number consistently | Add a way to bump the version number consistently
| Python | mit | tjguk/winshell,tjguk/winshell,tjguk/winshell | ---
+++
@@ -0,0 +1,30 @@
+"""Bump the version of this project:
+
+Look for likely files: setup.py, doc/conf.py, etc. and update
+version strings to whatever's passed in. At present, no check
+is made for sanity purposes.
+"""
+import os, sys
+import re
+
+patterns = [
+ ("winshell.py", r'__VERSION__ = "[^"]+"', '__V... | |
9bf713321f309a7652e53015aa9de4671593de74 | puzzles/shared_count.py | puzzles/shared_count.py |
from threading import Thread, Semaphore
import time
# shared count value
count = 0
def thread_finished(current_count=None):
print "count:", current_count
class Incrementer(object):
def __init__(self, mutex):
self.mutex = mutex
def run(self):
global count
self.mutex.acquire(... | Add shared count incrementer puzzle | Add shared count incrementer puzzle
| Python | mit | emre/semaphores | ---
+++
@@ -0,0 +1,44 @@
+
+
+from threading import Thread, Semaphore
+
+import time
+
+# shared count value
+count = 0
+
+def thread_finished(current_count=None):
+ print "count:", current_count
+
+
+class Incrementer(object):
+
+ def __init__(self, mutex):
+ self.mutex = mutex
+
+ def run(self):
+ ... | |
84474c08451825a6632e6c8e9c1b60702dab0ad3 | urbanTwitBot.py | urbanTwitBot.py | #!/usr/bin/env python
from bs4 import BeautifulSoup
import requests
import tweepy
from config import *
url = 'http://www.urbandictionary.com/'
page = requests.get(url)
soup = BeautifulSoup(page.text, "lxml")
data = dict()
data['def'] = soup(class_ = 'meaning')[0].text
data['word'] = soup(class_ = 'word')[0].text
word ... | Add twitbot for urban dictionary | Add twitbot for urban dictionary
| Python | unlicense | r3dact3d/tweeter | ---
+++
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+from bs4 import BeautifulSoup
+import requests
+import tweepy
+from config import *
+
+url = 'http://www.urbandictionary.com/'
+page = requests.get(url)
+soup = BeautifulSoup(page.text, "lxml")
+data = dict()
+data['def'] = soup(class_ = 'meaning')[0].text
+data['word'... | |
225249f5e677e155da036bb86b157707b9c8ba3d | corehq/apps/userreports/management/commands/count_ucrs.py | corehq/apps/userreports/management/commands/count_ucrs.py | from __future__ import absolute_import
from __future__ import print_function
import textwrap
from datetime import datetime
from django.conf import settings
from django.core.management import BaseCommand
from dimagi.utils.couch.database import iter_docs
from corehq.dbaccessors.couchapps.all_docs import get_doc_ids_by... | Add command to count UCRs on an environment | Add command to count UCRs on an environment
This is something we pull ~annually. It's simple enough to write, but
hopefully this'll give some confidence that we're pulling the same thing
every time.
| Python | bsd-3-clause | dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq | ---
+++
@@ -0,0 +1,36 @@
+from __future__ import absolute_import
+from __future__ import print_function
+
+import textwrap
+from datetime import datetime
+
+from django.conf import settings
+from django.core.management import BaseCommand
+
+from dimagi.utils.couch.database import iter_docs
+from corehq.dbaccessors.co... | |
2eeab9e35badba0c271b1d1671f08347a5c5e06e | penchy/tests/test_elements.py | penchy/tests/test_elements.py | import unittest2
from penchy.tests.util import MockPipelineElement
class PipelineElementHookTest(unittest2.TestCase):
def setUp(self):
self.e = MockPipelineElement()
self.list_ = [23, 42, 5]
def test_pre_hooks(self):
self.e.prehooks = [
lambda: self.list_.__setitem__(0, 1... | Add test for PipelineElement hooks. | tests: Add test for PipelineElement hooks.
Signed-off-by: Michael Markert <5eb998b7ac86da375651a4cd767b88c9dad25896@googlemail.com>
| Python | mit | fhirschmann/penchy,fhirschmann/penchy | ---
+++
@@ -0,0 +1,29 @@
+import unittest2
+
+from penchy.tests.util import MockPipelineElement
+
+
+class PipelineElementHookTest(unittest2.TestCase):
+ def setUp(self):
+ self.e = MockPipelineElement()
+ self.list_ = [23, 42, 5]
+
+ def test_pre_hooks(self):
+ self.e.prehooks = [
+ ... | |
a7a887706c30afb861d0db2e00297e3f918c0f22 | euler009.py | euler009.py | #!/usr/bin/python
"""
First attempt to resolve this, with a brute force algorithm,
it may not find the answer
"""
from math import sqrt
TARGET = 1000
LIMIT = int(sqrt(TARGET))
a, b, c = 0, 0, 0
m = 1
while(a + b + c != TARGET and m < LIMIT):
m += 1
a, b, c = 0, 0, 0
n = 1
while(a + b + c < TARGET and... | Add solution for problem 9 | Add solution for problem 9
| Python | mit | cifvts/PyEuler | ---
+++
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+
+"""
+First attempt to resolve this, with a brute force algorithm,
+it may not find the answer
+"""
+
+from math import sqrt
+
+TARGET = 1000
+LIMIT = int(sqrt(TARGET))
+a, b, c = 0, 0, 0
+m = 1
+while(a + b + c != TARGET and m < LIMIT):
+ m += 1
+ a, b, c = 0, 0, 0... | |
9b4f05df901c0e44cfdda2b4753253e0a263b03a | contrib/scrape-azure-prices.py | contrib/scrape-azure-prices.py | import json
import time
import os
import requests
PRICES_URL = ("https://azure.microsoft.com/api/v3/pricing/"
"virtual-machines/calculator/")
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
PRICING_FILE_PATH = os.path.join(BASE_PATH, '../libcloud/data/pricing.json')
PRICING_FILE_PATH = os.path.ab... | Add new file for price scraping for azure arm cloud | Add new file for price scraping for azure arm cloud
| Python | apache-2.0 | Kami/libcloud,andrewsomething/libcloud,mistio/libcloud,mistio/libcloud,Kami/libcloud,andrewsomething/libcloud,mistio/libcloud,apache/libcloud,apache/libcloud,andrewsomething/libcloud,apache/libcloud,Kami/libcloud | ---
+++
@@ -0,0 +1,70 @@
+import json
+import time
+import os
+import requests
+
+
+PRICES_URL = ("https://azure.microsoft.com/api/v3/pricing/"
+ "virtual-machines/calculator/")
+BASE_PATH = os.path.dirname(os.path.abspath(__file__))
+PRICING_FILE_PATH = os.path.join(BASE_PATH, '../libcloud/data/pricing.... | |
7a5c284505dfb0b94d2bc9a1f2bc264cbffa5d83 | tests/app/soc/views/models/test_sponsor.py | tests/app/soc/views/models/test_sponsor.py | #!/usr/bin/env python2.5
#
# Copyright 2010 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... | Add test for the sponsor views | Add test for the sponsor views
| Python | apache-2.0 | SRabbelier/Melange,SRabbelier/Melange,SRabbelier/Melange,SRabbelier/Melange,SRabbelier/Melange,SRabbelier/Melange,SRabbelier/Melange,SRabbelier/Melange,SRabbelier/Melange | ---
+++
@@ -0,0 +1,35 @@
+#!/usr/bin/env python2.5
+#
+# Copyright 2010 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/LICEN... | |
68f4a9f7393a1f29841463c9b6b7d6bec9a00d6b | namuhub/__init__.py | namuhub/__init__.py | """namuhub --- namu.wiki contribution graph"""
from flask import Flask, jsonify, render_template, request, url_for
app = Flask('namuhub')
@app.route('/', methods=['GET'])
def index():
return render_template('index.html')
@app.route('/<user>', methods=['GET'])
def index_user(user=''):
return render_template('... | """namuhub --- namu.wiki contribution graph"""
from flask import Flask, jsonify, render_template, request, url_for
app = Flask('namuhub')
@app.route('/', methods=['GET'])
def index():
return render_template('index.html')
@app.route('/<user>', methods=['GET'])
def index_user(user=''):
return render_template('... | Return http status code 501 when a malformed message is received | Return http status code 501 when a malformed message is received
| Python | apache-2.0 | ssut/namuhub,ssut/namuhub,ssut/namuhub | ---
+++
@@ -11,4 +11,9 @@
def index_user(user=''):
return render_template('index.html', **{'user': user})
+@app.route('/', methods=['POST'])
+def namu():
+ user = request.POST.get('user', None)
+ if not user:
+ return '', 501
|
56bd6c6a0363323cc1f4b3fbbcd460ba446b0c6d | cubes/stores.py | cubes/stores.py | from .errors import *
from .browser import AggregationBrowser
from .extensions import get_namespace, initialize_namespace
__all__ = (
"open_store",
"Store"
)
def open_store(name, **options):
"""Gets a new instance of a model provider with name `name`."""
ns = get_namespace("s... | from .errors import *
from .browser import AggregationBrowser
from .extensions import get_namespace, initialize_namespace
__all__ = (
"open_store",
"Store"
)
def open_store(name, **options):
"""Gets a new instance of a model provider with name `name`."""
ns = get_namespace("s... | Raise ConfigurationError error that causes server to fail and dump whole stacktrace | Raise ConfigurationError error that causes server to fail and dump whole stacktrace
| Python | mit | noyeitan/cubes,ubreddy/cubes,she11c0de/cubes,zejn/cubes,zejn/cubes,pombredanne/cubes,she11c0de/cubes,pombredanne/cubes,ubreddy/cubes,jell0720/cubes,cesarmarinhorj/cubes,noyeitan/cubes,ubreddy/cubes,cesarmarinhorj/cubes,cesarmarinhorj/cubes,zejn/cubes,jell0720/cubes,noyeitan/cubes,pombredanne/cubes,jell0720/cubes,she11c... | ---
+++
@@ -19,7 +19,7 @@
try:
factory = ns[name]
except KeyError:
- raise CubesError("Unable to find store '%s'" % name)
+ raise ConfigurationError("Unknown store '%s'" % name)
return factory(**options)
@@ -35,7 +35,7 @@
try:
factory = ns[type_]
except Key... |
3da5a4dd70b50b7988d0023087a9d73274f273ba | tests/test_smartypants.py | tests/test_smartypants.py | # -*- coding: utf-8 -*-
# This file is part of python-markups test suite
# License: BSD
# Copyright: (C) Dmitry Shachnev, 2012
from markups.common import educate as ed
import unittest
class SmartyTest(unittest.TestCase):
def test_quotes(self):
self.assertEqual(ed('"Isn\'t this fun?"'), '“Isn’t this fun?”')
self... | Add (currently failing) smartypants test | Add (currently failing) smartypants test
| Python | bsd-3-clause | mitya57/pymarkups,retext-project/pymarkups | ---
+++
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+
+# This file is part of python-markups test suite
+# License: BSD
+# Copyright: (C) Dmitry Shachnev, 2012
+
+from markups.common import educate as ed
+import unittest
+
+class SmartyTest(unittest.TestCase):
+ def test_quotes(self):
+ self.assertEqual(ed('"Isn\'t th... | |
7c94fd2484e5ba3528b44e0e38271c6f6126de1b | src/framematcher.py | src/framematcher.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Match Frame to appropriate VerbNet structures"""
from framestructure import *
import unittest
class EmptyFrameError(Exception):
"""Trying to use an empty frame in a match
:var frame1: VerbnetFrame, first frame
:var frame2: VerbnetFrame, second frame
... | Add a module to handle frame matching | Add a module to handle frame matching
git-svn-id: a2d0af3c19596d99b5c1e07a0b4fed4eaca14ddf@18208 7fff26f0-e11d-0410-b8d0-f4b6ff9b0dc5
| Python | agpl-3.0 | aymara/knowledgesrl,aymara/knowledgesrl | ---
+++
@@ -0,0 +1,88 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+"""Match Frame to appropriate VerbNet structures"""
+
+from framestructure import *
+import unittest
+
+class EmptyFrameError(Exception):
+ """Trying to use an empty frame in a match
+
+ :var frame1: VerbnetFrame, first frame
+ ... | |
5746ee3a5c07ea58631db85d43f103992d9e1e38 | mdot_rest/migrations/0001_initial.py | mdot_rest/migrations/0001_initial.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='ResourceLink',
fields=[
('id', models.AutoField... | Add the migration for initial model. | Add the migration for initial model.
| Python | apache-2.0 | uw-it-aca/mdot-rest,uw-it-aca/mdot-rest | ---
+++
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='ResourceLink',
+ fields... | |
f6c10e4a70e6fa91bf5abf63c50bc3ec9c3ac90c | scenarios/update_user_replace.py | scenarios/update_user_replace.py | c_uuid = None
def store_c_uuid():
global c_uuid
c_uuid = next(iter(reality.resources_by_logical_name('C')))
def check_c_replaced():
test.assertNotEqual(c_uuid,
next(iter(reality.resources_by_logical_name('newC'))))
test.assertIsNot(c_uuid, None)
example_template = Template({
... | Add a test for when the user renames a resource | Add a test for when the user renames a resource
| Python | apache-2.0 | zaneb/heat-convergence-prototype | ---
+++
@@ -0,0 +1,51 @@
+c_uuid = None
+
+def store_c_uuid():
+ global c_uuid
+ c_uuid = next(iter(reality.resources_by_logical_name('C')))
+
+def check_c_replaced():
+ test.assertNotEqual(c_uuid,
+ next(iter(reality.resources_by_logical_name('newC'))))
+ test.assertIsNot(c_uuid, N... | |
48d9c31c80efc1bccc3ef66df2262323c626198a | Home/xsOros.py | Home/xsOros.py | def checkio(array):
if array[0][0] == array[0][1] == array[0][2] or array[0][0] == array[1][0] == array[2][0] or array[0][0] == array[1][1] == array[2][2]:
return array[0][0]
if array[1][0] == array[1][1] == array[1][2] or array[0][1] == array[1][1] == array[2][1] or array[2][0] == array[1][1] == array[... | Solve "Xs or Os Referee" problem | Solve "Xs or Os Referee" problem
| Python | mit | edwardzhu/checkio-solution | ---
+++
@@ -0,0 +1,22 @@
+def checkio(array):
+ if array[0][0] == array[0][1] == array[0][2] or array[0][0] == array[1][0] == array[2][0] or array[0][0] == array[1][1] == array[2][2]:
+ return array[0][0]
+ if array[1][0] == array[1][1] == array[1][2] or array[0][1] == array[1][1] == array[2][1] or array... | |
032a4a545a8b07b2cc96482dfee557b013b132eb | build_index.py | build_index.py | #!/usr/bin/env python
import glob
import os
import sys
sys.path.insert(0, 'publisher')
import options
output_dir = 'output'
dirs = [d for d in glob.glob('%s/*' % output_dir) if os.path.isdir(d)]
pages = []
cum_pages = [1]
for d in sorted(dirs):
try:
stats = options.cfg2dict(os.path.join(d, 'paper_stat... | Add script that generates page numbers. | Add script that generates page numbers.
| Python | bsd-2-clause | sbenthall/scipy_proceedings,katyhuff/scipy_proceedings,mikaem/euroscipy_proceedings,michaelpacer/scipy_proceedings,mjklemm/euroscipy_proceedings,mikaem/euroscipy_proceedings,michaelpacer/scipy_proceedings,SepidehAlassi/euroscipy_proceedings,michaelpacer/scipy_proceedings,SepidehAlassi/euroscipy_proceedings,euroscipy/eu... | ---
+++
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+import glob
+import os
+import sys
+
+sys.path.insert(0, 'publisher')
+
+import options
+
+output_dir = 'output'
+dirs = [d for d in glob.glob('%s/*' % output_dir) if os.path.isdir(d)]
+
+pages = []
+cum_pages = [1]
+
+for d in sorted(dirs):
+ try:
+ stats ... | |
07271f2edc56a7a01913eb6dd2aa27dcd4cb84ec | scripts/client_credentials.py | scripts/client_credentials.py | """
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this ... | Add in demo script to get client credentials. | Add in demo script to get client credentials.
| Python | apache-2.0 | blorenz/vimeo.py,gabrielgisoldo/vimeo.py,greedo/vimeo.py,vimeo/vimeo.py | ---
+++
@@ -0,0 +1,63 @@
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
... | |
1122b162965201ee860ced829e6d9352da2d1e7f | handle_exception.py | handle_exception.py | """ Be DRY (don't repeat yourself), use exception handler function for try-except """
def handle_exception(func):
def inner(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as error:
print('[ERROR] {}'.format(error))
exit(1)
return inner
... | Use exception handler function for try-except | Use exception handler function for try-except
| Python | mit | foobar167/junkyard,foobar167/junkyard,foobar167/junkyard,foobar167/junkyard,foobar167/junkyard,foobar167/junkyard | ---
+++
@@ -0,0 +1,23 @@
+""" Be DRY (don't repeat yourself), use exception handler function for try-except """
+
+def handle_exception(func):
+ def inner(*args, **kwargs):
+ try:
+ return func(*args, **kwargs)
+ except Exception as error:
+ print('[ERROR] {}'.format(error))
+ ... | |
915b13a3940ec2bcde6784b30a97a44929ab3a02 | docker-nodev.py | docker-nodev.py |
from __future__ import print_function
import subprocess
import sys
DOCKER_CREATE_IN = 'docker create -it nodev {}'
DOCKER_SIMPLE_CMD_IN = 'docker {} {container_id}'
def nodev(argv=()):
container_id = subprocess.check_output(DOCKER_CREATE_IN.format(' '.join(argv)), shell=True).strip()
print('creating conta... | Make the script work on python 2 and print actions. | Make the script work on python 2 and print actions.
| Python | mit | nodev-io/nodev-starter-kit,nodev-io/nodev-starter-kit,nodev-io/nodev-tutorial | ---
+++
@@ -0,0 +1,24 @@
+
+from __future__ import print_function
+
+import subprocess
+import sys
+
+
+DOCKER_CREATE_IN = 'docker create -it nodev {}'
+DOCKER_SIMPLE_CMD_IN = 'docker {} {container_id}'
+
+
+def nodev(argv=()):
+ container_id = subprocess.check_output(DOCKER_CREATE_IN.format(' '.join(argv)), shell... | |
5be2c671197ac8e0192341e1cd3a3cdaabe23353 | corehq/apps/commtrack/management/commands/check_multiple_parentage.py | corehq/apps/commtrack/management/commands/check_multiple_parentage.py | from django.core.management.base import BaseCommand
from corehq.apps.domain.models import Domain
class Command(BaseCommand):
def handle(self, *args, **options):
self.stdout.write("Populating site codes...\n")
domains = Domain.get_all()
for d in domains:
if d.commtrack_enabled... | Add management command to check for multiple parent types | Add management command to check for multiple parent types
| Python | bsd-3-clause | dimagi/commcare-hq,SEL-Columbia/commcare-hq,SEL-Columbia/commcare-hq,qedsoftware/commcare-hq,puttarajubr/commcare-hq,SEL-Columbia/commcare-hq,qedsoftware/commcare-hq,puttarajubr/commcare-hq,qedsoftware/commcare-hq,qedsoftware/commcare-hq,puttarajubr/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,q... | ---
+++
@@ -0,0 +1,18 @@
+from django.core.management.base import BaseCommand
+from corehq.apps.domain.models import Domain
+
+
+class Command(BaseCommand):
+ def handle(self, *args, **options):
+ self.stdout.write("Populating site codes...\n")
+
+ domains = Domain.get_all()
+
+ for d in domai... | |
f9637bba0068b078728824d76cadf2f0c11d7c06 | hbase-tables/load_binary.py | hbase-tables/load_binary.py | ##
## Insert various data into HBase
##
## cd $HUE_HOME (e.g. cd /usr/share/hue(/opt/cloudera/parcels/CDH-XXXXX/share/hue if using parcels))
## build/env/bin/hue shell
##
from hbase.api import HbaseApi
HbaseApi().putRow('Cluster', 'events', 'hue-20130801', {'doc:txt': 'Hue is awesome!'})
HbaseApi().putRow('Cluster',... | Load binary data into HBase | [hbase] Load binary data into HBase
| Python | apache-2.0 | romainr/hadoop-tutorials-examples,skale1990/hadoop-tutorials-examples,skale1990/hadoop-tutorials-examples,skale1990/hadoop-tutorials-examples,romainr/hadoop-tutorials-examples,skale1990/hadoop-tutorials-examples,romainr/hadoop-tutorials-examples,skale1990/hadoop-tutorials-examples,romainr/hadoop-tutorials-examples,roma... | ---
+++
@@ -0,0 +1,26 @@
+##
+## Insert various data into HBase
+##
+
+## cd $HUE_HOME (e.g. cd /usr/share/hue(/opt/cloudera/parcels/CDH-XXXXX/share/hue if using parcels))
+## build/env/bin/hue shell
+##
+
+from hbase.api import HbaseApi
+
+HbaseApi().putRow('Cluster', 'events', 'hue-20130801', {'doc:txt': 'Hue is aw... | |
ee68ac19f7417a16f4250486a064bfc8a8f37e47 | wafer/talks/migrations/0011_talk_status_data_migration.py | wafer/talks/migrations/0011_talk_status_data_migration.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
# Data migration for the changed talk status
def change_pending(apps, schema_editor):
# Change Pending (P) status to
# (S) Submitted
# Use apps to ensure we have the correct version
Talk = apps.g... | Add data migration to update already existing talk states | Add data migration to update already existing talk states
| Python | isc | CTPUG/wafer,CTPUG/wafer,CTPUG/wafer,CTPUG/wafer | ---
+++
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+# Data migration for the changed talk status
+
+def change_pending(apps, schema_editor):
+ # Change Pending (P) status to
+ # (S) Submitted
+ # Use apps to ensure we hav... | |
2c118ab3a6b516fae87280dac69cb9c5d7caa5a9 | spacy/tests/doc/test_creation.py | spacy/tests/doc/test_creation.py | '''Test Doc sets up tokens correctly.'''
from __future__ import unicode_literals
import pytest
from ...vocab import Vocab
from ...tokens.doc import Doc
from ...lemmatizerlookup import Lemmatizer
@pytest.fixture
def lemmatizer():
return Lemmatizer({'dogs': 'dog', 'boxen': 'box', 'mice': 'mouse'})
@pytest.fixtur... | Add tests for Doc creation | Add tests for Doc creation
| Python | mit | recognai/spaCy,aikramer2/spaCy,honnibal/spaCy,honnibal/spaCy,spacy-io/spaCy,explosion/spaCy,spacy-io/spaCy,honnibal/spaCy,recognai/spaCy,spacy-io/spaCy,explosion/spaCy,spacy-io/spaCy,aikramer2/spaCy,explosion/spaCy,honnibal/spaCy,recognai/spaCy,recognai/spaCy,explosion/spaCy,spacy-io/spaCy,aikramer2/spaCy,spacy-io/spaC... | ---
+++
@@ -0,0 +1,37 @@
+'''Test Doc sets up tokens correctly.'''
+from __future__ import unicode_literals
+import pytest
+
+from ...vocab import Vocab
+from ...tokens.doc import Doc
+from ...lemmatizerlookup import Lemmatizer
+
+
+@pytest.fixture
+def lemmatizer():
+ return Lemmatizer({'dogs': 'dog', 'boxen': 'b... | |
5e7838d013dad41e4508e3736d3f2b401b1a0156 | cli/command.py | cli/command.py | """
In this module we define the interface between the cli input provided
by the user and the analytics required by the user
"""
def cmd_list_basic(args):
"""
List the basic analytics commands and their summary
"""
pass
def cmd_list_all(args):
"""
List all the analytics commands and their summary
"""
pass
... | Define interface between cli and data analysis | Define interface between cli and data analysis | Python | mit | McGillX/edx_data_research,McGillX/edx_data_research,McGillX/edx_data_research | ---
+++
@@ -0,0 +1,22 @@
+"""
+In this module we define the interface between the cli input provided
+by the user and the analytics required by the user
+"""
+
+def cmd_list_basic(args):
+ """
+ List the basic analytics commands and their summary
+ """
+ pass
+
+def cmd_list_all(args):
+ """
+ List all the analytics... | |
87c4a770b717fdfca819ce387163b0282a839ada | pombola/south_africa/management/commands/south_africa_sync_wikidata_ids_from_everypolitician.py | pombola/south_africa/management/commands/south_africa_sync_wikidata_ids_from_everypolitician.py | from everypolitician import EveryPolitician
from django.core.management.base import BaseCommand
from pombola.core.models import Person
class Command(BaseCommand):
help = "Sync Wikidata IDs from Everypolitician to Person's identifiers array"
def add_arguments(self, parser):
parser.add_argument('ever... | Add script to import Wikidata IDs from EveryPolitician | Add script to import Wikidata IDs from EveryPolitician
| Python | agpl-3.0 | mysociety/pombola,mysociety/pombola,mysociety/pombola,mysociety/pombola,mysociety/pombola,mysociety/pombola | ---
+++
@@ -0,0 +1,46 @@
+from everypolitician import EveryPolitician
+
+from django.core.management.base import BaseCommand
+
+from pombola.core.models import Person
+
+
+class Command(BaseCommand):
+ help = "Sync Wikidata IDs from Everypolitician to Person's identifiers array"
+
+ def add_arguments(self, pars... | |
733d1e49a68217b81654d3955e0066c590fe988d | toolkit/util/management/commands/delete_non_members_who_dont_get_the_mailout.py | toolkit/util/management/commands/delete_non_members_who_dont_get_the_mailout.py | # https://docs.djangoproject.com/en/1.11/howto/custom-management-commands/
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
from toolkit.members.models import Member
class Command(BaseCommand):
help = "Delete non-members who don't get the members mailout"
d... | Add manage.py utility to delete non members who dont get the mailout | Add manage.py utility to delete non members who dont get the mailout
| Python | agpl-3.0 | BenMotz/cubetoolkit,BenMotz/cubetoolkit,BenMotz/cubetoolkit,BenMotz/cubetoolkit | ---
+++
@@ -0,0 +1,32 @@
+# https://docs.djangoproject.com/en/1.11/howto/custom-management-commands/
+
+from django.core.management.base import BaseCommand, CommandError
+from django.conf import settings
+
+from toolkit.members.models import Member
+
+
+class Command(BaseCommand):
+ help = "Delete non-members who ... | |
d8ac6c5d9f4bf39eec590cd1f1b0d477a96318df | correct_ocr.py | correct_ocr.py | import glob
from count_labels import load_data
from collections import Counter
from bs4 import BeautifulSoup
import codecs
from fuzzywuzzy import process
# create word list
words = Counter()
data_dir = '/home/jvdzwaan/data/embem/txt/corpus_annotation/'
files = glob.glob('{}*.txt'.format(data_dir))
for i, file_ in e... | Add test script to replace ocr mistakes | Add test script to replace ocr mistakes
Added a script that finds matches for ocr mistakes using the fuzzywuzzy
library (based on Levenstein distance) and a list of words in the
annotated texts. It seems only more noise is introduced.
| Python | apache-2.0 | NLeSC/embodied-emotions-scripts,NLeSC/embodied-emotions-scripts | ---
+++
@@ -0,0 +1,35 @@
+import glob
+from count_labels import load_data
+from collections import Counter
+from bs4 import BeautifulSoup
+import codecs
+from fuzzywuzzy import process
+
+
+# create word list
+words = Counter()
+
+data_dir = '/home/jvdzwaan/data/embem/txt/corpus_annotation/'
+
+files = glob.glob('{}*... | |
c69166d98df2f7bebb3de629eb00328a5ef699d3 | poradnia/keys/migrations/0003_auto_20150721_0232.py | poradnia/keys/migrations/0003_auto_20150721_0232.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('keys', '0002_auto_20150710_2133'),
]
operations = [
migrations.AlterUniqueTogether(
name='key',
uniq... | Add unique to keys.AcccessKey.password per user | Add unique to keys.AcccessKey.password per user
| Python | mit | watchdogpolska/poradnia,rwakulszowa/poradnia,watchdogpolska/poradnia.siecobywatelska.pl,watchdogpolska/poradnia.siecobywatelska.pl,watchdogpolska/poradnia.siecobywatelska.pl,watchdogpolska/poradnia,watchdogpolska/poradnia,watchdogpolska/poradnia,rwakulszowa/poradnia,rwakulszowa/poradnia,rwakulszowa/poradnia | ---
+++
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('keys', '0002_auto_20150710_2133'),
+ ]
+
+ operations = [
+ migrations.AlterUniqueTogether(... | |
16a7185447e28312d5e316b92b7d3d37cb25b079 | contrib/svn-fe/svnrdump_sim.py | contrib/svn-fe/svnrdump_sim.py | #!/usr/bin/python
"""
Simulates svnrdump by replaying an existing dump from a file, taking care
of the specified revision range.
To simulate incremental imports the environment variable SVNRMAX can be set
to the highest revision that should be available.
"""
import sys, os
def getrevlimit():
var = 'SVNRMAX'
... | Add a svnrdump-simulator replaying a dump file for testing | Add a svnrdump-simulator replaying a dump file for testing
To ease testing without depending on a reachable svn server, this
compact python script mimics parts of svnrdumps behaviour. It
requires the remote url to start with sim://.
Start and end revisions are evaluated. If the requested revision
doesn't exist, as ... | Python | mit | destenson/git,destenson/git,destenson/git,destenson/git,destenson/git,destenson/git,destenson/git,destenson/git | ---
+++
@@ -0,0 +1,53 @@
+#!/usr/bin/python
+"""
+Simulates svnrdump by replaying an existing dump from a file, taking care
+of the specified revision range.
+To simulate incremental imports the environment variable SVNRMAX can be set
+to the highest revision that should be available.
+"""
+import sys, os
+
+
+def ge... | |
2861531067e6aa8d0f25a9808d38b607b69f427f | utilities/unicode_to_ascii.py | utilities/unicode_to_ascii.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Unicode to ASCII Utility
========================
"""
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import codecs
import os
import unicodedata
__copyright__ = 'Copyright (C) 2013-2018 - Colour Developers'
__license__ = 'New BSD License - http://opensource.or... | Convert unicode characters to ASCII using Canonical Decomposition (NFD). | Convert unicode characters to ASCII using Canonical Decomposition (NFD).
| Python | bsd-3-clause | colour-science/colour-hdri | ---
+++
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+Unicode to ASCII Utility
+========================
+"""
+
+import sys
+reload(sys)
+sys.setdefaultencoding('utf-8')
+
+import codecs
+import os
+import unicodedata
+
+__copyright__ = 'Copyright (C) 2013-2018 - Colour Developers'
+__license... | |
1b38f4f7bf3e485c319626ee631a391271cb4ec3 | examples/imagenet/compute_mean.py | examples/imagenet/compute_mean.py | #!/usr/bin/env python
import argparse
import sys
import cv2
import numpy
import six.moves.cPickle as pickle
parser = argparse.ArgumentParser(description='Compute images mean array')
parser.add_argument('dataset', help='Path to training image-label list file')
parser.add_argument('--output', '-o', default='mean.npy',
... | #!/usr/bin/env python
import argparse
import sys
import cv2
import numpy
import six.moves.cPickle as pickle
parser = argparse.ArgumentParser(description='Compute images mean array')
parser.add_argument('dataset', help='Path to training image-label list file')
parser.add_argument('--output', '-o', default='mean.npy',... | Add one more empty line to end of import to adjust to H306 | Add one more empty line to end of import to adjust to H306
| Python | mit | sinhrks/chainer,kikusu/chainer,ktnyt/chainer,hvy/chainer,muupan/chainer,laysakura/chainer,jnishi/chainer,1986ks/chainer,ktnyt/chainer,okuta/chainer,AlpacaDB/chainer,wkentaro/chainer,cupy/cupy,ysekky/chainer,keisuke-umezawa/chainer,cemoody/chainer,umitanuki/chainer,delta2323/chainer,chainer/chainer,kashif/chainer,jnishi... | ---
+++
@@ -5,6 +5,7 @@
import cv2
import numpy
import six.moves.cPickle as pickle
+
parser = argparse.ArgumentParser(description='Compute images mean array')
parser.add_argument('dataset', help='Path to training image-label list file') |
d3ac6ba3ecd754f6f996eaa9107ea1d28074e4a3 | src/python/tests/generators/transaction_generators/test_customer_transaction_parameters_generator.py | src/python/tests/generators/transaction_generators/test_customer_transaction_parameters_generator.py | import unittest
import simulation_parameters as sim_param
from generators.transaction_generator.customer_transaction_parameters_generator import CustomerTransactionParameters
from generators.transaction_generator.customer_transaction_parameters_generator import CustomerTransactionParametersGenerator
class TestCustom... | Add unit tests for customer transaction parameters generator.py | Add unit tests for customer transaction parameters generator.py
| Python | apache-2.0 | rnowling/bigpetstore-data-generator,rnowling/bigpetstore-data-generator,rnowling/bigpetstore-data-generator | ---
+++
@@ -0,0 +1,25 @@
+import unittest
+
+import simulation_parameters as sim_param
+
+from generators.transaction_generator.customer_transaction_parameters_generator import CustomerTransactionParameters
+from generators.transaction_generator.customer_transaction_parameters_generator import CustomerTransactionPara... | |
3b0ed9b42b23a18ead0f07f221cafe89f9c8463e | tools/refract-filter.py | tools/refract-filter.py | #!/usr/bin/env python
from __future__ import print_function
import argparse
import sys
import json
import textwrap
from collections import OrderedDict
try:
import yaml
except ImportError:
yaml = None
VERSION = "0.1"
def yaml_load(stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict):
class OrderedL... | Add tool for json and JSONschema pretty printing | Add tool for json and JSONschema pretty printing
| Python | mit | apiaryio/drafter,apiaryio/drafter,apiaryio/drafter,apiaryio/drafter,apiaryio/drafter | ---
+++
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+import argparse
+import sys
+import json
+import textwrap
+from collections import OrderedDict
+try:
+ import yaml
+except ImportError:
+ yaml = None
+
+VERSION = "0.1"
+
+
+def yaml_load(stream, Loader=yaml.Loader, object... | |
5a80583cdfb6f43cc31333eafcb544b7c7b49f08 | tools/subset_symbols.py | tools/subset_symbols.py | #!/usr/bin/python
#
# Copyright 2014 Google Inc. 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... | Add tool for subsetting symbols. | Add tool for subsetting symbols.
git-svn-id: ed1ad396822b1b6daf934b380f36d983ac38e44f@276 37e447bf-a746-2f79-0798-35135ca55e94
| Python | apache-2.0 | googlefonts/nototools,namemealrady/nototools,googlefonts/nototools,googlei18n/nototools,googlefonts/nototools,namemealrady/nototools,pathumego/nototools,pathumego/nototools,davelab6/nototools,dougfelt/nototools,dougfelt/nototools,davelab6/nototools,googlei18n/nototools,pahans/nototools,moyogo/nototools,moyogo/nototools... | ---
+++
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+#
+# Copyright 2014 Google Inc. 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/license... | |
d547eaef2b81d1a66eeae6a135059ef98aee7713 | tools/version_update.py | tools/version_update.py | import sys
from xml.dom.minidom import parse
pom = open("pom.xml")
dom = parse(pom)
pom.close()
mv = dom.getElementsByTagName('motech.version')
mv[0].childNodes[0].data = sys.argv[1]
f = open("pom.xml", 'w')
dom.writexml(f)
f.close()
| Add a small script to update motech-version in the pom | Add a small script to update motech-version in the pom
Change-Id: I15f828394346dd8260e1f1c2e899a6adf6c27d5d
| Python | bsd-3-clause | wstrzelczyk/modules,pgesek/modules,sebbrudzinski/modules,pgesek/modules,ngraczewski/modules,pmuchowski/modules,tstalka/modules,atish160384/modules,ScottKimball/modules,LukSkarDev/modules,justin-hayes/modules,ngraczewski/modules,martokarski/modules,tstalka/modules,justin-hayes/modules,atish160384/modules,frankhuster/mod... | ---
+++
@@ -0,0 +1,12 @@
+import sys
+from xml.dom.minidom import parse
+
+pom = open("pom.xml")
+dom = parse(pom)
+pom.close()
+mv = dom.getElementsByTagName('motech.version')
+mv[0].childNodes[0].data = sys.argv[1]
+
+f = open("pom.xml", 'w')
+dom.writexml(f)
+f.close() | |
7671e3dfe93853f318cec953dcdbd0fbb2584912 | Utilities/make_vm.py | Utilities/make_vm.py | """
Generate the enum code for the VM header file.
"""
def getmin(k):
if ((k & 0x8000) != 0):
return (k & 0x7fff)
else:
return (k >> 8)
def getmax(k):
if ((k & 0x8000) != 0):
return (k & 0x7fff)
elif ((k & 0x80) == 0):
return (k & 0xff)
else:
return -1;
def... | Add the utility script that generated vtkDICOMVM.h | Add the utility script that generated vtkDICOMVM.h
| Python | bsd-3-clause | dgobbi/vtk-dicom,hendradarwin/vtk-dicom,dgobbi/vtk-dicom,hendradarwin/vtk-dicom,hendradarwin/vtk-dicom,dgobbi/vtk-dicom | ---
+++
@@ -0,0 +1,67 @@
+"""
+Generate the enum code for the VM header file.
+"""
+
+def getmin(k):
+ if ((k & 0x8000) != 0):
+ return (k & 0x7fff)
+ else:
+ return (k >> 8)
+
+def getmax(k):
+ if ((k & 0x8000) != 0):
+ return (k & 0x7fff)
+ elif ((k & 0x80) == 0):
+ return (k... | |
10e51f918c208c1b3c6f27b28b085ac49b33431f | towers/beginner/level_001.py | towers/beginner/level_001.py | # --------
# |@ >|
# --------
level.description("You see before yourself a long hallway with stairs at "
"the end. There is nothing in the way.")
level.tip("Call warrior.walk_ to walk forward in the Player "
"'play_turn' method.")
level.time_bonus(15)
level.ace_score(10)
level.size(8,... | Add an initial tower that doesnt parse yet | Add an initial tower that doesnt parse yet
| Python | mit | arbylee/python-warrior | ---
+++
@@ -0,0 +1,14 @@
+# --------
+# |@ >|
+# --------
+level.description("You see before yourself a long hallway with stairs at "
+ "the end. There is nothing in the way.")
+level.tip("Call warrior.walk_ to walk forward in the Player "
+ "'play_turn' method.")
+level.time_bonus(15... | |
563f4fd48840655c849fa620d03bddf82ea63b50 | project/velkoja/management/commands/check_holvi_overdue.py | project/velkoja/management/commands/check_holvi_overdue.py | # -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand, CommandError
from velkoja.holvichecker import HolviOverdueInvoicesHandler
class Command(BaseCommand):
help = 'Import transaction data from Holvi API'
def add_arguments(self, parser):
pass
def handle(self, *args, **option... | # -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand, CommandError
from velkoja.holvichecker import HolviOverdueInvoicesHandler
class Command(BaseCommand):
help = 'Import transaction data from Holvi API'
def add_arguments(self, parser):
pass
def handle(self, *args, **option... | Make the command to actually send the overdues | Make the command to actually send the overdues
| Python | mit | rambo/asylum,hacklab-fi/asylum,jautero/asylum,rambo/asylum,HelsinkiHacklab/asylum,hacklab-fi/asylum,HelsinkiHacklab/asylum,jautero/asylum,rambo/asylum,HelsinkiHacklab/asylum,rambo/asylum,HelsinkiHacklab/asylum,jautero/asylum,hacklab-fi/asylum,jautero/asylum,hacklab-fi/asylum | ---
+++
@@ -10,7 +10,7 @@
def handle(self, *args, **options):
handler = HolviOverdueInvoicesHandler()
- notified = handler.process_overdue()
+ notified = handler.process_overdue(send=True)
if options['verbosity'] > 1:
for n,i in notified:
print("Not... |
dbd523861bfb9abad8a52b1de28de85c0f128807 | plume/linalg.py | plume/linalg.py | # 一些基本的线性代数算法
import numpy as np
def lu(A):
# LU 分解,要求必须非奇异
A = A.copy()
U = np.zeros(A.shape)
L = np.eye(A.shape[1])
for i in range(A.shape[1] - 1):
U[:i + 1, i] = A[:i + 1, i]
L[i + 1:, i] = A[i + 1:, i] / U[i, i]
A[i + 1:] -= L[i + 1:, i].reshape(-1, 1) * A[i, :]
U[... | Add some linear algebra algorithms. | Add some linear algebra algorithms.
| Python | mit | WiseDoge/plume | ---
+++
@@ -0,0 +1,59 @@
+# 一些基本的线性代数算法
+
+import numpy as np
+
+
+def lu(A):
+ # LU 分解,要求必须非奇异
+ A = A.copy()
+ U = np.zeros(A.shape)
+ L = np.eye(A.shape[1])
+ for i in range(A.shape[1] - 1):
+ U[:i + 1, i] = A[:i + 1, i]
+ L[i + 1:, i] = A[i + 1:, i] / U[i, i]
+ A[i + 1:] -= L[i... | |
a532da48349c645464b97fb618b83799269a6b4b | examples/terminal/powerline.py | examples/terminal/powerline.py | #!/usr/bin/env python
'''Powerline terminal prompt example.
'''
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
from lib.core import Powerline, Segment
from lib.renderers import TerminalSegmentRenderer
powerline = Powerline([
Segment('⭤ SSH', 220, 166, attr=Segment.ATTR_BOLD),... | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
'''Powerline terminal prompt example.
'''
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
from lib.core import Powerline, Segment
from lib.renderers import TerminalSegmentRenderer
powerline = Powerline([
Segment('⭤ SSH'... | Fix issues with the terminal prompt example | Fix issues with the terminal prompt example
| Python | mit | DoctorJellyface/powerline,junix/powerline,prvnkumar/powerline,lukw00/powerline,cyrixhero/powerline,DoctorJellyface/powerline,seanfisk/powerline,S0lll0s/powerline,areteix/powerline,magus424/powerline,wfscheper/powerline,xfumihiro/powerline,bartvm/powerline,firebitsbr/powerline,IvanAli/powerline,russellb/powerline,Luffin... | ---
+++
@@ -1,10 +1,11 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
+# -*- coding: utf-8 -*-
'''Powerline terminal prompt example.
'''
import os
import sys
-sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
+sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
fro... |
51a461032449ba10ed030f2d355817a2d2b65005 | dec01/part1.py | dec01/part1.py | # Advent of Code
# Dec 1, Part 1
# @geekygirlsarah
import struct
inputFile = "input.txt"
# Tracking vars
x = 0
y = 0
facing = "N"
with open(inputFile) as f:
while True:
contents = f.readline(-1)
if not contents:
# print "End of file"
break
# print ("Contents: ", c... | Add 12/1 part 1 solution | Add 12/1 part 1 solution
| Python | mit | geekygirlsarah/adventofcode2016 | ---
+++
@@ -0,0 +1,59 @@
+# Advent of Code
+# Dec 1, Part 1
+# @geekygirlsarah
+
+import struct
+
+inputFile = "input.txt"
+
+# Tracking vars
+x = 0
+y = 0
+facing = "N"
+
+with open(inputFile) as f:
+ while True:
+ contents = f.readline(-1)
+ if not contents:
+ # print "End of file"
+ ... | |
87b8b20f9d7e16d274a5f5130cd10beb1b69ff6c | test_microservice/toolkit/jsontools.py | test_microservice/toolkit/jsontools.py | # -*- coding: utf-8 -*-
# __ ___ ___ _ __ ___ ___ _ ___ ___ _
# (_ |\/| | __ | |_ (_ | __ /\ | | | / \ |\/| /\ | | / \ |\ |
# __) | | _|_ | |_ __) | /--\ |_| | \_/ | | /--\ | _|_ \_/ | \|
"""
JSON Toolkit
~~~~~~~~~~~~
Series of tools designed around JSON
Copyright (c)... | Add json tools to toolkit | Add json tools to toolkit
Create a new toolkit to interface with json files | Python | apache-2.0 | akashkw/smi-test-automation,MichaelRegert/smi-test-automation | ---
+++
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+
+# __ ___ ___ _ __ ___ ___ _ ___ ___ _
+# (_ |\/| | __ | |_ (_ | __ /\ | | | / \ |\/| /\ | | / \ |\ |
+# __) | | _|_ | |_ __) | /--\ |_| | \_/ | | /--\ | _|_ \_/ | \|
+
+"""
+JSON Toolkit
+~~~~~~~~~~~~
+Series of tool... | |
408788b42de9cdde08a069db7f5709398c0febd4 | tests/adapter/mongo/test_rank_model.py | tests/adapter/mongo/test_rank_model.py | from scout.server.app import create_app
from scout.server.extensions import store
def test_rank_model_from_url_snv(adapter, case_obj):
"""Test parsing and saving a SNV rank model object from a remote config file"""
# GIVEN that the params to retrieve a SNV genetic model are available in the app context
R... | Add parsing and adding model to db tests | Add parsing and adding model to db tests
| Python | bsd-3-clause | Clinical-Genomics/scout,Clinical-Genomics/scout,Clinical-Genomics/scout | ---
+++
@@ -0,0 +1,46 @@
+from scout.server.app import create_app
+from scout.server.extensions import store
+
+
+def test_rank_model_from_url_snv(adapter, case_obj):
+ """Test parsing and saving a SNV rank model object from a remote config file"""
+
+ # GIVEN that the params to retrieve a SNV genetic model are... | |
07f7281089ef799c369655145fae00a530080d8b | tests/test_sparse_matrix_operations.py | tests/test_sparse_matrix_operations.py | from __future__ import division
import math
import numpy as np
import pyviennacl as p
import scipy.sparse.linalg as spspla
from _common import *
from itertools import product
size, sparsity = 20, 0.1
dtype_tolerances = [('float32', 1.0E-3), ('float64', 1.0E-8)]
dense_matrix_getters = [('matrix', 'get_matrix'),
... | Add sparse matrix operations test | Add sparse matrix operations test
| Python | mit | viennacl/pyviennacl-dev,opticode/pyviennacl-dev,viennacl/pyviennacl-dev,opticode/pyviennacl-dev | ---
+++
@@ -0,0 +1,54 @@
+from __future__ import division
+
+import math
+import numpy as np
+import pyviennacl as p
+import scipy.sparse.linalg as spspla
+from _common import *
+from itertools import product
+
+size, sparsity = 20, 0.1
+
+dtype_tolerances = [('float32', 1.0E-3), ('float64', 1.0E-8)]
+
+dense_matrix_... | |
a020e8c35c35a3e0ec16b42abd62ee689351b7f6 | tests/functional/test_truststore.py | tests/functional/test_truststore.py | import sys
from typing import Any, Callable
import pytest
from tests.lib import PipTestEnvironment, TestPipResult
PipRunner = Callable[..., TestPipResult]
@pytest.fixture()
def pip(script: PipTestEnvironment) -> PipRunner:
def pip(*args: str, **kwargs: Any) -> TestPipResult:
return script.pip(*args, "-... | Add very simple tests to ensure feature is enabled | Add very simple tests to ensure feature is enabled
| Python | mit | pfmoore/pip,pradyunsg/pip,pradyunsg/pip,sbidoul/pip,pfmoore/pip,sbidoul/pip,pypa/pip,pypa/pip | ---
+++
@@ -0,0 +1,61 @@
+import sys
+from typing import Any, Callable
+
+import pytest
+
+from tests.lib import PipTestEnvironment, TestPipResult
+
+PipRunner = Callable[..., TestPipResult]
+
+
+@pytest.fixture()
+def pip(script: PipTestEnvironment) -> PipRunner:
+ def pip(*args: str, **kwargs: Any) -> TestPipRes... | |
8e9e5c7965d50113dda4e69c9ec0248cd3db0037 | nova/db/sqlalchemy/migrate_repo/versions/140_drop_unused_postgresql_volume_sequences.py | nova/db/sqlalchemy/migrate_repo/versions/140_drop_unused_postgresql_volume_sequences.py | # vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (c) 2012 Red Hat, Inc.
# 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.o... | Drop unused PostgreSQL sequences from Folsom. | Drop unused PostgreSQL sequences from Folsom.
In Folsom the snapshots and volumes tables were converted to use
UUID's. When we performed this conversion in Folsom a couple of
unused PostgreSQL sequences were left behind.
This migration removes the snapshots_id_seq and volumes_id_seq
if they exist in the schema when u... | Python | apache-2.0 | klmitch/nova,shahar-stratoscale/nova,cernops/nova,rajalokan/nova,aristanetworks/arista-ovs-nova,adelina-t/nova,jianghuaw/nova,berrange/nova,vmturbo/nova,eayunstack/nova,blueboxgroup/nova,eonpatapon/nova,watonyweng/nova,Francis-Liu/animated-broccoli,eonpatapon/nova,ruslanloman/nova,houshengbo/nova_vmware_compute_driver,... | ---
+++
@@ -0,0 +1,61 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (c) 2012 Red Hat, Inc.
+# 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... | |
5e2000852933da680af03e002f094ff9a5e7bc25 | txircd/modules/extra/conn_umodes.py | txircd/modules/extra/conn_umodes.py | from twisted.plugin import IPlugin
from txircd.module_interface import IModuleData, ModuleData
from zope.interface import implements
class AutoUserModes(ModuleData):
implements(IPlugin, IModuleData)
name = "AutoUserModes"
def hookIRCd(self, ircd):
self.ircd = ircd
def actions(self):
... | Implement the usermodes on connect module | Implement the usermodes on connect module
| Python | bsd-3-clause | Heufneutje/txircd,ElementalAlchemist/txircd | ---
+++
@@ -0,0 +1,25 @@
+from twisted.plugin import IPlugin
+from txircd.module_interface import IModuleData, ModuleData
+from zope.interface import implements
+
+class AutoUserModes(ModuleData):
+ implements(IPlugin, IModuleData)
+
+ name = "AutoUserModes"
+
+ def hookIRCd(self, ircd):
+ self.ircd =... | |
94c7de8340f8cfb630c09d86a709e62436ce7d9e | packages/Python/lldbsuite/test/repl/type_lookup/TestREPLTypeLookup.py | packages/Python/lldbsuite/test/repl/type_lookup/TestREPLTypeLookup.py | # TestREPLTypeLookup.py
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIB... | Add a test case to validate that 'type lookup' picks Swift vs. ObjC properly in the REPL | Add a test case to validate that 'type lookup' picks Swift vs. ObjC properly in the REPL
| Python | apache-2.0 | apple/swift-lldb,apple/swift-lldb,apple/swift-lldb,apple/swift-lldb,apple/swift-lldb,apple/swift-lldb | ---
+++
@@ -0,0 +1,32 @@
+# TestREPLTypeLookup.py
+#
+# This source file is part of the Swift.org open source project
+#
+# Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
+# Licensed under Apache License v2.0 with Runtime Library Exception
+#
+# See http://swift.org/LICENSE.txt for license informa... | |
8745aaa16568ff4e0954c7e0351665d5c1eb9e01 | test/test_rmf3_dump.py | test/test_rmf3_dump.py | import unittest
import RMF
import subprocess
class Tests(unittest.TestCase):
def test_help(self):
"""Test rmf3_dump --help"""
p = subprocess.Popen(['rmf3_dump', '--help'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PI... | Add a basic test for rmf3_dump | Add a basic test for rmf3_dump
| Python | apache-2.0 | salilab/rmf,salilab/rmf,salilab/rmf,salilab/rmf | ---
+++
@@ -0,0 +1,32 @@
+import unittest
+import RMF
+import subprocess
+
+
+class Tests(unittest.TestCase):
+
+ def test_help(self):
+ """Test rmf3_dump --help"""
+ p = subprocess.Popen(['rmf3_dump', '--help'], stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ ... | |
a3664120d3606e0257b79da141313752cf347953 | write_serial.py | write_serial.py | #!/usr/bin/env python
from __future__ import print_function
import serial
import time
import json
def main():
with open('data.json') as fh:
values = json.load(fh)
with serial.Serial('/dev/tty.usbmodem1411', 9600) as port:
start_time = time.time()
for value in values:
while... | Add script to write serial capture | Add script to write serial capture
| Python | mit | thusoy/hhi-experiments | ---
+++
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+
+import serial
+import time
+import json
+
+def main():
+ with open('data.json') as fh:
+ values = json.load(fh)
+ with serial.Serial('/dev/tty.usbmodem1411', 9600) as port:
+ start_time = time.time()
+ ... | |
6994ba541f755abe427e032f9dd4991bf13f1f49 | pykmer/exset.py | pykmer/exset.py | """
This module provides an API for reading and writing sets (sorted lists)
of *k*-mers in an uncompressed form using the builtin Python array type.
It is good for small sets of *k*-mers, where the compression/decompression
overhead outweighs the space benefits.
"""
__docformat__ = 'restructuredtext'
import array
im... | Add an expanded k-mer set. | Add an expanded k-mer set.
| Python | apache-2.0 | drtconway/pykmer | ---
+++
@@ -0,0 +1,34 @@
+"""
+This module provides an API for reading and writing sets (sorted lists)
+of *k*-mers in an uncompressed form using the builtin Python array type.
+
+It is good for small sets of *k*-mers, where the compression/decompression
+overhead outweighs the space benefits.
+"""
+
+__docformat__ =... | |
dba74cdd2fb2a8e5be1b56bba3fdcadc40827f73 | links/utils/testing_helpers.py | links/utils/testing_helpers.py | from django.test import TestCase
from django.core.urlresolvers import reverse
from rest_framework.test import APIClient
class APITestCase(TestCase):
def setUp(self):
self.client = APIClient()
class AuthenticatedAPITestCase(APITestCase):
def setUp(self):
super(AuthenticatedAPITestCase, sel... | Create some testing helper classes | Create some testing helper classes
| Python | mit | projectweekend/Links-API,projectweekend/Links-API | ---
+++
@@ -0,0 +1,24 @@
+from django.test import TestCase
+from django.core.urlresolvers import reverse
+
+from rest_framework.test import APIClient
+
+
+class APITestCase(TestCase):
+
+ def setUp(self):
+ self.client = APIClient()
+
+
+class AuthenticatedAPITestCase(APITestCase):
+
+ def setUp(self):
+... | |
d1e07f55fd05bdd77ec323b814607deaab03de57 | tests/lib/test_files.py | tests/lib/test_files.py | # -*- coding: utf-8 -*-
import pytest
from skylines.lib import files
from skylines.lib.types import is_unicode
@pytest.mark.parametrize(
"input,expected",
[
(b"foo/bar/baz.igc", u"baz.igc"),
(u"HERR.müller@123.igc", u"herr.m_ller_123.igc"),
(u"abc/...1234.igc", u"1234.igc"),
... | Add tests for `sanitise_filename()` function | lib/files: Add tests for `sanitise_filename()` function
| Python | agpl-3.0 | skylines-project/skylines,skylines-project/skylines,skylines-project/skylines,skylines-project/skylines | ---
+++
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+
+import pytest
+
+from skylines.lib import files
+from skylines.lib.types import is_unicode
+
+
+@pytest.mark.parametrize(
+ "input,expected",
+ [
+ (b"foo/bar/baz.igc", u"baz.igc"),
+ (u"HERR.müller@123.igc", u"herr.m_ller_123.igc"),
+ (u... | |
fd47b1744567dfdfe9e3787bbc4638ddc30b3ff6 | tests/preflight_test.py | tests/preflight_test.py | from unittest import TestCase
from dusty.preflight import _assert_executable_exists, PreflightException
class PreflightTest(TestCase):
def test_assert_executable_exists(self):
_assert_executable_exists('python')
def test_assert_executable_exists_fails(self):
with self.assertRaises(PreflightEx... | Add tests for assert executable | Add tests for assert executable
| Python | mit | gamechanger/dusty,gamechanger/dusty,gamechanger/dusty,gamechanger/dusty,gamechanger/dusty | ---
+++
@@ -0,0 +1,11 @@
+from unittest import TestCase
+
+from dusty.preflight import _assert_executable_exists, PreflightException
+
+class PreflightTest(TestCase):
+ def test_assert_executable_exists(self):
+ _assert_executable_exists('python')
+
+ def test_assert_executable_exists_fails(self):
+ ... | |
ceb624e34de4165a75874786b34ca509fe865a43 | tools/telemetry/telemetry/page/actions/action_runner_unittest.py | tools/telemetry/telemetry/page/actions/action_runner_unittest.py | # Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.core.backends.chrome import tracing_backend
from telemetry.core.timeline import model
from telemetry.page.actions import action_runner as actio... | Add unittests for action_runner.BeginInteraction and action_runner.EndInteraction. | Add unittests for action_runner.BeginInteraction and action_runner.EndInteraction.
This is a reland of https://codereview.chromium.org/294943006 after it's reverted in
https://codereview.chromium.org/284183014/.
BUG=368767
Review URL: https://codereview.chromium.org/299443017
git-svn-id: de016e52bd170d2d4f2344f9bf9... | Python | bsd-3-clause | axinging/chromium-crosswalk,fujunwei/chromium-crosswalk,Chilledheart/chromium,M4sse/chromium.src,M4sse/chromium.src,Pluto-tv/chromium-crosswalk,dednal/chromium.src,dednal/chromium.src,TheTypoMaster/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,ltilve/chromium,hgl888/chromium-crosswalk-efl,mohamed--abdel-maksoud/... | ---
+++
@@ -0,0 +1,34 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+from telemetry.core.backends.chrome import tracing_backend
+from telemetry.core.timeline import model
+from telemetry.page.acti... | |
5240a982723eba0df09f4c360f1a1603b25fd3fe | py/continuous-subarray-sum.py | py/continuous-subarray-sum.py | from collections import Counter
class Solution(object):
def checkSubarraySum(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: bool
"""
if len(nums) < 2:
return False
k = abs(k)
if k == 0:
t1, t2 = iter(nums), iter(... | Add py solution for 523. Continuous Subarray Sum | Add py solution for 523. Continuous Subarray Sum
523. Continuous Subarray Sum: https://leetcode.com/problems/continuous-subarray-sum/
Approach:
Observe the first item remaining in each step. The value will be added
1 << step either the remaining count is odd or it's a left-to-right
step. Hence the n | 0x5... | Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,33 @@
+from collections import Counter
+class Solution(object):
+ def checkSubarraySum(self, nums, k):
+ """
+ :type nums: List[int]
+ :type k: int
+ :rtype: bool
+ """
+ if len(nums) < 2:
+ return False
+ k = abs(k)
+ if k == 0:... | |
fcb2913bd5cb4e25119ae65dd2ff681fe9dfc7eb | Spider/spider.py | Spider/spider.py | from worker import SpiderWorker
from bloomset import BloomSet
from queue import SpiderQueue
import utilities
class Spider:
def __init__(self , baseUrl, numthreads=1, depth=1):
self.baseUrl = baseUrl
self.numthreads = numthreads
self.depth = depth
if not utilities.validateURL(baseUrl):
raise ValueError... | Update names and change headers | Update names and change headers
| Python | mit | goelyash/Spider,goelyash/Spider | ---
+++
@@ -0,0 +1,21 @@
+from worker import SpiderWorker
+from bloomset import BloomSet
+from queue import SpiderQueue
+import utilities
+
+class Spider:
+ def __init__(self , baseUrl, numthreads=1, depth=1):
+ self.baseUrl = baseUrl
+ self.numthreads = numthreads
+ self.depth = depth
+ if not utilities.vali... | |
20e02587df6d8c776fa4b045e7004c546f531548 | tvrenamr/tests/base.py | tvrenamr/tests/base.py | from os import mkdir
from os.path import abspath, dirname, exists, join
from shutil import rmtree
from tvrenamr.config import Config
from tvrenamr.main import TvRenamr
from tvrenamr.tests import mock_requests
# make pyflakes STFU
assert mock_requests
class BaseTest(object):
files = 'tests/files'
organised = ... | from os import mkdir
from os.path import abspath, dirname, exists, join
from shutil import rmtree
from tvrenamr.config import Config
from tvrenamr.main import TvRenamr
from tvrenamr.tests import mock_requests
# make pyflakes STFU
assert mock_requests
class BaseTest(object):
files = 'tests/files'
organised = ... | Check and create the tests file folder using an absolute path | Check and create the tests file folder using an absolute path
| Python | mit | wintersandroid/tvrenamr,ghickman/tvrenamr | ---
+++
@@ -15,12 +15,12 @@
renamed = 'tests/data/renamed'
def setup(self):
- # if `file` isn't there, make it
- if not exists(self.files):
- mkdir(self.files)
-
# absolute path to the file is pretty useful
self.path = abspath(dirname(__file__))
+
+ # if `... |
db15972cb8efc93e4725967415ca3327473d88bf | dronesym-python/flask-api/src/node.py | dronesym-python/flask-api/src/node.py | import requests
import json
apiUrl = 'http://localhost:3000/dronesym/api/node'
def update_drone(id, status):
response = requests.post(apiUrl + '/update/' + str(id), json=status, headers={ 'Content-Type' : 'application/json' })
return response.json()
def get_drone_by_id(id):
response = requests.get(apiUrl + '/get/... | Implement python interface for Node API | Implement python interface for Node API
| Python | apache-2.0 | scorelab/DroneSym,scorelab/DroneSym,scorelab/DroneSym,scorelab/DroneSym,scorelab/DroneSym | ---
+++
@@ -0,0 +1,16 @@
+import requests
+import json
+
+apiUrl = 'http://localhost:3000/dronesym/api/node'
+
+def update_drone(id, status):
+ response = requests.post(apiUrl + '/update/' + str(id), json=status, headers={ 'Content-Type' : 'application/json' })
+ return response.json()
+
+def get_drone_by_id(id):
+ r... | |
3075051d66ed599c4a23c8ddd9f06427b294f461 | simulator/stream_positions.py | simulator/stream_positions.py | #!/usr/bin/env python3
#
# Copyright 2015 Secure Systems Group, Aalto University https://se-sy.org/.
#
# 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/LIC... | Add a script for printing file upload moments in the stream | Add a script for printing file upload moments in the stream
| Python | apache-2.0 | sjakthol/dedup-simulator,sjakthol/dedup-simulator | ---
+++
@@ -0,0 +1,39 @@
+#!/usr/bin/env python3
+#
+# Copyright 2015 Secure Systems Group, Aalto University https://se-sy.org/.
+#
+# 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
+#
+# ... | |
ac9ac690e9ae584333eaf960703926c1b6cfb531 | framework/archiver/__init__.py | framework/archiver/__init__.py | from website.project import signals as project_signals
class StatResult(object):
def __init__(self, target, problems=[], num_files=0, disk_usage=0, owners=[]):
self.target = target
self.num_files = num_files
self.disk_usage = disk_usage
self.owners = owners
self.problems = ... | Add preliminary class interface for Archiver | Add preliminary class interface for Archiver
| Python | apache-2.0 | DanielSBrown/osf.io,RomanZWang/osf.io,sloria/osf.io,zachjanicki/osf.io,sbt9uc/osf.io,TomHeatwole/osf.io,reinaH/osf.io,dplorimer/osf,jnayak1/osf.io,HalcyonChimera/osf.io,samchrisinger/osf.io,baylee-d/osf.io,dplorimer/osf,kch8qx/osf.io,CenterForOpenScience/osf.io,cosenal/osf.io,mluo613/osf.io,jmcarp/osf.io,alexschiller/o... | ---
+++
@@ -0,0 +1,59 @@
+from website.project import signals as project_signals
+
+class StatResult(object):
+
+ def __init__(self, target, problems=[], num_files=0, disk_usage=0, owners=[]):
+ self.target = target
+ self.num_files = num_files
+ self.disk_usage = disk_usage
+ self.owne... | |
70c8b573e0d1ff84da0b3449563a9d7bea508843 | morph_proxy.py | morph_proxy.py | # Run this with mitmdump -q -s morph_proxy.py
def request(context, flow):
# print out all the basic information to determine what request is being made
# coming from which container
# print flow.request.method
# print flow.request.host
# print flow.request.path
# print flow.request.scheme
# print flow.re... | Use mitmproxy to get basic information | Use mitmproxy to get basic information
| Python | agpl-3.0 | otherchirps/morph,OpenAddressesUK/morph,otherchirps/morph,openaustralia/morph,openaustralia/morph,otherchirps/morph,OpenAddressesUK/morph,otherchirps/morph,otherchirps/morph,otherchirps/morph,openaustralia/morph,openaustralia/morph,OpenAddressesUK/morph,OpenAddressesUK/morph,openaustralia/morph,openaustralia/morph,open... | ---
+++
@@ -0,0 +1,15 @@
+# Run this with mitmdump -q -s morph_proxy.py
+
+def request(context, flow):
+ # print out all the basic information to determine what request is being made
+ # coming from which container
+ # print flow.request.method
+ # print flow.request.host
+ # print flow.request.path
+ # print f... | |
b9d8406282c4017feca039a291699ae90f459f17 | trove/guestagent/common/timeutils.py | trove/guestagent/common/timeutils.py | from datetime import datetime
from oslo_utils import timeutils
def float_utcnow():
return float(datetime.strftime(timeutils.utcnow(), "%s.%f"))
| # 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 u... | Add Apache 2.0 license to source file | Add Apache 2.0 license to source file
As per OpenStack licensing guide lines [1]:
[H102 H103] Newly contributed Source Code should be licensed under
the Apache 2.0 license.
[H104] Files with no code shouldn't contain any license header nor
comments, and must be left completely empty.
[1] http://docs.openstack.org/dev... | Python | apache-2.0 | openstack/trove,zhangg/trove,hplustree/trove,openstack/trove,hplustree/trove,zhangg/trove | ---
+++
@@ -1,3 +1,15 @@
+# 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 ... |
fa6a9e58a1ebd30dc202d41d9bf3e795b0043c9b | usingnamespace/api/views/v1/entry.py | usingnamespace/api/views/v1/entry.py | from pyramid.view import (
view_config,
view_defaults,
)
from ....views.finalisecontext import FinaliseContext
@view_defaults(context='...traversal.v1.Entry',
route_name='api',
renderer='json',
)
class Site(FinaliseContext):
@view_config()
def main(self):
... | Add view for a single Entry | Add view for a single Entry
| Python | isc | usingnamespace/usingnamespace | ---
+++
@@ -0,0 +1,31 @@
+from pyramid.view import (
+ view_config,
+ view_defaults,
+ )
+
+from ....views.finalisecontext import FinaliseContext
+
+@view_defaults(context='...traversal.v1.Entry',
+ route_name='api',
+ renderer='json',
+ )
+class Site(FinaliseContext):
+ @... | |
55ea281c96228e46b8520f2aa7305116c21c6b20 | mailchimp3/entities/campaignfolder.py | mailchimp3/entities/campaignfolder.py | # coding=utf-8
"""
The Campaign Folders API endpoints
Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/campaign-folders/
Schema: https://api.mailchimp.com/schema/3.0/CampaignFolders/Instance.json
"""
from __future__ import unicode_literals
from mailchimp3.baseapi import BaseApi
class ... | Implement the Campaign Folders endpoint | Implement the Campaign Folders endpoint
| Python | mit | charlesthk/python-mailchimp | ---
+++
@@ -0,0 +1,99 @@
+# coding=utf-8
+"""
+The Campaign Folders API endpoints
+
+Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/campaign-folders/
+Schema: https://api.mailchimp.com/schema/3.0/CampaignFolders/Instance.json
+"""
+from __future__ import unicode_literals
+
+from mailc... | |
ede8c653722d8f316a368ec490023cff3abdeed0 | dashboard/helpers.py | dashboard/helpers.py | import json
import requests
def get_coin_price(coin_name):
url = "https://bittrex.com/api/v1.1/public/getticker?market=USDT-{}".format(coin_name)
data = requests.get(url).json()
last_price = data.get("result").get("Last")
data = json.dumps({
coin_name: last_price
})
return data
| Add helper to get the coin price | Add helper to get the coin price
| Python | mit | alessandroHenrique/coinpricemonitor,alessandroHenrique/coinpricemonitor,alessandroHenrique/coinpricemonitor | ---
+++
@@ -0,0 +1,14 @@
+import json
+import requests
+
+
+def get_coin_price(coin_name):
+ url = "https://bittrex.com/api/v1.1/public/getticker?market=USDT-{}".format(coin_name)
+ data = requests.get(url).json()
+ last_price = data.get("result").get("Last")
+
+ data = json.dumps({
+ coin_name: la... | |
5ea598d820997526bcde6e83b01852cc69f22d9b | scripts/ensure_log_backrefs.py | scripts/ensure_log_backrefs.py | # -*- coding: utf-8 -*-
from website.app import init_app
from website import models
from modularodm.storedobject import ensure_backrefs
def main():
init_app(routes=False)
for record in models.Node.find():
ensure_backrefs(record, ['logs'])
print('Done.')
if __name__ == "__main__":
main()
| Add script for ensuring log backrefs are correct | Add script for ensuring log backrefs are correct
| Python | apache-2.0 | wearpants/osf.io,caneruguz/osf.io,RomanZWang/osf.io,baylee-d/osf.io,TomBaxter/osf.io,CenterForOpenScience/osf.io,RomanZWang/osf.io,binoculars/osf.io,acshi/osf.io,jnayak1/osf.io,mluo613/osf.io,zamattiac/osf.io,alexschiller/osf.io,mfraezz/osf.io,amyshi188/osf.io,samchrisinger/osf.io,emetsger/osf.io,emetsger/osf.io,alexsc... | ---
+++
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+from website.app import init_app
+from website import models
+from modularodm.storedobject import ensure_backrefs
+
+def main():
+ init_app(routes=False)
+ for record in models.Node.find():
+ ensure_backrefs(record, ['logs'])
+ print('Done.')
+
+if __... | |
b8ec0533e671651a72e3bd06295a56913b9e9e64 | test/multiple_invocations_test.py | test/multiple_invocations_test.py | # Copyright (c) 2012 - 2014 Lars Hupfeldt Nielsen, Hupfeldt IT
# All rights reserved. This work is under a BSD license, see LICENSE.TXT.
from jenkinsflow.flow import serial
from .framework import mock_api
def test_multiple_invocations_immediate():
with mock_api.api(__file__) as api:
api.flow_job()
... | Test multiple invocations of same job in one flow | Test multiple invocations of same job in one flow
| Python | bsd-3-clause | lhupfeldt/jenkinsflow,lechat/jenkinsflow,lechat/jenkinsflow,lhupfeldt/jenkinsflow,lechat/jenkinsflow,lhupfeldt/jenkinsflow,lechat/jenkinsflow,lhupfeldt/jenkinsflow | ---
+++
@@ -0,0 +1,16 @@
+# Copyright (c) 2012 - 2014 Lars Hupfeldt Nielsen, Hupfeldt IT
+# All rights reserved. This work is under a BSD license, see LICENSE.TXT.
+
+from jenkinsflow.flow import serial
+from .framework import mock_api
+
+
+def test_multiple_invocations_immediate():
+ with mock_api.api(__file__) a... | |
7f143126a490e361a3495ecb8111572db23e0a56 | serfnode/handler/file_utils.py | serfnode/handler/file_utils.py | import os
from tempfile import mkstemp
import time
class atomic_write(object):
"""Perform an atomic write to a file.
Use as::
with atomic_write('/my_file') as f:
f.write('foo')
"""
def __init__(self, filepath):
"""
:type filepath: str
"""
self.fi... | Add module for atomic file writes and waits | Add module for atomic file writes and waits | Python | mit | waltermoreira/serfnode,waltermoreira/serfnode,waltermoreira/serfnode | ---
+++
@@ -0,0 +1,47 @@
+import os
+from tempfile import mkstemp
+import time
+
+
+class atomic_write(object):
+ """Perform an atomic write to a file.
+
+ Use as::
+
+ with atomic_write('/my_file') as f:
+ f.write('foo')
+
+ """
+
+ def __init__(self, filepath):
+ """
+ :t... | |
2bb4d373554cc62f3c55840cc0b4ecaf93fe1961 | server/accounts/serializers.py | server/accounts/serializers.py | import HTMLParser
import random
import re
from django.contrib.auth.models import User
from rest_framework import serializers
from . import models
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
fields = ('id', 'username', 'password', 'first_name',
'la... | Add the serialization functions for the User objects. | Add the serialization functions for the User objects.
| Python | agpl-3.0 | TomDataworks/angular-inventory,TomDataworks/angular-inventory | ---
+++
@@ -0,0 +1,21 @@
+import HTMLParser
+import random
+import re
+
+from django.contrib.auth.models import User
+from rest_framework import serializers
+
+from . import models
+
+class UserSerializer(serializers.ModelSerializer):
+ class Meta:
+ model = User
+ fields = ('id', 'username', 'passwo... | |
7d7d50aa23b2694c47d82c77043cb81e1255fd04 | bluebottle/projects/migrations/0043_remove_payout_status_sourcing_projects.py | bluebottle/projects/migrations/0043_remove_payout_status_sourcing_projects.py | # -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2017-10-30 21:49
from __future__ import unicode_literals
from django.db import migrations
def forward(apps, schema_editor):
Project = apps.get_model('projects', 'Project')
Project.objects.filter(amount_asked=0, payout_status__isnull=False).update(payout... | Add migration to remove payout status from sourcing projects | Add migration to remove payout status from sourcing projects
| Python | bsd-3-clause | onepercentclub/bluebottle,onepercentclub/bluebottle,onepercentclub/bluebottle,onepercentclub/bluebottle,onepercentclub/bluebottle | ---
+++
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.8 on 2017-10-30 21:49
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+def forward(apps, schema_editor):
+ Project = apps.get_model('projects', 'Project')
+ Project.objects.filter(amount_asked=0, payou... | |
ca90897d3e31fa7bab4d79c3d3ab61eb0fc53be9 | tests/unit/tspapi/api_test.py | tests/unit/tspapi/api_test.py | #!/usr/bin/env python
#
# Copyright 2016 BMC Software, Inc.
#
# 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 applicab... | Add unit tests to check parsing of timestamps | Add unit tests to check parsing of timestamps
| Python | apache-2.0 | jdgwartney/pulse-api-python | ---
+++
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 BMC Software, Inc.
+#
+# 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... | |
9eaf22a0fb928bb51090a25302d04219df3cdce6 | serial-selector-test.py | serial-selector-test.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, serial, wx
from serial.tools import list_ports
class COMPort:
def __init__(self, id, name):
self.id = id
self.name = name
class COMPortSelectForm(wx.Frame):
def __init__(self):
# Create non-resizable frame
wx.Frame.__ini... | Create COM port selection GUI. | Create COM port selection GUI.
| Python | bsd-3-clause | vegarbg/ksp-telemetry | ---
+++
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os, serial, wx
+from serial.tools import list_ports
+
+class COMPort:
+ def __init__(self, id, name):
+ self.id = id
+ self.name = name
+
+class COMPortSelectForm(wx.Frame):
+ def __init__(self):
+ # Create n... | |
c7ac8b29ac433efeed99d121f182fe24248ff568 | data_analysis/plot_generator.py | data_analysis/plot_generator.py | import sys
import pandas as pd
import matplotlib.pyplot as plt
colors = ["b", "g", "r", "c", "m", "y", "k"]
weeks = ["42", "43", "44", "45", "46", "47", "48", "49",
"50", "51", "52", "01", "02", "03",
"04", "05", "06", "07", "09", "10", "11", "12", "13", "14", "15", "16", "17"]
def plot_data(_range, data, color, labe... | Add a simple script to plot data. | Add a simple script to plot data.
| Python | mit | geektoni/Influenza-Like-Illness-Predictor,geektoni/Influenza-Like-Illness-Predictor | ---
+++
@@ -0,0 +1,30 @@
+import sys
+import pandas as pd
+import matplotlib.pyplot as plt
+
+colors = ["b", "g", "r", "c", "m", "y", "k"]
+weeks = ["42", "43", "44", "45", "46", "47", "48", "49",
+"50", "51", "52", "01", "02", "03",
+"04", "05", "06", "07", "09", "10", "11", "12", "13", "14", "15", "16", "17"]
+
+de... | |
7919a8dfed814c4855a1b27290ab213cba03255e | py/base-7.py | py/base-7.py | class Solution(object):
def convertToBase7(self, num):
"""
:type num: int
:rtype: str
"""
if num == 0:
return "0"
neg = "-" if num < 0 else ""
num = abs(num)
ans = []
while num > 0:
ans.append(num % 7)
num /=... | Add py solution for 504. Base 7 | Add py solution for 504. Base 7
504. Base 7: https://leetcode.com/problems/base-7/
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,15 @@
+class Solution(object):
+ def convertToBase7(self, num):
+ """
+ :type num: int
+ :rtype: str
+ """
+ if num == 0:
+ return "0"
+ neg = "-" if num < 0 else ""
+ num = abs(num)
+ ans = []
+ while num > 0:
+ ... | |
f251f18df4a3a236e1f090d11931b5bd86f6bcc7 | tests/test_file_handlers.py | tests/test_file_handlers.py | import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import unittest
from unittest import mock
from web_scraper.core import file_handlers
def mocked_random_randint(*args, **kwargs):
"""this method will be used by the mock to replace random.randint"""
return 1
class... | Add tests for save_data_to_file function | Add tests for save_data_to_file function
| Python | mit | Samuel-L/cli-ws,Samuel-L/cli-ws | ---
+++
@@ -0,0 +1,56 @@
+import os
+import sys
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+import unittest
+from unittest import mock
+
+from web_scraper.core import file_handlers
+
+def mocked_random_randint(*args, **kwargs):
+ """this method will be used by the mock to repla... | |
75498e899f017aff60a3d6dfe8ed4e39aa199f51 | tests/su2_test.py | tests/su2_test.py | """Test for the SU2 drudge."""
from sympy import Rational, I
from drudge import SU2LatticeDrudge
def test_su2_without_symbolic_index(spark_ctx):
"""Test SU2 lattice drudge without abstract symbolic lattice index."""
dr = SU2LatticeDrudge(spark_ctx)
p = dr.names
half = Rational(1, 2)
half_i = ha... | Add tests for SU2 drudge without abstract lattice | Add tests for SU2 drudge without abstract lattice
| Python | mit | tschijnmo/drudge,tschijnmo/drudge,tschijnmo/drudge | ---
+++
@@ -0,0 +1,38 @@
+"""Test for the SU2 drudge."""
+
+from sympy import Rational, I
+
+from drudge import SU2LatticeDrudge
+
+
+def test_su2_without_symbolic_index(spark_ctx):
+ """Test SU2 lattice drudge without abstract symbolic lattice index."""
+
+ dr = SU2LatticeDrudge(spark_ctx)
+ p = dr.names
+ ... | |
1dfe51ab87f090d57452937ce5c52d4f5541eac3 | sfstation.py | sfstation.py | #!/usr/bin/env python3
import requests
import time
from bs4 import BeautifulSoup
day = "02-01-2020"
last_day_string = "03-01-2020"
page = requests.get("https://www.sfstation.com/calendar/{}".format(day))
soup = BeautifulSoup(page.content)
events_seen = set()
last_day = False
# loop through every day until the next m... | Add thrown together date script | Add thrown together date script
| Python | mit | feilen/dotfiles,feilen/dotfiles,feilen/dotfiles | ---
+++
@@ -0,0 +1,51 @@
+#!/usr/bin/env python3
+import requests
+import time
+from bs4 import BeautifulSoup
+
+day = "02-01-2020"
+last_day_string = "03-01-2020"
+page = requests.get("https://www.sfstation.com/calendar/{}".format(day))
+soup = BeautifulSoup(page.content)
+
+events_seen = set()
+
+last_day = False
+... | |
2ee1ef825bb6aa6ff74228c90d4656da6c3ddde6 | 201507/ledpwm.py | 201507/ledpwm.py | #!/usr/bin/python
led0 = open('/dev/rtled0', 'a')
n = 0
while True :
print >> led0, "%d" % (0 if n%5 else 1)
n = n + 1
| Add pwm Python code for LED | Add pwm Python code for LED
| Python | mit | ryuichiueda/RPiM,ryuichiueda/RPiM | ---
+++
@@ -0,0 +1,8 @@
+#!/usr/bin/python
+
+led0 = open('/dev/rtled0', 'a')
+n = 0
+
+while True :
+ print >> led0, "%d" % (0 if n%5 else 1)
+ n = n + 1 | |
f2472202af524887ae18943be368db647e4c3db8 | plugins/words.py | plugins/words.py | from difflib import get_close_matches
import discord
from pcbot import Annotate
import plugins
client = plugins.client
def load_wordlist(filename: str):
with open("plugins/wordlib/SimpleWordlists/Thesaurus-" + filename + ".txt") as f:
return {k: v.split(",") for k, v in [line.split("|") for line in f.re... | Add autonym and synonym commands | Add autonym and synonym commands
| Python | mit | PcBoy111/PCBOT,PcBoy111/PC-BOT-V2,pckv/pcbot | ---
+++
@@ -0,0 +1,45 @@
+from difflib import get_close_matches
+
+import discord
+
+from pcbot import Annotate
+import plugins
+client = plugins.client
+
+
+def load_wordlist(filename: str):
+ with open("plugins/wordlib/SimpleWordlists/Thesaurus-" + filename + ".txt") as f:
+ return {k: v.split(",") for k,... | |
7d45fd15f9d2fa4e0d830e7f404fb77d531adc29 | examples/test-combo-box.py | examples/test-combo-box.py | """
This test is adopted form nbtk, but since it's summer it uses
Munich's most famous Beergarden instead of places in London ;)
"""
import clutter
import nbtk
def title_changed_cb(box, pspec):
print 'title now:', box.get_title()
def index_changed_cb(box, pspec):
print 'index now:', box.get_index()
def stage... | Add a simple test for ComboBox | Add a simple test for ComboBox
| Python | lgpl-2.1 | buztard/mxpy,buztard/mxpy,buztard/mxpy | ---
+++
@@ -0,0 +1,41 @@
+"""
+This test is adopted form nbtk, but since it's summer it uses
+Munich's most famous Beergarden instead of places in London ;)
+"""
+import clutter
+import nbtk
+
+def title_changed_cb(box, pspec):
+ print 'title now:', box.get_title()
+
+def index_changed_cb(box, pspec):
+ print '... | |
4fb1a760489d30dcc93bdac8209bc6eeceb81bd8 | piperlearn/visual/statsplot.py | piperlearn/visual/statsplot.py | import seaborn as sns
import matplotlib.pyplot as plt
from ..utility.validation import check_dataframe, check_cols
def compute_correlation(data=None, cols=None, method='pearson'):
datasets = check_dataframe(data, cols)
return datasets.corr(method)
class correlations(object):
def __init__(self, data, cols... | Add utility for validation and plot for heatmap | Add utility for validation and plot for heatmap
| Python | mit | dolremi/PiperLearn | ---
+++
@@ -0,0 +1,48 @@
+import seaborn as sns
+import matplotlib.pyplot as plt
+
+from ..utility.validation import check_dataframe, check_cols
+
+def compute_correlation(data=None, cols=None, method='pearson'):
+ datasets = check_dataframe(data, cols)
+ return datasets.corr(method)
+
+class correlations(objec... | |
e5e023cdbaf6996a6f26726ee63f551d5b73b313 | examples/voc/download_models.py | examples/voc/download_models.py | #!/usr/bin/env python
import os.path as osp
import fcn
def main():
# models converted from caffe
path = fcn.data.download_vgg16_chainermodel()
print('==> downloaded to: %s' % path)
path = fcn.data.download_fcn32s_chainermodel()
print('==> downloaded to: %s' % path)
path = fcn.data.download_f... | Add script to download pre-trained models | Add script to download pre-trained models
| Python | mit | wkentaro/fcn | ---
+++
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+import os.path as osp
+
+import fcn
+
+
+def main():
+ # models converted from caffe
+ path = fcn.data.download_vgg16_chainermodel()
+ print('==> downloaded to: %s' % path)
+ path = fcn.data.download_fcn32s_chainermodel()
+ print('==> downloaded to: %s... | |
ffae26e0a2f9ffa9aca1786d2ef4928e7eb2b401 | pycket/test/test_envext.py | pycket/test/test_envext.py | #! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Testing environmental and external behavior
#
import pytest
from pycket.test.test_basic import run_fix, run
from pycket.targetpycket import main
from rpython.rlib import jit
def pytest_funcarg__json(request):
tmpdir = request.getfuncargvalue('tmpdir')
assert r... | Add test for external and environmental stuff | Add test for external and environmental stuff
Here: Commandline
| Python | mit | krono/pycket,magnusmorton/pycket,vishesh/pycket,krono/pycket,cderici/pycket,cderici/pycket,magnusmorton/pycket,vishesh/pycket,samth/pycket,vishesh/pycket,samth/pycket,krono/pycket,pycket/pycket,samth/pycket,magnusmorton/pycket,cderici/pycket,pycket/pycket,pycket/pycket | ---
+++
@@ -0,0 +1,41 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Testing environmental and external behavior
+#
+import pytest
+from pycket.test.test_basic import run_fix, run
+from pycket.targetpycket import main
+from rpython.rlib import jit
+
+def pytest_funcarg__json(request):
+ tmpdir = request... | |
ff8cf64313e629b688d370768acac90273700a31 | python/function_sigtest.py | python/function_sigtest.py | # makes total sense
# syntax error in Python 2
# works in Python 3
def func(positional, *optional, defaulted='missing'):
print(positional, optional, defaulted)
func('first', 'second', 'third')
| Add function signature / argument specification oddity | Add function signature / argument specification oddity
| Python | mit | chbrown/sandbox,chbrown/sandbox,chbrown/sandbox,chbrown/sandbox,chbrown/sandbox,chbrown/sandbox,chbrown/sandbox,chbrown/sandbox,chbrown/sandbox,chbrown/sandbox | ---
+++
@@ -0,0 +1,8 @@
+# makes total sense
+# syntax error in Python 2
+# works in Python 3
+
+def func(positional, *optional, defaulted='missing'):
+ print(positional, optional, defaulted)
+
+func('first', 'second', 'third') | |
fd96efd8c4ec457d326a37a3b1a3f8f026c90bf6 | sara_flexbe_states/src/sara_flexbe_states/Wonderland_Add_Human.py | sara_flexbe_states/src/sara_flexbe_states/Wonderland_Add_Human.py | #!/usr/bin/env python
# encoding=utf8
import json
import requests
from flexbe_core import EventState, Logger
class Wonderland_Add_Human(EventState):
'''
Add an human to Wonderland. For the room, enter only ID or Name, not both.
Return the ID of the added human.
># name string name of the human
># ... | Create a state for add an human | Create a state for add an human
| Python | bsd-3-clause | WalkingMachine/sara_behaviors,WalkingMachine/sara_behaviors | ---
+++
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+# encoding=utf8
+
+import json
+import requests
+from flexbe_core import EventState, Logger
+
+
+class Wonderland_Add_Human(EventState):
+ '''
+ Add an human to Wonderland. For the room, enter only ID or Name, not both.
+ Return the ID of the added human.
+
+ ># name ... | |
89028d0d737a32edd165c1226e10ab764f6b0d41 | generate_data.py | generate_data.py | # DATA ACQUISITION
import pymongo
from bluesky import RunEngine
from bluesky.plans import scan
from bluesky.preprocessors import SupplementalData
from ophyd.sim import det, motor
class MongoInsertCallback:
"""
This is a replacmenet for db.insert.
"""
def __init__(self, uri):
self._uri = uri
... | Make a separate script for data generation. | Make a separate script for data generation.
| Python | bsd-3-clause | ericdill/databroker,ericdill/databroker | ---
+++
@@ -0,0 +1,52 @@
+# DATA ACQUISITION
+import pymongo
+from bluesky import RunEngine
+from bluesky.plans import scan
+from bluesky.preprocessors import SupplementalData
+from ophyd.sim import det, motor
+
+
+class MongoInsertCallback:
+ """
+ This is a replacmenet for db.insert.
+ """
+ def __init_... | |
f421f66cafa8d884af4ab2e4d43cad44743a6ffc | fun/necrodancer-shuffle.py | fun/necrodancer-shuffle.py | #!/usr/bin/env python3
import random
ZONES = 5
FLOORS = 3
BOSSES = [
'Deep Blues',
'King Conga',
'Death Metal',
'Coral Riff',
'Fortissimole',
]
SONGS = {
(1, 1): 'Disco Descent',
(1, 2): 'Crypteque',
(1, 3): 'Mausoleum Mash',
(2, 1): 'Fungal Funk',
(2, 2): 'Grave Throbbing',
... | Add Necrodancer floor shuffle script. | Add Necrodancer floor shuffle script.
| Python | mit | ammongit/scripts,ammongit/scripts,ammongit/scripts,ammongit/scripts | ---
+++
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+
+import random
+
+ZONES = 5
+FLOORS = 3
+
+BOSSES = [
+ 'Deep Blues',
+ 'King Conga',
+ 'Death Metal',
+ 'Coral Riff',
+ 'Fortissimole',
+]
+
+SONGS = {
+ (1, 1): 'Disco Descent',
+ (1, 2): 'Crypteque',
+ (1, 3): 'Mausoleum Mash',
+ (2, 1):... | |
e0bbbf6bc7ec1703b104dbb705fad8acdf818871 | neutron/db/migration/alembic_migrations/versions/3a520dd165d0_cisco_nexus_multi_switch.py | neutron/db/migration/alembic_migrations/versions/3a520dd165d0_cisco_nexus_multi_switch.py | # vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright 2013 OpenStack Foundation
#
# 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... | Add missing migration for fields in Cisco Nexus table | Add missing migration for fields in Cisco Nexus table
Change-Id: Ib31ec7f92d568c21d607b0bf003494acd1e3a3e8
Closes-bug: #1232360
| Python | apache-2.0 | gkotton/vmware-nsx,gkotton/vmware-nsx | ---
+++
@@ -0,0 +1,59 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+# Copyright 2013 OpenStack Foundation
+#
+# 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
+#
+# ht... | |
dbf438e65a038652adffe04dd43949dbbfb19b5c | samples/cdrom.py | samples/cdrom.py | import ipaddr
from devops.helpers.helpers import SSHClient
def one(manager):
environment = manager.environment_create('cdrom')
internal_pool = manager.create_network_pool(
networks=[ipaddr.IPNetwork('10.108.0.0/16')], prefix=24
)
private_pool = manager.create_network_pool(
networks=[ipa... | Add example with iso volume | Add example with iso volume
| Python | apache-2.0 | stackforge/fuel-devops,stackforge/fuel-devops | ---
+++
@@ -0,0 +1,51 @@
+import ipaddr
+from devops.helpers.helpers import SSHClient
+
+def one(manager):
+ environment = manager.environment_create('cdrom')
+ internal_pool = manager.create_network_pool(
+ networks=[ipaddr.IPNetwork('10.108.0.0/16')], prefix=24
+ )
+ private_pool = manager.create... | |
f3e8ffce89fe13dc46ba5f3823a1ef73d727c6f0 | scripts/flatten_content.py | scripts/flatten_content.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# This program flattens the content hierarchy of documents generated using the write_content function.
# It creates markdown versions from files named index.html in the directory content_new. New files get
# the name of their parent directory.
import os
from html2text impo... | Add script that creates markdown versions of content files and flattens the content directory structure. | Add script that creates markdown versions of content files and flattens the content directory structure.
| Python | mit | yaph/logya,elaOnMars/logya,elaOnMars/logya,elaOnMars/logya,yaph/logya | ---
+++
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# This program flattens the content hierarchy of documents generated using the write_content function.
+# It creates markdown versions from files named index.html in the directory content_new. New files get
+# the name of their parent directory... | |
cfb6e853b306b9b64293795b7f6f7dfe1ac334b3 | tests/config_decorator_test.py | tests/config_decorator_test.py | import unittest
import webracer
class ConfigDecoratorTest(unittest.TestCase):
def test_config_decorator(self):
@webracer.config(host='decoratortesthost', port=5544)
class test_class(webracer.WebTestCase):
def test_noop(self):
pass
instance = test_class('... | Test for multiple config decorators | Test for multiple config decorators
| Python | bsd-2-clause | p/webracer | ---
+++
@@ -0,0 +1,31 @@
+import unittest
+import webracer
+
+class ConfigDecoratorTest(unittest.TestCase):
+ def test_config_decorator(self):
+ @webracer.config(host='decoratortesthost', port=5544)
+ class test_class(webracer.WebTestCase):
+ def test_noop(self):
+ pass
+ ... | |
0c68ae4fe747b6eb1ee140e43409c469c2f07de3 | pidman/pid/migrations/0003_rm_invalidark_target_urlfield.py | pidman/pid/migrations/0003_rm_invalidark_target_urlfield.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pid', '0002_pid_sequence_initial_value'),
]
operations = [
migrations.DeleteModel(
name='InvalidArk',
),... | Add invalid ark and target uri field migration | Add invalid ark and target uri field migration
Not significant changes, but django complains about model changes
not matching otherwise.
| Python | apache-2.0 | emory-libraries/pidman,emory-libraries/pidman | ---
+++
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('pid', '0002_pid_sequence_initial_value'),
+ ]
+
+ operations = [
+ migrations.DeleteModel(
... | |
0a47c0b259dba0634e1287515c339e9a1e0306ae | folia2kaf.py | folia2kaf.py | """Create KAF file based on FoLiA file
Usage: python kaf2folia.py <file in>
"""
from pynlpl.formats import folia
from lxml import etree
# Load document
doc = folia.Document(file='medea-folia-no_events.xml')
# output document
root = etree.Element('KAF')
kaf_document = etree.ElementTree(root)
text = etree.SubElement(ro... | Add script to transform folia into kaf | Add script to transform folia into kaf
Added the first version of the script to transform folia xml into kaf.
The script is not finished, because it is still unknown what the folia
files will exactly look like.
| Python | apache-2.0 | NLeSC/embodied-emotions-scripts,NLeSC/embodied-emotions-scripts | ---
+++
@@ -0,0 +1,23 @@
+"""Create KAF file based on FoLiA file
+Usage: python kaf2folia.py <file in>
+"""
+from pynlpl.formats import folia
+from lxml import etree
+
+# Load document
+doc = folia.Document(file='medea-folia-no_events.xml')
+
+# output document
+root = etree.Element('KAF')
+kaf_document = etree.Eleme... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.