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 |
|---|---|---|---|---|---|---|---|
0091af78bd191e34ecb621b20e79d6dd3d32ebb6 | Add unit tests for VocabularySet | tests/test_core.py | tests/test_core.py | #!/usr/bin/env python
from __future__ import division
from unittest import TestCase, main
from metasane.core import VocabularySet
class VocabularySetTests(TestCase):
def setUp(self):
"""Initialize data used in the tests."""
self.single_vocab = {'vocab_1': VOCAB_1.split('\n')}
self.multi_vo... | Python | 0 | |
1f9240f0b954afa9f587f468872c3e1e215f2eaa | Implement channel mode +s (or what's left of it) | txircd/modules/cmode_s.py | txircd/modules/cmode_s.py | from txircd.modbase import Mode
class SecretMode(Mode):
def listOutput(self, command, data):
if command != "LIST":
return data
cdata = data["cdata"]
if "s" in cdata["modes"] and cdata["name"] not in data["user"].channels:
data["cdata"] = {}
# other +s stuff is hiding in other modules.
class Spawner(obje... | Python | 0 | |
9f59cf074c4f64616bf3a31fd5c6fc649e99e4ae | Checks whether all the case-based letters of the strings are uppercase | techgig_isupper.py | techgig_isupper.py | def main():
s=raw_input()
if s.isupper():
print "True"
else:
print "False"
main()
| Python | 0.999999 | |
2a26fc7f0ac6223ebcb20eb1de550e899e5728db | add beginnings of script for ball identification | scripts/hist.py | scripts/hist.py | import cv2
import numpy as np
frame = cv2.imread('/mnt/c/Users/T-HUNTEL/Desktop/hackathon/table3.jpg')
h,w,c = frame.shape
print frame.shape
# Convert BGR to HSV
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
BORDER_COLOR = 0
def flood_fill(image, x, y, value):
count = 1
points = [(x, y)]
"Flood fill on a... | Python | 0 | |
6234d8942e77ef2fda05cc7e15b901a788418070 | Create Benchmark.py | qiskit/aqua/components/optimizers/Benchmark.py | qiskit/aqua/components/optimizers/Benchmark.py | # -*- coding: utf-8 -*-
# Copyright 2018 IBM.
#
# 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 agre... | Python | 0 | |
6a686a800a3579970a15fa9552b2eb4e1b6b3ed9 | add some tools for ml scoring | corgi/ml.py | corgi/ml.py | import numpy as np
import pandas as pd
from scipy.stats import kendalltau, spearmanr
from sklearn.metrics import (accuracy_score, f1_score, log_loss,
mean_squared_error, precision_score, recall_score)
from sklearn.model_selection import StratifiedKFold
from tqdm import tqdm
classifier_sc... | Python | 0 | |
2d7d4987eb06372496ce4a5b7b961a12deba9574 | add windows-specific tests for shell_{quote,split} | tests/util_test.py | tests/util_test.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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | Python | 0 | |
a6ff8a5838f82be3d5b0b4196c03fbf7c15aff7a | Test dat.info | test.py | test.py | import unittest
import requests
port = 'http://localhost:6461'
def info():
call = port + '/api'
req = requests.get(call, stream=True)
print(req.content)
return req.status_code
class DatTest(unittest.TestCase):
def test_info(self):
self.assertEqual(info(), 200)
if __name__ == '__mai... | Python | 0 | |
26c49015b0c3be8045423306abb74eb7ea080f0b | Create test.py | test.py | test.py | # -*- coding: utf-8 -*-
import sys
import time
import feedparser
import nltk
import coding
import numpy as np
import nltk
import string
from nltk.corpus import stopwords
#coding.setup_console("utf8")
if __name__ == "__main__":
start_time = time.time()
if len(sys.argv) >= 1:
print "Старт " + str(sta... | Python | 0.000005 | |
18df3284fd6dc176b71c41599d02a24dc021f8db | add file that is useful for testing; but will be much more useful when I figure out how to turn of debugging output in Flask. | test.py | test.py | #!/usr/bin/env python
import os
from doctest import testmod, NORMALIZE_WHITESPACE, ELLIPSIS
import backend, client, frontend, misc, model, session
def tm(module):
testmod(module, optionflags=NORMALIZE_WHITESPACE | ELLIPSIS)
def run_doctests():
tm(backend)
tm(client)
tm(frontend)
tm(misc)
tm(... | Python | 0 | |
ae6184a023f9a14c54663270d4a4294b8c3832f4 | Create test.py | test.py | test.py | import os
print("hello there")
| Python | 0.000002 | |
9309f7190314abdd8b56368147862453d17d97b5 | Create test.py | test.py | test.py | Python | 0.000005 | ||
d527bc83d44b91bb827c02907faf8cd7e7d49544 | Add dateutil gist | dateutil.py | dateutil.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8:et
"""Date and Time util
"""
__author__ = ["Jianlong Chen <jianlong99@gmail.com>"]
__date__ = "2013-07-17"
import datetime
def year():
return datetime.datetime.strftime(datetime.datetime.now(), '%Y')
def date_time():
return datetime.datetime.str... | Python | 0 | |
75a61dfe788102d04e1cc3b151e839fa9add724f | Fix review requests | tools/export/cdt/__init__.py | tools/export/cdt/__init__.py | import re
from os.path import join, exists, realpath, relpath, basename
from os import makedirs
from tools.export.makefile import Makefile, GccArm, Armc5, IAR
class Eclipse(Makefile):
"""Generic Eclipse project. Intended to be subclassed by classes that
specify a type of Makefile.
"""
def generate(se... | import re
from os.path import join, exists, realpath, relpath, basename
from os import makedirs
from tools.export.makefile import Makefile, GccArm, Armc5, IAR
class Eclipse(Makefile):
"""Generic Eclipse project. Intended to be subclassed by classes that
specify a type of Makefile.
"""
def generate(se... | Python | 0 |
5186f3e4bfcaf033c4012e72c8cb766a0b903296 | Add file for updating strains | set_isotypes.py | set_isotypes.py | from gcloud import datastore
import requests
import time
ds = datastore.Client(project='andersen-lab')
url = "https://docs.google.com/spreadsheets/d/1V6YHzblaDph01sFDI8YK_fP0H7sVebHQTXypGdiQIjI/pub?gid=0&single=true&output=tsv"
gs = requests.get(url).text.encode("utf-8").splitlines()
gs = [str(x, 'utf-8').strip().sp... | Python | 0 | |
39fa13cf9b12f3828d4776d10532405c0ea43603 | Add an example | examples/example.py | examples/example.py | """
Flow as follows:
Create Service -> Create User -> Initiate Authentication -> Verify Pin
"""
from messente.verigator.api import Api
api = Api("username", "password")
service = api.services.create("http://example.com", "service_name")
user = api.users.create(service.id, "+xxxxxxxxxxx", "username")
auth_id = api.a... | Python | 0 | |
265f8c48f4b257287dd004ba783a8aa6f94bb870 | Add Latin params file | cltk/tokenize/latin/params.py | cltk/tokenize/latin/params.py | """ Params: Latin
"""
__author__ = ['Patrick J. Burns <patrick@diyclassics.org>']
__license__ = 'MIT License.'
PRAENOMINA = ['a', 'agr', 'ap', 'c', 'cn', 'd', 'f', 'k', 'l', "m'", 'm', 'mam', 'n', 'oct', 'opet', 'p', 'post', 'pro', 'q', 's', 'ser', 'sert', 'sex', 'st', 't', 'ti', 'v', 'vol', 'vop', 'a', 'ap', 'c', 'c... | Python | 0.000001 | |
8f6e10a6fe5d76a27369801ae998e3d7e30b667e | Implement Zhai_Luo support. | colour/adaptation/zhai2018.py | colour/adaptation/zhai2018.py | import numpy as np
def chromatic_adaptation_forward_Zhai2018(XYZb,
XYZwb,
Db,
XYZws,
Ds,
XYZwo,
... | Python | 0 | |
0a9efede94c64d114cf536533b94a47210a90604 | Add viper.common.constants.py | viper/common/constants.py | viper/common/constants.py | # This file is part of Viper - https://github.com/botherder/viper
# See the file 'LICENSE' for copying permission.
import os
_current_dir = os.path.abspath(os.path.dirname(__file__))
VIPER_ROOT = os.path.normpath(os.path.join(_current_dir, "..", ".."))
| Python | 0 | |
2d7ea21c2d9171a79298866bf02abf64b849be0e | add a simple info cog | dog/ext/info.py | dog/ext/info.py | from textwrap import dedent
import discord
from discord.ext.commands import guild_only
from lifesaver.bot import Cog, group, Context
from lifesaver.utils import human_delta
class Info(Cog):
"""A cog that provides information about various entities like guilds or members."""
@group(aliases=['guild', 'guild_i... | Python | 0 | |
eff85f039674ca9fe69294ca2e81644dc4ff4cb6 | add celery for all notification mail | gnowsys-ndf/gnowsys_ndf/ndf/views/tasks.py | gnowsys-ndf/gnowsys_ndf/ndf/views/tasks.py | from celery import task
from django.contrib.auth.models import User
from django.template.loader import render_to_string
from django.contrib.sites.models import Site
from gnowsys_ndf.notification import models as notification
from gnowsys_ndf.ndf.models import Node
from gnowsys_ndf.ndf.models import node_collection, tr... | Python | 0 | |
f956af85b27d104e84754b4d93a761b82ae39831 | add external_iterate.py | external_iterate.py | external_iterate.py | #!/usr/bin/env python
"""Compile a Myrial program into logical relational algebra."""
import raco.myrial.interpreter as interpreter
import raco.myrial.parser as parser
import raco.scheme
from raco import algebra
from raco import myrialang
from raco.compile import optimize
from raco.language import MyriaAlgebra
impor... | Python | 0 | |
40146a54f9857aaaf252f3e1e5de7dc73c6cd181 | add pl.proportions | scvelo/plotting/proportions.py | scvelo/plotting/proportions.py | from ..preprocessing.utils import sum_var
import matplotlib.pyplot as pl
import numpy as np
def proportions(adata, groupby='clusters', layers=['spliced', 'unspliced', 'ambigious'], highlight='unspliced',
add_labels_pie=True, add_labels_bar=True, fontsize=8, figsize=(10, 2), dpi=100, show=True):
"... | Python | 0.999557 | |
7f78d4ea286d9827aaa47022077de286195c2cd9 | Add a Fast(er) DS1820 reader | wipy/flash/lib/FDS1820.py | wipy/flash/lib/FDS1820.py | from onewire import *
import machine
import time
class FDS1820(object):
def __init__(self, onewire):
self.ow = onewire
self.roms = [rom for rom in self.ow.scan() if rom[0] == 0x10 or rom[0] == 0x28]
def read_temp(self, rom=None):
"""
Read and return the temperature of one DS18x... | Python | 0 | |
9184d4cebf95ee31836970bedffaddc3bfaa2c2d | Prepare v2.20.8.dev | flexget/_version.py | flexget/_version.py | """
Current FlexGet version.
This is contained in a separate file so that it can be easily read by setup.py, and easily edited and committed by
release scripts in continuous integration. Should (almost) never be set manually.
The version should always be set to the <next release version>.dev
The jenkins release job wi... | """
Current FlexGet version.
This is contained in a separate file so that it can be easily read by setup.py, and easily edited and committed by
release scripts in continuous integration. Should (almost) never be set manually.
The version should always be set to the <next release version>.dev
The jenkins release job wi... | Python | 0.000004 |
1bf65c4b18b1d803b9515f80056c4be5790e3bde | Prepare v1.2.276.dev | flexget/_version.py | flexget/_version.py | """
Current FlexGet version.
This is contained in a separate file so that it can be easily read by setup.py, and easily edited and committed by
release scripts in continuous integration. Should (almost) never be set manually.
The version should always be set to the <next release version>.dev
The jenkins release job wi... | """
Current FlexGet version.
This is contained in a separate file so that it can be easily read by setup.py, and easily edited and committed by
release scripts in continuous integration. Should (almost) never be set manually.
The version should always be set to the <next release version>.dev
The jenkins release job wi... | Python | 0.000002 |
f4a4b733445abba45a0a168dde9b7c10248688a6 | Prepare v1.2.318.dev | flexget/_version.py | flexget/_version.py | """
Current FlexGet version.
This is contained in a separate file so that it can be easily read by setup.py, and easily edited and committed by
release scripts in continuous integration. Should (almost) never be set manually.
The version should always be set to the <next release version>.dev
The jenkins release job wi... | """
Current FlexGet version.
This is contained in a separate file so that it can be easily read by setup.py, and easily edited and committed by
release scripts in continuous integration. Should (almost) never be set manually.
The version should always be set to the <next release version>.dev
The jenkins release job wi... | Python | 0.000002 |
860cf7b9743744c9d21796b227cf21d684fb5519 | Add test_modulepickling_change_cache_dir | test/test_cache.py | test/test_cache.py | from jedi import settings
from jedi.cache import ParserCacheItem, _ModulePickling
ModulePickling = _ModulePickling()
def test_modulepickling_change_cache_dir(monkeypatch, tmpdir):
"""
ModulePickling should not save old cache when cache_directory is changed.
See: `#168 <https://github.com/davidhalter/je... | Python | 0.000003 | |
8a511662948bff2f878d5af31fd45d02eee6dd4b | MigrationHistory.applied should be NOT NULL | south/models.py | south/models.py | from django.db import models
class MigrationHistory(models.Model):
app_name = models.CharField(max_length=255)
migration = models.CharField(max_length=255)
applied = models.DateTimeField(blank=True)
class Meta:
unique_together = (('app_name', 'migration'),)
@classmethod
def for_migrat... | from django.db import models
class MigrationHistory(models.Model):
app_name = models.CharField(max_length=255)
migration = models.CharField(max_length=255)
applied = models.DateTimeField(blank=True, null=True)
class Meta:
unique_together = (('app_name', 'migration'),)
@classmethod
def... | Python | 1 |
d082eb41c2ccef7178d228896a7658fe52bcbdec | Create directory for useless symbols remove | tests/UselessSymbolsRemove/__init__.py | tests/UselessSymbolsRemove/__init__.py | #!/usr/bin/env python
"""
:Author Patrik Valkovic
:Created 17.08.2017 14:38
:Licence GNUv3
Part of grammpy-transforms
""" | Python | 0 | |
8dc6a8088a42d836d9182592bb3e7f2f3440ccc2 | Add ptpython config | .config/ptpython/config.py | .config/ptpython/config.py | """
Configuration example for ``ptpython``.
Copy this file to $XDG_CONFIG_HOME/ptpython/config.py
On Linux, this is: ~/.config/ptpython/config.py
"""
from prompt_toolkit.filters import ViInsertMode
from prompt_toolkit.key_binding.key_processor import KeyPress
from prompt_toolkit.keys import Keys
from prompt_toolkit.st... | Python | 0.000002 | |
0c3a1d6df2350692755b33abadaa6d4355c8134c | Create separate_genes.py | separate_genes.py | separate_genes.py | """
Script to separate genes from MiSeq run fastQ files (NEXTERA style)
Use it after the tail and adapter have been trimmed from the seqs (see trim_adaptors.py),
and merged paired-end reads (I've been using flash).
This script also trims forward and reverse primers.
It will produce one file for each gene (4 here - 16S... | Python | 0 | |
3c82f0228095b2616b35a2881f51c93999fdd79b | Test models/FieldMapper | tests/test_models/test_field_mapper.py | tests/test_models/test_field_mapper.py | import json
import jsonschema
from django.test import TestCase
from core.models import FieldMapper
from tests.utils import json_string
class FieldMapperTestCase(TestCase):
@classmethod
def setUpTestData(cls):
cls.attributes = {
'name': 'Test Field Mapper',
'config_json': json_st... | Python | 0 | |
ebe10d39064410fc49ac90e38339a54d0ed47c80 | update hooks for sqlalchemy | setup/hooks/hook-sqlalchemy.py | setup/hooks/hook-sqlalchemy.py | __author__ = 'stephanie'
# Copyright (C) 2009, Giovanni Bajo
# Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; ... | Python | 0 | |
7f8f5e14f88304b272423ab12728d5329a2ba808 | use raw strings for urls | shop/urls/cart.py | shop/urls/cart.py | from django.conf.urls.defaults import url, patterns
from shop.views.cart import CartDetails, CartItemDetail
urlpatterns = patterns('',
url(r'^delete/$', CartDetails.as_view(action='delete'), # DELETE
name='cart_delete'),
url(r'^item/$', CartDetails.as_view(action='post'), # POST
name='cart_... | from django.conf.urls.defaults import url, patterns
from shop.views.cart import CartDetails, CartItemDetail
urlpatterns = patterns('',
url(r'^delete/$', CartDetails.as_view(action='delete'), # DELETE
name='cart_delete'),
url('^item/$', CartDetails.as_view(action='post'), # POST
name='cart_i... | Python | 0.000009 |
45869cdf6087cd625db385ef52475d98c9842efa | add migen_local_install script | migen_local_install.py | migen_local_install.py | import os
os.system("git clone http://github.com/m-labs/migen")
os.system("mv migen migen_tmp")
os.system("mv migen_tmp/migen migen")
os.system("rm -rf migen_tmp") | Python | 0.000001 | |
5f31e729ce6752c2f0a6b7f19f76c2a7e95636b9 | Create friends-of-appropriate-ages.py | Python/friends-of-appropriate-ages.py | Python/friends-of-appropriate-ages.py | # Time: O(a^2 + n), a is the number of ages,
# n is the number of people
# Space: O(a)
# Some people will make friend requests.
# The list of their ages is given and ages[i] is the age of the ith person.
#
# Person A will NOT friend request person B (B != A)
# if any of the following conditions are... | Python | 0.000029 | |
9caf9d3bfaaff9d7721f611d9c351dd14f67daa6 | add log progress | log_progress.py | log_progress.py | def log_progress(sequence, every=None, size=None):
from ipywidgets import IntProgress, HTML, VBox
from IPython.display import display
is_iterator = False
if size is None:
try:
size = len(sequence)
except TypeError:
is_iterator = True
if size is not None:
... | Python | 0.000001 | |
d9c7ce7f2b47bee3b2e657157fe4df8f9a00973a | Create smiles_preview.py | smiles_preview.py | smiles_preview.py | import sublime
import sublime_plugin
import base64
import os
import re
class SmilesPreview(sublime_plugin.EventListener):
def on_hover(self, view, point, hover_zone):
if (hover_zone == sublime.HOVER_TEXT):
# locate smiles in the string. smiles string should be at the beginning and followed by t... | Python | 0.000658 | |
fbeb3d04b16afa0b2daf49597a07c32b0d72630c | Add missing mica.report __init__ to project | mica/report/__init__.py | mica/report/__init__.py | from .report import main, update
| Python | 0.000019 | |
dca9931e894c1e5cae9f5229b04cc72c31eef5f5 | Create a.py | a.py | a.py | # this code is wrote on python
a = 3
print a
| Python | 0.000489 | |
2c0a06a8e460de06dd9a929baa02e2d369fbe0a6 | Prepare v2.17.4.dev | flexget/_version.py | flexget/_version.py | """
Current FlexGet version.
This is contained in a separate file so that it can be easily read by setup.py, and easily edited and committed by
release scripts in continuous integration. Should (almost) never be set manually.
The version should always be set to the <next release version>.dev
The jenkins release job wi... | """
Current FlexGet version.
This is contained in a separate file so that it can be easily read by setup.py, and easily edited and committed by
release scripts in continuous integration. Should (almost) never be set manually.
The version should always be set to the <next release version>.dev
The jenkins release job wi... | Python | 0.000003 |
b815b2e94814e86ba2e4713d15aa2143594344bc | Prepare v2.13.13.dev | flexget/_version.py | flexget/_version.py | """
Current FlexGet version.
This is contained in a separate file so that it can be easily read by setup.py, and easily edited and committed by
release scripts in continuous integration. Should (almost) never be set manually.
The version should always be set to the <next release version>.dev
The jenkins release job wi... | """
Current FlexGet version.
This is contained in a separate file so that it can be easily read by setup.py, and easily edited and committed by
release scripts in continuous integration. Should (almost) never be set manually.
The version should always be set to the <next release version>.dev
The jenkins release job wi... | Python | 0.000004 |
a30a6104554fb39d068fd8aadbb128dff1d482fb | Create dl.py | dl.py | dl.py | #!/usr/bin/env python
import requests, urllib2, os, shutil, sys, futures
from time import sleep
download_board = sys.argv[1]
def download(**kwargs):
with open('./'+download_board+'/'+kwargs['filename'], 'wb') as handle:
request = requests.get(kwargs['url'], stream=True)
for block in request.iter_... | Python | 0 | |
0b90446471805276ed141800337e6044ce130b93 | Test for the bugfix of Project.last_update | akvo/rsr/tests/models/test_project.py | akvo/rsr/tests/models/test_project.py | # -*- coding: utf-8 -*-
# Akvo Reporting is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
from unittest import TestCase
... | Python | 0 | |
30381ced0d7535428398b3df5f1caffd684b20d5 | Implement K means network. | KMeansnet.py | KMeansnet.py | import numpy as np
class Kmeansnet(object):
def __init__(self, data, clusters, eta):
self.data = data
self.n_dim = data.shape[1]
self.num_clusters = clusters
self.weights = np.random.rand(self.num_clusters, self.n_dim)
self.eta = eta
def calc_dist(self, inp, weights):
return np.sum((weights * inp), axis... | Python | 0 | |
b876332debd21edb3e3b84f01bb8aec5196bd8d8 | add enumerating partition | resource-4/combinatorics/integer-partitions/enumerating/partition.py | resource-4/combinatorics/integer-partitions/enumerating/partition.py | #zero
if n == 0:
yield []
return
#modify
for ig in partitions(n-1):
yield [1] + ig
if ig and (len(ig) < 2 or ig[1] > ig[0]):
yield [ig[0] + 1] + ig[1:]
| Python | 0.000044 | |
39714efdbfb9620acb1bb43fa8a3dbf59bfbef85 | add shortnaturaltime template filter | wypok/templatetags/shortnaturaltime.py | wypok/templatetags/shortnaturaltime.py | # from: https://github.com/ollieglass/django-shortnaturaltime
from django import template
from django.utils.timezone import utc
import time
from datetime import datetime, timedelta, date
register = template.Library()
def _now():
return datetime.utcnow().replace(tzinfo=utc)
# return datetime.now()
def abs_timede... | Python | 0 | |
d9c95fcf89f0e72c3504a4988e6d4fb6ef2ae6cd | Add the timeseries neural network | src/backend/timeseries_nnet.py | src/backend/timeseries_nnet.py | # Modified code from https://github.com/hawk31/nnet-ts
import logging
import numpy as np
from keras.optimizers import SGD
from keras.models import Sequential
from keras.layers.core import Dense, Activation
from sklearn.preprocessing import StandardScaler
logging.basicConfig(format='%(levelname)s:%(message)s', level=lo... | Python | 0.999953 | |
fefb9a9fa5a7c6080bc52896e2d1517828b01a3d | Add all PLs to db | migrations/versions/299e1d15a55f_populate_provincial_legislatures.py | migrations/versions/299e1d15a55f_populate_provincial_legislatures.py | """populate-provincial-legislatures
Revision ID: 299e1d15a55f
Revises: 1f97f799a477
Create Date: 2018-08-20 16:17:28.919476
"""
# revision identifiers, used by Alembic.
revision = '299e1d15a55f'
down_revision = '1f97f799a477'
from alembic import op
import sqlalchemy as sa
def upgrade():
"""
Ensure all pro... | Python | 0 | |
253ff8bc8f848effea6ad7602b6424cf997c926c | rename celeba_multitask_acc to celeba_multilabel_acc | caffe/result/celeba_multilabel_acc.py | caffe/result/celeba_multilabel_acc.py | import os
import numpy as np
import sys
label_file = open('/home/hypan/data/celebA/test.txt', 'r')
lines = label_file.readlines()
label_file.close()
acc = np.zeros(40)
cou = 0
for line in lines:
info = line.strip('\r\n').split()
name = info[0].split('.')[0]
gt_labels = info[1: ]
feat_path = '/home/hy... | Python | 0.999996 | |
d2e165ace4fc26b51e18494c4878f95ebcefa20a | add api | web/routers/api.py | web/routers/api.py | # coding: utf-8
import os
import json
import time
import datetime
import humanize
import flask
from flask import request, flash, redirect, url_for, render_template
import models
import gcfg
bp = flask.Blueprint('api', __name__)
@bp.route('/')
def home():
return flask.render_template('api.html')
@bp.route('/v1/... | Python | 0 | |
edbdf0d955eb387d74a73997cd11a2d05550e05a | add new action plugin junos_config | lib/ansible/plugins/action/junos_config.py | lib/ansible/plugins/action/junos_config.py | #
# Copyright 2015 Peter Sprygada <psprygada@ansible.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any... | Python | 0 | |
6c9760b328716d6b2e099698293c93cba9361932 | Add script for testing error reporting. | checkserver/testchecks/check_error.py | checkserver/testchecks/check_error.py | #!/usr/bin/env python
# Copyright 2012 The greplin-nagios-utils 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... | Python | 0 | |
bc651b5ca15cf41eece321b77142c2973bd41ede | Add a sqlite config | zinnia/tests/implementations/sqlite.py | zinnia/tests/implementations/sqlite.py | """Settings for testing zinnia on SQLite"""
from zinnia.tests.implementations.settings import * # noqa
DATABASES = {
'default': {
'NAME': 'zinnia.db',
'ENGINE': 'django.db.backends.sqlite3'
}
}
| Python | 0.000002 | |
b546ac87cd3e3821619a5ac7ed7806c1f569a3cd | Create PySMS.py | PySMS.py | PySMS.py | # -*- coding: utf-8 -*-
import smtplib
from time import strftime
# User account credentials -- (gmail username and password)
USERNAME = ''
PASSWORD = ''
# Routing -- (FROMADDR can be null iirc)
FROMADDR = ''
TOADDRS = ''
# Message Body
MESSAGE = ''
def SendMessage(MESSAGE):
server = smtplib.SMTP('smtp.gmail.... | Python | 0.000001 | |
36a8a2f52f1b85d70cda0bf399a371a4c04d0ccd | add utility script to easily launch the bottle development server | util/dev_runner.py | util/dev_runner.py | import os, dmon, bottle
os.chdir(os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..')))
bottle.run(host='localhost', port=8001) | Python | 0 | |
2fdace2e358ede8da1a6f569b063548f8969d825 | Add supervisor config generator | util/supervisor.py | util/supervisor.py | from util.config import Configuration
from configparser import ConfigParser
import platform
import os
class Supervisor:
__config = Configuration()
def __init__(self):
self.__config_file = self.__config.get_config_dir() + '/supervisor.conf'
def generate_config(self, servers):
parser = Con... | Python | 0 | |
9c731cd17ccc853207b715b778622274b28e9efd | Create clientsocket.py | clientsocket.py | clientsocket.py |
#!/usr/bin/env python
import socket
clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
clientSocket.connect(("www.google.com", 80))
request = "GET / HTTP/1.0\n\n"
clientSocket.sendall(request)
response = bytearray()
while True:
part = clientSocket.recv(1024)
if (part):
response.extend(part)
e... | Python | 0.000002 | |
885ff9c8886abd30518d2cd149f37f0ba507bb71 | add 6 | 006.py | 006.py | def sum_squares(l):
return reduce(lambda x, y: x + y**2, l)
def square_sums(l):
return reduce(lambda x, y: x + y, l) ** 2
r = range(1, 101)
ssum = sum_squares(r)
ssquare = square_sums(r)
delta = ssquare - ssum
print ssum, ssquare, delta
| Python | 0.999998 | |
a03da2611de32a38ab5b505f85136a3a9c5345f3 | add ycm config | .ycm_extra_conf.py | .ycm_extra_conf.py | # This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either... | Python | 0.000001 | |
39798f325aa0fdcfeb24ae4db97107c26e88fec9 | Create month_comparison.py | month_comparison.py | month_comparison.py | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 18 10:30:22 2015
Last updated on Tue Jul 30 12:36 2015
@author: O. B. Alam
@email: oalam@haystack.mit.edu
"""
import numpy as np
import matplotlib.pyplot as plt
import shlex
###############################################################################
content = [] ... | Python | 0.000001 | |
7ce57e27265d4ea7639aaf6f806b9312d17c5c5a | Create HR_pythonSwapCase.py | HR_pythonSwapCase.py | HR_pythonSwapCase.py | #pythonSwapCase.py
def swap_case(s):
return s.swapcase()
| Python | 0.000165 | |
104ce4eb41a8d1d8307618f619dbf5336af1056d | Add CVE plugin. | plumeria/plugins/cve.py | plumeria/plugins/cve.py | import re
import urllib.parse
from plumeria.command import commands, CommandError
from plumeria.util import http
from plumeria.util.ratelimit import rate_limit
CVE_PATTERN = re.compile("^(CVE-\\d{4,5}-\d+)$", re.IGNORECASE)
@commands.register("cve", category="Search")
@rate_limit()
async def cve(message):
"""
... | Python | 0 | |
ac7c5f51e270e48d3be9363a7c65b4b2f019c90c | Add tests for xkcd bot. | contrib_bots/bots/xkcd/test_xkcd.py | contrib_bots/bots/xkcd/test_xkcd.py | #!/usr/bin/env python
from __future__ import absolute_import
from __future__ import print_function
import mock
import os
import sys
our_dir = os.path.dirname(os.path.abspath(__file__))
# For dev setups, we can find the API in the repo itself.
if os.path.exists(os.path.join(our_dir, '..')):
sys.path.insert(0, '..... | Python | 0 | |
552e2381b25c9d3591e7b4bf4a4c5796744b15ba | Add demo configuration | .salt/files/demo.py | .salt/files/demo.py | from .prod import *
LEAFLET_CONFIG['TILES'] = [
(gettext_noop('Scan'), 'http://{s}.livembtiles.makina-corpus.net/makina/OSMTopo/{z}/{x}/{y}.png', 'OSM Topo'),
(gettext_noop('Ortho'), 'https://{s}.tiles.mapbox.com/v3/makina-corpus.i3p1001l/{z}/{x}/{y}.png', '© MapBox Satellite'),
]
LEAFLET_CONFIG['SRID'] ... | Python | 0 | |
4b4bfd8d1bfb5e6db7ac5d24be526f188ceb6e68 | add payout exceptions | bluebottle/payouts_dorado/exceptions.py | bluebottle/payouts_dorado/exceptions.py | class PayoutException(Exception):
def __init__(self, message, error_list=None):
self.message = message
self.error_list = error_list
def __str__(self):
return str(self.message)
def __unicode__(self):
return unicode(self.message)
| Python | 0 | |
41e775e0a1b7cfeaeedd078913a2f8e004999b3a | Create linkchecker.py | linkchecker.py | linkchecker.py | #!/usr/bin/env python
import pbs as sh
import os
import commands
import sys
import urllib2
class linkchecker(object):
def __init__(self):
self.urlhostnames = {}
self.tracing = {}
self.printdebug = True
def debug(self, text):
if self.printdebug:
print "DEBUG:", text... | Python | 0 | |
5908d941fc113ee02b7d5962f0209a528ab9ecb1 | Add cross-site css module | core/modules/uses_stylesheet_naver.py | core/modules/uses_stylesheet_naver.py | from bs4 import BeautifulSoup
"""
Sites that are in the Naver domain are already checked by is_masquerading. So no need to check url again
"""
def uses_stylesheet_naver(resp):
print('uses_stylesheet_naver')
answer = "U"
current_page = BeautifulSoup(resp.text, 'lxml')
stylesheets = current_page.find_al... | Python | 0.000001 | |
d217ee9c830a6cccb70155ceff44746b4e5215d6 | Add missing csv migration | saleor/csv/migrations/0004_auto_20200604_0633.py | saleor/csv/migrations/0004_auto_20200604_0633.py | # Generated by Django 3.0.6 on 2020-06-04 11:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("csv", "0003_auto_20200520_0247"),
]
operations = [
migrations.AlterField(
model_name="exportevent",
name="type",
... | Python | 0.000011 | |
6dde0b138a34698e113a3f6b017956958a4335d4 | rework blink.py | blink.py | blink.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
####
import pygame as pyg
import itertools as it
####
class Grid(object):
"""A Grid Abstraction"""
def __init__(self, dx=1, dy=1, width=1, height=1, xoff=0, yoff=0):
"""dx, dy should be > 0"""
self.dx = dx
self.dy = dy
self.w... | Python | 0.000003 | |
2b86b727cd701464969de5679d30f9bea38a08f3 | Create TheDescent.py | Easy/TheDescent/TheDescent.py | Easy/TheDescent/TheDescent.py | import sys
import math
while True:
tallest_index = -1
tallest_height = -1
for i in range(8):
mountain_h = int(input()) # represents the height of one mountain.
if(tallest_height != -1):
if(mountain_h > tallest_height):
tallest_index = i
tal... | Python | 0.000001 | |
2a01ffdbac602873615925e6f99fab801a324fef | Create minesweeper.py | minesweeper.py | minesweeper.py | import tkinter
import random
def pol_param():
size = 50
a = 8
b = 8
n = 10
return [size, a, b, n]
def perevod(a, v, d):
f = a*v + d
return f
def sozd_bomb(a, b, n):
m = []
for x in range(n):
k = (random.randrange(a * b))
while k in m:
k... | Python | 0.000001 | |
280aa4c8db7b5580b73ab6980f10d21a6ef2d761 | Add an audio output using the pygame mixer. This abuses pygame to a fair extent, but works reasonably with large-ish buffer sizes. | Sketches/JT/Jam/library/trunk/Kamaelia/Apps/Jam/Audio/PyGameOutput.py | Sketches/JT/Jam/library/trunk/Kamaelia/Apps/Jam/Audio/PyGameOutput.py | import numpy
import Numeric
import pygame
import Axon
import time
class PyGameOutput(Axon.ThreadedComponent.threadedcomponent):
bufferSize = 1024
sampleRate = 44100
def __init__(self, **argd):
super(PyGameOutput, self).__init__(**argd)
pygame.mixer.init(self.sampleRate, -16, 1, self.bufferS... | Python | 0 | |
4433cadaa39dd84b922329c84a7e791d81cac7c6 | Add a very simple test that *must* always pass. * Useful for testing the newstyle API | nettests/simpletest.py | nettests/simpletest.py | from ooni import nettest
class SimpleTest(nettest.TestCase):
inputs = range(1,100)
optParameters = [['asset', 'a', None, 'Asset file'],
['controlserver', 'c', 'google.com', 'Specify the control server'],
['resume', 'r', 0, 'Resume at this index'],
[... | Python | 0.000001 | |
73b085113b70df87098190669cfad7867d7ad57c | Create nshield-main.py | nshield-main.py | nshield-main.py | #!/usr/bin/python
# Author: Sami Yessou - samiii@protonmail.com
# nShield - An Easy and Simple Anti-DDoS solution for VPS,Dedicated Servers and IoT devices
# (To be)*Features: Blocks known attackers from the Web and allows users to CDN/Proxying their site with an offsite VPS/Servers
# Still in beta
import os
# e... | Python | 0 | |
6c7e3c4e56151dc4723d0c6ae64de6b1acfc0673 | Add some prelimenary tests for new action classes. | st2common/tests/test_shell_action_system_model.py | st2common/tests/test_shell_action_system_model.py | # Licensed to the StackStorm, Inc ('StackStorm') under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use th... | Python | 0 | |
124c4f30455d0892608622ddd09a0e7d83c3e8da | Create xmltodict_implementation.py | Useful-Libs/xmltodict_implementation.py | Useful-Libs/xmltodict_implementation.py | import xmltodict
with open('path/to/file.xml') as fd:
doc = xmltodict.parse(fd.read())
doc['mydocument']['@has'] # == u'an attribute'
doc['mydocument']['and']['many'] # == [u'elements', u'more elements']
doc['mydocument']['plus']['@a'] # == u'complex'
doc['mydocument']['plus']['#text'] # == u'ele... | Python | 0.000006 | |
3971a15aea15e097fac00f680068b505cc9047b8 | Add new descend functionality. | python/seqan/descend.py | python/seqan/descend.py | #
# Copyright John Reid 2014
#
"""
Code to descend indexes with top-down and top-down-history iterators.
"""
def depthpredicate(maxdepth):
"""Create a predicate that only descends the tree to a maximum depth.
"""
def predicate(it):
return it.repLength < maxdepth
return predicate
def suffixp... | Python | 0 | |
1e6956fb793e12b720b521feb4c0eeabaf490cea | add cache.py to cleanup cache | cache.py | cache.py | #!/usr/bin/python
import os
import time
from workflow import Workflow
AGE = 3600 * 24
LOG = None
class Cache(object):
def __init__(self):
global LOG
self.wf = Workflow()
LOG = self.wf.logger
self.cachedir = self.wf.cachedir
self.wf.cached_data_age = self.cached_data_age
... | Python | 0.000001 | |
25e09e4dbbc6dbc87c3b1cc2833021a9ae022a0e | Create compact/struct.py for python2/3 compatibility | pyvisa/compat/struct.py | pyvisa/compat/struct.py | # -*- coding: utf-8 -*-
"""
pyvisa.compat.struct
~~~~~~~~~~~~~~~~~~~~~~~~~
Python 2/3 compatibility for struct module
:copyright: 2015, PSF
:license: PSF License
"""
from __future__ import division, unicode_literals, print_function, absolute_import
import sys
import struct
# we always want the ... | Python | 0 | |
ef8bc0ddffa142e8580606377bff1d2737365711 | add various utilities in dog.util | dog/util.py | dog/util.py | import discord
def make_profile_embed(member):
embed = discord.Embed()
embed.set_author(name=f'{member.name}#{member.discriminator}',
icon_url=member.avatar_url)
return embed
def american_datetime(datetime):
return datetime.strftime('%m/%d/%Y %I:%M:%S %p')
def pretty_timedelta... | Python | 0.000251 | |
976eda9cbbce4a4fad759c4197b630209dd5a2bd | add programmer wrapper script | dist/tools/programmer/programmer.py | dist/tools/programmer/programmer.py | #!/usr/bin/env python3
# Copyright (C) 2021 Inria
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
import sys
import time
import shlex
import subprocess
import argparse
from contextlib import cont... | Python | 0.000001 | |
595356b13c68dbd3ecd50fe4eede1b479e918056 | This is junk | django-hq/apps/transformers/junk.py | django-hq/apps/transformers/junk.py | # This is a test
# for linefeeds | Python | 0.999993 | |
a7f97bbb5019b073d211c999d05b0500434d3c75 | Use six.moves.http_client instead of httplib. | oscar/test/testcases.py | oscar/test/testcases.py | from six.moves import http_client
from django.core.urlresolvers import reverse
from django.contrib.auth.models import Permission
from django_webtest import WebTest
from purl import URL
from oscar.core.compat import get_user_model
User = get_user_model()
def add_permissions(user, permissions):
"""
:param p... | from six.moves import http_client
from django.core.urlresolvers import reverse
from django.contrib.auth.models import Permission
from django_webtest import WebTest
from purl import URL
from oscar.core.compat import get_user_model
User = get_user_model()
def add_permissions(user, permissions):
"""
:param p... | Python | 0 |
d9c197840282c6bdedf5e001a1092aa707ae139c | update email field length | corehq/apps/data_analytics/migrations/0008_auto_20161114_1903.py | corehq/apps/data_analytics/migrations/0008_auto_20161114_1903.py | # -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2016-11-14 19:03
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('data_analytics', '0007_auto_20160819_1423'),
]
operations = [
migrations.Al... | Python | 0.000001 | |
0c2f730ad2e4db7f53b2a867711e00048428d82d | add rest api | src/emuvim/examples/simple_topology_restapi.py | src/emuvim/examples/simple_topology_restapi.py | """
This is an example topology for the distributed cloud emulator (dcemulator).
(c) 2015 by Manuel Peuster <manuel.peuster@upb.de>
This is an example that shows how a user of the emulation tool can
define network topologies with multiple emulated cloud data centers.
The definition is done with a Python API which lo... | Python | 0 | |
8ccf3d937d25ec93d1ce22d60735ffbcaf776fe3 | Add a script for plotting distance to target. | analysis/plot-target-distance.py | analysis/plot-target-distance.py | import climate
import itertools
import lmj.plot
import numpy as np
import source as experiment
import plots
@climate.annotate(
root='plot data from this experiment subjects',
pattern=('plot data from files matching this pattern', 'option'),
markers=('plot data for these mocap markers', 'option'),
tar... | Python | 0 | |
d8c18d9244ca09e942af57d74a407498c25d05ce | Add Linear Discriminant Analaysis. | LDA.py | LDA.py | import numpy as np
from scipy import linalg as LA
class LDA(object):
def __init__(self, data_inputs, data_labels):
self.data_inputs = np.array(data_inputs)
self.data_labels = data_labels
self.test_cases = self.data_inputs.shape[0]
self.labels = np.unique(data_labels)
self.Sw = np.zeros((self.data_inputs.sha... | Python | 0.000016 | |
3cc1bceaca2fe74d3d9f9fa846f976ba99cc7dee | Create RDF.py | RDF.py | RDF.py | from sys import argv
import pandas as pd
import numpy as np
from functions import crdf
import time
import accelerate as acc
import matplotlib
from matplotlib import pyplot as plt
fn = argv[1]
print('Box origin must be at the center!')
pos = pd.read_csv(fn, delim_whitespace=True, squeeze=1, header=None).values
import ti... | Python | 0.000004 | |
bce02c436479adf3bf3deae22704be5cf1cace89 | set addr_list and contact_list attr #5635 | erpnext/utilities/address_and_contact.py | erpnext/utilities/address_and_contact.py | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def load_address_and_contact(doc, key):
"""Loads address list and contact list in `__onload`"""
from erpnext.utilities.doctype.address.... | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def load_address_and_contact(doc, key):
"""Loads address list and contact list in `__onload`"""
from erpnext.utilities.doctype.address.... | Python | 0 |
10dbbe5b10abf954ab912fc3a2cdfe1532bf71cf | test file added | cortex-py/test/test_cortex.py | cortex-py/test/test_cortex.py | import time
import cortex
class MyDataHandler:
def __init__(self):
self.alldata = []
def MyErrorHandler(self, iLevel, msg):
print("ERROR: ")
print(iLevel, msg.contents)
return 0
def MyDataHandler(self, Frame):
print("got called")
try:
... | Python | 0 | |
8b257c2a4b8f949f81965b7ffaa80d18c48974a4 | add app framework | app.py | app.py | import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
| Python | 0.000003 | |
e258b608c40b2abca30fbc85601e05c48558fff9 | add weird migration | webapp/calendars/migrations/0023_auto_20160109_1307.py | webapp/calendars/migrations/0023_auto_20160109_1307.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('calendars', '0022_auto_20151121_1628'),
]
operations = [
migrations.AlterModelOptions(
name='category',
... | Python | 0.000002 | |
7b15ad790631926030f8b0b6c32f214f2c8001b1 | Create __init__.py | cno/boolean/__init__.py | cno/boolean/__init__.py | Python | 0.000429 | ||
edf6e9ceacab9aa2d8795340089182ead07c30b3 | Add ipopt v3.12.4 package. | var/spack/repos/builtin/packages/ipopt/package.py | var/spack/repos/builtin/packages/ipopt/package.py | from spack import *
class Ipopt(Package):
"""Ipopt (Interior Point OPTimizer, pronounced eye-pea-Opt) is a
software package for large-scale nonlinear optimization."""
homepage = "https://projects.coin-or.org/Ipopt"
url = "http://www.coin-or.org/download/source/Ipopt/Ipopt-3.12.4.tgz"
versi... | Python | 0 | |
b69476c28ed3e67d77c93f8c1fc75fde0cb33f2a | Add WikiaSearch module | commands/WikiaSearch.py | commands/WikiaSearch.py | import requests
from CommandTemplate import CommandTemplate
from IrcMessage import IrcMessage
import Constants
class Command(CommandTemplate):
triggers = ['wikiasearch']
helptext = "Searches a wiki on Wikia.com. Usage: '{commandPrefix}wikiasearch [wiki-name] [search]'. Wiki names aren't case-sensitive, but searche... | Python | 0 | |
fe32ab94bbf36621fa926d565a7720b52f1d5f11 | 268. Missing Number. In-place | p268_inplace.py | p268_inplace.py | import unittest
class Solution(object):
def missingNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
n = len(nums)
for num in nums:
if num == -1:
continue
while num != n and nums[num] != -1:
next_... | Python | 0.999999 | |
533aeb6cdc045f7d4cbfc4bc20dd89da4179ab35 | Add application class to hold all the resources pertaining to an end-user application including RPC servers, HTTP servers etc. | app/core/services/application.py | app/core/services/application.py | from threading import RLock
from uuid import uuid4
from app.core.messaging import Sender
class Application(object):
APPLICATION_INFO_QUEUE = "/_system/applications"
def __init__(self):
self.unique_id = str(uuid4())
self.rpc_servers = {}
self.app_servers = {}
self.info_lock = ... | Python | 0 | |
1df5619347b8f3e2a9fd49c95455e8b3aba07cf9 | Add example of desired new quick server usage | examples/quick_server.py | examples/quick_server.py | import hug
@hug.get()
def quick():
return "Serving!"
if __name__ == '__main__':
__hug__.serve()
| Python | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.