text stringlengths 0 1.05M | meta dict |
|---|---|
# A small SOCP formulation of minimizing the p-norm of a vector subject to
# constraints (in this trivial case, maximize the two-norm subject to the
# entire vector being fixed). This example originally caused the ninth SOCP
# IPM KKT system to be excessively ill-conditioned and was reported by
# Steven Diamond via C... | {
"repo_name": "justusc/Elemental",
"path": "examples/interface/PNorm.py",
"copies": "1",
"size": "2536",
"license": "bsd-3-clause",
"hash": 3366034296351202000,
"line_mean": 23.862745098,
"line_max": 75,
"alpha_frac": 0.6612776025,
"autogenerated": false,
"ratio": 2.2245614035087717,
"config_te... |
# A small, stupid benchmark for friendlydb.
#
# v2.0.0
# ------
# Generating 10000 took 0.11811709404
# Building 1000000 relations took 178.619861126
# Checking 1000 users followers took 1.66441106796
# mean: 0.00166352272034
# min: 0.00112891197205
# max: 0.00374412536621
#
# v0.3.1
# ------
#
# Generating 10000... | {
"repo_name": "toastdriven/friendlydb",
"path": "benchmark.py",
"copies": "1",
"size": "3150",
"license": "bsd-3-clause",
"hash": -4462421401826307000,
"line_mean": 23.609375,
"line_max": 93,
"alpha_frac": 0.6406349206,
"autogenerated": false,
"ratio": 3.237410071942446,
"config_test": false,
... |
"""A small tweeter bot."""
from twitter import Twitter, OAuth
from random import choice
from config import consumer_key, consumer_secret, \
access_token, access_token_secret
adjective = "adjective.txt"
animal = "animal.txt"
friend = "friend.txt"
def adjectiveanimalfriend():
with open(adjective) as adjectiv... | {
"repo_name": "fennekki/adjectiveanimalfriend",
"path": "main.py",
"copies": "1",
"size": "1029",
"license": "unlicense",
"hash": -7042552571555963000,
"line_mean": 30.1818181818,
"line_max": 75,
"alpha_frac": 0.5850340136,
"autogenerated": false,
"ratio": 4.051181102362205,
"config_test": fals... |
"""A small wrapper to grab the data from the pubg website
more functions and features will be added as pubg adds more API calls"""
import json
import requests
import constants
class APIException(Exception):
"""Generic exception class for raising errors"""
pass
class PUBGAPI:
"""Object that ... | {
"repo_name": "lbrictson/pypubg",
"path": "pypubg/core.py",
"copies": "1",
"size": "5759",
"license": "mit",
"hash": 79198762550422000,
"line_mean": 39.4316546763,
"line_max": 131,
"alpha_frac": 0.5750998437,
"autogenerated": false,
"ratio": 4.262768319763138,
"config_test": false,
"has_no_ke... |
"""A smart choices interface for Django apps."""
__all__ = ['Choice', 'Choices']
def _smart_namify(name):
"""Translate the name into a more user friendly name."""
name = name.replace('_', ' ').title()
return name
class Choice(object):
"""A representation of a single choice."""
order = 0
de... | {
"repo_name": "storybird/smartchoices",
"path": "smartchoices.py",
"copies": "1",
"size": "2441",
"license": "mit",
"hash": -7826773288257334000,
"line_mean": 30.2948717949,
"line_max": 87,
"alpha_frac": 0.5497746825,
"autogenerated": false,
"ratio": 4.208620689655173,
"config_test": false,
"... |
"""A SmartInspect Python Library.
Port of SmartInspect.pas (from SmartInspect Professional v2.3.3.7025)
NOTE: Many things in here have not yet been tested at all. This code is alpha
quality in a very real sense. You have been warned.
Not all the features have been implemented yet. In particular, the file-base... | {
"repo_name": "miracle2k/python-smartinspect",
"path": "smartinspect/smartinspect.py",
"copies": "2",
"size": "54644",
"license": "bsd-2-clause",
"hash": -8688558772469361000,
"line_mean": 32.8285532186,
"line_max": 95,
"alpha_frac": 0.5603725935,
"autogenerated": false,
"ratio": 4.39932372594799... |
# A smart string is one with characters in strictly increasing or decreasing order.
# Given a string M, we need to determine the minimum number of contiguous substrings in which M can be broken so that each substring is smart.
# Examples: Input: abcdcba
# Output: 2
# partitioned into abc and dcba
# Input: ffdhbbbde... | {
"repo_name": "saisankargochhayat/algo_quest",
"path": "Company-Based/google/smart_strings.py",
"copies": "1",
"size": "1097",
"license": "apache-2.0",
"hash": -7891037780157796000,
"line_mean": 27.1538461538,
"line_max": 142,
"alpha_frac": 0.5843208751,
"autogenerated": false,
"ratio": 3.6085526... |
# ASN.1 "character string" types
from pyasn1.type import univ, tag
class NumericString(univ.OctetString):
tagSet = univ.OctetString.tagSet.tagImplicitly(
tag.Tag(tag.tagClassUniversal, tag.tagFormatSimple, 18)
)
class PrintableString(univ.OctetString):
tagSet = univ.OctetString.tagSet.tagImpli... | {
"repo_name": "mith1979/ansible_automation",
"path": "applied_python/applied_python/lib/python2.7/site-packages/pyasn1/type/char.py",
"copies": "172",
"size": "2043",
"license": "apache-2.0",
"hash": 2133283242103077600,
"line_mean": 30.921875,
"line_max": 63,
"alpha_frac": 0.7151248164,
"autogener... |
# ASN.1 "character string" types
from pyasn1.type import univ, tag
class UTF8String(univ.OctetString):
tagSet = univ.OctetString.tagSet.tagImplicitly(
tag.Tag(tag.tagClassUniversal, tag.tagFormatSimple, 12)
)
encoding = "utf-8"
class NumericString(univ.OctetString):
tagSet = univ.OctetStri... | {
"repo_name": "zlsun/XX-Net",
"path": "code/default/python27/1.0/lib/noarch/pyasn1/type/char.py",
"copies": "10",
"size": "1965",
"license": "bsd-2-clause",
"hash": -6364153715361140000,
"line_mean": 31.2131147541,
"line_max": 63,
"alpha_frac": 0.71043257,
"autogenerated": false,
"ratio": 3.46560... |
# ASN.1 "character string" types
from pyasn1.type import univ, tag
class UTF8String(univ.OctetString):
tagSet = univ.OctetString.tagSet.tagImplicitly(
tag.Tag(tag.tagClassUniversal, tag.tagFormatSimple, 12)
)
encoding = "utf-8"
class NumericString(univ.OctetString):
tagSet = univ.OctetString... | {
"repo_name": "itielshwartz/BackendApi",
"path": "lib/pyasn1/type/char.py",
"copies": "1",
"size": "1931",
"license": "apache-2.0",
"hash": 1552037105156359200,
"line_mean": 26.1971830986,
"line_max": 63,
"alpha_frac": 0.7229414811,
"autogenerated": false,
"ratio": 3.4056437389770724,
"config_t... |
"""ASN.1 constraints checker.
"""
import string
from copy import copy
from . import ConstraintsError
from . import add_error_location
from . import compiler
from . import format_or
from .permitted_alphabet import NUMERIC_STRING
from .permitted_alphabet import PRINTABLE_STRING
from .permitted_alphabet import IA5_STRI... | {
"repo_name": "eerimoq/asn1tools",
"path": "asn1tools/codecs/constraints_checker.py",
"copies": "1",
"size": "13905",
"license": "mit",
"hash": -6163410316042081000,
"line_mean": 29.1626898048,
"line_max": 84,
"alpha_frac": 0.5171521036,
"autogenerated": false,
"ratio": 4.519012024699382,
"conf... |
'''ASN.1 definitions.
Not all ASN.1-handling code use these definitions, but when it does, they should be here.
'''
from pyasn1.type import univ, namedtype, tag
class PubKeyHeader(univ.Sequence):
componentType = namedtype.NamedTypes(
namedtype.NamedType('oid', univ.ObjectIdentifier()),
namedtype... | {
"repo_name": "itielshwartz/BackendApi",
"path": "lib/rsa/asn1.py",
"copies": "1",
"size": "1111",
"license": "apache-2.0",
"hash": 6756827686237756000,
"line_mean": 29.027027027,
"line_max": 91,
"alpha_frac": 0.6597659766,
"autogenerated": false,
"ratio": 4.084558823529412,
"config_test": fals... |
"""ASN1 encoding helpers for converting between PKCS1 and PKCS8.
Required by rsa_backend but not cryptography_backend.
"""
from pyasn1.codec.der import decoder, encoder
from pyasn1.type import namedtype, univ
RSA_ENCRYPTION_ASN1_OID = "1.2.840.113549.1.1.1"
class RsaAlgorithmIdentifier(univ.Sequence):
"""ASN1 s... | {
"repo_name": "mpdavis/python-jose",
"path": "jose/backends/_asn1.py",
"copies": "1",
"size": "2655",
"license": "mit",
"hash": -5183161161527873000,
"line_mean": 30.9879518072,
"line_max": 118,
"alpha_frac": 0.7122410546,
"autogenerated": false,
"ratio": 3.73943661971831,
"config_test": false,... |
# ASN.1 named integers
from pyasn1 import error
__all__ = [ 'NamedValues' ]
class NamedValues:
def __init__(self, *namedValues):
self.nameToValIdx = {}; self.valToNameIdx = {}
self.namedValues = ()
automaticVal = 1
for namedValue in namedValues:
if isinstance(namedValue... | {
"repo_name": "qqzwc/XX-Net",
"path": "code/default/python27/1.0/lib/noarch/pyasn1/type/namedval.py",
"copies": "8",
"size": "1581",
"license": "bsd-2-clause",
"hash": -3622864098095066600,
"line_mean": 33.3695652174,
"line_max": 78,
"alpha_frac": 0.586970272,
"autogenerated": false,
"ratio": 3.8... |
# ASN.1 named integers
from pyasn1 import error
__all__ = ['NamedValues']
class NamedValues:
def __init__(self, *namedValues):
self.nameToValIdx = {};
self.valToNameIdx = {}
self.namedValues = ()
automaticVal = 1
for namedValue in namedValues:
if isinstance(nam... | {
"repo_name": "itielshwartz/BackendApi",
"path": "lib/pyasn1/type/namedval.py",
"copies": "1",
"size": "1615",
"license": "apache-2.0",
"hash": 1281108558821286000,
"line_mean": 28.9074074074,
"line_max": 78,
"alpha_frac": 0.5746130031,
"autogenerated": false,
"ratio": 3.929440389294404,
"confi... |
"""ASN.1 object identifiers. This module contains a dictionary of known OIDs.
See http://luca.ntop.org/Teaching/Appunti/asn1.html for a good introduction
to ASN.1.
"""
from ct.crypto import error
from ct.crypto.asn1 import tag
from ct.crypto.asn1 import types
@types.Universal(6, tag.PRIMITIVE)
class ObjectIdentifie... | {
"repo_name": "kyprizel/certificate-transparency",
"path": "python/ct/crypto/asn1/oid.py",
"copies": "34",
"size": "15864",
"license": "apache-2.0",
"hash": -2977350829034045000,
"line_mean": 44.9826086957,
"line_max": 93,
"alpha_frac": 0.6265758951,
"autogenerated": false,
"ratio": 3.04257767548... |
"""ASN.1 specification for X509 extensions."""
from ct.crypto.asn1 import named_value
from ct.crypto.asn1 import oid
from ct.crypto.asn1 import tag
from ct.crypto.asn1 import types
from ct.crypto.asn1 import x509_common
from ct.crypto.asn1 import x509_name
# Standard extensions from RFC 5280.
class BasicConstraints(... | {
"repo_name": "rep/certificate-transparency",
"path": "python/ct/crypto/asn1/x509_extension.py",
"copies": "1",
"size": "7387",
"license": "apache-2.0",
"hash": -9024353478338749000,
"line_mean": 29.1510204082,
"line_max": 80,
"alpha_frac": 0.7071883038,
"autogenerated": false,
"ratio": 3.5772397... |
"""ASN.1 specification for X509 name types."""
from ct.crypto import error
from ct.crypto.asn1 import oid
from ct.crypto.asn1 import types
class AttributeType(oid.ObjectIdentifier):
pass
class AttributeValue(types.Any):
pass
class DirectoryString(types.Choice):
components = {
"teletexString":... | {
"repo_name": "nhr/origin",
"path": "vendor/github.com/google/certificate-transparency/python/ct/crypto/asn1/x509_name.py",
"copies": "35",
"size": "7180",
"license": "apache-2.0",
"hash": 6338756929624510000,
"line_mean": 34.1960784314,
"line_max": 80,
"alpha_frac": 0.6544568245,
"autogenerated": ... |
"""ASN.1 tagging."""
from ct.crypto import error
UNIVERSAL = 0x00
APPLICATION = 0x40
CONTEXT_SPECIFIC = 0x80
PRIVATE = 0xc0
PRIMITIVE = 0x00
CONSTRUCTED = 0x20
# Constants for better readability.
IMPLICIT, EXPLICIT = range(2)
class Tag(object):
"""An ASN.1 tag."""
_CLASS_MASK = 0xc0
_ENCODING_MASK = 0... | {
"repo_name": "RJPercival/certificate-transparency",
"path": "python/ct/crypto/asn1/tag.py",
"copies": "35",
"size": "4183",
"license": "apache-2.0",
"hash": 6140881235332341000,
"line_mean": 30.2164179104,
"line_max": 80,
"alpha_frac": 0.5395649056,
"autogenerated": false,
"ratio": 3.95742667928... |
"""ASN.1 types.
Spec: http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf
See also http://luca.ntop.org/Teaching/Appunti/asn1.html for a good introduction
to ASN.1.
This module implements a restricted encoder/decoder for a subset of ASN.1 types.
The decoder has a strict and non-strict mode. Non-stric... | {
"repo_name": "elyscape/origin",
"path": "vendor/github.com/google/certificate-transparency/python/ct/crypto/asn1/types.py",
"copies": "34",
"size": "56328",
"license": "apache-2.0",
"hash": -8156575416197773000,
"line_mean": 33.4513761468,
"line_max": 80,
"alpha_frac": 0.5748828291,
"autogenerated... |
# ASN.1 types tags
from operator import getitem
from pyasn1 import error
tagClassUniversal = 0x00
tagClassApplication = 0x40
tagClassContext = 0x80
tagClassPrivate = 0xC0
tagFormatSimple = 0x00
tagFormatConstructed = 0x20
tagCategoryImplicit = 0x01
tagCategoryExplicit = 0x02
tagCategoryUntagged = 0x04
class Tag:
... | {
"repo_name": "qqzwc/XX-Net",
"path": "code/default/python27/1.0/lib/noarch/pyasn1/type/tag.py",
"copies": "8",
"size": "4295",
"license": "bsd-2-clause",
"hash": -5603237265099525000,
"line_mean": 34.2049180328,
"line_max": 76,
"alpha_frac": 0.5694994179,
"autogenerated": false,
"ratio": 3.76094... |
# ASN.1 types tags
from operator import getitem
from pyasn1 import error
tagClassUniversal = 0x00
tagClassApplication = 0x40
tagClassContext = 0x80
tagClassPrivate = 0xC0
tagFormatSimple = 0x00
tagFormatConstructed = 0x20
tagCategoryImplicit = 0x01
tagCategoryExplicit = 0x02
tagCategoryUntagged = 0x04
class Tag:... | {
"repo_name": "itielshwartz/BackendApi",
"path": "lib/pyasn1/type/tag.py",
"copies": "1",
"size": "4375",
"license": "apache-2.0",
"hash": -8513442430148157000,
"line_mean": 26.6898734177,
"line_max": 77,
"alpha_frac": 0.5590857143,
"autogenerated": false,
"ratio": 3.7748058671268336,
"config_t... |
# ASN.1 "universal" data types
import operator
import sys
from pyasn1.type import base, tag, constraint, namedtype, namedval, tagmap
from pyasn1.codec.ber import eoo
from pyasn1.compat import octets
from pyasn1 import error
# "Simple" ASN.1 types (yet incomplete)
class Integer(base.AbstractSimpleAsn1Item):
tagS... | {
"repo_name": "itielshwartz/BackendApi",
"path": "lib/pyasn1/type/univ.py",
"copies": "1",
"size": "40225",
"license": "apache-2.0",
"hash": 4607418034862288400,
"line_mean": 31.4919224556,
"line_max": 117,
"alpha_frac": 0.5433685519,
"autogenerated": false,
"ratio": 4.220438568880495,
"config_... |
# ASN.1 "universal" data types
import operator, sys, math
from pyasn1.type import base, tag, constraint, namedtype, namedval, tagmap
from pyasn1.codec.ber import eoo
from pyasn1.compat import octets
from pyasn1 import error
# "Simple" ASN.1 types (yet incomplete)
class Integer(base.AbstractSimpleAsn1Item):
tagSet... | {
"repo_name": "coruus/pyasn1",
"path": "pyasn1/type/univ.py",
"copies": "1",
"size": "44262",
"license": "bsd-2-clause",
"hash": -8172155834446786000,
"line_mean": 37.7922874671,
"line_max": 105,
"alpha_frac": 0.5488906963,
"autogenerated": false,
"ratio": 4.174478921060078,
"config_test": fals... |
# ASN.1 "universal" data types
import operator, sys
from pyasn1.type import base, tag, constraint, namedtype, namedval, tagmap
from pyasn1.codec.ber import eoo
from pyasn1.compat import octets
from pyasn1 import error
# "Simple" ASN.1 types (yet incomplete)
class Integer(base.AbstractSimpleAsn1Item):
tagSet = bas... | {
"repo_name": "viger/docker",
"path": "proxy/proxy/code/default/python27/1.0/lib/noarch/pyasn1/type/univ.py",
"copies": "8",
"size": "39459",
"license": "mit",
"hash": -2490643430241797000,
"line_mean": 36.8685220729,
"line_max": 117,
"alpha_frac": 0.5537646671,
"autogenerated": false,
"ratio": 4... |
"""ASN.1 UTCTime and GeneralizedTime, as understood by RFC 5280."""
import abc
import time
from ct.crypto import error
from ct.crypto.asn1 import tag
from ct.crypto.asn1 import types
class BaseTime(types.ASN1String):
"""Base class for time types."""
def __init__(self, value=None, serialized_value=None, stric... | {
"repo_name": "kyprizel/certificate-transparency",
"path": "python/ct/crypto/asn1/x509_time.py",
"copies": "6",
"size": "5505",
"license": "apache-2.0",
"hash": 7206818316295418000,
"line_mean": 32.3636363636,
"line_max": 79,
"alpha_frac": 0.5714804723,
"autogenerated": false,
"ratio": 3.85504201... |
"""ASN.1 X509 specification."""
from ct.crypto.asn1 import types
from ct.crypto.asn1 import x509_common
from ct.crypto.asn1 import x509_extension
from ct.crypto.asn1 import x509_name
from ct.crypto.asn1 import x509_time
class TBSCertificate(types.Sequence):
components = (
(types.Component("version", x509... | {
"repo_name": "AlCutter/certificate-transparency",
"path": "python/ct/crypto/asn1/x509.py",
"copies": "35",
"size": "1520",
"license": "apache-2.0",
"hash": 6837186720075873000,
"line_mean": 40.0810810811,
"line_max": 81,
"alpha_frac": 0.6269736842,
"autogenerated": false,
"ratio": 4.257703081232... |
#A snapshot of a conversation segment
class Snapshot:
def __init__(self):
self.dialog = []
self.uses = 0 #For pruning
def append(self,s):
self.dialog.append(s)
def getFinale(self):
self.uses += 1
return self.dialog[-1]
def getScore(self... | {
"repo_name": "henfredemars/python-personal-projects",
"path": "ChatBot/Snapshot.py",
"copies": "1",
"size": "1123",
"license": "mit",
"hash": -1501657738977634000,
"line_mean": 21.8936170213,
"line_max": 45,
"alpha_frac": 0.4452359751,
"autogenerated": false,
"ratio": 3.509375,
"config_test": ... |
# as noted in the individual source code files.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agr... | {
"repo_name": "enderlabs/gavl",
"path": "gavl/engine.py",
"copies": "1",
"size": "12900",
"license": "apache-2.0",
"hash": -291037946808374700,
"line_mean": 27.9237668161,
"line_max": 83,
"alpha_frac": 0.5905426357,
"autogenerated": false,
"ratio": 3.8313038313038312,
"config_test": false,
"h... |
# as_nrf_test.py Test script for as_nrf_stream
# (C) Peter Hinch 2020
# Released under the MIT licence
import uasyncio as asyncio
import ujson
import time
from as_nrf_stream import Master, Slave
from asconfig import config_master, config_slave # Hardware configuration
try:
from pyb import LED
except ImportError... | {
"repo_name": "peterhinch/micropython-radio",
"path": "async/as_nrf_test.py",
"copies": "1",
"size": "3926",
"license": "mit",
"hash": -5562622274729315000,
"line_mean": 31.9915966387,
"line_max": 96,
"alpha_frac": 0.5748853795,
"autogenerated": false,
"ratio": 3.6725912067352664,
"config_test"... |
"""A socket for sending and receiving s-expressions"""
from socket import *
_socket =socket
from pisces import spkilib
def socket(domain, type, proto=None):
if proto is None:
sock = _socket(domain, type)
else:
sock = _socket(domain, type, proto)
return SexpSocket(sock)
class SexpSocket:... | {
"repo_name": "danieljohnlewis/pisces",
"path": "pisces/spkilib/sexpsocket.py",
"copies": "1",
"size": "2794",
"license": "mit",
"hash": -4869357104469675000,
"line_mean": 28.1041666667,
"line_max": 69,
"alpha_frac": 0.6202576951,
"autogenerated": false,
"ratio": 3.7203728362183757,
"config_tes... |
"""A Socket subclass that adds some serialization methods."""
import zlib
import pickle
import numpy
import zmq
class SerializingSocket(zmq.Socket):
"""A class with some extra serialization methods
send_zipped_pickle is just like send_pyobj, but uses
zlib to compress the stream before sending.
... | {
"repo_name": "Mustard-Systems-Ltd/pyzmq",
"path": "examples/serialization/serialsocket.py",
"copies": "6",
"size": "2319",
"license": "bsd-3-clause",
"hash": -4013049703060465700,
"line_mean": 30.3378378378,
"line_max": 65,
"alpha_frac": 0.6188012074,
"autogenerated": false,
"ratio": 3.545871559... |
# a socks5 proxy with rule-based forwarding
import logging
import sys
import os
import re
from urlparse import urlparse
from sys import platform as _platform
if _platform == "linux" or _platform == "linux2":
os.environ['GEVENT_RESOLVER'] = "ares"
from smart_relay import SmartRelayFactory, RESocksMatcher, ForwardDe... | {
"repo_name": "Jonavin/firefly-proxy",
"path": "gsocks/smartproxy.py",
"copies": "6",
"size": "1251",
"license": "bsd-2-clause",
"hash": -3410202184097716000,
"line_mean": 26.2173913043,
"line_max": 88,
"alpha_frac": 0.6059152678,
"autogenerated": false,
"ratio": 3.3449197860962565,
"config_tes... |
# a socks proxy forwarding to a remote socks through meek (i.e., HTTP transport)
import logging
import os
import sys
from sys import platform as _platform
if _platform == "linux" or _platform == "linux2":
os.environ['GEVENT_RESOLVER'] = "ares"
from server import SocksServer
from relay import MeekRelayFactory, Rela... | {
"repo_name": "yinghuocho/meeksocks-py",
"path": "client.py",
"copies": "6",
"size": "1354",
"license": "bsd-2-clause",
"hash": -2168233039744343800,
"line_mean": 27.2083333333,
"line_max": 84,
"alpha_frac": 0.6196454948,
"autogenerated": false,
"ratio": 3.359801488833747,
"config_test": false,... |
#As of 09-14-2016, twitch API now requires Client-ID with all requests. You will need to create one from here:
# https://www.twitch.tv/settings/connections
# complete twitch.py rewrite coming soon™
import requests
import sopel
import re
from sopel.tools import SopelMemory
import datetime
# TODO: Make these config op... | {
"repo_name": "ridelore/sopel-modules",
"path": "twitch.py",
"copies": "2",
"size": "11859",
"license": "apache-2.0",
"hash": -4951539943785539000,
"line_mean": 40.3135888502,
"line_max": 179,
"alpha_frac": 0.5800792781,
"autogenerated": false,
"ratio": 3.6404666871354006,
"config_test": false,... |
# A solution to the British Informatics Olympiad 2011 Question 2
# Scores 24/24
from __future__ import print_function
while True:
try:
input = raw_input
except:
pass
from collections import deque
suits = ['C', 'H', 'S', 'D']
values = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '... | {
"repo_name": "matthewelse/british-informatics-olympiad",
"path": "2011/q2-accordionpatience.py",
"copies": "1",
"size": "4646",
"license": "mit",
"hash": -418890924998253630,
"line_mean": 23.0725388601,
"line_max": 78,
"alpha_frac": 0.4246663797,
"autogenerated": false,
"ratio": 3.59597523219814... |
# A solution to the British Informatics Olympiad 2011 Question 3
# Scores 24/24
from __future__ import print_function
try:
input = raw_input
except:
pass
def number_with_n_digits(n):
return 9**(n//2)
def nth_with_n_digits(number_of_digits, n):
if number_of_digits == 0:
return ""
if number_of_digits % 2 == 1:
... | {
"repo_name": "matthewelse/british-informatics-olympiad",
"path": "2011/q3-upsidedown.py",
"copies": "1",
"size": "1050",
"license": "mit",
"hash": -6917340826105736000,
"line_mean": 22.3333333333,
"line_max": 101,
"alpha_frac": 0.6514285714,
"autogenerated": false,
"ratio": 2.5609756097560976,
... |
# A solution to the British Informatics Olympiad 2012 Question 2
# Scores 19/23 Marks
class Station(object):
def __init__(self, name, up, left, right, lazy=True):
self.name = name
self.up = up
self.left = left
self.right = right
assert isinstance(lazy, bool), "Lazy must be ... | {
"repo_name": "matthewelse/british-informatics-olympiad",
"path": "2012/q2-ontherighttrack.py",
"copies": "1",
"size": "2674",
"license": "mit",
"hash": 8159926709352365000,
"line_mean": 27.1473684211,
"line_max": 64,
"alpha_frac": 0.4569932685,
"autogenerated": false,
"ratio": 2.9910514541387023... |
# A solution to the problem.txt in Python with test cases :)
# To try this on your own simply delete the contents of string_compression and fill it in yourself
# Enter any assumptions you're making about about the problem or any notes you want taken into account here
# - Currently this method assumes that you will get... | {
"repo_name": "riggspc/exercises",
"path": "strings/string_compression/solution.py",
"copies": "1",
"size": "2362",
"license": "mit",
"hash": 9042891775661324000,
"line_mean": 37.737704918,
"line_max": 112,
"alpha_frac": 0.6769686706,
"autogenerated": false,
"ratio": 3.8096774193548386,
"config... |
"""A solver that alternates between deductive and hypothetical phases:
Deductive phase:
* Generate a list of all possible lines for each row and column.
* For each list, mark or unmark any cell that is in common between all of
the possible lines.
* Iterate to fixity.
Hypothetical phase:
* Find the cell with th... | {
"repo_name": "ggould256/nonogram",
"path": "src/solver/backward_chain_solver.py",
"copies": "1",
"size": "6110",
"license": "apache-2.0",
"hash": 6569717767358210000,
"line_mean": 44.9398496241,
"line_max": 78,
"alpha_frac": 0.6220949264,
"autogenerated": false,
"ratio": 4.3241330502477,
"conf... |
"A sort of application framework for the Mac"
DEBUG=0
from warnings import warnpy3k
warnpy3k("In 3.x, the FrameWork module is removed.", stacklevel=2)
import MacOS
import traceback
from Carbon.AE import *
from Carbon.AppleEvents import *
from Carbon.Ctl import *
from Carbon.Controls import *
from Carbon.Dlg import ... | {
"repo_name": "Lh4cKg/sl4a",
"path": "python/src/Lib/plat-mac/FrameWork.py",
"copies": "33",
"size": "37669",
"license": "apache-2.0",
"hash": -3665134559612246500,
"line_mean": 32.4538188277,
"line_max": 107,
"alpha_frac": 0.566725955,
"autogenerated": false,
"ratio": 3.7477862899214007,
"conf... |
"A sort of application framework for the Mac"
DEBUG=0
import MacOS
import traceback
from Carbon.AE import *
from Carbon.AppleEvents import *
from Carbon.Ctl import *
from Carbon.Controls import *
from Carbon.Dlg import *
from Carbon.Dialogs import *
from Carbon.Evt import *
from Carbon.Events import *
from Carbon.He... | {
"repo_name": "MalloyPower/parsing-python",
"path": "front-end/testsuite-python-lib/Python-2.3/Lib/plat-mac/FrameWork.py",
"copies": "1",
"size": "37559",
"license": "mit",
"hash": 7710305092704972000,
"line_mean": 32.4452359751,
"line_max": 107,
"alpha_frac": 0.5655102639,
"autogenerated": false,
... |
"""ASOS comparisons"""
import datetime
import calendar
import numpy as np
from pandas.io.sql import read_sql
from pyiem.plot import get_cmap
from pyiem.plot.use_agg import plt
from pyiem.util import get_autoplot_context, get_dbconn
from pyiem.exceptions import NoDataFound
PDICT = {
"low": "Morning Low (midnight t... | {
"repo_name": "akrherz/iem",
"path": "htdocs/plotting/auto/scripts/p54.py",
"copies": "1",
"size": "6270",
"license": "mit",
"hash": 7147107645008939000,
"line_mean": 27.1165919283,
"line_max": 78,
"alpha_frac": 0.5189792663,
"autogenerated": false,
"ratio": 3.1365682841420712,
"config_test": f... |
""" ASOS Daily Summary Message Parser ingestor """
# 3rd Party
import pytz
from twisted.internet import reactor
from pyiem.nws.products.dsm import parser
from pyiem.util import get_dbconn, LOG
# Local
from pywwa import common
from pywwa.ldm import bridge
from pywwa.database import get_database
# database timezones t... | {
"repo_name": "akrherz/pyWWA",
"path": "parsers/pywwa/workflows/dsm_parser.py",
"copies": "1",
"size": "1611",
"license": "mit",
"hash": 3383250952382785000,
"line_mean": 25.4098360656,
"line_max": 73,
"alpha_frac": 0.6238361266,
"autogenerated": false,
"ratio": 3.427659574468085,
"config_test"... |
"""A sound file (a wav file) undergoing analysis.
Loads the data from the sound file on disk, and provides methods for accessing
the sound data and, if it exists, associated textgrid annotation information.
"""
# Licensed under Apache v2 (see LICENSE)
from __future__ import division
import math
import os
import nu... | {
"repo_name": "voicesauce/opensauce-python",
"path": "opensauce/soundfile.py",
"copies": "1",
"size": "6905",
"license": "apache-2.0",
"hash": 1154700737670910200,
"line_mean": 38.683908046,
"line_max": 95,
"alpha_frac": 0.5551049964,
"autogenerated": false,
"ratio": 4.315625,
"config_test": fa... |
"""A source object that computes stress tensors on a volume.
The tensors are computed from the application of a point load on a
semi-infinite domain.
"""
# Authors: KK Rai (kk.rai [at] iitb.ac.in)
# R. Ambareesha (ambareesha [at] iitb.ac.in)
# Prabhu Ramachandran (prabhu [at] aero.iitb.ac.in... | {
"repo_name": "alexandreleroux/mayavi",
"path": "mayavi/sources/point_load.py",
"copies": "3",
"size": "2160",
"license": "bsd-3-clause",
"hash": 3936292239228518400,
"line_mean": 33.8387096774,
"line_max": 74,
"alpha_frac": 0.5175925926,
"autogenerated": false,
"ratio": 4.509394572025053,
"con... |
"""A source of audio signal that connects to the
:py:class:`~pyfmodex.channel_group.ChannelGroup` mixing
hierarchy.
"""
from ctypes import *
from .channel_control import ChannelControl
from .fmodobject import _dll
from .globalvars import get_class
from .utils import check_type, ckresult
class Channel(ChannelControl)... | {
"repo_name": "tyrylu/pyfmodex",
"path": "pyfmodex/channel.py",
"copies": "1",
"size": "8896",
"license": "mit",
"hash": 7559459173687925000,
"line_mean": 36.6949152542,
"line_max": 85,
"alpha_frac": 0.6435476619,
"autogenerated": false,
"ratio": 3.775891341256367,
"config_test": false,
"has_... |
""" A sparse matrix in COOrdinate or 'triplet' format"""
from __future__ import division, print_function, absolute_import
__docformat__ = "restructuredtext en"
__all__ = ['coo_matrix', 'isspmatrix_coo']
from warnings import warn
import numpy as np
from scipy.lib.six import xrange, zip as izip
from ._sparsetools i... | {
"repo_name": "jshiv/turntable",
"path": "test/lib/python2.7/site-packages/scipy/sparse/coo.py",
"copies": "7",
"size": "18062",
"license": "mit",
"hash": -646700355547197600,
"line_mean": 34.9800796813,
"line_max": 84,
"alpha_frac": 0.5133982948,
"autogenerated": false,
"ratio": 3.85692931881272... |
""" A sparse matrix in COOrdinate or 'triplet' format"""
__docformat__ = "restructuredtext en"
__all__ = ['coo_matrix', 'isspmatrix_coo']
from warnings import warn
import numpy as np
from sparsetools import coo_tocsr, coo_todense, coo_matvec
from base import isspmatrix
from data import _data_matrix
from sputils im... | {
"repo_name": "jasonmccampbell/scipy-refactor",
"path": "scipy/sparse/coo.py",
"copies": "1",
"size": "12356",
"license": "bsd-3-clause",
"hash": -2725816645268759000,
"line_mean": 33.0385674931,
"line_max": 96,
"alpha_frac": 0.5101165426,
"autogenerated": false,
"ratio": 3.7105105105105105,
"c... |
""" A sparse matrix in COOrdinate or 'triplet' format"""
__docformat__ = "restructuredtext en"
__all__ = ['coo_matrix', 'isspmatrix_coo']
from warnings import warn
import numpy as np
from ._sparsetools import coo_tocsr, coo_todense, coo_matvec
from .base import isspmatrix, SparseEfficiencyWarning, spmatrix
from .... | {
"repo_name": "endolith/scipy",
"path": "scipy/sparse/coo.py",
"copies": "12",
"size": "22145",
"license": "bsd-3-clause",
"hash": 2635325659697761000,
"line_mean": 34.8333333333,
"line_max": 91,
"alpha_frac": 0.5230977647,
"autogenerated": false,
"ratio": 3.8227170723286727,
"config_test": fal... |
"""A Spawner for JupyterHub to allow the Hub to be run as non-root.
This spawns a mediator process with sudo, which then takes actions on behalf of the user.
"""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import json
import shutil
import sys
import os
import... | {
"repo_name": "jupyter/sudospawner",
"path": "sudospawner/spawner.py",
"copies": "1",
"size": "4510",
"license": "bsd-3-clause",
"hash": -1383084342336814000,
"line_mean": 34.7936507937,
"line_max": 139,
"alpha_frac": 0.6133037694,
"autogenerated": false,
"ratio": 3.994685562444641,
"config_tes... |
""" A Spawner for JupyterHub to allow users to execute Jupyter
without involving root, sudo, or local system accounts. """
# Copyright (c) Christopher H Smith <chris@binc.jp>
# Distributed under the terms of the Modified BSD License.
import os
import errno
import signal
import pipes
import shutil
from tornado import ... | {
"repo_name": "chris-x86-64/rootlessspawner",
"path": "rootlessspawner/spawner.py",
"copies": "1",
"size": "5614",
"license": "bsd-3-clause",
"hash": 8141347024322774000,
"line_mean": 29.8461538462,
"line_max": 99,
"alpha_frac": 0.5774848593,
"autogenerated": false,
"ratio": 4.02725968436155,
"... |
"""A spec and code to implement the spec.
The spec defines a generic mapper for types to other types,
which can be used for validation, code generation and more.
NOTE: The below imports are always wrapped in a try/catch block
to ensure that users can optionally use/install one or more without having
to install them a... | {
"repo_name": "christabor/type_mappers",
"path": "type_mappers/__init__.py",
"copies": "1",
"size": "7832",
"license": "mit",
"hash": 54866169894168890,
"line_mean": 23.3987538941,
"line_max": 75,
"alpha_frac": 0.5820990807,
"autogenerated": false,
"ratio": 4.087682672233821,
"config_test": fal... |
"""A specfile interface.
Used mainly by transformer and tests to represent
a conventional specfile as a structure of sections.
"""
try:
from functools import reduce
except ImportError:
pass # we're on Python 2 => ok
import re
from spec2scl import settings
class Specfile(object):
"""An specfile interf... | {
"repo_name": "sclorg/spec2scl",
"path": "spec2scl/specfile.py",
"copies": "2",
"size": "2041",
"license": "mit",
"hash": 8684009288473769000,
"line_mean": 33.0166666667,
"line_max": 93,
"alpha_frac": 0.6080352768,
"autogenerated": false,
"ratio": 4.041584158415842,
"config_test": false,
"has... |
"""A special directive for including a matplotlib plot.
Given a path to a .py file, it includes the source code inline, then:
- On HTML, will include a .png with a link to a high-res .png.
- On LaTeX, will include a .pdf
This directive supports all of the options of the `image` directive,
except for `target` (since... | {
"repo_name": "FrankBian/kuma",
"path": "vendor/packages/ipython/docs/sphinxext/plot_directive.py",
"copies": "5",
"size": "4718",
"license": "mpl-2.0",
"hash": -1913020632091823000,
"line_mean": 29.4387096774,
"line_max": 79,
"alpha_frac": 0.637134379,
"autogenerated": false,
"ratio": 3.82643957... |
"""A specialization of RO.Wdg.StripChart that adds methods to trace keyVars
History:
2010-10-01 ROwen
2010-12-23 Backward-incompatible changes:
- Modified for backward-incompatible RO.Wdg.StripChartWdg
- plotKeyVar no longer takes a "name" argument; use label if you want a name that shows up ... | {
"repo_name": "r-owen/stui",
"path": "TUI/Base/StripChartWdg.py",
"copies": "1",
"size": "1617",
"license": "bsd-3-clause",
"hash": 7166198364515294000,
"line_mean": 38.4390243902,
"line_max": 114,
"alpha_frac": 0.6406926407,
"autogenerated": false,
"ratio": 3.887019230769231,
"config_test": fa... |
"""A specialization of RO.Wdg.StripChart that adds methods to trace keyVars
History:
2010-10-01 ROwen
2010-12-23 Backward-incompatible changes:
- Modified for backward-incompatible RO.Wdg.StripChartWdg
- plotKeyVar no longer takes a "name" argument; use label if you want a name that shows up i... | {
"repo_name": "r-owen/TUI",
"path": "TUI/Base/StripChartWdg.py",
"copies": "1",
"size": "1467",
"license": "bsd-3-clause",
"hash": 8897508130497432000,
"line_mean": 37.6052631579,
"line_max": 114,
"alpha_frac": 0.6387184731,
"autogenerated": false,
"ratio": 4.019178082191781,
"config_test": fal... |
"""A specialized report"""
from io import StringIO
import datetime
from pyiem.util import get_dbconn
def averageTemp(db, hi="high", lo="low"):
"""Average Temp"""
highSum, lowSum = 0, 0
for day in db.keys():
highSum += db[day][hi]
lowSum += db[day][lo]
highAvg = highSum / float(len(db... | {
"repo_name": "akrherz/iem",
"path": "cgi-bin/climate/orc.py",
"copies": "1",
"size": "4250",
"license": "mit",
"hash": 5682048764897902000,
"line_mean": 25.397515528,
"line_max": 76,
"alpha_frac": 0.4567058824,
"autogenerated": false,
"ratio": 3.0422333571939872,
"config_test": false,
"has_n... |
""" A special-purpose statusbar for Kura """
False = 0
True = 1
import os.path
from qt import QStatusBar, QLabel, QSizePolicy, QFont
from kuragui.guiconfig import guiConf
from kuragui import guiconfig
from kuralib import kuraapp
class KuraPanel(QLabel):
def __init__(self, *args):
QLabel.__init__(self, ... | {
"repo_name": "boudewijnrempt/kura",
"path": "kuraclient/kurastatusbar.py",
"copies": "1",
"size": "2886",
"license": "bsd-2-clause",
"hash": -6744461611099576000,
"line_mean": 30.0322580645,
"line_max": 89,
"alpha_frac": 0.5637560638,
"autogenerated": false,
"ratio": 3.9,
"config_test": false,... |
# Import system modules
from __future__ import absolute_import
import arcpy
import math
import sys
from arcpy.sa import Aspect, Sin, Cos
# local imports
from . import utils
from . import config
# Check out any necessary licenses
arcpy.CheckOutExtension("Spatial")
def main(bathy=None, out_sin_raster... | {
"repo_name": "EsriOceans/btm",
"path": "Install/toolbox/scripts/aspect.py",
"copies": "1",
"size": "2017",
"license": "mpl-2.0",
"hash": 7761680052133755000,
"line_mean": 32.775862069,
"line_max": 78,
"alpha_frac": 0.6643529995,
"autogenerated": false,
"ratio": 3.7771535580524342,
"config_test... |
"""A speedometer to measure the speed of a ball."""
from mpf.core.system_wide_device import SystemWideDevice
class Speedometer(SystemWideDevice):
"""A device which represents a tachometer."""
config_section = 'speedometers'
collection = 'speedometers'
class_label = 'speedometer'
__slots__ = ["t... | {
"repo_name": "missionpinball/mpf",
"path": "mpf/devices/speedometer.py",
"copies": "1",
"size": "1298",
"license": "mit",
"hash": 5540917065144658000,
"line_mean": 31.45,
"line_max": 76,
"alpha_frac": 0.626348228,
"autogenerated": false,
"ratio": 3.851632047477745,
"config_test": false,
"has... |
'''A Sphinx extension to automatically document CKAN's crazy plugins toolkit,
autodoc-style.
Sphinx's autodoc extension can document modules or classes, but although it
masquerades as a module CKAN's plugins toolkit is actually neither a module nor
a class, it's an object-instance of a class, and it's an object with w... | {
"repo_name": "WilJoey/tn_ckan",
"path": "ckan/plugins/toolkit_sphinx_extension.py",
"copies": "1",
"size": "6849",
"license": "mit",
"hash": 5073529053988026000,
"line_mean": 36.0216216216,
"line_max": 79,
"alpha_frac": 0.6579062637,
"autogenerated": false,
"ratio": 4.413015463917525,
"config_... |
"""A sphnix-doc plugin to build mxnet docs"""
import subprocess
import re
import os
import json
from recommonmark import transform
import pypandoc
# start or end of a code block
_CODE_MARK = re.compile('^([ ]*)```([\w]*)')
# language names and the according file extensions and comment symbol
_LANGS = {'python' : ('py... | {
"repo_name": "pluskid/mxnet",
"path": "docs/mxdoc.py",
"copies": "8",
"size": "9690",
"license": "apache-2.0",
"hash": 8571601984516879000,
"line_mean": 34.1086956522,
"line_max": 111,
"alpha_frac": 0.5034055728,
"autogenerated": false,
"ratio": 3.524918152055293,
"config_test": false,
"has_... |
"""A sphnix-doc plugin to build mxnet docs"""
import subprocess
import re
import os
import json
import sys
from recommonmark import transform
import pypandoc
import StringIO
import contextlib
# white list to evaluate the code block output, such as ['tutorials/gluon']
_EVAL_WHILTELIST = []
# start or end of a code blo... | {
"repo_name": "hesseltuinhof/mxnet",
"path": "docs/mxdoc.py",
"copies": "4",
"size": "11916",
"license": "apache-2.0",
"hash": -354918375070730940,
"line_mean": 32.3781512605,
"line_max": 111,
"alpha_frac": 0.5061262169,
"autogenerated": false,
"ratio": 3.5517138599105813,
"config_test": false,... |
# A spider, S, sits in one corner of a cuboid room, measuring
# 6 by 5 by 3, and a fly, F, sits in the opposite corner. By
# travelling on the surfaces of the room the shortest "straight
# line" distance from S to F is 10 and the path is shown on the
# diagram.
# [../img/p086.gif]
# However, there are up to three "sh... | {
"repo_name": "cloudzfy/euler",
"path": "src/86.py",
"copies": "1",
"size": "1101",
"license": "mit",
"hash": 4113555804418402300,
"line_mean": 29.5833333333,
"line_max": 64,
"alpha_frac": 0.6939146231,
"autogenerated": false,
"ratio": 3.238235294117647,
"config_test": false,
"has_no_keywords... |
""" A spiral matrix is a square matrix of size n × n. It contains all the integers in range from 1 to n * n so
that number 1 is written in the bottom right corner, and all other numbers are written in increasing order
spirally in the counterclockwise direction.
Given the size of the matrix n, your task is to create ... | {
"repo_name": "ntthuy11/CodeFights",
"path": "Arcade/04_Python/05_ComplexityOfComprehension/createSpiralMatrix.py",
"copies": "1",
"size": "1127",
"license": "mit",
"hash": -7177934518818029000,
"line_mean": 36.5333333333,
"line_max": 111,
"alpha_frac": 0.5426287744,
"autogenerated": false,
"rati... |
"""A Sportszone client.
Given a Sportszone URL, the client will scrape the site for team and scheduling
information.
"""
import collections
import httplib
import time
import urlparse
from lxml import html
Game = collections.namedtuple(
'Game', ['game_datetime', 'arena', 'home_away', 'opponent'])
class Sportszo... | {
"repo_name": "kjiwa/sportszone-exporter",
"path": "sportszone.py",
"copies": "1",
"size": "2393",
"license": "mit",
"hash": 1515149513282930400,
"line_mean": 24.4574468085,
"line_max": 79,
"alpha_frac": 0.6021730046,
"autogenerated": false,
"ratio": 3.399147727272727,
"config_test": false,
"... |
''' As practice with using classes, I'm going to define a class corresponding to three-vectors
(named, appropriately, ThreeVec).
ThreeVec will support vector addition and subtraction, scalar multiplication and division, dot
products (which, perhaps confusingly, will /also/ be represented by *, so th... | {
"repo_name": "k-shukla/misc_exercises-py",
"path": "Shukla - Three Vec.py",
"copies": "1",
"size": "4847",
"license": "mit",
"hash": -1041949717208874100,
"line_mean": 39.7844827586,
"line_max": 144,
"alpha_frac": 0.5597276666,
"autogenerated": false,
"ratio": 3.711332312404288,
"config_test":... |
# A sprite class derivative that implements integer z values (larger negatives are more distant)
import pyglet
from pyglet.gl import *
from pyglet import graphics
from pyglet import image
from pyglet import sprite
from pyglet import clock
"""
NB. You will need to set up z-buffering and your near and far clipping plan... | {
"repo_name": "NiclasEriksen/rpg_procgen",
"path": "zsprite.py",
"copies": "1",
"size": "9692",
"license": "cc0-1.0",
"hash": -3163968723735719400,
"line_mean": 34.5054945055,
"line_max": 101,
"alpha_frac": 0.5159925712,
"autogenerated": false,
"ratio": 3.9286582894203486,
"config_test": true,
... |
# Asq's setup.py
from distutils.core import setup
import io
import os
import re
from asq import __version__ as version
def read(*names, **kwargs):
with io.open(
os.path.join(os.path.dirname(__file__), *names),
encoding=kwargs.get("encoding", "utf8")
) as fp:
return fp.read()
def fin... | {
"repo_name": "sherzberg/asq",
"path": "setup.py",
"copies": "1",
"size": "1788",
"license": "mit",
"hash": -5424735152461003000,
"line_mean": 30.9285714286,
"line_max": 73,
"alpha_frac": 0.6096196868,
"autogenerated": false,
"ratio": 3.804255319148936,
"config_test": false,
"has_no_keywords"... |
# Asq's setup.py
from distutils.core import setup
from asq import __version__ as version
with open('README.txt', 'r') as readme:
long_description = readme.read()
setup(
name = "asq",
packages = ["asq"],
version = "{version}".format(version=version),
description = "LINQ-for-objects style queries ... | {
"repo_name": "flying-circus/asq",
"path": "setup.py",
"copies": "4",
"size": "1278",
"license": "mit",
"hash": 3985569163965589000,
"line_mean": 34.5,
"line_max": 115,
"alpha_frac": 0.6244131455,
"autogenerated": false,
"ratio": 3.9444444444444446,
"config_test": false,
"has_no_keywords": fa... |
# Asq's setup.py
from setuptools import setup
import io
import os
import re
def read(*names, **kwargs):
with io.open(
os.path.join(os.path.dirname(__file__), *names),
encoding=kwargs.get("encoding", "utf8")
) as fp:
return fp.read()
def find_version(*file_paths):
version_file = ... | {
"repo_name": "rob-smallshire/asq",
"path": "setup.py",
"copies": "1",
"size": "1864",
"license": "mit",
"hash": -1774069633655595800,
"line_mean": 31.1379310345,
"line_max": 75,
"alpha_frac": 0.6056866953,
"autogenerated": false,
"ratio": 3.8592132505175982,
"config_test": false,
"has_no_key... |
# as_rwGPS.py Asynchronous device driver for GPS devices using a UART.
# Supports a limited subset of the PMTK command packets employed by the
# widely used MTK3329/MTK3339 chip.
# Sentence parsing based on MicropyGPS by Michael Calvin McCoy
# https://github.com/inmcm/micropyGPS
# Copyright (c) 2018 Peter Hinch
# Rele... | {
"repo_name": "peterhinch/micropython-async",
"path": "v3/as_drivers/as_GPS/as_rwGPS.py",
"copies": "1",
"size": "4383",
"license": "mit",
"hash": -2223760741929690000,
"line_mean": 36.1440677966,
"line_max": 91,
"alpha_frac": 0.5544147844,
"autogenerated": false,
"ratio": 3.0522284122562673,
"... |
# Ass7.2
# Liu Li
# 18 Nov, 2015
'''
Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form:
X-DSPAM-Confidence: 0.8475
Count these lines and extract the floating point values from each of the lines and compute the average of those values and prod... | {
"repo_name": "ll0816/PythonForEverybody",
"path": "Python-Data-Structure/Ass7.2.py",
"copies": "1",
"size": "1031",
"license": "mit",
"hash": -2842668874437314000,
"line_mean": 38.6538461538,
"line_max": 156,
"alpha_frac": 0.694471387,
"autogenerated": false,
"ratio": 3.4713804713804715,
"conf... |
"""assassins URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.9/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-b... | {
"repo_name": "bobandbetty/assassins",
"path": "assassins/assassins/urls.py",
"copies": "2",
"size": "1209",
"license": "mit",
"hash": -1494126348087691800,
"line_mean": 39.3,
"line_max": 89,
"alpha_frac": 0.6906534326,
"autogenerated": false,
"ratio": 3.4152542372881354,
"config_test": false,
... |
"""Assay information class"""
import os
import yaml
import pandas as pd
from .example_filetype_format import FileTypeFormat
from . import process_functions
class Assayinfo(FileTypeFormat):
"""Assay information file type"""
_fileType = "assayinfo"
_process_kwargs = ["newPath", "databaseSynId"]
def... | {
"repo_name": "thomasyu888/Genie",
"path": "genie/assay.py",
"copies": "1",
"size": "12289",
"license": "mit",
"hash": 3083143859711158300,
"line_mean": 39.8272425249,
"line_max": 89,
"alpha_frac": 0.5457726422,
"autogenerated": false,
"ratio": 4.038448899112717,
"config_test": false,
"has_no... |
# Assemble Arybo IR into ASM thanks to LLVM
# Map symbol names to register
# Warning: this tries to do its best to save modified temporary registers.
# There might be errors while doing this. The idea is not to regenerate clean
# binaries, but to help the reverser!
try:
import llvmlite.ir as ll
import llvmlite... | {
"repo_name": "quarkslab/arybo",
"path": "arybo/lib/exprs_asm.py",
"copies": "1",
"size": "10636",
"license": "bsd-3-clause",
"hash": -5456864958629841000,
"line_mean": 32.872611465,
"line_max": 112,
"alpha_frac": 0.6078412937,
"autogenerated": false,
"ratio": 3.1863391252246855,
"config_test":... |
# Assembler - main class
#
# Input: a single assembly source file
# Output: an object file with the assembled source and other
# linkage information (relocation table, list of unresolved
# and exported labels).
#
# Luz micro-controller assembler
# Eli Bendersky (C) 2008-2010
#
import pprint, os, sys
from collections im... | {
"repo_name": "eliben/luz-cpu",
"path": "luz_asm_sim/lib/asmlib/assembler.py",
"copies": "1",
"size": "14448",
"license": "unlicense",
"hash": -8956863696156704000,
"line_mean": 38.0486486486,
"line_max": 119,
"alpha_frac": 0.4986157254,
"autogenerated": false,
"ratio": 4.703125,
"config_test":... |
# Assembler - main class
#
# Input: a single assembly source file
# Output: an object file with the assembled source and other
# linkage information (relocation table, list of unresolved
# and exported labels).
#
# Luz micro-controller assembler
# Eli Bendersky (C) 2008-2010
#
import pprint, os, sys
from col... | {
"repo_name": "8l/luz-cpu",
"path": "luz_asm_sim/lib/asmlib/assembler.py",
"copies": "1",
"size": "15393",
"license": "unlicense",
"hash": 4126728296630606300,
"line_mean": 39.3002680965,
"line_max": 119,
"alpha_frac": 0.4680049373,
"autogenerated": false,
"ratio": 4.906917437041759,
"config_te... |
# assembler.py 03/11/2014 D.J.Whale
#
# Read a file and assemble it into a numeric representation
import parser
import instruction
import symtab
import io
# Extension mechanism
import extarch
# Set to True if you want addresses prefixed into the output file
PREFIX_ADDR = False
def trace(msg):
print(str(msg))
... | {
"repo_name": "whaleygeek/MyLittleComputer",
"path": "src/python/assembler.py",
"copies": "1",
"size": "2189",
"license": "mit",
"hash": 2115840577182450400,
"line_mean": 20.2524271845,
"line_max": 78,
"alpha_frac": 0.6697121974,
"autogenerated": false,
"ratio": 3.015151515151515,
"config_test"... |
# assembles and executes example files and compares expected and actual output
import subprocess
import sys
# prep input to make it consumable by the pixie executable
def prep(s):
return ('\n'.join(s) + '\n').encode('ascii')
test_cases = {
'42':
[('', b'42')],
'add':
[(prep('11'), b'2'),... | {
"repo_name": "vladris/pixie",
"path": "test/run.py",
"copies": "1",
"size": "1838",
"license": "mit",
"hash": 5293416439142903000,
"line_mean": 28.6451612903,
"line_max": 82,
"alpha_frac": 0.4504896627,
"autogenerated": false,
"ratio": 3.6252465483234713,
"config_test": false,
"has_no_keywor... |
''' Assemble websocket wire message fragments into complete Bokeh Server
message objects that can be processed.
'''
from __future__ import absolute_import
import six
from tornado.concurrent import return_future
from ..exceptions import ValidationError
import logging
log = logging.getLogger(__name__)
class Receiver... | {
"repo_name": "msarahan/bokeh",
"path": "bokeh/server/protocol/receiver.py",
"copies": "17",
"size": "3054",
"license": "bsd-3-clause",
"hash": 8954305614819286000,
"line_mean": 30.1632653061,
"line_max": 131,
"alpha_frac": 0.6365422397,
"autogenerated": false,
"ratio": 4.511078286558345,
"conf... |
''' Assemble WebSocket wire message fragments into complete Bokeh Server
message objects that can be processed.
'''
from __future__ import absolute_import
import six
from tornado.concurrent import return_future
from .exceptions import ValidationError
import logging
log = logging.getLogger(__name__)
class Receiver(... | {
"repo_name": "DuCorey/bokeh",
"path": "bokeh/protocol/receiver.py",
"copies": "5",
"size": "4492",
"license": "bsd-3-clause",
"hash": 401028304959828540,
"line_mean": 32.0294117647,
"line_max": 131,
"alpha_frac": 0.6188780053,
"autogenerated": false,
"ratio": 4.718487394957983,
"config_test": ... |
''' Assemble WebSocket wire message fragments into complete Bokeh Server
message objects that can be processed.
'''
from __future__ import absolute_import
import six
from tornado import gen
from .exceptions import ValidationError
import logging
log = logging.getLogger(__name__)
class Receiver(object):
''' Rece... | {
"repo_name": "mindriot101/bokeh",
"path": "bokeh/protocol/receiver.py",
"copies": "3",
"size": "4356",
"license": "bsd-3-clause",
"hash": -4086375689410751500,
"line_mean": 31.7518796992,
"line_max": 131,
"alpha_frac": 0.6179981635,
"autogenerated": false,
"ratio": 4.683870967741935,
"config_t... |
'''Assemble what we have and try it out
Sadly we get an error. But at n=6 so might be easy to fix. In
winter 2014-15 calculations we got past 6.
>>> doit_G(2, 3)
array([[[1, 0, 0, 0, 0, 1, 0, 1],
[0, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 1]],
<BLANKLINE>
[[0, 0, 0, 0, 0, 1, 0, 0],
... | {
"repo_name": "jfine2358/py-linhomy",
"path": "py/linhomy/work.py",
"copies": "1",
"size": "6556",
"license": "mit",
"hash": -1068034642474522000,
"line_mean": 26.2033195021,
"line_max": 72,
"alpha_frac": 0.4655277608,
"autogenerated": false,
"ratio": 2.146692861820563,
"config_test": false,
... |
# Assembling likelihood functions for Gyrochronology, isochrones, dynamics
# and asteroseismology.
import os
import time
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import scipy.misc as spm
from isochrones import StarModel
from isochrones.mist import MIST_Isochrone
from simple_gibbs import... | {
"repo_name": "RuthAngus/chronometer",
"path": "chronometer/age_test.py",
"copies": "1",
"size": "3725",
"license": "mit",
"hash": 9122150168786762000,
"line_mean": 27.2196969697,
"line_max": 78,
"alpha_frac": 0.5973154362,
"autogenerated": false,
"ratio": 3.0887230514096187,
"config_test": fal... |
# assembling
import dis
import struct
from error import *
compare_op = dict((which, num) for num, which in enumerate(dis.cmp_op))
def assemble(tuples):
return ''.join([assemble_instruction(*tup) for tup in tuples])
def assemble_instruction(opname, arg=None):
return assemble_opcode_arg(dis.opmap[opname], ar... | {
"repo_name": "thepaul/noodle",
"path": "Noodle/assembling.py",
"copies": "1",
"size": "2854",
"license": "mit",
"hash": -6815999519838767000,
"line_mean": 26.9803921569,
"line_max": 81,
"alpha_frac": 0.5543097407,
"autogenerated": false,
"ratio": 2.9698231009365244,
"config_test": false,
"ha... |
'''Assembly (byte code) utilities
'''
from __future__ import absolute_import
if __name__ == '__main__':
import jamenson.compiler.asm
exit()
import byteplay as B
from .util import collect_list
from ..runtime import ore as O
def finalize_instructions(ops):
ops = fix_set_lineno(ops)
if not (ops and o... | {
"repo_name": "matthagy/Jamenson",
"path": "jamenson/compiler/asm.py",
"copies": "1",
"size": "4647",
"license": "apache-2.0",
"hash": -5285109826822895000,
"line_mean": 27.8633540373,
"line_max": 78,
"alpha_frac": 0.5295889821,
"autogenerated": false,
"ratio": 3.3431654676258993,
"config_test"... |
"""Assembly function."""
from typing import Optional, Tuple
from hdltools.binutils.instruction import AsmInstruction
from hdltools.binutils import AsmObject
class AsmFunction(AsmObject):
"""Asm function."""
def __init__(
self,
name: str,
address: int,
instructions: Optional[T... | {
"repo_name": "brunosmmm/hdltools",
"path": "hdltools/binutils/function.py",
"copies": "1",
"size": "1028",
"license": "mit",
"hash": 2910594776285354500,
"line_mean": 22.3636363636,
"line_max": 61,
"alpha_frac": 0.563229572,
"autogenerated": false,
"ratio": 4.589285714285714,
"config_test": fa... |
"""Assembly instruction."""
from typing import Optional, Any
from enum import Enum, auto
from hdltools.binutils import AsmObject
class InstructionType(Enum):
"""Abstract instruction type."""
UNKNOWN = auto()
class MemoryInstructionType(Enum):
"""Abstract memory instruction types."""
LOAD = auto()... | {
"repo_name": "brunosmmm/hdltools",
"path": "hdltools/binutils/instruction.py",
"copies": "1",
"size": "2449",
"license": "mit",
"hash": -5175874070656232000,
"line_mean": 19.9316239316,
"line_max": 62,
"alpha_frac": 0.5802368314,
"autogenerated": false,
"ratio": 4.365418894830659,
"config_test... |
"""assert functions from numpy and pandas testing
"""
import re
from distutils.version import StrictVersion, LooseVersion
import numpy as np
import numpy.testing as npt
import pandas
import pandas.util.testing as pdt
# for pandas version check
def strip_rc(version):
return re.sub(r"rc\d+$", "", version)
def i... | {
"repo_name": "kiyoto/statsmodels",
"path": "statsmodels/tools/testing.py",
"copies": "6",
"size": "1504",
"license": "bsd-3-clause",
"hash": -5062789264598751000,
"line_mean": 31.6956521739,
"line_max": 76,
"alpha_frac": 0.6934840426,
"autogenerated": false,
"ratio": 3.7044334975369457,
"confi... |
"""assert functions from numpy and pandas testing
"""
import re
from distutils.version import StrictVersion
import numpy as np
import numpy.testing as npt
import pandas
import pandas.util.testing as pdt
# for pandas version check
def strip_rc(version):
return re.sub(r"rc\d+$", "", version)
def is_pandas_min_ve... | {
"repo_name": "rgommers/statsmodels",
"path": "statsmodels/tools/testing.py",
"copies": "2",
"size": "1442",
"license": "bsd-3-clause",
"hash": -3064190874507549700,
"line_mean": 31.0444444444,
"line_max": 76,
"alpha_frac": 0.6955617198,
"autogenerated": false,
"ratio": 3.6974358974358976,
"con... |
assert __import__("pkg_resources").get_distribution(
"sqlalchemy").version.split('.') >= ['0', '6'], \
"requires sqlalchemy version 0.6 or greater"
from builtins import next
import warnings
from datetime import datetime
from werkzeug.urls import iri_to_uri
from sqlalchemy import schema, Table, exc, util
from ... | {
"repo_name": "maparent/virtuoso-python",
"path": "virtuoso/alchemy.py",
"copies": "1",
"size": "29042",
"license": "bsd-3-clause",
"hash": -5632344684373782000,
"line_mean": 35.6691919192,
"line_max": 95,
"alpha_frac": 0.6018180566,
"autogenerated": false,
"ratio": 3.706227667177131,
"config_t... |
"""Assertion based test cases for monotable.table.MonoTable for pytest."""
from collections import namedtuple
from os import path
import re
import pytest
import monotable
import monotable.plugin
import monotable.table
def read_file(*path_components):
"""Read a text file from the source tree into a string.
... | {
"repo_name": "tmarktaylor/monotable",
"path": "test/test_monotable.py",
"copies": "1",
"size": "28338",
"license": "apache-2.0",
"hash": 4139715556106275300,
"line_mean": 30.1406593407,
"line_max": 80,
"alpha_frac": 0.535923495,
"autogenerated": false,
"ratio": 3.4749233599019007,
"config_test... |
"""Assertion runners.
"""
import re
import verify
from .base import Assertion, is_assertion
__all__ = (
'ensure',
'expect',
)
class expect(object):
"""Pass `value` through a set of assertable functions.
There are two styles for invoking ``expect``:
1. Pass `value` and all `assertions` as arg... | {
"repo_name": "dgilland/verify",
"path": "verify/runners.py",
"copies": "1",
"size": "3566",
"license": "mit",
"hash": -2181258280822830000,
"line_mean": 27.528,
"line_max": 79,
"alpha_frac": 0.5765563657,
"autogenerated": false,
"ratio": 4.531130876747141,
"config_test": false,
"has_no_keywo... |
""" Assertions for testing
:Author: Jonathan Karr <karr@mssm.edu>
:Date: 2019-06-18
:Copyright: 2019, Karr Lab
:License: MIT
"""
import humanfriendly
import objsize
def assert_memory_less(obj, size, exclusive=False):
""" Assert that the memory occupied by an object is less than a
size
Args:
obj... | {
"repo_name": "KarrLab/wc_utils",
"path": "wc_utils/util/testing.py",
"copies": "1",
"size": "1750",
"license": "mit",
"hash": -6553077271228284000,
"line_mean": 28.1666666667,
"line_max": 79,
"alpha_frac": 0.6154285714,
"autogenerated": false,
"ratio": 3.9149888143176734,
"config_test": false,... |
""" Assertions for use within the test controllers.
Copyright (c) 2014 Kenn Takara
See LICENSE for details
"""
import os
import sys
def assert_equals(condition_a, condition_b):
""" Assert that both sides are equal """
caller = sys._getframe(1)
if condition_a != condition_b:
raise Assert... | {
"repo_name": "kennt/fixtest",
"path": "fixtest/base/asserts.py",
"copies": "1",
"size": "3538",
"license": "mit",
"hash": -6776215625254238000,
"line_mean": 31.4587155963,
"line_max": 75,
"alpha_frac": 0.5353306953,
"autogenerated": false,
"ratio": 4.094907407407407,
"config_test": false,
"h... |
"""Assertions.
Generally you just use the ``ASSERT`` object defined in this module, but
if you want to raise different exception, just define an ``Assertions``
instance.
Examples:
>>> from g1.bases.assertions import ASSERT
>>> ASSERT(is_prime(x), 'expect a prime number, not {}', x)
This module is different from (and... | {
"repo_name": "clchiou/garage",
"path": "py/g1/bases/g1/bases/assertions.py",
"copies": "1",
"size": "11506",
"license": "mit",
"hash": -7955244830073160000,
"line_mean": 27.0634146341,
"line_max": 78,
"alpha_frac": 0.5862158874,
"autogenerated": false,
"ratio": 3.6713465220165924,
"config_test... |
"""Assertions related to containers/iterables.
"""
import operator
import pydash
from .base import Assertion, Comparator, Negate
from .numbers import Between
__all__ = (
'In',
'NotIn',
'Contains',
'NotContains',
'ContainsOnly',
'NotContainsOnly',
'Subset',
'NotSubset',
'Superset... | {
"repo_name": "dgilland/verify",
"path": "verify/containers.py",
"copies": "1",
"size": "7481",
"license": "mit",
"hash": 6053268354495464000,
"line_mean": 20.0732394366,
"line_max": 79,
"alpha_frac": 0.5703782917,
"autogenerated": false,
"ratio": 3.5931796349663783,
"config_test": false,
"ha... |
"""Assertions related to equality.
"""
import operator
from functools import partial
import re
import pydash
from .base import Assertion, Comparator, Negate, NotSet
__all__ = (
'Equal',
'NotEqual',
'Match',
'NotMatch',
'Is',
'IsNot',
'IsTrue',
'IsNotTrue',
'IsFalse',
'IsNotF... | {
"repo_name": "dgilland/verify",
"path": "verify/equality.py",
"copies": "1",
"size": "4665",
"license": "mit",
"hash": -7240248771391749000,
"line_mean": 16.4719101124,
"line_max": 79,
"alpha_frac": 0.5530546624,
"autogenerated": false,
"ratio": 3.2968197879858656,
"config_test": false,
"has... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.