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 |
|---|---|---|---|---|---|---|---|---|
import os
import sys
import argparse
from importlib import import_module
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()
# Load configuration
parser = argparse.ArgumentParser()
parser.add_argument("job", type=str, nargs='?', default="Job1.MyMethod")
parser.add_argument("slot", type=st... | 38.388889 | 120 | 0.730825 | [
"MIT"
] | DataThirstLtd/databricks.pyspark.application.demo | main.py | 1,382 | Python |
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
SECRET_KEY = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
DEBUG = True
USE_TZ = False
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib... | 25.803922 | 70 | 0.648936 | [
"MIT"
] | QueraTeam/django-nextjs | tests/settings.py | 1,316 | Python |
import re
regexp = re.compile(r'''(
[a-zA-Z0-9._%+-]+ # username
@ # @ symbol
(\w)+ # domain name
(\.[a-zA-Z]{2,4}) # dot-something
)''', re.VERBOSE)
| 17.2 | 37 | 0.482558 | [
"MIT"
] | 022ey/Python_Scripts | Email Adresses/email.py | 172 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by TaoYuan on 2018/2/28 0028.
# @Link : http://blog.csdn.net/lftaoyuan
# Github : https://github.com/seeways
import asyncio
import orm
from models import User, Blog, Comment
@asyncio.coroutine
def test(loop):
yield from orm.create_pool(loop=loop, use... | 27.954545 | 117 | 0.710569 | [
"Apache-2.0"
] | seeways/awesome-python3-webapp | www/test_sql.py | 615 | Python |
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community
Edition) available.
Copyright (C) 2017-2020 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in co... | 46.272727 | 115 | 0.806483 | [
"Apache-2.0"
] | sighttviewliu/bk-sops | gcloud/iam_auth/signals/handlers.py | 1,036 | Python |
import _plotly_utils.basevalidators
class TextValidator(_plotly_utils.basevalidators.StringValidator):
def __init__(
self, plotly_name="text", parent_name="heatmap.colorbar.title", **kwargs
):
super(TextValidator, self).__init__(
plotly_name=plotly_name,
parent_name=par... | 34.863014 | 80 | 0.582711 | [
"MIT",
"BSD-3-Clause"
] | leex5089/leex5089.github.io | venv/Lib/site-packages/plotly/validators/heatmap/colorbar/title/__init__.py | 2,545 | Python |
from __future__ import unicode_literals
import sys
import types
from django import http
from django.core import signals
from django.utils.encoding import force_text
from django.utils.importlib import import_module
from django.utils.log import getLogger
from django.utils import six
logger = getLogger('django.request'... | 45.076046 | 157 | 0.59806 | [
"BSD-3-Clause"
] | chalkchisel/django | django/core/handlers/base.py | 11,855 | Python |
# Copyright 2020 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... | 51.2 | 82 | 0.741211 | [
"Apache-2.0"
] | Aditya-shahh/models | official/nlp/modeling/models/__init__.py | 1,024 | Python |
"""Tools for constructing domains for expressions. """
from sympy.polys.polyutils import parallel_dict_from_basic
from sympy.polys.polyoptions import build_options
from sympy.polys.domains import ZZ, QQ, RR, EX
from sympy.assumptions import ask, Q
from sympy.core import S, sympify
from sympy.utilities import any
def ... | 26.880342 | 78 | 0.563116 | [
"BSD-3-Clause"
] | jegerjensen/sympy | sympy/polys/constructor.py | 6,290 | Python |
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
| 15.428571 | 26 | 0.62963 | [
"BSD-3-Clause"
] | BlueMoon55/flask_test | tests/test_apps/helloworld/hello.py | 108 | Python |
import logging
import pathlib
from carim.configuration import decorators
from carim.global_resources import auth
from carim.util import file_writing
log = logging.getLogger(__name__)
@decorators.register
@decorators.server
def priority_queue(directory):
users = []
for priority_user in auth.get().get('priori... | 29.6 | 85 | 0.726351 | [
"Apache-2.0"
] | schana/dayz-server-carim | carim/configuration/universal/config.py | 592 | Python |
from pathlib import Path
from sys import stderr
from click import command, argument
from cv2 import cv2
from life_of_photo.game_of_life import GameOfLife
WINDOW_NAME = "Life of photo"
@command()
@argument("path")
def main(path):
path = Path(path).resolve()
if not path.exists():
print(f"`{path}` do... | 24.292683 | 62 | 0.629518 | [
"MIT"
] | DAtek/life-of-photo | life_of_photo/gui.py | 996 | Python |
from setuptools import setup
package_name = 'examples_rclpy_minimal_action_server'
setup(
name=package_name,
version='0.10.3',
packages=[package_name],
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['pack... | 33.875 | 86 | 0.628044 | [
"Apache-2.0"
] | Ericsson/ros2-examples | rclpy/actions/minimal_action_server/setup.py | 1,355 | Python |
# Copyright (c) 2020 PaddlePaddle 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 appl... | 32.030303 | 74 | 0.754967 | [
"Apache-2.0"
] | aiyasin/X2Paddle | x2paddle/optimizer/fusion/dygraph/trace_fc_fuse_pass.py | 1,065 | Python |
""" Plays back tiny performances by sending OSC messages to Pure Data """
import struct
import socket
import random
from threading import Timer
DEFAULT_OSC_ADDRESS = "localhost"
DEFAULT_OSC_PORT = 5000
class TouchScreenOscClient(object):
"""A simple OSC client for sending messages recording touch screen performa... | 42.438596 | 114 | 0.647788 | [
"MIT"
] | cpmpercussion/robojam | robojam/tiny_performance_player.py | 2,419 | Python |
import networkx as nx
import numpy as np
import itertools
from scipy.spatial import distance
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import csv
import pdb
import globals as const
from funcs_orig import *
from math import isclose
from pyqt_viz import edge_viewer
import time
# Constants f... | 43.444162 | 213 | 0.526903 | [
"MIT"
] | laurentmackay/3d-vertex | main_orig.py | 17,117 | Python |
from typing import Callable, Iterable
import torch
from torch.utils.data.dataloader import default_collate as default_collate_fn
from catalyst.data import ListDataset
def get_loader(
data_source: Iterable[dict],
open_fn: Callable,
dict_transform: Callable = None,
sampler=None,
collate_fn: Callab... | 36.956522 | 78 | 0.652941 | [
"Apache-2.0"
] | Inkln/catalyst | catalyst/dl/utils/torch.py | 2,550 | Python |
"""
This module contains functionality for extracting a grammar from
classes in a module.
"""
from __future__ import annotations
import types
from parsing.interfaces import SpecSource
from parsing.grammar import (
PrecedenceSpec,
PrecedenceRef,
TokenSpec,
NontermSpec,
)
from parsing.ast import Token, N... | 37.973154 | 79 | 0.470308 | [
"MIT"
] | MagicStack/parsing | parsing/module_spec.py | 5,658 | Python |
# cash register
class RetailItem:
def __init__(self, description, units_in_inventory, price):
self.__description = description
self.__units_in_inventory = units_in_inventory
self.__price = price
def get_description(self):
return self.__description
def get_units_in_invento... | 33.752 | 79 | 0.560796 | [
"MIT"
] | SergeHall/Tony-Gaddis-Python-4th | chapter_10/08_cash_register.py | 4,219 | Python |
from itertools import chain
from typing import Iterator, Mapping, Union, List
from uuid import UUID
from gemd.entity.link_by_uid import LinkByUID
from gemd.entity.bounds import RealBounds, CategoricalBounds, MolecularStructureBounds, \
IntegerBounds, CompositionBounds
from gemd.entity.template.attribute_template i... | 39.111111 | 96 | 0.668706 | [
"Apache-2.0"
] | CitrineInformatics/citrine-python | src/citrine/builders/descriptors.py | 9,152 | Python |
#!/usr/bin/env python
# encoding: utf-8
"""
@Author: yangwenhao
@Contact: 874681044@qq.com
@Software: PyCharm
@File: train_lores10_kaldi.py
@Time: 2020/4/4 11:14 AM
@Overview:
"""
from __future__ import print_function
import argparse
import os
import os.path as osp
import sys
import time
# Version conflict
import war... | 44.822556 | 120 | 0.63267 | [
"MIT"
] | Wenhao-Yang/DeepSpeaker-pytorch | TrainAndTest/Spectrogram/train_domres_egs.py | 29,807 | Python |
""" Contains the urls for the maingui module"""
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('login', views.login, name='login'),
]
| 20.4 | 47 | 0.661765 | [
"BSD-3-Clause"
] | edgarceron/agent_console | maingui/urls.py | 204 | Python |
#!/usr/bin/env python
# encoding: utf-8
# The MIT License (MIT)
# Copyright (c) 2014 CNRS
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation ... | 31.545611 | 84 | 0.522261 | [
"MIT"
] | Parisson/pyannote-core | pyannote/core/transcription.py | 18,353 | Python |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-12-13 09:21
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('lowfat', '0144_auto_20190123_1534'),
]
operations = [
migrations.AddField(... | 26.684211 | 49 | 0.573964 | [
"BSD-3-Clause"
] | elena-kolomeets/lowfat | lowfat/migrations/0145_auto_20181213_0921.py | 1,014 | Python |
#!/bin/python
"""
This is a class for loading input sentences
"""
class SentenceAttr:
def __init__(self, attr_list):
self.article_id = attr_list[1]
self.title = attr_list[2]
self.sentence = attr_list[3]
self.article_structure = attr_list[4]
self.place = attr_list[5]
de... | 24.263158 | 102 | 0.54953 | [
"MIT"
] | lychyzclc/High-throughput-relation-extraction-algorithm | src/util/load_sentence.py | 1,429 | Python |
#!/usr/bin/env python
#
# sqpdfo documentation build configuration file, created by
# sphinx-quickstart on Fri Jun 9 13:47:02 2017.
#
# 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.
#
# All ... | 29.288344 | 77 | 0.683703 | [
"BSD-3-Clause"
] | DLR-SC/sqpdfo | docs/conf.py | 4,774 | Python |
from argparse import ArgumentParser
from collections import OrderedDict
from datetime import datetime, timedelta
from elasticsearch6 import Elasticsearch
from json import dump, load
from math import pi, sin, cos
from matplotlib import pyplot as plt
from matplotlib import dates as mdates
from matplotlib import ticker as... | 37.474413 | 204 | 0.531545 | [
"MIT"
] | kamakazikamikaze/wotc-bot-twitter | bot.py | 62,245 | Python |
"""Options manager for :class:`Poly` and public API functions. """
from __future__ import print_function, division
__all__ = ["Options"]
from sympy.core import S, Basic, sympify
from sympy.core.compatibility import string_types, with_metaclass
from sympy.utilities import numbered_symbols, topological_sort, public
fr... | 27.249673 | 114 | 0.577905 | [
"MIT"
] | 18padx08/PPTex | PPTexEnv_x86_64/lib/python2.7/site-packages/sympy/polys/polyoptions.py | 20,846 | Python |
from .base_model import BaseModel
from . import networks
from .cycle_gan_model import CycleGANModel
class TestModel(BaseModel):
def name(self):
return 'TestModel'
@staticmethod
def modify_commandline_options(parser, is_train=True):
assert not is_train, 'TestModel cannot be used in train mode'
parser = Cycle... | 36.723404 | 128 | 0.741599 | [
"BSD-3-Clause"
] | yunyanxing/pairwise_xray_augmentation | models/test_model.py | 1,726 | Python |
from flask import Flask, render_template, url_for, request
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
db = SQLAlchemy(app)
app.config['SQLALCHEMY_TRACK MODIFICATIONS'] = False
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite3'
class User(db.Model):
id = db.Column(db.Integer, primar... | 25.870968 | 62 | 0.703242 | [
"Apache-2.0"
] | PrateekBing/fake-instagram-page | app.py | 802 | Python |
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Tests for L{twisted.web.static}.
"""
import errno
import inspect
import mimetypes
import os
import re
import sys
import warnings
from io import BytesIO as StringIO
from unittest import skipIf
from zope.interface.verify import verifyObject
f... | 36.635332 | 102 | 0.617383 | [
"MIT",
"Unlicense"
] | ikingye/twisted | src/twisted/web/test/test_static.py | 67,812 | Python |
import os
import re
import sys
import threading
import logging
import random
from time import sleep
from peewee import *
from enum import IntEnum
from threading import Thread
from models import DataFile
from lib.jobstatus import JobStatus
from lib.util import print_debug
from lib.util import print_line
from lib.util ... | 44.313364 | 149 | 0.475284 | [
"MIT"
] | jhkennedy/processflow | lib/filemanager.py | 28,848 | Python |
import os
import base64
from Crypto import Random
from Crypto.Cipher import AES
from Crypto.PublicKey import RSA
from Crypto.Hash import MD5
from Crypto.Hash import SHA
from Crypto.Hash import SHA256
## needs to be imported from hashlib, libcrypto
## versions do not have a block_size member var
from hashlib import s... | 27.33617 | 117 | 0.721357 | [
"MIT"
] | Anarchid/uberserver | CryptoHandler.py | 12,848 | Python |
from flask import Flask
from flask import request, session, render_template, json, Response, jsonify, make_response, send_file, redirect, url_for
import requests
import xml.etree.ElementTree as ET
import lxml
import pandas as pd
import re
app = Flask(__name__)
@app.route('/')
def index():
return render_template('pr... | 27.473684 | 121 | 0.646232 | [
"Apache-2.0"
] | DARIAH-ERIC/DESIR-CodeSprint-TrackA-TextMining | TrackA_python/codesprintapp/views.py | 3,132 | Python |
import math
import numpy as np
from cpp2py_test.bior_2d_forward_test1 import original_bior_2d_forward, bior15_coef
def bior_2d_forward(img):
assert img.shape[0] == img.shape[1]
N = img.shape[0]
iter_max = int(math.log2(N))
for iter in range(iter_max):
coeffs2 = pywt.dwt2(img[:N, :N], 'bior1.5... | 29.454545 | 83 | 0.606173 | [
"MIT"
] | oleges1/denoising_project | BM3D_py/cpp2py_test/bior_2d_forward_test2.py | 1,620 | Python |
"""mysite URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based ... | 34.652174 | 77 | 0.702635 | [
"MIT"
] | vadonmo/django | mysite/mysite/urls.py | 797 | Python |
# ReID Online Upload Service | 28 | 28 | 0.821429 | [
"MIT"
] | MikeCun/PersonReID | upload/__init__.py | 28 | Python |
from PySide import QtGui, QtCore
from AttributeWidgetImpl import AttributeWidget
class ScalarWidget(AttributeWidget):
def __init__(self, attribute, parentWidget=None, addNotificationListener = True):
super(ScalarWidget, self).__init__(attribute, parentWidget=parentWidget, addNotificationListener = addNot... | 31.244444 | 131 | 0.667141 | [
"BSD-3-Clause"
] | FabricExile/Kraken | Python/kraken/ui/DataTypeWidgets/ScalarWidgetImpl.py | 1,406 | Python |
# Author: F. Alex Wolf (http://falexwolf.de)
"""Differential Gene Expression Analysis
This is a Beta Version of a tool for differential gene expression testing
between sets detected in previous tools. Tools such as dpt, cluster,...
"""
import numpy as np
from scipy.sparse import issparse
from .. import utils
from .. ... | 44.679739 | 104 | 0.655061 | [
"BSD-3-Clause"
] | gioelelm/scanpy | scanpy/tools/rank_genes_groups.py | 6,837 | Python |
from __future__ import absolute_import
from django.dispatch import Signal
from functools import wraps
class BetterSignal(Signal):
def connect(self, receiver=None, **kwargs):
"""
Support decorator syntax:
>>> @signal.connect(sender=type)
>>> def my_receiver(**kwargs):
>>> ... | 26.928571 | 91 | 0.657825 | [
"BSD-3-Clause"
] | ChadKillingsworth/sentry | src/sentry/signals.py | 754 | Python |
# Purpose: Calculate hydrological fluxes in the canopy, unsaturated and saturated sub-domains
# Record of revisions:
# Date Programmer Description of change
# ======== ============= =====================
# 09-2020 A. Elkouk Original code
# ------------------------------------------------... | 28.520913 | 121 | 0.557792 | [
"MIT"
] | aelkouk/rainfall_runoff | flux_param.py | 7,501 | Python |
from django import forms
class SubmitEmbed(forms.Form):
url = forms.URLField() | 20.75 | 30 | 0.746988 | [
"MIT"
] | Tag-Strategies/Tag_Strategies | backend/fec/forms.py | 83 | Python |
########################################################################
#
# Constants
#
########################################################################
RETURN_SUCCESS = 1234 # Requested command executed successfully
RETURN_FAIL = None # Requested command failed | 34.625 | 72 | 0.361011 | [
"BSD-3-Clause"
] | dibondar/PyPhotonicReagents | libs/dev/consts.py | 277 | Python |
#!/usr/bin/env python
#
# Copyright 2013 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
#... | 30.38806 | 96 | 0.639244 | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | AaronFriel/rust | src/etc/generate-deriving-span-tests.py | 4,072 | Python |
#!/bin/env python
# Automatically translated python version of
# OpenSceneGraph example program "osgwidgetprogress"
# !!! This program will need manual tuning before it will work. !!!
import sys
from osgpypp import osgDB
from osgpypp import osgWidget
# Translated from file 'osgwidgetprogress.cpp'
# -*-c++-*- osg... | 24.724771 | 78 | 0.643043 | [
"BSD-3-Clause"
] | JaneliaSciComp/osgpyplusplus | examples/rough_translated1/osgwidgetprogress.py | 2,695 | Python |
import numpy as np
import cv2
import matplotlib.pyplot as plt
#read image
img = np.array(cv2.imread('1.jpg'))
#this is mask
mask = np.zeros(img.shape[:2],np.uint8)
#this bgdModel and fgdModel is used in background
bgdModel = np.zeros((1,65),np.float64)
fgdModel = np.zeros((1,65),np.float64)
#This is a... | 26.9 | 88 | 0.708798 | [
"MIT"
] | ultimus11/Foreground-Detection-OpenCV | code/grab_foreground.py | 807 | Python |
#!/usr/bin/env python3
"""
Convert data received from alfred (ffbi format) and serve them as prometheus python client
Typical call::
alfred -r 69 -u /var/run/alfred/alfred.sock > robin.txt
./robin_prometheus.py -m robin.txt
Dependencies:
prometheus_client -> pip3 install prometheus_client
License: CC BY... | 30.545699 | 116 | 0.597201 | [
"MIT"
] | ffbsee/ffbsee-ansible | roles/ffbsee-robin-exporter/files/robin_prometheus.py | 11,363 | Python |
"""
Aaron Harkrider
November 8th, 2018
Build a trojan horse that gains access to a file on cyber.anderson.edu.
The file under attack is the grade book for this assignment.
Sneaky sneaky
"""
import os
def test_mytest():
"""
When Dr. Tarplee run's py.test on the assignment this py file will run and insert my... | 30.152174 | 115 | 0.688536 | [
"MIT"
] | awharkrider/CPSC_3320_Cybersecurity_Lab | Trojan_Horse_Lab/awharkrider_test.py | 1,387 | Python |
# SPDX-License-Identifier: Apache-2.0
# Copyright 2021 Blue Cheetah Analog Design Inc.
#
# 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
#
# U... | 25.95 | 74 | 0.674374 | [
"Apache-2.0"
] | bluecheetah/pybind11_generics_tests | tests/test_list.py | 3,114 | Python |
##############################################################################
# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-64... | 40.878049 | 79 | 0.672434 | [
"BSD-3-Clause"
] | ctuning/ck-spack | package/spack-xsetmode/package.py | 1,676 | Python |
# Copyright 2022, Kay Hayen, mailto:kay.hayen@gmail.com
#
# Part of "Nuitka", an optimizing Python compiler that is compatible and
# integrates with CPython, but also works on its own.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in complianc... | 32.340909 | 81 | 0.625908 | [
"Apache-2.0"
] | sthagen/Nuitka-Nuitka | nuitka/utils/MemoryUsage.py | 4,269 | Python |
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2018-04-30 17:09
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('codenerix_storages', '0025_auto_20180426_1035'),
]
... | 35.612903 | 206 | 0.672101 | [
"Apache-2.0"
] | centrologic/django-codenerix-storages | codenerix_storages/migrations/0026_auto_20180430_1909.py | 1,104 | Python |
CThostFtdcDisseminationField = {
"SequenceSeries": "int",
"SequenceNo": "int",
}
CThostFtdcReqUserLoginField = {
"TradingDay": "string",
"BrokerID": "string",
"UserID": "string",
"Password": "string",
"UserProductInfo": "string",
"InterfaceProductInfo": "string",
"ProtocolInfo": "st... | 24.87309 | 51 | 0.598508 | [
"MIT"
] | 1122455801/vnpy | vnpy/api/ctp/generator/ctp_struct.py | 122,102 | Python |
from tranzact.util.byte_types import make_sized_bytes
bytes4 = make_sized_bytes(4)
bytes8 = make_sized_bytes(8)
bytes32 = make_sized_bytes(32)
bytes48 = make_sized_bytes(48)
bytes96 = make_sized_bytes(96)
bytes100 = make_sized_bytes(100)
bytes480 = make_sized_bytes(480)
| 27.2 | 53 | 0.819853 | [
"Apache-2.0"
] | Tranzact-Network/tranzact-blockchain | tranzact/types/blockchain_format/sized_bytes.py | 272 | Python |
# -*- coding: utf-8 -*-
# File generated according to Generator/ClassesRef/Machine/Magnet.csv
# WARNING! All changes made in this file will be lost!
"""Method code available at https://github.com/Eomys/pyleecan/tree/master/pyleecan/Methods/Machine/Magnet
"""
from os import linesep
from sys import getsizeof
from loggin... | 34.087719 | 111 | 0.610782 | [
"Apache-2.0"
] | mjfwest/pyleecan | pyleecan/Classes/Magnet.py | 7,772 | Python |
"""Module containing a preprocessor that removes the outputs from code cells"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import os
from textwrap import dedent
try:
from queue import Empty # Py 3
except ImportError:
from Queue import Empty # Py 2
... | 32.221053 | 93 | 0.542143 | [
"MIT"
] | wagnermarkd/stationary-hud | env/lib/python2.7/site-packages/nbconvert/preprocessors/execute.py | 6,122 | Python |
from rqalpha.interface import AbstractMod
from rqalpha.apis import *
from rqalpha.events import EVENT
from collections import defaultdict
import datetime
import os
class ForceClose(AbstractMod):
def __init__(self):
self._log_dir = None
self._log_file = defaultdict(lambda: None)
self._force... | 44.287671 | 115 | 0.588308 | [
"Apache-2.0"
] | wzf92/rqalpha | rqalpha/mod/rqalpha_mod_force_close/mod.py | 3,233 | Python |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2018 damian <damian@C-DZ-E5500>
#
# Distributed under terms of the MIT license.
"""
"""
import subprocess
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
import yaml
def read_file(filename):
with open(f... | 19.757576 | 52 | 0.691718 | [
"Apache-2.0"
] | DamZiobro/coding_playground | bandit/insecureCode.py | 653 | Python |
# Python program to reverse a linked list
# Time Complexity : O(n)
# Space Complexity : O(1)
# Node Class
class Node:
# Constructor to initialize the node object
def __init__(self, data):
self.data = data
self.next = None # In python, None == null
class LinkedList:
# Constructor to initi... | 21.87037 | 77 | 0.609088 | [
"MIT"
] | AayushTyagi1/DSA-Library | Data_Structures/LinkedList/Reverse_List/reverse_LinkedList.py | 3,543 | Python |
#
# PySNMP MIB module SENAO-ENTERPRISE-INDOOR-AP-CB-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SENAO-ENTERPRISE-INDOOR-AP-CB-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:53:40 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using P... | 119.018018 | 3,826 | 0.756983 | [
"Apache-2.0"
] | agustinhenze/mibs.snmplabs.com | pysnmp/SENAO-ENTERPRISE-INDOOR-AP-CB-MIB.py | 26,422 | Python |
import bthomehub
client = bthomehub.BtHomeClient('192.168.0.254')
client.authenticate()
values = client.get_values()
print('DownstreamRate = ' + str(float(values["Device/DSL/Channels/Channel[@uid='1']/DownstreamCurrRate"]) / 1000))
print('UpstreamRate = ' + str(float(values["Device/DSL/Channels/Channel[@uid='1']/Up... | 46.625 | 120 | 0.72118 | [
"Unlicense"
] | abaitken/bthomehub_client | example.py | 746 | Python |
import asyncio
import dataclasses
import time
import traceback
from secrets import token_bytes
from typing import Dict, List, Optional, Tuple, Set
from blspy import AugSchemeMPL, G2Element
from chiabip158 import PyBIP158
import chia.server.ws_connection as ws
from chia.consensus.block_creation import create_unfinishe... | 47.811796 | 120 | 0.645049 | [
"Apache-2.0"
] | AppleOfEnlightenment/chia-blockchain | chia/full_node/full_node_api.py | 72,148 | Python |
import requests, json
from time import sleep
from datetime import datetime
import sys
import traceback
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("outputfile", nargs='?', default="bitcoin_price.json")
parser.add_argument("errorfile", nargs='?', default="bitcoin_price_error.txt")
args = pa... | 30.939394 | 128 | 0.644466 | [
"MIT"
] | OrhanAbuska/Bitcoin-Prediction-Master | get_bitcoin_new.py | 1,021 | Python |
"""
Provide a mock switch platform.
Call init before using it in your tests to ensure clean test data.
"""
from homeassistant.const import STATE_ON, STATE_OFF
from tests.common import MockToggleDevice
DEVICES = []
def init(empty=False):
"""Initialize the platform with devices."""
global DEVICES
DEVICE... | 24.464286 | 72 | 0.686131 | [
"Apache-2.0"
] | DevRGT/home-assistant | tests/testing_config/custom_components/switch/test.py | 685 | Python |
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name="listings"),
path('<int:listing_id>', views.listing, name="listing"),
path('search', views.search, name="search")
]
| 22.2 | 60 | 0.662162 | [
"MIT"
] | toyerovsky/btre-project | listings/urls.py | 222 | Python |
#AST transform that puts programs in SSA form
import collections
from translate import *
class SSAVisitor(Visitor):
def __init__(self):
# Number of static assignments to that variable seen so far.
self.definition_counter = collections.defaultdict(int)
# Name of the live definition of each v... | 38.62987 | 92 | 0.525635 | [
"MIT"
] | gpoesia/sketchy | ssa.py | 5,949 | Python |
from __future__ import absolute_import
from __future__ import unicode_literals
import docker
import pytest
from docker.constants import DEFAULT_DOCKER_API_VERSION
from docker.errors import APIError
from docker.errors import NotFound
from .. import mock
from .. import unittest
from compose.config.errors import Depende... | 37.531378 | 101 | 0.599226 | [
"Apache-2.0"
] | BEllis/compose | tests/unit/service_test.py | 55,021 | Python |
import subprocess
import pymongo
class ReportsDataBase:
def __init__(self, url, db_name):
self.db_name = db_name
self.db = pymongo.MongoClient(url)[self.db_name]
self.db['reports'].create_index('group')
self.db['reports'].create_index('author')
self.db['reports'].create_i... | 36.567857 | 108 | 0.514601 | [
"MIT"
] | moevm/nosql1h19-report-stats | src/database/reports_data_base.py | 10,239 | Python |
# coding: utf-8
"""
Velo Payments APIs
## Terms and Definitions Throughout this document and the Velo platform the following terms are used: * **Payor.** An entity (typically a corporation) which wishes to pay funds to one or more payees via a payout. * **Payee.** The recipient of funds paid out by a payor.... | 52.376812 | 4,651 | 0.666021 | [
"Apache-2.0"
] | velopaymentsapi/velo-python | velo_payments/models/name2.py | 10,846 | Python |
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'calculator2.ui'
#
# Created by: PyQt5 UI code generator 5.15.3
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 impor... | 45.326203 | 80 | 0.616505 | [
"MIT"
] | Eqwe-Wewe/accounting-calc | gui_calculator.py | 16,968 | Python |
"""
Seed-based connectivity on the surface
=======================================
The dataset that is a subset of the enhanced NKI Rockland sample
(http://fcon_1000.projects.nitrc.org/indi/enhanced/, Nooner et al, 2012)
Resting state fMRI scans (TR=645ms) of 102 subjects were preprocessed
(https://github.com/fliem/n... | 40.791139 | 79 | 0.636618 | [
"BSD-2-Clause"
] | QinglinDong/nilearn-deep | examples/01_plotting/plot_surf_stat_map.py | 6,445 | Python |
import logging
import sys
from abc import abstractmethod
from typing import TextIO
import pandas as pd
from datapackage import Package
from pandas_datapackage_reader import read_datapackage
from sqlalchemy import create_engine
from otoole import read_packaged_file
logger = logging.getLogger(__name__)
class DataPac... | 30.425 | 92 | 0.598877 | [
"MIT"
] | chrwm/otoole | src/otoole/preprocess/narrow_to_datafile.py | 7,302 | Python |
from __future__ import absolute_import
from jinja2 import Environment
def environment(**kwargs):
extensions = [] if 'extensions' not in kwargs else kwargs['extensions']
extensions.append('sass_processor.jinja2.ext.SassSrc')
kwargs['extensions'] = extensions
return Environment(**kwargs)
| 25.583333 | 75 | 0.749186 | [
"MIT"
] | AstraLuma/django-sass-processor | tests/jinja2.py | 307 | Python |
# Data from https://www.kaggle.com/crawford/80-cereals/version/2
import pandas, matplotlib
data = pandas.read_csv('http://www.compassmentis.com/wp-content/uploads/2019/04/cereal.csv')
data = data.set_index('name')
data = data.calories.sort_values()[-10:]
ax = data.plot(kind='barh')
ax.set_xlabel('Calories per serving')... | 38.166667 | 92 | 0.766376 | [
"MIT"
] | CompassMentis/practical_python_in_10_lines | read_csv_and_plot/read_and_plot.py | 458 | Python |
#!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Copyright (C) 2008 Evan Martin <martine@danga.com>
"""A git-command for integrating reviews on Rietveld and Gerrit."""
from __f... | 37.336608 | 80 | 0.654348 | [
"BSD-3-Clause"
] | wuyong2k/chromium_depot_tool | git_cl.py | 190,006 | Python |
import numpy as np
from hqca.core import *
from hqca.core.primitives import *
from hqca.tools import *
import sys
from numpy import sin as sin
from numpy import cos as cos
from copy import deepcopy as copy
class ExpPauli:
def __init__(self,vec):
v = np.asmatrix(vec)
if v.shape[0]>v.shape[1]:
... | 29.304688 | 68 | 0.466276 | [
"Apache-2.0"
] | damazz/HQCA | examples/r2021_arxiv_qcase_benzyne/_instruct_22.py | 3,751 | Python |
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
# Copyright (c) 2010 Citrix Systems, Inc.
# Copyright (c) 2011 Piston Cloud Computing, Inc
# Copyright (c) 2012 University Of Minho
# (c) Copyright 2013 Hewlett-Pa... | 43.114281 | 79 | 0.568124 | [
"Apache-2.0"
] | srajag/nova | nova/virt/libvirt/driver.py | 244,846 | Python |
# Copyright 2018 Braxton Mckee
#
# 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 t... | 32.813559 | 106 | 0.710744 | [
"Apache-2.0"
] | braxtonmckee/nativepython | object_database/service_manager/ServiceBase.py | 1,936 | Python |
# Generated by Django 2.0.5 on 2018-12-04 13:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('branch', '0007_auto_20181204_2034'),
]
operations = [
migrations.AddField(
model_name='authentication',
name='sty',
... | 21.7 | 60 | 0.601382 | [
"Apache-2.0"
] | 106626/Practical | Demo/branch/migrations/0008_authentication_sty.py | 434 | 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 (the
# "License"); you may not u... | 38.317829 | 74 | 0.752377 | [
"Apache-2.0"
] | Explorer1092/aliyun-openapi-python-sdk | aliyun-python-sdk-dyplsapi/aliyunsdkdyplsapi/request/v20170525/BindAxnRequest.py | 4,943 | Python |
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, DateTime, LargeBinary, Float, UniqueConstraint
from sqlalchemy.orm import relationship, backref
from datetime import datetime
from conductor.app.db.base_class import Base
class DiscoveryResult(Base):
__tablename__ = "discovery_results"
__ta... | 38.526316 | 115 | 0.741803 | [
"MIT"
] | PHT-EU/central-conductor | conductor/app/models/discovery.py | 732 | Python |
import re
import jieba
import jieba.posseg as pseg
def split2sens(text):
pstop = re.compile(rf'[。!??!…]”*')
sens = []
stoplist = pstop.findall(text)
senlist = []
for sen in pstop.split(text):
if len(sen) == 0:
continue
senlist.append(sen)
for i, sen in enumerate(sen... | 20.029412 | 38 | 0.543319 | [
"MIT"
] | fcoolish/All4NLP | nbt/splittext/splittext.py | 691 | Python |
## @package attention
# Module caffe2.python.attention
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
class AttentionType:
Regular, Recurrent = range(2)
def s(scope, name):
# We have to manually scope due t... | 28.926199 | 78 | 0.694221 | [
"MIT"
] | Excalibur0214/Hello-world | caffe2/python/attention.py | 7,839 | Python |
# -*- coding: utf-8 -*-
from sqlalchemy import Column, String, Float
from sqlalchemy.ext.declarative import declarative_base
from zvt.contract import Mixin
from zvt.contract.register import register_schema
MoneyFlowBase = declarative_base()
# 板块资金流向
class BlockMoneyFlow(MoneyFlowBase, Mixin):
__tablename__ = '... | 24 | 84 | 0.700893 | [
"MIT"
] | Bruce-Dudu/zvt | zvt/domain/misc/money_flow.py | 2,132 | Python |
# -*- coding: utf-8 -*-
"""Identity Services Engine getAllowedProtocolById data model.
Copyright (c) 2021 Cisco and/or its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without rest... | 32.425993 | 80 | 0.416388 | [
"MIT"
] | oianson/ciscoisesdk | tests/models/validators/v3_0_0/jsd_e3ddfddd45e299f14ed194926f8de.py | 8,982 | Python |
#! /usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2019/3/10 7:44 PM
# @Author : xiaoliji
# @Email : yutian9527@gmail.com
"""
找出和为s的数字。
>>> nums = [1, 2, 4, 7, 11, 15]
>>> FindNumbersWithSum(nums, 15)
(4, 11)
"""
def FindNumbersWithSum(array: list, tsum: int) -> tuple:
l, r = 0, len(a... | 21.916667 | 56 | 0.48289 | [
"Apache-2.0"
] | ck76/awesome-cs | Algorithm/coding_interviews/Python/sword-for-offer/57_find_num_with_sum.py | 542 | Python |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# This file is part of REANA.
# Copyright (C) 2017, 2018, 2019, 2020, 2021, 2022 CERN.
#
# REANA is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""REANA Job Controller models."""
from ... | 37.203704 | 96 | 0.664759 | [
"MIT"
] | focilo/focilo-job-controller | reana_job_controller/schemas.py | 4,018 | Python |
from django import forms
from models import *
class QuestionForm(forms.ModelForm):
def __init__(self, user = None, *args, **kwargs):
self.user = user
super(QuestionForm, self).__init__(*args, **kwargs)
def save(self):
question = Question(user = self.user, category = self.c... | 31.136364 | 171 | 0.587591 | [
"BSD-3-Clause"
] | agiliq/django-answrs | answrs/aforms.py | 1,370 | Python |
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "vote_project.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that... | 35.217391 | 77 | 0.644444 | [
"MIT"
] | dasap89/django_test_tutorial | vote_project/manage.py | 810 | Python |
"""A setuptools based setup module.
See:
https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject
"""
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path
here = path.absp... | 39.626506 | 112 | 0.686683 | [
"BSD-3-Clause"
] | AkatsukiCC/pretrained-models.pytorch | setup.py | 6,578 | Python |
# encoding: utf-8
#
# Copyright 2009-2020 Greg Neagle.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable l... | 40.826893 | 80 | 0.617831 | [
"Apache-2.0"
] | Artoria2e5/munki | code/client/munkilib/updatecheck/catalogs.py | 26,415 | Python |
#--- Exercício 1 - Funções - 1
#--- Escreva uma função que imprima um cabeçalho
#--- O cabeçalho deve ser escrito usando a multiplicação de carácter
#--- resultado esperado: -------------- Cadastro Serasa --------------------------
#--- O cabeçalho deve conter o nome de uma empresa, que será uma variável
#--- Realize... | 40.769231 | 82 | 0.658491 | [
"MIT"
] | AmandaRH07/Entra21_Python | 01-Exercicios/Aula007/Ex1.py | 545 | Python |
# coding=utf-8
from typing import Iterable
from .registry import registry
@registry.register("A000073")
def tribonacci() -> Iterable[int]:
"""Tribonacci numbers."""
yield 0
yield 0
yield 1
p3: int = 0 # tribonacci(0)
p2: int = 0 # tribonacci(1)
p1: int = 1 # tribonacci(2)
while Tru... | 20.45 | 34 | 0.581907 | [
"MIT"
] | reidhoch/oeis-seq | oeis/tribonacci.py | 409 | Python |
from dataclasses import dataclass
from enum import IntEnum
from typing import Optional, Dict
from blspy import G1Element
from wheat.protocols.pool_protocol import POOL_PROTOCOL_VERSION
from wheat.types.blockchain_format.coin import Coin
from wheat.types.blockchain_format.program import Program
from wheat.types.blockc... | 38.87069 | 117 | 0.758261 | [
"Apache-2.0"
] | Jsewill/wheat-blockchain | wheat/pools/pool_wallet_info.py | 4,509 | Python |
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
# SPDX-FileCopyrightText: Copyright (c) 2022 Jeff Epler for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
# On an Adafruit Feather M4 or Adafruit Feather RP2040 with Floppy Featherwing,
# do some track-to-track seeking and flu... | 24.77551 | 79 | 0.682043 | [
"MIT"
] | jepler/Adafruit_CircuitPython_floppy | examples/floppy_simpletest.py | 1,214 | Python |
"""Code and data structures for managing source directives."""
import bisect
import collections
import re
import sys
import tokenize
from pytype import utils
from six import moves
_DIRECTIVE_RE = re.compile(r"#\s*(pytype|type)\s*:\s?([^#]*)")
_CLOSING_BRACKETS_RE = re.compile(r"^(\s*[]})]\s*)+(#.*)?$")
_WHITESPACE_R... | 38.013468 | 80 | 0.66519 | [
"Apache-2.0"
] | Flameeyes/pytype | pytype/directors.py | 11,290 | Python |
from .utils import make_cobertura
def remove_style_tag(html):
style_pattern_start = '\n <style>'
style_pattern_stop = '\n </style>'
style_starts = html.find(style_pattern_start)
style_stops = html.find(style_pattern_stop) + len(style_pattern_stop)
html_nostyle = html[:style_starts] + html[st... | 29.940919 | 224 | 0.529708 | [
"MIT"
] | kannaiah/pycobertura | tests/test_reporters.py | 13,683 | Python |
import os
import time
import torch
import torch.nn as nn
import utils
from torch.autograd import Variable
import numpy as np
import matplotlib.pyplot as plt
def instance_bce_with_logits(logits, labels):
assert logits.dim() == 2
loss = nn.functional.binary_cross_entropy_with_logits(logits, labels)
loss *... | 33.942857 | 132 | 0.617284 | [
"MIT"
] | SinghJasdeep/Attention-on-Attention-for-VQA | train.py | 3,564 | Python |
import asyncio
import decimal
import unittest
class DecimalContextTest(unittest.TestCase):
def test_asyncio_task_decimal_context(self):
async def fractions(t, precision, x, y):
with decimal.localcontext() as ctx:
ctx.prec = precision
a = decimal.Deci... | 29.7 | 66 | 0.535354 | [
"BSD-3-Clause"
] | DISOGitHub/FastCAE | output/python37/Lib/test/test_asyncio/test_context.py | 891 | Python |
from collections import defaultdict
from hashlib import md5
from typing import DefaultDict, Dict, List, Set, Union
import attr
from pyrdf2vec.graphs import KG, Vertex
from pyrdf2vec.typings import Entities, EntityWalks, SWalk
from pyrdf2vec.walkers import RandomWalker
@attr.s
class WLWalker(RandomWalker):
"""We... | 34.716495 | 79 | 0.580995 | [
"MIT"
] | vishalbelsare/pyRDF2Vec | pyrdf2vec/walkers/weisfeiler_lehman.py | 6,735 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.