content stringlengths 7 928k | avg_line_length float64 3.5 33.8k | max_line_length int64 6 139k | alphanum_fraction float64 0.08 0.96 | licenses list | repository_name stringlengths 7 104 | path stringlengths 4 230 | size int64 7 928k | lang stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|
from collections import defaultdict
game = defaultdict(list)
tuple_list_county = [('US', 'Visconsin'), ('Germany', 'Bavaria'), ('UK', 'Bradfordshire'), ('India', 'punjab'), ('China', 'Shandong'), ('Canada', 'Nova Scotia')]
print game["any_value"]
for k,v in tuple_list_county:
game[k].append(v)
print game | 26.25 | 162 | 0.669841 | [
"MIT"
] | LuisPereda/Learning_Python | Chapter10/default_dict_list_of_tuples.py | 315 | Python |
def pixel(num):
def f(s):
return s + '\033[{}m \033[0m'.format(num)
return f
def new_line(s):
return s + u"\n"
def build(*steps, string=""):
for step in steps:
string = step(string)
return string
def main():
cyan = pixel(46)
space = pixel('08')
heart = [new_line,
... | 36.6875 | 87 | 0.579216 | [
"MIT"
] | xxninjabunnyxx/pixel-pop-heart-challenge | heart.py | 1,174 | Python |
class AdminCatalogHelper:
def __init__(self, app):
self.app = app
def go_though_each_product_and_print_browser_log(self):
for i in range(len(self.app.wd.find_elements_by_css_selector('.dataTable td:nth-of-type(3) a[href*="&product_id="]'))):
self.app.wd.find_elements_by_css_selecto... | 50.833333 | 127 | 0.678689 | [
"MIT"
] | spcartman/selenium_full_course | v_python/fixture/admin_catalog.py | 610 | Python |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from msccl.collectives import *
from msccl.algorithm import *
from msccl.instance import *
from msccl.topologies import *
def _alltoall_subproblem(local_nodes, num_copies):
remote_node = local_nodes
local_end = local_nodes * local_nodes... | 45.267857 | 133 | 0.60355 | [
"MIT"
] | angelica-moreira/sccl | msccl/distributors/alltoall_subproblem.py | 10,140 | Python |
import logging
from collections import OrderedDict
from pathlib import Path
from typing import List, Optional, Set, Tuple, Union
import numpy as np
import torch
from sklearn.metrics.pairwise import cosine_similarity
from sklearn.preprocessing import minmax_scale
from tqdm import tqdm
import flair
from flair.data impo... | 40.6947 | 119 | 0.621436 | [
"MIT"
] | garciaeduardo7143/flair | flair/models/tars_model.py | 35,323 | Python |
# -*- coding: utf-8 -*-
"""Console script for python_learn."""
import sys
import click
@click.command()
def main(args=None):
"""Console script for python_learn."""
click.echo("Replace this message by putting your code into "
"python_learn.cli.main")
click.echo("See click documentation at h... | 22.526316 | 68 | 0.649533 | [
"MIT"
] | Zhazhanan/python_learn | python_learn/cli.py | 428 | Python |
# -------------------------------------------------------------------------
# Copyright (C) 2018 BMW Car IT GmbH
# -------------------------------------------------------------------------
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distrib... | 40.023256 | 76 | 0.440442 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | Yuehai-Zhou/GENIVI | scripts/code_style_checker/common_modules/config.py | 1,721 | Python |
import time
import random
import highfive
# This is the remote worker for the sum example. Here, we define what the
# workers do when they get a call from the master. All we need is a single
# function which takes the call, does some processing, and returns a response.
# An interesting way to play with the workers ... | 38.333333 | 79 | 0.745819 | [
"MIT"
] | abau171/highfive | examples/sum_worker.py | 1,495 | Python |
import datetime
import inspect
import os
import pprint as pretty_print
import jinja2
from jinja2 import Environment, FileSystemLoader
DEFAULT_TEMPLATE_FOLDERS = ["templates"]
def get_log_errors(logs):
return [e for e in logs.list() if e["level"] >= 40]
def make_list(obj):
return list(obj)
def pprint(obj... | 26.449438 | 83 | 0.661852 | [
"BSD-3-Clause"
] | ankitjavalkar/spidermon | spidermon/templates.py | 2,354 | Python |
# -*- coding: utf-8 -*-
#
# github-cli documentation build configuration file, created by
# sphinx-quickstart on Tue May 5 17:40:34 2009.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# ... | 32.34359 | 80 | 0.722531 | [
"BSD-3-Clause"
] | jsmits/github-cli | docs/source/conf.py | 6,307 | Python |
from __future__ import print_function
import argparse
import os
import pickle
import sys
import cv2
import numpy as np
import torch
import vlfeat # calls constructor
from sklearn.cluster import MiniBatchKMeans
from src.utils.cluster.eval_metrics import _hungarian_match, _original_match, \
_acc
from src.utils.segm... | 36.618421 | 80 | 0.676967 | [
"MIT"
] | THinnerichs/MiS-Information-Clustering | src/scripts/segmentation/baselines/kmeans_and_sift.py | 11,132 | Python |
from ruamel import yaml
import great_expectations as ge
if __name__ == "__main__":
context = ge.get_context()
datasource_config = {
"name": "my_notion_pandas_data_source",
"class_name": "Datasource",
"module_name": "great_expectations.datasource",
"execution_engine": {
... | 31.777778 | 78 | 0.630536 | [
"MIT"
] | datarootsio/notion-dbs-data-quality | src/build_data_source.py | 858 | Python |
from django.db import models
from django.template.defaultfilters import truncatechars
from django.utils import timezone
from camper.sked.models import Event, Session
from camper.twit.threads import SendTweetThread
class TweetTooLongError(Exception):
def __init__(self, msg=None):
self.msg = msg
if... | 30.58427 | 96 | 0.560434 | [
"BSD-3-Clause"
] | drinks/camper | camper/twit/models.py | 5,444 | Python |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (t... | 36.225455 | 118 | 0.57639 | [
"Apache-2.0"
] | brondsem/allura | Allura/allura/model/index.py | 9,962 | Python |
import os, sys
sys.path.insert(0, os.path.join("..",".."))
from nodebox.graphics.context import *
from nodebox.graphics import *
from nodebox.graphics.geometry import coordinates
from nodebox.graphics.shader import dropshadow, OffscreenBuffer, transparent, stretch
from time import time
flower = Image("cell.png")
... | 37.304636 | 91 | 0.606071 | [
"BSD-3-Clause"
] | pepsipepsi/nodebox_opengl_python3 | examples/07-filter/09-buffer.py | 5,633 | Python |
import tkinter as tk
from PIL import Image, ImageTk
# The Custom Variable Widgets
class MyBar(tk.Canvas) :
def __init__(self, master:object, shape:object, value=0, maximum=100,
bg="#231303", trough_color='#8a7852', bar_color='#f7f4bf'):
"""Creating the alpha mask and creating a custom wid... | 40.409091 | 120 | 0.644544 | [
"MIT"
] | 1337-inc/Captain | Scripts/mybar.py | 1,778 | Python |
from typing import List, Generator
def n_gons(partial: List[int], size: int, sums: int=None) -> \
Generator[List[int], None, None]:
length = len(partial)
if length == size * 2:
yield partial
for i in range(1, size * 2 + 1):
if i in partial:
continue
partial.a... | 27.147541 | 75 | 0.504227 | [
"MIT"
] | cryvate/project-euler | project_euler/solutions/problem_68.py | 1,656 | Python |
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
'''btDown.py - Download resource for HTTP/HTTPS/FTP/Thunder/Magnet/BT
Usage: python3 btDown.py <url> [path]
Required:
url HTTP/HTTPS/FTP/Thunder/MagNet/BT downloading URL
Optionals:
path The store path for the downloaded file
Notice: Python3 requ... | 31.760736 | 75 | 0.596871 | [
"MIT"
] | tianxiaxi/iDown | btDown.py | 5,205 | Python |
"""Commands for starting daemons."""
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import pprint
import confpy.api
import confpy.core.option
from .. import messages
cfg = confpy.api.Configuration... | 25.74026 | 77 | 0.619324 | [
"Apache-2.0"
] | kevinconway/PyPerf | pyperf/cmd/daemons.py | 3,964 | Python |
from kat.harness import Query, EDGE_STACK
from abstract_tests import AmbassadorTest, HTTP
from abstract_tests import ServiceType
from selfsigned import TLSCerts
from kat.utils import namespace_manifest
#####
# XXX This file is annoying.
#
# RedirectTestsWithProxyProto and RedirectTestsInvalidSecret used to be subcla... | 31.398693 | 127 | 0.658097 | [
"Apache-2.0"
] | DoodleScheduling/emissary | python/tests/kat/t_redirect.py | 9,608 | Python |
#!/usr/bin/env python3
# Copyright (C) 2019 - Virtual Open Systems SAS
#
# 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 ... | 31.344828 | 74 | 0.731573 | [
"Apache-2.0"
] | 5GCity/5GCity-resource-placement | src/bjointsp/main.py | 909 | Python |
"""
A simple Line class.
NOTE: This is NOT rosegraphics -- it is your OWN Line class.
Authors: David Mutchler, Vibha Alangar, Matt Boutell, Dave Fisher,
Mark Hays, Amanda Stouder, Aaron Wilkin, their colleagues,
and Jacob Jarski.
""" # DONE: 1. PUT YOUR NAME IN THE ABOVE LINE.
import math
impor... | 38.270729 | 98 | 0.479757 | [
"MIT"
] | jarskijr/10-MoreImplementingClasses | src/m1_Line.py | 38,309 | Python |
# Auto generated by generator.py. Delete this line if you make modification.
from scrapy.spiders import Rule
from scrapy.linkextractors import LinkExtractor
XPATH = {
'name' : "//div[@class='product-name']/h1",
'price' : "//p[@class='special-price']/span[@class='price']|//span[@class='regular-price']/span[@cla... | 34.3 | 117 | 0.609329 | [
"MIT"
] | chongiadung/choinho | scraper/storage_spiders/azoravn.py | 1,029 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is subject to the terms and conditions defined in
# file 'LICENSE.md', which is part of this source code package.
#
import re
import base64
import json
import os
import tempfile
import requests
import urllib3
from kubernetes_py.utils.ConvertData import conver... | 31.327273 | 120 | 0.578642 | [
"Apache-2.0"
] | ThinkIQ/kubernetes-py | kubernetes_py/utils/HttpRequest.py | 3,446 | Python |
"""
The code below crawls the annotations of the MADE 1.0 Train Data and stores them
as Corpus ID, Annotation ID, Type, Length, Offset, Text in the
CSV_Annotations.csv file.
Input Files:
All xml files in the annotations folder in the made_train_data folder
Output Files:
CSV_Annotati... | 34.890909 | 143 | 0.600313 | [
"MIT"
] | avsharma96/Named-Entity-Recognition | Code/PreProcessing/Regex/annotation_crawling.py | 1,919 | Python |
import matplotlib.pyplot as plt
import numpy as np
from prmlmy.util import cv_, norm2s, calc_range
def plot_decision_boundary(model, X_train, y_train=None, x1_range=None, x2_range=None, points=300,
title=None, pad_ratio=0.2, ax=None):
ax = ax or plt
x1_range = x1_range or calc_range... | 39.516129 | 100 | 0.647347 | [
"MIT"
] | jms7446/PRML | prmlmy/plot_util.py | 2,450 | Python |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
One of the trickier parts of creating a mock btrfs filesystem is tracking
the structures of the write forks, respec... | 43.310263 | 80 | 0.648372 | [
"MIT"
] | SaurabhAgarwala/antlir | antlir/btrfs_diff/extents_to_chunks.py | 18,147 | Python |
from sympy.vector.coordsysrect import CoordSysCartesian
from sympy.vector.scalar import BaseScalar
from sympy import sin, cos, pi, ImmutableMatrix as Matrix, \
symbols, simplify, zeros, expand
from sympy.vector.functions import express
from sympy.vector.point import Point
from sympy.vector.vector import Vector
fro... | 43.071186 | 91 | 0.488745 | [
"BSD-3-Clause"
] | Anshnrag02/sympy | sympy/vector/tests/test_coordsysrect.py | 12,706 | Python |
# Webhooks for external integrations.
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.models import get_client
from zerver.lib.actions import check_send_stream_message
from zerver.lib.response import json_success, json_error
from zerver.decorator import... | 38.614035 | 91 | 0.664244 | [
"Apache-2.0"
] | Rishabh570/zulip | zerver/webhooks/semaphore/view.py | 2,201 | Python |
#!/usr/bin/env python
#$Id: rotate_molecule.py,v 1.2.10.1 2016/02/11 09:24:08 annao Exp $
import os
from MolKit import Read
from MolKit.pdbWriter import PdbWriter, PdbqsWriter, PdbqWriter, PdbqtWriter
from mglutil.math.rotax import rotax
import numpy
if __name__ == '__main__':
import sys
import getopt
... | 33.6 | 82 | 0.537879 | [
"BSD-3-Clause"
] | e-mayo/autodocktools-prepare-py3k | AutoDockTools/Utilities24/rotate_molecule.py | 5,544 | Python |
import subprocess
import socket
import tempfile
import redis
import time
import os
import itertools
import sys
# Environment variable pointing to the redis executable
REDIS_PATH_ENVVAR = 'REDIS_PATH'
def get_random_port():
sock = socket.socket()
sock.listen(0)
_, port = sock.getsockname()
sock.close(... | 27.439024 | 112 | 0.569333 | [
"BSD-2-Clause"
] | MPalarya/RAMP | RAMP/disposableredis/__init__.py | 2,250 | Python |
# Copyright (c) 2020, RTE (https://www.rte-france.com)
# See AUTHORS.txt
# This Source Code Form is subject to the terms of the Mozilla Public License, version 2.0.
# If a copy of the Mozilla Public License, version 2.0 was not distributed with this file,
# you can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-Lice... | 71.242553 | 115 | 0.443256 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | BDonnot/lightsim2grid | lightsim2grid/tests/test_DataConverter.py | 16,742 | Python |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from .video_record import VideoRecord
from datetime import timedelta
import time
def timestamp_to_sec(timestamp):
x = time.strptime(timestamp, '%H:%M:%S.%f')
sec = float(timedelta(hours=x.tm_hour,
... | 28.672727 | 91 | 0.637286 | [
"Apache-2.0"
] | Lucaweihs/Motionformer | slowfast/datasets/epickitchens_record.py | 1,577 | Python |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import unittest
import torch
import torch.nn as nn
from opacus import PerSampleGradientClipper
from opacus.dp_model_inspector import DPModelInspector
from opacus.layers import DPLSTM, DPMultiheadAttention, SequenceBias
from o... | 34.326087 | 101 | 0.611146 | [
"Apache-2.0"
] | RosaYen/DP_FL_recreation | DP_FL_recreate/opacus/tests/layers_grad_test.py | 6,316 | Python |
import yaml
class HdcpSource:
def __init__(self, conf_yaml):
f = open(conf_yaml, "r")
conf = yaml.load(f)
f.close()
def process_request(req):
msg_type, msg = req
if __name__ == "__main__":
HdcpSource("yaml/rx1.yaml")
| 14.157895 | 34 | 0.583643 | [
"MIT"
] | imamotts/hdcp_test | src/hdcp_source.py | 269 | Python |
import os
import shutil
import yaml
from mock import patch
from dsl_parser.exceptions import DSLParsingLogicException
from .. import cfy
from ... import env
from ...config import config
from ...commands import init
from .test_base import CliCommandTest
from .constants import BLUEPRINTS_DIR, SAMPLE_INPUTS_PATH, \
... | 33.882629 | 78 | 0.618678 | [
"Apache-2.0"
] | TS-at-WS/cloudify-cli | cloudify_cli/tests/commands/test_init.py | 7,217 | Python |
from django.db import migrations, models
import django_simple_file_handler.models
class Migration(migrations.Migration):
dependencies = [
('django_simple_file_handler', '0002_auto_20180521_1545'),
]
operations = [
migrations.AlterField(
model_name='privatedocument',
... | 43.45283 | 143 | 0.671733 | [
"MIT"
] | jonathanrickard/django-simple-file-handler | django_simple_file_handler/migrations/0003_auto_20180525_1035.py | 2,303 | Python |
import atexit
import logging
import multiprocessing
import gc
import os
from sys import exit
import warnings
import click
import dask
from distributed import Nanny, Worker
from distributed.security import Security
from distributed.cli.utils import check_python_3, install_signal_handlers
from distributed.comm import ge... | 26.997567 | 95 | 0.62518 | [
"BSD-3-Clause"
] | MdSalih/distributed | distributed/cli/dask_worker.py | 11,096 | Python |
# --- Imports --- #
import torch
import torch.nn.functional as F
# --- Perceptual loss network --- #
class LossNetwork(torch.nn.Module):
def __init__(self, vgg_model):
super(LossNetwork, self).__init__()
self.vgg_layers = vgg_model
self.layer_name_mapping = {
'3': "relu1_2",
... | 33.366667 | 76 | 0.598402 | [
"MIT"
] | liuh127/NTIRE-2021-Dehazing-Two-branch | perceptual.py | 1,001 | Python |
import heapq
import math
import random as rnd
from functools import partial
from .core import Bag
def sample(population, k):
"""Chooses k unique random elements from a bag.
Returns a new bag containing elements from the population while
leaving the original population unchanged.
Parameters
---... | 26.117647 | 89 | 0.623592 | [
"MIT"
] | CDU55/FakeNews | ServerComponent/venv/Lib/site-packages/dask/bag/random.py | 3,552 | Python |
from django.db.models.fields import Field
from django.urls import NoReverseMatch
from django.urls import reverse
from polymorphic.managers import PolymorphicManager
from common.business_rules import NoBlankDescription
from common.business_rules import UpdateValidity
from common.models.mixins.validity import ValiditySt... | 31.307692 | 82 | 0.679607 | [
"MIT"
] | uktrade/tamato | common/models/mixins/description.py | 2,035 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pip install nvidia-ml-py3 --user
import pynvml
try:
pynvml.nvmlInit()
except pynvml.NVMLError as error:
print(error)
# Driver Not Loaded 驱动加载失败(没装驱动或者驱动有问题)
# Insufficent Permission 没有以管理员权限运行 pynvml.NVMLError_DriverNotLoaded: Driver Not Loaded
... | 25.441176 | 92 | 0.746821 | [
"MIT"
] | forwardmeasure/kubeflow | setup/nvidia/nvml-test.py | 919 | Python |
# Time: O(n * n!/(c_a!*...*c_z!), n is the length of A, B,
# c_a...c_z is the count of each alphabet,
# n = sum(c_a...c_z)
# Space: O(n * n!/(c_a!*...*c_z!)
# 854
# Strings A and B are K-similar (for some non-negative integer K)
# if we can swap the po... | 39.309278 | 108 | 0.586415 | [
"MIT"
] | RideGreg/LeetCode | Python/k-similar-strings.py | 3,813 | Python |
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import subprocess
from ..utils.scripts import make_path
from ..utils.testing import Checker
from .obs_table import ObservationTable
from .hdu_index_table impo... | 33.871345 | 87 | 0.601865 | [
"BSD-3-Clause"
] | qpiel/gammapy | gammapy/data/data_store.py | 11,584 | Python |
from typing import Optional
import django_admin_relation_links
from adminutils import options
from authtools import admin as authtools_admin
from django.contrib import admin
from enumfields.admin import EnumFieldListFilter
from rangefilter.filter import DateRangeFilter
from solo.admin import SingletonModelAdmin
from ... | 26.433735 | 80 | 0.667274 | [
"MIT"
] | rtcharity/eahub.org | eahub/base/admin.py | 2,194 | Python |
class Pessoa():
def criar_lista(self, n, id_ade, sexo, saude):
lista = []
qunt = int(input('quantas pessoas são: '))
for c in range(qunt):
n = input('digite seu nome: ')
lista.append(n)
idade = int(input('digite sua idade: '))
while idade ... | 39.875 | 113 | 0.523511 | [
"MIT"
] | Felipe-Gs/Dupla-2-F | ex3.py | 1,614 | Python |
# -*- coding: utf-8 -*-
from django import forms
from django.contrib.auth import get_user_model
from django.utils.translation import ugettext_lazy as _
from tcms.core.utils import string_to_list
from tcms.core.forms.fields import UserField
from tcms.management.models import Product, Version, Build
from tcms.testplans.... | 34.25 | 83 | 0.734307 | [
"MIT"
] | YangKaiting/kiwitcms-telemetry-failed-test-cases | telemetryPlugin/forms.py | 685 | Python |
# pylint: disable=no-member
from logging.config import fileConfig
from sqlalchemy import engine_from_config
from sqlalchemy import pool
from alembic import context
from playthrough-bot.models import ModelBase, get_engine
# this is the Alembic Config object, which provides
# access to the values within the .ini file... | 26.885057 | 80 | 0.70714 | [
"MIT"
] | Rain288/playthrough-bot | src/playthrough-bot/models/alembic/env.py | 2,339 | Python |
"""
Experimemtal code for trimming primers & polyA tails from high error rate long reads
"""
import os, sys, pdb
from csv import DictWriter
from collections import namedtuple
from multiprocessing import Process
from Bio.Seq import Seq
from Bio import SeqIO
import parasail
ScoreTuple = namedtuple('ScoreTuple', ['score5... | 36.344978 | 123 | 0.58104 | [
"BSD-3-Clause-Clear"
] | ArthurDondi/cDNA_Cupcake | beta/trim_primers.py | 8,323 | Python |
#!/usr/bin/env python
"""
Tests for ohsome client
"""
import os
import pandas as pd
from nose.tools import raises
import geojson
import geopandas as gpd
import ohsome
@raises(ohsome.OhsomeException)
def test_handle_multiple_responses_throw_timeouterror():
"""
Tests counting elements within a bounding box for... | 32.628 | 125 | 0.55388 | [
"BSD-3-Clause"
] | redfrexx/osm_association_rules | src/ohsome/tests/test_ohsome_client.py | 8,157 | Python |
import os, sys, glob, argparse
import logging
import types
from collections import OrderedDict
import torch
import torch.nn.functional as F
import utils
import models
import main as entry
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"]="0"
def export_onnx(args):
model_name = args... | 40.234694 | 158 | 0.563108 | [
"BSD-2-Clause"
] | billhhh/model-quantization-1 | tools.py | 11,829 | Python |
from selenium import webdriver
#import itertools
from openpyxl import Workbook, load_workbook
import re
import datetime
driver = webdriver.Firefox()
driver.get("https://www.worldometers.info/coronavirus/")
countries = []
cases = []
newCases = []
data = []
casesInt = []
newCasesInt = []
cells = []
cellsB = []
datez = da... | 27.672131 | 103 | 0.695498 | [
"MIT"
] | stephengarn/coronavirus | corona.py | 1,688 | Python |
import glob
import os
import librosa
import numpy as np
import tensorflow as tf
import sounddevice
from sklearn.preprocessing import StandardScaler
duration = 0.1 # seconds
sample_rate=44100
'''0 = air_conditioner
1 = car_horn
2 = children_playing
3 = dog_bark
4 = drilling
5 = engine_idling
6 = gun_shot
7 = jackha... | 28.08046 | 97 | 0.715104 | [
"MIT"
] | GianlucaPaolocci/SMProject | classiPi.py | 2,443 | Python |
import epaper2in13
from machine import Pin,SPI
from time import sleep_ms
# SPI #2 on ESP32
spi = SPI(2,baudrate=2000000, polarity=0, phase=0) # miso=Pin(12), mosi=Pin(23), sck=Pin(18))
cs = Pin(5)
dc = Pin(2)
rst = Pin(15)
busy = Pin(4)
e = epaper2in13.EPD(spi, cs, dc, rst, busy)
e.init(e.FULL_UPDATE)
y_start = 6 ... | 23 | 93 | 0.671498 | [
"MIT"
] | piratebriggs/micropython-waveshare-epaper | examples/2in13-hello-world/test.py | 1,035 | Python |
import datetime
import os
import typing
from dataclasses import dataclass
import pandas
import pytest
from dataclasses_json import dataclass_json
import flytekit
from flytekit import ContainerTask, SQLTask, dynamic, kwtypes, maptask
from flytekit.common.translator import get_serializable
from flytekit.core import con... | 27.333333 | 117 | 0.5814 | [
"Apache-2.0"
] | ThomVett/flytek | tests/flytekit/unit/core/test_type_hints.py | 26,978 | Python |
# coding=utf-8
# *** WARNING: this file was generated by pulumigen. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
from ... import _utilities
from ... import me... | 68.014368 | 415 | 0.713634 | [
"Apache-2.0"
] | Teshel/pulumi-kubernetes | sdk/python/pulumi_kubernetes/storage/v1beta1/CSIStorageCapacity.py | 23,669 | Python |
# -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2017-10-15 15:04
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('ContestAnalyzerOnline', '0006_auto_20171015_1445'),
]
operations = [
migrations.Del... | 19.736842 | 61 | 0.64 | [
"MIT"
] | rogercaminal/HamToolsManager | ContestAnalyzerOnline/utils/migrations/0007_delete_comment.py | 375 | Python |
#!/usr/bin/env python
# Licensed to Cloudera, Inc. under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. Cloudera, Inc. licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you ma... | 31.506876 | 211 | 0.685477 | [
"Apache-2.0"
] | apoorvanand/hue | desktop/libs/metadata/src/metadata/optimizer_api.py | 16,037 | Python |
# -*- coding: utf-8 -*-
"""
walle-web
:copyright: © 2015-2019 walle-web.io
:created time: 2019-02-24 10:47:53
:author: wushuiyong@walle-web.io
"""
import os
import re
import os.path as osp
import git as PyGit
from git import Repo as PyRepo
class Repo:
path = None
def __init__(self, path=Non... | 24.744828 | 93 | 0.510033 | [
"Apache-2.0"
] | lgq9220/walle-web | walle/service/git/repo.py | 3,713 | Python |
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import datetime
import logging
import os
import time
import isodate
from testlib import mini_poster
logger = logging... | 33.649573 | 89 | 0.665481 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | Mozilla-GitHub-Standards/ca053cb8c97310481ca4524f115cd80002b8bbd773c6bdc00eb9955dd3d48e83 | tests/systemtest/test_post_crash.py | 3,937 | Python |
import requests
import argparse
import logging
import coloredlogs
import threading
from flask import Flask, request, jsonify
from flask_swagger import swagger
from waitress import serve
import subprocess
import json
from kafka import KafkaConsumer
from threading import Thread
from threading import Timer
from datetime i... | 42.132203 | 154 | 0.629898 | [
"Apache-2.0"
] | 5GEVE/5geve-wp4-dcs-signalling-topic-handler | dcs_rest_client.py | 12,429 | Python |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 19:14:52 2020
@author: prachi
"""
import pickle
import numpy as np
der='swbd_diar/exp_new/callhome/plda_oracle/der.scp'
der_pickle = 'swbd_diar/exp_new/callhome/plda_oracle/derdict'
der=open(der,'r').readlines()
DER={}
for line i... | 20.875 | 62 | 0.658683 | [
"Apache-2.0"
] | iiscleap/self_supervised_AHC | services/gen_der_dict.py | 501 | Python |
# coding=utf-8
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import absolute_import, division, print_function, unicode_literals
import os
import sys
from six import StringIO
from pants.base.workunit import WorkUnitL... | 49.416667 | 109 | 0.705928 | [
"Apache-2.0"
] | GoingTharn/pants | src/python/pants/reporting/reporting.py | 7,709 | Python |
import numpy as np
import pygame as pg
from numba import njit
def main():
size = np.random.randint(20,60) # size of the map
posx, posy, posz = 1.5, np.random.uniform(1, size -1), 0.5
rot, rot_v = (np.pi/4, 0)
lx, ly, lz = (size*20, size*30, 1000)
mr, mg, mb, maph, mapr, exitx, exity,... | 47.337778 | 192 | 0.393234 | [
"MIT"
] | FinFetChannel/PytracingMaze | RayTracingMazeEnem.py | 31,953 | Python |
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
# Analog to digital converter example.
# Will loop forever printing ADC channel 1 raw and mV values every second.
# NOTE the ADC can only read voltages in the range of ~900mV to 1800mV!
import time
import board
impo... | 32.431818 | 85 | 0.715487 | [
"Apache-2.0"
] | IanSMoyes/SpiderPi | Lights/adafruit-circuitpython-bundle-6.x-mpy-20210310/examples/lis3dh_adc.py | 1,427 | Python |
import datetime
from datetime import datetime, timedelta
from time import sleep
from app.search import add_to_index, delete_index, create_index, query_index
from app import db
from app.models import Post, User
from tests.BaseDbTest import BaseDbTest
class SearchTest(BaseDbTest):
index_name = "test_index"
d... | 32.357143 | 76 | 0.640177 | [
"MIT"
] | cuongbm/microblog | tests/SearchTest.py | 1,812 | Python |
# ---------------------------------------------------------------------
# CPE check
# ---------------------------------------------------------------------
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
import... | 36.910112 | 93 | 0.448706 | [
"BSD-3-Clause"
] | nocproject/noc | services/discovery/jobs/box/cpe.py | 3,285 | Python |
"""The tests for the Entity component helper."""
# pylint: disable=protected-access
import asyncio
from collections import OrderedDict
import logging
import unittest
from unittest.mock import patch, Mock
from datetime import timedelta
import pytest
import homeassistant.core as ha
import homeassistant.loader as loader... | 35.230769 | 78 | 0.673006 | [
"Apache-2.0"
] | BobbyBleacher/home-assistant | tests/helpers/test_entity_component.py | 17,404 | Python |
#!/usr/bin/env python
"""
Copyright 2012 GroupDocs.
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... | 29.974359 | 77 | 0.656116 | [
"Apache-2.0"
] | groupdocs-legacy-sdk/python | groupdocs/models/GetBillingAddressResponse.py | 1,169 | Python |
from setuptools import setup, find_packages
setup(
name='wtouch',
version='0.0.1',
description='Create a file in current folder.',
url='https://github.com/Frederick-S/wtouch',
packages=find_packages(exclude=['tests']),
entry_points={
'console_scripts': [
'wtouch = wtouch.mai... | 23.588235 | 51 | 0.628429 | [
"MIT"
] | Frederick-S/wtouch | setup.py | 401 | Python |
# Generated by Django 3.0.4 on 2020-03-29 13:08
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('analyzer', '0004_auto_20200328_1750'),
]
operations = [
migrations.AddField(
model_name='diseas... | 27.4 | 115 | 0.626277 | [
"MIT"
] | 4elovek37/diseases_risk_analysing | analyzer/migrations/0005_auto_20200329_1308.py | 685 | Python |
import sys
import os
if len(sys.argv) > 1:
folder = sys.argv[1]
jsfile = open("./" + folder + ".js", "w+")
images = [f[:len(f)-4] for f in os.listdir("./" + folder) if f.endswith(".svg")]
varnames = []
for i in images:
varname = "svg_" + i.replace('-', '_');
varnames.append(varname)... | 33.388889 | 87 | 0.515807 | [
"MIT"
] | pdyxs/WhereTheHeartIs | src/js/components/Map/svg/makeimport.py | 601 | Python |
# encoding=utf8
# This is temporary fix to import module from parent folder
# It will be removed when package is published on PyPI
import sys
sys.path.append('../')
# End of fix
import random
from NiaPy.algorithms.basic import MultiStrategyDifferentialEvolution
from NiaPy.util import StoppingTask, OptimizationType
fro... | 35.578947 | 99 | 0.755917 | [
"MIT"
] | kozulic/NiaPy | examples/run_msde.py | 676 | Python |
from json import load
import os
import argparse
import random
from copy import deepcopy
import torchvision
import torchvision.transforms as transforms
from torch import nn
import sys
import torch
import numpy as np
import cvxopt
torch.manual_seed(0)
from fedlab.core.client.serial_trainer import SubsetSerialTrainer
fro... | 34.689655 | 123 | 0.615706 | [
"Apache-2.0"
] | KarhouTam/FedLab-benchmarks | fedlab_benchmarks/fedmgda+/standalone.py | 5,034 | Python |
from shoppinglist.models import Ingredient
from rest_framework import serializers
class IngredientSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Ingredient
fields = ('account', 'member', 'ref_date', 'ref_meal',
'ingredient', 'created', 'ingredient_there')
| 35.555556 | 67 | 0.709375 | [
"MIT"
] | christiankuhl/foodplanner | shoppinglist/serializers.py | 320 | Python |
""" NNAPI Systrace parser - tracking of call tree based on trace lines
See contract-between-code-and-parser.txt for the
specification (cases in the specification are referred to with SPEC).
"""
import re
import sys
from parser.naming import (subphases, translate_hidl_mark_to_nn_and_tag,
... | 42.11583 | 160 | 0.660799 | [
"Apache-2.0"
] | PotatoProject-next/ackages_modules_NeuralNetworks | tools/systrace_parser/parser/tracker.py | 10,908 | Python |
from __future__ import print_function
import os
import percy
from percy import errors
from percy import utils
__all__ = ['Runner']
class Runner(object):
def __init__(self, loader=None, config=None, client=None):
self.loader = loader
self.config = config or percy.Config()
self.client = c... | 41.094737 | 102 | 0.627561 | [
"MIT"
] | getsentry/python-percy-client | percy/runner.py | 3,904 | Python |
# Copyright 2019 TerraPower, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writi... | 36.114583 | 88 | 0.675224 | [
"Apache-2.0"
] | youngmit/armi | armi/materials/tests/test_water.py | 6,934 | Python |
# Fix the code so that there's no error!
def count_evens(start, end):
"""Returns the number of even numbers between start and end."""
counter = start
num_evens = 0
while counter <= end:
if counter % 2 == 0:
num_evens += 1
counter += 1
return num_evens
def count_multiples(start, end, divisor):
... | 25.625 | 73 | 0.666667 | [
"MIT"
] | annezola/gdi-python | exercise_brokencounts_solution.py | 615 | Python |
"""My nifty plot-level RGB algorithm
"""
# Importing modules. Please add any additional import statements below
import numpy as np
# Definitions
# Please replace these definitions' values with the correct ones
VERSION = '1.0'
# Information on the creator of this algorithm
ALGORITHM_AUTHOR = 'Unknown'
ALGORITHM_AUTHO... | 38.095238 | 128 | 0.768333 | [
"BSD-3-Clause"
] | AgPipeline/plot-base-rgb | .github/workflows/algorithm_rgb.py | 2,400 | Python |
"""Implementation of Rule L042."""
from sqlfluff.core.rules.base import BaseCrawler, LintResult
from sqlfluff.core.rules.doc_decorators import document_configuration
@document_configuration
class Rule_L042(BaseCrawler):
"""Join/From clauses should not contain subqueries. Use CTEs instead.
By default this ru... | 31.559524 | 113 | 0.562429 | [
"MIT"
] | Jophish/sqlfluff | src/sqlfluff/core/rules/std/L042.py | 2,651 | Python |
#!/usr/bin/env python
"""
More complex demonstration of what's possible with the progress bar.
"""
import threading
import time
from quo.text import Text
from quo.progress import ProgressBar
def main():
with ProgressBar(
title=Text("<b>Example of many parallel tasks.</b>"),
bottom_toolbar=Text("<b... | 34.173913 | 82 | 0.592875 | [
"MIT"
] | scalabli/quo | examples/progress/many-parallel-tasks.py | 1,572 | Python |
import math
import lavalink
import ksoftapi
import discord
from discord.ext import commands
class Music(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.kclient = bot.kclient
if not hasattr(bot, 'lavalink'):
bot.lavalink = lavalink.Client(bot.user.id)
bo... | 42.798956 | 141 | 0.596694 | [
"MIT"
] | 1Prototype1/HexBot | cogs/music.py | 16,422 | Python |
import math
class MinStack:
def __init__(self):
"""
initialize your data structure here.
"""
self.stack = []
self.min = math.inf
def push(self, x: int) -> None:
self.x = x
self.stack.append(x)
if x < self.min:
self.min = x
def p... | 21.184211 | 63 | 0.532919 | [
"MIT"
] | bgoonz/INTERVIEW-PREP-COMPLETE | notes-n-resources/Data-Structures-N-Algo/_DS-n-Algos/Interview-Problems/LeetCode/MinStack.py | 805 | Python |
import argparse
import json
import os
from collections import Counter, defaultdict
from helper import _is_token_alnum
THRESHOLD = 0.01
GAP = 10
def get_full_mapping(src_filename, trg_filename, align_filename,
mapping_filename, reverse_src2trg=False, lowercase=True):
""" Get full mapping giv... | 37.918269 | 85 | 0.52035 | [
"Apache-2.0"
] | JiangtaoFeng/ParaGen | examples/wmt/tools/align/extract_bilingual_vocabulary.py | 7,887 | Python |
#!/usr/bin/env python
# coding: utf-8
"""
Multi-Sensor Moving Platform Simulation Example
===============================================
This example looks at how multiple sensors can be mounted on a single moving platform and exploiting a defined moving
platform as a sensor target.
"""
# %%
# Building a Simulated M... | 44.452685 | 120 | 0.693976 | [
"MIT"
] | GitRooky/Stone-Soup | docs/examples/Moving_Platform_Simulation.py | 17,381 | Python |
#!/usr/bin/env python
import unittest
from weblogo.seq_io._nexus import Nexus
from . import data_stream
class test_nexus(unittest.TestCase):
def test_create(self):
n = Nexus()
self.assertNotEqual(n, None)
def test_parse_f0(self):
f = data_stream("nexus/test_Nexus_input.nex")
... | 23.463768 | 62 | 0.536751 | [
"MIT"
] | WebLogo/weblogo | tests/test_nexus.py | 1,619 | Python |
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import numpy as np
import GPy
from emukit.quadrature.methods.vanilla_bq import VanillaBayesianQuadrature
from emukit.quadrature.loop.quadrature_loop import VanillaBayesianQuadratureLoop
from emukit.core.lo... | 41.428571 | 109 | 0.721121 | [
"Apache-2.0"
] | DavidJanz/emukit | integration_tests/emukit/quadrature/test_vanilla_bq_loop.py | 2,320 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from alipay.aop.api.response.AlipayResponse import AlipayResponse
class AlipayCommerceAntestCaselistQueryResponse(AlipayResponse):
def __init__(self):
super(AlipayCommerceAntestCaselistQueryResponse, self).__init__()
self._data = None
... | 26.692308 | 114 | 0.706052 | [
"Apache-2.0"
] | Anning01/alipay-sdk-python-all | alipay/aop/api/response/AlipayCommerceAntestCaselistQueryResponse.py | 694 | Python |
from markovp import Markov
from src.forms import Markov_Form
from flask import Flask, render_template, request, redirect, url_for, Blueprint, make_response
home = Blueprint("home", __name__)
@home.route("/")
def index():
#{
form = Markov_Form()
return render_template('form.html', form = form)
#}
# The submis... | 27.073171 | 94 | 0.583784 | [
"MIT"
] | TexAgg/MarkovTextGenerator | web/src/views/home.py | 1,110 | Python |
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
#
# 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 applica... | 40.215686 | 80 | 0.673685 | [
"Apache-2.0"
] | ADiegoCAlonso/tensorflow | tensorflow/contrib/linalg/python/ops/linear_operator_kronecker.py | 22,561 | Python |
import threading
import sys
class ThreadHandler(object):
def __init__(self, name, callable, *args, **kwargs):
# Set up exception handling
self.exception = None
def wrapper(*args, **kwargs):
try:
callable(*args, **kwargs)
except BaseException:
... | 28 | 68 | 0.588435 | [
"BSD-2-Clause"
] | akheron/fabric | fabric/thread_handling.py | 588 | Python |
# -*- coding: utf-8 -*-
# ===============================================================
# Author: Rodolfo Ferro
# Email: ferro@cimat.mx
# Twitter: @FerroRodolfo
#
# ABOUT COPYING OR USING PARTIAL INFORMATION:
# This script was originally created by Rodolfo Ferro, for
# his workshop in HackSureste 2019 at Universidad... | 22.518519 | 65 | 0.581003 | [
"MIT"
] | RodolfoFerro/iris-api | app.py | 2,433 | Python |
from pydantic import BaseModel
from .utils import BaseEvent
class MainPublisherEvent(BaseEvent):
pass
class CheckStatus(MainPublisherEvent):
channel: str
class WaitLiveVideo(MainPublisherEvent):
pass
class WaitStream(MainPublisherEvent):
time: int
class DownloaderEvent(BaseEvent):
pass
... | 16.232143 | 53 | 0.733773 | [
"MIT"
] | tausackhn/twlived | twlived/events.py | 909 | Python |
from argparse import Action, Namespace
from typing import (List)
from .switch_config import SwitchConfigCLI
from ..switch import SwitchChip
class EraseConfigCLI(SwitchConfigCLI):
"""
The "erase" action that removes all stored items from the EEPROM memory.
"""
def __init__(self, subparsers: Action, sw... | 28.692308 | 76 | 0.670241 | [
"MIT"
] | ararobotique/botblox-manager-software | botblox_config/data_manager/erase.py | 746 | Python |
# Copyright 2020 The FedLearner Authors. All Rights Reserved.
#
# 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 applica... | 34.484375 | 74 | 0.663344 | [
"Apache-2.0"
] | duanbing/fedlearner | web_console_v2/api/fedlearner_webconsole/workflow_template/slots_formatter.py | 2,207 | Python |
from dataclasses import dataclass, field
from enum import Enum
from typing import (
Callable,
Dict,
List,
Optional,
Union
)
import weakref
import threading
import torch
import torch.distributed as dist
from torch.distributed import rpc
from torch.distributed import distributed_c10d
from torch.distr... | 40.637931 | 126 | 0.649163 | [
"Apache-2.0"
] | dannis999/tensorflow | torch/distributed/_sharded_tensor/api.py | 30,641 | Python |
# -*- coding: utf-8 -*-
from CuAsm.CuInsAssemblerRepos import CuInsAssemblerRepos
from CuAsm.CuInsFeeder import CuInsFeeder
def constructReposFromFile(sassname, savname=None, arch='sm_75'):
# initialize a feeder with sass
feeder = CuInsFeeder(sassname, arch=arch)
# initialize an empty repos
... | 27.307692 | 70 | 0.672535 | [
"MIT"
] | cloudcores/CuAssembler | Tests/test_CuInsAsmRepos_sm50.py | 1,420 | Python |
from cumulusci.core.config import ConnectedAppOAuthConfig
from django.conf import settings
def get_connected_app():
return ConnectedAppOAuthConfig(
{
"callback_url": settings.CONNECTED_APP_CALLBACK_URL,
"client_id": settings.CONNECTED_APP_CLIENT_ID,
"client_secret": set... | 28.538462 | 66 | 0.708895 | [
"BSD-3-Clause"
] | abhishekalgo/metaci | metaci/cumulusci/utils.py | 371 | Python |
import re, multiprocessing
from tqdm import tqdm
import numpy as np
class Cleaner():
def __init__(self, num_threads=1): # right now, it's single threaded
self.num_threads = min(num_threads, int(multiprocessing.cpu_count()/2))
"""
S- ar putea să fie necesar să- l recitiţi.
"""
sel... | 40.946721 | 212 | 0.586828 | [
"MIT"
] | senisioi/Romanian-Transformers | corpus/text_cleaner.py | 10,124 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.