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 |
|---|---|---|---|---|---|---|---|---|---|---|
23c15c3bdf2db8f23b23bef7eaaa9b6bbbe600d7 | __init__.py | __init__.py | """Tink package."""
from __future__ import absolute_import
from __future__ import division
from __future__ import google_type_annotations
from __future__ import print_function
from google3.third_party.tink.python import aead
from google3.third_party.tink.python import key_manager
from google3.third_party.tink.python i... | Make tink a package and refactor aead into a package. | Make tink a package and refactor aead into a package.
PiperOrigin-RevId: 249473289
| Python | apache-2.0 | google/tink,google/tink,google/tink,google/tink,google/tink,google/tink,google/tink,google/tink | ---
+++
@@ -0,0 +1,15 @@
+"""Tink package."""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import google_type_annotations
+from __future__ import print_function
+
+from google3.third_party.tink.python import aead
+from google3.third_party.tink.python import key_manager
+fr... | |
1ef37363a55e8e2e98d70c8ee58d76fe34bc92b0 | tests/test_util.py | tests/test_util.py | import os
from aiodownload.util import clean_filename, make_dirs, default_url_transform
def test_clean_filename():
sanitized_filename = clean_filename('français.txt')
assert sanitized_filename == 'francais.txt'
def test_make_dirs(tmpdir):
test_path = os.path.sep.join([tmpdir.strpath, 'test', 'make',... | Add tests for utl module | Add tests for utl module
| Python | mit | jelloslinger/aiodownload | ---
+++
@@ -0,0 +1,25 @@
+import os
+
+from aiodownload.util import clean_filename, make_dirs, default_url_transform
+
+
+def test_clean_filename():
+
+ sanitized_filename = clean_filename('français.txt')
+
+ assert sanitized_filename == 'francais.txt'
+
+
+def test_make_dirs(tmpdir):
+
+ test_path = os.path... | |
0333216c2054effbe68a4af6e38de80f3e52dc7b | sorting.py | sorting.py | def bubble_sort(arr_list):
# For bigO benchmarking
num_of_comparison = 0
num_of_exchanges = 0
for pass_num in range(len(arr_list) - 1, 0, -1):
for j in range(pass_num):
num_of_comparison += 1 # For bigO benchmarking
if arr_list[j] > arr_list[j + 1]:
arr_l... | Implement bubble sort algorithm with benchmarking | Implement bubble sort algorithm with benchmarking
| Python | mit | andela-kerinoso/data_structures_algo | ---
+++
@@ -0,0 +1,34 @@
+def bubble_sort(arr_list):
+ # For bigO benchmarking
+ num_of_comparison = 0
+ num_of_exchanges = 0
+
+ for pass_num in range(len(arr_list) - 1, 0, -1):
+ for j in range(pass_num):
+ num_of_comparison += 1 # For bigO benchmarking
+ if arr_list[j] > ar... | |
381ac12d14a248748e36d79cf5ec32770391f2e6 | tests/test_plugins.py | tests/test_plugins.py | from django.utils import unittest
from hydra_agent import plugins
class TestPlugins(unittest.TestCase):
def test_scan_plugins(self):
"""Test that we get a list of plugin names."""
self.assertNotEqual(plugins.scan_plugins(), [])
@unittest.skip("test not implemented")
def test_load_plugins(... | Add a little test coverage for plugins, needs more. | Add a little test coverage for plugins, needs more.
| Python | mit | intel-hpdd/intel-manager-for-lustre,intel-hpdd/intel-manager-for-lustre,intel-hpdd/intel-manager-for-lustre | ---
+++
@@ -0,0 +1,17 @@
+from django.utils import unittest
+from hydra_agent import plugins
+
+
+class TestPlugins(unittest.TestCase):
+ def test_scan_plugins(self):
+ """Test that we get a list of plugin names."""
+ self.assertNotEqual(plugins.scan_plugins(), [])
+
+ @unittest.skip("test not imp... | |
0d7401d0b651a9c2889a7b0a3ead41ef0c28cedb | tools/sensorama.py | tools/sensorama.py | #!/usr/bin/env python
import sys
import json
def usage():
print "validate.py <jsonfilename>\n"
sys.exit(1)
def main():
if len(sys.argv) != 2:
usage()
fn = sys.argv[1]
print "# fn=" + fn
with open(fn, "r") as f:
js = json.load(f)
f.close()
js = json.dumps(js, sort_ke... | Add a simple validator for the Sensorama JSON format. | Add a simple validator for the Sensorama JSON format.
| Python | bsd-2-clause | wkoszek/sensorama,wkoszek/sensorama | ---
+++
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+import sys
+import json
+
+def usage():
+ print "validate.py <jsonfilename>\n"
+ sys.exit(1)
+
+def main():
+ if len(sys.argv) != 2:
+ usage()
+
+ fn = sys.argv[1]
+ print "# fn=" + fn
+
+ with open(fn, "r") as f:
+ js = json.load(f)
+... | |
bd99d5fe158d911e08b329c05fc8ba46c909d7b4 | scripts/ua/mine_mtarchive.py | scripts/ua/mine_mtarchive.py | import subprocess
import datetime
import pytz
import urllib2
from ingest_from_rucsoundings import RAOB
import psycopg2
POSTGIS = psycopg2.connect(database='postgis', host='iemdb')
def conv( raw):
if float(raw) < -9998:
return None
return float(raw)
sts = datetime.datetime(1946,1,1)
ets = datetime.da... | Add script to process mtarchive's sounding archive | Add script to process mtarchive's sounding archive | Python | mit | akrherz/iem,akrherz/iem,akrherz/iem,akrherz/iem,akrherz/iem | ---
+++
@@ -0,0 +1,84 @@
+import subprocess
+import datetime
+import pytz
+import urllib2
+from ingest_from_rucsoundings import RAOB
+import psycopg2
+
+POSTGIS = psycopg2.connect(database='postgis', host='iemdb')
+
+def conv( raw):
+ if float(raw) < -9998:
+ return None
+ return float(raw)
+
+sts = dat... | |
f4a27896f9c60c64631e27633154474e6ddc3181 | py2/EulerRunner.py | py2/EulerRunner.py | #EulerRunner.py
import datetime
def solve_problem(solve_func):
start = datetime.datetime.now()
result = str(solve_func())
end = datetime.datetime.now()
print 'The answer is "' + result + '". Solved in ' + str((end - start).total_seconds()) + 's'
| Add problem solver to display results and give accurate measure of times to solve | Add problem solver to display results and give accurate measure of times to solve
| Python | mit | DanielGarrett/ProjectEuler | ---
+++
@@ -0,0 +1,8 @@
+#EulerRunner.py
+import datetime
+def solve_problem(solve_func):
+ start = datetime.datetime.now()
+ result = str(solve_func())
+ end = datetime.datetime.now()
+ print 'The answer is "' + result + '". Solved in ' + str((end - start).total_seconds()) + 's'
+ | |
a9aefba284ca775939e41ce4a280cb27f3cd8bf6 | app.py | app.py | """
Usage:
create_room <name> <type_room>
add_person <firstname> <surname> [wants_accomodation="N"]
dojo (-i | --interactive)
dojo (-h | --help | --version)
Options:
-i, --interactive Interactive Mode
-h, --help Show this screen and exit.
"""
from docopt impor... | Make room arg list and Dojo instance | Make room arg list and Dojo instance
| Python | mit | JoshuaOndieki/dojo | ---
+++
@@ -0,0 +1,85 @@
+"""
+ Usage:
+ create_room <name> <type_room>
+ add_person <firstname> <surname> [wants_accomodation="N"]
+ dojo (-i | --interactive)
+ dojo (-h | --help | --version)
+ Options:
+ -i, --interactive Interactive Mode
+ -h, --help Show this scre... | |
d9cd5401a782313a2e02c81c3bc69f25f8fb1acc | peakachulib/float_range.py | peakachulib/float_range.py | class FloatRange(object):
def __init__(self, start, end):
self.start = start
self.end = end
def __eq__(self, other):
return self.start <= other <= self.end
| Add small helper class to check if float parameters are in allowed range | Add small helper class to check if float parameters are in allowed range
| Python | isc | tbischler/PEAKachu | ---
+++
@@ -0,0 +1,6 @@
+class FloatRange(object):
+ def __init__(self, start, end):
+ self.start = start
+ self.end = end
+ def __eq__(self, other):
+ return self.start <= other <= self.end | |
7dbb1bf87a1f423d0241eec4aab7b603801f4f53 | calculate_pnps.py | calculate_pnps.py | #!/usr/bin/env python
"""Module to calculate pn ps."""
from Bio import AlignIO
from Bio.Align import MultipleSeqAlignment
def calculate_pnps(genomes_a, genomes_b, sico_files):
""""""
refseq_ids_a = [genome['RefSeq project ID'] for genome in genomes_a]
refseq_ids_b = [genome['RefSeq project ID'] for genome ... | Add initial modules to calculate pn & ps | Add initial modules to calculate pn & ps
| Python | mit | ODoSE/odose.nl | ---
+++
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+"""Module to calculate pn ps."""
+from Bio import AlignIO
+from Bio.Align import MultipleSeqAlignment
+
+def calculate_pnps(genomes_a, genomes_b, sico_files):
+ """"""
+ refseq_ids_a = [genome['RefSeq project ID'] for genome in genomes_a]
+ refseq_ids_b = [gen... | |
6700d784ff69c800dbc50abed341b20f806bddd2 | configs/new_baselines/mask_rcnn_R_50_FPN_50ep_LSJ.py | configs/new_baselines/mask_rcnn_R_50_FPN_50ep_LSJ.py | from .mask_rcnn_R_50_FPN_100ep_LSJ import (
dataloader,
lr_multiplier,
model,
optimizer,
train,
)
train.max_iter //= 2 # 100ep -> 50ep
| Add 50ep R50 Mask RCNN training recipe to D2 new baselines | Add 50ep R50 Mask RCNN training recipe to D2 new baselines
Summary: Added a training recipe with a shorter training time, reducing `train.max_iter` using the same pattern used to length it for the recipes >100ep.
Reviewed By: rbgirshick
Differential Revision: D28935200
fbshipit-source-id: 8423d125bc628885990a343cbb... | Python | apache-2.0 | facebookresearch/detectron2,facebookresearch/detectron2,facebookresearch/detectron2 | ---
+++
@@ -0,0 +1,9 @@
+from .mask_rcnn_R_50_FPN_100ep_LSJ import (
+ dataloader,
+ lr_multiplier,
+ model,
+ optimizer,
+ train,
+)
+
+train.max_iter //= 2 # 100ep -> 50ep | |
426ccdfd15c703ea2c67e85175265acc76c4beff | capture_circles.py | capture_circles.py | #! /usr/bin/env python
# -*- coding:utf-8 -*-
#
# Capture calibration circles
#
# External dependencies
import cv2
import numpy as np
# Get the camera
camera = cv2.VideoCapture( 0 )
# Acquisition loop
while( True ) :
# Capture image-by-image
_, image = camera.read()
# Convert it to gray
gray = cv2.cv... | Add a circle detection script. | Add a circle detection script.
| Python | mit | microy/RobotVision,microy/RobotVision | ---
+++
@@ -0,0 +1,40 @@
+#! /usr/bin/env python
+# -*- coding:utf-8 -*-
+
+#
+# Capture calibration circles
+#
+
+# External dependencies
+import cv2
+import numpy as np
+
+# Get the camera
+camera = cv2.VideoCapture( 0 )
+# Acquisition loop
+while( True ) :
+ # Capture image-by-image
+ _, image = camera.read(... | |
65c91f14d3131d5e9cbd34cedcbeb508a108203b | src/test/test_orientation.py | src/test/test_orientation.py | #!/usr/bin/env python
import unittest
from math import pi
from orientation import get_angle_between_0_and_2_pi
class OrientationTest(unittest.TestCase):
def setUp(self):
self.delta = 0.000001
def test_when_angle_is_between_0_and_2_pi_then_angle_is_returned(self):
angle = 50 * pi / 180.0
... | Return angle between 0 and 2pi | refactor: Return angle between 0 and 2pi
Consider cases when angle is greater than 2pi and less than -2pi, and when it is exactly 2pi. | Python | mit | bit0001/trajectory_tracking,bit0001/trajectory_tracking | ---
+++
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+import unittest
+from math import pi
+
+from orientation import get_angle_between_0_and_2_pi
+
+
+class OrientationTest(unittest.TestCase):
+
+ def setUp(self):
+ self.delta = 0.000001
+
+ def test_when_angle_is_between_0_and_2_pi_then_angle_is_returned(se... | |
a1229bd5cc1446c11950232ee551acfc99092fcf | kaiser_shift.py | kaiser_shift.py | #!/usr/bin/env python2.7
# ##### BEGIN AGPL LICENSE BLOCK #####
# This file is part of SimpleMMO.
#
# Copyright (C) 2012 Charles Nelson
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, e... | Add a dumb language "translator" function. | Add a dumb language "translator" function.
| Python | agpl-3.0 | cnelsonsic/SimpleMMO,cnelsonsic/SimpleMMO,cnelsonsic/SimpleMMO | ---
+++
@@ -0,0 +1,61 @@
+#!/usr/bin/env python2.7
+# ##### BEGIN AGPL LICENSE BLOCK #####
+# This file is part of SimpleMMO.
+#
+# Copyright (C) 2012 Charles Nelson
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# publishe... | |
bd56f87db537a0381252b68ed06dc4f13eca3018 | sconsole/cmdbar.py | sconsole/cmdbar.py | '''
Define the command bar
'''
# Import third party libs
import urwid
class CommandBar(object):
'''
The object to manage the command bar
'''
def __init__(self, opts):
self.opts = opts
self.tgt_txt = urwid.Text('Target')
self.tgt_edit = urwid.Edit()
self.fun_txt = urwid.... | Add initial command bar module | Add initial command bar module
| Python | apache-2.0 | saltstack/salt-console | ---
+++
@@ -0,0 +1,32 @@
+'''
+Define the command bar
+'''
+# Import third party libs
+import urwid
+
+
+class CommandBar(object):
+ '''
+ The object to manage the command bar
+ '''
+ def __init__(self, opts):
+ self.opts = opts
+ self.tgt_txt = urwid.Text('Target')
+ self.tgt_edit = ... | |
89839288d015e5d90c45279aeca3b6e67d2af00b | examples/test_gen_each_case.py | examples/test_gen_each_case.py | # -*- coding: utf-8 -*-
"""
autodoc.tests.test_unittest
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Autodoc for UnitTest.
:copyright: (c) 2014 Shinya Ohyanagi, All rights reserved.
:license: BSD, see LICENSE for more details.
"""
from unittest import TestCase
from webtest import TestApp
from autodoc import autod... | Add example of generate document by each test case. | Add example of generate document by each test case.
| Python | bsd-3-clause | heavenshell/py-autodoc | ---
+++
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+"""
+ autodoc.tests.test_unittest
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Autodoc for UnitTest.
+
+
+ :copyright: (c) 2014 Shinya Ohyanagi, All rights reserved.
+ :license: BSD, see LICENSE for more details.
+"""
+from unittest import TestCase
+from webtest ... | |
81a90abae2545b29d04b400923725a18816bacba | test/test_github_trending.py | test/test_github_trending.py | import unittest
from githubtrending import trending as githubtrending
from . import data
class TestGithubTrending(unittest.TestCase):
def test_read_page(self):
for each in data.READ_PAGE_DATA:
url = each.get('url')
expected_status_code = each.get('status_code')
respon... | Add test case for read_page | Test: Add test case for read_page
| Python | mit | staranjeet/github-trending-cli | ---
+++
@@ -0,0 +1,18 @@
+import unittest
+
+from githubtrending import trending as githubtrending
+
+from . import data
+
+class TestGithubTrending(unittest.TestCase):
+
+ def test_read_page(self):
+ for each in data.READ_PAGE_DATA:
+ url = each.get('url')
+ expected_status_code = eac... | |
76090f2972386140c71abdf5e008e383cd57a79c | tests/test_infrastructure.py | tests/test_infrastructure.py |
from nose.tools import eq_, assert_raises
from utils import with_app, pretty_print_xml
from sphinxcontrib.traceables.infrastructure import (Traceable,
TraceablesStorage)
# =============================================================================
# Test... | Add tests of certain basic infrastructure behavior | Add tests of certain basic infrastructure behavior
| Python | apache-2.0 | t4ngo/sphinxcontrib-traceables | ---
+++
@@ -0,0 +1,22 @@
+
+from nose.tools import eq_, assert_raises
+from utils import with_app, pretty_print_xml
+from sphinxcontrib.traceables.infrastructure import (Traceable,
+ TraceablesStorage)
+
+
+# =========================================================... | |
38a0e3c7681bdc6bd74d8b80a0aea68c264f418f | tools/heapcheck/PRESUBMIT.py | tools/heapcheck/PRESUBMIT.py | # Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details on the presubmit API built into gcl.
"""
def CheckChang... | Add presubmit checks for suppressions. | Heapchecker: Add presubmit checks for suppressions.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3197014
git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@57132 0039d316-1c4b-4281-b951-d872f2087c98
| Python | bsd-3-clause | dednal/chromium.src,PeterWangIntel/chromium-crosswalk,ondra-novak/chromium.src,timopulkkinen/BubbleFish,mohamed--abdel-maksoud/chromium.src,keishi/chromium,krieger-od/nwjs_chromium.src,fujunwei/chromium-crosswalk,littlstar/chromium.src,jaruba/chromium.src,jaruba/chromium.src,zcbenz/cefode-chromium,hujiajie/pa-chromium,... | ---
+++
@@ -0,0 +1,43 @@
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
+for more details on the presubmit API b... | |
d7c3bf6f7176f595198c078003a1fc8e8f50ea0f | molo/core/migrations/0071_remove_old_image_hashes.py | molo/core/migrations/0071_remove_old_image_hashes.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
def delete_imageinfo(apps, schema_editor):
ImageInfo = apps.get_model('core.ImageInfo')
ImageInfo.objects.all().delete()
class Migration(migrations.Migration):
dependencies = [
('core', '00... | Remove old type of image hashes | Remove old type of image hashes
| Python | bsd-2-clause | praekelt/molo,praekelt/molo,praekelt/molo,praekelt/molo | ---
+++
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+def delete_imageinfo(apps, schema_editor):
+ ImageInfo = apps.get_model('core.ImageInfo')
+ ImageInfo.objects.all().delete()
+
+
+class Migration(migrations.Migration):
+
+... | |
acc1e7d483b206665e3d749947359382d2ba53a5 | tests/test_fixed.py | tests/test_fixed.py | from copperhead import *
import unittest
@cu
def dismantle((x, (y, z))):
return x
@cu
def tuple_inline_test(x):
return dismantle((x,(x,x)))
class TupleInlineTest(unittest.TestCase):
def testTupleInline(self):
self.assertEqual(tuple_inline_test(2), 2)
if __name__ == '__main__':
unittest.main... | Add tests for bugs which have been fixed. | Add tests for bugs which have been fixed.
| Python | apache-2.0 | shyamalschandra/copperhead,shyamalschandra/copperhead,beni55/copperhead,copperhead/copperhead,beni55/copperhead,copperhead/copperhead | ---
+++
@@ -0,0 +1,19 @@
+from copperhead import *
+
+import unittest
+
+@cu
+def dismantle((x, (y, z))):
+ return x
+
+@cu
+def tuple_inline_test(x):
+ return dismantle((x,(x,x)))
+
+class TupleInlineTest(unittest.TestCase):
+ def testTupleInline(self):
+ self.assertEqual(tuple_inline_test(2), 2)
+
+... | |
32cd9776facaa8271b16b28c5dec4c31241f3064 | annot/MODtree_bp_tbl-to-prot_targets.py | annot/MODtree_bp_tbl-to-prot_targets.py | #!/usr/bin/env python3
import sys
import gzip
import re
filename_tbl = sys.argv[1]
filename_base = re.sub(r'.bp\+\_tbl.gz', '', filename_tbl)
print(filename_tbl, filename_base)
sys.exit(1)
blastp_Evalue_cutoff = 0.0001
min_best_targets = 3
def open_file(tmp_filename):
f = open(tmp_filename, 'r')
if tmp_fil... | Make a prot_target table from bp+_tbl | Make a prot_target table from bp+_tbl
| Python | apache-2.0 | taejoonlab/NuevoTx,marcottelab/NuevoTx,marcottelab/NuevoTx,taejoonlab/NuevoTx | ---
+++
@@ -0,0 +1,56 @@
+#!/usr/bin/env python3
+import sys
+import gzip
+import re
+
+filename_tbl = sys.argv[1]
+filename_base = re.sub(r'.bp\+\_tbl.gz', '', filename_tbl)
+
+print(filename_tbl, filename_base)
+sys.exit(1)
+
+blastp_Evalue_cutoff = 0.0001
+min_best_targets = 3
+
+
+def open_file(tmp_filename):
+ ... | |
145df11bb07120d29fd50a6a37a3a2441e63904b | integration-tests/stress_test.py | integration-tests/stress_test.py | #!/usr/bin/env python3
from json import dumps
from random import randint
from sys import argv
from urllib.error import HTTPError
from urllib.request import Request, urlopen
def put_payload(addr: str, payload):
auth = 'mS7karSP9QbD2FFdgBk2QmuTna7fJyp7ll0Vg8gnffIBHKILSrusMslucBzMhwO'
url = 'http://localhost:30... | Add Python script to stress test the system | Add Python script to stress test the system
| Python | bsd-3-clause | channable/icepeak,channable/icepeak,channable/icepeak | ---
+++
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+
+from json import dumps
+from random import randint
+from sys import argv
+from urllib.error import HTTPError
+from urllib.request import Request, urlopen
+
+
+def put_payload(addr: str, payload):
+ auth = 'mS7karSP9QbD2FFdgBk2QmuTna7fJyp7ll0Vg8gnffIBHKILSrusMsluc... | |
a38763f7fb02f574bae8f17c987cff7e7f802b2d | py/two-sum-iv-input-is-a-bst.py | py/two-sum-iv-input-is-a-bst.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 inOrderAsc(self, root):
stack = []
visited = set()
stack.append(root)
while stack:
... | Add py solution for 653. Two Sum IV - Input is a BST | Add py solution for 653. Two Sum IV - Input is a BST
653. Two Sum IV - Input is a BST: https://leetcode.com/problems/two-sum-iv-input-is-a-bst/
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,66 @@
+# 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 inOrderAsc(self, root):
+ stack = []
+ visited = set()
+ s... | |
5bcadebe3f5a1ae3e6e15580ac741660e929d642 | tests/test_rmap.py | tests/test_rmap.py | from skrt.utils import rmap
def test_list():
list_ = [1, 2, 3, 4, 5]
assert rmap(list_, lambda x: x**2, int) == [1, 4, 9, 16, 25]
def test_tuple():
tuple_ = (1, 2, 3, 4, 5)
assert rmap(tuple_, lambda x: x**2, int) == (1, 4, 9, 16, 25)
def test_set():
set_ = {1, 2, 3, 4, 5}
assert rmap(set_... | Add simple tests for rmap | Add simple tests for rmap
| Python | mit | nvander1/skrt | ---
+++
@@ -0,0 +1,21 @@
+from skrt.utils import rmap
+
+
+def test_list():
+ list_ = [1, 2, 3, 4, 5]
+ assert rmap(list_, lambda x: x**2, int) == [1, 4, 9, 16, 25]
+
+
+def test_tuple():
+ tuple_ = (1, 2, 3, 4, 5)
+ assert rmap(tuple_, lambda x: x**2, int) == (1, 4, 9, 16, 25)
+
+
+def test_set():
+ s... | |
2f83733b2f9526b9d81a5b088927218f78ee442b | tests/jobs/test_update_sample.py | tests/jobs/test_update_sample.py | import pytest
import virtool.jobs.create_sample
@pytest.fixture
def test_update_sample_job(mocker, tmpdir, loop, request, dbi, dbs, test_db_connection_string, test_db_name):
tmpdir.mkdir("samples")
tmpdir.mkdir("logs").mkdir("jobs")
settings = {
"data_path": str(tmpdir),
"db_name": test_... | Add test module for update_sample job | Add test module for update_sample job
| Python | mit | igboyes/virtool,virtool/virtool,virtool/virtool,igboyes/virtool | ---
+++
@@ -0,0 +1,87 @@
+import pytest
+
+import virtool.jobs.create_sample
+
+
+@pytest.fixture
+def test_update_sample_job(mocker, tmpdir, loop, request, dbi, dbs, test_db_connection_string, test_db_name):
+ tmpdir.mkdir("samples")
+ tmpdir.mkdir("logs").mkdir("jobs")
+
+ settings = {
+ "data_path"... | |
80f53a346be979e96788e5d45cfe14cf5d12b22a | micall/utils/remove_dupe_dirs.py | micall/utils/remove_dupe_dirs.py | import shutil
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
from pathlib import Path
def parse_args():
# noinspection PyTypeChecker
parser = ArgumentParser(
description='Remove folders that have already been zipped.',
formatter_class=ArgumentDefaultsHelpFormatter)
# no... | Add script to remove duplicate results folders. | Add script to remove duplicate results folders.
| Python | agpl-3.0 | cfe-lab/MiCall,cfe-lab/MiCall,cfe-lab/MiCall | ---
+++
@@ -0,0 +1,52 @@
+import shutil
+from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
+from pathlib import Path
+
+
+def parse_args():
+ # noinspection PyTypeChecker
+ parser = ArgumentParser(
+ description='Remove folders that have already been zipped.',
+ formatter_class=Ar... | |
f1caaf8ed8c11e00342fc45472f2f723a923fa04 | test/test_notification.py | test/test_notification.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
###############################################################################
# Copyright Kitware Inc.
#
# Licensed under the Apache License, Version 2.0 ( the "License" );
# you may not use this file except in compliance with the License.
# You may obtain a copy of ... | Add a test to the notification list endpoint | Add a test to the notification list endpoint
| Python | apache-2.0 | RafaelPalomar/girder,manthey/girder,RafaelPalomar/girder,data-exp-lab/girder,data-exp-lab/girder,girder/girder,data-exp-lab/girder,RafaelPalomar/girder,RafaelPalomar/girder,girder/girder,data-exp-lab/girder,data-exp-lab/girder,jbeezley/girder,Kitware/girder,manthey/girder,girder/girder,Kitware/girder,kotfic/girder,Rafa... | ---
+++
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+###############################################################################
+# Copyright Kitware Inc.
+#
+# Licensed under the Apache License, Version 2.0 ( the "License" );
+# you may not use this file except in compliance with the Li... | |
484636805602348c883d8dc775082169f97cce76 | crawler/management/commands/similar_apps_category_counter.py | crawler/management/commands/similar_apps_category_counter.py | import logging.config
from operator import or_
from django.core.management.base import BaseCommand
from crawler.models import *
logger = logging.getLogger('crawler.command')
class Command(BaseCommand):
help = 'Generate comparison between google similar app and ours'
def handle(self, *args, **options):
... | Create similar category counter command | Create similar category counter command
| Python | apache-2.0 | bkosawa/admin-recommendation | ---
+++
@@ -0,0 +1,43 @@
+import logging.config
+from operator import or_
+
+from django.core.management.base import BaseCommand
+
+from crawler.models import *
+
+logger = logging.getLogger('crawler.command')
+
+
+class Command(BaseCommand):
+ help = 'Generate comparison between google similar app and ours'
+
+ ... | |
f15b886db255e2fd91e98c3a03e9f6200ebb1bf4 | twisted/plugins/txircd_plugin.py | twisted/plugins/txircd_plugin.py | from twisted.application.service import IServiceMaker
from twisted.plugin import IPlugin
from twisted.python import usage
from zope.interface import implements
class Options(usage.Options):
# If we ever start having options, don't forget to put them here
pass
class IRCdServiceMaker(object):
implements(ISe... | Add framework for new Twisted plugin to be filled in as functionality is actually implemented | Add framework for new Twisted plugin to be filled in as functionality is actually implemented
| Python | bsd-3-clause | ElementalAlchemist/txircd,Heufneutje/txircd | ---
+++
@@ -0,0 +1,20 @@
+from twisted.application.service import IServiceMaker
+from twisted.plugin import IPlugin
+from twisted.python import usage
+from zope.interface import implements
+
+class Options(usage.Options):
+ # If we ever start having options, don't forget to put them here
+ pass
+
+class IRCdSer... | |
29f0f543f93f0f3c9df3bf823f43c616199f8d4f | tests/helpers/test_net.py | tests/helpers/test_net.py | import unittest
from pycroft.helpers import net
class IpRegexTestCase(unittest.TestCase):
def test_ip_regex(self):
regex = net.ip_regex
self.assertTrue(regex.match("141.30.228.39"))
self.assertFalse(regex.match("141.3330.228.39"))
self.assertFalse(regex.match("141.3330.228.39."))
... | Add simple test for IP regex | Add simple test for IP regex
Fixes #360
| Python | apache-2.0 | agdsn/pycroft,agdsn/pycroft,agdsn/pycroft,agdsn/pycroft,agdsn/pycroft | ---
+++
@@ -0,0 +1,12 @@
+import unittest
+
+from pycroft.helpers import net
+
+
+class IpRegexTestCase(unittest.TestCase):
+ def test_ip_regex(self):
+ regex = net.ip_regex
+ self.assertTrue(regex.match("141.30.228.39"))
+ self.assertFalse(regex.match("141.3330.228.39"))
+ self.assertF... | |
828e79b9b788b232ebffe99cc69257494b8e1dda | ci/utils.py | ci/utils.py | #!/usr/bin/python
# Copyright (C) 2017 Kubos Corporation
#
# 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 new utility base file for module discovery | Add new utility base file for module discovery
| Python | apache-2.0 | kubostech/KubOS,Psykar/kubos,Psykar/kubos,Psykar/kubos,Psykar/kubos,Psykar/kubos,Psykar/kubos,kubostech/KubOS,Psykar/kubos | ---
+++
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+
+# Copyright (C) 2017 Kubos Corporation
+#
+# 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.... | |
8b85b1a46eade948a8c962b928a9cdd52da7a643 | test/test_datahandler.py | test/test_datahandler.py | import sys
sys.path.append('..')
import unittest
from datahandler import data_handler_factory
from sweep import Sweep
class DataHandlerTestCase(unittest.TestCase):
def setUp(self):
path = 'C:/Dropbox/PhD/sandbox_phd/FolderBrowser/data/2016-09-19#015'
self.sweep = Sweep(path)
data = self.sw... | Add some tests for DataHandler | Add some tests for DataHandler
| Python | mit | mchels/FolderBrowser | ---
+++
@@ -0,0 +1,38 @@
+import sys
+sys.path.append('..')
+import unittest
+from datahandler import data_handler_factory
+from sweep import Sweep
+
+
+class DataHandlerTestCase(unittest.TestCase):
+ def setUp(self):
+ path = 'C:/Dropbox/PhD/sandbox_phd/FolderBrowser/data/2016-09-19#015'
+ self.swee... | |
285f22ffb2fef2bdfdb5fc49fb0c3d72f54f6c88 | fib_list.py | fib_list.py | from peer import begin_tran, end_tran, shared
begin_tran()
lst = shared.setdefault('lst', [0, 1])
end_tran()
while True:
begin_tran()
next_num = lst[-2] + lst[-1]
s.append(next_num)
end_tran()
print(lst[-10:])
| Add a test Python program. | Add a test Python program.
| Python | apache-2.0 | snyderek/floating_temple,snyderek/floating_temple,snyderek/floating_temple | ---
+++
@@ -0,0 +1,13 @@
+from peer import begin_tran, end_tran, shared
+
+begin_tran()
+lst = shared.setdefault('lst', [0, 1])
+end_tran()
+
+while True:
+ begin_tran()
+ next_num = lst[-2] + lst[-1]
+ s.append(next_num)
+ end_tran()
+
+ print(lst[-10:]) | |
0c298a88290ed0d57359de90c9d61619c1d579cc | pykeg/src/pykeg/core/management/commands/common.py | pykeg/src/pykeg/core/management/commands/common.py | # Copyright 2010 Mike Wakerly <opensource@hoho.com>
#
# This file is part of the Pykeg package of the Kegbot project.
# For more information on Pykeg or Kegbot, see http://kegbot.org/
#
# Pykeg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by... | Add small utility module for kb_ commands. | Add small utility module for kb_ commands.
| Python | mit | Kegbot/kegbot-server,Kegbot/kegbot-server,Kegbot/kegbot-server,Kegbot/kegbot-server,Kegbot/kegbot-server | ---
+++
@@ -0,0 +1,39 @@
+# Copyright 2010 Mike Wakerly <opensource@hoho.com>
+#
+# This file is part of the Pykeg package of the Kegbot project.
+# For more information on Pykeg or Kegbot, see http://kegbot.org/
+#
+# Pykeg is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Gene... | |
b13ddcc7d001606faa27637b2cb09e789dff4271 | thinc/tests/layers/test_layers_api.py | thinc/tests/layers/test_layers_api.py | from thinc.api import registry
import pytest
@pytest.mark.parametrize(
"name,kwargs",
[
("CauchySimilarity.v0", {}),
("Dropout.v0", {}),
("Embed.v0", {}),
("ExtractWindow.v0", {}),
("FeatureExtractor.v0", {"columns": [1, 2]}),
("HashEmbed.v0", {"nO": 1, "nV": 2}... | Add layer creation sanity checks | Add layer creation sanity checks
| Python | mit | explosion/thinc,explosion/thinc,explosion/thinc,spacy-io/thinc,spacy-io/thinc,spacy-io/thinc,explosion/thinc | ---
+++
@@ -0,0 +1,34 @@
+from thinc.api import registry
+import pytest
+
+
+@pytest.mark.parametrize(
+ "name,kwargs",
+ [
+ ("CauchySimilarity.v0", {}),
+ ("Dropout.v0", {}),
+ ("Embed.v0", {}),
+ ("ExtractWindow.v0", {}),
+ ("FeatureExtractor.v0", {"columns": [1, 2]}),
+ ... | |
20550e0890e31d98d0fd7e5abd058dcf33aa2ba7 | p002_even_fibonacci_numbers.py | p002_even_fibonacci_numbers.py | #
'''
Project Euler - Problem 2 - Even Fibonacci numbers
https://projecteuler.net/problem=2
Each new term in the Fibonacci sequence is generated by adding the previous two
terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci seq... | Add problem 2 even fibonacci numbers python solution | Add problem 2 even fibonacci numbers python solution
| Python | mit | ChrisFreeman/project-euler | ---
+++
@@ -0,0 +1,45 @@
+#
+'''
+Project Euler - Problem 2 - Even Fibonacci numbers
+https://projecteuler.net/problem=2
+
+Each new term in the Fibonacci sequence is generated by adding the previous two
+terms. By starting with 1 and 2, the first 10 terms will be:
+
+1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
+
+By cons... | |
ff2c8d3f74a69dd8873019ae2e966833ef4d79fd | pombola/south_africa/management/commands/south_africa_export_committee_members.py | pombola/south_africa/management/commands/south_africa_export_committee_members.py | """Export a CSV listing committee members with term dates."""
import unicodecsv as csv
import os
import collections
from pombola.core.models import Person, Organisation, OrganisationKind
from django.core.management.base import BaseCommand, CommandError
from django.utils import dateformat
def formatApproxDate(date)... | Add export script for committee members | Add export script for committee members
| Python | agpl-3.0 | mysociety/pombola,mysociety/pombola,mysociety/pombola,mysociety/pombola,mysociety/pombola,mysociety/pombola | ---
+++
@@ -0,0 +1,89 @@
+"""Export a CSV listing committee members with term dates."""
+
+import unicodecsv as csv
+import os
+import collections
+
+from pombola.core.models import Person, Organisation, OrganisationKind
+
+from django.core.management.base import BaseCommand, CommandError
+from django.utils import da... | |
e552a70777ee5733434707f1d1fa334a8909cd87 | tests/test_crossmatch.py | tests/test_crossmatch.py | from __future__ import unicode_literals, division, absolute_import
from tests import FlexGetBase
class TestCrossmatch(FlexGetBase):
__yaml__ = """
tasks:
test_title:
mock:
- title: entry 1
- title: entry 2
crossmatch:
from:
... | Add a test for crossmatch | Add a test for crossmatch
| Python | mit | jacobmetrick/Flexget,thalamus/Flexget,ianstalk/Flexget,ibrahimkarahan/Flexget,qk4l/Flexget,qvazzler/Flexget,ibrahimkarahan/Flexget,lildadou/Flexget,Flexget/Flexget,drwyrm/Flexget,vfrc2/Flexget,ZefQ/Flexget,patsissons/Flexget,ratoaq2/Flexget,JorisDeRieck/Flexget,Pretagonist/Flexget,grrr2/Flexget,offbyone/Flexget,thalamu... | ---
+++
@@ -0,0 +1,22 @@
+from __future__ import unicode_literals, division, absolute_import
+from tests import FlexGetBase
+
+class TestCrossmatch(FlexGetBase):
+ __yaml__ = """
+ tasks:
+ test_title:
+ mock:
+ - title: entry 1
+ - title: entry 2
+ cross... | |
66d84f16e01ac92d3f2973bcb7b9297e3e04ad85 | tests/models.py | tests/models.py | import logging
class MockHandler(logging.Handler):
def __init__(self, *args, **kwargs):
self.reset()
logging.Handler.__init__(self, *args, **kwargs)
def emit(self, record):
self.messages[record.levelname.lower()].append(record.getMessage())
def reset(self):
self.messages ... | Add a mock log handler for aggregating log messages | Add a mock log handler for aggregating log messages
| Python | bsd-2-clause | chop-dbhi/varify,chop-dbhi/varify,chop-dbhi/varify,chop-dbhi/varify | ---
+++
@@ -0,0 +1,19 @@
+import logging
+
+
+class MockHandler(logging.Handler):
+ def __init__(self, *args, **kwargs):
+ self.reset()
+ logging.Handler.__init__(self, *args, **kwargs)
+
+ def emit(self, record):
+ self.messages[record.levelname.lower()].append(record.getMessage())
+
+ ... | |
1c2f6cccdda57b52ab779539acbe42a427e4b21e | conftest.py | conftest.py | import pandana.network as pdna
# Pandana uses global state for networks,
# so we have to pre-declare here how many networks will be
# created during testing.
#
# If you see an error that looks like:
# AssertionError: Adding more networks than have been reserved
# then you probably need to update this number.
num_n... | Declare number of Networks used during testing | Declare number of Networks used during testing
Done via conftest.py file (a special feature of pytest)
that calls pandana.network.reserve_num_graphs.
| Python | agpl-3.0 | waddell/pandana,rafapereirabr/pandana,rafapereirabr/pandana,synthicity/pandana,rafapereirabr/pandana,synthicity/pandana,SANDAG/pandana,UDST/pandana,synthicity/pandana,UDST/pandana,SANDAG/pandana,UDST/pandana,waddell/pandana,SANDAG/pandana,UDST/pandana,rafapereirabr/pandana,waddell/pandana,synthicity/pandana,waddell/pan... | ---
+++
@@ -0,0 +1,11 @@
+import pandana.network as pdna
+
+# Pandana uses global state for networks,
+# so we have to pre-declare here how many networks will be
+# created during testing.
+#
+# If you see an error that looks like:
+# AssertionError: Adding more networks than have been reserved
+# then you probab... | |
a3907ed778c827a2807cb66d67f639abe706a808 | examples/btest.py | examples/btest.py | import numpy as np
import loopy as lp
target = lp.CudaTarget()
kernel = lp.make_kernel(
"{ [i_node,j_node]: 0<=i_node,j_node<n_node}",
"""
<float32> coupling_value = params(1)
<float32> speed_value = params(0)
<float32> dt=0.1
<float32> M_PI_F = 2.0
<float32> rec_n = 1.0f / n_node
<float32> rec_speed_dt = 1... | Test example to recreate kernel from hackathon and explore loopy tutorial | Test example to recreate kernel from hackathon and explore loopy tutorial
| Python | apache-2.0 | the-virtual-brain/tvb-hpc,the-virtual-brain/tvb-hpc,the-virtual-brain/tvb-hpc | ---
+++
@@ -0,0 +1,50 @@
+import numpy as np
+import loopy as lp
+
+target = lp.CudaTarget()
+
+kernel = lp.make_kernel(
+ "{ [i_node,j_node]: 0<=i_node,j_node<n_node}",
+ """
+ <float32> coupling_value = params(1)
+ <float32> speed_value = params(0)
+
+ <float32> dt=0.1
+ <float32> M_PI_F = 2.0
+ <float32> rec_n = ... | |
db92e3818e9dac883288bf24e04d64a5d94054ac | xos/helloworld/models.py | xos/helloworld/models.py | from django.db import models
from core.models import User, Service, SingletonModel, PlCoreBase, Instance
from core.models.plcorebase import StrippedCharField
import os
from django.db import models
from django.forms.models import model_to_dict
from django.db.models import Q
# Create your models here.
class Hello(PlCo... | from django.db import models
from core.models import User, Service, SingletonModel, PlCoreBase, Instance
from core.models.plcorebase import StrippedCharField
import os
from django.db import models
from django.forms.models import model_to_dict
from django.db.models import Q
# Create your models here.
class Hello(PlCo... | Change old 'sliver' ref to instance | Change old 'sliver' ref to instance
| Python | apache-2.0 | xmaruto/mcord,cboling/xos,xmaruto/mcord,xmaruto/mcord,jermowery/xos,cboling/xos,cboling/xos,cboling/xos,jermowery/xos,jermowery/xos,xmaruto/mcord,jermowery/xos,cboling/xos | ---
+++
@@ -11,7 +11,7 @@
class Hello(PlCoreBase):
name = models.CharField(max_length=254,help_text="Salutation e.g. Hello or Bonjour")
- sliver_backref = models.ForeignKey(Instance)
+ instance_backref = models.ForeignKey(Instance)
class World(PlCoreBase):
name = models.CharField(max_length=... |
eb984f5b3267f090cbfe0c0b5974126ebef7190c | tests/unit/test__compat.py | tests/unit/test__compat.py | # -*- coding: utf-8 -*-
'''
Unit tests for salt.config
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
import sys
# Import Salt Testing libs
from tests.support.helpers import with_tempdir, with_tempfile, destructiveTest
from tests.support.mixins import ... | Add unit tests for _compat.py | Add unit tests for _compat.py
| Python | apache-2.0 | saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt | ---
+++
@@ -0,0 +1,78 @@
+# -*- coding: utf-8 -*-
+'''
+Unit tests for salt.config
+'''
+
+# Import Python libs
+from __future__ import absolute_import, print_function, unicode_literals
+import logging
+import sys
+
+# Import Salt Testing libs
+from tests.support.helpers import with_tempdir, with_tempfile, destructiv... | |
fcc2013d1d3a21a1c23cafbaf24cb49a74d054ea | tools/committee_counter.py | tools/committee_counter.py | #!/usr/bin/env
from pupa.core import db
for orga in db.organizations.find({"classification": "committee"}):
memberships = db.memberships.find({
"organization_id": orga['_id'],
"end_date": None
}).count()
print memberships, orga['jurisdiction_id'], orga['name']
| Add a counter to help with debugging. | Add a counter to help with debugging.
| Python | bsd-3-clause | rshorey/pupa,influence-usa/pupa,opencivicdata/pupa,datamade/pupa,mileswwatkins/pupa,mileswwatkins/pupa,opencivicdata/pupa,datamade/pupa,rshorey/pupa,influence-usa/pupa | ---
+++
@@ -0,0 +1,11 @@
+#!/usr/bin/env
+
+from pupa.core import db
+
+
+for orga in db.organizations.find({"classification": "committee"}):
+ memberships = db.memberships.find({
+ "organization_id": orga['_id'],
+ "end_date": None
+ }).count()
+ print memberships, orga['jurisdiction_id'], org... | |
15012a11fc0e2f28982ea7956f822dff3af800d7 | application/list_locations.py | application/list_locations.py | #!/usr/bin/python3
'''
Created on Dec 15, 2014
@author: lwoydziak
'''
from jsonconfigfile import Env
from providers import digitalOceanHosting
'''usage:
list_locations.py # clean up
'''
def ListLocations():
initial... | Add a factility to list regions/locations. | Add a factility to list regions/locations.
| Python | mit | Pipe-s/dynamic_machine,Pipe-s/dynamic_machine | ---
+++
@@ -0,0 +1,41 @@
+#!/usr/bin/python3
+'''
+Created on Dec 15, 2014
+
+@author: lwoydziak
+'''
+from jsonconfigfile import Env
+from providers import digitalOceanHosting
+
+'''usage:
+list_locations.py # clean up
+... | |
5410e89233fc4b01e8f74003ecc6dbc126b50728 | bin/fake_fastq.py | bin/fake_fastq.py | import os
import sys
import argparse
from rob import read_fasta
__author__ = 'Rob Edwards'
parser = argparse.ArgumentParser(description='Convert a fasta file to fastq, faking the qual scores')
parser.add_argument('-f', help='fasta file', required=True)
parser.add_argument('-q', help='fastq output file', required=True... | Convert a fasta file to fastq | Convert a fasta file to fastq
| Python | mit | linsalrob/EdwardsLab,linsalrob/EdwardsLab,linsalrob/EdwardsLab,linsalrob/EdwardsLab,linsalrob/EdwardsLab | ---
+++
@@ -0,0 +1,21 @@
+import os
+import sys
+import argparse
+from rob import read_fasta
+
+__author__ = 'Rob Edwards'
+
+parser = argparse.ArgumentParser(description='Convert a fasta file to fastq, faking the qual scores')
+parser.add_argument('-f', help='fasta file', required=True)
+parser.add_argument('-q', he... | |
8df96bee4fd11d552ffeb01ec8b7025c7cacd8ca | convertPositions.py | convertPositions.py | """
Will read a gzipped file containing build conversion info for snps (based on
snpdb), and save these extra values to the fasttrack database.
Recent version is 38. We use this because HUNT is now on 37 (19).
First parameter is build number (now we use 37). Second is gzip filename (now
we use b147_SNPChrPosOnRef_105... | Add script to convert positions by adding extra columns for build | Add script to convert positions by adding extra columns for build
| Python | agpl-3.0 | hunt-genes/gwasc,hunt-genes/fasttrack,hunt-genes/gwasc,hunt-genes/fasttrack | ---
+++
@@ -0,0 +1,82 @@
+"""
+Will read a gzipped file containing build conversion info for snps (based on
+snpdb), and save these extra values to the fasttrack database.
+
+Recent version is 38. We use this because HUNT is now on 37 (19).
+
+First parameter is build number (now we use 37). Second is gzip filename (... | |
7cd74b37f0f2be43a6b56f0898f68ef166de3f87 | server/src/weblab/db/upgrade/scheduling/versions/2ecc7c4ec0c5_add_experiment_infor.py | server/src/weblab/db/upgrade/scheduling/versions/2ecc7c4ec0c5_add_experiment_infor.py | """Add experiment information
Revision ID: 2ecc7c4ec0c5
Revises: None
Create Date: 2013-04-21 19:16:09.441855
"""
# revision identifiers, used by Alembic.
revision = '2ecc7c4ec0c5'
down_revision = None
from alembic import op
import sqlalchemy as sa
def upgrade():
pass
def downgrade():
pass
| Add initial upgrade for supporting exp_info | Add initial upgrade for supporting exp_info
| Python | bsd-2-clause | weblabdeusto/weblabdeusto,porduna/weblabdeusto,porduna/weblabdeusto,zstars/weblabdeusto,weblabdeusto/weblabdeusto,morelab/weblabdeusto,weblabdeusto/weblabdeusto,morelab/weblabdeusto,zstars/weblabdeusto,porduna/weblabdeusto,zstars/weblabdeusto,weblabdeusto/weblabdeusto,porduna/weblabdeusto,zstars/weblabdeusto,weblabdeus... | ---
+++
@@ -0,0 +1,22 @@
+"""Add experiment information
+
+Revision ID: 2ecc7c4ec0c5
+Revises: None
+Create Date: 2013-04-21 19:16:09.441855
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '2ecc7c4ec0c5'
+down_revision = None
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+ p... | |
88bfcb37227b1e02abfc44fa931a940cce354e03 | photutils/utils/_optional_deps.py | photutils/utils/_optional_deps.py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Checks for optional dependencies using lazy import from
`PEP 562 <https://www.python.org/dev/peps/pep-0562/>`_.
"""
import importlib
# This list is a duplicate of the dependencies in setup.cfg "all".
optional_deps = ['scipy', 'matplotlib', 'scikit-imag... | Add module for optional dependency checking | Add module for optional dependency checking
| Python | bsd-3-clause | larrybradley/photutils,astropy/photutils | ---
+++
@@ -0,0 +1,22 @@
+# Licensed under a 3-clause BSD style license - see LICENSE.rst
+"""Checks for optional dependencies using lazy import from
+`PEP 562 <https://www.python.org/dev/peps/pep-0562/>`_.
+"""
+import importlib
+
+# This list is a duplicate of the dependencies in setup.cfg "all".
+optional_deps = [... | |
7a971038a1a2c045387523aef858c841ae3d4bdc | tests/integration/suite/test_notifier.py | tests/integration/suite/test_notifier.py | from kubernetes.client import CustomObjectsApi
from .common import random_str
def test_notifier_smtp_password(admin_mc, remove_resource):
client = admin_mc.client
name = random_str()
password = random_str()
notifier = client.create_notifier(clusterId="local",
name... | Test Email Notifier SMTP Password | Test Email Notifier SMTP Password
| Python | apache-2.0 | rancher/rancher,rancher/rancher,rancherio/rancher,rancher/rancher,cjellick/rancher,cjellick/rancher,rancher/rancher,rancherio/rancher,cjellick/rancher | ---
+++
@@ -0,0 +1,62 @@
+from kubernetes.client import CustomObjectsApi
+from .common import random_str
+
+
+def test_notifier_smtp_password(admin_mc, remove_resource):
+ client = admin_mc.client
+ name = random_str()
+ password = random_str()
+ notifier = client.create_notifier(clusterId="local",
+ ... | |
c12357b7dfb673639418078994d48c2696848b06 | html5lib/tests/tokenizertotree.py | html5lib/tests/tokenizertotree.py | import sys
import os
import json
import re
import html5lib
import support
import test_parser
import test_tokenizer
p = html5lib.HTMLParser()
unnamespaceExpected = re.compile(r"^(\s*)<html (\S+)>", re.M).sub
def main(out_path):
if not os.path.exists(out_path):
sys.stderr.write("Path %s does not exist"%ou... | Add file for converting the tokenizer tests to tree tests (assuming html5lib works with them correctly) | Add file for converting the tokenizer tests to tree tests (assuming html5lib works with them correctly)
| Python | mit | alex/html5lib-python,dstufft/html5lib-python,alex/html5lib-python,gsnedders/html5lib-python,mgilson/html5lib-python,dstufft/html5lib-python,mindw/html5lib-python,ordbogen/html5lib-python,html5lib/html5lib-python,html5lib/html5lib-python,mindw/html5lib-python,ordbogen/html5lib-python,alex/html5lib-python,dstufft/html5li... | ---
+++
@@ -0,0 +1,64 @@
+import sys
+import os
+import json
+import re
+
+import html5lib
+import support
+import test_parser
+import test_tokenizer
+
+p = html5lib.HTMLParser()
+
+unnamespaceExpected = re.compile(r"^(\s*)<html (\S+)>", re.M).sub
+
+def main(out_path):
+ if not os.path.exists(out_path):
+ ... | |
8901e618318c901287d2af5f701ce9ae44c79f18 | avena/tests/test-xcor2.py | avena/tests/test-xcor2.py | #!/usr/bin/env python
from numpy import all, array
from .. import np, xcor2
def test_zeropad():
x = array([[1]])
y = array([[1, 0, 0], [0, 0, 0], [0, 0, 0]])
z = xcor2._zeropad(x, y.shape)
assert all(z == y)
def test_xcor2_shape():
x = (3, 3)
y = (1, 1)
z = (4, 4)
assert xcor2._xco... | Add some unit tests for the xcor2 module. | Add some unit tests for the xcor2 module.
| Python | isc | eliteraspberries/avena | ---
+++
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+
+from numpy import all, array
+
+from .. import np, xcor2
+
+
+def test_zeropad():
+ x = array([[1]])
+ y = array([[1, 0, 0], [0, 0, 0], [0, 0, 0]])
+ z = xcor2._zeropad(x, y.shape)
+ assert all(z == y)
+
+
+def test_xcor2_shape():
+ x = (3, 3)
+ y =... | |
25fc278e90857c4e26a87e7795a784d159c33d89 | py/convert-bst-to-greater-tree.py | py/convert-bst-to-greater-tree.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 inOrderDesc(self, root):
if root:
self.inOrderDesc(root.right)
root.val = self.increm... | Add py solution for 538. Convert BST to Greater Tree | Add py solution for 538. Convert BST to Greater Tree
538. Convert BST to Greater Tree: https://leetcode.com/problems/convert-bst-to-greater-tree/
| 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 inOrderDesc(self, root):
+ if root:
+ self.inOrderDesc(root.rig... | |
edb2622e6da18bd2cff523fe96ec56cec0c1b94f | lvsr/configs/timit_bothgru_cumsum_250.py | lvsr/configs/timit_bothgru_cumsum_250.py | Config(
net=Config(
dim_dec=250,
dim_bidir=250,
dims_bottom=[250],
dec_transition='GatedRecurrent',
enc_transition='GatedRecurrent',
attention_type='content_and_cumsum'),
initialization=[
("/recognizer", "rec_weights_init", "IsotropicGaussian(0.1)")],
... | Add config without dropout for 250 hidden units | Add config without dropout for 250 hidden units
| Python | mit | rizar/attention-lvcsr,rizar/attention-lvcsr,nke001/attention-lvcsr,rizar/attention-lvcsr,nke001/attention-lvcsr,rizar/attention-lvcsr,nke001/attention-lvcsr,nke001/attention-lvcsr,rizar/attention-lvcsr,nke001/attention-lvcsr | ---
+++
@@ -0,0 +1,12 @@
+Config(
+ net=Config(
+ dim_dec=250,
+ dim_bidir=250,
+ dims_bottom=[250],
+ dec_transition='GatedRecurrent',
+ enc_transition='GatedRecurrent',
+ attention_type='content_and_cumsum'),
+ initialization=[
+ ("/recognizer", "rec_weights_in... | |
acdc2c8c6d47e6c6ffc15c9fea1aff20a2645363 | helenae/gui/widgets/InputLinkCtrl.py | helenae/gui/widgets/InputLinkCtrl.py | # -*- coding: utf-8 -*-
import wx
import platform
class InputLink(wx.Dialog):
def __init__(self, parent, id, title, ico_folder):
if platform.system() == 'Darwin':
wx.Dialog.__init__(self, parent, id, title, style=wx.DEFAULT_FRAME_STYLE &
... | Add input dialog for links | Add input dialog for links
| Python | mit | Relrin/Helenae,Relrin/Helenae,Relrin/Helenae | ---
+++
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+import wx
+import platform
+
+
+class InputLink(wx.Dialog):
+ def __init__(self, parent, id, title, ico_folder):
+
+ if platform.system() == 'Darwin':
+ wx.Dialog.__init__(self, parent, id, title, style=wx.DEFAULT_FRAME_STYLE &
+ ... | |
cef078ebfa96bfea7d36b5cb1bf90f8cbd070df5 | domino/utils/gender.py | domino/utils/gender.py | # Author: Álvaro Parafita (parafita.alvaro@gmail.com)
class Gender:
"""
Class to represent gender as ints.
Definition of each gender is according to ISO/IEC 5218.
An instance of Gender must be created passing it a converter function
that takes any value and returns a string in
... | Add utils package with offtopic functions | Add utils package with offtopic functions
Add Gender class for proper Gender representation
| Python | mit | aparafita/domino | ---
+++
@@ -0,0 +1,81 @@
+# Author: Álvaro Parafita (parafita.alvaro@gmail.com)
+
+class Gender:
+ """
+ Class to represent gender as ints.
+ Definition of each gender is according to ISO/IEC 5218.
+
+ An instance of Gender must be created passing it a converter function
+ that takes an... | |
c413b91e7316055dc6ff5c82ee35e94e2a32fa62 | lpthw/ex21.py | lpthw/ex21.py | def add(a, b):
print "ADDING %d + %d" % (a, b)
return a + b
def subtract(a, b):
print "SUBTRACTING %d - %d" % (a, b)
return a -b
def multiply(a, b):
print "MULTIPLYING %d * %d" % (a, b)
return a * b
def divide(a, b):
print "DIVIDING %d / %d" % (a, b)
return a / b
print "Let's do som... | Add work from exercise 21 in lpthw. | Add work from exercise 21 in lpthw.
| Python | mit | jaredmanning/learning,jaredmanning/learning | ---
+++
@@ -0,0 +1,35 @@
+def add(a, b):
+ print "ADDING %d + %d" % (a, b)
+ return a + b
+
+def subtract(a, b):
+ print "SUBTRACTING %d - %d" % (a, b)
+ return a -b
+
+def multiply(a, b):
+ print "MULTIPLYING %d * %d" % (a, b)
+ return a * b
+
+def divide(a, b):
+ print "DIVIDING %d / %d" % (a, ... | |
6c1ecad37e4735ed77403f82ad2464115447b4c9 | tests/graphics/toolbarpalettes.py | tests/graphics/toolbarpalettes.py | # Copyright (C) 2007, Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distrib... | Add testcase for toolbar and tray palettes. | Add testcase for toolbar and tray palettes.
| Python | lgpl-2.1 | i5o/sugar-toolkit-gtk3,gusDuarte/sugar-toolkit-gtk3,ceibal-tatu/sugar-toolkit-gtk3,godiard/sugar-toolkit-gtk3,ceibal-tatu/sugar-toolkit,tchx84/debian-pkg-sugar-toolkit,samdroid-apps/sugar-toolkit-gtk3,Daksh/sugar-toolkit-gtk3,manuq/sugar-toolkit-gtk3,ceibal-tatu/sugar-toolkit,i5o/sugar-toolkit-gtk3,manuq/sugar-toolkit-... | ---
+++
@@ -0,0 +1,65 @@
+# Copyright (C) 2007, Red Hat, Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later ver... | |
ac6a4aff86c312b507353e7f0ae3f3447328d8f2 | decorate_all_functions.py | decorate_all_functions.py | from functools import wraps
def decorate_all_functions(func_decorator):
def decorator(cls):
for name, obj in vars(cls).items():
if callable(obj):
try:
obj = obj.__func__ # unwrap Python 2 unbound method
except AttributeError:
... | Add an example to decorate each of the functions in the class. | Add an example to decorate each of the functions in the class.
| Python | mit | iandmyhand/python-utils | ---
+++
@@ -0,0 +1,37 @@
+from functools import wraps
+
+
+def decorate_all_functions(func_decorator):
+ def decorator(cls):
+ for name, obj in vars(cls).items():
+ if callable(obj):
+ try:
+ obj = obj.__func__ # unwrap Python 2 unbound method
+ e... | |
36bc44a04e9a2bbed30ce19522bdf608afa3bfea | tests/test_gross_total_volume.py | tests/test_gross_total_volume.py | from gypsy import gross_total_volume
def test_pl():
# TODO: known value
# TODO: 0 as an input
# TODO: negative as an input
# TODO: scalar and array
gross_total_volume.gtv_pl(0, 0)
assert False
def test_aw():
# TODO: known value
# TODO: 0 as an input
# TODO: negative as an input
... | Add reminder for testing gross total volume | Add reminder for testing gross total volume
| Python | mit | tesera/pygypsy,tesera/pygypsy | ---
+++
@@ -0,0 +1,37 @@
+from gypsy import gross_total_volume
+
+def test_pl():
+ # TODO: known value
+ # TODO: 0 as an input
+ # TODO: negative as an input
+ # TODO: scalar and array
+ gross_total_volume.gtv_pl(0, 0)
+ assert False
+
+def test_aw():
+ # TODO: known value
+ # TODO: 0 as an in... | |
35b275cb3cb714bcc1634d84d6b4272f598e6bf3 | exercises/chapter_04/exercise_04_01/exercise_04_01.py | exercises/chapter_04/exercise_04_01/exercise_04_01.py | # 4-1. Pizzas
favorite_pizzas = ["Columpus", "Marco Polo", "Amerikana"]
for pizza in favorite_pizzas:
print(pizza)
| Add first basic version of exercise 4.1. | Add first basic version of exercise 4.1.
| Python | mit | HenrikSamuelsson/python-crash-course | ---
+++
@@ -0,0 +1,6 @@
+# 4-1. Pizzas
+
+favorite_pizzas = ["Columpus", "Marco Polo", "Amerikana"]
+
+for pizza in favorite_pizzas:
+ print(pizza) | |
69918ffce16158842e61d1cc89ec81d8f791ab43 | support/upgrade.py | support/upgrade.py | # encoding: utf-8
# Copyright 2010 California Institute of Technology. ALL RIGHTS
# RESERVED. U.S. Government Sponsorship acknowledged.
#
# Upgrade an existing installation of the EDRN public portal.
#
# Execute with a Zope instance's "run" command, ie:
# bin/instance-debug run support/upgrade.py
#
# Assumes that th... | Upgrade procedure for EDRN portal | Upgrade procedure for EDRN portal
| Python | apache-2.0 | EDRN/PublicPortal,EDRN/PublicPortal | ---
+++
@@ -0,0 +1,57 @@
+# encoding: utf-8
+# Copyright 2010 California Institute of Technology. ALL RIGHTS
+# RESERVED. U.S. Government Sponsorship acknowledged.
+#
+# Upgrade an existing installation of the EDRN public portal.
+#
+# Execute with a Zope instance's "run" command, ie:
+# bin/instance-debug run supp... | |
c74c7f7799c9f4ebf0930bfc3b83226b56eb7fcc | tools/testDevice/testDevice.py | tools/testDevice/testDevice.py | #!/usr/bin/python
#
# Copyright 2015 - 2016 Boling Consulting Solutions, bcsw.net
#
# 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
#
... | Test RESTCONF device (for XRD and eventually other debugging purposes) | Test RESTCONF device (for XRD and eventually other debugging purposes)
| Python | apache-2.0 | cboling/onos-restconf-providers,cboling/onos-restconf-providers,cboling/onos-restconf-providers | ---
+++
@@ -0,0 +1,74 @@
+#!/usr/bin/python
+#
+# Copyright 2015 - 2016 Boling Consulting Solutions, bcsw.net
+#
+# 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://ww... | |
f4e35be12b0c0af40f7a9e18871526c7f482b5be | python/examples/bspline_pickle.py | python/examples/bspline_pickle.py | ###################################################################################
# Pickle/unpickle functionality for the BSpline class. #
# Works by creating a named temporary file which the BSpline is saved to. #
# The temp file is then read and the data is returned to Pickle. ... | Add example showing how to pickle/unpickle a BSpline object | Add example showing how to pickle/unpickle a BSpline object
| Python | mpl-2.0 | bgrimstad/splinter,bgrimstad/splinter,bgrimstad/splinter,bgrimstad/splinter,bgrimstad/splinter | ---
+++
@@ -0,0 +1,58 @@
+###################################################################################
+# Pickle/unpickle functionality for the BSpline class. #
+# Works by creating a named temporary file which the BSpline is saved to. #
+# The temp file is then read and the ... | |
b0b2e6d0fe5656825bc4ded8314297983f3401d9 | utils.py | utils.py | #!/usr/bin/env python
import argparse
import sys
def parse_basic_args(args=sys.argv[1:]):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
'--input', '-i', metavar='FILE',
default=sys.stdin, type=argparse.FileType('r'),
help='the file to process (default: std... | Add basic argument parser that will be used in basic srt tools | Add basic argument parser that will be used in basic srt tools
| Python | mit | cdown/srt | ---
+++
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+import argparse
+import sys
+
+
+def parse_basic_args(args=sys.argv[1:]):
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument(
+ '--input', '-i', metavar='FILE',
+ default=sys.stdin, type=argparse.FileType('r'),
+ ... | |
bdd8a51d29da86d764bf472219dbe17eea3f3674 | tests/gl_test_2.py | tests/gl_test_2.py | #!/usr/bin/env python
'''
'''
__docformat__ = 'restructuredtext'
__version__ = '$Id$'
import pyglet.window
from pyglet.window.event import *
import time
from pyglet.GL.VERSION_1_1 import *
from pyglet.GLU.VERSION_1_1 import *
from pyglet import clock
factory = pyglet.window.WindowFactory()
factory.config._attribut... | Test two windows drawing GL with different contexts. | Test two windows drawing GL with different contexts.
git-svn-id: d4fdfcd4de20a449196f78acc655f735742cd30d@45 14d46d22-621c-0410-bb3d-6f67920f7d95
| Python | bsd-3-clause | regular/pyglet-avbin-optimizations,regular/pyglet-avbin-optimizations,regular/pyglet-avbin-optimizations,regular/pyglet-avbin-optimizations | ---
+++
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+'''
+'''
+
+__docformat__ = 'restructuredtext'
+__version__ = '$Id$'
+
+import pyglet.window
+from pyglet.window.event import *
+import time
+
+from pyglet.GL.VERSION_1_1 import *
+from pyglet.GLU.VERSION_1_1 import *
+from pyglet import clock
+
+factory = pyglet.win... | |
79a451ca7ff1e08bf4b126e8a4565166c203227e | scripts/extract_syscall.py | scripts/extract_syscall.py | #! /usr/bin/env python
from __future__ import print_function
import argparse
import sys
import re
PREAMBULE = """
#include <python2.7/Python.h>
#include "PythonBindings.h"
#include "Registers.h"
#include "asm/unistd_64.h"
void initLinux64Env(PyObject *idLinux64ClassDict)
{\
"""
SMT = ' PyDict_SetItemString(idLi... | Create a script that parse asm/unistd_64.h to fetch syscalls ids. | Create a script that parse asm/unistd_64.h to fetch syscalls ids.
| Python | apache-2.0 | JonathanSalwan/Triton,JonathanSalwan/Triton,JonathanSalwan/Triton,JonathanSalwan/Triton,JonathanSalwan/Triton | ---
+++
@@ -0,0 +1,39 @@
+#! /usr/bin/env python
+
+from __future__ import print_function
+
+import argparse
+import sys
+import re
+
+PREAMBULE = """
+#include <python2.7/Python.h>
+
+#include "PythonBindings.h"
+#include "Registers.h"
+#include "asm/unistd_64.h"
+
+
+void initLinux64Env(PyObject *idLinux64ClassDict... | |
9c4224a13c38e319dd10be6964f36b6f0ae12553 | python/ember/examples/example_cylindrical_inward.py | python/ember/examples/example_cylindrical_inward.py | #!/usr/bin/env python
"""
An inwardly-propagating, cylindrical, strained, lean flame.
The flame radius, defined by the centroid of the heat release
rate, is specified. The stagnation surface is a cylinder located
at a greater radius than the flame (on the burned side).
In this configuration, the curvature and stretchi... | Add example of an inwardly-propagating cylindrical flame | Add example of an inwardly-propagating cylindrical flame
| Python | mit | speth/ember,speth/ember,speth/ember | ---
+++
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+"""
+An inwardly-propagating, cylindrical, strained, lean flame.
+The flame radius, defined by the centroid of the heat release
+rate, is specified. The stagnation surface is a cylinder located
+at a greater radius than the flame (on the burned side).
+
+In this config... | |
6413bf641060658bd057c330a4779d8460250d8b | tests/grammar_term-nonterm_test/TerminalHaveTest.py | tests/grammar_term-nonterm_test/TerminalHaveTest.py | #!/usr/bin/env python
"""
:Author Patrik Valkovic
:Created 23.06.2017 16:39
:Licence GNUv3
Part of grammpy
"""
from unittest import TestCase
from grammpy import Grammar
class TempClass:
pass
class TerminalAddingTest(TestCase):
def test_haveTermEmpty(self):
gr = Grammar()
self.assertFalse(gr... | Add test for have_term method if array is passed | Add test for have_term method if array is passed
| Python | mit | PatrikValkovic/grammpy | ---
+++
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+"""
+:Author Patrik Valkovic
+:Created 23.06.2017 16:39
+:Licence GNUv3
+Part of grammpy
+
+"""
+from unittest import TestCase
+from grammpy import Grammar
+
+
+class TempClass:
+ pass
+
+
+class TerminalAddingTest(TestCase):
+ def test_haveTermEmpty(self):
+ ... | |
7a5af8d2c60327a76ae96572e5ee807be299e347 | django_mc/migration_operations.py | django_mc/migration_operations.py | from django.db import migrations
ALL_REGIONS = object()
class _ManageComponentTypeInRegions(migrations.RunPython):
"""
Requires all migrations of ``django.contrib.contenttypes`` to be applied.
"""
def __init__(self, component_app_label, component_model,
regions=ALL_REGIONS):
... | Add migration operation for easy add/remove component types in regions | Add migration operation for easy add/remove component types in regions
| Python | bsd-3-clause | team23/django_mc | ---
+++
@@ -0,0 +1,71 @@
+from django.db import migrations
+
+
+ALL_REGIONS = object()
+
+
+class _ManageComponentTypeInRegions(migrations.RunPython):
+ """
+ Requires all migrations of ``django.contrib.contenttypes`` to be applied.
+ """
+
+ def __init__(self, component_app_label, component_model,
+ ... | |
548bcc45c4e8c98cd4f8ae8722f422f648b7f83b | winsys/extras/isapi_monitor.py | winsys/extras/isapi_monitor.py | import win32traceutil
import monitor_directory
import isapi_wsgi
def __ExtensionFactory__ ():
return isapi_wsgi.ISAPISimpleHandler (monitor_directory.App ())
def set_auth (params, options, target_dir):
#
# Make sure directory authentication is:
# - Anonymous
# - NTLM
#
target_dir.Au... | Set up ISAPI link for directory monitor | Set up ISAPI link for directory monitor
added isapi_monitor.py
| Python | mit | one2pret/winsys,one2pret/winsys | ---
+++
@@ -0,0 +1,31 @@
+import win32traceutil
+import monitor_directory
+import isapi_wsgi
+
+def __ExtensionFactory__ ():
+ return isapi_wsgi.ISAPISimpleHandler (monitor_directory.App ())
+
+def set_auth (params, options, target_dir):
+ #
+ # Make sure directory authentication is:
+ # - Anonymous
+ # ... | |
b11bd211a117b695f2a1a2aa09763f4332e37ace | tests/ratings/test_rating_signals.py | tests/ratings/test_rating_signals.py | import pytest
from django.core.exceptions import ObjectDoesNotExist
from adhocracy4.ratings import models
@pytest.mark.django_db
def test_delete_of_content_object(rating):
question = rating.content_object
question.delete()
with pytest.raises(ObjectDoesNotExist):
models.Rating.objects.get(id=rat... | Add test for rating signals | Add test for rating signals
| Python | agpl-3.0 | liqd/adhocracy4,liqd/adhocracy4,liqd/adhocracy4,liqd/adhocracy4 | ---
+++
@@ -0,0 +1,14 @@
+import pytest
+
+from django.core.exceptions import ObjectDoesNotExist
+
+from adhocracy4.ratings import models
+
+
+@pytest.mark.django_db
+def test_delete_of_content_object(rating):
+ question = rating.content_object
+ question.delete()
+
+ with pytest.raises(ObjectDoesNotExist):
... | |
5be2a1721f345afae9c92dfd2d999fdc6393a38a | tests/test_mailparsers_accepted_upload.py | tests/test_mailparsers_accepted_upload.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
import os, sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from DebianChangesBot.mailparsers import AcceptedUploadParser as p
class TestMailParserAcceptedUpload(unittest.TestCase):
def setUp(self):
self.body ... | Add some tests for the AcceptedUpload parser | Add some tests for the AcceptedUpload parser
Signed-off-by: Chris Lamb <711c73f64afdce07b7e38039a96d2224209e9a6c@chris-lamb.co.uk>
| Python | agpl-3.0 | lamby/debian-devel-changes-bot,xtaran/debian-devel-changes-bot,xtaran/debian-devel-changes-bot,sebastinas/debian-devel-changes-bot,lamby/debian-devel-changes-bot,lamby/debian-devel-changes-bot | ---
+++
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import unittest
+
+import os, sys
+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from DebianChangesBot.mailparsers import AcceptedUploadParser as p
+
+class TestMailParserAcceptedUpload(unittest.TestCase):
+
... | |
49dd2d8bdd6bceea79f7799be41844f01ba4df1e | txircd/modules/extra/stats_onlineopers.py | txircd/modules/extra/stats_onlineopers.py | from twisted.plugin import IPlugin
from txircd.module_interface import IModuleData, ModuleData
from txircd.utils import now
from zope.interface import implements
class StatsOnlineOpers(ModuleData):
implements(IPlugin, IModuleData)
name = "StatsOnlineOpers"
def actions(self):
return [ ("statsruntype-onlineopers"... | Add STATS type to display online opers | Add STATS type to display online opers
| Python | bsd-3-clause | Heufneutje/txircd | ---
+++
@@ -0,0 +1,21 @@
+from twisted.plugin import IPlugin
+from txircd.module_interface import IModuleData, ModuleData
+from txircd.utils import now
+from zope.interface import implements
+
+class StatsOnlineOpers(ModuleData):
+ implements(IPlugin, IModuleData)
+
+ name = "StatsOnlineOpers"
+
+ def actions(self):
... | |
372e2d788e13bd1825edc2bdb31dfd4dda5353cb | kolibri/content/utils/channels.py | kolibri/content/utils/channels.py | import fnmatch
import logging as logger
import os
import uuid
logging = logger.getLogger(__name__)
def _is_valid_hex_uuid(uuid_to_test):
try:
uuid_obj = uuid.UUID(uuid_to_test)
except ValueError:
return False
return uuid_to_test == uuid_obj.hex
def get_channel_id_list_from_scanning_conten... | import fnmatch
import logging as logger
import os
import uuid
logging = logger.getLogger(__name__)
def _is_valid_hex_uuid(uuid_to_test):
try:
uuid_obj = uuid.UUID(uuid_to_test)
except ValueError:
return False
return uuid_to_test == uuid_obj.hex
def get_channel_id_list_from_scanning_conten... | Extend get_channel_id_* to return the full path to the exported DBs. | Extend get_channel_id_* to return the full path to the exported DBs.
| Python | mit | learningequality/kolibri,jtamiace/kolibri,indirectlylit/kolibri,MingDai/kolibri,jtamiace/kolibri,ralphiee22/kolibri,learningequality/kolibri,mrpau/kolibri,mrpau/kolibri,lyw07/kolibri,aronasorman/kolibri,learningequality/kolibri,christianmemije/kolibri,jtamiace/kolibri,jonboiser/kolibri,jayoshih/kolibri,jtamiace/kolibri... | ---
+++
@@ -12,7 +12,7 @@
return False
return uuid_to_test == uuid_obj.hex
-def get_channel_id_list_from_scanning_content_database_dir(content_database_dir):
+def get_channel_id_list_from_scanning_content_database_dir(content_database_dir, return_full_dir=False):
"""
Returns a list of channe... |
dac42830664dd1dd4b636c942b730a18f81663b2 | myhdl/test/bugs/test_issue_180.py | myhdl/test/bugs/test_issue_180.py | from __future__ import absolute_import
from myhdl import *
times_called = 0
@block
def Demonstration():
a = Signal(False)
@instance
def poke_loop():
yield delay(1)
a.next = not a
@always(a)
def comb_loop():
global times_called
times_called += 1
a.next = n... | Add a test case for combinatorial loops | Add a test case for combinatorial loops
| Python | lgpl-2.1 | juhasch/myhdl,juhasch/myhdl,juhasch/myhdl | ---
+++
@@ -0,0 +1,29 @@
+from __future__ import absolute_import
+
+from myhdl import *
+
+times_called = 0
+
+@block
+def Demonstration():
+ a = Signal(False)
+
+ @instance
+ def poke_loop():
+ yield delay(1)
+ a.next = not a
+
+ @always(a)
+ def comb_loop():
+ global times_called... | |
eeaba2ee8a0e0717a11624781445ad7c3a8d854d | examples/unpFromLattice.py | examples/unpFromLattice.py | import uci.BorisUpdater as BorisUpdater
import uci.Ptcls as Ptcls
import numpy as np
# Some helpful constants.
fund_charge = 1.602176565e-19
# Mass of Sr88 ions.
atomic_unit = 1.66053892e-27
ion_mass = 87.9056 * atomic_unit
# initialize particles
n_wells = 100
n_ions = n_wells**3
ptcls = Ptcls.Ptcls()
ptcls.set_n... | Create initial state for UNP from lattice simulation. | Create initial state for UNP from lattice simulation.
| Python | mit | hosseinsadeghi/ultracold-ions,Tech-XCorp/ultracold-ions,Tech-XCorp/ultracold-ions,hosseinsadeghi/ultracold-ions | ---
+++
@@ -0,0 +1,42 @@
+import uci.BorisUpdater as BorisUpdater
+import uci.Ptcls as Ptcls
+import numpy as np
+
+
+# Some helpful constants.
+fund_charge = 1.602176565e-19
+
+
+# Mass of Sr88 ions.
+atomic_unit = 1.66053892e-27
+ion_mass = 87.9056 * atomic_unit
+
+
+# initialize particles
+n_wells = 100
+n_ions = ... | |
ff49b55303ef4df360add9659067ac60c700d611 | ass3/hw3.py | ass3/hw3.py | import numpy as np
from scipy.special import comb
def hoeffding_inequality_sample_size_needed(probability, error, num_hypothesis):
return np.log(probability/2/num_hypothesis)/-2/error**2
def question_one_two_three():
return hoeffding_inequality_sample_size_needed(0.03, 0.05, 1), hoeffding_inequality_sample_siz... | Add ass3 work until question 7, Come up with both iterative and analytical growth function for the two interval problem | Add ass3 work until question 7, Come up with both iterative and analytical growth function for the two interval problem
| Python | mit | zhiyanfoo/caltech-machine-learning | ---
+++
@@ -0,0 +1,52 @@
+import numpy as np
+from scipy.special import comb
+def hoeffding_inequality_sample_size_needed(probability, error, num_hypothesis):
+ return np.log(probability/2/num_hypothesis)/-2/error**2
+
+def question_one_two_three():
+ return hoeffding_inequality_sample_size_needed(0.03, 0.05, 1... | |
f0bb66143cf8f48026beaf4a98dcc553a7f94d7f | tt/eqtools.py | tt/eqtools.py | """
A module for extracting an manipulating information from Boolean equations.
"""
from tt.utils import without_spaces
eq_transform_sym_dict = {
"~" : ["not", "NOT", "~", "!"],
"&" : ["and", "AND", "&", "&&", "/\\"],
"|" : ["or", "O... | Add basic functionality for transforming boolean equation to tt schema | Add basic functionality for transforming boolean equation to tt schema | Python | mit | welchbj/tt,welchbj/tt,welchbj/tt | ---
+++
@@ -0,0 +1,53 @@
+"""
+A module for extracting an manipulating information from Boolean equations.
+"""
+
+from tt.utils import without_spaces
+
+eq_transform_sym_dict = {
+ "~" : ["not", "NOT", "~", "!"],
+ "&" : ["and", "AND", "&", "&&", "/\\"],
+ ... | |
cfcabcafeddd851659cacd48265686e20492a657 | scripts/get_mems.py | scripts/get_mems.py | import argparse
import os
parser = argparse.ArgumentParser(description='Collect memories from a corpus')
parser.add_argument('-c', '--corpus_dir', default='hp_corpus',
type=str, help='Path to corpus directory')
parser.add_argument('-n', '--name', default='harry potter',
type=str... | Add script to get all memories | Add script to get all memories
| Python | apache-2.0 | CDIPS-AI-2017/pensieve | ---
+++
@@ -0,0 +1,35 @@
+import argparse
+import os
+
+parser = argparse.ArgumentParser(description='Collect memories from a corpus')
+parser.add_argument('-c', '--corpus_dir', default='hp_corpus',
+ type=str, help='Path to corpus directory')
+parser.add_argument('-n', '--name', default='harry pot... | |
58bb4cb3a0974e3a433cbd903b15e95efba6acca | apps/splash/migrations/0006_auto_20151213_0309.py | apps/splash/migrations/0006_auto_20151213_0309.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django_extensions.db.fields
class Migration(migrations.Migration):
dependencies = [
('splash', '0005_auto_20150422_2236'),
]
operations = [
migrations.AlterField(
... | Add migrations to models from django18 upgrade | Add migrations to models from django18 upgrade
| Python | mit | dotKom/onlineweb4,dotKom/onlineweb4,dotKom/onlineweb4,dotKom/onlineweb4 | ---
+++
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django_extensions.db.fields
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('splash', '0005_auto_20150422_2236'),
+ ]
+
+ operations = [
+ ... | |
868b4edfbf85aaee096021580146419904476e7d | snapshot_archive.py | snapshot_archive.py | #!/usr/bin/env python
"""
Crawl the SOLr indexes to get all dataset documents for a particular project
and extract enough information to create a snapshot of the current state.
Querying SOLr directly should work better than via the esgf search api.
Currently this script assumes dataset versions are not tampered wit... | Add script for extracting SOLr data | Add script for extracting SOLr data
| Python | bsd-3-clause | stephenpascoe/esgf-analytics | ---
+++
@@ -0,0 +1,92 @@
+#!/usr/bin/env python
+"""
+Crawl the SOLr indexes to get all dataset documents for a particular project
+and extract enough information to create a snapshot of the current state.
+
+Querying SOLr directly should work better than via the esgf search api.
+
+Currently this script assumes da... | |
fbaa823a58d20e6a6755382139d66bb962b4f181 | fix_tags.py | fix_tags.py | import codecs
from lxml import etree
from bs4 import BeautifulSoup
from emotools.bs4_helpers import act, sentence, word, speaker_turn, note
import argparse
import os
import re
import sys
if __name__ == '__main__':
folia = '/home/jvdzwaan/data/embem-annotatie/vinc001pefr02_01.xml'
tag = '/home/jvdzwaan/data/em... | Add a script that fixes tag files | Add a script that fixes tag files
The kaf files used for annotation were generated using folia files
contain strange ids (starting with lg-added). Unfortunately, these
folia files were not saved. Therefore, the word ids in the kaf files
must be updated to the word ids in the new folia files. This script does
that for ... | Python | apache-2.0 | NLeSC/embodied-emotions-scripts,NLeSC/embodied-emotions-scripts | ---
+++
@@ -0,0 +1,67 @@
+import codecs
+from lxml import etree
+from bs4 import BeautifulSoup
+from emotools.bs4_helpers import act, sentence, word, speaker_turn, note
+import argparse
+import os
+import re
+import sys
+
+
+if __name__ == '__main__':
+ folia = '/home/jvdzwaan/data/embem-annotatie/vinc001pefr02_01... | |
bc927060950dafdc9b1f3d401261f79b108a2bf1 | tests/strings/string_format_d_simple.py | tests/strings/string_format_d_simple.py |
a = 1.123456
b = 10
c = -30
d = 34
e = 123.456
f = 19892122
# form 0
s = "b=%d" % b
print s
# form 1
s = "b,c,d=%d+%d+%d" % (b,c,d)
print s
# form 2
#s = "b=%(b)0d and c=%(c)d and d=%(d)d" % { 'b':b,'c':c,'d':d }
print s
# width,flags
#s = "e=%020d e=%+d e=%20d e=%-20d (e=%- 20d)" % (e,e,e,e,e)
print s
| Add a simplified test that works | Add a simplified test that works
| Python | mit | qsnake/py2js,buchuki/pyjaco,qsnake/py2js,mattpap/py2js,buchuki/pyjaco,buchuki/pyjaco,chrivers/pyjaco,chrivers/pyjaco,mattpap/py2js,chrivers/pyjaco | ---
+++
@@ -0,0 +1,23 @@
+
+a = 1.123456
+b = 10
+c = -30
+d = 34
+e = 123.456
+f = 19892122
+
+# form 0
+s = "b=%d" % b
+print s
+
+# form 1
+s = "b,c,d=%d+%d+%d" % (b,c,d)
+print s
+
+# form 2
+#s = "b=%(b)0d and c=%(c)d and d=%(d)d" % { 'b':b,'c':c,'d':d }
+print s
+
+# width,flags
+#s = "e=%020d e=%+d e=%20d e=%-... | |
f7aabc3a0abf0f45d55b31e01fd487d8fc7dc4b4 | cinder/tests/functional/__init__.py | cinder/tests/functional/__init__.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... | Fix cinder functional tests job | Fix cinder functional tests job
We have to register cinder objects to run functional tests.
Closes-Bug: #1674627
Change-Id: Ib385382878185c958ea813e324b0e88961662a3a
| Python | apache-2.0 | mahak/cinder,eharney/cinder,mahak/cinder,openstack/cinder,j-griffith/cinder,eharney/cinder,j-griffith/cinder,openstack/cinder,phenoxim/cinder,Datera/cinder,phenoxim/cinder,Datera/cinder | ---
+++
@@ -0,0 +1,18 @@
+# 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... | |
d7cdb10b11c950be7aee7e7bbddb9b164512ab8a | src/nodeconductor_openstack/openstack_tenant/migrations/0025_copy_certifications_from_existing_settings.py | src/nodeconductor_openstack/openstack_tenant/migrations/0025_copy_certifications_from_existing_settings.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib.contenttypes.models import ContentType
from django.db import migrations
def copy_certifications_from_openstack_settings_to_openstack_tenant_settings(apps, schema_editor):
ServiceSettings = apps.get_model('structure', 'ServiceSett... | Migrate certification for existing settings | Migrate certification for existing settings
- [WAL-622]
Copy certifications from existing openstack service settings to
existings openstack_tenant service settings.
| Python | mit | opennode/nodeconductor-openstack | ---
+++
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.contrib.contenttypes.models import ContentType
+from django.db import migrations
+
+
+def copy_certifications_from_openstack_settings_to_openstack_tenant_settings(apps, schema_editor):
+ ServiceSettings = apps... | |
921f4e12bd04fb1c6b625833c0d7353ff52a5953 | derrida/interventions/iiif_urls.py | derrida/interventions/iiif_urls.py | from django.conf.urls import url
from .views import ManifestList, ManifestDetail, CanvasDetail, \
CanvasAutocomplete
# override the default djiffy views to require view permissions
# in order to access to digitized content
urlpatterns = [
url(r'^$', ManifestList.as_view(), name='list'),
url(r'^(?P<id>[^/... | Update intervention language editing to use list passed in via context | Update intervention language editing to use list passed in via context
| Python | apache-2.0 | Princeton-CDH/derrida-django,Princeton-CDH/derrida-django,Princeton-CDH/derrida-django,Princeton-CDH/derrida-django | ---
+++
@@ -0,0 +1,16 @@
+from django.conf.urls import url
+
+from .views import ManifestList, ManifestDetail, CanvasDetail, \
+ CanvasAutocomplete
+
+# override the default djiffy views to require view permissions
+# in order to access to digitized content
+
+urlpatterns = [
+ url(r'^$', ManifestList.as_view()... | |
da8b3841903dd6b64a0adb0e36e791cbb35a9276 | testCompletenessOfTokensAgainstUSFM.py | testCompletenessOfTokensAgainstUSFM.py | '''
This program tests the completeness of the token list against the usfm
files from the tokens created. This will help us in testing if any words or
phrases that are not correctly represented in the token list.
Input: usfm files (under the usfm folder)
token file (in this case ROM-REV_Full.csv)
... | Test Completeness of Tokens against the USFM files | Test Completeness of Tokens against the USFM files
This program tests the completeness of the token list against the usfm
files from the tokens created. This will help us in testing if any words or
phrases that are not correctly represented in the token list.
Input: usfm files (under the usfm folder)
... | Python | mit | beniza/learningPython | ---
+++
@@ -0,0 +1,40 @@
+'''
+This program tests the completeness of the token list against the usfm
+files from the tokens created. This will help us in testing if any words or
+phrases that are not correctly represented in the token list.
+
+ Input: usfm files (under the usfm folder)
+ token file (in ... | |
7dc6ad8b5f6553d3c1b503cfc55b8fd8264e0d2e | tests/gallery/test_raster_transform.py | tests/gallery/test_raster_transform.py | """
Reproject a Raster using ST_Transform
=====================================
The `ST_Transform()` function (and a few others like `ST_SnapToGrid()`) can be used on
both `Geometry` and `Raster` types. In `GeoAlchemy2`, this function is only defined for
`Geometry` as it can not be defined for several types at the sam... | Add a test in the gallery to show how to deal with function that can return both Geometry and Raster | Add a test in the gallery to show how to deal with function that can return both Geometry and Raster
| Python | mit | geoalchemy/geoalchemy2 | ---
+++
@@ -0,0 +1,65 @@
+"""
+Reproject a Raster using ST_Transform
+=====================================
+
+The `ST_Transform()` function (and a few others like `ST_SnapToGrid()`) can be used on
+both `Geometry` and `Raster` types. In `GeoAlchemy2`, this function is only defined for
+`Geometry` as it can not be de... | |
36ae1dbecaa821715cad982fd566ce9904a71a6f | waterbutler/server/handlers/folders.py | waterbutler/server/handlers/folders.py | import asyncio
from waterbutler.server import utils
from waterbutler.server.handlers import core
class FolderHandler(core.BaseHandler):
ACTION_MAP = {
'GET': 'create_folder',
}
@utils.coroutine
def prepare(self):
yield from super().prepare()
@utils.coroutine
def get(self):
... | Add the folder creating endpoint | Add the folder creating endpoint
| Python | apache-2.0 | rafaeldelucena/waterbutler,chrisseto/waterbutler,Johnetordoff/waterbutler,kwierman/waterbutler,Ghalko/waterbutler,felliott/waterbutler,icereval/waterbutler,rdhyee/waterbutler,cosenal/waterbutler,TomBaxter/waterbutler,RCOSDP/waterbutler,CenterForOpenScience/waterbutler,hmoco/waterbutler | ---
+++
@@ -0,0 +1,21 @@
+import asyncio
+
+from waterbutler.server import utils
+from waterbutler.server.handlers import core
+
+
+class FolderHandler(core.BaseHandler):
+
+ ACTION_MAP = {
+ 'GET': 'create_folder',
+ }
+
+ @utils.coroutine
+ def prepare(self):
+ yield from super().prepare()... | |
aa206b740e5046444f6ea470f66ed9116c70a472 | opps/core/models/publisher.py | opps/core/models/publisher.py | #!/usr/bin/env python
from django.db import models
from django.utils.translation import ugettext_lazy as _
from datetime import datetime
class PublisherMnager(models.Manager):
def all_published(self):
return super(PublisherMnager, self).get_query_set().filter(
date_available__lte=datetim... | Create Publisher models basic architecture publication | Create Publisher models
basic architecture publication
| Python | mit | jeanmask/opps,opps/opps,opps/opps,jeanmask/opps,YACOWS/opps,williamroot/opps,YACOWS/opps,williamroot/opps,jeanmask/opps,YACOWS/opps,opps/opps,williamroot/opps,williamroot/opps,YACOWS/opps,jeanmask/opps,opps/opps | ---
+++
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+from django.db import models
+from django.utils.translation import ugettext_lazy as _
+
+from datetime import datetime
+
+
+
+class PublisherMnager(models.Manager):
+ def all_published(self):
+ return super(PublisherMnager, self).get_query_set().filter(
+ ... | |
72307bb21c403c76f59ecd93aab52a3b57da4e61 | qgis_raster_transparency.py | qgis_raster_transparency.py | from qgis.core import QgsRasterTransparency
print 'Start'
active_layer = l = qgis.utils.iface.mapCanvas().currentLayer()
raster_transpareny = active_layer.renderer().rasterTransparency()
ltr = QgsRasterTransparency.TransparentSingleValuePixel()
tr_list = []
ltr.min = 0
ltr.max = 0
ltr.percentTransparent = 50
tr_list.... | Set transparency of QGIS Raster Layer | Set transparency of QGIS Raster Layer
Run in QGIS Python Console.
| Python | mit | ismailsunni/scripts | ---
+++
@@ -0,0 +1,15 @@
+from qgis.core import QgsRasterTransparency
+
+print 'Start'
+active_layer = l = qgis.utils.iface.mapCanvas().currentLayer()
+raster_transpareny = active_layer.renderer().rasterTransparency()
+ltr = QgsRasterTransparency.TransparentSingleValuePixel()
+tr_list = []
+ltr.min = 0
+ltr.max = 0
... | |
c14944b08df56337c74994bddc22fd9b675e1417 | py/convert-a-number-to-hexadecimal.py | py/convert-a-number-to-hexadecimal.py | class Solution(object):
def toHex(self, num):
"""
:type num: int
:rtype: str
"""
ans = []
for i in xrange(8):
ans.append('0123456789abcdef'[num & 0xf])
num >>= 4
if num == 0:
break
return ''.join(ans[::-1])
| Add py solution for 405. Convert a Number to Hexadecimal | Add py solution for 405. Convert a Number to Hexadecimal
405. Convert a Number to Hexadecimal: https://leetcode.com/problems/convert-a-number-to-hexadecimal/
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,13 @@
+class Solution(object):
+ def toHex(self, num):
+ """
+ :type num: int
+ :rtype: str
+ """
+ ans = []
+ for i in xrange(8):
+ ans.append('0123456789abcdef'[num & 0xf])
+ num >>= 4
+ if num == 0:
+ br... | |
5234ef22796e03d983b5681fdd288f28f61e520d | scripts/create_ticket_category.py | scripts/create_ticket_category.py | #!/usr/bin/env python
"""Create a ticket category for a party.
:Copyright: 2006-2018 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""
import click
from byceps.services.ticketing import category_service
from byceps.util.system import get_config_filename_from_env_or_exit
from bootstrap.util ... | Add script to create a ticket category | Add script to create a ticket category
| Python | bsd-3-clause | homeworkprod/byceps,m-ober/byceps,homeworkprod/byceps,m-ober/byceps,m-ober/byceps,homeworkprod/byceps | ---
+++
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+"""Create a ticket category for a party.
+
+:Copyright: 2006-2018 Jochen Kupperschmidt
+:License: Modified BSD, see LICENSE for details.
+"""
+
+import click
+
+from byceps.services.ticketing import category_service
+from byceps.util.system import get_config_filename... | |
b518f05e2a51013e0540ecce240540e557099a03 | olympiad/diagram.py | olympiad/diagram.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2014 Fabian M.
#
# 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... | Add solution for problem A4 | Add solution for problem A4
| Python | apache-2.0 | fabianm/olympiad,fabianm/olympiad,fabianm/olympiad | ---
+++
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+# Copyright 2014 Fabian M.
+#
+# 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/lic... | |
cce9ae43b007e59f310fbf063df24a41508b3066 | scripts/parglare_qtree.py | scripts/parglare_qtree.py | #!/usr/bin/env python3
# Produce LaTex qtree output from the parglare parse trees.
from parglare import Grammar, GLRParser, NodeNonTerm
INPUT = '1 + 2 * 3 + 4'
grammar = r'''
E: E '+' E
| E '*' E
| '(' E ')'
| number;
terminals
number: /\d+/;
'''
g = Grammar.from_string(grammar)
parser = GLRParser(g, build_tree... | Add script for generating LaTex qtree descriptions | Add script for generating LaTex qtree descriptions
| Python | mit | igordejanovic/parglare,igordejanovic/parglare | ---
+++
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+# Produce LaTex qtree output from the parglare parse trees.
+
+from parglare import Grammar, GLRParser, NodeNonTerm
+
+INPUT = '1 + 2 * 3 + 4'
+
+grammar = r'''
+E: E '+' E
+ | E '*' E
+ | '(' E ')'
+ | number;
+
+terminals
+number: /\d+/;
+'''
+
+g = Grammar.from_str... | |
211eefa9e607e16ad04e3617c2de1156697417e2 | tests/test_apps.py | tests/test_apps.py | from unittest import TestCase
from clean_fields.apps import CleanFieldsConfig
class CleanFieldsConfigTestCase(TestCase):
def test_name_class_attr(self):
self.assertEqual(CleanFieldsConfig.name, 'clean_fields')
| Add unit tests for AppConfig | Add unit tests for AppConfig
Oh, that sweet, sweet 100% coverage. Aw yiss.
| Python | mit | lamarmeigs/django-clean-fields | ---
+++
@@ -0,0 +1,8 @@
+from unittest import TestCase
+
+from clean_fields.apps import CleanFieldsConfig
+
+
+class CleanFieldsConfigTestCase(TestCase):
+ def test_name_class_attr(self):
+ self.assertEqual(CleanFieldsConfig.name, 'clean_fields') | |
99f6f8ff2a1fd95ff2ea4b0205edace9b0b08df3 | paw/tests/test_choose_algo.py | paw/tests/test_choose_algo.py | import wlgen
import paw
from .base import paw_test
class choose_algo_test(paw_test):
def test_choose_gen_wordlist(self):
self.paw = paw.Paw(algo=0)
self.assertTrue(
self.paw.gen_wordlist.__code__.co_code
== wlgen.gen_wordlist_iter.__code__.co_code
)
... | Add tests for algorithm choices | Add tests for algorithm choices
The addition of these tests increases coverage to 100%.
| Python | mit | tehw0lf/paw | ---
+++
@@ -0,0 +1,26 @@
+import wlgen
+import paw
+from .base import paw_test
+
+
+class choose_algo_test(paw_test):
+ def test_choose_gen_wordlist(self):
+ self.paw = paw.Paw(algo=0)
+ self.assertTrue(
+ self.paw.gen_wordlist.__code__.co_code
+ == wlgen.gen_wordlist_iter.__cod... | |
786494c6da00fae1d10b6d9190b4a8418d693576 | methods/todd-ann.py | methods/todd-ann.py | # -*- coding: utf-8 -*-
"""
ANN based on Todd's design
"""
from pybrain.structure.connections.connection import Connection
from pybrain.datasets.sequential import SequentialDataSet
from scipy import dot
class WeightedPartialIdentityConnection(Connection):
"""Connection which connects the i'th element from the fir... | Add methods for Todd ANN | Add methods for Todd ANN
| Python | mit | Melamoto/ML-Melody-Co-composition | ---
+++
@@ -0,0 +1,76 @@
+# -*- coding: utf-8 -*-
+"""
+ANN based on Todd's design
+"""
+
+from pybrain.structure.connections.connection import Connection
+from pybrain.datasets.sequential import SequentialDataSet
+from scipy import dot
+
+class WeightedPartialIdentityConnection(Connection):
+ """Connection which ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.