commit stringlengths 40 40 | subject stringlengths 1 1.49k | old_file stringlengths 4 311 | new_file stringlengths 4 311 | new_contents stringlengths 1 29.8k | old_contents stringlengths 0 9.9k | lang stringclasses 3
values | proba float64 0 1 |
|---|---|---|---|---|---|---|---|
64184fa97e9bc55dc50ed492b0b03896a7f5328d | Add degree_size | problem/pop_map/grid/degree_size.py | problem/pop_map/grid/degree_size.py | #! /usr/bin/env python
# Copyright 2020 John Hanley.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, me... | Python | 0.999462 | |
b861ce4ca77f66eca61363855003aa508b0d6421 | add api call script | scripts/api_calls.py | scripts/api_calls.py | # -*- coding: utf-8 -*-
import requests
import json
from collections import namedtuple
'''
NEWS
====
value: [
{
name: string
url: string
image: { thumbnail:
{ contentUrl: string
width: int
height: int
}
}
description: string
about: [ { readLink: string
... | Python | 0.000001 | |
4bdc0e150419e43fa1406c72af75533b45f9129a | Add Williamson test case 5 | swe-williamson-tests/sw_williamson5.py | swe-williamson-tests/sw_williamson5.py | from gusto import *
from firedrake import IcosahedralSphereMesh, SpatialCoordinate, \
as_vector, pi, sqrt, Min, FunctionSpace
import sys
parameters["pyop2_options"]["lazy_evaluation"] = False
def is_intstring(s):
try:
int(s)
return True
except ValueError:
return False
# Use a sp... | Python | 0.000007 | |
aa1fbbaca3e26904855a33014c5077867df54342 | Add Vetinari example | examples/vetinari/vetinari.py | examples/vetinari/vetinari.py | #! /usr/bin/env python
# -*- coding: utf-8 -*-
'''A Lord Vetinari clock API.'''
from time import strftime, localtime, time
from random import randint
from uwsgi import async_sleep as sleep
from swaggery.keywords import *
class TickStream(Model):
'''A stream of clock ticks.'''
schema = {
'type': 'a... | Python | 0 | |
ef14a21d5bbd2b0c98ac20eb455bd13402749463 | fix bug | app/api_1_0/activities.py | app/api_1_0/activities.py | # -*- coding:utf8 -*-
# Author: shizhenyu96@gamil.com
# github: https://github.com/imndszy
import time
from flask import request, jsonify, session
from flask_login import login_required, current_user
from app.api_1_0 import api
from app.admin.functions import admin_login_required
from app import db
from app.models imp... | # -*- coding:utf8 -*-
# Author: shizhenyu96@gamil.com
# github: https://github.com/imndszy
import time
from flask import request, jsonify, session
from flask_login import login_required
from app.api_1_0 import api
from app.admin.functions import admin_login_required
from app import db
from app.models import Activity
... | Python | 0.000001 |
eb8f749b2094d61737af496fb6e6c90bad423761 | add disk_usage.py example script | examples/disk_usage.py | examples/disk_usage.py | #!/usr/bin/env python
"""
List all mounted disk partitions a-la "df" command.
"""
import sys
import psutil
def convert_bytes(n):
if n == 0:
return "0B"
symbols = ('k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
prefix = {}
for i, s in enumerate(symbols):
prefix[s] = 1 << (i+1)*10
for s in... | Python | 0.000001 | |
5721ec07b9a40d2f8f5e04bd2c37c1e015fb99df | add an example client, nsq_to_nsq.py | examples/nsq_to_nsq.py | examples/nsq_to_nsq.py | # nsq_to_nsq.py
# Written by Ryder Moody and Jehiah Czebotar.
# Slower than the golang nsq_to_nsq included with nsqd, but useful as a
# starting point for a message transforming client written in python.
import tornado.options
from nsq import Reader, run
from nsq import Writer, Error
import functools
import logging
fr... | Python | 0.000001 | |
f2a824715216ca637251a19648f52c030a8abb30 | Update handler.py | tendrl/node_agent/message/handler.py | tendrl/node_agent/message/handler.py | import os
from io import BlockingIOError
import sys
import traceback
import gevent.event
import gevent.greenlet
from gevent.server import StreamServer
from gevent import socket
from gevent.socket import error as socket_error
from gevent.socket import timeout as socket_timeout
from tendrl.commons.message import Mess... | import os
from io import BlockingIOError
import sys
import traceback
import gevent.event
import gevent.greenlet
from gevent.server import StreamServer
from gevent import socket
from gevent.socket import error as socket_error
from gevent.socket import timeout as socket_timeout
from tendrl.commons.message import Mess... | Python | 0.000001 |
39c50fe7d4713b9d0a8e4618a829d94b4fe7456c | Add code to test van der pol model | van_der_pol_sync.py | van_der_pol_sync.py |
from __future__ import division
import sys
import numpy as np
sys.path.append('/media/ixaxaar/Steam/src/nest/local/lib/python2.7/site-packages/')
import nest
import nest.raster_plot
import nest.voltage_trace
import uuid
import pylab
nest.SetKernelStatus({"resolution": .001})
u = uuid.uuid4()
nest.CopyModel('ac_gene... | Python | 0 | |
161802f87065a6b724c8c02357edf8cbb5b38f1a | Add a rosenbrock example. | examples/rosenbrock.py | examples/rosenbrock.py | import climate
import downhill
import matplotlib.pyplot as plt
import matplotlib.animation as anim
import mpl_toolkits.mplot3d.axes3d
import numpy as np
import theano
import theano.tensor as TT
climate.enable_default_logging()
_, ax = plt.subplots(1, 1)
# run several optimizers for comparison.
for i, (algo, label, ... | Python | 0 | |
5aca812341fa16f0d31fcf6f43f1c937a81c2141 | Create supervised.py | examples/supervised.py | examples/supervised.py |
""" Part 1 """
# Load data
import numpy as np
from sklearn import datasets
iris = datasets.load_iris()
iris_X = iris.data
iris_y = iris.target
print(iris.feature_names)
print(iris.target_names)
print(np.unique(iris_y))
# Visualize data
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
X = iri... | Python | 0.000001 | |
d14130c30f776d9b10ab48c993096dce251aba28 | Add script to get list of HRS station IDs | get_hrs_cc_streamflow_list.py | get_hrs_cc_streamflow_list.py | import pandas as pd
from kiwis_pie import KIWIS
k = KIWIS('http://www.bom.gov.au/waterdata/services')
def get_cc_hrs_station_list(update = False):
"""
Return list of station IDs that exist in HRS and are supplied by providers that license their data under the Creative Commons license.
:param upda... | Python | 0 | |
cbb7fd7d31bf103e0e9c7b385926b61d42dbb8ec | add __main__ file | homework_parser/__main__.py | homework_parser/__main__.py | from homework_parser.file_parser import detect_plugin
from sys import argv, stdin, stdout, stderr, exit
if __name__ == "__main__":
in_format = argv[1]
out_format = argv[2]
out_plugin = detect_plugin(out_format)
if out_plugin is None:
print >> stderr, ('out-plugin %s not found' % out_format)
... | Python | 0.000099 | |
de5c4e57ccedf0b5c9897bc2046b79ac19a18a0c | add solution for Remove Duplicates from Sorted List | src/removeDuplicatesFromSortedList.py | src/removeDuplicatesFromSortedList.py | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# @param head, a ListNode
# @return a ListNode
def deleteDuplicates(self, head):
p1 = head
while p1:
p2 = p1.next
w... | Python | 0 | |
aec88e4f9cf2d9ee7f9fe876a7b884028b6c190c | Add Script to generate a container schema from DockerFile | bin/buildHierarchiqueDiagram.py | bin/buildHierarchiqueDiagram.py | #!/usr/bin/env/python
from datetime import datetime
import os
import argparse
import re
from graphviz import Digraph
PATH = os.path.dirname(os.path.abspath(__file__))
FROM_REGEX = re.compile(ur'^FROM\s+(?P<image>[^:]+)(:(?P<tag>.+))?', re.MULTILINE)
CONTAINERS = {}
def get_current_date():
import dat... | Python | 0.000001 | |
77b7b4603466c390bf2dc61428c64e85f7babbb0 | create a new file test_cut_milestone.py | test/unit_test/test_cut_milestone.py | test/unit_test/test_cut_milestone.py | from lexos.processors.prepare.cutter import cut_by_milestone
class TestMileStone:
def test_milestone_regular(self):
text_content = "The bobcat slept all day.."
milestone = "bobcat"
assert cut_by_milestone(text_content, milestone) == ["The ",
... | Python | 0.000004 | |
3284a384a4147857c16462c0fde6a4dec39de2b7 | Read temperature | 1-wire/ds18b20/python/ds18b20.py | 1-wire/ds18b20/python/ds18b20.py | import glob
import time
base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0]
device_file = device_folder + '/w1_slave'
def read_temp_raw():
f = open(device_file, 'r')
lines = f.readlines()
f.close()
return lines
def read_temp():
lines = read_temp_raw()
while lines[0].strip()[-3:] !=... | Python | 0 | |
89a65c75ade2629e2b67a9887e27a177617dd39e | add armes | armes/armes.py | armes/armes.py | class Arme(object) :
def __init__(self):
'''Caracteristiques de la classe arme'''
pass
def tirer(self, position, vecteur) :
'''cree et envoie un projectile dans une direction'''
pass | Python | 0.999991 | |
244b7a3b8d3bd32517effdd4b7bab35628a6db61 | move init db | flask_again/init_db.py | flask_again/init_db.py | from aone_app.db import init_db
init_db()
| Python | 0 | |
d054178a75caecfb20a5c4989dc4e9cd7bf4a853 | add grayscale conversion test - refs #1454 | tests/python_tests/grayscale_test.py | tests/python_tests/grayscale_test.py | import mapnik
from nose.tools import *
def test_grayscale_conversion():
im = mapnik.Image(2,2)
im.background = mapnik.Color('white')
im.set_grayscale_to_alpha()
pixel = im.get_pixel(0,0)
eq_((pixel >> 24) & 0xff,255);
if __name__ == "__main__":
[eval(run)() for run in dir() if 'test_' in run]
| Python | 0 | |
a76d8287d5ad0b9d43c4b509b2b42eb0a7fa03a2 | Add asyncio slackbot | slackbot_asyncio.py | slackbot_asyncio.py | import asyncio
import json
import signal
import aiohttp
from config import DEBUG, TOKEN
import websockets
RUNNING = True
async def api_call(method, data=None, file=None, token=TOKEN):
"""Perform an API call to Slack.
:param method: Slack API method name.
:param type: str
:param data: Form data to... | Python | 0.000003 | |
f4ed2ec503bc12fe645b6d79a330787d2dde6c8e | Bump version 0.15.0rc7 --> 0.15.0rc8 | lbrynet/__init__.py | lbrynet/__init__.py | import logging
__version__ = "0.15.0rc8"
version = tuple(__version__.split('.'))
logging.getLogger(__name__).addHandler(logging.NullHandler())
| import logging
__version__ = "0.15.0rc7"
version = tuple(__version__.split('.'))
logging.getLogger(__name__).addHandler(logging.NullHandler())
| Python | 0 |
1f1da12d49b9aa9b28a937fdf877bb990eb0bd2a | add convenience script to sync local from test | scratchpad/sync/sync_from_remote.py | scratchpad/sync/sync_from_remote.py | import esprit
from portality.core import app
remote = esprit.raw.Connection("http://ooz.cottagelabs.com:9200", "doaj")
local = esprit.raw.Connection("http://localhost:9200", "doaj")
esprit.tasks.copy(remote, "journal", local, "journal")
esprit.tasks.copy(remote, "account", local, "account")
esprit.tasks.copy(remote, ... | Python | 0 | |
9d7166e489b425acd64e1294236a821d76270cfc | Create letter_game_v1.1.py | letter_game_v1.1.py | letter_game_v1.1.py | # only guess a single letter
# only guess an alphabetic
# user can play again
# strikes max up to 7
# draw guesses letter, spaces, and strikes
import random
words = [
'cow',
'cat',
'crocodile',
'lion',
'tiger',
'mouse',
'goat',
'giraffe',
'elephant',
'dear',
'eagle',
'b... | Python | 0.000032 | |
e1021970c445acd8ba3acc24294611bebc63bc5a | test if weather forecast saves data in the db | server/forecasting/tests/test_weather_forecast.py | server/forecasting/tests/test_weather_forecast.py | #import unittest
from server.forecasting.forecasting.weather import WeatherForecast
from django.test import TestCase
#from server.models import Device, Sensor, SensorEntry
''''class ForecastingTest(unittest.TestCase):
def test_test(self):
cast = WeatherForecast()
'''
class ForecastingDBTest(TestCase):
def test_cra... | Python | 0.000001 | |
7f9b2cfc5605333960b20d1f0c151d966819a53b | correct SQL bug with metadata update | scripts/RT/flowpathlength_totals.py | scripts/RT/flowpathlength_totals.py | """Examination of erosion totals vs flowpath length"""
import pandas as pd
import os
import datetime
import multiprocessing
import sys
import numpy as np
import psycopg2
from tqdm import tqdm
from pyiem import dep as dep_utils
def find_huc12s():
"""yield a listing of huc12s with output!"""
pgconn = psycopg2.c... | Python | 0 | |
cb74b0055efe19b500cc959af5f931779a94fbfb | Add track proto evaluation code. | tools/evaluate/track_proto_evaluate.py | tools/evaluate/track_proto_evaluate.py | #!/usr/bin/env python
import argparse
import os
import os.path as osp
import glob
from vdetlib.utils.protocol import proto_load
import numpy as np
import sys
this_dir = osp.dirname(__file__)
sys.path.insert(0, osp.join(this_dir, '../../external/py-faster-rcnn/lib/'))
from fast_rcnn.nms_wrapper import nms
import cPickl... | Python | 0 | |
f7d88f43779f94dc2623e4726bd50f997104865f | add compress-the-string | contest/pythonist3/compress-the-string/compress-the-string.py | contest/pythonist3/compress-the-string/compress-the-string.py | # -*- coding: utf-8 -*-
# @Author: Zeyuan Shang
# @Date: 2016-05-13 12:35:11
# @Last Modified by: Zeyuan Shang
# @Last Modified time: 2016-05-13 12:35:16
from itertools import groupby
s = raw_input()
for k, g in groupby(s):
print '({}, {})'.format(len(list(g)), k), | Python | 0.999703 | |
bf7bfce64b2964cd6adb515788420747fcbedeae | Add an app.wsgi just in case | app.wsgi | app.wsgi | #!/usr/bin/env python
import itty
import leapreader
app = itty.handle_request
| Python | 0 | |
ada3083c38fe75f139079e93b7c544540fe95e1a | add sources/ package | sources/__init__.py | sources/__init__.py | import sqlaload as sl
from lobbyfacts.core import app
def etl_engine():
return sl.connect(app.config.get('ETL_URL'))
| Python | 0 | |
78a8fef6123b81011b3d896af69470d249570b05 | Add ls.py | kadai3/ls.py | kadai3/ls.py | # -*- coding: utf-8 -*-
import sys
import os
import time
import argparse
import re
from tarfile import filemode
import pwd
import grp
parser = argparse.ArgumentParser()
parser.add_argument("path",
metavar="path",
nargs="?",
default="",
... | Python | 0.000093 | |
0223ae91b669ce12b16d8b89456f3291eeed441e | Add log command. | src/commands/log.py | src/commands/log.py | #
# Copyright (c) 2012 Joshua Hughes <kivhift@gmail.com>
#
import os
import subprocess
import tempfile
import threading
import qmk
import pu.utils
class LogCommand(qmk.Command):
'''Make log entries using restructured text.'''
def __init__(self):
super(LogCommand, self).__init__(self)
self._nam... | Python | 0.000001 | |
c4d583966ef1a4d9bdb57715ef5e766ba62fbed6 | Add tests for the Django directory | jacquard/directory/tests/test_django.py | jacquard/directory/tests/test_django.py | from jacquard.directory.base import UserEntry
from jacquard.directory.django import DjangoDirectory
import pytest
import unittest.mock
try:
import sqlalchemy
except ImportError:
sqlalchemy = None
if sqlalchemy is not None:
test_database = sqlalchemy.create_engine('sqlite://')
test_database.execute("... | Python | 0 | |
6babb6e64e93ed74a72203fdc67955ae8ca3bfb3 | Add a baseline set of _MultiCall performance tests | testing/benchmark.py | testing/benchmark.py | """
Benchmarking and performance tests.
"""
import pytest
from pluggy import _MultiCall, HookImpl
from pluggy import HookspecMarker, HookimplMarker
hookspec = HookspecMarker("example")
hookimpl = HookimplMarker("example")
def MC(methods, kwargs, firstresult=False):
hookfuncs = []
for method in methods:
... | Python | 0 | |
21dc462b47f5b5577d51119ddd340c518d8cfb94 | Add script to rename photos in directory | photos.py | photos.py | import os
from datetime import date
# Programs at the Coral Gables Art Cinema.
programs = ['1. Main Features', '2. After Hours', '3. Special Screenings',
'4. Family Day on Aragon', '5. National Theatre Live',
'6. See It in 70mm', '7. Alternative Content']
for program in programs:
print(pro... | Python | 0 | |
f182dae6eb0a17f8b7a437694b69b273595f9549 | Add YAML export | jrnl/plugins/yaml_exporter.py | jrnl/plugins/yaml_exporter.py | #!/usr/bin/env python
# encoding: utf-8
from __future__ import absolute_import, unicode_literals, print_function
from .text_exporter import TextExporter
import re
import sys
import yaml
class MarkdownExporter(TextExporter):
"""This Exporter can convert entries and journals into Markdown with YAML front matter.""... | Python | 0.000001 | |
41bd33421f14498737aa0088f2d93b00bb521d7b | implement a viewset controller, capable of containing controllers | julesTk/controller/viewset.py | julesTk/controller/viewset.py |
from . import ViewController
class ViewSetController(ViewController):
def __init__(self, parent, view=None):
super(ViewSetController, self).__init__(parent, view)
self._controllers = {}
@property
def controllers(self):
""" Dictionary with all controllers used in this viewset
... | Python | 0 | |
8c5fb07b37eebf484c33ca735bd2b9dac5d0dede | solve 1 problem | solutions/nested-list-weight-sum.py | solutions/nested-list-weight-sum.py | #!/usr/bin/env python
# encoding: utf-8
"""
nested-list-weight-sum.py
Created by Shuailong on 2016-03-30.
https://leetcode.com/problems/nested-list-weight-sum/.
"""
# """
# This is the interface that allows for creating nested lists.
# You should not implement it, or speculate about its implementation
# """
# cla... | Python | 0.000027 | |
0738b3816db752b8cb678324ff4c113625660b94 | add test for pathops.operations.intersection | tests/operations_test.py | tests/operations_test.py | from pathops import Path, PathVerb
from pathops.operations import union, difference, intersection, reverse_difference, xor
import pytest
@pytest.mark.parametrize(
"subject_path, clip_path, expected",
[
[
[
(PathVerb.MOVE, ((0, 0),)),
(PathVerb.LINE, ((0, 10)... | Python | 0.000025 | |
f3c11599ef1714f7337191719172614c43b87eff | Add tests.test_OrderedSet. | tests/test_OrderedSet.py | tests/test_OrderedSet.py | from twisted.trial import unittest
from better_od import OrderedSet
class TestOrderedDict(unittest.TestCase):
def setUp(self):
self.values = 'abcddefg'
self.s = OrderedSet(self.values)
def test_order(self):
expected = list(enumerate('abcdefg'))
self.assertEquals(list(enumerat... | Python | 0 | |
7df6189dbfd69c881fedf71676dd4fdbc7dba2f0 | Add test for renormalize migration | tests/test_migrations.py | tests/test_migrations.py | import copy
import pytest
import mock
import scrapi
from scrapi.linter.document import NormalizedDocument
from scrapi import tasks
from scrapi import registry
from scrapi.migrations import delete
from scrapi.migrations import rename
from scrapi.migrations import renormalize
# Need to force cassandra to ignore set k... | import copy
import pytest
import mock
import scrapi
from scrapi.linter.document import NormalizedDocument
from scrapi import tasks
from scrapi import registry
from scrapi.migrations import delete
from scrapi.migrations import rename
# Need to force cassandra to ignore set keyspace
from scrapi.processing.cassandra i... | Python | 0.000001 |
85fc51ef3d75d2f78e80b346897d22bebf797424 | add mf_helpers | mf2py/mf_helpers.py | mf2py/mf_helpers.py | def get_url(mf):
"""parses the mf dictionary obtained as returns the URL"""
urls = []
for item in mf:
if isinstance(item, basestring):
urls.append(item)
else:
itemtype = [x for x in item.get('type',[]) if x.startswith('h-')]
if itemtype is not []:
... | Python | 0.000001 | |
1831dbd065a8776a77d18e10b44f84c99bca4c75 | Add test of simple textcat workflow | spacy/tests/textcat/test_textcat.py | spacy/tests/textcat/test_textcat.py | from __future__ import unicode_literals
from ...language import Language
def test_simple_train():
nlp = Language()
nlp.add_pipe(nlp.create_pipe('textcat'))
nlp.get_pipe('textcat').add_label('is_good')
nlp.begin_training()
for i in range(5):
for text, answer in [('aaaa', 1.), ('bbbb', 0),... | Python | 0.000001 | |
47af5fc466936f46e05f4ebaf89257e5c731a38e | add test_handle_conversation_after_delete | plugin/test/test_handle_conversation_after_delete.py | plugin/test/test_handle_conversation_after_delete.py | import unittest
import copy
from unittest.mock import Mock
import chat_plugin
from chat_plugin import handle_conversation_after_delete
class TestHandleConversationAfterDelete(unittest.TestCase):
def setUp(self):
self.conn = None
self.mock_publish_event = Mock()
chat_plugin._publish_event ... | Python | 0.000008 | |
7516f369be3723520def3a9141facc6783d3a887 | remove 4handler | githubapp.py | githubapp.py | import os
import base64
from flask import Flask , request, render_template
import nbconvert.nbconvert as nbconvert
import requests
from nbformat import current as nbformat
from flask import Flask, redirect, abort
import re
import github as gh
from gist import render_content
app = Flask(__name__)
github = gh.Github()
... | import os
import base64
from flask import Flask , request, render_template
import nbconvert.nbconvert as nbconvert
import requests
from nbformat import current as nbformat
from flask import Flask, redirect, abort
import re
import github as gh
from gist import render_content
app = Flask(__name__)
github = gh.Github()
... | Python | 0.000006 |
b7c1e4feefcb4c6eb532af5be6a65370487841ab | Create ranking.py | ranking.py | ranking.py | import datacommons as dc
import json
import urllib
import sys
import threading
import os.path
threadedp = False
US_dcid = "country/USA"
statVarConfig = None
allStatVars = []
def readVars (file):
f = open(file)
jsstr = f.read()
f.close()
statVarConfig = json.loads(jsstr)
for svc in statVarConfig:
... | Python | 0.000072 | |
a4620f5371cea0a90360c6968c7ecbe426e9e1f4 | Create genomic_range_query.py | codility/genomic_range_query.py | codility/genomic_range_query.py | """
https://codility.com/programmers/task/genomic_range_query/
"""
from collections import Counter
def solution(S, P, Q):
# Instead of counters, could've also used four prefix-sum and four suffix-sum
# arrays. E.g., `pref_1` would just do a prefix sum across S, summing up
# only the ones; `pref_2` woul... | Python | 0.000167 | |
116cf83475378b929d5b716d51e0d3fea06a42a5 | Add build script | build.py | build.py | #!/usr/bin/env python3
import re
import mmap
import os
import sys
class Header:
__slots__ = ['dir', 'file', 'map', 'data', 'comment', 'once',
'includes', 'local_includes', 'body']
FIRST_COMMENT = re.compile(br'^\s*(/\*(?:[^*]|\*+[^*/])*\*+/)')
SKIP = re.compile(br'\s*(?:(?://[^\n]*|/\*(... | Python | 0.000001 | |
ce93955bc9a5f16129ec93293a6debdb7e75891a | add script to generate gexf from csvs | tools/graph/generate_gexf_from_csv.py | tools/graph/generate_gexf_from_csv.py | #!/usr/bin/env python3
# generate a gexf file from a node csv and an edges csv
import argparse
import csv
import networkx as nx
import re
import mediawords.util.log
logger = mediawords.util.log.create_logger(__name__)
def main():
parser = argparse.ArgumentParser(description='generate a gexf file from nodes a... | Python | 0 | |
911da4d608883931166db3db27668cbc20413a6f | Create a .csv file from the CRISPR database. | extract_CRISPRdb.py | extract_CRISPRdb.py | import requests
from pattern import web
import re
import csv
def get_dom(url):
html = requests.get(url).text
dom = web.Element(html)
return dom
def get_taxons_from_CRISPRdb():
url = "http://crispr.u-psud.fr/crispr/"
dom_homepage = get_dom(url)
container = dom_homepage('div[class="strainlist... | Python | 0 | |
1cb55aa6b3abd4a3a20ff0f37b6c80c0c89ef1ff | Add a dummy pavement file. | tools/win32/build_scripts/pavement.py | tools/win32/build_scripts/pavement.py | options(
setup=Bunch(
name = "scipy-superpack",
)
)
@task
def setup():
print "Setting up package %s" % options.name
| Python | 0 | |
cef74f6d84f1d7fec54fd9a314888e7d0e84ac3f | Create telnet-cmdrunner.py | telnet-cmdrunner.py | telnet-cmdrunner.py | #!/usr/bin/python
from __future__ import absolute_import, division, print_function
import netmiko
import json
import tools
import sys ### Capture and handle signals past from the Operating System.
import signal
signal.signal(signal.SIGPIPE, signal.SIG_DFL) ### IOERror: Broken pipe
signal.signal(signal.SIGINT... | Python | 0.000006 | |
ecb6390c800260cedddba655f253a8307e096d76 | Create setup.py | setup.py | setup.py | from distutils.core import setup
setup(name='atmPy',
version='0.1',
description='Python Distribution Utilities',
author='Hagen Telg and Matt Richardson',
author_email='matt.richardson@msrconsults.com',
packages=['atmPy'],
)
| Python | 0.001383 | |
93cb8184fe5fdbf294c1e8f36b45ed8b514b2ce5 | Allow setup file to enable pip installation | setup.py | setup.py | from distutils.core import setup
setup(
name='multiworld',
packages=('multiworld', ),
)
| Python | 0 | |
dad2024344f581aa042f767e4aa473d50a8f78bc | Create individual_dist_label.py | sandbox/individual_distance/individual_dist_label.py | sandbox/individual_distance/individual_dist_label.py | #!/usr/bin/python
import os, numpy as np, scipy as sp, nibabel.freesurfer as fs
from sklearn.utils.arpack import eigsh
# Set defaults:
base_dir = '/scr/liberia1/LEMON_LSD/LSD_rest_surf'
output_base_dir = '/scr/liberia1'
subjects = [26410]
for subject in subjects:
for hemi in ['lh', 'rh']:
# read in cort... | Python | 0.000005 | |
a2865b712d0a28e3a0b8943f67703a77b5d90894 | Add a stub for testing _utils | tests/test__utils.py | tests/test__utils.py | # -*- coding: utf-8 -*-
| Python | 0 | |
181833870da1921e280d2439ae08ed74c7b137a5 | Add test for h5diag | tests/test_h5diag.py | tests/test_h5diag.py | from os.path import dirname
import numpy as np
import hdf5plugin
import h5py
from blimpy.h5diag import cmd_tool
from tests.data import voyager_h5, voyager_fil
import pytest
header = [
["fruit", "apple"],
["color", "red"],
["plant", "tree"]
]
DIR = dirname(voyager_fil)
TEST_H5 = DIR + "/test.h5"
TIME_I... | Python | 0.000002 | |
ec9944bdb7945543c95ec43d627d213536d5735a | Add monitor for volume tags | scripts/monitoring/cron-send-snapshots-tags-check.py | scripts/monitoring/cron-send-snapshots-tags-check.py | #!/usr/bin/env python
""" Check Persistent Volumes Snapshot Tags """
# We just want to see any exception that happens
# don't want the script to die under any cicumstances
# script must try to clean itself up
# pylint: disable=broad-except
# main() function has a lot of setup and error handling
# pylint: disable=too-... | Python | 0 | |
9a3a619791d34847e07c7dc7b952863d2a6d30c7 | Add simple test for monthly ghistory | tests/test_splits.py | tests/test_splits.py | import re
from tests.base import IntegrationTest
from tasklib.task import local_zone
from datetime import datetime
class TestBurndownDailySimple(IntegrationTest):
def execute(self):
self.command("TaskWikiBurndownDaily")
assert self.command(":py print vim.current.buffer", silent=False).startswith... | import re
from tests.base import IntegrationTest
from tasklib.task import local_zone
from datetime import datetime
class TestBurndownDailySimple(IntegrationTest):
def execute(self):
self.command("TaskWikiBurndownDaily")
assert self.command(":py print vim.current.buffer", silent=False).startswith... | Python | 0 |
a986397ca1bdc3bdc8894fab8b336803c172b295 | add settings file for staging (has a database url but no Sentry) | txlege84/txlege84/settings/staging.py | txlege84/txlege84/settings/staging.py | #######################
# PRODUCTION SETTINGS #
#######################
import dj_database_url
from .base import *
LOGGING = {
'version': 1,
'handlers': {
'console':{
'level':'DEBUG',
'class':'logging.StreamHandler',
},
},
'loggers': {
'django.request':... | Python | 0 | |
f5ba686196866c78dfeafb34a5f78f5cfc2c50bd | Add buildbot.py with required coverage | buildbot.py | buildbot.py | #!/usr/bin/env python
# encoding: utf-8
project_name = 'sak'
def configure(options):
pass
def build(options):
pass
def run_tests(options):
pass
def coverage_settings(options):
options['required_line_coverage'] = 94.9
| Python | 0 | |
7bbf99a60526e1b15aaf7a7fc9f5b7d6889a9efc | Create getnotfound.py | tools/getnotfound.py | tools/getnotfound.py | #!/usr/bin/env python
from __future__ import print_function
import argparse
import requests
import json
import wget
import sys
import os
__author__ = "Vesselin Bontchev <vbontchev@yahoo.com>"
__license__ = "GPL"
__VERSION__ = "1.00"
def error(e):
print("Error: %s." % e, file=sys.stderr)
sys.exit(-1)
def mak... | Python | 0.000001 | |
1a1e9123313fdedab14700ead90748d9e6182a42 | Add revision for new boardmoderator columns | migrations/versions/da8b38b5bdd5_add_board_moderator_roles.py | migrations/versions/da8b38b5bdd5_add_board_moderator_roles.py | """Add board moderator roles
Revision ID: da8b38b5bdd5
Revises: 90ac01a2df
Create Date: 2016-05-03 09:32:06.756899
"""
# revision identifiers, used by Alembic.
revision = 'da8b38b5bdd5'
down_revision = '90ac01a2df'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
from sqlalchemy... | Python | 0 | |
4213e9756872cd3a64ca75f374b5bc292e08e3be | add scraping script | scrapingArticle.py | scrapingArticle.py | # -*- coding: utf-8 -*-
from urllib.request import urlopen
from urllib.error import HTTPError
from bs4 import BeautifulSoup
def scrapingArticleText(url):
"""
引数から得たURLからブログ本文を取得して
一文ずつ区切ったstringのlistをreturnする
"""
try:
html = urlopen(url)
except HTTPError as e:
print(e)
... | Python | 0.000001 | |
0c5f2c0003ceb1568aa4f6dccce5f6de42b5462e | Add a simple monitoring solution | scripts/monitor.py | scripts/monitor.py | #!/usr/bin/python
# -*- coding: UTF-8
# Copyright: 2014 Tor Hveem <thveem>
# License: GPL3
#
# Simple Python script for polling amatyr installation and check latest date
#
# Usage: python monitor.py <AMATYR BASEURL> <EMAIL RECIPIENT>
# Check every 5 minute in crontab:
# */5 * * * * <AMATYRPATH>/scripts/monitor.py
#
i... | Python | 0.000001 | |
23dab9c4a0220a7a35b4a88daeda79bd65bdeb3b | fix in range | ostap/fitting/tests/test_in_range_2d.py | ostap/fitting/tests/test_in_range_2d.py | import sys
from ostap.core.pyrouts import *
import ROOT, random, time
import ostap.fitting.roofit
import ostap.fitting.models as Models
from ostap.core.core import cpp, VE, dsID
from ostap.logger.utils import rooSilent
from builtins import range
from ostap.fitting.background import make_b... | Python | 0.000007 | |
5e20df222456fe17fa78290e8fa08b051a951b38 | Add events.py | octokit/resources/events.py | octokit/resources/events.py | # encoding: utf-8
"""Methods for the Events API
http://developer.github.com/v3/activity/events/
http://developer.github.com/v3/issues/events/
"""
| Python | 0.000004 | |
3b22994b26db1c224ef0076bf9a031f661953ada | create Feed of latest articles on the current site. | opps/articles/views/feed.py | opps/articles/views/feed.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.contrib.syndication.views import Feed
from django.contrib.sites.models import get_current_site
from opps.articles.models import Article
class ArticleFeed(Feed):
link = "/RSS"
def __call__(self, request, *args, **kwargs):
self.site = get_curr... | Python | 0 | |
111eb59d2390a008cad5edc8e18456d42b7f7117 | Add hearthPwnCrawler.py, for crawling deck strings from hearthPwn websize. | hearthPwnCrawler.py | hearthPwnCrawler.py | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Created on 2017-07-17 08:52:38 by lanhin
# Project: Deckstring Crawler
#
# Use this file as a pyspider script
# To crawl deck from http://www.hearthpwn.com/decks
# Refer to http://docs.pyspider.org/en/latest/Quickstart/ for more details
from pyspider.libs.base_handler ... | Python | 0 | |
4cfc07a275a473ed14f7c99150b2f233c680d7c0 | Add db dumping utility | dbcat.py | dbcat.py | #!/usr/bin/env python
import sys
import anydbm as dbm
def main():
for k,v in dbm.open(sys.argv[1]).iteritems():
print "key: {0:s} value: {1:s}".format(k, v)
if __name__ == '__main__':
sys.exit(main()) | Python | 0 | |
1631731657af28c275b35f9b084807e4f244c334 | debug module. initial code | debug.py | debug.py | # -*- coding: utf-8 -*-
# MusicPlayer, https://github.com/albertz/music-player
# Copyright (c) 2013, Albert Zeyer, www.az2000.de
# All rights reserved.
# This code is under the 2-clause BSD license, see License.txt in the root directory of this project.
# This is the debug module: tools to debug MusicPlayer.
# This is... | Python | 0.999675 | |
ed43384ece07bf1a02529d2f79423e96c8283443 | Add mangling experimental sample | src_clang/experimental/show-mangle.py | src_clang/experimental/show-mangle.py | import pprint
import sys
import clang.cindex
def get_cursor(source, spelling):
"""Obtain a cursor from a source object.
This provides a convenient search mechanism to find a cursor with specific
spelling within a source. The first argument can be either a
TranslationUnit or Cursor instance.
If th... | Python | 0 | |
472d23ec5706d081cbdbf32687884b133fdf6864 | Add benchmark for ogbg_molpcba example. | examples/ogbg_molpcba/ogbg_molpcba_benchmark.py | examples/ogbg_molpcba/ogbg_molpcba_benchmark.py | # Copyright 2021 The Flax Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | Python | 0.000045 | |
0caaf977096d5936747ad4931d14041675a9864a | create a paths utility to better work with ceph paths | ceph_deploy/util/paths.py | ceph_deploy/util/paths.py | from os.path import join
from ceph_deploy.util import constants
class mon(object):
_base = join(constants.mon_path, 'ceph-')
@classmethod
def path(cls, hostname):
return "%s%s" % (cls._base, hostname)
@classmethod
def done(cls, hostname):
return join(cls.path(hostname), 'done')... | Python | 0 | |
1aeb34f003e5d437ac55c560ef062b22e9f02c0a | Define health blueprint. | rio/blueprints/health.py | rio/blueprints/health.py | # -*- coding: utf-8 -*-
from flask import Blueprint
bp = Blueprint('health', __name__)
@bp.route('/')
def index():
return 'OK'
| Python | 0.000002 | |
a8b48d9174ce9c30166c0c2a8011c2c40624c4bd | Add a spider for Planned Parenthood | locations/spiders/planned_parenthood.py | locations/spiders/planned_parenthood.py | # -*- coding: utf-8 -*-
import scrapy
import json
import re
from locations.items import GeojsonPointItem
class PlannedParenthoodSpider(scrapy.Spider):
name = "planned_parenthood"
allowed_domains = ["www.plannedparenthood.org"]
start_urls = (
'https://www.plannedparenthood.org/health-center',
... | Python | 0 | |
397f31c8b43da123f2a55350a7d572b3a13431a6 | Add module to ease handling of CKAN filestores. | ckantoolbox/filestores.py | ckantoolbox/filestores.py | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# CKAN-Toolbox -- Various modules that handle CKAN API and data
# By: Emmanuel Raviart <emmanuel@raviart.com>
#
# Copyright (C) 2013 Emmanuel Raviart
# http://gitorious.org/etalab/ckan-toolbox
#
# This file is part of CKAN-Toolbox.
#
# CKAN-Toolbox is free software; you ... | Python | 0 | |
0331bffc755ad4234edcca3edaf1b9697b8ae8c3 | Create A.py | Google-Code-Jam/2010-Africa/A.py | Google-Code-Jam/2010-Africa/A.py | Python | 0.000004 | ||
c568256dac3c13f6740d2a2df5a8a848e2f7d68e | check in new stream settings file | waterbutler/core/streams/settings.py | waterbutler/core/streams/settings.py | from waterbutler import settings
config = settings.child('STREAMS_CONFIG')
ZIP_EXTENSIONS = config.get('ZIP_EXTENSIONS', '.zip .gz .bzip .bzip2 .rar .xz .bz2 .7z').split(' ')
| Python | 0 | |
5bea532c7651faacb163745fbbf28fa4f53ba438 | add predicting-office-space-price | ai/machine-learning/predicting-office-space-price/predicting-office-space-price.py | ai/machine-learning/predicting-office-space-price/predicting-office-space-price.py | import numpy as np
from sklearn.preprocessing import PolynomialFeatures
from sklearn import linear_model
if __name__ == "__main__":
(f, n) = map(int, raw_input().split())
x = []
y = []
poly = PolynomialFeatures(degree = 4)
for i in range(n):
v = map(float, raw_input().split())
x.app... | Python | 0.998153 | |
45fea3847e2800a920ccb06e102ebaf9a5f9a4ce | Add forgotten migration for newly introduced default ordering | tk/material/migrations/0002_auto_20170704_2155.py | tk/material/migrations/0002_auto_20170704_2155.py | # -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-07-04 19:55
from __future__ import unicode_literals
from django.db import migrations
import localized_fields.fields.field
class Migration(migrations.Migration):
dependencies = [
('material', '0001_initial'),
]
operations = [
m... | Python | 0 | |
af0486cd767564cda7259aa30a0d7c90420e226e | Add get json example | chapter2/get.py | chapter2/get.py | import urllib2,json
results = urllib2.urlopen('http://192.168.168.84/api.json').read()
json.loads(results)['led'] | Python | 0 | |
1acbad02071a4d1ef953bc2c0643525e5d681d54 | Add in a script to run the linter manually | runlint.py | runlint.py | #!/usr/bin/env python
import optparse
import sys
from closure_linter import checker
from closure_linter import error_fixer
from closure_linter import gjslint
USAGE = """%prog [options] [file1] [file2]...
Run a JavaScript linter on one or more files.
This will invoke the linter, and optionally attempt to auto-fix ... | Python | 0.000382 | |
3e5d6e5dd31193f42ebddaeff856bfe53703a19e | Add script to get evidence sources | models/fallahi_eval/evidence_sources.py | models/fallahi_eval/evidence_sources.py | from util import pklload
from collections import defaultdict
import indra.tools.assemble_corpus as ac
if __name__ == '__main__':
# Load cached Statements just before going into the model
stmts = pklload('pysb_stmts')
# Start a dictionary for source counts
sources_count = defaultdict(int)
# Count ... | Python | 0 | |
276435cc3b4f77dc16dde4a73cd930e461e1ef47 | Implement LM in defn/lm.py | imaginet/defn/lm.py | imaginet/defn/lm.py | from funktional.layer import Layer, Dense, StackedGRU, StackedGRUH0, \
Embedding, OneHot, clipped_rectify, CrossEntropy, \
last, softmax3d, params
import funktional.context as context
from funktional.layer import params
import imaginet.task
from funkti... | Python | 0.001362 | |
bcb8615fb0d009ad4e7899b9e91701333dc56990 | Add abyss package (#4555) | var/spack/repos/builtin/packages/abyss/package.py | var/spack/repos/builtin/packages/abyss/package.py | ##############################################################################
# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-64... | Python | 0 | |
418e714e3d544abc7120c7252c51493cd59081a0 | Add custom CommentedObjectManager | comment_utils/managers.py | comment_utils/managers.py | """
Custom manager which managers of objects which allow commenting can
inheit from.
"""
from django.db import models
class CommentedObjectManager(models.Manager):
"""
A custom manager class which provides useful methods for types of
objects which allow comments.
Models which allow comments but ... | Python | 0.000001 | |
f189ed9401e82e55a7b3b73ce06a8f5c642344ac | Add functional test file | functional_tests.py | functional_tests.py | from selenium import webdriver
import unittest
class Test(unittest.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
self.browser.implicitly_wait(3) # Browser will eventually wait 3 secs
# for a thing to appear if needed
def tearDown(self):... | Python | 0.000001 | |
09a25009965d9951614ed0702185947f796c41a0 | Create scraper.py | scraper.py | scraper.py | from lxml.html import parse
def main():
baseurl = 'http://www.schoolcolleges.com/school.select.php?offset=%s&val=city=%270%27&select=%s'
states = [
'Andhra Pradesh',
'Arunachal Pradesh',
'Assam',
'BIHAR',
'Chhattisgarh',
'Goa',
'Gujarat',
'Haryana',
'Himachal Pradesh',
'Jammu & Kashmir',
'Jharkhand',
'Ka... | Python | 0.000004 | |
691543bb43b67dd9cc9ff6d6ee6a212badd4c61e | add valid unicode example | scripts/unicode_valid.py | scripts/unicode_valid.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
print(json.dumps({
"_meta": {
"hostvars": {
"not_unicode": {"host_var": "unicode here 日本語"}
}
},
"all": {
"vars": {
"inventory_var": "this is an inventory var 日本語"
}
},
"group_日本語": {
... | Python | 0.004751 | |
2bc7acd167d6e18dfbc2bc2625957f2bd58fa1f5 | Create spacial_prototype.py | Vision/spacial_prototype.py | Vision/spacial_prototype.py | import numpy as np
import math as m
# Prototype code for the image-to-world location system. Requires numpy.
# TODO
def _inverse_perspective():
pass
# Convert a global coordinate to a relative coordinate
# (roll, pitch, yaw) = camera_angle
# (x, y, z) = camera_pos, cone_pos (global coordinates)
# (width, height)... | Python | 0.000003 | |
785f6a4f435c68bb6336b4e42da0964cf5cbfce4 | Add module that finds classifier training examples given a ground truth in the graph | hytra/jst/classifiertrainingexampleextractor.py | hytra/jst/classifiertrainingexampleextractor.py | '''
Provide methods to find positive and negative training examples from a hypotheses graph and
a ground truth mapping, in the presence of multiple competing segmentation hypotheseses.
'''
import numpy as np
import logging
from hytra.core.random_forest_classifier import RandomForestClassifier
def getLogger():
''... | Python | 0.00015 | |
23f6d87b94bf0340b70b9803f1b8c712f1d88726 | Add models in session module. | dataviva/apps/session/models.py | dataviva/apps/session/models.py | from dataviva.apps.session.login_providers import facebook, twitter, google
from dataviva.apps.account.models import User
from dataviva.utils.encode import sha512
from flask import Blueprint, request, render_template, session, redirect, Response
from flask.ext.login import login_user, logout_user
from forms import Log... | Python | 0 | |
ccd1822d65f5565d4881e5a6a32b535e55cc2b50 | Implement preview of entries for restricted users in EntryPreviewMixin | zinnia/views/mixins/entry_preview.py | zinnia/views/mixins/entry_preview.py | """Preview mixins for Zinnia views"""
from django.http import Http404
from django.utils.translation import ugettext as _
from zinnia.managers import PUBLISHED
class EntryPreviewMixin(object):
"""
Mixin implementing the preview of Entries.
"""
def get_object(self, queryset=None):
"""
... | Python | 0 | |
120c93a2dd0022de5cb3a30ceffc027e69b23c3a | Add ProgressMonitor | entity_networks/monitors.py | entity_networks/monitors.py | from __future__ import absolute_import
from __future__ import print_function
from __future__ import division
import numpy as np
import tensorflow as tf
from tqdm import tqdm
class ProgressMonitor(tf.contrib.learn.monitors.EveryN):
def __init__(self, tensor_names, every_n_steps=100, first_n_steps=1):
sup... | Python | 0 | |
770ed3ea3ec2ab8d76172b85bd8b37c22517139c | add initial define function | cogs/define.py | cogs/define.py | import discord
from discord.ext import commands
from bs4 import BeautifulSoup
class Define:
def __init__(self, bot):
self.bot = bot
self.aiohttp_session = bot.aiohttp_session
self.url = 'https://google.com/search'
self.headers = {'User-Agent':
'Mozilla/5.0 (W... | Python | 0.000004 | |
fe7d8e23a6ab8d86c39ef8ede2ddafa40a7fc1fb | Add RIPE space lookup thread | irrexplorer/ripe.py | irrexplorer/ripe.py | #!/usr/bin/env python
# Copyright (C) 2015 Job Snijders <job@instituut.net>
#
# This file is part of IRR Explorer
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the abo... | Python | 0 | |
a91386a802d3346c945e107aa3abd6aa5fcfe0d7 | Solve double base palindrome | project_euler/036.double_palindromes.py | project_euler/036.double_palindromes.py | '''
Problem 036
The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.
Find the sum of all numbers, less than one million, which are palindromic in
base 10 and base 2.
(Please note that the palindromic number, in either base, may not include
leading zeros.)
Solution: Copyright 2017 D... | Python | 0.999999 | |
892b6b6cb334ec3f932881f7e698e3ab6619cbf3 | add a script to get an API token | oauth.py | oauth.py | """Simple script to obtain an API token via OAuth."""
import webbrowser
from argparse import ArgumentParser
from http.server import BaseHTTPRequestHandler, HTTPServer
from typing import Dict
from urllib.parse import urlencode
import requests
HOST_NAME = "localhost"
SERVER_PORT = 8080
REDIRECT_PATH = "/oauth/return"
... | Python | 0.000001 | |
3096af347f1cda453eb48f7002371a49b389c568 | use keep_lazy if available | django_extensions/utils/text.py | django_extensions/utils/text.py | # -*- coding: utf-8 -*-
import six
from django.utils.encoding import force_text
try:
from django.utils.functional import keep_lazy
KEEP_LAZY = True
except ImportError:
from django.utils.functional import allow_lazy
KEEP_LAZY = False
def truncate_letters(s, num):
"""
truncates a string to a num... | # -*- coding: utf-8 -*-
import six
from django.utils.encoding import force_text
from django.utils.functional import allow_lazy
def truncate_letters(s, num):
"""
truncates a string to a number of letters, similar to truncate_words
"""
s = force_text(s)
length = int(num)
if len(s) > length:
... | Python | 0.000001 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.