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 |
|---|---|---|---|---|---|---|---|---|---|---|
480852bb1dd6796b7fb12e40edc924b9a4dbee60 | test/test_misc.py | test/test_misc.py | import unittest
from .helpers import run_module
class MiscTests(unittest.TestCase):
def setUp(self):
self.name = "benchmarker"
def test_no_framework(self):
with self.assertRaises(Exception):
run_module(self.name)
def test_no_problem(self):
with self.assertRaises(Exce... | Add tests to cover no framework, no problem | Add tests to cover no framework, no problem
| Python | mpl-2.0 | undertherain/benchmarker,undertherain/benchmarker,undertherain/benchmarker,undertherain/benchmarker | ---
+++
@@ -0,0 +1,16 @@
+import unittest
+
+from .helpers import run_module
+
+
+class MiscTests(unittest.TestCase):
+ def setUp(self):
+ self.name = "benchmarker"
+
+ def test_no_framework(self):
+ with self.assertRaises(Exception):
+ run_module(self.name)
+
+ def test_no_problem(s... | |
3b66fbc844b023003420db7a9986811110f55489 | tests/test_run.py | tests/test_run.py | import sys
import tempfile
import unittest
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
import icon_font_to_png
class TestRun(unittest.TestCase):
def create_css_file(self, contents):
css_file = tempfile.NamedTemporaryFile()
css_file.write(contents.encode(... | Add tests for the run() function | Add tests for the run() function
| Python | mit | Pythonity/icon-font-to-png | ---
+++
@@ -0,0 +1,67 @@
+import sys
+import tempfile
+import unittest
+
+try:
+ from StringIO import StringIO
+except ImportError:
+ from io import StringIO
+
+import icon_font_to_png
+
+class TestRun(unittest.TestCase):
+ def create_css_file(self, contents):
+ css_file = tempfile.NamedTemporaryFile(... | |
578de6c57f9698c7e273af06d1e815f71269bb18 | tests/to_debug.py | tests/to_debug.py | import sys
import os
import time
import threading
import ikpdb
TEST_MULTI_THREADING = False
TEST_EXCEPTION_PROPAGATION = False
TEST_POSTMORTEM = True
TEST_SYS_EXIT = 0
TEST_STEPPING = False
# Note that ikpdb.set_trace() will reset/mess breakpoints set using GUI
TEST_SET_TRACE = False
TCB = TEST_CONDITIONAL_BREAKPO... | Add a sample python file interesting to debug | Add a sample python file interesting to debug
| Python | mit | audaxis/ikpdb,audaxis/ikpdb | ---
+++
@@ -0,0 +1,108 @@
+import sys
+import os
+import time
+import threading
+import ikpdb
+
+TEST_MULTI_THREADING = False
+TEST_EXCEPTION_PROPAGATION = False
+TEST_POSTMORTEM = True
+TEST_SYS_EXIT = 0
+TEST_STEPPING = False
+
+# Note that ikpdb.set_trace() will reset/mess breakpoints set using GUI
+TEST_SET_TRACE... | |
f6f2c6fc2a51bb3243d9b99ab1093809a2d1a5bb | test_players.py | test_players.py | from AI import *
import random
def RandomPlayer(game):
return 0, random.choice(game.get_available_moves())
def ABPlayer(game):
return alpha_beta_search(game, 8, -np.inf, np.inf, True, evaluate_base)
def ABChainPlayer1(game):
return alpha_beta_search(game, 7, -np.inf, np.inf, True, evaluate_chain_len)
de... | Add script that tests AI players | Add script that tests AI players
| Python | mit | giovannipcarvalho/dots-and-boxes | ---
+++
@@ -0,0 +1,32 @@
+from AI import *
+import random
+
+def RandomPlayer(game):
+ return 0, random.choice(game.get_available_moves())
+
+def ABPlayer(game):
+ return alpha_beta_search(game, 8, -np.inf, np.inf, True, evaluate_base)
+
+def ABChainPlayer1(game):
+ return alpha_beta_search(game, 7, -np.inf,... | |
da2b773bf6e669b3ec50bbd6af73e1d80bb0b5a5 | tsstats/events.py | tsstats/events.py | from collections import namedtuple
Event = namedtuple(
'Event', ['timestamp', 'identifier', 'action', 'arg', 'arg_is_client']
)
def nick(timestamp, identifier, nick):
return Event(timestamp, identifier, 'set_nick', nick, arg_is_client=False)
def connect(timestamp, identifier):
return Event(
tim... | Add tsstats/event.py for easy event-initialization | Add tsstats/event.py for easy event-initialization
| Python | mit | Thor77/TeamspeakStats,Thor77/TeamspeakStats | ---
+++
@@ -0,0 +1,33 @@
+from collections import namedtuple
+
+Event = namedtuple(
+ 'Event', ['timestamp', 'identifier', 'action', 'arg', 'arg_is_client']
+)
+
+
+def nick(timestamp, identifier, nick):
+ return Event(timestamp, identifier, 'set_nick', nick, arg_is_client=False)
+
+
+def connect(timestamp, ide... | |
c0b05a43e10693f8aab87a7f86726d512b7494fc | bluebottle/clients/management/commands/export_tenants.py | bluebottle/clients/management/commands/export_tenants.py | import json
from rest_framework.authtoken.models import Token
from django.contrib.contenttypes.models import ContentType
from django.core.management.base import BaseCommand
from bluebottle.clients import properties
from bluebottle.clients.models import Client
from bluebottle.clients.utils import LocalTenant
class C... | Add tenant exporter for accounting | Add tenant exporter for accounting
| Python | bsd-3-clause | onepercentclub/bluebottle,onepercentclub/bluebottle,onepercentclub/bluebottle,onepercentclub/bluebottle,onepercentclub/bluebottle | ---
+++
@@ -0,0 +1,46 @@
+import json
+
+from rest_framework.authtoken.models import Token
+from django.contrib.contenttypes.models import ContentType
+from django.core.management.base import BaseCommand
+
+from bluebottle.clients import properties
+from bluebottle.clients.models import Client
+from bluebottle.client... | |
dfbf888ca0b56448a4f211900b16e3c85648b241 | editorsnotes/main/migrations/0025_auto_20160628_0913.py | editorsnotes/main/migrations/0025_auto_20160628_0913.py | # -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-06-28 09:13
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0024_topic_ld'),
]
operations = [
migrations.AlterField(
... | Add migration for changing docstring of Note.is_private to unicode | Add migration for changing docstring of Note.is_private to unicode
(instead of a bytes)
| Python | agpl-3.0 | editorsnotes/editorsnotes,editorsnotes/editorsnotes | ---
+++
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.4 on 2016-06-28 09:13
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('main', '0024_topic_ld'),
+ ]
+
+ operations = [
+... | |
25ff8c6f8bc9d70886d004f8b64f08facb8c12cf | leetcode/277-Find-the-Celebrity/FindtheCelebrity_sol.py | leetcode/277-Find-the-Celebrity/FindtheCelebrity_sol.py | # The knows API is already defined for you.
# @param a, person a
# @param b, person b
# @return a boolean, whether a knows b
# def knows(a, b):
class Solution(object):
def findCelebrity(self, n):
"""
:type n: int
:rtype: int
"""
if n < 2:
return -1
candi... | Create Find the Celebrity sol for Leetcode | Create Find the Celebrity sol for Leetcode
| Python | mit | Chasego/cod,cc13ny/algo,cc13ny/Allin,Chasego/cod,cc13ny/Allin,cc13ny/algo,Chasego/codirit,Chasego/codirit,cc13ny/algo,cc13ny/Allin,cc13ny/algo,Chasego/codirit,cc13ny/algo,Chasego/codi,Chasego/codi,Chasego/codi,cc13ny/Allin,Chasego/codirit,Chasego/codi,Chasego/cod,Chasego/codi,Chasego/codirit,Chasego/cod,cc13ny/Allin,Ch... | ---
+++
@@ -0,0 +1,25 @@
+# The knows API is already defined for you.
+# @param a, person a
+# @param b, person b
+# @return a boolean, whether a knows b
+# def knows(a, b):
+
+class Solution(object):
+ def findCelebrity(self, n):
+ """
+ :type n: int
+ :rtype: int
+ """
+ if n <... | |
1a4052deb8e0ab2deb7038220ae23d7bb9311ce9 | ovf_to_facter.py | ovf_to_facter.py | #!/usr/bin/python
#stdlib
import json
import os
import subprocess
from xml.dom.minidom import parseString
def which(cmd):
"""Python implementation of `which` command."""
for path in os.environ["PATH"].split(os.pathsep):
file = os.path.join(path, cmd)
if os.path.exists(file) and os.access(file,... | Add initial version of the script | Add initial version of the script
| Python | mit | agarstang/vmware-ofv-to-facter | ---
+++
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+
+#stdlib
+import json
+import os
+import subprocess
+from xml.dom.minidom import parseString
+
+def which(cmd):
+ """Python implementation of `which` command."""
+ for path in os.environ["PATH"].split(os.pathsep):
+ file = os.path.join(path, cmd)
+ if ... | |
1396ff4ab4e6664c265f97958951815a525f7823 | reddit_donate/pages.py | reddit_donate/pages.py | from r2.lib.pages import Reddit
from r2.lib.wrapped import Templated
class DonatePage(Reddit):
extra_stylesheets = Reddit.extra_stylesheets + ["donate.less"]
def __init__(self, title, content, **kwargs):
Reddit.__init__(
self,
title=title,
content=content,
... | from r2.lib.pages import Reddit
from r2.lib.wrapped import Templated
class DonatePage(Reddit):
extra_stylesheets = Reddit.extra_stylesheets + ["donate.less"]
def __init__(self, title, content, **kwargs):
Reddit.__init__(
self,
title=title,
content=content,
... | Remove confusing navigation tabs from header. | Remove confusing navigation tabs from header.
| Python | bsd-3-clause | reddit/reddit-plugin-donate,madbook/reddit-plugin-donate,reddit/reddit-plugin-donate,madbook/reddit-plugin-donate,madbook/reddit-plugin-donate,reddit/reddit-plugin-donate | ---
+++
@@ -14,6 +14,10 @@
**kwargs
)
+ def build_toolbars(self):
+ # get rid of tabs on the top
+ return []
+
class DonateLanding(Templated):
pass |
4db13bdab18934bebcfe5b102044f936e0eab892 | etc/component_list.py | etc/component_list.py | COMPONENTS = [
"AdaBoost",
"AutoInvert",
"AutoMlpClassifier",
"BiggestCcExtractor",
"BinarizeByHT",
"BinarizeByOtsu",
"BinarizeByRange",
"BinarizeBySauvola",
"BitDataset",
"BitNN",
"BookStore",
"CascadedMLP",
"CenterFeatureMap",
"ConnectedComponentSegmenter",
"CurvedCutSegmenter",
"CurvedCutWithCcSe... | Add a place to put random stuff and a list of components as a python module. | Add a place to put random stuff and a list of components as a python module.
| Python | apache-2.0 | vitorio/ocropodium,vitorio/ocropodium,vitorio/ocropodium,vitorio/ocropodium | ---
+++
@@ -0,0 +1,87 @@
+COMPONENTS = [
+ "AdaBoost",
+ "AutoInvert",
+ "AutoMlpClassifier",
+ "BiggestCcExtractor",
+ "BinarizeByHT",
+ "BinarizeByOtsu",
+ "BinarizeByRange",
+ "BinarizeBySauvola",
+ "BitDataset",
+ "BitNN",
+ "BookStore",
+ "CascadedMLP",
+ "CenterFeatureMap",
+ "ConnectedComponentSegmenter",
... | |
0ede4e22370a3f8217fee8ff995a9c7057d8b00b | vumi_http_retry/tests/test_redis.py | vumi_http_retry/tests/test_redis.py | import json
from twisted.trial.unittest import TestCase
from twisted.internet.defer import inlineCallbacks
from vumi_http_retry.tests.redis import create_client, zitems
class TestRedis(TestCase):
@inlineCallbacks
def setUp(self):
self.redis = yield create_client()
@inlineCallbacks
def tearD... | Add test for redis test helper | Add test for redis test helper
| Python | bsd-3-clause | praekelt/vumi-http-retry-api,praekelt/vumi-http-retry-api | ---
+++
@@ -0,0 +1,34 @@
+import json
+
+from twisted.trial.unittest import TestCase
+from twisted.internet.defer import inlineCallbacks
+
+from vumi_http_retry.tests.redis import create_client, zitems
+
+
+class TestRedis(TestCase):
+ @inlineCallbacks
+ def setUp(self):
+ self.redis = yield create_clien... | |
fa55ceb71ff254f8ed3413a35acfe20da7c03a91 | rxbtcomm.py | rxbtcomm.py | #!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (c) 2016 F Dou<programmingrobotsstudygroup@gmail.com>
# See LICENSE for details.
import bluetooth
import logging
class RxBtComm(object):
"""BT communication wrapper:
Attributes:
addy: A string representing the device address.
name: A stri... | Create BT Comm wrapper class | Create BT Comm wrapper class
| Python | apache-2.0 | javatechs/RxCmd,javatechs/RxCmd,javatechs/RxCmd | ---
+++
@@ -0,0 +1,68 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# Copyright (c) 2016 F Dou<programmingrobotsstudygroup@gmail.com>
+# See LICENSE for details.
+
+
+import bluetooth
+import logging
+
+class RxBtComm(object):
+ """BT communication wrapper:
+
+ Attributes:
+ addy: A string representing... | |
3de2e625af9047b64cc2718e6e79be0c428b6ae7 | CodeFights/extractEachKth.py | CodeFights/extractEachKth.py | #!/usr/local/bin/python
# Code Fights Extract Each Kth Problem
def extractEachKth(inputArray, k):
return [e for i, e in enumerate(inputArray) if (i + 1) % k != 0]
def main():
tests = [
[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3, [1, 2, 4, 5, 7, 8, 10]],
[[1, 1, 1, 1, 1], 1, []],
[[1, 2, 1, ... | Solve Code Fights extract each kth problem | Solve Code Fights extract each kth problem
| Python | mit | HKuz/Test_Code | ---
+++
@@ -0,0 +1,28 @@
+#!/usr/local/bin/python
+# Code Fights Extract Each Kth Problem
+
+
+def extractEachKth(inputArray, k):
+ return [e for i, e in enumerate(inputArray) if (i + 1) % k != 0]
+
+
+def main():
+ tests = [
+ [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3, [1, 2, 4, 5, 7, 8, 10]],
+ [[1, 1... | |
60b5948508a67cb213ca04b5faacb77e27d8f84c | samples/forms.py | samples/forms.py | import datetime #for checking renewal date range.
from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from .models import (Patient, AdmissionNote, FluVaccine,
CollectionType, CollectedSample,
Symptom, ObservedSymptom,
)
from fioc... | import datetime #for checking renewal date range.
from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from .models import (Patient, AdmissionNote, FluVaccine,
CollectionType, CollectedSample,
Symptom, ObservedSymptom,
)
from fioc... | Add fields expicitly declared in form | :art: Add fields expicitly declared in form
| Python | mit | gems-uff/labsys,gems-uff/labsys,gems-uff/labsys,gcrsaldanha/fiocruz,gcrsaldanha/fiocruz | ---
+++
@@ -33,5 +33,5 @@
class Meta:
model = FluVaccine
- exclude = ['admission_note', ]
+ fields = ['was_applied', 'date_applied', ]
|
877a7b7449a1d88c14633376a2dfaca8c619c26a | exercises/chapter_03/exercise_03_06/exercise_03_06.py | exercises/chapter_03/exercise_03_06/exercise_03_06.py | # 3-6 Guest List
guest_list = ["Albert Einstein", "Isac Newton", "Marie Curie", "Galileo Galilei"]
message = "Hi " + guest_list[0] + " you are invited to dinner at 7 on saturday."
print(message)
message = "Hi " + guest_list[1] + " you are invited to dinner at 7 on saturday."
print(message)
message = "Hi " + guest_l... | Add solution to exercis 3.6. | Add solution to exercis 3.6.
| Python | mit | HenrikSamuelsson/python-crash-course | ---
+++
@@ -0,0 +1,60 @@
+# 3-6 Guest List
+
+guest_list = ["Albert Einstein", "Isac Newton", "Marie Curie", "Galileo Galilei"]
+
+message = "Hi " + guest_list[0] + " you are invited to dinner at 7 on saturday."
+print(message)
+
+message = "Hi " + guest_list[1] + " you are invited to dinner at 7 on saturday."
+print... | |
a8db8c0448d98e2de0e662581542bd644e673c7c | geotrek/core/migrations/0018_remove_other_objects_from_factories.py | geotrek/core/migrations/0018_remove_other_objects_from_factories.py | # Generated by Django 2.0.13 on 2020-04-06 13:40
from django.conf import settings
from django.contrib.gis.geos import Point, LineString
from django.db import migrations
def remove_generated_objects_factories(apps, schema_editor):
ComfortModel = apps.get_model('core', 'Comfort')
PathSourceModel = apps.get_mod... | Add migration removing generated objects with factories | Add migration removing generated objects with factories
| Python | bsd-2-clause | makinacorpus/Geotrek,makinacorpus/Geotrek,GeotrekCE/Geotrek-admin,GeotrekCE/Geotrek-admin,makinacorpus/Geotrek,GeotrekCE/Geotrek-admin,makinacorpus/Geotrek,GeotrekCE/Geotrek-admin | ---
+++
@@ -0,0 +1,25 @@
+# Generated by Django 2.0.13 on 2020-04-06 13:40
+
+from django.conf import settings
+from django.contrib.gis.geos import Point, LineString
+from django.db import migrations
+
+
+def remove_generated_objects_factories(apps, schema_editor):
+ ComfortModel = apps.get_model('core', 'Comfort'... | |
49c673c5c8374867fc9bf026717fe137bdba84bc | greengraph/test/test_graph.py | greengraph/test/test_graph.py | from greengraph.map import Map
from greengraph.graph import Greengraph
from mock import patch
import geopy
from nose.tools import assert_equal
start = "London"
end = "Durham"
def test_Greengraph_init():
with patch.object(geopy.geocoders,'GoogleV3') as mock_GoogleV3:
test_Greengraph = Greengraph(start,end)... | Add test file for graph.py and add test of Greengraph class constructor | Add test file for graph.py and add test of Greengraph class constructor
| Python | mit | MikeVasmer/GreenGraphCoursework | ---
+++
@@ -0,0 +1,17 @@
+from greengraph.map import Map
+from greengraph.graph import Greengraph
+from mock import patch
+import geopy
+from nose.tools import assert_equal
+
+start = "London"
+end = "Durham"
+
+def test_Greengraph_init():
+ with patch.object(geopy.geocoders,'GoogleV3') as mock_GoogleV3:
+ ... | |
82e4c67bd7643eed06e7cd170ca1d0de41c70912 | core/data/DataAnalyzer.py | core/data/DataAnalyzer.py | """
DataAnalyzer
:Authors:
Berend Klein Haneveld
"""
class DataAnalyzer(object):
"""
DataAnalyzer
"""
def __init__(self):
super(DataAnalyzer, self).__init__()
@classmethod
def histogramForData(cls, data, nrBins):
"""
Samples the image data in order to create bins
for making a histogram of the data.
... | Add a data analyzer class. | Add a data analyzer class.
Might come in handy to get statistical data of image datasets.
| Python | mit | berendkleinhaneveld/Registrationshop,berendkleinhaneveld/Registrationshop | ---
+++
@@ -0,0 +1,35 @@
+"""
+DataAnalyzer
+
+:Authors:
+ Berend Klein Haneveld
+"""
+
+
+class DataAnalyzer(object):
+ """
+ DataAnalyzer
+ """
+
+ def __init__(self):
+ super(DataAnalyzer, self).__init__()
+
+ @classmethod
+ def histogramForData(cls, data, nrBins):
+ """
+ Samples the image data in order to cre... | |
3f85610873d88592970c64661e526b2a576e300f | sms_generator.py | sms_generator.py | def generate_new_procedure_message(procedure, ward, timeframe, doctor):
unique_reference = str(1)
message = str.format("{0} is available on {1}. Attend the ward in {2} and meet {3} in the junior doctors' office. "
"To accept this opportunity reply with {4}",
pro... | Add new sms message generator | Add new sms message generator
| Python | mit | bsharif/SLOT,nhshd-slot/SLOT,bsharif/SLOT,nhshd-slot/SLOT,nhshd-slot/SLOT,bsharif/SLOT | ---
+++
@@ -0,0 +1,29 @@
+def generate_new_procedure_message(procedure, ward, timeframe, doctor):
+ unique_reference = str(1)
+ message = str.format("{0} is available on {1}. Attend the ward in {2} and meet {3} in the junior doctors' office. "
+ "To accept this opportunity reply with {4}... | |
8e8e11990e430302eca24d32ba0b88dcc66233d6 | clburlison_scripts/connect2_wifi_pyobjc/connect2_wifi_pyobjc.py | clburlison_scripts/connect2_wifi_pyobjc/connect2_wifi_pyobjc.py | #!/usr/bin/python
"""
I didn't create this but I'm storing it so I can reuse it.
http://stackoverflow.com/a/34967364/4811765
"""
import objc
SSID = "MyWifiNetwork"
PASSWORD = "MyWifiPassword"
objc.loadBundle('CoreWLAN',
bundle_path='/System/Library/Frameworks/CoreWLAN.framework',
modul... | Add connect2 wifi via pyobjc | Add connect2 wifi via pyobjc
| Python | mit | clburlison/scripts,clburlison/scripts,clburlison/scripts | ---
+++
@@ -0,0 +1,17 @@
+#!/usr/bin/python
+"""
+I didn't create this but I'm storing it so I can reuse it.
+http://stackoverflow.com/a/34967364/4811765
+"""
+import objc
+
+SSID = "MyWifiNetwork"
+PASSWORD = "MyWifiPassword"
+
+objc.loadBundle('CoreWLAN',
+ bundle_path='/System/Library/Frameworks/Cor... | |
a6d6b833e33dc465b0fa828018e2cbba748f8282 | pygraphc/evaluation/EvaluationUtility.py | pygraphc/evaluation/EvaluationUtility.py |
class EvaluationUtility(object):
@staticmethod
def convert_to_text(graph, clusters):
# convert clustering result from graph to text
new_clusters = {}
for cluster_id, nodes in clusters.iteritems():
for node in nodes:
members = graph.node[node]['member']
... | Add utility class for evaluation | Add utility class for evaluation
| Python | mit | studiawan/pygraphc | ---
+++
@@ -0,0 +1,13 @@
+
+class EvaluationUtility(object):
+ @staticmethod
+ def convert_to_text(graph, clusters):
+ # convert clustering result from graph to text
+ new_clusters = {}
+ for cluster_id, nodes in clusters.iteritems():
+ for node in nodes:
+ members... | |
6a6abadc2395810076b89fb38c759f85426a0304 | supportVectorMachine/howItWorksSupportVectorMachine.py | supportVectorMachine/howItWorksSupportVectorMachine.py | # -*- coding: utf-8 -*-
"""Support Vector Machine (SVM) classification for machine learning.
SVM is a binary classifier. The objective of the SVM is to find the best
separating hyperplane in vector space which is also referred to as the
decision boundary. And it decides what separating hyperplane is the 'best'
because... | Add framework for own SVM from scratch | Add framework for own SVM from scratch
| Python | mit | a-holm/MachinelearningAlgorithms,a-holm/MachinelearningAlgorithms | ---
+++
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+"""Support Vector Machine (SVM) classification for machine learning.
+
+SVM is a binary classifier. The objective of the SVM is to find the best
+separating hyperplane in vector space which is also referred to as the
+decision boundary. And it decides what separating... | |
92ec849fc18d7cb610839abe2213ce30ceced46b | InvenTree/InvenTree/ci_postgresql.py | InvenTree/InvenTree/ci_postgresql.py | """
Configuration file for running tests against a MySQL database.
"""
from InvenTree.settings import *
# Override the 'test' database
if 'test' in sys.argv:
eprint('InvenTree: Running tests - Using MySQL test database')
DATABASES['default'] = {
# Ensure postgresql backend is being used
'... | Add ci settings file for postgresql database | Add ci settings file for postgresql database
| Python | mit | inventree/InvenTree,SchrodingersGat/InvenTree,inventree/InvenTree,inventree/InvenTree,inventree/InvenTree,SchrodingersGat/InvenTree,SchrodingersGat/InvenTree,SchrodingersGat/InvenTree | ---
+++
@@ -0,0 +1,17 @@
+"""
+Configuration file for running tests against a MySQL database.
+"""
+
+from InvenTree.settings import *
+
+# Override the 'test' database
+if 'test' in sys.argv:
+ eprint('InvenTree: Running tests - Using MySQL test database')
+
+ DATABASES['default'] = {
+ # Ensure pos... | |
c84ce4b2494771c48890c122420e4665828ac4f8 | CodeFights/differentRightmostBit.py | CodeFights/differentRightmostBit.py | #!/usr/local/bin/python
# Code Different Right-most Bit (Core) Problem
def differentRightmostBit(n, m):
return (n ^ m) & -(n ^ m)
def main():
tests = [
[11, 13, 2],
[7, 23, 16],
[1, 0, 1],
[64, 65, 1],
[1073741823, 1071513599, 131072],
[42, 22, 4]
]
f... | Solve Code Fights different rightmost bit problem | Solve Code Fights different rightmost bit problem
| Python | mit | HKuz/Test_Code | ---
+++
@@ -0,0 +1,30 @@
+#!/usr/local/bin/python
+# Code Different Right-most Bit (Core) Problem
+
+
+def differentRightmostBit(n, m):
+ return (n ^ m) & -(n ^ m)
+
+
+def main():
+ tests = [
+ [11, 13, 2],
+ [7, 23, 16],
+ [1, 0, 1],
+ [64, 65, 1],
+ [1073741823, 1071513599,... | |
3345dc2f1ac15f06d3e95b5ead894ee9d3a27d9e | piwrite.py | piwrite.py | #!/bin/env python
import argparse
import sys
import os
parser = argparse.ArgumentParser(description="Write multiple svgs from stdin to files")
parser.add_argument('-o', '--outfile', metavar='OUTFILE', default='output.svg')
args = parser.parse_args()
base, extension = os.path.splitext(args.outfile)
def write_files... | Add file writer utility script | Add file writer utility script
| Python | epl-1.0 | rbuchmann/pivicl | ---
+++
@@ -0,0 +1,21 @@
+#!/bin/env python
+
+import argparse
+import sys
+import os
+
+parser = argparse.ArgumentParser(description="Write multiple svgs from stdin to files")
+parser.add_argument('-o', '--outfile', metavar='OUTFILE', default='output.svg')
+
+args = parser.parse_args()
+
+base, extension = os.path.s... | |
a3df0567c295f0b2879c9a4f095a31108359d531 | nodeconductor/billing/migrations/0003_invoice_status.py | nodeconductor/billing/migrations/0003_invoice_status.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('billing', '0002_pricelist'),
]
operations = [
migrations.AddField(
model_name='invoice',
name='statu... | Add missing migration for invoice status | Add missing migration for invoice status
- ITACLOUD-4886
| Python | mit | opennode/nodeconductor,opennode/nodeconductor,opennode/nodeconductor | ---
+++
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('billing', '0002_pricelist'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ mod... | |
7b40a4902d1dc43c73a7858fc9286a641b3a9666 | assess_isoform_quantification/options.py | assess_isoform_quantification/options.py | from schema import Schema
def validate_file_option(file_option, msg):
msg = "{msg} '{file}'.".format(msg=msg, file=file_option)
return Schema(open, error=msg).validate(file_option)
| Add validation function removed from main script. | Add validation function removed from main script.
| Python | mit | COMBINE-lab/piquant,lweasel/piquant,lweasel/piquant | ---
+++
@@ -0,0 +1,6 @@
+from schema import Schema
+
+
+def validate_file_option(file_option, msg):
+ msg = "{msg} '{file}'.".format(msg=msg, file=file_option)
+ return Schema(open, error=msg).validate(file_option) | |
e304aae71617cdba0ffcb720a24406375fb866a1 | Sketches/MH/audio/ToWAV.py | Sketches/MH/audio/ToWAV.py | from Axon.Component import component
import string
import struct
from Axon.Ipc import producerFinished, shutdown
class PCMToWave(component):
def __init__(self, bytespersample, samplingfrequency):
super(PCMToWave, self).__init__()
self.bytespersample = bytespersample
self.samplingfrequency =... | Copy of Ryan's PCMToWave component. | Copy of Ryan's PCMToWave component.
Matt
| Python | apache-2.0 | sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia | ---
+++
@@ -0,0 +1,72 @@
+from Axon.Component import component
+import string
+import struct
+from Axon.Ipc import producerFinished, shutdown
+
+class PCMToWave(component):
+ def __init__(self, bytespersample, samplingfrequency):
+ super(PCMToWave, self).__init__()
+ self.bytespersample = bytespersam... | |
16275938769c16c79b89349612e8e7b2891de815 | kolibri/auth/migrations/0008_auto_20180222_1244.py | kolibri/auth/migrations/0008_auto_20180222_1244.py | # -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-02-22 20:44
from __future__ import unicode_literals
import kolibri.auth.models
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('kolibriauth', '0007_auto_20171226_1125'),
]
operations = [
... | Add migration for user manager | Add migration for user manager
| Python | mit | benjaoming/kolibri,jonboiser/kolibri,christianmemije/kolibri,lyw07/kolibri,mrpau/kolibri,mrpau/kolibri,DXCanas/kolibri,mrpau/kolibri,benjaoming/kolibri,lyw07/kolibri,mrpau/kolibri,christianmemije/kolibri,learningequality/kolibri,jonboiser/kolibri,learningequality/kolibri,lyw07/kolibri,indirectlylit/kolibri,DXCanas/koli... | ---
+++
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.13 on 2018-02-22 20:44
+from __future__ import unicode_literals
+
+import kolibri.auth.models
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('kolibriauth', '0007_auto_20171226_... | |
883aac8a282d4525e82d3eb151ea293c5577424c | core/migrations/0002_auto_20141008_0853.py | core/migrations/0002_auto_20141008_0853.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
def create_extra_users(apps, schema_editor):
user = apps.get_model("auth.User").objects.create(username='GesInv-ULL')
apps.get_model("core", "UserProfile").objects.create(user=user,
... | Add data migration to create gesinv | Add data migration to create gesinv
| Python | agpl-3.0 | tic-ull/portal-del-investigador,tic-ull/portal-del-investigador,tic-ull/portal-del-investigador,tic-ull/portal-del-investigador | ---
+++
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+def create_extra_users(apps, schema_editor):
+ user = apps.get_model("auth.User").objects.create(username='GesInv-ULL')
+ apps.get_model("core", "UserProfile").objects.crea... | |
e6181c5d7c95af23ee6d51d125642104782f5cf1 | Python/136_SingleNumber.py | Python/136_SingleNumber.py | class Solution(object):
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
#Using XOR to find the single number.
#Because every number appears twice, while N^N=0, 0^N=N,
#XOR is cummutative, so the order of elements does not matter.
... | Add solution for 136_Single Number with XOR operation. | Add solution for 136_Single Number with XOR operation.
| Python | mit | comicxmz001/LeetCode,comicxmz001/LeetCode | ---
+++
@@ -0,0 +1,19 @@
+class Solution(object):
+ def singleNumber(self, nums):
+ """
+ :type nums: List[int]
+ :rtype: int
+ """
+
+ #Using XOR to find the single number.
+ #Because every number appears twice, while N^N=0, 0^N=N,
+ #XOR is cummutative, so the ord... | |
95edeaa711e8c33e1b431f792e0f2638126ed461 | pymtl/tools/translation/dynamic_ast_test.py | pymtl/tools/translation/dynamic_ast_test.py | #=======================================================================
# verilog_from_ast_test.py
#=======================================================================
# This is the test case that verifies the dynamic AST support of PyMTL.
# This test is contributed by Zhuanhao Wu through #169, #170 of PyMTL v2.
#... | Add test case for dynamic ast | [dynamic-ast] Add test case for dynamic ast
| Python | bsd-3-clause | cornell-brg/pymtl,cornell-brg/pymtl,cornell-brg/pymtl | ---
+++
@@ -0,0 +1,73 @@
+#=======================================================================
+# verilog_from_ast_test.py
+#=======================================================================
+# This is the test case that verifies the dynamic AST support of PyMTL.
+# This test is contributed by Zhuanhao Wu t... | |
1b6fecb5819fbead0aadcc1a8669e915542c5ea0 | other/testing-game.py | other/testing-game.py | #!/usr/bin/python
# -*- coding: utf-8 -*-
import argparse
import os
import subprocess
import re
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--directory', help='The directory to search for files in', required=False, default=os.getcwd())
args = parser.parse_args()
names = {}
for root, dirs, files in... | Add script for gameifying testing | Tools: Add script for gameifying testing
| Python | apache-2.0 | spotify/testing-game,spotify/testing-game,spotify/testing-game,spotify/testing-game | ---
+++
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import argparse
+import os
+import subprocess
+import re
+
+parser = argparse.ArgumentParser()
+parser.add_argument('-d', '--directory', help='The directory to search for files in', required=False, default=os.getcwd())
+args = parser.parse_args()... | |
940299a7bfd967653899b176ce76e6f1cf02ca83 | liwcpairs2es.py | liwcpairs2es.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from elasticsearch import Elasticsearch, helpers
from collections import Counter
from datetime import datetime
def find_pairs(list1, list2):
pairs = []
if list1 and list2:
for item1 in list1:
for item2 in list2:
pairs.append(u'{... | Add script to generate pairs of LIWC categories | Add script to generate pairs of LIWC categories
Added a script that generates pairs of LIWC categories for Body and
Posemo words. The pairs are added to the index. And data about the pairs
is written to std out.
The LIWC categories for which pairs are generated are hardcoded. This
should be changed. Also adding the pa... | Python | apache-2.0 | NLeSC/embodied-emotions-scripts,NLeSC/embodied-emotions-scripts | ---
+++
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+from elasticsearch import Elasticsearch, helpers
+from collections import Counter
+from datetime import datetime
+
+
+def find_pairs(list1, list2):
+ pairs = []
+ if list1 and list2:
+ for item1 in list1:
+ for item2 in ... | |
95f5b7cd2325a61f537bffb783e950b30c97da5f | bayespy/demos/gamma_shape.py | bayespy/demos/gamma_shape.py |
from bayespy import nodes
from bayespy.inference import VB
def run():
a = nodes.GammaShape(name='a')
b = nodes.Gamma(1e-5, 1e-5, name='b')
tau = nodes.Gamma(a, b, plates=(1000,), name='tau')
tau.observe(nodes.Gamma(10, 20, plates=(1000,)).random())
Q = VB(tau, a, b)
Q.update(repeat=1000)... | Add a demo about learning the shape parameter of gamma dist | DEMO: Add a demo about learning the shape parameter of gamma dist
| Python | mit | bayespy/bayespy,fivejjs/bayespy,jluttine/bayespy,SalemAmeen/bayespy | ---
+++
@@ -0,0 +1,26 @@
+
+
+from bayespy import nodes
+from bayespy.inference import VB
+
+
+def run():
+
+ a = nodes.GammaShape(name='a')
+ b = nodes.Gamma(1e-5, 1e-5, name='b')
+
+ tau = nodes.Gamma(a, b, plates=(1000,), name='tau')
+ tau.observe(nodes.Gamma(10, 20, plates=(1000,)).random())
+
+ Q ... | |
d8fff759f2bff24f20cdbe98370ede9e5f3b7b13 | convergence_tests/2D_helmholtz.py | convergence_tests/2D_helmholtz.py | from __future__ import absolute_import, division
from firedrake import *
import numpy as np
def helmholtz_mixed(x, V1, V2):
# Create mesh and define function space
mesh = UnitSquareMesh(2**x, 2**x)
V1 = FunctionSpace(mesh, *V1, name="V")
V2 = FunctionSpace(mesh, *V2, name="P")
W = V1 * V2
# D... | Add 2D helmholtz convergence test | Add 2D helmholtz convergence test
| Python | mit | thomasgibson/firedrake-hybridization | ---
+++
@@ -0,0 +1,56 @@
+from __future__ import absolute_import, division
+from firedrake import *
+import numpy as np
+
+
+def helmholtz_mixed(x, V1, V2):
+ # Create mesh and define function space
+ mesh = UnitSquareMesh(2**x, 2**x)
+ V1 = FunctionSpace(mesh, *V1, name="V")
+ V2 = FunctionSpace(mesh, *V... | |
1cc15f3ae9a0b7fa5b2dae4bcdd9f0f3c061ce4d | reclama/sprints/migrations/0002_auto_20150130_1751.py | reclama/sprints/migrations/0002_auto_20150130_1751.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('sprints', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='bug',
name='event',
... | Fix relate_name on Bug model | Fix relate_name on Bug model
| Python | mpl-2.0 | mozilla/reclama,mozilla/reclama,mozilla/reclama,mozilla/reclama | ---
+++
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('sprints', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ mod... | |
dc0ecffd6c4115019cfcbcc13b17a20511888c9b | python/paddle/fluid/tests/unittests/test_fused_emb_seq_pool_op.py | python/paddle/fluid/tests/unittests/test_fused_emb_seq_pool_op.py | # Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by app... | Add ut for fused ops | Add ut for fused ops
| Python | apache-2.0 | chengduoZH/Paddle,baidu/Paddle,tensor-tang/Paddle,chengduoZH/Paddle,baidu/Paddle,baidu/Paddle,luotao1/Paddle,baidu/Paddle,luotao1/Paddle,baidu/Paddle,luotao1/Paddle,luotao1/Paddle,PaddlePaddle/Paddle,PaddlePaddle/Paddle,luotao1/Paddle,PaddlePaddle/Paddle,chengduoZH/Paddle,PaddlePaddle/Paddle,tensor-tang/Paddle,luotao1/... | ---
+++
@@ -0,0 +1,51 @@
+# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICE... | |
a852de81afdf8426cb243115a87856e2767a8d40 | tests/benchmarks/constructs/InplaceOperationStringAdd.py | tests/benchmarks/constructs/InplaceOperationStringAdd.py | # Copyright 2015, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Python test originally created or extracted from other peoples work. The
# parts from me are licensed as below. It is at least Free Softwar where
# it's copied from other people. In these cases, that will normally be
# indicated.
#
# Li... | Add construct test for known bad inplace string operations. | Tests: Add construct test for known bad inplace string operations.
| Python | apache-2.0 | kayhayen/Nuitka,tempbottle/Nuitka,tempbottle/Nuitka,tempbottle/Nuitka,tempbottle/Nuitka,kayhayen/Nuitka,kayhayen/Nuitka,wfxiang08/Nuitka,wfxiang08/Nuitka,wfxiang08/Nuitka,kayhayen/Nuitka,wfxiang08/Nuitka | ---
+++
@@ -0,0 +1,44 @@
+# Copyright 2015, Kay Hayen, mailto:kay.hayen@gmail.com
+#
+# Python test originally created or extracted from other peoples work. The
+# parts from me are licensed as below. It is at least Free Softwar where
+# it's copied from other people. In these cases, that will normall... | |
b260040bc3ca48b4e76d73c6efe60b964fa5c108 | tests/UnreachableSymbolsRemove/RemovingTerminalsTest.py | tests/UnreachableSymbolsRemove/RemovingTerminalsTest.py | #!/usr/bin/env python
"""
:Author Patrik Valkovic
:Created 17.08.2017 14:23
:Licence GNUv3
Part of grammpy-transforms
"""
from unittest import main, TestCase
from grammpy import *
from grammpy_transforms import *
class A(Nonterminal): pass
class B(Nonterminal): pass
class C(Nonterminal): pass
class D(Nonterminal):... | Add test of removing unreachable terminals | Add test of removing unreachable terminals
| Python | mit | PatrikValkovic/grammpy | ---
+++
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+"""
+:Author Patrik Valkovic
+:Created 17.08.2017 14:23
+:Licence GNUv3
+Part of grammpy-transforms
+
+"""
+
+
+from unittest import main, TestCase
+from grammpy import *
+from grammpy_transforms import *
+
+
+class A(Nonterminal): pass
+class B(Nonterminal): pass
+cla... | |
0ac0c81a3427f35447f52c1643229f5dbe607002 | osf/migrations/0099_merge_20180426_0930.py | osf/migrations/0099_merge_20180426_0930.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11.11 on 2018-04-26 14:30
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('osf', '0098_merge_20180416_1807'),
('osf', '0096_add_provider_doi_prefixes'),
]
op... | Add a merge migration and bring up to date | Add a merge migration and bring up to date
| Python | apache-2.0 | mfraezz/osf.io,erinspace/osf.io,aaxelb/osf.io,CenterForOpenScience/osf.io,HalcyonChimera/osf.io,adlius/osf.io,erinspace/osf.io,cslzchen/osf.io,mattclark/osf.io,CenterForOpenScience/osf.io,Johnetordoff/osf.io,icereval/osf.io,mfraezz/osf.io,icereval/osf.io,caseyrollins/osf.io,caseyrollins/osf.io,baylee-d/osf.io,HalcyonCh... | ---
+++
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.11 on 2018-04-26 14:30
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('osf', '0098_merge_20180416_1807'),
+ ('osf', '0096_add... | |
28696b671a5f80f781c67f35ae5abb30efd6379c | solutions/uri/1019/1019.py | solutions/uri/1019/1019.py | import sys
h = 0
m = 0
for t in sys.stdin:
t = int(t)
if t >= 60 * 60:
h = t // (60 * 60)
t %= 60 * 60
if t >= 60:
m = t // 60
t %= 60
print(f"{h}:{m}:{t}")
h = 0
m = 0
| Solve Time Conversion in python | Solve Time Conversion in python
| Python | mit | deniscostadsc/playground,deniscostadsc/playground,deniscostadsc/playground,deniscostadsc/playground,deniscostadsc/playground,deniscostadsc/playground,deniscostadsc/playground,deniscostadsc/playground,deniscostadsc/playground,deniscostadsc/playground,deniscostadsc/playground,deniscostadsc/playground,deniscostadsc/playgr... | ---
+++
@@ -0,0 +1,20 @@
+import sys
+
+h = 0
+m = 0
+
+for t in sys.stdin:
+ t = int(t)
+
+ if t >= 60 * 60:
+ h = t // (60 * 60)
+ t %= 60 * 60
+
+ if t >= 60:
+ m = t // 60
+ t %= 60
+
+ print(f"{h}:{m}:{t}")
+
+ h = 0
+ m = 0 | |
69005d995aa0e6d291216101253197c6b2d8260a | husc/main.py | husc/main.py | import argparse
parser = argparse.ArgumentParser(description="Run the HUSC functions.")
subpar = parser.add_subparsers()
stitch = subpar.add_parser('stitch',
help="Stitch four quadrants into one image.")
stitch.add_argument('quadrant_image', nargs=4,
help="The images ... | Add module for command-line interface | Add module for command-line interface
| Python | bsd-3-clause | starcalibre/microscopium,jni/microscopium,microscopium/microscopium,microscopium/microscopium,Don86/microscopium,jni/microscopium,Don86/microscopium | ---
+++
@@ -0,0 +1,31 @@
+import argparse
+
+parser = argparse.ArgumentParser(description="Run the HUSC functions.")
+subpar = parser.add_subparsers()
+
+stitch = subpar.add_parser('stitch',
+ help="Stitch four quadrants into one image.")
+stitch.add_argument('quadrant_image', nargs=4,
+ ... | |
ea0087970b0c0adfd8942123899ff0ec231afa03 | test/selenium/src/lib/page/extended_info.py | test/selenium/src/lib/page/extended_info.py | # Copyright (C) 2015 Google Inc., authors, and contributors <see AUTHORS file>
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
# Created By: jernej@reciprocitylabs.com
# Maintained By: jernej@reciprocitylabs.com
"""A module for extended info page models (visible in LHN on hover over
obje... | # Copyright (C) 2015 Google Inc., authors, and contributors <see AUTHORS file>
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
# Created By: jernej@reciprocitylabs.com
# Maintained By: jernej@reciprocitylabs.com
"""A module for extended info page models (visible in LHN on hover over
obje... | Handle stealable element with utils | Handle stealable element with utils
| Python | apache-2.0 | AleksNeStu/ggrc-core,edofic/ggrc-core,josthkko/ggrc-core,kr41/ggrc-core,prasannav7/ggrc-core,j0gurt/ggrc-core,j0gurt/ggrc-core,VinnieJohns/ggrc-core,NejcZupec/ggrc-core,plamut/ggrc-core,NejcZupec/ggrc-core,andrei-karalionak/ggrc-core,AleksNeStu/ggrc-core,selahssea/ggrc-core,NejcZupec/ggrc-core,edofic/ggrc-core,selahsse... | ---
+++
@@ -10,34 +10,32 @@
from lib import base
from lib.constants import locator
+from lib.utils import selenium_utils
class ExtendedInfo(base.Component):
"""Model representing an extended info box that allows the object to be
mapped"""
- _locator = locator.ExtendedInfo
+ locator_cls = locator.Exte... |
7922b24882894cbc83bd4247c11d8c4a66b4b218 | _setup_database.py | _setup_database.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from setup.create_teams import migrate_teams
from setup.create_divisions import create_divisions
if __name__ == '__main__':
# migrating teams from json file to database
migrate_teams(simulation=True)
# creating divisions from division configuration file
c... | Add utility script for database setup | Add utility script for database setup
| Python | mit | leaffan/pynhldb | ---
+++
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from setup.create_teams import migrate_teams
+from setup.create_divisions import create_divisions
+
+
+if __name__ == '__main__':
+ # migrating teams from json file to database
+ migrate_teams(simulation=True)
+ # creating divisions ... | |
93621f9441af4df77c8364050d7cc3dc2b1b43b2 | tests/functional/registration/test_check.py | tests/functional/registration/test_check.py | """
Test check/validation command.
"""
import os
import subprocess
this_folder = os.path.abspath(os.path.dirname(__file__))
def test_check_metamodel():
"""
Meta-model is also a model
"""
metamodel_file = os.path.join(this_folder,
'projects', 'flow_dsl', 'flow_dsl', ... | Add tests for `check` command | Add tests for `check` command
| Python | mit | igordejanovic/textX,igordejanovic/textX,igordejanovic/textX | ---
+++
@@ -0,0 +1,37 @@
+"""
+Test check/validation command.
+"""
+import os
+import subprocess
+
+this_folder = os.path.abspath(os.path.dirname(__file__))
+
+
+def test_check_metamodel():
+ """
+ Meta-model is also a model
+ """
+
+ metamodel_file = os.path.join(this_folder,
+ ... | |
474c5f977ab5b035567f0107c457622c51189ac6 | csunplugged/topics/migrations/0086_auto_20171108_0840.py | csunplugged/topics/migrations/0086_auto_20171108_0840.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-11-08 08:40
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('topics', '0085_auto_20171030_0035'),
]
operations = [
migrations.AddField(
... | Add new topics migration file | Add new topics migration file
| Python | mit | uccser/cs-unplugged,uccser/cs-unplugged,uccser/cs-unplugged,uccser/cs-unplugged | ---
+++
@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.5 on 2017-11-08 08:40
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('topics', '0085_auto_20171030_0035'),
+ ]
+
+ ope... | |
71afe426a84789b65953ccd057014d17a11de859 | mzalendo/core/management/commands/core_extend_areas_to_generation_2.py | mzalendo/core/management/commands/core_extend_areas_to_generation_2.py | # The import of data into Kenyan MapIt had the constituencies in
# generation 2, while all the other area types were in generation 1.
# This is unfortunate since it makes it appear to later import scripts
# that the district type disappeared between generation 1 and 3.
#
# This script just extends the generation_high t... | Add a command to extend the generation_high from generation 1 to 2 | Add a command to extend the generation_high from generation 1 to 2
| Python | agpl-3.0 | mysociety/pombola,geoffkilpin/pombola,ken-muturi/pombola,geoffkilpin/pombola,geoffkilpin/pombola,hzj123/56th,geoffkilpin/pombola,hzj123/56th,mysociety/pombola,hzj123/56th,ken-muturi/pombola,patricmutwiri/pombola,patricmutwiri/pombola,hzj123/56th,mysociety/pombola,hzj123/56th,mysociety/pombola,mysociety/pombola,ken-mutu... | ---
+++
@@ -0,0 +1,19 @@
+# The import of data into Kenyan MapIt had the constituencies in
+# generation 2, while all the other area types were in generation 1.
+# This is unfortunate since it makes it appear to later import scripts
+# that the district type disappeared between generation 1 and 3.
+#
+# This script j... | |
b88b97c7d56506804fc9eb93ce7074454fc492f3 | base/apps/people/migrations/0002_auto_20141223_0316.py | base/apps/people/migrations/0002_auto_20141223_0316.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('people', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Designation',
fields=[
... | Add the migration for designations. | Add the migration for designations.
| Python | apache-2.0 | hello-base/web,hello-base/web,hello-base/web,hello-base/web | ---
+++
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('people', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ nam... | |
0cabf3c4dae3599e2d1627ff41707cf36b4d2ddd | acoustics/__init__.py | acoustics/__init__.py | """
Acoustics
=========
The acoustics module...
"""
import acoustics.ambisonics
import acoustics.utils
import acoustics.octave
import acoustics.doppler
import acoustics.signal
import acoustics.directivity
import acoustics.building
import acoustics.room
import acoustics.standards
import acoustics.cepstrum
from acoust... | """
Acoustics
=========
The acoustics module...
"""
import acoustics.aio
import acoustics.ambisonics
import acoustics.atmosphere
import acoustics.bands
import acoustics.building
import acoustics.cepstrum
import acoustics.criterion
import acoustics.decibel
import acoustics.descriptors
import acoustics.directivity
impo... | Load all modules by default | Load all modules by default
| Python | bsd-3-clause | python-acoustics/python-acoustics,antiface/python-acoustics,FRidh/python-acoustics,felipeacsi/python-acoustics,giumas/python-acoustics | ---
+++
@@ -5,15 +5,27 @@
The acoustics module...
"""
+import acoustics.aio
import acoustics.ambisonics
-import acoustics.utils
+import acoustics.atmosphere
+import acoustics.bands
+import acoustics.building
+import acoustics.cepstrum
+import acoustics.criterion
+import acoustics.decibel
+import acoustics.descri... |
513af3716c596bb67c0f6552824b854b3735858c | corehq/apps/domain/tests/test_password_strength.py | corehq/apps/domain/tests/test_password_strength.py | from django import forms
from django.test import SimpleTestCase, override_settings
from corehq.apps.domain.forms import clean_password
class PasswordStrengthTest(SimpleTestCase):
@override_settings(MINIMUM_ZXCVBN_SCORE=2)
def test_score_0_password(self):
self.assert_bad_password(PASSWORDS_BY_STRENGT... | Add simple tests for password strength and sensitivity to MINIMUM_ZXCVBN_SCORE setting | Add simple tests for password strength and sensitivity to MINIMUM_ZXCVBN_SCORE setting
| Python | bsd-3-clause | dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq | ---
+++
@@ -0,0 +1,39 @@
+from django import forms
+from django.test import SimpleTestCase, override_settings
+
+from corehq.apps.domain.forms import clean_password
+
+
+class PasswordStrengthTest(SimpleTestCase):
+
+ @override_settings(MINIMUM_ZXCVBN_SCORE=2)
+ def test_score_0_password(self):
+ self.as... | |
97d6cce2a5c0c905f0c33c41316c8e65eaed0e08 | update-bikestations.py | update-bikestations.py | #!/usr/bin/env python
from multiprocessing.pool import ThreadPool
import requests
import json
baseurl = 'http://api.citybik.es/v2/networks/'
networkids = [ 'bixi-montreal', 'bixi-toronto', 'capital-bixi', 'hubway',
'capital-bikeshare', 'citi-bike-nyc', 'barclays-cycle-hire' ]
def process_network(netwo... | Update way we synchronize from citybik.es | Update way we synchronize from citybik.es
Now we only download the information we actually need. We also download
and generate network information dynamically, which should enable some
cool stuff
| Python | mit | wlach/nixi,wlach/nixi | ---
+++
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+
+from multiprocessing.pool import ThreadPool
+import requests
+import json
+
+baseurl = 'http://api.citybik.es/v2/networks/'
+networkids = [ 'bixi-montreal', 'bixi-toronto', 'capital-bixi', 'hubway',
+ 'capital-bikeshare', 'citi-bike-nyc', 'barclays-cycl... | |
665b3372e089fda3dde104b0754efa65a87a9bd2 | Sketches/MPS/Bookmarks/TestHTTPResponseHandler.py | Sketches/MPS/Bookmarks/TestHTTPResponseHandler.py | #!/usr/bin/python
import base64
from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
from Kamaelia.File.Writing import SimpleFileWriter
from Kamaelia.Chassis.Pipeline import Pipeline
from TwitterStream import HTTPClientResponseHandler
from Kamaelia.Util.PureTransformer import PureTransformer
from Kamaelia.Util.C... | Test harness for checking wtf the HTTPClientResponseHandler is actually doing with data from the network | Test harness for checking wtf the HTTPClientResponseHandler is actually doing with data from the network | Python | apache-2.0 | sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia,sparkslabs/kamaelia | ---
+++
@@ -0,0 +1,16 @@
+#!/usr/bin/python
+
+import base64
+from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
+from Kamaelia.File.Writing import SimpleFileWriter
+from Kamaelia.Chassis.Pipeline import Pipeline
+from TwitterStream import HTTPClientResponseHandler
+from Kamaelia.Util.PureTransformer import P... | |
53467bd7d4c9c12b73c66244a91f31f0dbadeeec | hc/front/tests/test_add_pagerteam.py | hc/front/tests/test_add_pagerteam.py | from hc.api.models import Channel
from hc.test import BaseTestCase
class AddPagerTeamTestCase(BaseTestCase):
url = "/integrations/add_pagerteam/"
def test_instructions_work(self):
self.client.login(username="alice@example.org", password="password")
r = self.client.get(self.url)
self.a... | Add pagerteam tests file which had been missed despite its existence | Add pagerteam tests file which had been missed despite its existence
| Python | bsd-3-clause | healthchecks/healthchecks,iphoting/healthchecks,iphoting/healthchecks,iphoting/healthchecks,healthchecks/healthchecks,healthchecks/healthchecks,iphoting/healthchecks,healthchecks/healthchecks | ---
+++
@@ -0,0 +1,30 @@
+from hc.api.models import Channel
+from hc.test import BaseTestCase
+
+
+class AddPagerTeamTestCase(BaseTestCase):
+ url = "/integrations/add_pagerteam/"
+
+ def test_instructions_work(self):
+ self.client.login(username="alice@example.org", password="password")
+ r = sel... | |
9f9916d662d1ab130c9685c415c25b19a14733d7 | examples/svm_objectives.py | examples/svm_objectives.py | # showing the relation between cutting plane and primal objectives
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_digits
from sklearn.cross_validation import train_test_split
from pystruct.problems import CrammerSingerSVMProblem
from pystruct.learners import (StructuredSVM, OneS... | Add example to illustrate different optimization procedures | Add example to illustrate different optimization procedures
| Python | bsd-2-clause | d-mittal/pystruct,massmutual/pystruct,wattlebird/pystruct,massmutual/pystruct,wattlebird/pystruct,pystruct/pystruct,amueller/pystruct,d-mittal/pystruct,pystruct/pystruct,amueller/pystruct | ---
+++
@@ -0,0 +1,48 @@
+# showing the relation between cutting plane and primal objectives
+
+import numpy as np
+import matplotlib.pyplot as plt
+
+from sklearn.datasets import load_digits
+from sklearn.cross_validation import train_test_split
+
+from pystruct.problems import CrammerSingerSVMProblem
+from pystruct... | |
3a2e9a19feab0c882a9821b7ff555bd1e2693190 | exp/sandbox/DeltaLaplacianExp.py | exp/sandbox/DeltaLaplacianExp.py | import numpy
import scipy.sparse
from apgl.graph import GraphUtils
from apgl.util.Util import Util
numpy.set_printoptions(suppress=True, precision=3)
n = 10
W1 = scipy.sparse.rand(n, n, 0.5).todense()
W1 = W1.T.dot(W1)
W2 = W1.copy()
W2[1, 2] = 1
W2[2, 1] = 1
print("W1="+str(W1))
print("W2="+str(W2))
L1 = Gr... | Test effect of change in Laplacian. | Test effect of change in Laplacian. | Python | bsd-3-clause | charanpald/APGL | ---
+++
@@ -0,0 +1,28 @@
+import numpy
+import scipy.sparse
+from apgl.graph import GraphUtils
+from apgl.util.Util import Util
+
+numpy.set_printoptions(suppress=True, precision=3)
+n = 10
+W1 = scipy.sparse.rand(n, n, 0.5).todense()
+W1 = W1.T.dot(W1)
+W2 = W1.copy()
+
+W2[1, 2] = 1
+W2[2, 1] = 1
+
+print("W... | |
9a22cf7452723686a5065658ce5c9d31333c8a33 | examples/download_random_leader_avatar.py | examples/download_random_leader_avatar.py | # Run with Python 3
import json
import requests
from random import randint
import shutil
import math
# 1. Get your keys at https://stepic.org/oauth2/applications/ (client type = confidential,
# authorization grant type = client credentials)
client_id = "..."
client_secret = "..."
# 2. Get a token
auth = requests.auth... | Add download random leader avatar to examples | Add download random leader avatar to examples
| Python | mit | StepicOrg/Stepic-API | ---
+++
@@ -0,0 +1,50 @@
+# Run with Python 3
+import json
+import requests
+from random import randint
+import shutil
+import math
+
+# 1. Get your keys at https://stepic.org/oauth2/applications/ (client type = confidential,
+# authorization grant type = client credentials)
+client_id = "..."
+client_secret = "..."
... | |
0507a47f1c15bac5f6eddbeb9c712f5c2b2a9358 | intake_bluesky/tests/test_msgpack.py | intake_bluesky/tests/test_msgpack.py | import intake_bluesky.msgpack # noqa
import intake
from suitcase.msgpack import Serializer
import os
import pytest
import shutil
import tempfile
import time
import types
from .generic import * # noqa
TMP_DIR = tempfile.mkdtemp()
TEST_CATALOG_PATH = [TMP_DIR]
YAML_FILENAME = 'intake_msgpack_test_catalog.yml'
def ... | Add tests for msgpack reader. | TST: Add tests for msgpack reader.
| Python | bsd-3-clause | ericdill/databroker,ericdill/databroker | ---
+++
@@ -0,0 +1,63 @@
+import intake_bluesky.msgpack # noqa
+import intake
+from suitcase.msgpack import Serializer
+import os
+import pytest
+import shutil
+import tempfile
+import time
+import types
+
+from .generic import * # noqa
+
+TMP_DIR = tempfile.mkdtemp()
+TEST_CATALOG_PATH = [TMP_DIR]
+
+YAML_FILENAME... | |
a42a6a54f732ca7eba700b867a3025739ad6a271 | list_all_users_in_group.py | list_all_users_in_group.py | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import grp
import pwd
import inspect
import argparse
def list_all_users_in_group(groupname):
"""Get list of all users of group.
Get sorted list of all users of group GROUP,
including users with main group GROUP.
Ori... | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import grp
import pwd
import inspect
import argparse
def list_all_users_in_group(groupname):
"""Get list of all users of group.
Get sorted list of all users of group GROUP,
including users with main group GROUP.
Ori... | Move main code to function because of pylint warning 'Invalid constant name' | Move main code to function because of pylint warning 'Invalid constant name'
| Python | cc0-1.0 | vazhnov/list_all_users_in_group | ---
+++
@@ -27,7 +27,8 @@
group_all_users_set.add(user.pw_name)
return sorted(group_all_users_set)
-if __name__ == "__main__":
+
+def main():
parser = argparse.ArgumentParser(description=inspect.getdoc(list_all_users_in_group),
formatter_class=argparse.Ra... |
d067d9937ff34787e6f632d86075af29c27d98f8 | py/best-time-to-buy-and-sell-stock-with-transaction-fee.py | py/best-time-to-buy-and-sell-stock-with-transaction-fee.py | class Solution(object):
def maxProfit(self, prices, fee):
"""
:type prices: List[int]
:type fee: int
:rtype: int
"""
hold, not_hold = None, 0
for p in prices:
hold, not_hold = max(hold, not_hold - p - fee), max(not_hold, None if hold is None else h... | Add py solution for 714. Best Time to Buy and Sell Stock with Transaction Fee | Add py solution for 714. Best Time to Buy and Sell Stock with Transaction Fee
714. Best Time to Buy and Sell Stock with Transaction Fee: https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,11 @@
+class Solution(object):
+ def maxProfit(self, prices, fee):
+ """
+ :type prices: List[int]
+ :type fee: int
+ :rtype: int
+ """
+ hold, not_hold = None, 0
+ for p in prices:
+ hold, not_hold = max(hold, not_hold - p - fee), max(... | |
4c2c80e0004a758787beb555fbbe789cce5e82fc | nova/tests/test_vmwareapi_vm_util.py | nova/tests/test_vmwareapi_vm_util.py | # vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright 2013 Canonical Corp.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.or... | Fix variable referenced before assginment in vmwareapi code. | Fix variable referenced before assginment in vmwareapi code.
Add unitests for VMwareapi vm_util.
fix bug #1177689
Change-Id: If16109ee626c197227affba122c2e4986d92d2df
| Python | apache-2.0 | n0ano/gantt,n0ano/gantt | ---
+++
@@ -0,0 +1,55 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+# Copyright 2013 Canonical Corp.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License ... | |
1dc439fcf7a823270156708208339a8bf420703c | opps/sitemaps/sitemaps.py | opps/sitemaps/sitemaps.py | # -*- coding: utf-8 -*-
from django.contrib.sitemaps import GenericSitemap as DjangoGenericSitemap
from django.contrib.sitemaps import Sitemap as DjangoSitemap
from django.utils import timezone
from opps.articles.models import Article
def InfoDisct(googlenews=False):
article = Article.objects.filter(date_availab... | Create Generic Sitemap abstract django | Create Generic Sitemap abstract django
| Python | mit | opps/opps,YACOWS/opps,jeanmask/opps,williamroot/opps,YACOWS/opps,opps/opps,williamroot/opps,opps/opps,YACOWS/opps,jeanmask/opps,williamroot/opps,jeanmask/opps,williamroot/opps,opps/opps,YACOWS/opps,jeanmask/opps | ---
+++
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+from django.contrib.sitemaps import GenericSitemap as DjangoGenericSitemap
+from django.contrib.sitemaps import Sitemap as DjangoSitemap
+from django.utils import timezone
+
+from opps.articles.models import Article
+
+
+def InfoDisct(googlenews=False):
+ article ... | |
7707e65ed591b890d91bcb7bf22923b8c17a113a | readthedocs/rtd_tests/tests/test_api_permissions.py | readthedocs/rtd_tests/tests/test_api_permissions.py | from functools import partial
from mock import Mock
from unittest import TestCase
from readthedocs.restapi.permissions import APIRestrictedPermission
class APIRestrictedPermissionTests(TestCase):
def get_request(self, method, is_admin):
request = Mock()
request.method = method
request.use... | Add tests from Gregor's PR | Add tests from Gregor's PR
| Python | mit | davidfischer/readthedocs.org,wijerasa/readthedocs.org,rtfd/readthedocs.org,davidfischer/readthedocs.org,safwanrahman/readthedocs.org,pombredanne/readthedocs.org,rtfd/readthedocs.org,SteveViss/readthedocs.org,stevepiercy/readthedocs.org,rtfd/readthedocs.org,stevepiercy/readthedocs.org,safwanrahman/readthedocs.org,clarkp... | ---
+++
@@ -0,0 +1,81 @@
+from functools import partial
+from mock import Mock
+from unittest import TestCase
+
+from readthedocs.restapi.permissions import APIRestrictedPermission
+
+
+class APIRestrictedPermissionTests(TestCase):
+ def get_request(self, method, is_admin):
+ request = Mock()
+ reque... | |
30567284410b9bb7154b8d39e5dfe7bc4bb1b269 | herald/migrations/0006_auto_20170825_1813.py | herald/migrations/0006_auto_20170825_1813.py | # -*- coding: utf-8 -*-
# Generated by Django 1.9.8 on 2017-08-25 23:13
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('herald', '0005_merge_201704... | Add migration for on_delete SET_NULL | Add migration for on_delete SET_NULL
| Python | mit | worthwhile/django-herald,jproffitt/django-herald,jproffitt/django-herald,worthwhile/django-herald | ---
+++
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.8 on 2017-08-25 23:13
+from __future__ import unicode_literals
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = ... | |
f3c4bac262c6d09730b3f0c4a24639fde8b4d923 | gunicorn-app.py | gunicorn-app.py | from __future__ import unicode_literals
import multiprocessing
import gunicorn.app.base
from gunicorn.six import iteritems
def number_of_workers():
return (multiprocessing.cpu_count() * 2) + 1
def handler_app(environ, start_response):
response_body = b'Works fine'
status = '200 OK'
response_head... | Add wsgi compatible example gunicorn application | Add wsgi compatible example gunicorn application | Python | mit | voidabhi/python-scripts,voidabhi/python-scripts,voidabhi/python-scripts,voidabhi/python-scripts,voidabhi/python-scripts | ---
+++
@@ -0,0 +1,49 @@
+from __future__ import unicode_literals
+
+import multiprocessing
+
+import gunicorn.app.base
+
+from gunicorn.six import iteritems
+
+
+def number_of_workers():
+ return (multiprocessing.cpu_count() * 2) + 1
+
+
+def handler_app(environ, start_response):
+ response_body = b'Works fine... | |
ae948c95ea0087f33f13ef3463dc022eda0301a2 | python/labs/make-a-short-story/mystory.py | python/labs/make-a-short-story/mystory.py | # Create a function for adjectives so I don't repeat myself in prompts.
def get_adjective():
return raw_input("Give me an adjective: ")
def get_noun():
return raw_input("Give me a noun: ")
def get_verb():
return raw_input("Give me a verb: ")
adjective1 = get_adjective()
noun1 = get_noun()
verb1 = get_ver... | Add a solution for the MadLibs lab | Add a solution for the MadLibs lab
| Python | apache-2.0 | google/cssi-labs,google/cssi-labs | ---
+++
@@ -0,0 +1,22 @@
+# Create a function for adjectives so I don't repeat myself in prompts.
+def get_adjective():
+ return raw_input("Give me an adjective: ")
+
+def get_noun():
+ return raw_input("Give me a noun: ")
+
+def get_verb():
+ return raw_input("Give me a verb: ")
+
+adjective1 = get_adjectiv... | |
77b34390345208a6e0bc5ad30cdce62e42ca0c56 | wafer/management/commands/pycon_speaker_tickets.py | wafer/management/commands/pycon_speaker_tickets.py | import sys
import csv
from optparse import make_option
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
from wafer.talks.models import ACCEPTED
class Command(BaseCommand):
help = "List speakers and associated tickets."
option_list = BaseCommand.option_list + t... | Add simple command to list speakers and tickets | Add simple command to list speakers and tickets
| Python | isc | CTPUG/wafer,CTPUG/wafer,CarlFK/wafer,CTPUG/wafer,CTPUG/wafer,CarlFK/wafer,CarlFK/wafer,CarlFK/wafer | ---
+++
@@ -0,0 +1,46 @@
+import sys
+import csv
+from optparse import make_option
+
+from django.core.management.base import BaseCommand
+
+from django.contrib.auth.models import User
+from wafer.talks.models import ACCEPTED
+
+
+class Command(BaseCommand):
+ help = "List speakers and associated tickets."
+
+ ... | |
3bbf06964452683d986db401556183f575d15a55 | insert-project.py | insert-project.py | #!/usr/bin/env python3
import pymongo
import subprocess
import re
from datetime import datetime
import argparse
from json import load as load_json
import sys
def _info(msg):
sys.stdout.write(msg + '\n')
sys.stdout.flush()
cl_parser = argparse.ArgumentParser(description='Insert a project into Meteor\'s local... | Add script for inserting project into DB | Add script for inserting project into DB
| Python | mit | muzhack/muzhack,muzhack/muzhack,praneybehl/muzhack,muzhack/musitechhub,praneybehl/muzhack,praneybehl/muzhack,muzhack/musitechhub,praneybehl/muzhack,muzhack/muzhack,muzhack/muzhack,muzhack/musitechhub,muzhack/musitechhub | ---
+++
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+import pymongo
+import subprocess
+import re
+from datetime import datetime
+import argparse
+from json import load as load_json
+import sys
+
+
+def _info(msg):
+ sys.stdout.write(msg + '\n')
+ sys.stdout.flush()
+
+
+cl_parser = argparse.ArgumentParser(descrip... | |
8fe73523b7141f93d8523e56a7c6a5cc2ed82051 | src/collectors/iodrivesnmp/test/testiodrivesnmp.py | src/collectors/iodrivesnmp/test/testiodrivesnmp.py | #!/usr/bin/python
# coding=utf-8
################################################################################
from test import CollectorTestCase
from test import get_collector_config
from iodrivesnmp import IODriveSNMPCollector
class TestIODriveSNMPCollector(CollectorTestCase):
def setUp(self, allowed_names... | Test case for ioddrivesnmp class | Test case for ioddrivesnmp class
| Python | mit | datafiniti/Diamond,stuartbfox/Diamond,joel-airspring/Diamond,disqus/Diamond,Netuitive/Diamond,metamx/Diamond,cannium/Diamond,hvnsweeting/Diamond,MichaelDoyle/Diamond,MediaMath/Diamond,Precis/Diamond,anandbhoraskar/Diamond,socialwareinc/Diamond,joel-airspring/Diamond,h00dy/Diamond,mfriedenhagen/Diamond,socialwareinc/Dia... | ---
+++
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# coding=utf-8
+################################################################################
+
+from test import CollectorTestCase
+from test import get_collector_config
+
+from iodrivesnmp import IODriveSNMPCollector
+
+
+class TestIODriveSNMPCollector(CollectorTestCa... | |
7ec15caf8f2c9d0a21581261a356f6decc548061 | test/ui_test.py | test/ui_test.py | from app import app
import unittest
class UiTestCase(unittest.TestCase):
def setUp(self):
self.app = app.test_client()
def test_index(self):
self.assertEqual(self.app.get('/').status_code, 200)
def test_no_page(self):
self.assertEqual(self.app.get('/missing-page').status_code, 200... | Add some basic UI tests | Add some basic UI tests
| Python | agpl-3.0 | spacewiki/spacewiki,tdfischer/spacewiki,spacewiki/spacewiki,spacewiki/spacewiki,tdfischer/spacewiki,tdfischer/spacewiki,tdfischer/spacewiki,spacewiki/spacewiki | ---
+++
@@ -0,0 +1,19 @@
+from app import app
+import unittest
+
+class UiTestCase(unittest.TestCase):
+ def setUp(self):
+ self.app = app.test_client()
+
+ def test_index(self):
+ self.assertEqual(self.app.get('/').status_code, 200)
+
+ def test_no_page(self):
+ self.assertEqual(self.ap... | |
7ddfb39256229aa8c985ed8d70a29479187c76ad | lily/management/commands/generate_beta_invites.py | lily/management/commands/generate_beta_invites.py | import csv
import gc
import logging
from datetime import date
from hashlib import sha256
from django.conf import settings
from django.core.files.storage import default_storage
from django.core.management import call_command
from django.core.management.base import BaseCommand
from django.core.urlresolvers import revers... | Create script for beta invites | LILY-2366: Create script for beta invites
| Python | agpl-3.0 | HelloLily/hellolily,HelloLily/hellolily,HelloLily/hellolily,HelloLily/hellolily | ---
+++
@@ -0,0 +1,65 @@
+import csv
+import gc
+import logging
+from datetime import date
+from hashlib import sha256
+
+from django.conf import settings
+from django.core.files.storage import default_storage
+from django.core.management import call_command
+from django.core.management.base import BaseCommand
+from ... | |
5bc089a98bf578fd0c56e3e50cf76888ee74aba2 | py/complex-number-multiplication.py | py/complex-number-multiplication.py | import re
class Solution(object):
def complexNumberMultiply(self, a, b):
"""
:type a: str
:type b: str
:rtype: str
"""
pat = re.compile(r'(-?\d+)\+(-?\d+)i')
mata = pat.match(a)
matb = pat.match(b)
a = int(mata.group(1)), int(mata.group(2))
... | Add py solution for 537. Complex Number Multiplication | Add py solution for 537. Complex Number Multiplication
537. Complex Number Multiplication: https://leetcode.com/problems/complex-number-multiplication/
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,15 @@
+import re
+class Solution(object):
+ def complexNumberMultiply(self, a, b):
+ """
+ :type a: str
+ :type b: str
+ :rtype: str
+ """
+ pat = re.compile(r'(-?\d+)\+(-?\d+)i')
+ mata = pat.match(a)
+ matb = pat.match(b)
+ a = int... | |
06e82c471afa83bf0f08f0779b32dd8a09b8d1ba | py/intersection-of-two-arrays-ii.py | py/intersection-of-two-arrays-ii.py | from collections import Counter
class Solution(object):
def intersect(self, nums1, nums2):
"""
:type nums1: List[int]
:type nums2: List[int]
:rtype: List[int]
"""
c1, c2 = Counter(nums1), Counter(nums2)
return list((c1 & c2).elements())
| Add py solution for 350. Intersection of Two Arrays II | Add py solution for 350. Intersection of Two Arrays II
350. Intersection of Two Arrays II: https://leetcode.com/problems/intersection-of-two-arrays-ii/
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,10 @@
+from collections import Counter
+class Solution(object):
+ def intersect(self, nums1, nums2):
+ """
+ :type nums1: List[int]
+ :type nums2: List[int]
+ :rtype: List[int]
+ """
+ c1, c2 = Counter(nums1), Counter(nums2)
+ return list((c1 & c2... | |
9d7c348170fc0f9d339a2ef57a9e64b1ceaa7516 | web/whim/core/scrapers/mnh.py | web/whim/core/scrapers/mnh.py | from datetime import datetime, timezone, time
import requests
from bs4 import BeautifulSoup
from django.db import transaction
from .base import BaseScraper
from .exceptions import ScraperException
from whim.core.models import Event, Source, Category
from whim.core.utils import get_object_or_none
from whim.core.time... | Add demo MNH event scraper | Add demo MNH event scraper
| Python | mit | andrewgleave/whim,andrewgleave/whim,andrewgleave/whim | ---
+++
@@ -0,0 +1,73 @@
+from datetime import datetime, timezone, time
+
+import requests
+from bs4 import BeautifulSoup
+
+from django.db import transaction
+
+from .base import BaseScraper
+from .exceptions import ScraperException
+
+from whim.core.models import Event, Source, Category
+from whim.core.utils import... | |
84990a4ef20c2e0f42133ed06ade5ce2d4e98ae3 | chmvh_website/team/models.py | chmvh_website/team/models.py | from django.db import models
def team_member_image_name(instance, filename):
return 'team/{0}'.format(instance.name)
class TeamMember(models.Model):
bio = models.TextField(
verbose_name='biography')
name = models.CharField(
max_length=50,
unique=True,
verbose_name='name')... | import os
from django.db import models
def team_member_image_name(instance, filename):
_, ext = os.path.splitext(filename)
return 'team/{0}{1}'.format(instance.name, ext)
class TeamMember(models.Model):
bio = models.TextField(
verbose_name='biography')
name = models.CharField(
max_... | Save team member picture with extension. | Save team member picture with extension.
| Python | mit | cdriehuys/chmvh-website,cdriehuys/chmvh-website,cdriehuys/chmvh-website | ---
+++
@@ -1,8 +1,12 @@
+import os
+
from django.db import models
def team_member_image_name(instance, filename):
- return 'team/{0}'.format(instance.name)
+ _, ext = os.path.splitext(filename)
+
+ return 'team/{0}{1}'.format(instance.name, ext)
class TeamMember(models.Model): |
257134bdaea7c250d5956c4095adf0b917b65aa6 | database/dict_converters/event_details_converter.py | database/dict_converters/event_details_converter.py | from database.dict_converters.converter_base import ConverterBase
class EventDetailsConverter(ConverterBase):
SUBVERSIONS = { # Increment every time a change to the dict is made
3: 0,
}
@classmethod
def convert(cls, event_details, dict_version):
CONVERTERS = {
3: cls.even... | from database.dict_converters.converter_base import ConverterBase
class EventDetailsConverter(ConverterBase):
SUBVERSIONS = { # Increment every time a change to the dict is made
3: 0,
}
@classmethod
def convert(cls, event_details, dict_version):
CONVERTERS = {
3: cls.even... | Fix null case for event details | Fix null case for event details
| Python | mit | verycumbersome/the-blue-alliance,the-blue-alliance/the-blue-alliance,nwalters512/the-blue-alliance,nwalters512/the-blue-alliance,the-blue-alliance/the-blue-alliance,tsteward/the-blue-alliance,nwalters512/the-blue-alliance,phil-lopreiato/the-blue-alliance,nwalters512/the-blue-alliance,tsteward/the-blue-alliance,jaredhas... | ---
+++
@@ -16,10 +16,10 @@
@classmethod
def eventDetailsConverter_v3(cls, event_details):
event_details_dict = {
- 'alliances': event_details.alliance_selections,
- 'district_points': event_details.district_points,
- 'rankings': event_details.renderable_rankings,
-... |
03279bbc6193d3944dcd2542daa65701a1e0eded | euler026.py | euler026.py | #!/usr/bin/python
"""
For resolve this, we have to find the maximum
Full Reptend Prime int he given limit. To do that, we need
to check if the 10 is a primitive root of p.
See http://mathworld.wolfram.com/FullReptendPrime.html for details
"""
from sys import exit
for p in range(999, 7, -2):
for k in range(1, p)... | Add solution for problem 26 | Add solution for problem 26
| Python | mit | cifvts/PyEuler | ---
+++
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+"""
+For resolve this, we have to find the maximum
+Full Reptend Prime int he given limit. To do that, we need
+to check if the 10 is a primitive root of p.
+
+See http://mathworld.wolfram.com/FullReptendPrime.html for details
+"""
+
+from sys import exit
+
+for p in ran... | |
930a8b1a7c980183df5469627a734033ca39a444 | shade/tests/functional/test_image.py | shade/tests/functional/test_image.py | # -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, softw... | Add functional tests for create_image | Add functional tests for create_image
Change-Id: Iadb70ca764fbc2c8102a988d6e03cf623b6df48d
| Python | apache-2.0 | openstack-infra/shade,jsmartin/shade,dtroyer/python-openstacksdk,openstack/python-openstacksdk,stackforge/python-openstacksdk,openstack-infra/shade,dtroyer/python-openstacksdk,stackforge/python-openstacksdk,jsmartin/shade,openstack/python-openstacksdk | ---
+++
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicabl... | |
9c045f7667e1bdc6c9137c3877292907f4623774 | make_a_plea/management/commands/check_urns_in_db.py | make_a_plea/management/commands/check_urns_in_db.py | import csv
from django.core.management.base import BaseCommand
from apps.plea.models import DataValidation, Case
from apps.plea.standardisers import standardise_urn, format_for_region
class Command(BaseCommand):
help = "Build weekly aggregate stats"
def add_arguments(self, parser):
parser.add_argum... | Add a management command to check if URNs are present in the database | Add a management command to check if URNs are present in the database
| Python | mit | ministryofjustice/manchester_traffic_offences_pleas,ministryofjustice/manchester_traffic_offences_pleas,ministryofjustice/manchester_traffic_offences_pleas,ministryofjustice/manchester_traffic_offences_pleas | ---
+++
@@ -0,0 +1,38 @@
+import csv
+from django.core.management.base import BaseCommand
+
+
+from apps.plea.models import DataValidation, Case
+from apps.plea.standardisers import standardise_urn, format_for_region
+
+
+class Command(BaseCommand):
+ help = "Build weekly aggregate stats"
+
+ def add_arguments(... | |
d6e9971ceefc69f0eefc7440cc5e7035e7dcc05d | contentcuration/contentcuration/middleware/ErrorReportingMiddleware.py | contentcuration/contentcuration/middleware/ErrorReportingMiddleware.py | from google.cloud import error_reporting
class ErrorReportingMiddleware(object):
def __init__(self, *args, **kwargs):
self.client = error_reporting.Client()
def process_exception(self, request, exception):
self.client.report_exception()
| Add the middleware for reporting errors to gcloud. | Add the middleware for reporting errors to gcloud.
| Python | mit | fle-internal/content-curation,jonboiser/content-curation,jonboiser/content-curation,jayoshih/content-curation,aronasorman/content-curation,jayoshih/content-curation,fle-internal/content-curation,aronasorman/content-curation,jayoshih/content-curation,DXCanas/content-curation,jonboiser/content-curation,fle-internal/conte... | ---
+++
@@ -0,0 +1,9 @@
+from google.cloud import error_reporting
+
+
+class ErrorReportingMiddleware(object):
+ def __init__(self, *args, **kwargs):
+ self.client = error_reporting.Client()
+
+ def process_exception(self, request, exception):
+ self.client.report_exception() | |
40f92e6293bb13ee1462b932be15f5f11ceeee74 | compiler/infer.py | compiler/infer.py | """
# ----------------------------------------------------------------------
# infer.py
#
# Type inference for Llama
# http://courses.softlab.ntua.gr/compilers/2012a/llama2012.pdf
#
# Authors: Nick Korasidis <renelvon@gmail.com>
# Dimitris Koutsoukos <dim.kou.shmmy@gmail.com>
# --------------------------------... | Add initial implementation of TempType. | Infer: Add initial implementation of TempType.
* This will be used to supply types to all type-bearing nodes during
type inference.
| Python | mit | Renelvon/llama,Renelvon/llama | ---
+++
@@ -0,0 +1,40 @@
+"""
+# ----------------------------------------------------------------------
+# infer.py
+#
+# Type inference for Llama
+# http://courses.softlab.ntua.gr/compilers/2012a/llama2012.pdf
+#
+# Authors: Nick Korasidis <renelvon@gmail.com>
+# Dimitris Koutsoukos <dim.kou.shmmy@gmail.com... | |
133da92ed69aafc6c0a8d4466cf3b0266c5edc68 | userprofile/migrations/0006_auto_20180309_2215.py | userprofile/migrations/0006_auto_20180309_2215.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-03-09 22:15
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('userprofile', '0005_auto_20171121_1923'),
]
operations = [
migrations.AlterFi... | Add migration for change in profile model. | Add migration for change in profile model.
| Python | mit | hackerspace-ntnu/website,hackerspace-ntnu/website,hackerspace-ntnu/website | ---
+++
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2018-03-09 22:15
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('userprofile', '0005_auto_20171121_1923'),
+ ]
+
+ ... | |
f3db6608c2b4afeb214c3f1b94e0175609ad0b88 | cs4teachers/events/migrations/0018_auto_20170706_0803.py | cs4teachers/events/migrations/0018_auto_20170706_0803.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-07-06 08:03
from __future__ import unicode_literals
import autoslug.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('events', '0017_auto_20170705_0952'),
]
operations = [
migrat... | Add migration file for event slug changes | Add migration file for event slug changes
| Python | mit | uccser/cs4teachers,uccser/cs4teachers,uccser/cs4teachers,uccser/cs4teachers | ---
+++
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.2 on 2017-07-06 08:03
+from __future__ import unicode_literals
+
+import autoslug.fields
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('events', '0017_auto_20170705_0952'),
+... | |
8cf5b328d7596a9b74490b7dfd4a1b8aa1577b55 | accelerator/migrations/0110_remove_bucket_list_program_role_20220707_1001.py | accelerator/migrations/0110_remove_bucket_list_program_role_20220707_1001.py | from django.db import migrations
def remove_bucket_list_program_roles(apps, schema_editor):
BucketState = apps.get_model('accelerator', 'BucketState')
ProgramRole = apps.get_model('accelerator', 'ProgramRole')
ProgramRoleGrant = apps.get_model('accelerator', 'ProgramRoleGrant')
NodePublishedFor = apps... | Merge remote-tracking branch 'origin' into AC-9512 | [AC-9512] Merge remote-tracking branch 'origin' into AC-9512
| Python | mit | masschallenge/django-accelerator,masschallenge/django-accelerator | ---
+++
@@ -0,0 +1,28 @@
+from django.db import migrations
+
+
+def remove_bucket_list_program_roles(apps, schema_editor):
+ BucketState = apps.get_model('accelerator', 'BucketState')
+ ProgramRole = apps.get_model('accelerator', 'ProgramRole')
+ ProgramRoleGrant = apps.get_model('accelerator', 'ProgramRoleG... | |
98295608a2ba4519d12212532380253bba4372ed | scripts/frequency_analysis.py | scripts/frequency_analysis.py | import asyncio
import attr
import pprint
import dateutil.parser
from datetime import timedelta
from bobsled.core import bobsled
from bobsled.base import Status
def recommend_frequency_for_task(runs):
total_duration = timedelta(seconds=0)
longest_duration = timedelta(seconds=0)
for run in runs:
sta... | Add script that recommends scrape task schedule based on recent run timings | Add script that recommends scrape task schedule based on recent run timings
| Python | mit | openstates/bobsled,openstates/bobsled,openstates/bobsled,openstates/bobsled | ---
+++
@@ -0,0 +1,66 @@
+import asyncio
+import attr
+import pprint
+import dateutil.parser
+from datetime import timedelta
+from bobsled.core import bobsled
+from bobsled.base import Status
+
+
+def recommend_frequency_for_task(runs):
+ total_duration = timedelta(seconds=0)
+ longest_duration = timedelta(seco... | |
6aef9ab419b09822b2255141349144ac8978e862 | kolibri/core/content/migrations/0025_add_h5p_kind.py | kolibri/core/content/migrations/0025_add_h5p_kind.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11.23 on 2019-12-19 02:29
from __future__ import unicode_literals
from django.db import migrations
from django.db import models
class Migration(migrations.Migration):
dependencies = [
("content", "0024_channelmetadata_public"),
]
operations = [
... | Add migration for h5p kind. | Add migration for h5p kind.
| Python | mit | mrpau/kolibri,indirectlylit/kolibri,indirectlylit/kolibri,mrpau/kolibri,learningequality/kolibri,indirectlylit/kolibri,learningequality/kolibri,learningequality/kolibri,mrpau/kolibri,mrpau/kolibri,indirectlylit/kolibri,learningequality/kolibri | ---
+++
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.23 on 2019-12-19 02:29
+from __future__ import unicode_literals
+
+from django.db import migrations
+from django.db import models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("content", "0024_channelmetadata... | |
ecfadf8478b8775d8579812a7bd835f6ebb1ffd4 | util/rclone-list-files.py | util/rclone-list-files.py | #!/usr/bin/env python3
import glob
# For use with --files-from argument for Rclone
# This suits Edgar's structure with is
# SPECIESNAME/{occurrences|projected-distributions}/[2nd-to-latest-file-is-the-latest].zip
for folder in glob.glob('*'):
occurrences = glob.glob(folder + '/occurrences/*')
projected_distrib... | Add file lister for rclone export | Add file lister for rclone export | Python | bsd-3-clause | jcu-eresearch/Edgar,jcu-eresearch/Edgar,jcu-eresearch/Edgar,jcu-eresearch/Edgar,jcu-eresearch/Edgar,jcu-eresearch/Edgar | ---
+++
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+import glob
+
+# For use with --files-from argument for Rclone
+# This suits Edgar's structure with is
+# SPECIESNAME/{occurrences|projected-distributions}/[2nd-to-latest-file-is-the-latest].zip
+for folder in glob.glob('*'):
+ occurrences = glob.glob(folder + '/oc... | |
499adce8b5c23d60073d4c92259e611609ee0c61 | states/common/maven/artifacts/check_dependencies.py | states/common/maven/artifacts/check_dependencies.py | #!/usr/bin/env python
import subprocess as sub
import yaml
import re
distrib_pom_path = '/home/uvsmtid/Works/maritime-singapore.git/clearsea-distribution/pom.xml'
# Resolve (download) all dependencies locally so that next command
# can work offline.
sub.check_call(
[
'mvn',
'-f',
distrib_... | Add initial draft script to analyse Maven deps | Add initial draft script to analyse Maven deps
| Python | apache-2.0 | uvsmtid/common-salt-states,uvsmtid/common-salt-states,uvsmtid/common-salt-states,uvsmtid/common-salt-states | ---
+++
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+import subprocess as sub
+import yaml
+import re
+
+distrib_pom_path = '/home/uvsmtid/Works/maritime-singapore.git/clearsea-distribution/pom.xml'
+
+# Resolve (download) all dependencies locally so that next command
+# can work offline.
+sub.check_call(
+ [
+ ... | |
6fd75772efac321517a1d8c01addfa5cbbf7caf0 | tests/db/user_test.py | tests/db/user_test.py | from okcupyd.db import user
def test_have_messaged_before(T):
message_thread_model = T.factory.message_thread()
assert user.have_messaged_by_username(
message_thread_model.initiator.handle,
message_thread_model.respondent.handle
)
assert user.have_messaged_by_username(
message_t... | Add test file for user functions. | Add test file for user functions.
| Python | mit | IvanMalison/okcupyd,okuser/okcupyd,IvanMalison/okcupyd,okuser/okcupyd | ---
+++
@@ -0,0 +1,22 @@
+from okcupyd.db import user
+
+def test_have_messaged_before(T):
+ message_thread_model = T.factory.message_thread()
+ assert user.have_messaged_by_username(
+ message_thread_model.initiator.handle,
+ message_thread_model.respondent.handle
+ )
+ assert user.have_mes... | |
f8a0aa92c8e19bc11f8a609733644afe0efed5c8 | decompose_test.py | decompose_test.py | from util.decompose_graph import decompose_graph
from core.himesis_utils import expand_graph, set_do_pickle, set_compression
set_do_pickle(True)
set_compression(6)
file_name = "226482067288742734644994685633991185819"
graph = expand_graph(file_name)
print(graph.name)
from core.himesis_utils import load_directory
... | Update test script to do match testing. | Update test script to do match testing.
| Python | mit | levilucio/SyVOLT,levilucio/SyVOLT | ---
+++
@@ -0,0 +1,53 @@
+from util.decompose_graph import decompose_graph
+
+from core.himesis_utils import expand_graph, set_do_pickle, set_compression
+
+set_do_pickle(True)
+set_compression(6)
+
+file_name = "226482067288742734644994685633991185819"
+
+graph = expand_graph(file_name)
+
+print(graph.name)
+
+from ... | |
7e96013f21bbb5003b30da1e04833dcf58650602 | freenoted/tasks/tornado_thrift.py | freenoted/tasks/tornado_thrift.py | from __future__ import absolute_import
import tornado.web
from thrift.transport.TTransport import TMemoryBuffer
from thrift.protocol.TBinaryProtocol import TBinaryProtocol
class TornadoThriftHandler(tornado.web.RequestHandler):
def initialize(self, processor):
self.processor = processor
def post... | Implement a ThriftHandler for tornado | Implement a ThriftHandler for tornado
This Handler requires a processor=... kwarg (e.g., self.service) for the
third value in the handler description (e.g.,:
('/thrift', TornadoThriftHandler, dict(processor=self.service))
).
| Python | bsd-3-clause | fmoo/sparts,bboozzoo/sparts,facebook/sparts,pshuff/sparts,fmoo/sparts,djipko/sparts,bboozzoo/sparts,djipko/sparts,facebook/sparts,pshuff/sparts | ---
+++
@@ -0,0 +1,17 @@
+from __future__ import absolute_import
+
+import tornado.web
+from thrift.transport.TTransport import TMemoryBuffer
+from thrift.protocol.TBinaryProtocol import TBinaryProtocol
+
+
+class TornadoThriftHandler(tornado.web.RequestHandler):
+ def initialize(self, processor):
+ self.pr... | |
d60c1f9a6e56472611a96779462b42e8505e7905 | python/pdf_to_img.py | python/pdf_to_img.py | import requests
import json
# Convert a PDF document to JPEG/PNG image via /pdftoimg endpoint - https://pixlab.io/cmd?id=pdftoimg
req = requests.get('https://api.pixlab.io/pdftoimg',params={
'src':'https://www.getharvest.com/downloads/Invoice_Template.pdf',
'export': 'jpeg',
'key':'My_PixLab_Key'
})
reply = req.j... | Convert a PDF document to JPEG/PNG image via /pdftoimg endpoint | Convert a PDF document to JPEG/PNG image via /pdftoimg endpoint | Python | bsd-2-clause | symisc/pixlab,symisc/pixlab,symisc/pixlab | ---
+++
@@ -0,0 +1,13 @@
+import requests
+import json
+# Convert a PDF document to JPEG/PNG image via /pdftoimg endpoint - https://pixlab.io/cmd?id=pdftoimg
+req = requests.get('https://api.pixlab.io/pdftoimg',params={
+ 'src':'https://www.getharvest.com/downloads/Invoice_Template.pdf',
+ 'export': 'jpeg',
+ 'key... | |
b47369d43a0a85ac2bc32bfa77c6a4d9074ce700 | test/test_retrieve_dns.py | test/test_retrieve_dns.py | import logging
import os
import tempfile
import unittest
import mock
import bin.retrieve_dns
logging.basicConfig(level=logging.INFO)
class RetrieveDnsTestCase(unittest.TestCase):
def setUp(self):
# Mock out logging
mock.patch('bin.retrieve_dns.set_up_logging', autospec=True).start()
... | Add basic test case for retrieve_dns module | Add basic test case for retrieve_dns module
| Python | apache-2.0 | apel/apel,stfc/apel,tofu-rocketry/apel,apel/apel,tofu-rocketry/apel,stfc/apel | ---
+++
@@ -0,0 +1,57 @@
+import logging
+import os
+import tempfile
+import unittest
+
+import mock
+
+import bin.retrieve_dns
+
+
+logging.basicConfig(level=logging.INFO)
+
+
+class RetrieveDnsTestCase(unittest.TestCase):
+
+ def setUp(self):
+ # Mock out logging
+ mock.patch('bin.retrieve_dns.set_... | |
9dab373023fa6b7767cd7555a533161752205eda | scripts/0-weighted-affine.py | scripts/0-weighted-affine.py | #!/usr/bin/python
import sys
sys.path.append('../lib')
import transformations
v0 = [[0, 1031, 1031, 0], [0, 0, 1600, 1600]]
v1 = [[675, 826, 826, 677], [55, 52, 281, 277]]
#weights = [1.0, 1.0, 1.0, 1.0]
weights = [0.1, 0.01, 0.1, 0.2]
print "original"
print transformations.affine_matrix_from_points(v0, v1, shear=Fa... | Test a weighted affine solver. | Test a weighted affine solver.
Former-commit-id: b8876ed995f7c2ec029697ccd815957bc4a6cc93 | Python | mit | UASLab/ImageAnalysis | ---
+++
@@ -0,0 +1,15 @@
+#!/usr/bin/python
+
+import sys
+
+sys.path.append('../lib')
+import transformations
+
+v0 = [[0, 1031, 1031, 0], [0, 0, 1600, 1600]]
+v1 = [[675, 826, 826, 677], [55, 52, 281, 277]]
+#weights = [1.0, 1.0, 1.0, 1.0]
+weights = [0.1, 0.01, 0.1, 0.2]
+print "original"
+print transformations.af... | |
260e0ef2bc37750dccea47d30110221c272e757a | run_all_corpora.py | run_all_corpora.py | import os
import argparse
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument("corpusdir", help = "Path to the directory containing corpus directories")
parser.add_argument("script", help = "name of the script to be run")
args = parser.parse_args()
## lists of corpora to skip
## and failed to run... | Add script for automating analysis for all corpora | Add script for automating analysis for all corpora
| Python | mit | MontrealCorpusTools/SPADE,MontrealCorpusTools/SPADE | ---
+++
@@ -0,0 +1,37 @@
+import os
+import argparse
+import subprocess
+
+parser = argparse.ArgumentParser()
+parser.add_argument("corpusdir", help = "Path to the directory containing corpus directories")
+parser.add_argument("script", help = "name of the script to be run")
+args = parser.parse_args()
+
+## lists of... | |
d17c14df00c31af49080ff2f9fea8597a8861461 | starthinker_ui/recipe/management/commands/recipe_usage.py | starthinker_ui/recipe/management/commands/recipe_usage.py | ###########################################################################
#
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/l... | Add recipe usage command for quick diagnostics. | Add recipe usage command for quick diagnostics.
PiperOrigin-RevId: 432485870
| Python | apache-2.0 | google/starthinker,google/starthinker,google/starthinker | ---
+++
@@ -0,0 +1,39 @@
+###########################################################################
+#
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at... | |
e53a951ed98f460b603f43f6364d5d0a0f17a1ba | src/streamer.py | src/streamer.py | class pStream:
###PRIVATE FUNCTIONS
def _builder(self, expression):
self.STR = expression
return self
###OVERRIDES
def next(self):
return next(self.STR)
def __init__(self, iterable_thing):
self.STR = iterable_thing
def __iter__(self):
return iter(self.STR)
#... | Add basic class structure, map functionality, and a set of consumer functions. | Add basic class structure, map functionality, and a set of consumer functions.
| Python | mit | caffeine-potent/Streamer-Datastructure | ---
+++
@@ -0,0 +1,34 @@
+class pStream:
+###PRIVATE FUNCTIONS
+
+ def _builder(self, expression):
+ self.STR = expression
+ return self
+
+
+###OVERRIDES
+ def next(self):
+ return next(self.STR)
+
+ def __init__(self, iterable_thing):
+ self.STR = iterable_thing
+
+ def __ite... | |
0b6709670179c0721b4f113d13bf34d9ac7715dd | test/indices.py | test/indices.py | import matplotlib.pyplot as plt
import numpy
from math import factorial
def binom(a,b):
return factorial(a) / (factorial(b)*factorial(a-b))
def stirling(n,k):
if n<=0 or n!=0 and n==k:
return 1
elif k<=0 or n<k:
return 0
elif n==0 and k==0:
return -1
else:
s = sum(... | Add a python plotter that compares the results of with Stirling numbers | Add a python plotter that compares the results of with Stirling numbers
| Python | lgpl-2.1 | Anaphory/parameterclone,Anaphory/parameterclone | ---
+++
@@ -0,0 +1,31 @@
+import matplotlib.pyplot as plt
+import numpy
+
+from math import factorial
+
+def binom(a,b):
+ return factorial(a) / (factorial(b)*factorial(a-b))
+
+def stirling(n,k):
+ if n<=0 or n!=0 and n==k:
+ return 1
+ elif k<=0 or n<k:
+ return 0
+ elif n==0 and k==0:
+ ... | |
7b179e4a420a3cd7a27f0f438a6eac462048bb93 | py/brick-wall.py | py/brick-wall.py | import heapq
class Solution(object):
def leastBricks(self, wall):
"""
:type wall: List[List[int]]
:rtype: int
"""
n_row = len(wall)
heap = [(wall[i][0], i, 0) for i in xrange(n_row)]
heapq.heapify(heap)
max_noncross = 0
while True:
... | Add py solution for 554. Brick Wall | Add py solution for 554. Brick Wall
554. Brick Wall: https://leetcode.com/problems/brick-wall/
Approach1:
O(n_brick * log(n_row)) Use heap to find the least length of accumulated row
and find how many rows can match such length
| Python | apache-2.0 | ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode,ckclark/leetcode | ---
+++
@@ -0,0 +1,28 @@
+import heapq
+class Solution(object):
+ def leastBricks(self, wall):
+ """
+ :type wall: List[List[int]]
+ :rtype: int
+ """
+ n_row = len(wall)
+ heap = [(wall[i][0], i, 0) for i in xrange(n_row)]
+ heapq.heapify(heap)
+ max_noncros... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.