text stringlengths 0 1.05M | meta dict |
|---|---|
__author__ = 'fatcloud'
import cv2
import numpy as np
from cam import OpenCV_Cam
class MotionDetector(object):
def __init__(self, N=1, shape=(480,640,3)):
self._N = N
self._frame = [None] * (2 * N + 1)
self._index = 0
for i in range(2 * N + 1):
self._frame[i] = np.ful... | {
"repo_name": "philipz/PyCV-time",
"path": "experiments/background_substraction/motion_detect.py",
"copies": "3",
"size": "1324",
"license": "mit",
"hash": -9120261148143839000,
"line_mean": 23.0727272727,
"line_max": 57,
"alpha_frac": 0.5370090634,
"autogenerated": false,
"ratio": 2.884531590413... |
__author__ = 'fauri'
from PriceCutdown.items import ProductItem
import os
import scrapy
class CelSpider(scrapy.Spider):
name = "cel"
allowed_domains = ["cel.ro"]
start_urls = ['http://www.cel.ro/laptop-laptopuri/apple/']
base_product_url = "http://www.cel.ro"
def __init__(self, name=None, reque... | {
"repo_name": "fioan89/Price-Cutdown",
"path": "PriceCutdown/spiders/cel_spider.py",
"copies": "1",
"size": "2119",
"license": "mit",
"hash": -2780339375906320400,
"line_mean": 36.8571428571,
"line_max": 156,
"alpha_frac": 0.5988673903,
"autogenerated": false,
"ratio": 3.743816254416961,
"confi... |
__author__ = 'fauri'
from PriceCutdown.items import ProductItem
import os
import scrapy
class EmagSpider(scrapy.Spider):
name = "emag"
allowed_domains = ["emag.ro"]
start_urls = ["http://emag.ro/laptopuri/apple/c"]
base_product_url = "http://emag.ro"
def __init__(self, name=None, requests_file=... | {
"repo_name": "fioan89/Price-Cutdown",
"path": "PriceCutdown/spiders/emag_spider.py",
"copies": "1",
"size": "1892",
"license": "mit",
"hash": -1613121219909803000,
"line_mean": 35.3846153846,
"line_max": 124,
"alpha_frac": 0.5983086681,
"autogenerated": false,
"ratio": 3.7465346534653468,
"con... |
__author__ = 'fauri'
import datetime
import sys
import unittest
from decimal import Decimal
class psycopg2stub():
@staticmethod
def connect(database=None, user=None, password=None, host=None, port=None,
connection_factory=None, cursor_factory=None, async=False, **kwargs):
class Connec... | {
"repo_name": "fioan89/Price-Cutdown",
"path": "PriceCutdown/unittests/test_monitor.py",
"copies": "1",
"size": "7772",
"license": "mit",
"hash": -9517467671359028,
"line_mean": 52.6,
"line_max": 111,
"alpha_frac": 0.4799279465,
"autogenerated": false,
"ratio": 4.185245018847604,
"config_test":... |
__author__ = 'fauri'
import psycopg2
import settings
from email_postman import GmailPostMan
SELECT_PROD_IDS_DISTINCT = "SELECT DISTINCT prod_id, name, url FROM products ORDER BY prod_id"
# Result
# [(1,'product long name', 'http://www.<provider>.com/product_location_xxssd_dsad')]
SELECT_PRICES = "SELECT price, date... | {
"repo_name": "fioan89/Price-Cutdown",
"path": "PriceCutdown/monitor.py",
"copies": "1",
"size": "6168",
"license": "mit",
"hash": -8958500762340509000,
"line_mean": 44.3529411765,
"line_max": 119,
"alpha_frac": 0.5875486381,
"autogenerated": false,
"ratio": 3.8121137206427687,
"config_test": f... |
__author__ = 'fauri'
import random
from scrapy.downloadermiddlewares.useragent import UserAgentMiddleware
# http://www.useragentstring.com/pages/useragentstring.php
USER_AGENTS = [
'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1',
'Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101... | {
"repo_name": "fioan89/Price-Cutdown",
"path": "PriceCutdown/dmiddlewares/rotate_useragent.py",
"copies": "1",
"size": "1819",
"license": "mit",
"hash": 2009537426931118000,
"line_mean": 59.6333333333,
"line_max": 133,
"alpha_frac": 0.7003848268,
"autogenerated": false,
"ratio": 2.591168091168091... |
__author__ = 'fauri'
import smtplib
import socket
from sys import stderr
GMAIL_SMTP_HOST = 'smtp.gmail.com'
GMAIL_SMTP_PORT = 587
def recvline(sock):
stop = 0
line = ''
while True:
i = sock.recv(1)
if i == '\n': stop = 1
line += i
if stop == 1:
break
retu... | {
"repo_name": "fioan89/Price-Cutdown",
"path": "PriceCutdown/email_postman.py",
"copies": "1",
"size": "4029",
"license": "mit",
"hash": -8809469147075851000,
"line_mean": 38.1165048544,
"line_max": 117,
"alpha_frac": 0.5889798958,
"autogenerated": false,
"ratio": 3.7937853107344632,
"config_te... |
__author__ = 'fbidu'
BASE_URL = "https://raw.githubusercontent.com/github/gitignore/master/"
GITIGNORE_URL = ""
def has_gitignore():
import os
return os.path.isfile("./.gitignore")
def get_https_response(host, path):
import httplib
conn = httplib.HTTPSConnection(host)
conn.request('HEAD', path)
... | {
"repo_name": "fbidu/giting",
"path": "giting.py",
"copies": "1",
"size": "1493",
"license": "mit",
"hash": 8421309291562696000,
"line_mean": 23.4918032787,
"line_max": 78,
"alpha_frac": 0.6523777629,
"autogenerated": false,
"ratio": 3.504694835680751,
"config_test": false,
"has_no_keywords":... |
__author__ = 'fcanas'
import termhelper
class Reporter:
"""
Responsible for displaying results and recording them to log files.
"""
def __init__(self, warg=0):
self.width = warg
self.set_terminal_width(warg) # default width of terminal
templates = {
'test': '[ {0:.<{2}}... | {
"repo_name": "izv/IzVerifier",
"path": "IzVerifier/logging/reporter.py",
"copies": "1",
"size": "4354",
"license": "mit",
"hash": 5251067989599517000,
"line_mean": 37.201754386,
"line_max": 111,
"alpha_frac": 0.515158475,
"autogenerated": false,
"ratio": 4.315163528245788,
"config_test": true,... |
__author__ = 'fcanas'
import unittest
from IzVerifier.izverifier import IzVerifier
path1 = 'data/sample_installer_iz5/izpack/'
path2 = 'data/sample_installer_iz5/resources/'
source_path2 = 'data/sample_code_base/src/'
pom = 'data/sample_installer_iz5/pom.xml'
class TestDependencies(unittest.TestCase):
"""
... | {
"repo_name": "izv/IzVerifier",
"path": "IzVerifier/test/test_dependencies.py",
"copies": "1",
"size": "1556",
"license": "mit",
"hash": -8278919572127591000,
"line_mean": 25.3728813559,
"line_max": 113,
"alpha_frac": 0.5655526992,
"autogenerated": false,
"ratio": 3.758454106280193,
"config_tes... |
__author__ = 'federicamoscato'
def clean_author(string_authors, users_lastnames_names):
repls = {"\\`{": "", "\\'{": "", '{': '', '}': "", '\\`': "",
"\'": "", '\~': '', "\"": "", "\\": ""}
repls_names = {".": "", ",":""}
authors_asi = []
try:
#e' questa finalmente la formula mag... | {
"repo_name": "lbmm/S.E.Arch",
"path": "pubblicazioniASI/ASI_authors.py",
"copies": "1",
"size": "2803",
"license": "mit",
"hash": 2849362086033005000,
"line_mean": 28.1979166667,
"line_max": 99,
"alpha_frac": 0.5215840171,
"autogenerated": false,
"ratio": 4.015759312320917,
"config_test": fals... |
__author__ = 'federicamoscato'
import argparse
from datetime import datetime
import pymongo
import sys
sys.path.insert(0, "../")
import pubblicazioniASDC.userDAO as userDAO
connection_string = "mongodb://localhost"
connection = pymongo.MongoClient(connection_string)
database = connection.publication
users = userDA... | {
"repo_name": "lbmm/ASDCBibliographyTool",
"path": "bin/createAdmin.py",
"copies": "1",
"size": "2596",
"license": "mit",
"hash": 7976351839107419000,
"line_mean": 24.4509803922,
"line_max": 108,
"alpha_frac": 0.6275038521,
"autogenerated": false,
"ratio": 4.088188976377952,
"config_test": fals... |
__author__ = 'federicamoscato'
import csv
import pymongo
import pubblicazioniASI.contractDAO as contractDAO
FILE_TO_LOAD = 'docs/Contratti_scientifici_ASI per biblioteca.csv'
connection_string = ""
connection = pymongo.MongoClient(connection_string)
database = connection.publicationASI
contracts = contractDAO.Contr... | {
"repo_name": "lbmm/S.E.Arch",
"path": "bin/loadContracts.py",
"copies": "1",
"size": "1918",
"license": "mit",
"hash": 5236936825621333000,
"line_mean": 27.6268656716,
"line_max": 126,
"alpha_frac": 0.6272158498,
"autogenerated": false,
"ratio": 3.724271844660194,
"config_test": false,
"has_... |
__author__ = 'federicamoscato'
import csv
import re
from datetime import datetime
import pymongo
import pubblicazioniASI.userDAO as userDAO
FILE_TO_LOAD = ''
connection_string = ""
connection = pymongo.MongoClient(connection_string)
database = connection.publicationASI
users = userDAO.UserDAO(database)
repls = {" ... | {
"repo_name": "lbmm/S.E.Arch",
"path": "bin/loadUsers.py",
"copies": "1",
"size": "1919",
"license": "mit",
"hash": -9022661222912998000,
"line_mean": 25.2876712329,
"line_max": 111,
"alpha_frac": 0.5732152163,
"autogenerated": false,
"ratio": 3.8767676767676766,
"config_test": false,
"has_no... |
__author__ = 'federicamoscato'
import pymongo
import bibtexparser
from datetime import datetime
import pubblicazioniASI.publicationDAO as publicationDAO
import pubblicazioniASI.userDAO as userDAO
import pubblicazioniASI.ASI_authors as ASI_authors
import pubblicazioniASI.pubUtilities as pu
FILE_TO_LOAD = 'documentat... | {
"repo_name": "lbmm/S.E.Arch",
"path": "bin/loadPublications.py",
"copies": "1",
"size": "4930",
"license": "mit",
"hash": 8584648304021406000,
"line_mean": 29.8125,
"line_max": 107,
"alpha_frac": 0.6095334686,
"autogenerated": false,
"ratio": 3.4596491228070176,
"config_test": false,
"has_no... |
__author__ = 'Federico Milano'
import fhir.client.primitive
import fhir.client.complex
class Address:
def __init__(self):
self.__code = fhir.client.primitive.Code('home')
self.lines = []
self.city = ''
self.state = ''
self.zip = ''
self.country = ''
self.__... | {
"repo_name": "Johnnetto/FHIRSnake",
"path": "fhir/client/address.py",
"copies": "1",
"size": "1128",
"license": "mit",
"hash": 8917471612303605000,
"line_mean": 25.8571428571,
"line_max": 94,
"alpha_frac": 0.5806737589,
"autogenerated": false,
"ratio": 3.9166666666666665,
"config_test": false,... |
__author__ = 'Federico Milano'
import sys
class Place:
def __init__(self, x, y, dict_fingerprint):
self.x = x
self.y = y
self.dict_fingerprint = dict_fingerprint
def distance(self, dict_fingerprint):
sum = 0.
for mac in dict_fingerprint.keys():
if self.di... | {
"repo_name": "Johnnetto/Localizacion-WiFi",
"path": "Plano/location.py",
"copies": "1",
"size": "1272",
"license": "mit",
"hash": -7868828334467997000,
"line_mean": 25.5,
"line_max": 120,
"alpha_frac": 0.5715408805,
"autogenerated": false,
"ratio": 3.901840490797546,
"config_test": false,
"h... |
__author__ = 'Federico'
# Multilabel (i.e. a sample is assigned to more than one category) Naive Bayes classifier for WoN dataset
#It uses OneVsRest, MultinomialNB classification strategies
from numpy import *
from tools.tensor_utils import read_input_tensor, SparseTensor
from sklearn import metrics
from sklearn.naive... | {
"repo_name": "researchstudio-sat/wonpreprocessing",
"path": "python-processing/classification/multilabel_classifier.py",
"copies": "1",
"size": "3587",
"license": "apache-2.0",
"hash": 4019642468848916500,
"line_mean": 33.8252427184,
"line_max": 110,
"alpha_frac": 0.6816281015,
"autogenerated": fa... |
__author__ = 'Federico Vaggi'
from abc import ABCMeta
from copy import deepcopy
import numpy as np
from ..utils import OrderedHashDict
class LossFunctionABC(object):
__metaclass__ = ABCMeta
def __init__(self):
pass
def evaluate(self, simulations, experiment_measures):
pass
def resi... | {
"repo_name": "FedericoV/SysBio_Modeling",
"path": "project/loss_functions/abstract_loss_function.py",
"copies": "1",
"size": "5734",
"license": "mit",
"hash": -6170085012664762000,
"line_mean": 38.0068027211,
"line_max": 119,
"alpha_frac": 0.5997558423,
"autogenerated": false,
"ratio": 3.9958188... |
__author__ = 'Federico Vaggi'
import os
n_vars = 2
def michelis_menten(y, t, *args):
p = args[0]
#*! Parameters Start
vmax = p[0]
km = p[1]
k_synt_s = p[2]
k_deg_s = p[3]
k_deg_p = p[4]
#*! Parameters End
#*! Variables Start
_s = y[0]
_p = y[1]
#*! Variables End... | {
"repo_name": "FedericoV/SysBio_Modeling",
"path": "tests/test_utils/michelis_menten_model.py",
"copies": "1",
"size": "1517",
"license": "mit",
"hash": -7782393476918352000,
"line_mean": 23.4677419355,
"line_max": 112,
"alpha_frac": 0.5715227423,
"autogenerated": false,
"ratio": 2.57993197278911... |
__author__ = 'Federico Vaggi'
from .abstract_measurement import MeasurementABC
class TimecourseMeasurement(MeasurementABC):
"""
A series of measured values, with their associated timepoints and standard deviations (optimal).
:param variable_name: The name of the measured variable
:type: string
:... | {
"repo_name": "FedericoV/SysBio_Modeling",
"path": "measurement/timecourse_measurement.py",
"copies": "1",
"size": "1931",
"license": "mit",
"hash": -1458420469514725000,
"line_mean": 41.9111111111,
"line_max": 114,
"alpha_frac": 0.6716727084,
"autogenerated": false,
"ratio": 4.022916666666666,
... |
__author__ = 'Federico Vaggi'
from .squared_loss_function import SquareLossFunction
class NormalizedSquareLossFunction(SquareLossFunction):
"""
Normalized Square Loss Function:
.. math::
C(\theta)= 0.5*(\frac{\sum{BX_i - Y_i}}^2{(\sigma_i * Y_i))}^2
Where:
`X_i` is f(\theta, i), `Y_i`... | {
"repo_name": "FedericoV/SysBio_Modeling",
"path": "project/loss_functions/squared_loss/normalized_squared_loss_function.py",
"copies": "1",
"size": "2182",
"license": "mit",
"hash": 1291735551385719300,
"line_mean": 45.4255319149,
"line_max": 119,
"alpha_frac": 0.670944088,
"autogenerated": false,... |
__author__ = 'Federico Vaggi'
from unittest import TestCase
import os
from nose.tools import raises
import numpy as np
from scipy.integrate import odeint
import numba
from ..symbolic import make_jit_model
from test_utils import simple_model
from test_utils.jittable_model import model as unjitted_model
from test_util... | {
"repo_name": "FedericoV/SysBio_Modeling",
"path": "tests/test_sympy_tools.py",
"copies": "1",
"size": "3188",
"license": "mit",
"hash": -2455492486069958000,
"line_mean": 34.8202247191,
"line_max": 99,
"alpha_frac": 0.6320577164,
"autogenerated": false,
"ratio": 2.9301470588235294,
"config_tes... |
__author__ = 'Federico Vaggi'
from unittest import TestCase
import numpy as np
from nose.tools import raises
from ..measurement import TimecourseMeasurement
class TestTimecourseMeasurement(TestCase):
@classmethod
def setUpClass(cls):
exp_timepoints = np.array([0. , 11.11111111, 22.222222... | {
"repo_name": "FedericoV/SysBio_Modeling",
"path": "tests/test_Measurements.py",
"copies": "1",
"size": "3001",
"license": "mit",
"hash": -8746063680428023000,
"line_mean": 47.4193548387,
"line_max": 100,
"alpha_frac": 0.5704765078,
"autogenerated": false,
"ratio": 3.3123620309050774,
"config_t... |
__author__ = 'Federico Vaggi'
import numpy as np
import numba
from assimulo.problem import Explicit_Problem
from assimulo.solvers import CVode
from assimulo.solvers.sundials import CVodeError
from assimulo.exception import TimeLimitExceeded
from abstract_model import ModelABC
def _make_rhs(odefunc, y0):
yout = n... | {
"repo_name": "FedericoV/SysBio_Modeling",
"path": "model/assimulo_model.py",
"copies": "1",
"size": "4235",
"license": "mit",
"hash": -7747042942891799000,
"line_mean": 31.0833333333,
"line_max": 98,
"alpha_frac": 0.6030696576,
"autogenerated": false,
"ratio": 3.3189655172413794,
"config_test"... |
__author__ = 'Federico Vaggi'
import numpy as np
import scipy
import numba
from ..abstract_scale_factor import ScaleFactorABC
########################################################################################
# Utility Functions
#################################################################################... | {
"repo_name": "FedericoV/SysBio_Modeling",
"path": "project/loss_functions/squared_loss/linear_scale_factor.py",
"copies": "1",
"size": "3197",
"license": "mit",
"hash": -7304890394780238000,
"line_mean": 35.3295454545,
"line_max": 115,
"alpha_frac": 0.543009071,
"autogenerated": false,
"ratio": ... |
__author__ = 'Federico Vaggi'
import numpy as np
import scipy
from ..abstract_scale_factor import ScaleFactorABC
class LogScaleFactor(ScaleFactorABC):
def __init__(self, log_prior=None, log_prior_sigma=None):
super(LogScaleFactor, self).__init__(log_prior, log_prior_sigma)
self._sf = 0
... | {
"repo_name": "FedericoV/SysBio_Modeling",
"path": "project/loss_functions/squared_loss/log_scale_factor.py",
"copies": "1",
"size": "3016",
"license": "mit",
"hash": -5900497969810092000,
"line_mean": 35.7804878049,
"line_max": 115,
"alpha_frac": 0.5872015915,
"autogenerated": false,
"ratio": 3.... |
__author__ = 'Federico Vaggi'
import numpy as np
from ..abstract_loss_function import LossFunctionWithScaleFactors, DifferentiableLossFunctionABC
from .linear_scale_factor import LinearScaleFactor
class SquareLossFunction(LossFunctionWithScaleFactors, DifferentiableLossFunctionABC):
def __init__(self, sf_groups... | {
"repo_name": "FedericoV/SysBio_Modeling",
"path": "project/loss_functions/squared_loss/squared_loss_function.py",
"copies": "1",
"size": "4571",
"license": "mit",
"hash": -738757216994129900,
"line_mean": 42.1226415094,
"line_max": 111,
"alpha_frac": 0.5867425071,
"autogenerated": false,
"ratio"... |
__author__ = 'Federico Vaggi'
import numpy as np
from .squared_loss_function import SquareLossFunction
from .log_scale_factor import LogScaleFactor
class LogSquareLossFunction(SquareLossFunction):
def __init__(self, sf_groups=None):
"""
Log Square Loss Function:
.. math::
C(... | {
"repo_name": "FedericoV/SysBio_Modeling",
"path": "project/loss_functions/squared_loss/log_squared_loss_function.py",
"copies": "1",
"size": "4450",
"license": "mit",
"hash": 8522523578714877000,
"line_mean": 44.4081632653,
"line_max": 113,
"alpha_frac": 0.5840449438,
"autogenerated": false,
"ra... |
__author__ = 'Federico Vaggi'
import numpy as np
###############################################################################
# Simple mapping functions
###############################################################################
def direct_model_var_to_measure(model_sim, model_timepoints, experiment, measure... | {
"repo_name": "FedericoV/SysBio_Modeling",
"path": "project/utils.py",
"copies": "1",
"size": "7559",
"license": "mit",
"hash": 6169741051941985000,
"line_mean": 35.8780487805,
"line_max": 114,
"alpha_frac": 0.5908188914,
"autogenerated": false,
"ratio": 4.36431870669746,
"config_test": false,
... |
__author__ = 'Federico Vaggi'
n_vars = 1
def simple_model(y, t, *args):
p = args[0]
#*! Parameters Start
k_deg = p[0]
k_synt = p[1]
#*! Parameters End
#*! Variables Start
_y = y[0]
#*! Variables End
#*! Differential Equations Start
d_y = k_synt - k_deg * _y
#*! Differential Equations End
... | {
"repo_name": "FedericoV/SysBio_Modeling",
"path": "tests/test_utils/simple_model.py",
"copies": "1",
"size": "1437",
"license": "mit",
"hash": 4820330914108645000,
"line_mean": 26.6346153846,
"line_max": 97,
"alpha_frac": 0.5448851775,
"autogenerated": false,
"ratio": 2.8971774193548385,
"conf... |
__author__ = 'feeltheajf'
from dateutil import parser
import json
from dojo.models import Finding
class BrakemanScanParser(object):
def __init__(self, filename, test):
tree = filename.read()
try:
data = json.loads(str(tree, 'utf-8'))
except:
data = json.loads(tree)... | {
"repo_name": "rackerlabs/django-DefectDojo",
"path": "dojo/tools/brakeman/parser.py",
"copies": "2",
"size": "2107",
"license": "bsd-3-clause",
"hash": 2081585176107773400,
"line_mean": 29.9852941176,
"line_max": 79,
"alpha_frac": 0.4532510679,
"autogenerated": false,
"ratio": 4.482978723404256,... |
class ListNode:
"""singly-linked node
"""
def __init__(self, x=None):
"""
:rtype : object
"""
self.val = self.next = None
if isinstance(x, list):
if len(x) == 1:
self.val = x[0]
self.next = None
elif len(x) > ... | {
"repo_name": "feigaochn/leetcode",
"path": "node/sllist.py",
"copies": "2",
"size": "6108",
"license": "mit",
"hash": 680358928053089800,
"line_mean": 22.766536965,
"line_max": 72,
"alpha_frac": 0.4413883432,
"autogenerated": false,
"ratio": 3.9406451612903224,
"config_test": false,
"has_no_... |
# Definition for a binary tree node
class TreeNode(object):
def __init__(self, x=None):
self.left = None
self.right = None
self.dic = dict()
if isinstance(x, (list, tuple)):
self = self.build_from_list(list(x))
else:
self.val = x
def print_mlr(s... | {
"repo_name": "feigaochn/leetcode",
"path": "node/btree.py",
"copies": "2",
"size": "4309",
"license": "mit",
"hash": 5239277271339080000,
"line_mean": 27.7266666667,
"line_max": 61,
"alpha_frac": 0.4330471107,
"autogenerated": false,
"ratio": 4.175387596899225,
"config_test": false,
"has_no_... |
class Solution:
# @param matrix, a list of lists of integers
# @return a list of integers
def spiralOrder(self, matrix):
result = []
rows = len(matrix)
if rows == 0:
return result
columns = len(matrix[0])
if columns == 0:
return result
... | {
"repo_name": "feigaochn/leetcode",
"path": "p54_spiral_matrix.py",
"copies": "2",
"size": "1708",
"license": "mit",
"hash": -5740700698323864000,
"line_mean": 27.9491525424,
"line_max": 106,
"alpha_frac": 0.4765807963,
"autogenerated": false,
"ratio": 3.6033755274261603,
"config_test": false,
... |
import bisect
class Solution:
# @param A, a list of integers
# @param target, an integer to be searched
# @return a list of length 2, [index1, index2]
def searchRange(self, A, target):
if A is None or len(A) == 0:
return [-1, -1]
if target < A[0] or target > A[-1]:
... | {
"repo_name": "feigaochn/leetcode",
"path": "p34_search_for_a_range.py",
"copies": "2",
"size": "1353",
"license": "mit",
"hash": 363309488993864640,
"line_mean": 25.0192307692,
"line_max": 98,
"alpha_frac": 0.5373244642,
"autogenerated": false,
"ratio": 3.1538461538461537,
"config_test": false... |
import itertools
class Solution:
# @return a list of strings, [s1, s2]
def letterCombinations(self, digits):
number_letters = {}
for i in range(2, 7):
number_letters[str(i)] = [chr(j + ord('a')) for j in range((i - 2) * 3, (i - 2) * 3 + 3)]
number_letters[str(7)] = 'pqrs'
... | {
"repo_name": "feigaochn/leetcode",
"path": "p17_letter_combinations_of_a_phone_number.py",
"copies": "2",
"size": "1451",
"license": "mit",
"hash": 6784723832360441000,
"line_mean": 29.2291666667,
"line_max": 101,
"alpha_frac": 0.5789110958,
"autogenerated": false,
"ratio": 3.382284382284382,
... |
# Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
from node import TreeNode
class Solution:
# @param root, a tree node
# @return an integer
def maxPathSum(self, root):
if root is None... | {
"repo_name": "feigaochn/leetcode",
"path": "p124_binary_tree_maximum_path_sum.py",
"copies": "2",
"size": "1977",
"license": "mit",
"hash": -8285126258304741000,
"line_mean": 27.2428571429,
"line_max": 72,
"alpha_frac": 0.5209914011,
"autogenerated": false,
"ratio": 3.240983606557377,
"config_... |
from node import TreeNode
class Solution:
# @param root, a tree node
# @return an integer
def maxDepth(self, root):
def max_depth(root):
"""
find maximum depth of root
"""
# bfs
depth = 0
cur_depth = [root]
whil... | {
"repo_name": "feigaochn/leetcode",
"path": "p104_maximum_depth_of_binary_tree.py",
"copies": "2",
"size": "1368",
"license": "mit",
"hash": -7939669673879497000,
"line_mean": 23.4285714286,
"line_max": 116,
"alpha_frac": 0.5226608187,
"autogenerated": false,
"ratio": 3.8974358974358974,
"confi... |
class Solution:
# @param prices, a list of integer
# @return an integer
def maxProfit(self, prices):
if prices is None or len(prices) == 0:
return 0
# (best win from start to here, min price before here)
best_from_start = [(0, prices[0])]
for cur_price in pric... | {
"repo_name": "feigaochn/leetcode",
"path": "p123_best_time_to_buy_and_sell_stock_iii.py",
"copies": "2",
"size": "1727",
"license": "mit",
"hash": -3059615292462201000,
"line_mean": 29.8392857143,
"line_max": 79,
"alpha_frac": 0.5906195715,
"autogenerated": false,
"ratio": 3.295801526717557,
"... |
# Note: if price drops today, sell out yesterday and buy in today!
class Solution:
# @param prices, a list of integer
# @return an integer
def maxProfit(self, prices):
if prices is None or len(prices) <= 1:
return 0
win = 0
buy = prices[0]
for i in range(1, le... | {
"repo_name": "feigaochn/leetcode",
"path": "p122_best_time_to_buy_and_sell_stock_ii.py",
"copies": "2",
"size": "1355",
"license": "mit",
"hash": 5887877990251484000,
"line_mean": 26.6530612245,
"line_max": 79,
"alpha_frac": 0.5948339483,
"autogenerated": false,
"ratio": 3.4478371501272265,
"c... |
class Solution:
# @param prices, a list of integer
# @return an integer
def maxProfit(self, prices):
if prices is None or len(prices) == 0:
return 0
# (best win from start to here, min price before here)
best_from_start = [(0, prices[0])]
for cur_price in price... | {
"repo_name": "feigaochn/leetcode",
"path": "p121_best_time_to_buy_and_sell_stock.py",
"copies": "2",
"size": "1213",
"license": "mit",
"hash": -3289985792014864400,
"line_mean": 27.2093023256,
"line_max": 79,
"alpha_frac": 0.6108821105,
"autogenerated": false,
"ratio": 3.3324175824175826,
"con... |
class Solution:
# @param root, a tree node
# @return a list of lists of integers
def levelOrder(self, root):
if root is None:
return []
result = []
cur_level = [root]
next_level = []
while len(cur_level) > 0:
values = []
for node ... | {
"repo_name": "feigaochn/leetcode",
"path": "p102_binary_tree_level_order_traversal.py",
"copies": "2",
"size": "1565",
"license": "mit",
"hash": -3205848459239234000,
"line_mean": 23.453125,
"line_max": 135,
"alpha_frac": 0.5392971246,
"autogenerated": false,
"ratio": 3.3874458874458875,
"conf... |
class Solution:
# @param root, a tree node
# @param sum, an integer
# @return a boolean
def hasPathSum(self, root, sum):
def gao(node, sum):
if node.left is None and node.right is None:
return sum == node.val
if node.left is not None \
... | {
"repo_name": "feigaochn/leetcode",
"path": "p112_path_sum.py",
"copies": "2",
"size": "1184",
"license": "mit",
"hash": -3786663526525126700,
"line_mean": 25.9090909091,
"line_max": 150,
"alpha_frac": 0.5135135135,
"autogenerated": false,
"ratio": 3.6097560975609757,
"config_test": false,
"h... |
from node.sllist import ListNode, SinglyLinkedList
class Solution:
# @return a ListNode
def addTwoNumbers(self, l1, l2):
h1 = l1
h2 = l2
h = ListNode(0)
p = h
carry = 0
while h1 and h2:
p.next = ListNode(h1.val + h2.val + carry)
p = p.ne... | {
"repo_name": "feigaochn/leetcode",
"path": "p2_add_two_numbers.py",
"copies": "2",
"size": "1551",
"license": "mit",
"hash": -3660409702980258300,
"line_mean": 23.234375,
"line_max": 73,
"alpha_frac": 0.4893617021,
"autogenerated": false,
"ratio": 3.2379958246346554,
"config_test": false,
"h... |
from node import TreeNode
class Solution:
# @param root, a tree node
# @return a list of integers
def preorderTraversal(self, root):
preorder = []
if root is None:
return preorder
queue = [root]
while len(queue) != 0:
node = queue.pop(0)
... | {
"repo_name": "feigaochn/leetcode",
"path": "p144_binary_tree_preorder_traversal.py",
"copies": "2",
"size": "1086",
"license": "mit",
"hash": 8028927252266412000,
"line_mean": 21.625,
"line_max": 74,
"alpha_frac": 0.5607734807,
"autogenerated": false,
"ratio": 3.5145631067961167,
"config_test"... |
class Solution:
# @return an integer
def maxArea(self, height):
if not height or len(height) < 2:
return 0
head_i = 0
head_h = height[0]
tail_i = len(height) - 1
tail_h = height[-1]
max_area = max(0, (tail_i - head_i) * min(tail_h, head_h))
... | {
"repo_name": "feigaochn/leetcode",
"path": "p11_container_with_most_water.py",
"copies": "2",
"size": "1510",
"license": "mit",
"hash": 4047026314874492400,
"line_mean": 24.593220339,
"line_max": 77,
"alpha_frac": 0.5026490066,
"autogenerated": false,
"ratio": 3.3856502242152464,
"config_test"... |
# Definition for singly-linked list with a random pointer.
class RandomListNode:
def __init__(self, x):
self.label = x
self.next = None
self.random = None
class Solution:
# @param head, a RandomListNode
# @return a RandomListNode
def copyRandomList(self, head):
if hea... | {
"repo_name": "feigaochn/leetcode",
"path": "p138_copy_list_with_random_pointer.py",
"copies": "2",
"size": "1599",
"license": "mit",
"hash": 8092429512132653000,
"line_mean": 22.8656716418,
"line_max": 73,
"alpha_frac": 0.5259537211,
"autogenerated": false,
"ratio": 3.7623529411764705,
"config... |
class Solution:
# @return a string
def countAndSay(self, n):
def process(s):
l = []
start = 0
for end in range(1, len(s)):
if s[end] != s[end-1]:
l.append(s[start:end])
start = end
l.append(s[start:... | {
"repo_name": "feigaochn/leetcode",
"path": "p38_count_and_say.py",
"copies": "2",
"size": "1100",
"license": "mit",
"hash": -215340578366094240,
"line_mean": 24,
"line_max": 78,
"alpha_frac": 0.5018181818,
"autogenerated": false,
"ratio": 3.3950617283950617,
"config_test": false,
"has_no_key... |
class Solution:
# @param s, a string
# @return an integer
def numDecodings(self, s):
if s is None or s == '':
return 0
seen = {'': 1, '0': 0}
def dp(s):
if s in seen:
return seen[s]
if s[:1] == '0':
return 0
... | {
"repo_name": "feigaochn/leetcode",
"path": "p91_decode_ways.py",
"copies": "2",
"size": "1198",
"license": "mit",
"hash": 6099383105586857000,
"line_mean": 20.7818181818,
"line_max": 96,
"alpha_frac": 0.4991652755,
"autogenerated": false,
"ratio": 3.403409090909091,
"config_test": false,
"ha... |
class Solution:
# @param tokens, a list of string
# @return an integer
def evalRPN(self, tokens):
if not tokens:
return None
op = {'+': lambda x, y: x + y,
'-': lambda x, y: x - y,
'*': lambda x, y: x * y,
'/': lambda x, y: int(float(x)... | {
"repo_name": "feigaochn/leetcode",
"path": "p150_evaluate_reverse_polish_notation.py",
"copies": "2",
"size": "1620",
"license": "mit",
"hash": -9462379525188140,
"line_mean": 28.4545454545,
"line_max": 89,
"alpha_frac": 0.4333333333,
"autogenerated": false,
"ratio": 3.375,
"config_test": fals... |
class Solution:
# @return a list of integers
def grayCode(self, n):
gray = [0]
for i in range(n):
gray = gray[:] + [x + 2**i for x in gray[::-1]]
return gray
def main():
solver = Solution()
for n in range(1, 4):
print(n, ':\n',
'\n'.join(['{:... | {
"repo_name": "feigaochn/leetcode",
"path": "p89_gray_code.py",
"copies": "2",
"size": "1088",
"license": "mit",
"hash": -9182128146445406000,
"line_mean": 25.5365853659,
"line_max": 77,
"alpha_frac": 0.6167279412,
"autogenerated": false,
"ratio": 3.296969696969697,
"config_test": false,
"has... |
import collections
class Solution:
# @return a boolean
def isInterleave(self, s1, s2, s3):
if not s1 or not s2:
return s3 == s1 + s2
if len(s1) + len(s2) != len(s3):
return False
l1 = len(s1) + 1
l2 = len(s2) + 1
dp = [[False for _ in range(l2)]... | {
"repo_name": "feigaochn/leetcode",
"path": "p97_interleaving_string.py",
"copies": "2",
"size": "1607",
"license": "mit",
"hash": -5115394913446252000,
"line_mean": 28.2181818182,
"line_max": 79,
"alpha_frac": 0.5351586808,
"autogenerated": false,
"ratio": 2.6872909698996654,
"config_test": fa... |
class Solution:
# @param head, a ListNode
# @return a list node
def detectCycle(self, head):
if head is None:
return None
elif head.next == head:
return head
h1 = head
h2 = head
end = False
steps = 0
m1 = 0
m2 = 0
... | {
"repo_name": "feigaochn/leetcode",
"path": "p142_linked_list_cycle_ii.py",
"copies": "2",
"size": "1246",
"license": "mit",
"hash": -2729893167365604000,
"line_mean": 19.4262295082,
"line_max": 77,
"alpha_frac": 0.4333868379,
"autogenerated": false,
"ratio": 3.8575851393188856,
"config_test": ... |
import collections
# Definition for a point
class Point:
def __init__(self, a=0, b=0):
self.x = a
self.y = b
def __repr__(self):
return repr((self.x, self.y))
class Solution:
# @param points, a list of Points
# @return an integer
def maxPoints(self, points):
zer... | {
"repo_name": "feigaochn/leetcode",
"path": "p149_max_points_on_a_line.py",
"copies": "2",
"size": "3718",
"license": "mit",
"hash": 5785095569113738000,
"line_mean": 39.4130434783,
"line_max": 120,
"alpha_frac": 0.391070468,
"autogenerated": false,
"ratio": 2.719824433065106,
"config_test": fa... |
# Definition for an interval.
class Interval:
def __init__(self, s=0, e=0):
self.start = s
self.end = e
class Solution:
# @param intervals, a list of Interval
# @return a list of Interval
def merge(self, intervals):
intervals.sort(key=(lambda x: (x.start, x.end)))
i... | {
"repo_name": "feigaochn/leetcode",
"path": "p56_merge_intervals.py",
"copies": "2",
"size": "1104",
"license": "mit",
"hash": 7490448069003001000,
"line_mean": 21.5306122449,
"line_max": 67,
"alpha_frac": 0.5389492754,
"autogenerated": false,
"ratio": 3.1907514450867054,
"config_test": false,
... |
class Solution:
# @param grid, a list of lists of integers
# @return an integer
def minPathSum(self, grid):
# DP
if grid is None or len(grid) == 0 or len(grid[0]) == 0:
return 0
n_row = len(grid)
n_col = len(grid[0])
dp = [[None for col in range(n_col)] ... | {
"repo_name": "feigaochn/leetcode",
"path": "p64_minimum_path_sum.py",
"copies": "2",
"size": "1476",
"license": "mit",
"hash": -3537896409512662000,
"line_mean": 30.4042553191,
"line_max": 79,
"alpha_frac": 0.5054200542,
"autogenerated": false,
"ratio": 3.28,
"config_test": false,
"has_no_ke... |
class Solution:
# @return a boolean
def isMatch(self, s, p):
# hack the TLE case: ("aaaaaaaaaaaaab", "a*a*a*a*a*a*a*a*a*a*c") -> False
p = str(p)
alphas = set(list(p)) - {'*'}
for k in alphas:
pt = k + '*' + k + '*'
while p.find(pt) != -1:
... | {
"repo_name": "feigaochn/leetcode",
"path": "p10_regular_expression_matching.py",
"copies": "2",
"size": "1950",
"license": "mit",
"hash": -7697690839032356000,
"line_mean": 25.3513513514,
"line_max": 81,
"alpha_frac": 0.4307692308,
"autogenerated": false,
"ratio": 3.1451612903225805,
"config_t... |
from node.sllist import SinglyLinkedList
class Solution:
# @param head, a ListNode
# @return a ListNode
def deleteDuplicates(self, head):
if head is None or head.next is None:
return head
h = head
n = head.next
dump = False
# while n is not None and n... | {
"repo_name": "feigaochn/leetcode",
"path": "p82_remove_duplicates_from_sorted_list_ii.py",
"copies": "2",
"size": "1255",
"license": "mit",
"hash": -392626560761196350,
"line_mean": 23.6078431373,
"line_max": 129,
"alpha_frac": 0.5537848606,
"autogenerated": false,
"ratio": 3.42896174863388,
"... |
from node.sllist import *
class Solution:
# @return a ListNode
def removeNthFromEnd(self, head, n):
# let ph be 1st, pn be n-th
ph = head
pn = head
i = 1
while pn.next is not None and i < n:
pn = pn.next
i += 1
# print(i, pn)
# l... | {
"repo_name": "feigaochn/leetcode",
"path": "p19_remove_nth_node_from_end_of_list.py",
"copies": "2",
"size": "1569",
"license": "mit",
"hash": -8086785324951557000,
"line_mean": 21.7391304348,
"line_max": 85,
"alpha_frac": 0.4952198853,
"autogenerated": false,
"ratio": 3.345415778251599,
"conf... |
import itertools
class Solution:
# @param s, a string
# @return a list of strings
def restoreIpAddresses(self, s):
one = [str(i) for i in range(256)]
result = []
def rec(s, n, p):
s = str(s)
if n == 0:
if s == '':
result... | {
"repo_name": "feigaochn/leetcode",
"path": "p93_restore_ip_addresses.py",
"copies": "2",
"size": "1072",
"license": "mit",
"hash": 3889059946385272000,
"line_mean": 21.8085106383,
"line_max": 108,
"alpha_frac": 0.5018656716,
"autogenerated": false,
"ratio": 3.7482517482517483,
"config_test": f... |
class Solution:
# @return an integer
def reverse(self, x):
return int((('-' if x < 0 else '') + str(abs(x))[::-1]))
def main():
solver = Solution()
tests = [123, -123, 0, -1]
for test in tests:
print(test)
print(' ->')
result = solver.reverse(test)
print(r... | {
"repo_name": "feigaochn/leetcode",
"path": "p7_reverse_integer.py",
"copies": "2",
"size": "1155",
"license": "mit",
"hash": -5059812593241134000,
"line_mean": 25.8604651163,
"line_max": 66,
"alpha_frac": 0.6406926407,
"autogenerated": false,
"ratio": 3.489425981873112,
"config_test": false,
... |
class Solution:
# @return a boolean
def isScramble(self, s1, s2):
if len(s1) != len(s2):
return False
elif s1 == s2 or s1 == reversed(s2):
return True
elif sorted(list(s1)) != sorted(list(s2)):
return False
else:
answer = False
... | {
"repo_name": "feigaochn/leetcode",
"path": "p87_scramble_string.py",
"copies": "2",
"size": "2178",
"license": "mit",
"hash": 4717422299166091000,
"line_mean": 27.2857142857,
"line_max": 117,
"alpha_frac": 0.5013774105,
"autogenerated": false,
"ratio": 3.142857142857143,
"config_test": false,
... |
import bisect
class Solution:
# @param A, a list of integers
# @param target, an integer to be searched
# @return an integer
def search(self, A, target):
if A is None or len(A) == 0:
return -1
min_index = self.find_min(A)
if min_index == 0:
return self.... | {
"repo_name": "feigaochn/leetcode",
"path": "p33_search_in_rotated_sorted_array.py",
"copies": "2",
"size": "1874",
"license": "mit",
"hash": 4746877726875558000,
"line_mean": 24.6712328767,
"line_max": 76,
"alpha_frac": 0.507470651,
"autogenerated": false,
"ratio": 3.6107899807321773,
"config_... |
class Solution:
# @param path, a string
# @return a string
def simplifyPath(self, path):
if len(path) == 0:
return '/'
paths = path.split('/')
# print(paths)
p_list = []
for p in paths:
if len(p) == 0:
continue
eli... | {
"repo_name": "feigaochn/leetcode",
"path": "p71_simplify_path.py",
"copies": "2",
"size": "1274",
"license": "mit",
"hash": -8296765215345634000,
"line_mean": 24.48,
"line_max": 101,
"alpha_frac": 0.4897959184,
"autogenerated": false,
"ratio": 3.6714697406340058,
"config_test": false,
"has_n... |
class Solution:
# @param A, a list of integer
# @return an integer
def singleNumber(self, A):
assert isinstance(A, list)
neg = 0
bits = [0 for _ in range(64)]
for val in A:
if val < 0:
neg += 1
val = -val
idx = 0
... | {
"repo_name": "feigaochn/leetcode",
"path": "p137_single_number_ii.py",
"copies": "2",
"size": "1223",
"license": "mit",
"hash": 3012297528850783000,
"line_mean": 22.5192307692,
"line_max": 91,
"alpha_frac": 0.4766966476,
"autogenerated": false,
"ratio": 3.8702531645569622,
"config_test": false... |
class Solution:
# @return a list of lists of integer
def generateMatrix(self, n):
if n <= 0:
return []
grid = [[0 for i in range(n)] for _ in range(n)]
r, c = 0, 0
direction = [(0, 1), (1, 0), (0, -1), (-1, 0)]
d = 0
for i in range(1, n**2 + 1):
... | {
"repo_name": "feigaochn/leetcode",
"path": "p59_spiral_matrix_ii.py",
"copies": "2",
"size": "1035",
"license": "mit",
"hash": -8733579555776222000,
"line_mean": 22,
"line_max": 97,
"alpha_frac": 0.4637681159,
"autogenerated": false,
"ratio": 3.008720930232558,
"config_test": false,
"has_no_... |
import itertools
class Solution:
# @param num, a list of integer
# @return a list of lists of integer
def subsetsWithDup(self, S):
all_subsets = list()
for i in range(len(S) + 1):
for sub in itertools.combinations(S, i):
all_subsets.append(sorted(list(sub)))
... | {
"repo_name": "feigaochn/leetcode",
"path": "p90_subsets_ii.py",
"copies": "2",
"size": "1241",
"license": "mit",
"hash": 922366897894018300,
"line_mean": 20.7719298246,
"line_max": 95,
"alpha_frac": 0.5374697824,
"autogenerated": false,
"ratio": 3.24869109947644,
"config_test": false,
"has_n... |
class Solution:
# @return a tuple, (index1, index2)
def twoSum(self, num, target):
nums = sorted(list(num))
target = int(target)
s = 0
e = len(nums) - 1
while s < e:
su = nums[s] + nums[e]
if su == target:
si = num.index(nums[s])
... | {
"repo_name": "feigaochn/leetcode",
"path": "p1_two_sum.py",
"copies": "2",
"size": "1360",
"license": "mit",
"hash": 2522684187547311000,
"line_mean": 27.3333333333,
"line_max": 77,
"alpha_frac": 0.5360294118,
"autogenerated": false,
"ratio": 3.451776649746193,
"config_test": false,
"has_no_... |
class Solution:
# @return a string
def convert(self, s, nRows):
if nRows == 1:
return s
cycle = nRows * 2 - 2
rows = ['' for _ in range(nRows)]
for i, c in enumerate(s):
m = i % cycle
if m < nRows - 1:
rows[m] += c
... | {
"repo_name": "feigaochn/leetcode",
"path": "p6_zigzag_conversion.py",
"copies": "2",
"size": "1200",
"license": "mit",
"hash": -5240484727194533000,
"line_mean": 25.6666666667,
"line_max": 174,
"alpha_frac": 0.5533333333,
"autogenerated": false,
"ratio": 3.380281690140845,
"config_test": false... |
from pyspark import SparkContext
from pyspark.sql import SQLContext
import sys
import os
from subprocess import Popen
from dateutil import parser
sc = SparkContext()
sqlContext = SQLContext(sc)
def help():
print("Usage: spark-submit (...) log_parsing.py"+\
"\n\t --in <input-path>\n\t\t# Directory containing... | {
"repo_name": "igm-team/atav",
"path": "utils/log_analysis/log_parsing.py",
"copies": "1",
"size": "10101",
"license": "mit",
"hash": -2082880507204396800,
"line_mean": 28.1095100865,
"line_max": 152,
"alpha_frac": 0.6655776656,
"autogenerated": false,
"ratio": 3.1418351477449455,
"config_test"... |
__author__ = "Felix Simkovic"
__data__ = "29.06.2016"
__version__ = "1.0"
class TMalignLogParser(object):
"""
Class to mine information from a TMalign log
Attributes
----------
tm : float
TemplateModelling score
rmsd : float
RMSD score
nr_residues_common : int
Number ... | {
"repo_name": "linucks/ample",
"path": "ample/parsers/tm_parser.py",
"copies": "2",
"size": "4113",
"license": "bsd-3-clause",
"hash": 1167451942939894000,
"line_mean": 25.3653846154,
"line_max": 101,
"alpha_frac": 0.5071723803,
"autogenerated": false,
"ratio": 3.801293900184843,
"config_test":... |
__author__ = "Felix Simkovic"
import logging
import os
import subprocess
import shutil
from conkit.command_line.conkit_plot import main as plot_cmd
TMP_DIR = "_tmp"
DATA_DIR = os.path.join(TMP_DIR, "conkit-examples")
OUT_DIR = os.path.join("examples", "images")
PLOTS = [
[
"chord",
"--confidence... | {
"repo_name": "rigdenlab/conkit",
"path": "docs/figures.py",
"copies": "2",
"size": "4229",
"license": "bsd-3-clause",
"hash": -3392032925850297300,
"line_mean": 23.1657142857,
"line_max": 99,
"alpha_frac": 0.4736344289,
"autogenerated": false,
"ratio": 2.9739803094233475,
"config_test": false,... |
__author__ = 'Felix Simkovic'
import os
import pytest
from unittest import mock
from pyjob.pbs import PortableBatchSystemTask
@pytest.mark.skipif(pytest.on_windows, reason='Unavailable on Windows')
@mock.patch('pyjob.pbs.PortableBatchSystemTask._check_requirements')
class TestCreateRunscript(object):
def test_1... | {
"repo_name": "fsimkovic/pyjob",
"path": "pyjob/tests/test_pbs.py",
"copies": "1",
"size": "9475",
"license": "mit",
"hash": 2651411293088529000,
"line_mean": 38.152892562,
"line_max": 75,
"alpha_frac": 0.513878628,
"autogenerated": false,
"ratio": 3.447962154294032,
"config_test": true,
"has... |
__author__ = 'Felix Simkovic'
import os
import pytest
from unittest import mock
from pyjob.slurm import SlurmTask
@pytest.mark.skipif(pytest.on_windows, reason='Unavailable on Windows')
@mock.patch('pyjob.slurm.SlurmTask._check_requirements')
class TestCreateRunscript(object):
def test_1(self, check_requirement... | {
"repo_name": "fsimkovic/pyjob",
"path": "pyjob/tests/test_slurm.py",
"copies": "1",
"size": "7710",
"license": "mit",
"hash": -2914655514058245600,
"line_mean": 38.9481865285,
"line_max": 72,
"alpha_frac": 0.5346303502,
"autogenerated": false,
"ratio": 3.5141294439380126,
"config_test": true,
... |
__author__ = 'Felix Simkovic'
import os
import pytest
import sys
import time
from pyjob.exception import PyJobError, PyJobTaskLockedError
from pyjob.local import CPU_COUNT, LocalTask
@pytest.mark.skipif(pytest.on_windows, reason='Deadlock on Windows')
class TestLocalTaskTermination(object):
def test_terminate_1... | {
"repo_name": "fsimkovic/pyjob",
"path": "pyjob/tests/test_local.py",
"copies": "1",
"size": "5641",
"license": "mit",
"hash": 8019745518913354000,
"line_mean": 38.1736111111,
"line_max": 83,
"alpha_frac": 0.6216982804,
"autogenerated": false,
"ratio": 3.469249692496925,
"config_test": true,
... |
__author__ = 'Felix Simkovic'
import unittest
from conkit.misc.energyfunction import RosettaFunctionConstructs
TEMPLATE = dict(
atom1='CB',
res1_seq=1,
atom2='CB',
res2_seq=2,
lower_bound=0,
upper_bound=2,
scalar_score=0.1,
sigmoid_cutoff=0.2,
sigmoid_slope=0.3,
energy_bonus=-... | {
"repo_name": "fsimkovic/conkit",
"path": "conkit/misc/tests/test_energyfunction.py",
"copies": "1",
"size": "1694",
"license": "bsd-3-clause",
"hash": -5601743757635000000,
"line_mean": 32.88,
"line_max": 115,
"alpha_frac": 0.6481700118,
"autogenerated": false,
"ratio": 3.1197053406998156,
"co... |
"""
LaTeX2e document tree Writer.
"""
# Thanks to Engelbert Gruber and various contributors for the original
# LaTeX writer, some code and many ideas of which have been used for
# this writer.
__docformat__ = 'reStructuredText'
import re
import os.path
from types import ListType
import docutils
from docutils impo... | {
"repo_name": "google-code-export/django-hotclub",
"path": "libs/external_libs/docutils-0.4/docutils/writers/newlatex2e/__init__.py",
"copies": "6",
"size": "30010",
"license": "mit",
"hash": -9211036888748141000,
"line_mean": 37.0837563452,
"line_max": 97,
"alpha_frac": 0.5440186604,
"autogenerate... |
"""
LaTeX2e document tree Writer.
"""
# Thanks to Engelbert Gruber and various contributors for the original
# LaTeX writer, some code and many ideas of which have been used for
# this writer.
__docformat__ = 'reStructuredText'
import re
import os.path
from types import ListType
import docutils
f... | {
"repo_name": "mogotest/selenium",
"path": "selenium/src/py/lib/docutils/writers/newlatex2e/__init__.py",
"copies": "5",
"size": "30798",
"license": "apache-2.0",
"hash": 5839795256600669000,
"line_mean": 37.0837563452,
"line_max": 97,
"alpha_frac": 0.5300993571,
"autogenerated": false,
"ratio": ... |
__author__ = 'fellipeh'
from datetime import datetime
from cassandra.cluster import Cluster
###
# Generating Cassandra Docs
#
# NOTE: Steps:
# - Create a new keyspace, named demo:
# CREATE KEYSPACE demo WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
# - Create a new table named "clientes... | {
"repo_name": "rg3915/simbiose_sync",
"path": "create_docs_cas.py",
"copies": "1",
"size": "1569",
"license": "mit",
"hash": 3169454353950544000,
"line_mean": 25.15,
"line_max": 99,
"alpha_frac": 0.6513702996,
"autogenerated": false,
"ratio": 3.0057471264367814,
"config_test": false,
"has_no_... |
__author__ = 'fellipeh'
from datetime import datetime
from elasticsearch import Elasticsearch
from cassandra.cluster import Cluster
es = Elasticsearch()
ca_cluster = Cluster()
ca_session = ca_cluster.connect('demo')
# first get all from ElasticSearch
es.indices.refresh(index="cliente-index")
res_es = es.search(ind... | {
"repo_name": "rg3915/simbiose_sync",
"path": "daemon.py",
"copies": "1",
"size": "2058",
"license": "mit",
"hash": -626907919094236700,
"line_mean": 30.1818181818,
"line_max": 85,
"alpha_frac": 0.5155490768,
"autogenerated": false,
"ratio": 3.5916230366492146,
"config_test": false,
"has_no_k... |
__author__ = 'fengguanhua'
from app import redis_client
from json import JSONEncoder, JSONDecoder
def cache_access_token(token, expires_in):
redis_client.set('assess_token', token, expires_in)
def get_cache_access_token():
return redis_client.get('assess_token')
def cache_ticket(type, token, expires_in):... | {
"repo_name": "davidvon/pipa-pay-server",
"path": "admin/cache/weixin.py",
"copies": "1",
"size": "1580",
"license": "apache-2.0",
"hash": -5705846921793092000,
"line_mean": 24.0793650794,
"line_max": 64,
"alpha_frac": 0.6512658228,
"autogenerated": false,
"ratio": 3.0739299610894943,
"config_t... |
__author__ = 'feng'
import requests
import json
import time
import hashlib
import os
import base64
class Http((object)):
def __init__(self):
self.IMAGE_FILE_NOT_EXISTS = -1
self.IMAGE_NETWORK_ERROR = -2
self.IMAGE_PARAMS_ERROR = -3
self.PERSON_ID_EMPTY = -4
self.GROUP_ID_EMP... | {
"repo_name": "fffy2366/image-processing",
"path": "bin/python/utils/http.py",
"copies": "1",
"size": "3491",
"license": "mit",
"hash": 647446571037285600,
"line_mean": 30.7363636364,
"line_max": 188,
"alpha_frac": 0.5270696076,
"autogenerated": false,
"ratio": 3.305871212121212,
"config_test":... |
__author__ = 'feng'
# https://github.com/dowski/misc/blob/master/varints.py
def encode_varint(value):
"""Encodes a single Python integer to a VARINT."""
return "".join(encode_varint_stream([value]))
def decode_varint(value):
"""Decodes a single Python integer from a VARINT.
Note that `value` may be ... | {
"repo_name": "shenfeng/pedis",
"path": "exper/leveldb_test/ssltable_reader.py",
"copies": "1",
"size": "4018",
"license": "apache-2.0",
"hash": 8030338807513178000,
"line_mean": 26.5205479452,
"line_max": 83,
"alpha_frac": 0.6047784968,
"autogenerated": false,
"ratio": 3.493913043478261,
"conf... |
__author__ = 'Feng Wang'
from matplotlib import pyplot
"""
Draw the plot of number of images ~ month.
"""
#"198401":"75215","199001":"9",
num = {"199403": "1", "199405": "1", "199406": "8", "199407": "3", "199409": "1",
"199411": "1", "199503": "8", "199504": "2", "199505": "2", "199506": "3",
"19... | {
"repo_name": "wdwind/ImageTrends",
"path": "Python/PyClustering/Other/ImagesNumberPlot.py",
"copies": "1",
"size": "4694",
"license": "mit",
"hash": 6868903783908734000,
"line_mean": 68.0441176471,
"line_max": 105,
"alpha_frac": 0.513421389,
"autogenerated": false,
"ratio": 2.3997955010224947,
... |
__author__ = 'Feng Wang'
from os import walk, path
from numpy import vstack, array, genfromtxt, zeros
from scipy.cluster.vq import kmeans, kmeans2, vq, whiten
#from __future__ import print_function
#from timeit import Timer
def clustering():
"""
For testing.
@deprecated
"""
mypath = r"C:\Users\D... | {
"repo_name": "wdwind/ImageTrends",
"path": "Python/PyClustering/Old/PyClustering_old.py",
"copies": "1",
"size": "1918",
"license": "mit",
"hash": 3937692608500542000,
"line_mean": 26.4,
"line_max": 87,
"alpha_frac": 0.5286757039,
"autogenerated": false,
"ratio": 3.545286506469501,
"config_tes... |
__author__ = 'Fenix'
from math import sqrt
parsedic = {"x": 0,
"y": 1,
"id": 2,
"serverip": 3,
"serverport": 4}
parsetype = {"x": float,
"y": float,
"id": int,
"serverip": str,
"serverport": int}
def parse_mission_f... | {
"repo_name": "adrien-bellaiche/Interceptor",
"path": "Trespassor/JogCommand/Utils.py",
"copies": "2",
"size": "1773",
"license": "apache-2.0",
"hash": 7018460337811912000,
"line_mean": 23.985915493,
"line_max": 88,
"alpha_frac": 0.518894529,
"autogenerated": false,
"ratio": 3.283333333333333,
... |
__author__ = 'Fergal Walsh'
__version__ = '0.0.3'
import sys
import time
import uuid
import logging
import traceback
import cPickle as pickle
from importlib import import_module
from redis import Redis
import newrelic
class ExceptionFormatter(logging.Formatter):
def formatException(self, exc_info):
resul... | {
"repo_name": "hakanzy/fifo",
"path": "fifo/__init__.py",
"copies": "1",
"size": "5709",
"license": "bsd-2-clause",
"hash": 4854309451048736000,
"line_mean": 33.6,
"line_max": 79,
"alpha_frac": 0.5524610264,
"autogenerated": false,
"ratio": 3.983949755757153,
"config_test": false,
"has_no_key... |
__author__ = 'Fergal Walsh'
__version__ = '0.0.3'
import time
import uuid
import logging
import traceback
try:
import cPickle as pickle
except:
import pickle
from importlib import import_module
from redis import Redis
class ExceptionFormatter(logging.Formatter):
def formatException(self, exc_info):
... | {
"repo_name": "fergalwalsh/fifo",
"path": "fifo/__init__.py",
"copies": "1",
"size": "5359",
"license": "bsd-2-clause",
"hash": -698974225489259300,
"line_mean": 33.1337579618,
"line_max": 79,
"alpha_frac": 0.5495428252,
"autogenerated": false,
"ratio": 3.9696296296296296,
"config_test": false,... |
__author__ = 'ferhat elmas'
__version__ = '0.0.4'
from random import choice, randint
class Haikunator:
adjectives = """
autumn hidden bitter misty silent empty dry dark summer
icy delicate quiet white cool spring winter patient
twilight dawn crimson wispy weathered blue billowing
... | {
"repo_name": "ferhatelmas/pyhaikunator",
"path": "haikunator.py",
"copies": "1",
"size": "2944",
"license": "mit",
"hash": 5333164151071476000,
"line_mean": 34.9024390244,
"line_max": 79,
"alpha_frac": 0.6273777174,
"autogenerated": false,
"ratio": 3.5342136854741897,
"config_test": true,
"h... |
__author__ = 'ferhat elmas'
__version__ = '0.0.5'
class FoundException(Exception):
pass
def fuzzysearch(needle, haystack):
hlen, nlen = len(haystack), len(needle)
if nlen > hlen:
return False
if nlen == hlen:
return needle == haystack
j = -1
for nch in needle:
try:
... | {
"repo_name": "ferhatelmas/simple-fuzzysearch",
"path": "fuzzysearch.py",
"copies": "1",
"size": "1273",
"license": "mit",
"hash": -9072335119818813000,
"line_mean": 27.9318181818,
"line_max": 53,
"alpha_frac": 0.5954438335,
"autogenerated": false,
"ratio": 3.6580459770114944,
"config_test": fa... |
__author__ = "Fernando Crema"
__copyright__ = "Copyright 2019, The Sabermetrics Python Package Project."
__credits__ = ["Fernando Crema @FernandoCremaG", "Antonio Jesús Torres @ajtorresd"]
__license__ = "GPL"
__version__ = "1.0"
__maintainer__ = "Fernando Crema"
__email__ = "fernando.crema@sabermetrics.dev"
__status__ ... | {
"repo_name": "belgrades/sabermetrics",
"path": "examples/monte_carlo.py",
"copies": "1",
"size": "2815",
"license": "apache-2.0",
"hash": 8913743693634654000,
"line_mean": 30.6179775281,
"line_max": 119,
"alpha_frac": 0.5636105188,
"autogenerated": false,
"ratio": 2.825301204819277,
"config_te... |
# AUTHOR: Fernando Gonzalez
# DESCRIPTION: Script para la subida de archivos o directorios por ssh
# a un server remoto.
#
# -COPIA EL DIRECTORIO
#
# PRE: Para usar este Script hay que instalar sshpass en el sistema
# Windows: No se buscaos la vida
# Linux: sudo apt-get install sshpass
# Mac: sudo port inst... | {
"repo_name": "nakernk/thunderbolt",
"path": "utils/copyproject.py",
"copies": "1",
"size": "1741",
"license": "apache-2.0",
"hash": -5883945431096646000,
"line_mean": 31.2407407407,
"line_max": 131,
"alpha_frac": 0.6507754164,
"autogenerated": false,
"ratio": 2.7990353697749195,
"config_test":... |
# AUTHOR: Fernando Gonzalez
# DESCRIPTION: Script para la subida de archivos o directorios por ssh
# a un server remoto.
#
# -Solo sube los archivos con cambios detectados
#
# PRE: Para usar este Script hay que instalar sshpass en el sistema
# Windows: No se buscaos la vida
# Linux: sudo apt-get install sshp... | {
"repo_name": "nakernk/thunderbolt",
"path": "utils/upproject.py",
"copies": "1",
"size": "1881",
"license": "apache-2.0",
"hash": -2448781637454224000,
"line_mean": 34.4905660377,
"line_max": 179,
"alpha_frac": 0.663476874,
"autogenerated": false,
"ratio": 2.815868263473054,
"config_test": fal... |
__author__ = 'Fero'
# ---------------------------------------------------------------
# Constants
# ---------------------------------------------------------------
MAX_LENGTH_FOR_QUADRATIC = 10000
# ---------------------------------------------------------------
# Interface
# ----------------------------------------... | {
"repo_name": "silverfield/pythonsessions",
"path": "s01_selection_sort/solutions/sol_selection_sort.py",
"copies": "1",
"size": "2779",
"license": "mit",
"hash": -1386271951013067500,
"line_mean": 28.8924731183,
"line_max": 119,
"alpha_frac": 0.5145735876,
"autogenerated": false,
"ratio": 4.1539... |
__author__ = 'ferrard'
import numpy as np
import math
# ---------------------------------------------------------------
# Interface
# ---------------------------------------------------------------
def get_2x2_eigen(m):
b = - m[0, 0] - m[1, 1]
c = m[0, 0]*m[1, 1] - m[0, 1]*m[1, 0]
eig1 = (-b + math.sqr... | {
"repo_name": "silverfield/pythonsessions",
"path": "s04_multiply_matrices/exercises/eigen_values.py",
"copies": "1",
"size": "1131",
"license": "mit",
"hash": 1524614473497795600,
"line_mean": 24.1555555556,
"line_max": 65,
"alpha_frac": 0.4288240495,
"autogenerated": false,
"ratio": 3.316715542... |
__author__ = 'ferrard'
import scipy as sp
import scipy.linalg as la
# ---------------------------------------------------------------
# Main
# ---------------------------------------------------------------
def main():
# define matrices
m_a = sp.matrix(
'1 5 8;'
'0 -1 4'
)
print(type... | {
"repo_name": "silverfield/pythonsessions",
"path": "s04_multiply_matrices/solutions/matrix_ops.py",
"copies": "1",
"size": "1983",
"license": "mit",
"hash": -7028056983314350000,
"line_mean": 21.5454545455,
"line_max": 93,
"alpha_frac": 0.4357034796,
"autogenerated": false,
"ratio": 2.6833558863... |
n = 100
# --------------------------------------------------
# region
# linear - O(n)
# endregion
total = 0
for i in range(n):
total += 1
print(total)
# --------------------------------------------------
# region
# quadratic O(n^2)
# endregion
for i in range(n):
for j in range(n):
print(str(i) + " ... | {
"repo_name": "silverfield/pythonsessions",
"path": "s10_complexity/complexity_basic.py",
"copies": "1",
"size": "2326",
"license": "mit",
"hash": -8358204848789492000,
"line_mean": 18.0737704918,
"line_max": 84,
"alpha_frac": 0.4449699054,
"autogenerated": false,
"ratio": 3.4820359281437128,
"... |
__author__ = 'ferrard'
# ---------------------------------------------------------------
# Class - Board
# ---------------------------------------------------------------
class Board:
# ---------------------------------------------------------------
# Initialisation
# ------------------------------------... | {
"repo_name": "silverfield/pythonsessions",
"path": "s06_classes_intro/solutions/board.py",
"copies": "1",
"size": "1812",
"license": "mit",
"hash": 3637018001649840600,
"line_mean": 26.8769230769,
"line_max": 94,
"alpha_frac": 0.309602649,
"autogenerated": false,
"ratio": 4.204176334106728,
"c... |
__author__ = 'ferrard'
# ---------------------------------------------------------------
# Class - Calculator
# ---------------------------------------------------------------
class Calculator:
"""Simple calculator that remembers what it was doing"""
# --------------------------------------------------------... | {
"repo_name": "silverfield/pythonsessions",
"path": "s06_classes_intro/exercises/calculator.py",
"copies": "1",
"size": "2354",
"license": "mit",
"hash": -682419418380749300,
"line_mean": 28.8101265823,
"line_max": 80,
"alpha_frac": 0.41971113,
"autogenerated": false,
"ratio": 4.256781193490054,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.