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 |
|---|---|---|---|---|---|---|---|---|---|---|
91e16cd265a04539f6eb8af5179a2b46262cbad1 | tests/test_registration.py | tests/test_registration.py | from aiosip import auth
AUTH = {
'auth_with_qop': 'Digest realm="asterisk",'
'nonce="1535646722/5d9e709c8f2ccd74601946bfbd77b032",'
'algorithm=md5,'
'qop="auth",'
'nc="00000001",'
'response="7aafeb20b391dfb0a... | Add the registration unit test | Add the registration unit test
| Python | apache-2.0 | Eyepea/aiosip | ---
+++
@@ -0,0 +1,48 @@
+from aiosip import auth
+
+
+AUTH = {
+ 'auth_with_qop': 'Digest realm="asterisk",'
+ 'nonce="1535646722/5d9e709c8f2ccd74601946bfbd77b032",'
+ 'algorithm=md5,'
+ 'qop="auth",'
+ 'nc="00000001",'
+ ... | |
ed1fde8b1dde1c7d9b7e7ef4554aaa38a202144c | registration/tps_gpu.py | registration/tps_gpu.py | from __future__ import division
import numpy as np
import pycuda.gpuarray as gpuarray
import pycuda.autoinit
import scikits.cuda.linalg as culinalg
culinalg.init()
def balance_matrix3_gpu(prob_nm, max_iter, row_priors, col_priors, outlierfrac, r_N = None):
n,m = prob_nm.shape
prob_NM = np.empty((n+1, m+1), '... | Add GPU version of balance_matrix3. | Add GPU version of balance_matrix3.
| Python | bsd-2-clause | wjchen84/lfd,rll/lfd,wjchen84/lfd,rll/lfd,rll/lfd,wjchen84/lfd | ---
+++
@@ -0,0 +1,43 @@
+from __future__ import division
+
+import numpy as np
+
+import pycuda.gpuarray as gpuarray
+import pycuda.autoinit
+import scikits.cuda.linalg as culinalg
+culinalg.init()
+
+def balance_matrix3_gpu(prob_nm, max_iter, row_priors, col_priors, outlierfrac, r_N = None):
+ n,m = prob_nm.shap... | |
9090c5243814b867257ee843eef6d46c44817eff | alexandria/models/record.py | alexandria/models/record.py | import datetime
from pyramid.compat import (
text_type,
binary_type
)
from .meta import (
Base,
DBSession,
)
from sqlalchemy import (
Column,
DateTime,
Enum,
ForeignKey,
Integer,
String,
Table,
Text,
... | Add the model for Records | Add the model for Records
| Python | isc | cdunklau/alexandria,cdunklau/alexandria,cdunklau/alexandria,bertjwregeer/alexandria,bertjwregeer/alexandria | ---
+++
@@ -0,0 +1,78 @@
+import datetime
+
+from pyramid.compat import (
+ text_type,
+ binary_type
+ )
+
+from .meta import (
+ Base,
+ DBSession,
+ )
+
+from sqlalchemy import (
+ Column,
+ DateTime,
+ Enum,
+ ForeignKey,
+ Integer,
+ ... | |
a4ab336cdfd8c65d627d39e90f5bb9a63b5572b6 | test/hoomd_script/test_option.py | test/hoomd_script/test_option.py | # -*- coding: iso-8859-1 -*-
# Maintainer: joaander
from hoomd_script import *
import unittest
import os
# unit tests for init.create_random
class init_create_random_tests (unittest.TestCase):
def setUp(self):
print
# tests that mode settings work properly
def test_mode(self):
option.... | Add script unit test for option | Add script unit test for option
resf #192
| Python | bsd-3-clause | joaander/hoomd-blue,joaander/hoomd-blue,joaander/hoomd-blue,joaander/hoomd-blue,joaander/hoomd-blue,joaander/hoomd-blue | ---
+++
@@ -0,0 +1,73 @@
+# -*- coding: iso-8859-1 -*-
+# Maintainer: joaander
+
+from hoomd_script import *
+import unittest
+import os
+
+# unit tests for init.create_random
+class init_create_random_tests (unittest.TestCase):
+ def setUp(self):
+ print
+
+ # tests that mode settings work properly
... | |
5cabd000e3a656ff372a4ba8b2865e2564eec903 | hug/documentation.py | hug/documentation.py | from collections import OrderedDict
import hug.types
def generate(module, base_url=""):
documentation = OrderedDict()
documenation['overview'] = module.__doc__
for url, method_handler in module.HUG_API_CALLS.items():
url_doc = documenation.setdefault(url, {})
mapping = OrderedDict()
... | Create initial api doc generator | Create initial api doc generator
| Python | mit | alisaifee/hug,alisaifee/hug,giserh/hug,jean/hug,gbn972/hug,MuhammadAlkarouri/hug,STANAPO/hug,gbn972/hug,janusnic/hug,yasoob/hug,MuhammadAlkarouri/hug,janusnic/hug,shaunstanislaus/hug,origingod/hug,MuhammadAlkarouri/hug,timothycrosley/hug,STANAPO/hug,origingod/hug,jean/hug,philiptzou/hug,yasoob/hug,timothycrosley/hug,sh... | ---
+++
@@ -0,0 +1,41 @@
+from collections import OrderedDict
+import hug.types
+
+
+def generate(module, base_url=""):
+ documentation = OrderedDict()
+ documenation['overview'] = module.__doc__
+ for url, method_handler in module.HUG_API_CALLS.items():
+ url_doc = documenation.setdefault(url, {})
+
... | |
8a1e4164b1dbcf8b17de638e915ed0fb4302707c | greenfan/management/commands/list-nodes.py | greenfan/management/commands/list-nodes.py | #
# Copyright 2012 Cisco Systems, Inc.
#
# Author: Soren Hansen <sorhanse@cisco.com>
#
# 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 a command to list participating nodes | Add a command to list participating nodes
| Python | apache-2.0 | sorenh/python-django-greenfan,sorenh/python-django-greenfan | ---
+++
@@ -0,0 +1,58 @@
+#
+# Copyright 2012 Cisco Systems, Inc.
+#
+# Author: Soren Hansen <sorhanse@cisco.com>
+#
+# 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
+#
+# h... | |
eb8a12371f97600e46614d199d08191ba367b825 | OpenPNM/Geometry/models/throat_perimeter.py | OpenPNM/Geometry/models/throat_perimeter.py | r"""
===============================================================================
Submodule -- throat_perimeter
===============================================================================
"""
def voronoi(geometry,
throat_perimeter='throat.perimeter',
**kwargs):
r"""
As the throat... | Create throat perimeter submodule to use with extrude | Create throat perimeter submodule to use with extrude
Signed-off-by: Tom Tranter <5f16e196b3c33003e3a85b835da4e658fd57e2ad@leeds.ac.uk>
| Python | mit | amdouglas/OpenPNM,amdouglas/OpenPNM,stadelmanma/OpenPNM,PMEAL/OpenPNM,TomTranter/OpenPNM | ---
+++
@@ -0,0 +1,16 @@
+r"""
+===============================================================================
+Submodule -- throat_perimeter
+===============================================================================
+
+"""
+def voronoi(geometry,
+ throat_perimeter='throat.perimeter',
+ *... | |
24df17e1c1265d81879a8f7e7a494cf4703dae69 | agent_test.py | agent_test.py | import time
import msvcrt
import zmq
from agent_pb2 import *
zctx = zmq.Context()
zsck_ctrl = zctx.socket(zmq.PUSH)
zsck_status = zctx.socket(zmq.SUB)
zsck_status.setsockopt(zmq.SUBSCRIBE, '')
zsck_ctrl.connect('tcp://127.0.0.1:17267')
zsck_status.connect('tcp://127.0.0.1:17268')
j = 0
while True:
cmd = msvcrt.... | Add simple manual test for remote control | Add simple manual test for remote control
| Python | mit | dkrikun/ffmpeg-rcd | ---
+++
@@ -0,0 +1,49 @@
+import time
+import msvcrt
+import zmq
+
+from agent_pb2 import *
+
+zctx = zmq.Context()
+zsck_ctrl = zctx.socket(zmq.PUSH)
+zsck_status = zctx.socket(zmq.SUB)
+zsck_status.setsockopt(zmq.SUBSCRIBE, '')
+
+zsck_ctrl.connect('tcp://127.0.0.1:17267')
+zsck_status.connect('tcp://127.0.0.1:1726... | |
30268d35e12224a8deee33fff78f7beabb4b4b79 | phi/math/_fit.py | phi/math/_fit.py | from ._shape import DimFilter, instance, shape
from ._tensors import Tensor
from ._ops import mean
def fit_line_2d(x: Tensor, y: Tensor, point_dim: DimFilter = instance, weights: Tensor = 1.):
"""
Fits a line of the form *slope · x + offset* to pass through the data points defined by their coordinates `x` and... | Add fit_line_2d (private for now) | [math] Add fit_line_2d (private for now)
| Python | mit | tum-pbs/PhiFlow,tum-pbs/PhiFlow | ---
+++
@@ -0,0 +1,35 @@
+from ._shape import DimFilter, instance, shape
+from ._tensors import Tensor
+from ._ops import mean
+
+
+def fit_line_2d(x: Tensor, y: Tensor, point_dim: DimFilter = instance, weights: Tensor = 1.):
+ """
+ Fits a line of the form *slope · x + offset* to pass through the data points d... | |
1a91b07ed22781f597a73fb6cf5c3391c5b691c1 | tests/run/pure_parallel.py | tests/run/pure_parallel.py | # mode: run
# tag: openmp, pure3.6
import cython
from cython.parallel import prange, parallel
def prange_regression(n: cython.int, data: list):
"""
>>> prange_regression(10, list(range(1, 4)))
19
"""
s: cython.int = 0
i: cython.int
d: cython.int[3] = data
for i in prange(n, num_threa... | Add a pure Python OpenMP test to make sure everything works from pure Python mode. | Add a pure Python OpenMP test to make sure everything works from pure Python mode.
| Python | apache-2.0 | cython/cython,da-woods/cython,scoder/cython,da-woods/cython,da-woods/cython,cython/cython,scoder/cython,da-woods/cython,cython/cython,cython/cython,scoder/cython,scoder/cython | ---
+++
@@ -0,0 +1,60 @@
+# mode: run
+# tag: openmp, pure3.6
+
+import cython
+from cython.parallel import prange, parallel
+
+
+def prange_regression(n: cython.int, data: list):
+ """
+ >>> prange_regression(10, list(range(1, 4)))
+ 19
+ """
+ s: cython.int = 0
+ i: cython.int
+ d: cython.int[3... | |
05ce9df1b02b98b163cadc9aed6cde34555d116e | compilebot/tests/run_all.py | compilebot/tests/run_all.py | # This script runs all of the suites from each unit test file.
# Run this file from the parent directory with the following command:
# python -m tests.run_all
from tests import *
import unittest
def main():
test_suites = [
test_reply.test_suite(),
test_compiler.test_suite()
]
all_tests ... | Add script to run all tests | Add script to run all tests
| Python | apache-2.0 | renfredxh/compilebot | ---
+++
@@ -0,0 +1,16 @@
+# This script runs all of the suites from each unit test file.
+# Run this file from the parent directory with the following command:
+# python -m tests.run_all
+from tests import *
+import unittest
+
+def main():
+ test_suites = [
+ test_reply.test_suite(),
+ test_compi... | |
d01799c33d442a8017b466db57afd15a852036a7 | dmoj/executors/mixins.py | dmoj/executors/mixins.py | import os
class NullStdoutMixin(object):
def __init__(self, *args, **kwargs):
self._devnull = open(os.devnull, 'w')
super(NullStdoutMixin, self).__init__(*args, **kwargs)
def cleanup(self):
if hasattr(self, '_devnull'):
self._devnull.close()
super(NullStdoutMixin, ... | Convert stdout redirection magic to a mixin. | Convert stdout redirection magic to a mixin.
| Python | agpl-3.0 | DMOJ/judge,DMOJ/judge,DMOJ/judge | ---
+++
@@ -0,0 +1,17 @@
+import os
+
+
+class NullStdoutMixin(object):
+ def __init__(self, *args, **kwargs):
+ self._devnull = open(os.devnull, 'w')
+ super(NullStdoutMixin, self).__init__(*args, **kwargs)
+
+ def cleanup(self):
+ if hasattr(self, '_devnull'):
+ self._devnull.c... | |
91dcfdfa7b3bcfdabaf5e23ed8ea2c64a0ae5240 | tests/filter/test_classbasedview_filterset.py | tests/filter/test_classbasedview_filterset.py | import pytest
from tests.apps.questions import models as question_models
from adhocracy4.filters.filters import ClassBasedViewFilterSet
from adhocracy4.filters.views import FilteredListView
class ExampleFilterSet(ClassBasedViewFilterSet):
class Meta:
model = question_models.Question
fields = ['te... | Add test for classbased view filters | Add test for classbased view filters
| Python | agpl-3.0 | liqd/adhocracy4,liqd/adhocracy4,liqd/adhocracy4,liqd/adhocracy4 | ---
+++
@@ -0,0 +1,42 @@
+import pytest
+from tests.apps.questions import models as question_models
+
+from adhocracy4.filters.filters import ClassBasedViewFilterSet
+from adhocracy4.filters.views import FilteredListView
+
+
+class ExampleFilterSet(ClassBasedViewFilterSet):
+ class Meta:
+ model = question_... | |
f4521d01fcb7a4f9f192ea932d103675e02a5ad9 | tests/integration/sts/openflow_buffer_test.py | tests/integration/sts/openflow_buffer_test.py | #!/usr/bin/env python
#
# Copyright 2011-2013 Colin Scott
#
# 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... | Add test for record_only mode | Add test for record_only mode
| Python | apache-2.0 | ucb-sts/sts,ucb-sts/sts,jmiserez/sts,jmiserez/sts | ---
+++
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+#
+# Copyright 2011-2013 Colin Scott
+#
+# 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... | |
9899fec1561d30a54279dd753114006f5e0e141c | src/functions/exercise4.py | src/functions/exercise4.py | # Define a function that print a lyrics and a function that repeat first operation 5 times.
def print_lyrics():
print "I'm a lumberjack, and I'm okay."
print "I sleep all night and I work all day."
def repl_lyrics():
for i in range(5):
print_lyrics()
def main():
print_lyrics()
... | Define a function that print a lyrics and a function that repeat first operation 5 times. | Define a function that print a lyrics and a function that repeat first operation 5 times.
| Python | mit | let42/python-course | ---
+++
@@ -0,0 +1,16 @@
+# Define a function that print a lyrics and a function that repeat first operation 5 times.
+
+def print_lyrics():
+ print "I'm a lumberjack, and I'm okay."
+ print "I sleep all night and I work all day."
+
+def repl_lyrics():
+ for i in range(5):
+ print_lyrics()
+
+def main... | |
017e7cae2aac65e405edf341c00a7052b8b13fa6 | minimal/ipython_notebook_config.py | minimal/ipython_notebook_config.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Configuration file for ipython-notebook.
c = get_config()
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888
# Whether to trust or not X-Scheme/X-Forwarded-Proto and X-Real-Ip/X-Forwarded-
# For headerssent by the upstream reverse proxy... | Set up an IPython config for the minimal image | Set up an IPython config for the minimal image
| Python | bsd-3-clause | mjbright/docker-demo-images,danielballan/docker-demo-images,Zsailer/docker-jupyter-teaching,odewahn/docker-demo-images,modulexcite/docker-demo-images,parente/docker-demo-images,CognitiveScale/docker-demo-images,ericdill/docker-demo-images,pelucid/docker-demo-images,willjharmer/docker-demo-images,CognitiveScale/docker-d... | ---
+++
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Configuration file for ipython-notebook.
+
+c = get_config()
+c.NotebookApp.ip = '*'
+c.NotebookApp.open_browser = False
+c.NotebookApp.port = 8888
+
+# Whether to trust or not X-Scheme/X-Forwarded-Proto and X-Real-Ip/X-Forwarded-
+# For he... | |
d8f1f40964eb4ca01f66a436a3e33bd1ec357fb3 | csunplugged/resources/views/binary_cards.py | csunplugged/resources/views/binary_cards.py | """Module for generating Binary Cards resource."""
from PIL import Image
def resource_image(get_request, resource):
"""Create a image for Binary Cards resource.
Args:
get_request: HTTP request object
resource: Object of resource data.
Returns:
A Pillow image object.
"""
... | Add basic binary card resource | Add basic binary card resource
| Python | mit | uccser/cs-unplugged,uccser/cs-unplugged,uccser/cs-unplugged,uccser/cs-unplugged | ---
+++
@@ -0,0 +1,49 @@
+"""Module for generating Binary Cards resource."""
+
+from PIL import Image
+
+
+def resource_image(get_request, resource):
+ """Create a image for Binary Cards resource.
+
+ Args:
+ get_request: HTTP request object
+ resource: Object of resource data.
+
+ Returns:
+ ... | |
eb0278b8360ad677aa66a6b1d9fc4fb9bd77f553 | localore/people/migrations/0004_auto_20160314_2320.py | localore/people/migrations/0004_auto_20160314_2320.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('people', '0003_auto_20160310_2235'),
]
operations = [
migrations.AlterModelOptions(
name='person',
o... | Add missed db migration for 50b7b53 | Add missed db migration for 50b7b53
| Python | mpl-2.0 | ghostwords/localore,ghostwords/localore,ghostwords/localore | ---
+++
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('people', '0003_auto_20160310_2235'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(... | |
46bc6d5892fd051428ace19fea8c763a1376a2e1 | cookiecutter/environment.py | cookiecutter/environment.py | # -*- coding: utf-8 -*-
from jinja2 import Environment, StrictUndefined
class StrictEnvironment(Environment):
"""Jinja2 environment that raises an error when it hits a variable
which is not defined in the context used to render a template.
"""
def __init__(self, **kwargs):
super(StrictEnviron... | Implement a strict subclass of jinja2 Environment | Implement a strict subclass of jinja2 Environment
| Python | bsd-3-clause | luzfcb/cookiecutter,audreyr/cookiecutter,dajose/cookiecutter,pjbull/cookiecutter,audreyr/cookiecutter,willingc/cookiecutter,hackebrot/cookiecutter,dajose/cookiecutter,Springerle/cookiecutter,hackebrot/cookiecutter,terryjbates/cookiecutter,willingc/cookiecutter,stevepiercy/cookiecutter,pjbull/cookiecutter,Springerle/coo... | ---
+++
@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+
+from jinja2 import Environment, StrictUndefined
+
+
+class StrictEnvironment(Environment):
+ """Jinja2 environment that raises an error when it hits a variable
+ which is not defined in the context used to render a template.
+ """
+ def __init__(self, *... | |
f344ba9bbc9d607c10bbed853f041003c5eacfad | scripts/ipcthreadtrace.py | scripts/ipcthreadtrace.py | """
ipctrace.py
Write a trace of instantaneous IPC values for all cores.
First argument is either a filename, or none to write to standard output.
Second argument is the interval size in nanoseconds (default is 10000)
"""
import sys, os, sim
class IpcTrace:
def setup(self, args):
self.freq = sim.dvfs.get_frequ... | Add a per-thread IPC tracing script. It currently handles scheduling / oversubscription but not DVFS | [scripts] Add a per-thread IPC tracing script. It currently handles scheduling / oversubscription but not DVFS
| Python | mit | abanaiyan/sniper,abanaiyan/sniper,abanaiyan/sniper,abanaiyan/sniper,abanaiyan/sniper | ---
+++
@@ -0,0 +1,50 @@
+"""
+ipctrace.py
+
+Write a trace of instantaneous IPC values for all cores.
+First argument is either a filename, or none to write to standard output.
+Second argument is the interval size in nanoseconds (default is 10000)
+"""
+
+import sys, os, sim
+
+class IpcTrace:
+ def setup(self, ar... | |
23d2fab545b2b384cb8f4d75932550252336131a | possel/irc.py | possel/irc.py | #!/usr/bin/env python3
# -*- coding: utf8 -*-
from tornado import ioloop, gen, tcpclient
loopinstance = ioloop.IOLoop.instance()
def split_irc_line(s):
"""Breaks a message from an IRC server into its prefix, command, and arguments.
"""
prefix = ''
trailing = []
if not s:
# Raise an excep... | Add rudiments of an IRC library using IOStream | Add rudiments of an IRC library using IOStream
| Python | bsd-3-clause | possel/possel,possel/possel,possel/possel,possel/possel | ---
+++
@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+# -*- coding: utf8 -*-
+
+from tornado import ioloop, gen, tcpclient
+
+loopinstance = ioloop.IOLoop.instance()
+
+
+def split_irc_line(s):
+ """Breaks a message from an IRC server into its prefix, command, and arguments.
+ """
+ prefix = ''
+ trailing = [... | |
5e18840ef328c18babe53dc38ee6baa4302a22f0 | Cura/slice/cura_sf/fabmetheus_utilities/fabmetheus_tools/interpret_plugins/amf.py | Cura/slice/cura_sf/fabmetheus_utilities/fabmetheus_tools/interpret_plugins/amf.py | from __future__ import absolute_import
import zipfile
try:
from xml.etree import cElementTree as ElementTree
except:
from xml.etree import ElementTree
from fabmetheus_utilities.geometry.geometry_tools import face
from fabmetheus_utilities.geometry.solids import triangle_mesh
from fabmetheus_utilities.vector3 import... | Add basic AMF support to skeinforge. | Add basic AMF support to skeinforge.
| Python | agpl-3.0 | alephobjects/Cura,alephobjects/Cura,alephobjects/Cura | ---
+++
@@ -0,0 +1,72 @@
+from __future__ import absolute_import
+
+import zipfile
+try:
+ from xml.etree import cElementTree as ElementTree
+except:
+ from xml.etree import ElementTree
+
+from fabmetheus_utilities.geometry.geometry_tools import face
+from fabmetheus_utilities.geometry.solids import triangle_mesh
+fr... | |
98c019c2328f4524019bf3a8cfb2e40842e2c7c7 | examples/example_maxent.py | examples/example_maxent.py | from __future__ import print_function
import dit
import numpy as np
# The functions will import this for you...just make sure you have it.
import cvxopt
def print_output(d, maxent_dists):
# Calculate the entropy for each.
entropies = np.asarray(map(dit.shannon.entropy, maxent_dists))
print()
print("E... | Add an example script for maxent. | Add an example script for maxent.
| Python | bsd-3-clause | Autoplectic/dit,chebee7i/dit,dit/dit,dit/dit,Autoplectic/dit,chebee7i/dit,chebee7i/dit,Autoplectic/dit,dit/dit,Autoplectic/dit,dit/dit,dit/dit,chebee7i/dit,Autoplectic/dit | ---
+++
@@ -0,0 +1,69 @@
+from __future__ import print_function
+
+import dit
+import numpy as np
+
+# The functions will import this for you...just make sure you have it.
+import cvxopt
+
+def print_output(d, maxent_dists):
+ # Calculate the entropy for each.
+ entropies = np.asarray(map(dit.shannon.entropy, m... | |
9ce9152fc6a610505b055d2648ba3f0bf99dd153 | opencivicdata/elections/migrations/0002_auto_20170731_2047.py | opencivicdata/elections/migrations/0002_auto_20170731_2047.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-31 20:47
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('elections', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
... | Add missing migration after editing meta options | Add missing migration after editing meta options
| Python | bsd-3-clause | opencivicdata/python-opencivicdata,opencivicdata/python-opencivicdata,opencivicdata/python-opencivicdata-django,opencivicdata/python-opencivicdata-django,opencivicdata/python-opencivicdata-django | ---
+++
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.3 on 2017-07-31 20:47
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('elections', '0001_initial'),
+ ]
+
+ operations = [
+ ... | |
f629b836aad3c06a387416c9a407df722d65d89a | py/subarray-product-less-than-k.py | py/subarray-product-less-than-k.py | class Solution(object):
def numSubarrayProductLessThanK(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: int
"""
ans = 0
subproduct = 1
if k <= 1:
return 0
start, end = 0, 0
while start < len(nums) or end < len... | Add py solution for 713. Subarray Product Less Than K | Add py solution for 713. Subarray Product Less Than K
713. Subarray Product Less Than K: https://leetcode.com/problems/subarray-product-less-than-k/
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,24 @@
+class Solution(object):
+ def numSubarrayProductLessThanK(self, nums, k):
+ """
+ :type nums: List[int]
+ :type k: int
+ :rtype: int
+ """
+ ans = 0
+ subproduct = 1
+ if k <= 1:
+ return 0
+ start, end = 0, 0
+ ... | |
613318672bf05b76feedc26d7ed06a773cc9faf7 | card_match_v3.py | card_match_v3.py | import pyglet
def draw_card():
pyglet.graphics.draw(4,
pyglet.gl.GL_QUADS,
('v2i', (get_card_vertices()))
)
def get_card_width():
return 300
def get_card_height():
return 200
def get_card_vertices():
card_width = get_card... | Add card match v3 python file | 3: Add card match v3 python file
| Python | mit | SingingTree/CardMatchPyglet | ---
+++
@@ -0,0 +1,51 @@
+import pyglet
+
+
+def draw_card():
+ pyglet.graphics.draw(4,
+ pyglet.gl.GL_QUADS,
+ ('v2i', (get_card_vertices()))
+ )
+
+
+def get_card_width():
+ return 300
+
+
+def get_card_height():
+ return 200
+
+
+def ... | |
ff1b1f8c61ea14c598443b54024357dc05d4dda2 | shapes.py | shapes.py | #Create a function to get a mesh file 'f'
def getMesh(fname):
#Open the file
f = open(fname, "r")
#Store the lines as a list
f = list(f)
#Strip newlines from the list
for l in range(len(f)):
f[l] = f[l].replace("\n","")
#Store the number of vertices, edges and sides
v = int(f[0])
e = int(f[1])
s = i... | Write function to read in vertices, edges and sides from file. | Write function to read in vertices, edges and sides from file.
| Python | mit | thebillington/pyPhys3D | ---
+++
@@ -0,0 +1,59 @@
+#Create a function to get a mesh file 'f'
+def getMesh(fname):
+
+ #Open the file
+ f = open(fname, "r")
+
+ #Store the lines as a list
+ f = list(f)
+
+ #Strip newlines from the list
+ for l in range(len(f)):
+ f[l] = f[l].replace("\n","")
+
+ #Store the number of vertices, edges and s... | |
7a53db57a8394891e11d6bbeb051964960662dfb | semabot_tools.py | semabot_tools.py | from flow import Flow
from config import BOTNAME, BOTPW, ORG_ID
try:
flow = Flow(BOTNAME)
except flow.FlowError as e:
flow = Flow()
flow.create_device(BOTNAME, BOTPW)
print('Device for bot {} created'.format(BOTNAME))
def print_channels():
print('\033[1mYour bot "{}" has access to these channels:... | Add tool for printing channel IDs | Add tool for printing channel IDs
| Python | mit | datamade/semabot,datamade/semabot | ---
+++
@@ -0,0 +1,19 @@
+from flow import Flow
+
+from config import BOTNAME, BOTPW, ORG_ID
+
+try:
+ flow = Flow(BOTNAME)
+except flow.FlowError as e:
+ flow = Flow()
+ flow.create_device(BOTNAME, BOTPW)
+ print('Device for bot {} created'.format(BOTNAME))
+
+def print_channels():
+ print('\033[1mYou... | |
411fa5e1a0af79bcd442544571fbea7ba24b8266 | spec/Report_S09_spec.py | spec/Report_S09_spec.py | from expects import expect, equal
from primestg.report import Report
from ast import literal_eval
with description('Report S09 example'):
with before.all:
self.data_filename_no_event_data = \
'spec/data/ZIV0000034180_0_S09_0_20161216104003'
# self.data_filename_with_event_data_D1 = \
... | Add first tests for S09 report reading | Add first tests for S09 report reading
| Python | agpl-3.0 | gisce/primestg | ---
+++
@@ -0,0 +1,60 @@
+from expects import expect, equal
+from primestg.report import Report
+from ast import literal_eval
+
+with description('Report S09 example'):
+ with before.all:
+
+ self.data_filename_no_event_data = \
+ 'spec/data/ZIV0000034180_0_S09_0_20161216104003'
+ # self.d... | |
f27a0ef659058789a75671582248c1fb12c30b6c | src/mmw/apps/bigcz/clients/usgswqp/models.py | src/mmw/apps/bigcz/clients/usgswqp/models.py | # -*- coding: utf-8 -*-
from __future__ import (absolute_import,
division,
print_function,
unicode_literals)
from apps.bigcz.models import Resource
class USGSResource(Resource):
def __init__(self, id, description, author, links, title,
... | Initialize USGSResource object model to be similar to cuahsi | Initialize USGSResource object model to be similar to cuahsi
| Python | apache-2.0 | WikiWatershed/model-my-watershed,WikiWatershed/model-my-watershed,WikiWatershed/model-my-watershed,WikiWatershed/model-my-watershed,WikiWatershed/model-my-watershed | ---
+++
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+from __future__ import (absolute_import,
+ division,
+ print_function,
+ unicode_literals)
+
+from apps.bigcz.models import Resource
+
+
+class USGSResource(Resource):
+ def __init__(self, id, de... | |
36950cb7192f81c27d7a78376274f0183e8ec999 | spec/openpassword/fudge_wrapper.py | spec/openpassword/fudge_wrapper.py | import fudge
import inspect
class MethodNotAvailableInMockedObjectException(Exception):
pass
def getMock(class_to_mock):
return FudgeWrapper(class_to_mock)
class FudgeWrapper(fudge.Fake):
def __init__(self, class_to_mock):
self._class_to_mock = class_to_mock
self._declared_calls = {}
... | Add wrapper for fudge to allow mock checks | Add wrapper for fudge to allow mock checks
Add wrapper to add mock checks on fudge, to prevent
the mock from getting out of sync with the real object.
| Python | mit | openpassword/blimey,openpassword/blimey | ---
+++
@@ -0,0 +1,26 @@
+import fudge
+import inspect
+
+
+class MethodNotAvailableInMockedObjectException(Exception):
+ pass
+
+
+def getMock(class_to_mock):
+ return FudgeWrapper(class_to_mock)
+
+
+class FudgeWrapper(fudge.Fake):
+ def __init__(self, class_to_mock):
+ self._class_to_mock = class_t... | |
890f906ec023e25b85990bcfefca4353d06916ce | src/get_botid.py | src/get_botid.py | import os
from slackclient import SlackClient
"""
Returns the id of the movie slackbot
"""
SLACK_BOT_TOKEN = os.environ.get('SLACK_BOT_TOKEN')
BOT_NAME = 'moebot'
bot_found = False
try:
slack_client = SlackClient(SLACK_BOT_TOKEN)
except:
print "Connection error"
#calling the api to get a list of all users in ... | Add code for fetching bot id | Add code for fetching bot id
Python code for getting the id of your Slack bot | Python | mit | SaishRedkar/FilmyBot | ---
+++
@@ -0,0 +1,39 @@
+import os
+from slackclient import SlackClient
+
+"""
+Returns the id of the movie slackbot
+
+"""
+
+
+SLACK_BOT_TOKEN = os.environ.get('SLACK_BOT_TOKEN')
+BOT_NAME = 'moebot'
+
+bot_found = False
+
+try:
+ slack_client = SlackClient(SLACK_BOT_TOKEN)
+except:
+ print "Connection error"
+
+ ... | |
db7a52cb9392f3cb9dc82323ff60cf9871dafbda | rename_files.py | rename_files.py | import os
import string
def list_files(path):
# returns a list of names (with extension, without full path) of all files
# in folder path
files = []
for name in os.listdir(path):
if os.path.isfile(os.path.join(path, name)):
files.append(name)
return files
files = list_files("... | Add script to rename files in a directory. | Add script to rename files in a directory.
| Python | isc | wablair/misc_scripts,wablair/misc_scripts,wablair/misc_scripts,wablair/misc_scripts | ---
+++
@@ -0,0 +1,20 @@
+import os
+import string
+
+def list_files(path):
+ # returns a list of names (with extension, without full path) of all files
+ # in folder path
+ files = []
+ for name in os.listdir(path):
+ if os.path.isfile(os.path.join(path, name)):
+ files.append(name)
+ ... | |
8e8352d53e9c446d908e90424bc2fb0bf7d7f587 | app_builder/app_builder_image/concat_roles.py | app_builder/app_builder_image/concat_roles.py | import glob
import os
import shutil
import subprocess
import yaml
def create_role(role):
ret = subprocess.check_output(
'ansible-galaxy init {}'.format(role).split())
if not ret.strip().endswith('created successfully'):
raise Exception('could not create role "{}"'.format(role))
def get_meta... | Add script to compose roles | Add script to compose roles
| Python | mit | waltermoreira/dockeransible,waltermoreira/dockeransible | ---
+++
@@ -0,0 +1,78 @@
+import glob
+import os
+import shutil
+import subprocess
+
+import yaml
+
+
+def create_role(role):
+ ret = subprocess.check_output(
+ 'ansible-galaxy init {}'.format(role).split())
+ if not ret.strip().endswith('created successfully'):
+ raise Exception('could not create... | |
5e270a34e2c7787459f307e957161aadd8d24476 | run_checks.py | run_checks.py | import os
from pre_push import run_checks
filepath = os.path.dirname(os.path.abspath(__file__))
project_root = os.path.join(filepath, "..")
if __name__ == "__main__":
run_checks(project_root)
| Add separate script to run checks from jenkins | Add separate script to run checks from jenkins
| Python | mit | kriskavalieri/nodejs-docker-boilerplate,kriskavalieri/nodejs-docker-boilerplate | ---
+++
@@ -0,0 +1,8 @@
+import os
+from pre_push import run_checks
+
+filepath = os.path.dirname(os.path.abspath(__file__))
+project_root = os.path.join(filepath, "..")
+
+if __name__ == "__main__":
+ run_checks(project_root) | |
779d8478fd05fe50ea7dccd55e98ae82ac609d32 | s3Uploader.py | s3Uploader.py | # -*- coding: utf-8 -*-
import botocore
import boto3
from datetime import datetime
class s3Uploader():
def __init__(self, bucketName, objectName, filePath):
self.__bucketName = bucketName
self.__objectName = objectName
self.__filePath = filePath
self.__s3 = boto3.client('s3')... | Add s3 uploader class from awsSample repository. | Add s3 uploader class from awsSample repository.
| Python | mit | hondasports/Bun-chan-Bot,hondasports/Bun-chan-Bot | ---
+++
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+
+import botocore
+import boto3
+from datetime import datetime
+
+
+class s3Uploader():
+
+ def __init__(self, bucketName, objectName, filePath):
+ self.__bucketName = bucketName
+ self.__objectName = objectName
+ self.__filePath = filePat... | |
da3abf4adc5ac7095e47d07dc1c448c6e7fc20a1 | tests/test_publish2cloud.py | tests/test_publish2cloud.py | import time
from mock import mock_open, patch
from publish2cloud import chunk_metadata
def test_chunk_metadata():
"""Test getting metadata from the chunk header of a list file."""
chunknum = int(time.time())
# Hash of test-track-digest256.dummytracker.org/
domain_hash = (b"q\xd8Q\xbe\x8b#\xad\xd9\xd... | Add unit test for chunk_metadata | Add unit test for chunk_metadata
| Python | mpl-2.0 | mozilla-services/shavar-list-creation | ---
+++
@@ -0,0 +1,25 @@
+import time
+
+from mock import mock_open, patch
+
+from publish2cloud import chunk_metadata
+
+
+def test_chunk_metadata():
+ """Test getting metadata from the chunk header of a list file."""
+ chunknum = int(time.time())
+ # Hash of test-track-digest256.dummytracker.org/
+ doma... | |
c97d3657fe3d3091458bbffcc070970cf949a459 | tests/test_routes_static.py | tests/test_routes_static.py | from .conftest import load
class TestStatic:
def test_get_index(self, client):
response = client.get("/")
assert response.status_code == 200
assert 'href="/api"' in load(response, as_json=False)
| Add a test for getting the homepage | Add a test for getting the homepage
| Python | mit | joshfriend/memegen,DanLindeman/memegen,joshfriend/memegen,DanLindeman/memegen,joshfriend/memegen,joshfriend/memegen,DanLindeman/memegen,DanLindeman/memegen | ---
+++
@@ -0,0 +1,9 @@
+from .conftest import load
+
+
+class TestStatic:
+
+ def test_get_index(self, client):
+ response = client.get("/")
+ assert response.status_code == 200
+ assert 'href="/api"' in load(response, as_json=False) | |
e97d8977b2c55c35030c3653dbddc7b4830b7f3f | tests/test_integration.py | tests/test_integration.py | import os
import tempfile
import vimrunner
from tasklib.task import TaskWarrior, Task
server = vimrunner.Server()
class TestIntegration(object):
def add_plugin(self, name):
plugin_base = os.path.expanduser('~/.vim/bundle/')
plugin_path = os.path.join(plugin_base, name)
self.client.add_pl... | Add basic integration tests using vimrunner | test: Add basic integration tests using vimrunner
| Python | mit | phha/taskwiki,Spirotot/taskwiki | ---
+++
@@ -0,0 +1,73 @@
+import os
+import tempfile
+import vimrunner
+
+from tasklib.task import TaskWarrior, Task
+
+server = vimrunner.Server()
+
+class TestIntegration(object):
+
+ def add_plugin(self, name):
+ plugin_base = os.path.expanduser('~/.vim/bundle/')
+ plugin_path = os.path.join(plugi... | |
4e161fd1ef64b9682d2d73ce413fdb68fbff9f85 | tests/test_javascript_solutions.py | tests/test_javascript_solutions.py | import glob
import json
import os
import pytest
from helpers import solutions_dir
# NOTE: If we make solution_files a fixture instead of a normal attr/function,
# then we can't use it in pytest's parametrize
solution_files = glob.glob(os.path.join(solutions_dir("javascript"), "*.js"))
@pytest.mark.javascript
def ... | Add separate test file for javascript | Add separate test file for javascript
| Python | mit | project-lovelace/lovelace-engine,project-lovelace/lovelace-engine,project-lovelace/lovelace-engine | ---
+++
@@ -0,0 +1,32 @@
+import glob
+import json
+import os
+
+import pytest
+
+from helpers import solutions_dir
+
+
+# NOTE: If we make solution_files a fixture instead of a normal attr/function,
+# then we can't use it in pytest's parametrize
+solution_files = glob.glob(os.path.join(solutions_dir("javascript"), ... | |
01625ec37806aa5fb9cdcf5e1ac92abf54aff4c9 | plugins/CuraEngineBackend/ProcessGCodeJob.py | plugins/CuraEngineBackend/ProcessGCodeJob.py | from UM.Job import Job
from UM.Application import Application
import os
class ProcessGCodeJob(Job):
def __init__(self, message):
super().__init__()
self._message = message
def run(self):
with open(self._message.filename) as f:
data = f.read(None)
Application.g... | Add a job to handle processing of GCode from the backend | Add a job to handle processing of GCode from the backend
| Python | agpl-3.0 | onitake/Uranium,onitake/Uranium | ---
+++
@@ -0,0 +1,17 @@
+from UM.Job import Job
+from UM.Application import Application
+
+import os
+
+class ProcessGCodeJob(Job):
+ def __init__(self, message):
+ super().__init__()
+
+ self._message = message
+
+ def run(self):
+ with open(self._message.filename) as f:
+ data... | |
bd315146db332bc92cf7d613ff8b8923a60d320f | src/manga2.py | src/manga2.py | import argparse
import itertools
from redux.helper.util import Util
from redux.site.mangafox import MangaFox
from redux.site.mangahere import MangaHere
from redux.site.mangapanda import MangaPanda
from redux.site.mangareader import MangaReader
def main():
parser = argparse.ArgumentParser(description='Download ma... | Add script using new library that can list chapters and titles of a series. | Add script using new library that can list chapters and titles of a series.
| Python | mit | jiaweihli/manga_downloader,joaquinpf/manga_downloader,CharlieCorner/manga_downloader,alexforsale/manga_downloader | ---
+++
@@ -0,0 +1,56 @@
+import argparse
+import itertools
+
+from redux.helper.util import Util
+from redux.site.mangafox import MangaFox
+from redux.site.mangahere import MangaHere
+from redux.site.mangapanda import MangaPanda
+from redux.site.mangareader import MangaReader
+
+
+def main():
+ parser = argparse.... | |
4e054b93bda5f7615c07142823fa111908ba157e | driver_station/src/ui/widgets/camera_widget.py | driver_station/src/ui/widgets/camera_widget.py |
import cv_widget
class CameraWidget(cv_widget.CvWidget):
def __init__(self, fixed_size):
cv_widget.CvWidget.__init__(self, fixed_size)
def set_error(self):
pass
def set_target_data(self, data):
img, data = data
self.set_from_np(img)
... | Add in camera widget, not complete yet | Add in camera widget, not complete yet
| Python | bsd-3-clause | frc1418/2014 | ---
+++
@@ -0,0 +1,17 @@
+
+import cv_widget
+
+class CameraWidget(cv_widget.CvWidget):
+
+ def __init__(self, fixed_size):
+ cv_widget.CvWidget.__init__(self, fixed_size)
+
+ def set_error(self):
+ pass
+
+ def set_target_data(self, data):
+ img, data = data
+
+ ... | |
3ff8b3de2b9f0d1de1414bad12d06d931e7919cd | utils/create_tree_from_metadata.py | utils/create_tree_from_metadata.py | #!/usr/bin/env python
"""
A utility to create a Girder hierarchy from metadata.json.
Useful in testing the monkeybrains plugin to set up a hierarchy,
then set_metadata.py can be run to add the metadata.
"""
import argparse
import json
import requests.packages.urllib3
from girder_client import GirderClient
requests... | Add utility to create test tree | Add utility to create test tree
| Python | apache-2.0 | girder/monkeybrains,girder/monkeybrains,girder/monkeybrains | ---
+++
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+"""
+A utility to create a Girder hierarchy from metadata.json.
+
+Useful in testing the monkeybrains plugin to set up a hierarchy,
+then set_metadata.py can be run to add the metadata.
+"""
+
+import argparse
+import json
+
+import requests.packages.urllib3
+
+from gi... | |
97df2e612f58bf7e0badb6da8bd564a98ac74355 | tools/gen_rtorrent_doc.py | tools/gen_rtorrent_doc.py | import sys
sys.path.insert(0, '..')
import model.rtorrent as rtorrent
import model.torrent as torrent
import model.peer as peer
for d in (rtorrent, torrent, peer):
for x, y in d._rpc_methods.iteritems():
print y[0], y[1]
#print y[0], '\n', y[1]
| Add rtorrent plaintext doc generator. | Tools: Add rtorrent plaintext doc generator.
| Python | agpl-3.0 | MerlijnWajer/pyroTorrent,MerlijnWajer/pyroTorrent | ---
+++
@@ -0,0 +1,12 @@
+import sys
+sys.path.insert(0, '..')
+
+import model.rtorrent as rtorrent
+import model.torrent as torrent
+import model.peer as peer
+
+
+for d in (rtorrent, torrent, peer):
+ for x, y in d._rpc_methods.iteritems():
+ print y[0], y[1]
+ #print y[0], '\n', y[1] | |
a784fd2f12328c9a200c48e72d68ca1ff3709316 | tests/IsGrammarGeneratingTest.py | tests/IsGrammarGeneratingTest.py | #!/usr/bin/env python
"""
:Author Patrik Valkovic
:Created 23.06.2017 16:39
:Licence GNUv3
Part of grammpy-transforms
"""
from unittest import TestCase, main
from grammpy import *
from grammpy_transforms import *
class IsGrammarGeneratingTest(TestCase):
pass
if __name__ == '__main__':
main()
| Add file for test if is grammar generating | Add file for test if is grammar generating
| Python | mit | PatrikValkovic/grammpy | ---
+++
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+"""
+:Author Patrik Valkovic
+:Created 23.06.2017 16:39
+:Licence GNUv3
+Part of grammpy-transforms
+
+"""
+
+from unittest import TestCase, main
+from grammpy import *
+from grammpy_transforms import *
+
+
+class IsGrammarGeneratingTest(TestCase):
+ pass
+
+
+if __... | |
2341e59f7e93865ebe6816db1c6c79c84a3d09cc | setup.py | setup.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from distutils.core import setup
setup(
name='regulations-parser',
url='https://github.com/cfpb/regulations-parser',
author='CFPB',
author_email='tech@cfpb.gov',
license='CC0',
version='0.1.0',
description='eCFR Parser for eRegulation... | Make the parser an installable Python package | Make the parser an installable Python package
| Python | cc0-1.0 | grapesmoker/regulations-parser | ---
+++
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os
+from distutils.core import setup
+
+setup(
+ name='regulations-parser',
+ url='https://github.com/cfpb/regulations-parser',
+ author='CFPB',
+ author_email='tech@cfpb.gov',
+ license='CC0',
+ version='0.1.0',
+ ... | |
fd423fa583c251c2c097bf6905b6803945698db6 | resource/maya/userSetup.py | resource/maya/userSetup.py | # :coding: utf-8
# :copyright: Copyright (c) 2013 Martin Pengelly-Phillips
# :license: See LICENSE.txt.
import maya.utils as utils
import pymel.core
def setup():
'''Configure Segue and add to a default menu.'''
pymel.core.menu(
label='Segue',
tearOff=True,
parent='MayaWindow'
)
... | Add default menu that can be enabled in Maya to launch exporter. | Add default menu that can be enabled in Maya to launch exporter.
| Python | apache-2.0 | 4degrees/segue | ---
+++
@@ -0,0 +1,36 @@
+# :coding: utf-8
+# :copyright: Copyright (c) 2013 Martin Pengelly-Phillips
+# :license: See LICENSE.txt.
+
+import maya.utils as utils
+import pymel.core
+
+
+def setup():
+ '''Configure Segue and add to a default menu.'''
+ pymel.core.menu(
+ label='Segue',
+ tearOff=Tr... | |
2af82e36c9a60613b91ca88b9768eabd4378af11 | tensorflow-samples/conv2d-numpy.py | tensorflow-samples/conv2d-numpy.py | from __future__ import print_function
import numpy as np
# Tensorflow is used to verify the results of numpy computations - you can
# remove its usage if you don't need the testing.
import tensorflow as tf
def conv2d_single_channel(input, w):
boundary_width = w.shape[0] // 2
padded_input = np.pad(input,
... | Add numpy implementation of simple 2d conv, with TF verification | Add numpy implementation of simple 2d conv, with TF verification
| Python | unlicense | eliben/deep-learning-samples,eliben/deep-learning-samples | ---
+++
@@ -0,0 +1,48 @@
+from __future__ import print_function
+import numpy as np
+
+# Tensorflow is used to verify the results of numpy computations - you can
+# remove its usage if you don't need the testing.
+import tensorflow as tf
+
+
+def conv2d_single_channel(input, w):
+ boundary_width = w.shape[0] // 2
... | |
7d08d7cc2a34e5e9a330c574a645cf94ab3d184b | python/read_yaml_safely.py | python/read_yaml_safely.py | """
Read a YAML file or stream safely.
"""
from pathlib import Path
def read_yaml_safely(filelike):
""" Read a YAML file or stream with no RCE backdoors open (using the ‘safe’ loader).
``filelike`` can be a path or an open handle (supporting ``read()``).
Supports a fallback chain of parsers ... | Read a YAML file or stream safely | Python3: Read a YAML file or stream safely
| Python | unlicense | jhermann/waif,jhermann/waif | ---
+++
@@ -0,0 +1,62 @@
+"""
+ Read a YAML file or stream safely.
+"""
+
+from pathlib import Path
+
+def read_yaml_safely(filelike):
+ """ Read a YAML file or stream with no RCE backdoors open (using the ‘safe’ loader).
+
+ ``filelike`` can be a path or an open handle (supporting ``read()``).
+
+ ... | |
81adf67267e77202bc5890840631181ffb52fd3d | tests/font/BULLET.py | tests/font/BULLET.py | #!/usr/bin/env python
'''Test that font.Text horizontal alignment works.
Three labels will be rendered aligned left, center and right.
'''
__docformat__ = 'restructuredtext'
__version__ = '$Id: $'
import unittest
from pyglet import font
import base_text
class TEST_HALIGN(base_text.TextTestBase):
font_name = ... | Test case for incorrect rendering of bullet noticed in a wydget test case. | Test case for incorrect rendering of bullet noticed in a wydget test case.
| Python | bsd-3-clause | niklaskorz/pyglet,seeminglee/pyglet64,niklaskorz/pyglet,seeminglee/pyglet64,adamlwgriffiths/Pyglet,seeminglee/pyglet64,niklaskorz/pyglet,adamlwgriffiths/Pyglet,adamlwgriffiths/Pyglet,adamlwgriffiths/Pyglet,niklaskorz/pyglet | ---
+++
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+'''Test that font.Text horizontal alignment works.
+
+Three labels will be rendered aligned left, center and right.
+'''
+
+__docformat__ = 'restructuredtext'
+__version__ = '$Id: $'
+
+import unittest
+
+from pyglet import font
+
+import base_text
+
+class TEST_HALI... | |
b7ede20d4e82b5aba701dd02c49ca8a5fe00e0ed | dimagi/utils/prime_views.py | dimagi/utils/prime_views.py | def prime_views(pool_size):
"""
Prime the views so that a very large import doesn't cause the index
to get too far behind
"""
# These have to be included here or ./manage.py runserver explodes on
# all pages of the app with single thread related errors
from gevent.pool import Pool
from ... | Move prime views method in | Move prime views method in
| Python | bsd-3-clause | qedsoftware/commcare-hq,dimagi/commcare-hq,puttarajubr/commcare-hq,qedsoftware/commcare-hq,qedsoftware/commcare-hq,dimagi/commcare-hq,qedsoftware/commcare-hq,dimagi/commcare-hq,puttarajubr/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,puttarajubr/commcare-hq,qedsoftware/commcare-hq,puttarajubr/commcare-hq | ---
+++
@@ -0,0 +1,15 @@
+def prime_views(pool_size):
+ """
+ Prime the views so that a very large import doesn't cause the index
+ to get too far behind
+ """
+
+ # These have to be included here or ./manage.py runserver explodes on
+ # all pages of the app with single thread related errors
+ fr... | |
ae189397e3ecbdaeec80d8f44b47e7a749f9d2ac | sft/agent/ah/RunningAvg.py | sft/agent/ah/RunningAvg.py | import theano
from sft import Size
from sft.Actions import Actions
from sft.agent.ah.ActionHistory import ActionHistory
import numpy as np
class RunningAvg(ActionHistory):
def __init__(self, logger, n, factor):
self.logger = logger
self.n = n
self.factor = factor
def get_size(self):
return Size(self.n, s... | Implement running average action history | Implement running average action history
| Python | mit | kevinkepp/search-for-this | ---
+++
@@ -0,0 +1,31 @@
+import theano
+
+from sft import Size
+from sft.Actions import Actions
+from sft.agent.ah.ActionHistory import ActionHistory
+
+import numpy as np
+
+
+class RunningAvg(ActionHistory):
+ def __init__(self, logger, n, factor):
+ self.logger = logger
+ self.n = n
+ self.factor = factor
+
+ ... | |
29b1c862f603f3399ebe1e3acb7e14e776e2102f | performance_testing/result.py | performance_testing/result.py | import os
from datetime import datetime
class Result:
def __init__(self, directory):
date = datetime.fromtimestamp(time())
name = '%d-%d-%d_%d-%d-%d' % (datetime.year,
datetime.month,
datetime.day,
... | Create Result class with file | Create Result class with file
| Python | mit | BakeCode/performance-testing,BakeCode/performance-testing | ---
+++
@@ -0,0 +1,28 @@
+import os
+from datetime import datetime
+
+
+class Result:
+ def __init__(self, directory):
+ date = datetime.fromtimestamp(time())
+ name = '%d-%d-%d_%d-%d-%d' % (datetime.year,
+ datetime.month,
+ d... | |
5aa3d52b6c60f668f4d96031778b3dd2662435cf | AndroidGatewayPlugin/Testdriver/ManyConnectors.py | AndroidGatewayPlugin/Testdriver/ManyConnectors.py | from ammo import AndroidConnector
from ammo import AmmoMessages_pb2
import uuid
import sys
import time
import datetime
import math
import optparse
from twisted.internet import reactor
latencies = []
def onDataReceived(connector, msg):
receivedTime = time.time()
if msg.type == AmmoMessages_pb2.MessageWrapper.DA... | Add testdriver to simulate large numbers of simultaneous connections | Add testdriver to simulate large numbers of simultaneous connections
| Python | mit | isis-ammo/ammo-gateway,isis-ammo/ammo-gateway,isis-ammo/ammo-gateway,isis-ammo/ammo-gateway,isis-ammo/ammo-gateway,isis-ammo/ammo-gateway | ---
+++
@@ -0,0 +1,74 @@
+from ammo import AndroidConnector
+from ammo import AmmoMessages_pb2
+
+import uuid
+import sys
+import time
+import datetime
+import math
+import optparse
+
+
+from twisted.internet import reactor
+
+latencies = []
+
+def onDataReceived(connector, msg):
+ receivedTime = time.time()
+ if m... | |
a3fda3f65f810e18c099050aac65e6f277d5e41e | osf/migrations/0074_parse_citation_styles.py | osf/migrations/0074_parse_citation_styles.py | # This migration port `scripts/parse_citation_styles` to automatically parse citation styles.
# Additionally, this set the corresponding `has_bibliography` field to `False` for all citation formats whose CSL files do not
# include a bibliography section. As a result, all such citation formats would not show up in OSF
#... | Revert "[REVERT][OSF-3622] Add migration file to automatically parse citations"" | Revert "[REVERT][OSF-3622] Add migration file to automatically parse citations""
| Python | apache-2.0 | caseyrollins/osf.io,icereval/osf.io,Johnetordoff/osf.io,sloria/osf.io,brianjgeiger/osf.io,HalcyonChimera/osf.io,TomBaxter/osf.io,cslzchen/osf.io,binoculars/osf.io,saradbowman/osf.io,felliott/osf.io,brianjgeiger/osf.io,icereval/osf.io,cslzchen/osf.io,Johnetordoff/osf.io,CenterForOpenScience/osf.io,leb2dg/osf.io,crcresea... | ---
+++
@@ -0,0 +1,78 @@
+# This migration port `scripts/parse_citation_styles` to automatically parse citation styles.
+# Additionally, this set the corresponding `has_bibliography` field to `False` for all citation formats whose CSL files do not
+# include a bibliography section. As a result, all such citation form... | |
23e75c71fd819f4d5aef4eff59b3c9fcf65b6339 | CodeFights/arrayReplace.py | CodeFights/arrayReplace.py | #!/usr/local/bin/python
# Code Fights Add Border Problem
def arrayReplace(inputArray, elemToReplace, substitutionElem):
pass
def main():
pass
if __name__ == '__main__':
main()
| Set up Code Fights array replace problem | Set up Code Fights array replace problem
| Python | mit | HKuz/Test_Code | ---
+++
@@ -0,0 +1,14 @@
+#!/usr/local/bin/python
+# Code Fights Add Border Problem
+
+
+def arrayReplace(inputArray, elemToReplace, substitutionElem):
+ pass
+
+
+def main():
+ pass
+
+
+if __name__ == '__main__':
+ main() | |
0a0096823f391e232f22ce80ace1e2ae751cbc4e | tests/services/ticketing/test_revocation.py | tests/services/ticketing/test_revocation.py | """
:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""
from byceps.services.seating import category_service
from byceps.services.ticketing import ticket_service
from tests.base import AbstractAppTestCase
class TicketRevocationTestCase(AbstractAppTestCase):
def setUp... | Add ticket revocation service tests | Add ticket revocation service tests
Forgot to actually add them earlier.
| Python | bsd-3-clause | m-ober/byceps,m-ober/byceps,homeworkprod/byceps,m-ober/byceps,homeworkprod/byceps,homeworkprod/byceps | ---
+++
@@ -0,0 +1,56 @@
+"""
+:Copyright: 2006-2017 Jochen Kupperschmidt
+:License: Modified BSD, see LICENSE for details.
+"""
+
+from byceps.services.seating import category_service
+from byceps.services.ticketing import ticket_service
+
+from tests.base import AbstractAppTestCase
+
+
+class TicketRevocationTestCa... | |
579718f1546df1e539cd2f7fbaf1617f06412eca | tools/find_deprecated_escaped_characters.py | tools/find_deprecated_escaped_characters.py | #! /usr/bin/env python
"""
Look for escape sequences deprecated in Python 3.6.
Python 3.6 deprecates a number of non-escape sequences starting with `\` that
were accepted before. For instance, '\(' was previously accepted but must now
be written as '\\(' or r'\('.
"""
from __future__ import division, absolute_import,... | Add tool to check for deprecated escaped characters. | ENH: Add tool to check for deprecated escaped characters.
Python 3.6 deprecates a number of escaped characters that were accepted
before. For instance, '\(' was previously accepted but must now be
written as '\\(' or r'\('.
[ci skip]
| Python | bsd-3-clause | madphysicist/numpy,simongibbons/numpy,Eric89GXL/numpy,pizzathief/numpy,MSeifert04/numpy,seberg/numpy,numpy/numpy,jakirkham/numpy,pdebuyl/numpy,seberg/numpy,jakirkham/numpy,mhvk/numpy,ssanderson/numpy,madphysicist/numpy,grlee77/numpy,ssanderson/numpy,WarrenWeckesser/numpy,pbrod/numpy,WarrenWeckesser/numpy,MSeifert04/num... | ---
+++
@@ -0,0 +1,69 @@
+#! /usr/bin/env python
+"""
+Look for escape sequences deprecated in Python 3.6.
+
+Python 3.6 deprecates a number of non-escape sequences starting with `\` that
+were accepted before. For instance, '\(' was previously accepted but must now
+be written as '\\(' or r'\('.
+
+"""
+from __futur... | |
f5e8a90a2e50816e18580fec3aba32bd17ebf2e0 | classes.py | classes.py | class BucketList():
def __init__(self, name, description):
self.name = name
self.description = description
self.activities = []
self.no_of_activities = len(self.activities)
def add_activity(self, activity):
self.activities.append(activity)
return True
def de... | Define the User class constructor | Define the User class constructor
| Python | mit | mkiterian/bucket-list-app,mkiterian/bucket-list-app,mkiterian/bucket-list-app | ---
+++
@@ -0,0 +1,22 @@
+class BucketList():
+ def __init__(self, name, description):
+ self.name = name
+ self.description = description
+ self.activities = []
+ self.no_of_activities = len(self.activities)
+
+ def add_activity(self, activity):
+ self.activities.append(activ... | |
8e01a902baa1be4574be2edef03ad72bdcdd8439 | py/sum-of-left-leaves.py | py/sum-of-left-leaves.py | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def sumOfLeftLeaves(self, root):
"""
:type root: TreeNode
:rtype: int
"""
ans = 0... | Add py solution for 404. Sum of Left Leaves | Add py solution for 404. Sum of Left Leaves
404. Sum of Left Leaves: https://leetcode.com/problems/sum-of-left-leaves/
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,22 @@
+# Definition for a binary tree node.
+# class TreeNode(object):
+# def __init__(self, x):
+# self.val = x
+# self.left = None
+# self.right = None
+
+class Solution(object):
+ def sumOfLeftLeaves(self, root):
+ """
+ :type root: TreeNode
+ ... | |
ad187547de905f8f5baba51f3a431c2cfb4a2704 | tests/test_01_read_write.py | tests/test_01_read_write.py | """Read an image index from the index file and write it back.
"""
import os.path
import shutil
import filecmp
import pytest
import photo.index
from conftest import tmpdir, gettestdata
testimgs = [
"dsc_4623.jpg", "dsc_4664.jpg", "dsc_4831.jpg",
"dsc_5126.jpg", "dsc_5167.jpg"
]
testimgfiles = [ gettestdata(... | Add a test to read an image index and write it back. | Add a test to read an image index and write it back.
| Python | apache-2.0 | RKrahl/photo-tools | ---
+++
@@ -0,0 +1,32 @@
+"""Read an image index from the index file and write it back.
+"""
+
+import os.path
+import shutil
+import filecmp
+import pytest
+import photo.index
+from conftest import tmpdir, gettestdata
+
+testimgs = [
+ "dsc_4623.jpg", "dsc_4664.jpg", "dsc_4831.jpg",
+ "dsc_5126.jpg", "dsc_51... | |
39e097c4edbc0c3eb3b8d0269d85666272531091 | ops/cookiejar-empty-hack.py | ops/cookiejar-empty-hack.py | ############################################################
# USE WITH CAUTION!
# May result in undesired behaviour, crashes, and wormholes.
############################################################
# Requirements:
# - Netcat with Unix socket support (e.g. the netcat-openbsd package on Debian/Ubuntu; not netcat-tr... | Add a hacky script for clearing a job's cookie jar | Add a hacky script for clearing a job's cookie jar
Cf. https://github.com/ArchiveTeam/wpull/issues/448
Based on https://gist.github.com/JustAnotherArchivist/8f5ac42a9c03302f222af3a58a863468
| Python | mit | ArchiveTeam/ArchiveBot,ArchiveTeam/ArchiveBot,ArchiveTeam/ArchiveBot,ArchiveTeam/ArchiveBot,ArchiveTeam/ArchiveBot | ---
+++
@@ -0,0 +1,32 @@
+############################################################
+# USE WITH CAUTION!
+# May result in undesired behaviour, crashes, and wormholes.
+############################################################
+
+# Requirements:
+# - Netcat with Unix socket support (e.g. the netcat-openbsd packa... | |
81a3cee4c1086d429fbc494935b82a0ea4539bb0 | source/PYTHON/EXTENSIONS/BALL.py | source/PYTHON/EXTENSIONS/BALL.py | from BALLCore import *
try:
from VIEW import *
except:
print "Warning: Could not find VIEW.\nVerify that BALL is built with VIEW support and check your PYTHONPATH. Continuing..."
| Add a script wrapping the splitted modules | Add a script wrapping the splitted modules
This script just imports both modules such that old scripts are still
running without issues.
| Python | lgpl-2.1 | tkemmer/ball,tkemmer/ball,tkemmer/ball,tkemmer/ball,tkemmer/ball,tkemmer/ball | ---
+++
@@ -0,0 +1,5 @@
+from BALLCore import *
+try:
+ from VIEW import *
+except:
+ print "Warning: Could not find VIEW.\nVerify that BALL is built with VIEW support and check your PYTHONPATH. Continuing..." | |
1b8edb32664e63d1dc2ad9af295395f62d08f4bd | crackingcointsolutions/chapter2/exercisesix.py | crackingcointsolutions/chapter2/exercisesix.py | '''
Created on 22 Aug 2017
Palindrome: implement a function to check if a linked list is a palindrome
Assumptions: each node of the list contains a single letter.
1) Invert-copy list, gives also back list size
2) compare until middle: size/2
@author: igoroya
'''
from chapter2 import utils # TODO: try relative impor... | Add exercise six of chapter two | Add exercise six of chapter two | Python | mit | igoroya/igor-oya-solutions-cracking-coding-interview | ---
+++
@@ -0,0 +1,97 @@
+'''
+Created on 22 Aug 2017
+
+Palindrome: implement a function to check if a linked list is a palindrome
+
+Assumptions: each node of the list contains a single letter.
+
+1) Invert-copy list, gives also back list size
+2) compare until middle: size/2
+
+@author: igoroya
+'''
+from chapter2... | |
7faad2fff896946c2b9b8deeb202dc27b5e3f6d7 | tests/test_object.py | tests/test_object.py | #!/usr/bin/env python
import unittest
class TestObject(unittest.TestCase):
def test_object(self):
import mlbgame
data = {
'string': 'string',
'int': '10',
'float': '10.1'
}
obj = mlbgame.object.Object(data)
self.assertIsInstance(obj.... | Add test for object module | Add test for object module
| Python | mit | panzarino/mlbgame,zachpanz88/mlbgame | ---
+++
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+import unittest
+
+class TestObject(unittest.TestCase):
+
+ def test_object(self):
+ import mlbgame
+ data = {
+ 'string': 'string',
+ 'int': '10',
+ 'float': '10.1'
+ }
+ obj = mlbgame.object.Object... | |
90ba69c5fec5a337a016a111ab196277e7d35843 | tools/add_to_yaml.py | tools/add_to_yaml.py | import os
import yaml
import yt
import sys
data_dir = '/mnt/data/renaissance'
rsl_page_root = os.environ.get(
'RSL_PAGE_ROOT', '/home/britton/rensimlab.github.io')
simyaml = os.path.join(rsl_page_root, '_data', 'simulations.yaml')
simulation_data = yaml.load(open(simyaml, 'r'))
if len(sys.argv) < 2:
sys.exi... | Add script to add a simulation to the yaml file. | Add script to add a simulation to the yaml file.
| Python | mit | rensimlab/rensimlab.github.io,rensimlab/rensimlab.github.io,rensimlab/rensimlab.github.io | ---
+++
@@ -0,0 +1,32 @@
+import os
+import yaml
+import yt
+import sys
+
+data_dir = '/mnt/data/renaissance'
+
+rsl_page_root = os.environ.get(
+ 'RSL_PAGE_ROOT', '/home/britton/rensimlab.github.io')
+
+simyaml = os.path.join(rsl_page_root, '_data', 'simulations.yaml')
+simulation_data = yaml.load(open(simyaml, '... | |
312be9e1d6a611ebcbe9e7110ffd77dc84a1633c | run_randoop.py | run_randoop.py | #!/usr/bin/python
import os,sys,common
import fetch
import time
def main():
if not os.path.exists(common.CORPUS_DIR) or not os.path.exists(common.LIBS_DIR):
print "Please run python fetch.py first to fetch the corpus and/or necessary tools."
sys.exit(1)
return
project = ""
if len(sys.argv) == 2:
... | Add script to run Randoop for evaluation over corpus | Add script to run Randoop for evaluation over corpus
| Python | mit | aas-integration/integration-test2,aas-integration/integration-test2,markro49/integration-test2,markro49/integration-test2 | ---
+++
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+
+import os,sys,common
+import fetch
+import time
+
+def main():
+ if not os.path.exists(common.CORPUS_DIR) or not os.path.exists(common.LIBS_DIR):
+ print "Please run python fetch.py first to fetch the corpus and/or necessary tools."
+ sys.exit(1)
+ return
+
+ ... | |
8a35d9a8f502a303ac164c138c2820254e600345 | girder/cluster_filesystem/server/dateutils.py | girder/cluster_filesystem/server/dateutils.py | import datetime as dt
def dateParser(timestring):
"""
Parse a datetime string from ls -l and return a standard isotime
ls -l returns dates in two different formats:
May 2 09:06 (for dates within 6 months from now)
May 2 2018 (for dates further away)
... | Add function to convert a date from bash to iso format | Add function to convert a date from bash to iso format
| Python | apache-2.0 | Kitware/cumulus,Kitware/cumulus | ---
+++
@@ -0,0 +1,47 @@
+import datetime as dt
+
+def dateParser(timestring):
+ """
+ Parse a datetime string from ls -l and return a standard isotime
+
+ ls -l returns dates in two different formats:
+
+ May 2 09:06 (for dates within 6 months from now)
+ May 2 2018 ... | |
b975a67714bd77121bd5289c2de272c280e6c805 | instrument-classification/extract_features.py | instrument-classification/extract_features.py | """
Extracts chromagram features from audio data.
Input: a 2D tensor with set of audio samples
Output: A tensor with a chromagram for each sample
"""
import argparse
import numpy as np
import sys
# TODO: package the chromagram script
sys.path.append('../tools/music-processing-experiments/')
from analysis import spl... | Add a script to extract chromagram features from the audio samples. | Add a script to extract chromagram features from the audio samples.
| Python | mit | bzamecnik/ml,bzamecnik/ml,bzamecnik/ml-playground,bzamecnik/ml,bzamecnik/ml-playground | ---
+++
@@ -0,0 +1,60 @@
+"""
+Extracts chromagram features from audio data.
+
+Input: a 2D tensor with set of audio samples
+Output: A tensor with a chromagram for each sample
+"""
+
+import argparse
+import numpy as np
+import sys
+
+# TODO: package the chromagram script
+sys.path.append('../tools/music-processing-... | |
8fc4d6db21ba3220794dbfb892c5556e28709ee5 | py/reconstruct-original-digits-from-english.py | py/reconstruct-original-digits-from-english.py | class Solution(object):
def originalDigits(self, s):
"""
:type s: str
:rtype: str
"""
digits = ['ero', 'one', 'to', 'three', 'for', 'five', 'si', 'seven', 'eiht', 'nine']
alphabets = list(set('zeroonetwothreefourfivesixseveneightnine') - set('guwxz'))
mapping ... | Add py solution for 423. Reconstruct Original Digits from English | Add py solution for 423. Reconstruct Original Digits from English
423. Reconstruct Original Digits from English: https://leetcode.com/problems/reconstruct-original-digits-from-english/
Approach 1:
Use matrix operation to find the answer
P.S. the number in the matrix is so terrible :o
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,40 @@
+class Solution(object):
+ def originalDigits(self, s):
+ """
+ :type s: str
+ :rtype: str
+ """
+ digits = ['ero', 'one', 'to', 'three', 'for', 'five', 'si', 'seven', 'eiht', 'nine']
+ alphabets = list(set('zeroonetwothreefourfivesixseveneightnine... | |
e3e545418dfab00b5d64530f4b1a7ed36e6b6edb | lib/ansible/runner/lookup_plugins/redis_kv.py | lib/ansible/runner/lookup_plugins/redis_kv.py | # (c) 2012, Jan-Piet Mens <jpmens(at)gmail.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later ver... | Add Redis GET $LOOKUP plugin renamed | Add Redis GET $LOOKUP plugin
renamed
| Python | mit | thaim/ansible,thaim/ansible | ---
+++
@@ -0,0 +1,67 @@
+# (c) 2012, Jan-Piet Mens <jpmens(at)gmail.com>
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, o... | |
aaff2c9f78a409ac00b0f8325e9bb29bdee50abc | python/print_sideways/ps.py | python/print_sideways/ps.py | #! /usr/bin/env python
# vim: set ai sw=4:
import sys
import os
import math
import argparse
def l10(num):
return int(math.log10(num))
def ps(num):
for d in xrange(l10(num), -1, -1):
print "".join([chr(ord('0')+((x/(10**d))%10)) for x in xrange(1,num+1)])
def ps_base(num, base):
for d in xrange(... | Add python program to print numbers sideways. | Add python program to print numbers sideways.
| Python | bsd-2-clause | tedzo/python_play | ---
+++
@@ -0,0 +1,51 @@
+#! /usr/bin/env python
+
+# vim: set ai sw=4:
+
+import sys
+import os
+import math
+import argparse
+
+def l10(num):
+ return int(math.log10(num))
+
+def ps(num):
+ for d in xrange(l10(num), -1, -1):
+ print "".join([chr(ord('0')+((x/(10**d))%10)) for x in xrange(1,num+1)])
+
+... | |
6100d873443581f6b4f34cd0e88150878f3825b2 | peerinst/migrations/0002_auto_20150430_2108.py | peerinst/migrations/0002_auto_20150430_2108.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('peerinst', '0001_squashed_0012_auto_20150423_1146'),
]
operations = [
migrations.AlterField(
model_name='answer'... | Add migration for show_to_others default value. | Add migration for show_to_others default value.
| Python | agpl-3.0 | open-craft/dalite-ng,open-craft/dalite-ng,open-craft/dalite-ng | ---
+++
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('peerinst', '0001_squashed_0012_auto_20150423_1146'),
+ ]
+
+ operations = [
+ migrations.Al... | |
fc17d313a296bf8c93fa857bf3cf2ffc775ce102 | lpthw/ex26.py | lpthw/ex26.py | def break_words(stuff):
"""This function will break up words for us."""
words = stuff.split(' ')
return words
def sort_words(words):
"""Sorts the words."""
return sorted(words)
def print_first_word(words):
"""Prints the first word after popping it off."""
word =... | Add work for Exercise 26: The Midterm. | Add work for Exercise 26: The Midterm.
| Python | mit | jaredmanning/learning,jaredmanning/learning | ---
+++
@@ -0,0 +1,86 @@
+def break_words(stuff):
+ """This function will break up words for us."""
+ words = stuff.split(' ')
+ return words
+
+def sort_words(words):
+ """Sorts the words."""
+ return sorted(words)
+
+def print_first_word(words):
+ """Prints the first word a... | |
7b828fedc64fccff23a85f6778add58ed93c1fff | kodi-stable/parts/plugins/x_kodiautotools.py | kodi-stable/parts/plugins/x_kodiautotools.py | # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
import snapcraft
from snapcraft.plugins import autotools
class KodiAutotoolsPlugin(autotools.AutotoolsPlugin):
def build(self):
# setup build directory
super(autotools.AutotoolsPlugin, self).build()
# run boostrap before autotools... | Add missing custom plugins python code. | Add missing custom plugins python code.
| Python | mit | jamestait/snappy-playpen,elopio/snappy-playpen,elopio/snappy-playpen,elopio/snappy-playpen,ubuntu/snappy-playpen,elopio/snappy-playpen,jamestait/snappy-playpen,ubuntu/snappy-playpen,jamestait/snappy-playpen,Zap123/snappy-playpen,jamestait/snappy-playpen,Zap123/snappy-playpen,ubuntu/snappy-playpen,ubuntu/snappy-playpen | ---
+++
@@ -0,0 +1,24 @@
+# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
+
+import snapcraft
+from snapcraft.plugins import autotools
+
+
+class KodiAutotoolsPlugin(autotools.AutotoolsPlugin):
+
+ def build(self):
+ # setup build directory
+ super(autotools.AutotoolsPlugin, self).build()
+
... | |
2f9d6dd3fa112844fd605348605673dc0c2a8b5f | tests/twisted/avahitest.py | tests/twisted/avahitest.py | """
Infrastructure for testing avahi
"""
import servicetest
from servicetest import Event
import dbus
import dbus.glib
import avahi
def get_host_name():
bus = dbus.SystemBus()
server = dbus.Interface(bus.get_object(avahi.DBUS_NAME,
avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER)
return server.... | Add some avahi testing utilities | Add some avahi testing utilities
| Python | lgpl-2.1 | freedesktop-unofficial-mirror/telepathy__telepathy-salut,freedesktop-unofficial-mirror/telepathy__telepathy-salut,freedesktop-unofficial-mirror/telepathy__telepathy-salut,freedesktop-unofficial-mirror/telepathy__telepathy-salut | ---
+++
@@ -0,0 +1,53 @@
+"""
+Infrastructure for testing avahi
+"""
+
+import servicetest
+from servicetest import Event
+import dbus
+import dbus.glib
+import avahi
+
+def get_host_name():
+ bus = dbus.SystemBus()
+ server = dbus.Interface(bus.get_object(avahi.DBUS_NAME,
+ avahi.DBUS_PATH_SERVER), avah... | |
ab2573d6a25a91f1a61e3cd5c5eb69682653ab0c | src/postgres/migrations/0004_user_generated_id.py | src/postgres/migrations/0004_user_generated_id.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
CREATE_USER_SCHEMA = """
CREATE FUNCTION users_user_id_generator(OUT result bigint) AS $$
DECLARE
-- 2015-08-19T00:00:00Z. This is arbitrarily chosen; anything is fine
-- as ... | Use Postgres long ID on user model | Use Postgres long ID on user model
| Python | mit | uranusjr/pycontw2016,pycontw/pycontw2016,pycontw/pycontw2016,pycontw/pycontw2016,uranusjr/pycontw2016,pycontw/pycontw2016,uranusjr/pycontw2016,uranusjr/pycontw2016 | ---
+++
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+CREATE_USER_SCHEMA = """
+ CREATE FUNCTION users_user_id_generator(OUT result bigint) AS $$
+ DECLARE
+ -- 2015-08-19T00:00:00Z. This is arbitrarily c... | |
5bd167e0e7497ced568cf0e34c51df4a1f0a391d | docs/tutorial/src/python-types/tutorial002.py | docs/tutorial/src/python-types/tutorial002.py | def get_full_name(first_name: str, last_name: str):
full_name = first_name.title() + " " + last_name.title()
return full_name
print(get_full_name("john", "doe"))
| Add second tutorial src for python-types | :memo: Add second tutorial src for python-types
| Python | mit | tiangolo/fastapi,tiangolo/fastapi,tiangolo/fastapi | ---
+++
@@ -0,0 +1,6 @@
+def get_full_name(first_name: str, last_name: str):
+ full_name = first_name.title() + " " + last_name.title()
+ return full_name
+
+
+print(get_full_name("john", "doe")) | |
59a2712f353f47e3dc237479cc6cc46666b7d0f1 | energy_demand/scripts/generate_dummy_data.py | energy_demand/scripts/generate_dummy_data.py | """Generate dummy data to use in smif as scenario data for testing
"""
from pprint import pprint
from energy_demand.read_write.data_loader import dummy_data_generation
import yaml
def main():
"""Generate and write out data
"""
data = dummy_data_generation({
'sim_param': {
'base_yr': ... | Write dummy data out to yaml | Write dummy data out to yaml
| Python | mit | nismod/energy_demand,nismod/energy_demand | ---
+++
@@ -0,0 +1,63 @@
+"""Generate dummy data to use in smif as scenario data for testing
+"""
+from pprint import pprint
+
+from energy_demand.read_write.data_loader import dummy_data_generation
+import yaml
+
+
+
+def main():
+ """Generate and write out data
+ """
+ data = dummy_data_generation({
+ ... | |
daa3504942e088fb6cd23eaccff78e613460f517 | mezzanine/accounts/admin.py | mezzanine/accounts/admin.py |
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from mezzanine.accounts.models import get_profile_model
Profile = get_profile_model()
class ProfileInline(admin.StackedInline):
model = Profile
can_delete = False
template = "ad... |
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from mezzanine.accounts.models import get_profile_model
from mezzanine.core.admin import AdminProfileInline
Profile = get_profile_model()
class ProfileInline(admin.StackedInline):
model... | Include AdminProfileInline so that it is not lost if the user enables Mezzanine accounts. | Include AdminProfileInline so that it is not lost if the user enables Mezzanine accounts.
--HG--
branch : admin_site_permissions
| Python | bsd-2-clause | spookylukey/mezzanine,christianwgd/mezzanine,molokov/mezzanine,frankier/mezzanine,SoLoHiC/mezzanine,ZeroXn/mezzanine,readevalprint/mezzanine,eino-makitalo/mezzanine,stbarnabas/mezzanine,theclanks/mezzanine,scarcry/snm-mezzanine,Cajoline/mezzanine,molokov/mezzanine,sjdines/mezzanine,joshcartme/mezzanine,frankchin/mezzan... | ---
+++
@@ -4,6 +4,7 @@
from django.contrib.auth.models import User
from mezzanine.accounts.models import get_profile_model
+from mezzanine.core.admin import AdminProfileInline
Profile = get_profile_model()
@@ -17,7 +18,7 @@
class UserProfileAdmin(UserAdmin):
- inlines = (ProfileInline,) if Profile e... |
f61870d3e3c5684101034fa800f6bece03f08c66 | disasm.py | disasm.py | import MOS6502
import instructions
def disasm(memory):
index = 0
lines = []
while index < len(memory):
currInst = instructions.instructions[memory[index]]
line = currInst.mnem + " "
line += currInst.operType + " "
if currInst.size > 1:
for i in range(1,... | Add quick dumb disassembler for upcoming debugger | Add quick dumb disassembler for upcoming debugger
| Python | bsd-2-clause | pusscat/refNes | ---
+++
@@ -0,0 +1,23 @@
+import MOS6502
+import instructions
+
+def disasm(memory):
+ index = 0
+ lines = []
+
+ while index < len(memory):
+ currInst = instructions.instructions[memory[index]]
+
+ line = currInst.mnem + " "
+ line += currInst.operType + " "
+ if currInst... | |
4c02bfc323dcdce642118978da04297dbea77189 | nightreads/emails/migrations/0002_auto_20160521_1046.py | nightreads/emails/migrations/0002_auto_20160521_1046.py | # -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-05-21 10:46
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('emails', '0001_initial'),
]
operations = [
... | Set `blank` attrib to True on Email.post field | Set `blank` attrib to True on Email.post field
| Python | mit | avinassh/nightreads,avinassh/nightreads | ---
+++
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.6 on 2016-05-21 10:46
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('emails', '0001_initia... | |
34810a3d6f95fe14a623090f2c8dfe01299be179 | backend/scripts/fixdrafts.py | backend/scripts/fixdrafts.py | #!/usr/bin/env python
import rethinkdb as r
import optparse
if __name__ == "__main__":
parser = optparse.OptionParser()
parser.add_option("-P", "--port", dest="port", type="int",
help="rethinkdb port", default=30815)
(options, args) = parser.parse_args()
conn = r.connect('localho... | Add script to fix Emmanuelle's messed up drafts. | Add script to fix Emmanuelle's messed up drafts.
| Python | mit | materials-commons/materialscommons.org,materials-commons/materialscommons.org,materials-commons/materialscommons.org,materials-commons/materialscommons.org,materials-commons/materialscommons.org | ---
+++
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+import rethinkdb as r
+import optparse
+
+if __name__ == "__main__":
+ parser = optparse.OptionParser()
+ parser.add_option("-P", "--port", dest="port", type="int",
+ help="rethinkdb port", default=30815)
+ (options, args) = parser.parse... | |
81c67593807ed22049b4ec7d4a1503a35b874444 | csunplugged/tests/resources/other/test_resource_cache_redirect.py | csunplugged/tests/resources/other/test_resource_cache_redirect.py | from tests.BaseTestWithDB import BaseTestWithDB
from django.test import tag
from django.http import QueryDict
from django.urls import reverse
from resources.views.views import resource_pdf_cache
from tests.resources.ResourcesTestDataGenerator import ResourcesTestDataGenerator
from utils.get_resource_generator import ge... | Add test for resource cache function | Add test for resource cache function
| Python | mit | uccser/cs-unplugged,uccser/cs-unplugged,uccser/cs-unplugged,uccser/cs-unplugged | ---
+++
@@ -0,0 +1,31 @@
+from tests.BaseTestWithDB import BaseTestWithDB
+from django.test import tag
+from django.http import QueryDict
+from django.urls import reverse
+from resources.views.views import resource_pdf_cache
+from tests.resources.ResourcesTestDataGenerator import ResourcesTestDataGenerator
+from util... | |
97bbbc7ac288b1d8220b4e335b9aa19555fee3f3 | buffer/tests/test_profile.py | buffer/tests/test_profile.py | import json
from nose.tools import eq_, raises
from mock import MagicMock, patch
from buffer.models.profile import Profile, PATHS
mocked_response = {
'name': 'me',
'service': 'twiter',
'id': 1
}
def test_profile_schedules_getter():
'''
Test schedules gettering from buffer api
'''
mocked_api = Magic... | Test profile schedulers gettering from buffer api | Test profile schedulers gettering from buffer api
| Python | mit | vtemian/buffpy,bufferapp/buffer-python | ---
+++
@@ -0,0 +1,25 @@
+import json
+
+from nose.tools import eq_, raises
+from mock import MagicMock, patch
+
+from buffer.models.profile import Profile, PATHS
+
+mocked_response = {
+ 'name': 'me',
+ 'service': 'twiter',
+ 'id': 1
+}
+
+def test_profile_schedules_getter():
+ '''
+ Test schedules gettering ... | |
4e27164028847fb7de8d4aef991f1f6e9c64c8be | l10n_br_sale/models/sale-l10n_br_sale_service.py | l10n_br_sale/models/sale-l10n_br_sale_service.py | # Copyright (C) 2014 Renato Lima - Akretion
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import _, api, models
from openerp.exceptions import Warning as UserError
class SaleOrder(models.Model):
_inherit = "sale.order"
@api.model
def _prepare_invoice(self, order, lines):... | Move models from l10n_br_sale_service to l10n_br_sale. | [12.0][MIG][WIP] Move models from l10n_br_sale_service to l10n_br_sale.
| Python | agpl-3.0 | akretion/l10n-brazil,akretion/l10n-brazil,OCA/l10n-brazil,OCA/l10n-brazil,OCA/l10n-brazil,akretion/l10n-brazil | ---
+++
@@ -0,0 +1,64 @@
+# Copyright (C) 2014 Renato Lima - Akretion
+# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
+
+from openerp import _, api, models
+from openerp.exceptions import Warning as UserError
+
+
+class SaleOrder(models.Model):
+ _inherit = "sale.order"
+
+ @api.model
+ de... | |
8d2fe4a34e34267eb2fe1b2d84fcc77c89eaebc2 | migrations/versions/0a2ba8dce059_oauth2_start.py | migrations/versions/0a2ba8dce059_oauth2_start.py | """OAuth2 start
Revision ID: 0a2ba8dce059
Revises: 9f50538504b1
Create Date: 2017-02-11 13:48:45.564677
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy import Text
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '0a2ba8dce059'
down_revision = '9f50538... | Add this missing OAuth2 migration. | Add this missing OAuth2 migration.
Signed-off-by: Laura <07c342be6e560e7f43842e2e21b774e61d85f047@veriny.tf>
| Python | mit | MJB47/Jokusoramame,MJB47/Jokusoramame,MJB47/Jokusoramame | ---
+++
@@ -0,0 +1,29 @@
+"""OAuth2 start
+
+Revision ID: 0a2ba8dce059
+Revises: 9f50538504b1
+Create Date: 2017-02-11 13:48:45.564677
+
+"""
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy import Text
+from sqlalchemy.dialects import postgresql
+
+# revision identifiers, used by Alembic.
+revision ... | |
5dc1d9d005bd88378f03ab6783858be09c348e4c | services/etsy.py | services/etsy.py | from werkzeug.urls import url_decode
import foauth.providers
class Etsy(foauth.providers.OAuth1):
# General info about the provider
provider_url = 'http://www.etsy.com/'
docs_url = 'http://www.etsy.com/developers/documentation'
category = 'Crafts'
# URLs to interact with the API
request_toke... | Add the code for Etsy | Add the code for Etsy
They've decided not to allow foauth.org to actually access their API, but there's no reason to hide the code in case someone can learn from it.
| Python | bsd-3-clause | foauth/foauth.org,foauth/foauth.org,foauth/foauth.org | ---
+++
@@ -0,0 +1,51 @@
+from werkzeug.urls import url_decode
+
+import foauth.providers
+
+
+class Etsy(foauth.providers.OAuth1):
+ # General info about the provider
+ provider_url = 'http://www.etsy.com/'
+ docs_url = 'http://www.etsy.com/developers/documentation'
+ category = 'Crafts'
+
+ # URLs to... | |
b7a1f8b9cbbf795f663987254a681281cda46abf | tests/contrib/hooks/test_gcp_dataproc_hook.py | tests/contrib/hooks/test_gcp_dataproc_hook.py | # -*- coding: utf-8 -*-
#
# 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
... | Add unit tests for DataProcHook | [AIRFLOW-1727] Add unit tests for DataProcHook
Closes #2697 from cjqian/1727
| Python | apache-2.0 | Tagar/incubator-airflow,Fokko/incubator-airflow,adamhaney/airflow,edgarRd/incubator-airflow,bolkedebruin/airflow,nathanielvarona/airflow,gilt/incubator-airflow,danielvdende/incubator-airflow,yk5/incubator-airflow,zack3241/incubator-airflow,wndhydrnt/airflow,mistercrunch/airflow,danielvdende/incubator-airflow,subodhchha... | ---
+++
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+#
+# 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 la... | |
579879a0c9f54d8f3ab6b57feaeeeaeee1365ab7 | campaign/migrations/0014_auto_20160717_2119.py | campaign/migrations/0014_auto_20160717_2119.py | # -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-07-17 21:19
from __future__ import unicode_literals
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('campaign', '0013_merge'),
]
operations = [
migr... | Integrate salary picker with PayFast | Integrate salary picker with PayFast
| Python | mit | toast38coza/FlashGiving,toast38coza/FlashGiving,toast38coza/FlashGiving | ---
+++
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2016-07-17 21:19
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.utils.timezone
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('campaign', '0013_merge'),... | |
48257a02d71ab4bf5f0b2415ea7ce298d9425516 | heat_integrationtests/functional/test_templates.py | heat_integrationtests/functional/test_templates.py | # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# d... | Add tests for heat template apis | Add tests for heat template apis
This patch covers 4 template api calls -
1. Get stack template
2. List template versions
3. List resource types
4. Show resource schema
Change-Id: I85b16b8893264d1313e2e184011dd0ddfdaa4349
| Python | apache-2.0 | jasondunsmore/heat,steveb/heat,steveb/heat,noironetworks/heat,openstack/heat,jasondunsmore/heat,cwolferh/heat-scratch,dims/heat,openstack/heat,noironetworks/heat,dims/heat,cwolferh/heat-scratch | ---
+++
@@ -0,0 +1,72 @@
+# 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 agr... | |
a11ed2f8db4d755764a94f9e71bd28e4e3cf582b | py/subarray-sum-equals-k.py | py/subarray-sum-equals-k.py | from collections import Counter
class Solution(object):
def subarraySum(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: int
"""
subsum = [0]
for i, n in enumerate(nums):
subsum.append(subsum[-1] + n)
c = Counter()
an... | Add py solution for 560. Subarray Sum Equals K | Add py solution for 560. Subarray Sum Equals K
560. Subarray Sum Equals K: https://leetcode.com/problems/subarray-sum-equals-k/
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,19 @@
+from collections import Counter
+class Solution(object):
+ def subarraySum(self, nums, k):
+ """
+ :type nums: List[int]
+ :type k: int
+ :rtype: int
+ """
+ subsum = [0]
+ for i, n in enumerate(nums):
+ subsum.append(subsum[-1] ... | |
c788e509500025252154b6dbde65d1b6bf9ee3f7 | nbgrader/tests/apps/test_nbgrader_formgrade.py | nbgrader/tests/apps/test_nbgrader_formgrade.py | from .. import run_nbgrader
from .base import BaseTestApp
class TestNbGraderFormgrade(BaseTestApp):
def test_help(self):
"""Does the help display without error?"""
run_nbgrader(["formgrade", "--help-all"])
| Add back in command line test for nbgrader formgrade | Add back in command line test for nbgrader formgrade
| Python | bsd-3-clause | jupyter/nbgrader,jupyter/nbgrader,jupyter/nbgrader,jupyter/nbgrader,jhamrick/nbgrader,jhamrick/nbgrader,jhamrick/nbgrader,jupyter/nbgrader,jhamrick/nbgrader | ---
+++
@@ -0,0 +1,9 @@
+from .. import run_nbgrader
+from .base import BaseTestApp
+
+
+class TestNbGraderFormgrade(BaseTestApp):
+
+ def test_help(self):
+ """Does the help display without error?"""
+ run_nbgrader(["formgrade", "--help-all"]) | |
d2341cb0cb876e95e1f49f6e1e7b094c67899bfb | vm/test_put_rand_jobs.py | vm/test_put_rand_jobs.py | import httplib
import json
import random
from dispatch import Job
N_JOBS = 10
url = 'jcluster12.appspot.com'
# url = 'localhost:8080'
jobs = []
for i in range(N_JOBS):
job = Job()
job.jobId = i
job.paraEA = random.uniform(0.5, 1.0)
job.paraSigma = random.uniform(0.001, 0.01)
job.running = False
... | Add test script to put 10 random jobs with proper param range | Add test script to put 10 random jobs with proper param range
| Python | apache-2.0 | henrique/DistEvo | ---
+++
@@ -0,0 +1,33 @@
+import httplib
+import json
+import random
+
+from dispatch import Job
+
+N_JOBS = 10
+
+url = 'jcluster12.appspot.com'
+# url = 'localhost:8080'
+
+jobs = []
+for i in range(N_JOBS):
+ job = Job()
+ job.jobId = i
+ job.paraEA = random.uniform(0.5, 1.0)
+ job.paraSigma = random.u... | |
bbabd09aa76fddd9a1ace88d17a07a242c8c37f1 | examples/test_mfa_login.py | examples/test_mfa_login.py | from seleniumbase import BaseCase
class TestMFALogin(BaseCase):
def test_mfa_login(self):
self.open("https://seleniumbase.io/realworld/login")
self.type("#username", "demo_user")
self.type("#password", "secret_pass")
totp_code = self.get_totp_code("GAXG2MTEOR3DMMDG")
... | Add an example test for Multi-Factor Auth Login | Add an example test for Multi-Factor Auth Login
| Python | mit | mdmintz/SeleniumBase,mdmintz/SeleniumBase,mdmintz/SeleniumBase,seleniumbase/SeleniumBase,seleniumbase/SeleniumBase,seleniumbase/SeleniumBase,seleniumbase/SeleniumBase,mdmintz/SeleniumBase | ---
+++
@@ -0,0 +1,14 @@
+from seleniumbase import BaseCase
+
+
+class TestMFALogin(BaseCase):
+ def test_mfa_login(self):
+ self.open("https://seleniumbase.io/realworld/login")
+ self.type("#username", "demo_user")
+ self.type("#password", "secret_pass")
+ totp_code = self.get_totp_cod... | |
2f611cccedfcb75dd23167f27d556f4f9b3e9a70 | quantecon/optimize/tests/test_root_finding.py | quantecon/optimize/tests/test_root_finding.py | import numpy as np
from numpy.testing import assert_almost_equal, assert_allclose
from numba import njit
from quantecon.optimize import newton, newton_secant
@njit
def func(x):
"""
Function for testing on.
"""
return (x**3 - 1)
@njit
def func_prime(x):
"""
Derivative for func.
"""
re... | Add test cases for newton methods | Add test cases for newton methods
| Python | bsd-3-clause | oyamad/QuantEcon.py,QuantEcon/QuantEcon.py,QuantEcon/QuantEcon.py,oyamad/QuantEcon.py | ---
+++
@@ -0,0 +1,95 @@
+import numpy as np
+from numpy.testing import assert_almost_equal, assert_allclose
+from numba import njit
+
+from quantecon.optimize import newton, newton_secant
+
+@njit
+def func(x):
+ """
+ Function for testing on.
+ """
+ return (x**3 - 1)
+
+
+@njit
+def func_prime(x):
+ ... | |
95f0383393d88328d49ae2af7a042be812d98372 | sql/branch.py | sql/branch.py | from gratipay import wireup
env = wireup.env()
db = wireup.db(env)
participants = []
with open('./sql/emails.txt') as f:
emails = [line.rstrip() for line in f]
participants = db.all("""
SELECT p.*::participants
FROM participants p
WHERE email_address IN %s
""", (tuple(emails), ... | Add script to queue emails from file | Add script to queue emails from file
| Python | mit | gratipay/gratipay.com,gratipay/gratipay.com,mccolgst/www.gittip.com,studio666/gratipay.com,studio666/gratipay.com,eXcomm/gratipay.com,eXcomm/gratipay.com,eXcomm/gratipay.com,studio666/gratipay.com,eXcomm/gratipay.com,mccolgst/www.gittip.com,mccolgst/www.gittip.com,studio666/gratipay.com,gratipay/gratipay.com,mccolgst/w... | ---
+++
@@ -0,0 +1,17 @@
+from gratipay import wireup
+
+env = wireup.env()
+db = wireup.db(env)
+
+participants = []
+
+with open('./sql/emails.txt') as f:
+ emails = [line.rstrip() for line in f]
+ participants = db.all("""
+ SELECT p.*::participants
+ FROM participants p
+ WHERE email... | |
de73dfd4445da3ff552a82cf53d239f2653f7ade | tests/pytests/functional/modules/test_sdb.py | tests/pytests/functional/modules/test_sdb.py | import tempfile
import pytest
@pytest.fixture(scope="module")
def minion_config_overrides():
with tempfile.TemporaryDirectory() as tempdir:
yield {
"mydude": {
"driver": "sqlite3",
"database": tempdir + "/test_sdb.sq3",
"table": __name__,
... | Add sqlite sdb smoke tests | Add sqlite sdb smoke tests
Right now sqlite sdb.get will fail for most purposes because the text
values are not decoded. This exhibits that behavior (except of course
for the lone byte-string parameter).
| Python | apache-2.0 | saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt | ---
+++
@@ -0,0 +1,38 @@
+import tempfile
+
+import pytest
+
+
+@pytest.fixture(scope="module")
+def minion_config_overrides():
+ with tempfile.TemporaryDirectory() as tempdir:
+ yield {
+ "mydude": {
+ "driver": "sqlite3",
+ "database": tempdir + "/test_sdb.sq3",
+ ... | |
6089d06942e7516d64c68c2e1cbab04d3500bcc7 | robocrm/migrations/0054_auto_20160620_2356.py | robocrm/migrations/0054_auto_20160620_2356.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import robocrm.fields
import robocrm.models
import django.core.validators
import django.core.files.storage
class Migration(migrations.Migration):
dependencies = [
('robocrm', '0053_robouser_resume'),... | Add migration for magnetic, resume, and rfid | Add migration for magnetic, resume, and rfid
| Python | mit | CMU-Robotics-Club/roboticsclub.org,CMU-Robotics-Club/roboticsclub.org,CMU-Robotics-Club/roboticsclub.org | ---
+++
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+import robocrm.fields
+import robocrm.models
+import django.core.validators
+import django.core.files.storage
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.