text stringlengths 0 1.05M | meta dict |
|---|---|
# ADAPTED FROM https://github.com/openai/gym-http-api
import requests
import six.moves.urllib.parse as urlparse
import json
import os
import pkg_resources
import sys
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
class Client(object):
"""
Gym client to interface with gym_htt... | {
"repo_name": "JackieTseng/Learning_to_run",
"path": "osim/http/client.py",
"copies": "1",
"size": "4026",
"license": "mit",
"hash": -6742848888585377000,
"line_mean": 36.6261682243,
"line_max": 98,
"alpha_frac": 0.5956284153,
"autogenerated": false,
"ratio": 3.8823529411764706,
"config_test": ... |
# adapted from https://github.com/pybind/cmake_example
import os
import re
import sys
import platform
import subprocess
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from distutils.version import LooseVersion
def get_env():
sp = sys.path[1].split("/")
if "envs" i... | {
"repo_name": "readdy/readdy",
"path": "examples/custom_potential/setup.py",
"copies": "1",
"size": "2719",
"license": "bsd-3-clause",
"hash": 5019624706463943000,
"line_mean": 33.858974359,
"line_max": 98,
"alpha_frac": 0.566016918,
"autogenerated": false,
"ratio": 3.8403954802259888,
"config_... |
# Adapted from https://github.com/rlcode/per/blob/master/SumTree.py
import numpy
# SumTree
# a binary tree data structure where the parent’s value is the sum of its children
class SumTree:
write = 0
def __init__(self, capacity):
self.capacity = capacity
self.tree = numpy.zeros(2 * capacity - 1)... | {
"repo_name": "ShangtongZhang/DeepRL",
"path": "deep_rl/utils/sum_tree.py",
"copies": "1",
"size": "1856",
"license": "mit",
"hash": 6522820849383296000,
"line_mean": 26.6865671642,
"line_max": 82,
"alpha_frac": 0.5604099245,
"autogenerated": false,
"ratio": 3.708,
"config_test": false,
"has_... |
# Adapted from https://github.com/rmcgibbo/npcuda-example and
# https://github.com/cupy/cupy/blob/master/cupy_setup_build.py
import logging
import os
import sys
from distutils import ccompiler, errors, msvccompiler, unixccompiler
from setuptools.command.build_ext import build_ext as setuptools_build_ext
def find_in_... | {
"repo_name": "benfred/implicit",
"path": "cuda_setup.py",
"copies": "1",
"size": "7190",
"license": "mit",
"hash": -2543849631468683000,
"line_mean": 33.5673076923,
"line_max": 98,
"alpha_frac": 0.5899860918,
"autogenerated": false,
"ratio": 3.6796315250767657,
"config_test": false,
"has_no_... |
# Adapted from https://github.com/robtandy/randomdict
# As version there has an outstanding bug
from collections import MutableMapping
import random
class RandomDict(MutableMapping):
def __init__(self, *args, **kwargs):
""" Create RandomDict object with contents specified by arguments.
Any argument
:param *arg... | {
"repo_name": "mattea/mattea-utils",
"path": "matteautils/randomdict.py",
"copies": "1",
"size": "2008",
"license": "apache-2.0",
"hash": -7060658257533913000,
"line_mean": 24.1,
"line_max": 74,
"alpha_frac": 0.6628486056,
"autogenerated": false,
"ratio": 3.065648854961832,
"config_test": false... |
# Adapted from https://github.com/sparticlesteve/cosmoflow-benchmark/blob/master/models/cosmoflow_v1.py
"""Model specification for CosmoFlow This module contains the v1
implementation of the benchmark model. It is deprecated now and being
replaced with the updated, more configurable architecture currently
defined in ... | {
"repo_name": "undertherain/benchmarker",
"path": "benchmarker/kernels/cosmoflow/tensorflow.py",
"copies": "1",
"size": "2148",
"license": "mpl-2.0",
"hash": 4417416568213855000,
"line_mean": 28.8333333333,
"line_max": 103,
"alpha_frac": 0.5856610801,
"autogenerated": false,
"ratio": 3.7684210526... |
# adapted from https://github.com/tannewt/agohunterdouglas/agohunterdouglas.py
# license from that project included in this repo as well
import time
import socket
import json
import re
import sys
import subprocess
import logging
from colorlog import ColoredFormatter
LOG_LEVEL = logging.ERROR
LOGFORMAT = "%(log_color)... | {
"repo_name": "schwark/alfred-hunterdouglas",
"path": "hunterdouglas.py",
"copies": "1",
"size": "6552",
"license": "mit",
"hash": -4036965793380962000,
"line_mean": 23.0919117647,
"line_max": 113,
"alpha_frac": 0.6153846154,
"autogenerated": false,
"ratio": 3.169811320754717,
"config_test": fa... |
# Adapted from https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/learn/python/learn/datasets/mnist.py
import numpy as np
class DataSet(object):
def __init__(self, x, labels):
if len(x.shape) > 2:
x = np.reshape(x, [x.shape[0], -1])
assert(x.shape[0] == labels.s... | {
"repo_name": "kohpangwei/influence-release",
"path": "influence/dataset.py",
"copies": "1",
"size": "2619",
"license": "mit",
"hash": 4394282622930959400,
"line_mean": 27.1720430108,
"line_max": 123,
"alpha_frac": 0.5597556319,
"autogenerated": false,
"ratio": 3.3151898734177214,
"config_test"... |
# Adapted from https://github.com/tindie/pydiscourse
import logging
import requests
from django.conf import settings
from requests.exceptions import HTTPError
log = logging.getLogger('pydiscourse.client')
NOTIFICATION_WATCHING = 3
NOTIFICATION_TRACKING = 2
NOTIFICATION_NORMAL = 1
NOTIFICATION_MUTED = 0
class Disc... | {
"repo_name": "crowdresearch/crowdsource-platform",
"path": "crowdsourcing/discourse.py",
"copies": "2",
"size": "11818",
"license": "mit",
"hash": 5220444826404106000,
"line_mean": 36.8782051282,
"line_max": 119,
"alpha_frac": 0.5903706211,
"autogenerated": false,
"ratio": 4.023833844058563,
"... |
## Adapted from https://github.com/tylin/coco-caption/blob/master/pycocoevalcap/eval.py (by tylin)
import os.path as osp
import sys
this_dir = osp.dirname(osp.realpath(__file__))
sys.path.append(osp.join(this_dir, 'coco-caption/pycocoevalcap'))
from tokenizer.ptbtokenizer import PTBTokenizer
from bleu.bleu import Ble... | {
"repo_name": "raingo/TGIF-Release",
"path": "data/eval.py",
"copies": "1",
"size": "2975",
"license": "bsd-3-clause",
"hash": -4404713437627284000,
"line_mean": 27.8834951456,
"line_max": 98,
"alpha_frac": 0.5045378151,
"autogenerated": false,
"ratio": 3.6016949152542375,
"config_test": true,
... |
# adapted from https://lsandig.org/blog/2014/08/apollon-python/en/
from cmath import sqrt
import math
class Circle(object):
"""
A circle represented by center point as complex number and radius.
"""
def __init__ ( self, mx, my, r ):
"""
@param mx: x center coordinate
@param my:... | {
"repo_name": "5agado/data-science-learning",
"path": "graphics/blender/apollonian_gaskets.py",
"copies": "1",
"size": "4357",
"license": "apache-2.0",
"hash": -1936496077419181800,
"line_mean": 32.7829457364,
"line_max": 121,
"alpha_frac": 0.6206105118,
"autogenerated": false,
"ratio": 2.8892572... |
# Adapted from https://pygame.org/wiki/Spritesheet
import pygame
class spritesheetmatrix(object):
def __init__(self, filename, rows=3, cols=4, colorkey=None):
try:
self.rows = int(rows)
self.cols = int(cols)
self.colorkey = colorkey
self.sprite_tuples = []... | {
"repo_name": "kzwatkins/spritesheetmatrix",
"path": "spritesheetmatrix.py",
"copies": "1",
"size": "2510",
"license": "apache-2.0",
"hash": 3897192291214126600,
"line_mean": 30.7848101266,
"line_max": 133,
"alpha_frac": 0.5924302789,
"autogenerated": false,
"ratio": 3.696612665684831,
"config_... |
# Adapted from https://pymotw.com/2/socket/multicast.html
import socket
import struct
import sys
import threading
import time
from mve.utils import eprint
def register(component_name, multicast_ip='224.3.29.71', multicast_port=10000):
"""Discovers and registers with a UDP Server
Returns the IP address of the... | {
"repo_name": "man-vs-electron/mve",
"path": "lib/mve/udp.py",
"copies": "1",
"size": "4089",
"license": "apache-2.0",
"hash": 8343672617435985000,
"line_mean": 33.075,
"line_max": 93,
"alpha_frac": 0.6400097823,
"autogenerated": false,
"ratio": 4.044510385756676,
"config_test": false,
"has_n... |
# Adapted from https://stanford.edu/~mwaskom/software/seaborn/examples/network_correlations.html
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
sns.set(context="paper", font="monospace")
# Load the datset of correlations between cortical brain networks
df = pd.read_csv("/... | {
"repo_name": "willettk/decals",
"path": "python/heatmap.py",
"copies": "1",
"size": "1202",
"license": "mit",
"hash": -5203481863561205000,
"line_mean": 29.05,
"line_max": 148,
"alpha_frac": 0.7221297837,
"autogenerated": false,
"ratio": 2.828235294117647,
"config_test": false,
"has_no_keywo... |
# Adapted from http://stackoverflow.com/questions/10017859/how-to-build-a-simple-http-post-server
# Thank you!
import sys
import BaseHTTPServer
import cgi
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_POST(self):
ctype, pdict = cgi.parse_header(self.headers.getheader('content-type'))
... | {
"repo_name": "aaaaalbert/repy-doodles",
"path": "httpserver_with_post.py",
"copies": "1",
"size": "1281",
"license": "unlicense",
"hash": 8718431688572975000,
"line_mean": 31.8461538462,
"line_max": 97,
"alpha_frac": 0.6221701795,
"autogenerated": false,
"ratio": 3.69164265129683,
"config_test... |
# Adapted from http://stackoverflow.com/questions/110803/dirty-fields-in-django
from copy import deepcopy
from django.core.exceptions import ValidationError
from django.db.models.signals import post_save, m2m_changed
from .compare import raw_compare, compare_states
from .compat import (is_db_expression, save_specific... | {
"repo_name": "jdotjdot/django-dirtyfields",
"path": "src/dirtyfields/dirtyfields.py",
"copies": "1",
"size": "5337",
"license": "bsd-3-clause",
"hash": -4575186713593828000,
"line_mean": 39.7404580153,
"line_max": 107,
"alpha_frac": 0.5979014428,
"autogenerated": false,
"ratio": 4.08965517241379... |
# Adapted from http://stackoverflow.com/questions/110803/dirty-fields-in-django
from django.db import models
from django.db.models.signals import pre_save, post_save
from django.contrib.contenttypes.models import ContentType
import random, string, hashlib, time
import six
def id_generator():
return hashlib.md5(st... | {
"repo_name": "futurice/django-dirtyfield",
"path": "djangodirtyfield/mixin.py",
"copies": "1",
"size": "4723",
"license": "bsd-3-clause",
"hash": 343151871745479360,
"line_mean": 37.0887096774,
"line_max": 102,
"alpha_frac": 0.5991954266,
"autogenerated": false,
"ratio": 3.8872427983539093,
"c... |
# Adapted from http://stackoverflow.com/questions/110803/dirty-fields-in-django
from django.db.models.signals import post_save
class DirtyFieldsMixin(object):
def __init__(self, *args, **kwargs):
super(DirtyFieldsMixin, self).__init__(*args, **kwargs)
post_save.connect(
self._reset_stat... | {
"repo_name": "stanhu/django-dirtyfields",
"path": "dirtyfields/dirtyfields.py",
"copies": "1",
"size": "1950",
"license": "bsd-3-clause",
"hash": 7348611343877332000,
"line_mean": 36.5,
"line_max": 80,
"alpha_frac": 0.5461538462,
"autogenerated": false,
"ratio": 3.8844621513944224,
"config_tes... |
# Adapted from http://stackoverflow.com/questions/110803/dirty-fields-in-django
from django import VERSION
from django.db.models.signals import post_save
class DirtyFieldsMixin(object):
def __init__(self, *args, **kwargs):
super(DirtyFieldsMixin, self).__init__(*args, **kwargs)
post_save.connect(r... | {
"repo_name": "georgemarshall/django-dirtyfields",
"path": "src/dirtyfields/dirtyfields.py",
"copies": "1",
"size": "1579",
"license": "bsd-3-clause",
"hash": 2485454510257850000,
"line_mean": 36.5952380952,
"line_max": 101,
"alpha_frac": 0.6402786574,
"autogenerated": false,
"ratio": 3.759523809... |
# Adapted from http://stackoverflow.com/questions/110803/dirty-fields-in-django
from django import VERSION
from django.db.models.signals import post_save, pre_save
def reset_instance(instance, *args, **kwargs):
"""
Called on the post_save signal. Calls the instance's _reset_state method
"""
instance._... | {
"repo_name": "mattcaldwell/django-dirtyfields",
"path": "dirtyfields/dirtyfields.py",
"copies": "1",
"size": "4724",
"license": "bsd-3-clause",
"hash": -2903478219675516000,
"line_mean": 39.3760683761,
"line_max": 103,
"alpha_frac": 0.5990685859,
"autogenerated": false,
"ratio": 4.16578483245149... |
# Adapted from http://stackoverflow.com/questions/110803/dirty-fields-in-django
from django.db.models.signals import post_save
from django.db.models.fields.related import ManyToManyField
class DirtyFieldsMixin(object):
check_relationship = False
def __init__(self, *args, **kwargs):
super(DirtyFields... | {
"repo_name": "ivelum/django-dirtyfields",
"path": "src/dirtyfields/dirtyfields.py",
"copies": "1",
"size": "2624",
"license": "bsd-3-clause",
"hash": 168473684608636770,
"line_mean": 33.5263157895,
"line_max": 79,
"alpha_frac": 0.6261432927,
"autogenerated": false,
"ratio": 4.074534161490683,
... |
# Adapted from http://stackoverflow.com/questions/110803/dirty-fields-in-django
from django.db.models.signals import post_save
import copy
class DirtyFieldsMixin(object):
def __init__(self, *args, **kwargs):
super(DirtyFieldsMixin, self).__init__(*args, **kwargs)
post_save.connect(reset_state,
... | {
"repo_name": "ActivKonnect/django-dirtyfields",
"path": "src/dirtyfields/dirtyfields.py",
"copies": "1",
"size": "1477",
"license": "bsd-3-clause",
"hash": 2182352157063341800,
"line_mean": 34.1666666667,
"line_max": 79,
"alpha_frac": 0.5666892349,
"autogenerated": false,
"ratio": 4.068870523415... |
# Adapted from http://stackoverflow.com/questions/110803/dirty-fields-in-django
from django.db.models.signals import post_save
class DirtyFieldsMixin(object):
def __init__(self, *args, **kwargs):
super(DirtyFieldsMixin, self).__init__(*args, **kwargs)
post_save.connect(reset_state, sender=self.__... | {
"repo_name": "akadan47/django-dirtyfields",
"path": "src/dirtyfields/dirtyfields.py",
"copies": "1",
"size": "1161",
"license": "bsd-3-clause",
"hash": 4384129551136021000,
"line_mean": 37.7,
"line_max": 109,
"alpha_frac": 0.6347975883,
"autogenerated": false,
"ratio": 3.6857142857142855,
"con... |
# Adapted from http://stackoverflow.com/questions/110803/dirty-fields-in-django
import copy
from django.db.models.signals import post_save
import django.dispatch
def _iter_fields(obj):
for field in obj._meta.local_fields:
if not field.rel:
yield field, field.to_python(getattr(obj, field.name... | {
"repo_name": "public/django-dirtyfields",
"path": "src/dirtyfields/dirtyfields.py",
"copies": "1",
"size": "1499",
"license": "bsd-3-clause",
"hash": 1744444564312487200,
"line_mean": 23.5737704918,
"line_max": 79,
"alpha_frac": 0.6010673783,
"autogenerated": false,
"ratio": 3.7196029776674937,
... |
# Adapted from http://stackoverflow.com/questions/110803
# and https://github.com/callowayproject/django-dirtyfields
# and https://github.com/smn/django-dirtyfields
import copy
from django import VERSION
from django.conf import settings
from django.db import router
from django.db.models import signals
def stale_cop... | {
"repo_name": "zapier/django-stalefields",
"path": "stalefields/stalefields.py",
"copies": "1",
"size": "6898",
"license": "bsd-3-clause",
"hash": -6044791152309148000,
"line_mean": 38.4171428571,
"line_max": 126,
"alpha_frac": 0.6064076544,
"autogenerated": false,
"ratio": 4.137972405518896,
"... |
# Adapted from https://www.kaggle.com/c/cdiscount-image-classification-challenge/discussion/41021
import os
import cv2
import time
import glob
import numpy as np
import pandas as pd
# Import torch-related functions
import torch
import torch.nn.functional as F
from torch.autograd import Variable
# Dataset
PROJECT_NAME... | {
"repo_name": "nixingyang/Kaggle-Face-Verification",
"path": "Cdiscount Image Classification/inference_HengCherKeng.py",
"copies": "1",
"size": "8676",
"license": "mit",
"hash": 7654389912968058000,
"line_mean": 45.6451612903,
"line_max": 187,
"alpha_frac": 0.6680497925,
"autogenerated": false,
"... |
# Adapted from: https://www.tensorflow.org/beta/tutorials/distribute/multi_worker_with_estimator
from __future__ import absolute_import, division, print_function, unicode_literals
def main_fun(args, ctx):
import numpy as np
import tensorflow as tf
import tensorflow_datasets as tfds
from tensorflowonspark imp... | {
"repo_name": "yahoo/TensorFlowOnSpark",
"path": "examples/mnist/estimator/mnist_pipeline.py",
"copies": "1",
"size": "8062",
"license": "apache-2.0",
"hash": 119764033514177900,
"line_mean": 40.3435897436,
"line_max": 134,
"alpha_frac": 0.6875465145,
"autogenerated": false,
"ratio": 3.5452946350... |
# Adapted from: https://www.tensorflow.org/beta/tutorials/distribute/multi_worker_with_estimator
def main_fun(args, ctx):
import numpy as np
import tensorflow as tf
import tensorflow_datasets as tfds
from tensorflowonspark import TFNode
strategy = tf.distribute.experimental.MultiWorkerMirroredStrategy()
... | {
"repo_name": "yahoo/TensorFlowOnSpark",
"path": "examples/mnist/estimator/mnist_spark.py",
"copies": "1",
"size": "6581",
"license": "apache-2.0",
"hash": -260550140453707550,
"line_mean": 41.4580645161,
"line_max": 187,
"alpha_frac": 0.6998936332,
"autogenerated": false,
"ratio": 3.521134296415... |
# Adapted from: https://www.tensorflow.org/beta/tutorials/distribute/multi_worker_with_estimator
def main_fun(args, ctx):
import tensorflow_datasets as tfds
import tensorflow as tf
BUFFER_SIZE = args.buffer_size
BATCH_SIZE = args.batch_size
LEARNING_RATE = args.learning_rate
def input_fn(mode, input_con... | {
"repo_name": "yahoo/TensorFlowOnSpark",
"path": "examples/mnist/estimator/mnist_tf.py",
"copies": "1",
"size": "4659",
"license": "apache-2.0",
"hash": 8661494634531110000,
"line_mean": 42.1388888889,
"line_max": 208,
"alpha_frac": 0.6915647135,
"autogenerated": false,
"ratio": 3.597683397683397... |
# Adapted from: https://www.tensorflow.org/beta/tutorials/distribute/multi_worker_with_keras
from __future__ import absolute_import, division, print_function, unicode_literals
def main_fun(args, ctx):
"""Example demonstrating loading TFRecords directly from disk (e.g. HDFS) without tensorflow_datasets."""
import... | {
"repo_name": "yahoo/TensorFlowOnSpark",
"path": "examples/mnist/keras/mnist_tf_ds.py",
"copies": "1",
"size": "5540",
"license": "apache-2.0",
"hash": 6679479221067892000,
"line_mean": 45.9491525424,
"line_max": 168,
"alpha_frac": 0.7151624549,
"autogenerated": false,
"ratio": 3.4155363748458694... |
# Adapted from http://wiki.python.org/moin/PythonDecoratorLibrary#Cached_Properties
import itertools
import time
from .decorators import wraps
from .python_compat import iteritems
from logging import getLogger
from types import MethodType, FunctionType
logger = getLogger(__name__)
class cached_property(object):
"... | {
"repo_name": "Infinidat/infi.pyutils",
"path": "infi/pyutils/lazy.py",
"copies": "1",
"size": "9213",
"license": "bsd-3-clause",
"hash": -6182288365175713000,
"line_mean": 35.5595238095,
"line_max": 127,
"alpha_frac": 0.599044828,
"autogenerated": false,
"ratio": 4.16500904159132,
"config_test... |
# adapted from http://www.nightmare.com/rushing/python/countmin.py
# estimate top k from a stream using a 'count-min' sketch and heap.
# based on https://github.com/ezyang/ocaml-cminsketch
# use gen-data.py to generate a data file
# usage
# python gen-data.py > dat.txt
# python countmin.py dat.txt
import heapq
imp... | {
"repo_name": "mitdbg/asciiclass",
"path": "lectures/lec10/countmin.py",
"copies": "3",
"size": "4043",
"license": "mit",
"hash": 957780748457707100,
"line_mean": 26.3175675676,
"line_max": 79,
"alpha_frac": 0.4907247094,
"autogenerated": false,
"ratio": 3.2112787926926134,
"config_test": false... |
# adapted from http://www.pygame.org/wiki/OBJFileLoader
import os
import cv2
import numpy as np
from visnav.algo import tools
def MTL(filename):
contents = {}
mtl = None
for line in open(filename, "r"):
if line.startswith('#'): continue
values = line.split()
if not values: continue
... | {
"repo_name": "oknuutti/visnav-py",
"path": "visnav/iotools/objloader.py",
"copies": "1",
"size": "9954",
"license": "mit",
"hash": -6774647881378110000,
"line_mean": 39.962962963,
"line_max": 118,
"alpha_frac": 0.5134619249,
"autogenerated": false,
"ratio": 3.532292405961675,
"config_test": fa... |
# Adapted from Jinja2. Jinja2 is (c) 2017 by the Jinja Team, licensed under the BSD license.
from typing import Union
binary_prefixes = ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
decimal_prefixes = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
def filesizeformat(value: Union[int, float], binary: boo... | {
"repo_name": "valohai/valohai-cli",
"path": "valohai_cli/utils/file_size_format.py",
"copies": "1",
"size": "1054",
"license": "mit",
"hash": -4481390251797432300,
"line_mean": 39.5384615385,
"line_max": 92,
"alpha_frac": 0.5948766603,
"autogenerated": false,
"ratio": 3.346031746031746,
"confi... |
# Adapted from Joe Birch's post: https://blog.bitrise.io/automating-code-review-tasks-for-multi-module-android-projects
# This takes all of our ktlint output XML files and combines them into one `ktlint-report.xml` file.
# This way we can pass one file into danger-checkstyle_format
import sys
import os.path
from xml.e... | {
"repo_name": "AdamMc331/CashCaretaker",
"path": "scripts/combine_ktlint_reports.py",
"copies": "1",
"size": "1791",
"license": "mit",
"hash": -7852619629714822000,
"line_mean": 29.8965517241,
"line_max": 119,
"alpha_frac": 0.7213847013,
"autogenerated": false,
"ratio": 3.1039861351819757,
"con... |
# Adapted from Keras source code
# License: https://github.com/fchollet/keras/blob/master/LICENSE
import itertools
from keras.layers.containers import Graph, Sequential
from keras.layers.core import Merge
try:
# pydot-ng is a fork of pydot that is better maintained
import pydot_ng as pydot
except ImportError:... | {
"repo_name": "jisraeli/dragonn",
"path": "dragonn/visualize_util.py",
"copies": "2",
"size": "5953",
"license": "mit",
"hash": 5907687212018057000,
"line_mean": 36.9171974522,
"line_max": 79,
"alpha_frac": 0.5797077104,
"autogenerated": false,
"ratio": 4.108350586611456,
"config_test": false,
... |
# Adapted from Kevin Keraudren's code at https://github.com/kevin-keraudren/randomforest-python
import numpy as np
from tree import *
import os
from glob import glob
import shutil
import itertools
import multiprocessing as mp
from weakLearner import WeakLearner, AxisAligned
def _grow_trees(params):
thread_id, p... | {
"repo_name": "grantathon/computer_vision_machine_learning",
"path": "project/randomforest/forest.py",
"copies": "1",
"size": "2984",
"license": "mit",
"hash": 686679297107518600,
"line_mean": 25.8828828829,
"line_max": 95,
"alpha_frac": 0.5154155496,
"autogenerated": false,
"ratio": 4.0161507402... |
# Adapted from lightning
import pickle
import numpy as np
from numpy.testing import (assert_almost_equal, assert_array_equal,
assert_equal)
from modl.utils.randomkit import RandomState
def test_random():
rs = RandomState(seed=0)
vals = [rs.randint(10) for t in range(10000)]
ass... | {
"repo_name": "arthurmensch/modl",
"path": "modl/utils/randomkit/tests/test_random.py",
"copies": "1",
"size": "1362",
"license": "bsd-2-clause",
"hash": 1798569976198477800,
"line_mean": 27.9787234043,
"line_max": 67,
"alpha_frac": 0.6292217327,
"autogenerated": false,
"ratio": 2.861344537815126... |
# Adapted from Matlab to Python by Jon Crall
# Original Matlab Source:
# http://www.mathworks.se/matlabcentral/fileexchange/36657-fast-bilateral-filter/content/FastBilateralFilter/shiftableBF.m
# These are shorthands I used to help with porting 1 based to 0 based
# [k] = 2:end
# [-k-1] = fliplr(1:end-1)
#... | {
"repo_name": "SU-ECE-17-7/hotspotter",
"path": "hstpl/other/shiftableBF.py",
"copies": "2",
"size": "6577",
"license": "apache-2.0",
"hash": 2168533983182901000,
"line_mean": 31.7213930348,
"line_max": 122,
"alpha_frac": 0.5187775582,
"autogenerated": false,
"ratio": 2.890989010989011,
"config... |
from ntlm import HTTPNtlmAuthHandler
import xml.etree.ElementTree as et
import uuid, urllib2, urlparse
class SoapService:
NS_SOAP_ENV = "{http://schemas.xmlsoap.org/soap/envelope/}"
NS_XSI = "{http://www.w3.org/2001/XMLSchema-instance}"
NS_XSD = "{http://www.w3.org/2001/XMLSchema}"
def __init__(self... | {
"repo_name": "madzak/tfs-git-hook",
"path": "lib/tfs.py",
"copies": "1",
"size": "6355",
"license": "bsd-2-clause",
"hash": -3186517757871922000,
"line_mean": 38.2283950617,
"line_max": 153,
"alpha_frac": 0.6207710464,
"autogenerated": false,
"ratio": 3.767042086544161,
"config_test": false,
... |
elif x[0] == 'if': # (if test conseq alt)
if len(x) == 4:
(_, test, conseq, alt) = x
elif len(x) == 3:
(_, test, conseq) = x
alt = None
if eval(test, env):
return eval(conseq, env)
elif alt:
return eval(alt, env... | {
"repo_name": "kbase/assembly",
"path": "lib/assembly/wasp.py",
"copies": "1",
"size": "19952",
"license": "mit",
"hash": 4523150534895927300,
"line_mean": 34.9495495495,
"line_max": 132,
"alpha_frac": 0.5081696071,
"autogenerated": false,
"ratio": 3.90755973364669,
"config_test": false,
"has... |
elif x[0] == 'if': # (if test conseq alt)
(_, test, conseq, alt) = x
return eval((conseq if eval(test, env) else alt), env)
elif x[0] == 'set!': # (set! var exp)
(_, var, exp) = x
env.find(var)[var] = eval(exp, env)
elif x[0] == 'setparam':
(_,... | {
"repo_name": "levinas/assembly",
"path": "lib/assembly/wasp.py",
"copies": "2",
"size": "19138",
"license": "mit",
"hash": -8035814847772044000,
"line_mean": 35.0414312618,
"line_max": 132,
"alpha_frac": 0.5064270039,
"autogenerated": false,
"ratio": 3.9161039492531207,
"config_test": false,
... |
"""Adapted from Nematode: https://github.com/demelin/nematode """
import sys
import tensorflow as tf
from tensorflow.python.ops.init_ops import glorot_uniform_initializer
# ModuleNotFoundError is new in 3.6; older versions will throw SystemError
if sys.version_info < (3, 6):
ModuleNotFoundError = SystemError
try... | {
"repo_name": "EdinburghNLP/nematus",
"path": "nematus/transformer_attention_modules.py",
"copies": "1",
"size": "24243",
"license": "bsd-3-clause",
"hash": -4614031530207206000,
"line_mean": 49.2966804979,
"line_max": 135,
"alpha_frac": 0.5527368725,
"autogenerated": false,
"ratio": 4.2524118575... |
"""Adapted from Nematode: https://github.com/demelin/nematode """
import sys
import tensorflow as tf
import numpy
# ModuleNotFoundError is new in 3.6; older versions will throw SystemError
if sys.version_info < (3, 6):
ModuleNotFoundError = SystemError
try:
from . import model_inputs
from . import mrt_ut... | {
"repo_name": "EdinburghNLP/nematus",
"path": "nematus/transformer.py",
"copies": "1",
"size": "18824",
"license": "bsd-3-clause",
"hash": 8521944491262957000,
"line_mean": 45.7096774194,
"line_max": 117,
"alpha_frac": 0.5450488738,
"autogenerated": false,
"ratio": 4.5711510441962115,
"config_t... |
"""Adapted from Nematode: https://github.com/demelin/nematode """
import sys
import tensorflow as tf
# ModuleNotFoundError is new in 3.6; older versions will throw SystemError
if sys.version_info < (3, 6):
ModuleNotFoundError = SystemError
try:
from . import tf_utils
from .transformer import INT_DTYPE, F... | {
"repo_name": "EdinburghNLP/nematus",
"path": "nematus/transformer_inference.py",
"copies": "1",
"size": "8088",
"license": "bsd-3-clause",
"hash": -5883049761063383000,
"line_mean": 39.0396039604,
"line_max": 94,
"alpha_frac": 0.5675074184,
"autogenerated": false,
"ratio": 4.265822784810126,
"... |
"""Adapted from Nematode: https://github.com/demelin/nematode """
import tensorflow as tf
from tensorflow.python.ops.init_ops import glorot_uniform_initializer
from transformer_layers import \
get_shape_list, \
FeedForwardLayer, \
matmul_nd
class MultiHeadAttentionLayer(object):
""" Defines the mult... | {
"repo_name": "rsennrich/nematus",
"path": "nematus/transformer_attention_modules.py",
"copies": "1",
"size": "23162",
"license": "bsd-3-clause",
"hash": 462439565097547800,
"line_mean": 49.4618736383,
"line_max": 119,
"alpha_frac": 0.5470598394,
"autogenerated": false,
"ratio": 4.286877660558948... |
"""Adapted from Nematode: https://github.com/demelin/nematode """
import tensorflow as tf
import numpy
import model_inputs
from transformer_layers import \
EmbeddingLayer, \
MaskedCrossEntropy, \
get_shape_list, \
get_right_context_mask, \
get_positional_signal
from transformer_blocks import Atten... | {
"repo_name": "rsennrich/nematus",
"path": "nematus/transformer.py",
"copies": "1",
"size": "18170",
"license": "bsd-3-clause",
"hash": 1345388726622965500,
"line_mean": 47.5828877005,
"line_max": 126,
"alpha_frac": 0.5323059989,
"autogenerated": false,
"ratio": 4.651817716333845,
"config_test"... |
"""Adapted from Nematode: https://github.com/demelin/nematode """
import tensorflow as tf
from transformer_layers import \
get_shape_list, \
get_positional_signal
def sample(session, model, x, x_mask, graph=None):
"""Randomly samples from a Transformer translation model.
Args:
session: Tenso... | {
"repo_name": "rsennrich/nematus",
"path": "nematus/transformer_inference.py",
"copies": "1",
"size": "33603",
"license": "bsd-3-clause",
"hash": -5566696101750246000,
"line_mean": 49.8366111952,
"line_max": 128,
"alpha_frac": 0.6047376722,
"autogenerated": false,
"ratio": 4.217243975903615,
"c... |
"""Adapted from Nematode: https://github.com/demelin/nematode """
import tensorflow as tf
from transformer_layers import \
ProcessingLayer, \
FeedForwardNetwork
from transformer_attention_modules import MultiHeadAttentionLayer
# from attention_modules import SingleHeadAttentionLayer, FineGrainedAttentionLa... | {
"repo_name": "rsennrich/nematus",
"path": "nematus/transformer_blocks.py",
"copies": "1",
"size": "5479",
"license": "bsd-3-clause",
"hash": -8484212468743595000,
"line_mean": 44.2809917355,
"line_max": 119,
"alpha_frac": 0.4822047819,
"autogenerated": false,
"ratio": 5.008226691042047,
"confi... |
"""Adapted from Nematode: https://github.com/demelin/nematode """
# TODO: Add an attention visualization component - very important (~easy)
""" Layer implementations. """
import numpy as np
import tensorflow as tf
from tensorflow.python.ops.init_ops import glorot_uniform_initializer
def matmul_nd(nd_tensor, matrix... | {
"repo_name": "rsennrich/nematus",
"path": "nematus/transformer_layers.py",
"copies": "1",
"size": "19406",
"license": "bsd-3-clause",
"hash": 3109951363511687700,
"line_mean": 45.9878934625,
"line_max": 124,
"alpha_frac": 0.5767803772,
"autogenerated": false,
"ratio": 4.308614564831261,
"confi... |
"""Adapted from Nematode: https://github.com/demelin/nematode """
# TODO: Add an attention visualization component - very important (~easy)
""" Layer implementations. """
import sys
import numpy as np
import tensorflow as tf
from tensorflow.python.ops.init_ops import glorot_uniform_initializer
# ModuleNotFoundError... | {
"repo_name": "EdinburghNLP/nematus",
"path": "nematus/transformer_layers.py",
"copies": "1",
"size": "20686",
"license": "bsd-3-clause",
"hash": -7928485361675858000,
"line_mean": 46.4449541284,
"line_max": 146,
"alpha_frac": 0.5801024848,
"autogenerated": false,
"ratio": 4.253752827472754,
"c... |
from random import random
from math import log, ceil
class Node(object):
__slots__ = 'value', 'next', 'width'
def __init__(self, value, next, width):
self.value, self.next, self.width = value, next, width
class End(object):
'Sentinel object that always compares greater than another object'
def... | {
"repo_name": "isdal/raspberrypi-fan-controller",
"path": "running_median/__init__.py",
"copies": "1",
"size": "3310",
"license": "apache-2.0",
"hash": 8865347572014921000,
"line_mean": 34.9891304348,
"line_max": 82,
"alpha_frac": 0.5734138973,
"autogenerated": false,
"ratio": 3.7401129943502824,... |
# adapted from:
# https://gist.github.com/cliffano/9868180
# https://github.com/petems/ansible-json.git
# https://github.com/jlafon/ansible-profile
# https://github.com/kalosoid/ansible-sumo-logs
import json
import logging
import logging.handlers
import uuid
import platform
import time
from datetime import dat... | {
"repo_name": "gadouryd/ansible-to-sumo",
"path": "plugins/callback/sumo_logs.py",
"copies": "3",
"size": "5346",
"license": "mit",
"hash": -7385371099894007000,
"line_mean": 30.8214285714,
"line_max": 144,
"alpha_frac": 0.5993265993,
"autogenerated": false,
"ratio": 3.5616255829447034,
"config... |
# Adapted from
# https://gist.github.com/jtriley/1108174
# pylint: disable=bare-except,unpacking-non-sequence
import os
import shlex
import struct
import platform
import subprocess
def get_terminal_size():
""" getTerminalSize()
- get width and height of console
- works on linux,os x,windows,cygwin(windo... | {
"repo_name": "chase-qi/workload-automation",
"path": "wlauto/utils/terminalsize.py",
"copies": "4",
"size": "2862",
"license": "apache-2.0",
"hash": -1028641405077686400,
"line_mean": 29.7741935484,
"line_max": 104,
"alpha_frac": 0.5828092243,
"autogenerated": false,
"ratio": 3.5116564417177916,... |
# Adapted from
# https://github.com/codekansas/keras-language-modeling/blob/master/attention_lstm.py
# Licensed under MIT
from __future__ import absolute_import
import keras
from keras.layers import LSTM, activations
class AttentionLSTM(LSTM):
def __init__(self, output_dim, attention_vec, attn_activation='tanh',... | {
"repo_name": "UKPLab/semeval2017-scienceie",
"path": "code/attention_lstm.py",
"copies": "1",
"size": "3078",
"license": "apache-2.0",
"hash": 967699502250229200,
"line_mean": 44.2647058824,
"line_max": 107,
"alpha_frac": 0.6328784925,
"autogenerated": false,
"ratio": 3.320388349514563,
"confi... |
# adapted from
# https://github.com/leporo/tornado-redis/blob/master/demos/websockets
from json import loads, dumps
from itertools import chain
import toredis
from tornado.web import authenticated
from tornado.websocket import WebSocketHandler
from tornado.gen import engine, Task
from future.utils import viewvalues
f... | {
"repo_name": "adamrp/qiita",
"path": "qiita_pet/handlers/websocket_handlers.py",
"copies": "1",
"size": "4398",
"license": "bsd-3-clause",
"hash": 3708839880658285600,
"line_mean": 35.0491803279,
"line_max": 78,
"alpha_frac": 0.6457480673,
"autogenerated": false,
"ratio": 4.311764705882353,
"c... |
# adapted from
# https://github.com/leporo/tornado-redis/blob/master/demos/websockets
from json import loads
import toredis
from tornado.web import authenticated
from tornado.websocket import WebSocketHandler
from tornado.gen import engine, Task
from moi import r_client
class MessageHandler(WebSocketHandler):
d... | {
"repo_name": "wasade/qiita",
"path": "qiita_pet/handlers/websocket_handlers.py",
"copies": "1",
"size": "2506",
"license": "bsd-3-clause",
"hash": -5054827661224869000,
"line_mean": 33.8055555556,
"line_max": 77,
"alpha_frac": 0.6508379888,
"autogenerated": false,
"ratio": 4.335640138408304,
"... |
# Adapted from
# https://github.com/pytorch/pytorch/blob/master/torch/nn/utils/weight_norm.py
# and https://github.com/salesforce/awd-lstm-lm/blob/master/weight_drop.py
import logging
import torch
from torch.nn import Parameter
from functools import wraps
def _norm(p, dim):
"""Computes the norm over all dimensio... | {
"repo_name": "eladhoffer/seq2seq.pytorch",
"path": "seq2seq/models/modules/weight_norm.py",
"copies": "1",
"size": "3220",
"license": "mit",
"hash": 685610828713549400,
"line_mean": 33.623655914,
"line_max": 81,
"alpha_frac": 0.5875776398,
"autogenerated": false,
"ratio": 3.7139561707035758,
"... |
# adapted from
# http://smallshire.org.uk/sufficientlysmall/2010/04/11/\
# a-hindley-milner-type-inference-implementation-in-python/
import gast
from copy import deepcopy
from numpy import floating, integer, complexfloating
from pythran.tables import MODULES, attributes
import pythran.typing as typing
from pyt... | {
"repo_name": "serge-sans-paille/pythran",
"path": "pythran/types/tog.py",
"copies": "1",
"size": "48907",
"license": "bsd-3-clause",
"hash": 4419343780957692400,
"line_mean": 33.3448033708,
"line_max": 80,
"alpha_frac": 0.5302103993,
"autogenerated": false,
"ratio": 4.117444014143795,
"config_... |
# Adapted from
# https://matplotlib.org/examples/user_interfaces/embedding_in_tk.html
# This gives the standard matplotlib interface, which for many applications would be
# great. But I just want a static plot...
# - Could just not use the `toolbar`
import matplotlib
print("Default backend appears to be:", matplotl... | {
"repo_name": "QuantCrimAtLeeds/PredictCode",
"path": "open_cp/snippets/matplotlib_in_tk.py",
"copies": "1",
"size": "2090",
"license": "artistic-2.0",
"hash": 5935038219444695000,
"line_mean": 27.2567567568,
"line_max": 88,
"alpha_frac": 0.719138756,
"autogenerated": false,
"ratio": 3.0289855072... |
# Adapted from
# http://stackoverflow.com/questions/12301071/multidimensional-confidence-intervals
from matplotlib.patches import Ellipse
from matplotlib.pylab import *
import numpy as np
def plot_cov_ellipse(cov, pos, nstd=2, ax=None, **kwargs):
"""
Plots an `nstd` sigma error ellipse based on the specified ... | {
"repo_name": "rjw57/starman",
"path": "doc/plotutils.py",
"copies": "1",
"size": "1979",
"license": "mit",
"hash": -5045370043697836000,
"line_mean": 32.5423728814,
"line_max": 83,
"alpha_frac": 0.6452753916,
"autogenerated": false,
"ratio": 3.572202166064982,
"config_test": false,
"has_no_k... |
"""Adapted from:
@longcw faster_rcnn_pytorch: https://github.com/longcw/faster_rcnn_pytorch
@rbgirshick py-faster-rcnn https://github.com/rbgirshick/py-faster-rcnn
Licensed under The MIT License [see LICENSE for details]
"""
from __future__ import print_function
from utils.pytorch_parameters import VOC_CLA... | {
"repo_name": "oarriaga/single_shot_multibox_detector",
"path": "src/evaluate.py",
"copies": "1",
"size": "15854",
"license": "mit",
"hash": -3218134673464111000,
"line_mean": 35.6143187067,
"line_max": 79,
"alpha_frac": 0.5490727892,
"autogenerated": false,
"ratio": 3.3789428815004263,
"config... |
import bcrypt
from website import settings
def generate_password_hash(password, rounds=None):
"""Generates a password hash using `bcrypt`. Specifying `log_rounds` sets
the log_rounds parameter of `bcrypt.gensalt()` which determines the
complexity of the salt. 12 is the default value.
Returns the hash... | {
"repo_name": "adlius/osf.io",
"path": "framework/bcrypt/__init__.py",
"copies": "6",
"size": "1516",
"license": "apache-2.0",
"hash": -2756777924942150700,
"line_mean": 23.0634920635,
"line_max": 77,
"alpha_frac": 0.6431398417,
"autogenerated": false,
"ratio": 3.7339901477832513,
"config_test"... |
import bcrypt
from website import settings
def generate_password_hash(password, rounds=None):
'''Generates a password hash using `bcrypt`. Specifying `log_rounds` sets
the log_rounds parameter of `bcrypt.gensalt()` which determines the
complexity of the salt. 12 is the default value.
Returns the hash... | {
"repo_name": "doublebits/osf.io",
"path": "framework/bcrypt/__init__.py",
"copies": "62",
"size": "1564",
"license": "apache-2.0",
"hash": -8834487231165424000,
"line_mean": 23.8253968254,
"line_max": 77,
"alpha_frac": 0.6445012788,
"autogenerated": false,
"ratio": 3.688679245283019,
"config_t... |
import bcrypt
from website import settings
def generate_password_hash(password, rounds=None):
"""Generates a password hash using `bcrypt`. Specifying `log_rounds` sets
the log_rounds parameter of `bcrypt.gensalt()` which determines the
complexity of the salt. 12 is the default value.
Returns the hash... | {
"repo_name": "HalcyonChimera/osf.io",
"path": "framework/bcrypt/__init__.py",
"copies": "8",
"size": "1564",
"license": "apache-2.0",
"hash": -1382400554379888400,
"line_mean": 23.8253968254,
"line_max": 77,
"alpha_frac": 0.6445012788,
"autogenerated": false,
"ratio": 3.688679245283019,
"confi... |
import bcrypt
_log_rounds = [12]
def generate_password_hash(password, rounds=None):
'''Generates a password hash using `bcrypt`. Specifying `log_rounds` sets
the log_rounds parameter of `bcrypt.gensalt()` which determines the
complexity of the salt. 12 is the default value.
Returns the hashed passw... | {
"repo_name": "GaryKriebel/osf.io",
"path": "framework/bcrypt/__init__.py",
"copies": "11",
"size": "1544",
"license": "apache-2.0",
"hash": -8977148429624079000,
"line_mean": 22.7538461538,
"line_max": 77,
"alpha_frac": 0.6353626943,
"autogenerated": false,
"ratio": 3.624413145539906,
"config_... |
# --------------------------------------------------------
# Fully Convolutional Instance-aware Semantic Segmentation
# Copyright (c) 2017 Microsoft
# Licensed under The Apache-2.0 License [see LICENSE for details]
# Written by Haochen Zhang
# --------------------------------------------------------
import numpy as n... | {
"repo_name": "vincentlooi/FCIS",
"path": "lib/utils/show_masks.py",
"copies": "1",
"size": "2454",
"license": "apache-2.0",
"hash": 3907408163121617000,
"line_mean": 40.593220339,
"line_max": 124,
"alpha_frac": 0.5150774246,
"autogenerated": false,
"ratio": 3.1181702668360862,
"config_test": f... |
# Adapted from
###########################################################################
# pbkdf2 - PKCS#5 v2.0 Password-Based Key Derivation #
# #
# Copyright (C) 2007-2011 Dwayne C. Litzenberger <dlitz@dlitz.net> #
#... | {
"repo_name": "quantmind/lux",
"path": "lux/utils/crypt/pbkdf2.py",
"copies": "1",
"size": "10785",
"license": "bsd-3-clause",
"hash": 6673127586773677000,
"line_mean": 34.8305647841,
"line_max": 78,
"alpha_frac": 0.5844228095,
"autogenerated": false,
"ratio": 4.1624855268236205,
"config_test":... |
"""Adapted from
sphinx.transforms.post_transforms.ReferencesResolver.resolve_anyref
If 'py' is one of the domains and `py:class` is defined,
the Python domain will be processed before the 'std' domain.
License for Sphinx
==================
Copyright (c) 2007-2019 by the Sphinx team (see AUTHORS file).
All rights res... | {
"repo_name": "mbeyeler/pulse2percept",
"path": "doc/_ext/custom_references_resolver.py",
"copies": "2",
"size": "5233",
"license": "bsd-3-clause",
"hash": 2802063057664619000,
"line_mean": 41.5447154472,
"line_max": 79,
"alpha_frac": 0.6273648003,
"autogenerated": false,
"ratio": 4.4460492778249... |
# Adapted from
# Transifex, https://github.com/transifex/transifex/blob/master/transifex/resources/formats/strings.py
# localizable https://github.com/chrisballinger/python-localizable/blob/master/localizable.py
# -*- coding: utf-8 -*-
# GPLv2
"""
Apple strings file handler/compiler
"""
from __future__ import print_fu... | {
"repo_name": "metasmile/transync",
"path": "strsync/strparser.py",
"copies": "2",
"size": "3809",
"license": "mit",
"hash": -2948284440874760700,
"line_mean": 31.2796610169,
"line_max": 169,
"alpha_frac": 0.5607771069,
"autogenerated": false,
"ratio": 3.4595821980018164,
"config_test": false,
... |
import collections
import contextlib
import logging
import os
import shutil
import subprocess
import sys
import tempfile
from PIL import Image
def _images_are_equal(filename1, filename2):
# We need to convert both images to the same format, as the resulting one
# may have lost the alpha channel (alpha=255) o... | {
"repo_name": "jpscaletti/moar",
"path": "moar/optimage.py",
"copies": "2",
"size": "7743",
"license": "mit",
"hash": -832543496685370400,
"line_mean": 32.6652173913,
"line_max": 80,
"alpha_frac": 0.6471651815,
"autogenerated": false,
"ratio": 4.070977917981073,
"config_test": false,
"has_no_... |
# Adapted from Parag K. Mital, Jan 2016 convolutional_autoencoder.py
import tensorflow as tf
import numpy as np
import numpy.matlib as matlib
import math
from libs.activations import lrelu
from libs.utils import corrupt
DEFAULT_IMAGE_SIZE = 128;
def autoencoder(input_shape=[None, DEFAULT_IMAGE_SIZE*DEFAULT_IMAGE_SIZ... | {
"repo_name": "apoorva-sharma/deep-frame-interpolation",
"path": "conv_auto_threechannel.py",
"copies": "1",
"size": "5777",
"license": "mit",
"hash": 1982798716517226800,
"line_mean": 33.3869047619,
"line_max": 120,
"alpha_frac": 0.6048121863,
"autogenerated": false,
"ratio": 3.5507068223724647,... |
""" adapted from phidl.Geometry
"""
import rectpack
import numpy as np
from pp.component import Component
from numpy import ndarray
from typing import Any, Dict, List, Tuple
def _pack_single_bin(
rect_dict: Dict[int, Tuple[int, int]],
aspect_ratio: Tuple[int, int],
max_size: ndarray,
sort_by_area: bo... | {
"repo_name": "psiq/gdsfactory",
"path": "pp/pack.py",
"copies": "1",
"size": "6854",
"license": "mit",
"hash": -4270698949828082000,
"line_mean": 33.6161616162,
"line_max": 126,
"alpha_frac": 0.5922089291,
"autogenerated": false,
"ratio": 3.5112704918032787,
"config_test": false,
"has_no_key... |
"""adapted from phidl.routing
temporary solution until we add Sbend routing functionality
"""
from typing import Optional
import gdspy
import numpy as np
from numpy import cos, mod, pi, sin
from numpy.linalg import norm
from pp.cell import cell
from pp.component import Component
from pp.config import TECH
from pp.sna... | {
"repo_name": "gdsfactory/gdsfactory",
"path": "pp/routing/routing.py",
"copies": "1",
"size": "41794",
"license": "mit",
"hash": -6407945316558603000,
"line_mean": 34.5693617021,
"line_max": 97,
"alpha_frac": 0.4698521319,
"autogenerated": false,
"ratio": 3.6150852002421936,
"config_test": fal... |
#Adapted from PIC
# This is sample code for learning the basics of the algorithm.
# It's not meant to be part of a production anti-spam system!
# Terrible for a large dataset
import sys
import os
import glob
import re
import math
import sqlite3
from decimal import *
DEFAULT_THRESHOLD = 0.7
def get_words(doc):
""... | {
"repo_name": "lrei/magical_code",
"path": "spamfilter.py",
"copies": "1",
"size": "8430",
"license": "mit",
"hash": -8115799704611686000,
"line_mean": 34.1291666667,
"line_max": 98,
"alpha_frac": 0.5723606168,
"autogenerated": false,
"ratio": 4.04510556621881,
"config_test": false,
"has_no_k... |
# adapted from pimoroni evdev support for the 7 inch capacitive screen
# added support for the resistive 3.5 and maybe others that doesn't depend upon SDL 1.2
import errno
import glob
import io
import os
import queue
import struct
import time
from collections import namedtuple
import logsupport
import config
import s... | {
"repo_name": "kevinkahn/softconsole",
"path": "touchhandler.py",
"copies": "1",
"size": "10413",
"license": "apache-2.0",
"hash": 4489486834519162400,
"line_mean": 24.7111111111,
"line_max": 108,
"alpha_frac": 0.6265245366,
"autogenerated": false,
"ratio": 2.7445967316816025,
"config_test": tr... |
# adapted from pydicom source code
from __version__ import __version__
__version_info__ = __version__.split('.')
# some imports
from applicationentity import AE
from SOPclass import \
VerificationSOPClass,\
StorageSOPClass,\
MRImageStorageSOPClass,\
CTImageStorageSOPClass,\
PositronEmissionTomogra... | {
"repo_name": "patmun/pynetdicom",
"path": "netdicom/__init__.py",
"copies": "2",
"size": "2877",
"license": "mit",
"hash": -3806404514835162000,
"line_mean": 35.417721519,
"line_max": 72,
"alpha_frac": 0.7765033021,
"autogenerated": false,
"ratio": 3.6279949558638083,
"config_test": false,
"... |
from __future__ import print_function
import os
import sys
import pkg_resources
import platform
from setuptools import setup, find_packages, Command
from setuptools.command.install_egg_info import install_egg_info as _install_egg_info
from setuptools.dist import Distribution
class EntryPoints(Command):
"""Get ... | {
"repo_name": "blankdots/pygradle-falcon-api",
"path": "setup.py",
"copies": "1",
"size": "6725",
"license": "apache-2.0",
"hash": 4947655725818165000,
"line_mean": 35.3513513514,
"line_max": 90,
"alpha_frac": 0.6316728625,
"autogenerated": false,
"ratio": 4.197877652933832,
"config_test": fals... |
# Adapted from py-l1tf here https://github.com/elsonidoq/py-l1tf/
from cvxopt import solvers, matrix
import l1
import numpy as np
solvers.options['show_progress'] = 0
from matrix_utils import *
def l1tf(y, alpha, period=0, eta=1.0, with_l1p=False, beta=0.0):
# scaling things to standardized size
y_min = float... | {
"repo_name": "dave31415/myl1tf",
"path": "myl1tf/myl1tf.py",
"copies": "1",
"size": "3664",
"license": "apache-2.0",
"hash": 9146451298056739000,
"line_mean": 25.7445255474,
"line_max": 90,
"alpha_frac": 0.5264737991,
"autogenerated": false,
"ratio": 2.7404637247569186,
"config_test": false,
... |
#Adapted from pySerial's Query COM Ports (http://pyserial.sourceforge.org) and Pavel Radzivilovsky (http://stackoverflow.com/questions/2937585/how-to-open-a-serial-port-by-friendly-name/2937588#2937588)
import serial
#setup environment using ctypes
import ctypes
from serial.win32 import ULONG_PTR, is_64bit
from ctypes... | {
"repo_name": "6ba1cbef/badgeup",
"path": "src/CPy27/badgeup/badgeup/COMBadge/SetupDeviceWrapper.py",
"copies": "1",
"size": "7875",
"license": "mit",
"hash": -7553666514904651000,
"line_mean": 36.6842105263,
"line_max": 202,
"alpha_frac": 0.6858412698,
"autogenerated": false,
"ratio": 3.37837837... |
#adapted from
#https://www.researchgate.net/publication/228966598_Optimal_Single_Biarc_Fitting_and_its_Applications
#calculates the biarc going through p0 and p1 with tangents t0 and t1
#respective. returns the homogeneous control points of a bezier curve
#defining the circular arcs.
def biarc_h(p0, t0, p1, t1, r... | {
"repo_name": "tarnheld/ted-editor",
"path": "cruft/old-biarc.py",
"copies": "1",
"size": "1929",
"license": "unlicense",
"hash": 8572040058868247000,
"line_mean": 23.72,
"line_max": 101,
"alpha_frac": 0.5272161742,
"autogenerated": false,
"ratio": 2.2456344586728756,
"config_test": false,
"h... |
''' Adapted from:
'''
import sys,getopt,struct,signal
from mod_debuggee_procedure_call import *
from pydbg import *
from pydbg.defines import *
from pydbg.pydbg_core import *
from pydbg_stack_dmp import *
from IPython.Shell import IPShellEmbed
import time
from subprocess import *
from mypdbg_bps import... | {
"repo_name": "deeso/python_scrirpts",
"path": "ida/mypdbg_interface.py",
"copies": "1",
"size": "9379",
"license": "apache-2.0",
"hash": -2333927574107269600,
"line_mean": 27.2242990654,
"line_max": 127,
"alpha_frac": 0.6200021324,
"autogenerated": false,
"ratio": 2.9064146265881625,
"config_t... |
# Adapted from rsted
import os
from os.path import join as J
from StringIO import StringIO
from docutils.core import publish_string, publish_parts
# see http://docutils.sourceforge.net/docs/user/config.html
default_rst_opts = {
'no_generator': True,
'no_source_link': True,
'tab_width': 4,
'file_insert... | {
"repo_name": "AcrDijon/henet",
"path": "henet/rst/rst2html.py",
"copies": "1",
"size": "1414",
"license": "apache-2.0",
"hash": 4134362435020623400,
"line_mean": 27.8571428571,
"line_max": 78,
"alpha_frac": 0.6357850071,
"autogenerated": false,
"ratio": 3.3908872901678655,
"config_test": false... |
# adapted from scikit-learn
"""Check whether we or not we should build the documentation
If the last commit message has a "[doc skip]" marker, do not build
the doc. On the contrary if a "[doc build]" marker is found, build the doc
instead of relying on the subsequent rules.
We always build the documentation for jobs ... | {
"repo_name": "kcompher/FreeDiscovUI",
"path": "build_tools/circle/check_build_doc.py",
"copies": "1",
"size": "2506",
"license": "bsd-3-clause",
"hash": -4921218578907263000,
"line_mean": 36.4029850746,
"line_max": 77,
"alpha_frac": 0.7158818835,
"autogenerated": false,
"ratio": 3.71259259259259... |
# Adapted from scikit learn
from operator import attrgetter
import inspect
import subprocess
import os
import sys
from functools import partial
REVISION_CMD = 'git rev-parse --short HEAD'
def _get_git_revision():
try:
revision = subprocess.check_output(REVISION_CMD.split()).strip()
except (subproces... | {
"repo_name": "rth/PyKrige",
"path": "doc/sphinxext/github_link.py",
"copies": "5",
"size": "2701",
"license": "bsd-3-clause",
"hash": 2432251983044790300,
"line_mean": 30.4069767442,
"line_max": 78,
"alpha_frac": 0.5808959645,
"autogenerated": false,
"ratio": 4.111111111111111,
"config_test": ... |
# Adapted from scikit learn
from operator import attrgetter
import inspect
import subprocess
import os
import sys
from functools import partial
REVISION_CMD = "git rev-parse --short HEAD"
def _get_git_revision():
try:
revision = subprocess.check_output(REVISION_CMD.split()).strip()
except (subproces... | {
"repo_name": "bsmurphy/PyKrige",
"path": "docs/source/sphinxext/github_link.py",
"copies": "1",
"size": "2645",
"license": "bsd-3-clause",
"hash": 2920548404126609000,
"line_mean": 30.1176470588,
"line_max": 85,
"alpha_frac": 0.593194707,
"autogenerated": false,
"ratio": 4.019756838905775,
"co... |
# Adapted from score written by wkentaro
# https://github.com/wkentaro/pytorch-fcn/blob/master/torchfcn/utils.py
import numpy as np
class runningScore(object):
def __init__(self, n_classes):
self.n_classes = n_classes
self.confusion_matrix = np.zeros((n_classes, n_classes))
def _fast_hist(se... | {
"repo_name": "meetshah1995/pytorch-semseg",
"path": "ptsemseg/metrics.py",
"copies": "1",
"size": "2166",
"license": "mit",
"hash": 5025356749440900000,
"line_mean": 29.9428571429,
"line_max": 96,
"alpha_frac": 0.5387811634,
"autogenerated": false,
"ratio": 3.3068702290076337,
"config_test": f... |
# Adapted from /seamless/stdlib/switch-join/switch-join.py
from seamless.highlevel import Context, Cell
from seamless import stdlib
ctx = Context()
ctx.include(stdlib.switch)
ctx.include(stdlib.join)
ctx.a = 10.0
ctx.a1 = Cell("float")
ctx.a2 = Cell("float")
ctx.a3 = Cell("float")
ctx.f1 = 2.0
ctx.f2 = 3.0
ctx.f3 = 4.... | {
"repo_name": "sjdv1982/seamless",
"path": "tests/highlevel/switch-join-stdlib.py",
"copies": "1",
"size": "2084",
"license": "mit",
"hash": -1973743578431258600,
"line_mean": 19.6435643564,
"line_max": 60,
"alpha_frac": 0.6756238004,
"autogenerated": false,
"ratio": 2.3155555555555556,
"config... |
# Adapted from select_parser.py by Paul McGuire
# http://pyparsing.wikispaces.com/file/view/select_parser.py/158651233/select_parser.py
#
# a simple SELECT statement parser, taken from SQLite's SELECT statement
# definition at http://www.sqlite.org/lang_select.html
#
from pyparsing import *
ParserElement.enablePackrat... | {
"repo_name": "lebinh/aq",
"path": "aq/select_parser.py",
"copies": "1",
"size": "6365",
"license": "mit",
"hash": 3449002527536661500,
"line_mean": 41.4333333333,
"line_max": 100,
"alpha_frac": 0.5838177533,
"autogenerated": false,
"ratio": 3.5049559471365637,
"config_test": false,
"has_no_k... |
# Adapted from similar tool in megaman (https://github.com/mmp2/megaman)
# LICENSE: Simplified BSD https://github.com/mmp2/megaman/blob/master/LICENSE
""" cythonize
Cythonize pyx files into C files as needed.
Usage: cythonize [root_dir]
Default [root_dir] is 'megaman'.
Checks pyx files to see if they have been changed... | {
"repo_name": "makokal/funzo",
"path": "tools/cythonize.py",
"copies": "1",
"size": "6391",
"license": "mit",
"hash": 6413831441783020000,
"line_mean": 30.6386138614,
"line_max": 97,
"alpha_frac": 0.6107025505,
"autogenerated": false,
"ratio": 3.713538640325392,
"config_test": false,
"has_no_... |
# Adapted from similar tool in scipy
# LICENSE: Simplified BSD https://github.com/mmp2/megaman/blob/master/LICENSE
""" cythonize
Cythonize pyx files into C files as needed.
Usage: cythonize [root_dir]
Default [root_dir] is 'megaman'.
Checks pyx files to see if they have been changed relative to their
corresponding C f... | {
"repo_name": "jakevdp/Mmani",
"path": "tools/cythonize.py",
"copies": "4",
"size": "6320",
"license": "bsd-2-clause",
"hash": 8289371627126050000,
"line_mean": 32.2631578947,
"line_max": 105,
"alpha_frac": 0.6136075949,
"autogenerated": false,
"ratio": 3.7132784958871916,
"config_test": false,... |
# Adapted from @skuroda,s PersistentRegexHighlight and @wbond's resource loader.
import sys
import sublime
#VERSION = int(sublime.version())
mod_prefix = "classes_and_tests"
reload_mods = []
"""
if VERSION > 3000:
mod_prefix = "PersistentRegexHighlight." + mod_prefix
from imp import reload
for mod in sy... | {
"repo_name": "anconaesselmann/ClassesAndTests",
"path": "classes_and_tests/src/reloader.py",
"copies": "1",
"size": "1566",
"license": "mit",
"hash": -7883799954134831000,
"line_mean": 25.5593220339,
"line_max": 84,
"alpha_frac": 0.6666666667,
"autogenerated": false,
"ratio": 3.5112107623318387,... |
# Adapted from Software Design's serve_my_exe.py program for using
# the SD_app React app.
from http.server import BaseHTTPRequestHandler, HTTPServer
from subprocess import Popen, PIPE
import sys
import logging
exe_name = ""
class S(BaseHTTPRequestHandler):
def _set_headers(self):
self.send_response(200... | {
"repo_name": "StoDevX/cs251-toolkit",
"path": "cs251tk/webapp/server.py",
"copies": "1",
"size": "1183",
"license": "mit",
"hash": -8126628704647342000,
"line_mean": 29.3333333333,
"line_max": 77,
"alpha_frac": 0.6551141167,
"autogenerated": false,
"ratio": 3.70846394984326,
"config_test": fal... |
"""Adapted from sphinx.ext.autosummary.generate
Modified to only consider module members listed in `__all__` and
only class members listed in `autodoc_allowed_special_members`.
Copyright 2007-2016 by the Sphinx team, https://github.com/sphinx-doc/sphinx/blob/master/AUTHORS
License: BSD, see https://github.com/sphinx-... | {
"repo_name": "dean0x7d/pybinding",
"path": "docs/_ext/generate.py",
"copies": "1",
"size": "5931",
"license": "bsd-2-clause",
"hash": 8182314794212353000,
"line_mean": 37.264516129,
"line_max": 99,
"alpha_frac": 0.6071488788,
"autogenerated": false,
"ratio": 3.8714099216710185,
"config_test": ... |
'''Adapted from Swinner, p: 88; class based version'''
import tkinter as tk
class DeuxDessins(tk.Tk):
def __init__(self):
super().__init__()
self.creation()
self.positionnement()
def creation(self):
'''création des différents widgets '''
self.canevas = tk.Canvas(self... | {
"repo_name": "aroberge/exemples_fr",
"path": "gui/deux_dessins_v2_tk.py",
"copies": "1",
"size": "2019",
"license": "cc0-1.0",
"hash": -8903217997508124000,
"line_mean": 29.5454545455,
"line_max": 76,
"alpha_frac": 0.5401785714,
"autogenerated": false,
"ratio": 3,
"config_test": false,
"has_... |
'''Adapted from Swinner, p: 88'''
import tkinter as tk
def dessiner_cercle(x, y, r, couleur='black'):
'''tracé d'un cercle de centre (x, y) et de rayon r'''
canevas.create_oval(x-r, y-r, x+r, y+r, outline=couleur)
def figure_1():
'''dessiner une cible'''
canevas.delete(tk.ALL) # efface dessin exist... | {
"repo_name": "aroberge/exemples_fr",
"path": "gui/deux_dessins_tk.py",
"copies": "1",
"size": "1403",
"license": "cc0-1.0",
"hash": -2407639466751425500,
"line_mean": 28.829787234,
"line_max": 71,
"alpha_frac": 0.5798858773,
"autogenerated": false,
"ratio": 2.5080500894454385,
"config_test": f... |
# Adapted from test_file.py by Daniel Stutzbach
#from __future__ import unicode_literals
import sys
import os
import unittest
from array import array
from weakref import proxy
from test.test_support import (TESTFN, findfile, check_warnings, run_unittest,
make_bad_fd)
from UserList impor... | {
"repo_name": "kangkot/arangodb",
"path": "3rdParty/V8-4.3.61/third_party/python_26/Lib/test/test_fileio.py",
"copies": "48",
"size": "9024",
"license": "apache-2.0",
"hash": -181123358207079000,
"line_mean": 32.5464684015,
"line_max": 86,
"alpha_frac": 0.5244902482,
"autogenerated": false,
"rati... |
# Adapted from test_file.py by Daniel Stutzbach
from __future__ import unicode_literals
import sys
import os
import errno
import unittest
from array import array
from weakref import proxy
from functools import wraps
from UserList import UserList
from test.test_support import TESTFN, check_warnings, run_unittest, mak... | {
"repo_name": "IronLanguages/ironpython2",
"path": "Src/StdLib/Lib/test/test_fileio.py",
"copies": "2",
"size": "17109",
"license": "apache-2.0",
"hash": 7781314735448295000,
"line_mean": 32.2213592233,
"line_max": 84,
"alpha_frac": 0.5481910106,
"autogenerated": false,
"ratio": 3.852510695789236... |
# Adapted from test_file.py by Daniel Stutzbach
import sys
import os
import errno
import unittest
from array import array
from weakref import proxy
from functools import wraps
from test.support import TESTFN, check_warnings, run_unittest, make_bad_fd
from test.support import gc_collect
from _io import FileIO as _Fil... | {
"repo_name": "wdv4758h/ZipPy",
"path": "lib-python/3/test/test_fileio.py",
"copies": "1",
"size": "13190",
"license": "bsd-3-clause",
"hash": 4190823416583478000,
"line_mean": 30.1820330969,
"line_max": 79,
"alpha_frac": 0.5328278999,
"autogenerated": false,
"ratio": 3.9209274673008325,
"confi... |
# Adapted from test_file.py by Daniel Stutzbach
import sys
import os
import io
import errno
import unittest
from array import array
from weakref import proxy
from functools import wraps
from test.support import TESTFN, check_warnings, run_unittest, make_bad_fd, cpython_only
from collections import UserList
import _i... | {
"repo_name": "MalloyPower/parsing-python",
"path": "front-end/testsuite-python-lib/Python-3.6.0/Lib/test/test_fileio.py",
"copies": "5",
"size": "18759",
"license": "mit",
"hash": 1826191505021484000,
"line_mean": 31.8528896673,
"line_max": 88,
"alpha_frac": 0.544432006,
"autogenerated": false,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.