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 |
|---|---|---|---|---|---|---|---|---|
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------... | 41.403162 | 104 | 0.664916 | [
"MIT"
] | DaeunYim/pgtoolsservice | tests/hosting/test_server.py | 20,950 | Python |
from setuptools import setup, find_packages
VERSION = '0.0.1'
DESCRIPTION = 'edu-lib'
LONG_DESCRIPTION = 'Libary zum erlernen der Grundstruktur.'
setup(
name="mylibrary",
version=VERSION,
author="Stephan Bökelmann",
author_email="[email protected]",
scripts=[],
description... | 26.192308 | 59 | 0.581498 | [
"MIT"
] | bjoekeldude/edu_python_mini_lib | setup.py | 682 | Python |
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi SDK Generator. ***
# *** 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
from ... import _utilities, _tables
from... | 51.065789 | 2,057 | 0.675213 | [
"Apache-2.0"
] | pulumi-bot/pulumi-azure-native | sdk/python/pulumi_azure_native/netapp/v20200901/account.py | 7,762 | Python |
from django.test import TestCase
from blog.models import Entry
class EntryModelTest(TestCase):
def test_string_representation(self):
entry = Entry(title="My entry title")
self.assertEqual(str(entry), entry.title)
def test_verbose_name_plural(self):
self.assertEqual(str(Entry._meta.ve... | 27 | 73 | 0.735043 | [
"BSD-2-Clause"
] | elinguiuriel/djangoTDD | code/blog/tests/test_models.py | 351 | Python |
import os
import logging
from django.conf import settings
from django.utils import translation
from django.utils.translation import gettext_lazy as _
from django.db import transaction
from django.core.files.base import ContentFile
from celery.exceptions import SoftTimeLimitExceeded
from froide.celery import app as c... | 28.307263 | 87 | 0.677719 | [
"MIT"
] | MrKrisKrisu/froide | froide/foirequest/tasks.py | 10,134 | Python |
from __future__ import absolute_import
import pytest
from changes.expanders.commands import CommandsExpander
from changes.testutils import TestCase
class CommandsExpanderTest(TestCase):
def setUp(self):
super(CommandsExpanderTest, self).setUp()
self.project = self.create_project()
def get_e... | 31.785714 | 56 | 0.626966 | [
"Apache-2.0"
] | dropbox/changes | tests/changes/expanders/test_commands.py | 1,335 | Python |
"""Parse Warren2020 fluxes.
Fluxes from https://zenodo.org/record/3952926 (DOI:10.5281/zenodo.3952926)
See https://arxiv.org/abs/1902.01340 and https://arxiv.org/abs/1912.03328
for description of the models.
"""
import h5py
from sntools.formats import gamma, get_starttime, get_endtime
flux = {}
def parse_input(in... | 30.578125 | 94 | 0.633112 | [
"BSD-3-Clause"
] | arfon/sntools | sntools/formats/warren2020.py | 1,957 | Python |
# Copyright 2016 Google 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
#
# Unless required by applicable law or agreed to in writing, ... | 30.278689 | 74 | 0.646995 | [
"Apache-2.0"
] | Acidburn0zzz/python-docs-samples | appengine/standard/users/main.py | 1,847 | Python |
"""
ASGI config for avocadobites project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_... | 23.588235 | 78 | 0.790524 | [
"MIT"
] | sanjuop/PatrioticPictures | avocadobites/avocadobites/asgi.py | 401 | Python |
"""
eZmax API Definition
This API expose all the functionnalities for the eZmax and eZsign applications. # noqa: E501
The version of the OpenAPI document: 1.1.3
Contact: [email protected]
Generated by: https://openapi-generator.tech
"""
import sys
import unittest
import eZmaxApi
from eZmaxA... | 26.846154 | 97 | 0.747851 | [
"MIT"
] | eZmaxinc/eZmax-SDK-python | test/test_ezsignformfield_response_compound.py | 1,047 | Python |
import os
import shutil
import tempfile
from unittest import TestCase
from mock import patch
from regulations.apps import RegulationsConfig
class RegulationsConfigTests(TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp()
def tearDown(self):
shutil.rmtree(self.tmpdir)
@patch('r... | 34.516129 | 70 | 0.695327 | [
"CC0-1.0"
] | CMSgov/cmcs-eregulations | regulations/tests/apps_tests.py | 1,070 | Python |
import random
from player import Player
from hand import Hand
class CPU(Player):
def __init__(self, name: str):
super().__init__(name)
self.hand = Hand()
def discard(self):
if(self.hand == None or len(self.hand) <= 0):
raise RuntimeError('No cards to discard')
retur... | 39.5 | 89 | 0.646624 | [
"MIT"
] | SudoSpartanDan/CribbagePythonGame | cpu.py | 948 | Python |
"""@package vc_updated
Functions to implement the updated Voce-Chaboche material model and measure its error.
"""
import numpy as np
import pandas as pd
from numdifftools import nd_algopy as nda
def uvc_return_mapping(x_sol, data, tol=1.0e-8, maximum_iterations=1000):
""" Implements the time integration of the up... | 38.755495 | 119 | 0.641455 | [
"MIT"
] | AlbanoCastroSousa/RESSPyLab | RESSPyLab/uvc_model.py | 14,107 | Python |
import wikipedia as wiki
from ..parsing import get_wiki_page_id, get_wiki_lines, get_wiki_sections
def get_wiki_references(url, outfile=None):
"""get_wiki_references.
Extracts references from predefined sections of wiki page
Uses `urlscan`, `refextract`, `doi`, `wikipedia`, and `re` (for ArXiv URLs)
:... | 41 | 94 | 0.622593 | [
"MIT"
] | antimike/citation-scraper | scraper/apis/wikipedia.py | 1,558 | Python |
from armulator.armv6.opcodes.abstract_opcodes.mov_register_thumb import MovRegisterThumb
from armulator.armv6.opcodes.opcode import Opcode
class MovRegisterThumbT2(MovRegisterThumb, Opcode):
def __init__(self, instruction, m, d):
Opcode.__init__(self, instruction)
MovRegisterThumb.__init__(self, T... | 31.904762 | 88 | 0.674627 | [
"MIT"
] | AhmedMounir/armulator | armulator/armv6/opcodes/thumb_instruction_set/thumb_instruction_set_encoding_16_bit/thumb_shift_immediate_add_subtract_move_and_compare/mov_register_thumb_t2.py | 670 | Python |
class DefaultConfig(object):
DEBUG = False
JSONIFY_PRETTYPRINT_REGULAR = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
API_PREFIX = '/api'
| 25.666667 | 42 | 0.74026 | [
"MIT"
] | sz-piotr/fioletowe-pomarancze | server/src/config.py | 154 | Python |
from concurrent.futures.process import ProcessPoolExecutor
import api.Config
import api.middleware
from api.Config import app
from api.routers import (feedback, hiscore, label, legacy, legacy_debug,
player, prediction, report, scraper)
app.include_router(hiscore.router)
app.include_router(pl... | 25.878788 | 72 | 0.757611 | [
"BSD-2-Clause"
] | ThorntonMatthewD/Bot-Detector-Core-Files | api/app.py | 854 | Python |
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
import os
import subprocess
OTBN_DIR = os.path.join(os.path.dirname(__file__), '../../..')
UTIL_DIR = os.path.join(OTBN_DIR, 'util')
SIM_DIR = os.path.join(os.path.dirnam... | 30.607143 | 74 | 0.690782 | [
"Apache-2.0"
] | OneToughMonkey/opentitan | hw/ip/otbn/dv/otbnsim/test/testutil.py | 857 | Python |
import numpy as np
from .VariableUnitTest import VariableUnitTest
from gwlfe.MultiUse_Fxns.Discharge import UrbanQTotal
class TestUrbanQTotal(VariableUnitTest):
def test_UrbanQTotal(self):
z = self.z
np.testing.assert_array_almost_equal(
UrbanQTotal.UrbanQTotal_f(z.NYrs, z.DaysMonth,... | 43.823529 | 119 | 0.606711 | [
"Apache-2.0"
] | rajadain/gwlf-e | test/unittests/test_UrbanQTotal.py | 745 | Python |
#Find,Remove,Find
"""Return a tuple of the indices of the two smallest values in list L.
>>> items = [809, 834, 477, 478, 307, 122, 96, 102, 324, 476]
>>> find_two_smallest(items)
(6, 7)
>>> items == [809, 834, 477, 478, 307, 122, 96, 102, 324, 476]
True
"""
from typing import List, Tuple
def fin... | 24.3 | 70 | 0.614198 | [
"MIT"
] | YordanIH/Intro_to_CS_w_Python | chapter12/examples/example02.py | 972 | Python |
from __future__ import absolute_import, print_function
import logging
import bokeh.server.tornado as tornado
from bokeh.application import Application
from bokeh.client import pull_session
from bokeh.server.views.static_handler import StaticHandler
from .utils import ManagedServerLoop, url
logging.basicConfig(leve... | 42.732759 | 80 | 0.65463 | [
"BSD-3-Clause"
] | Maluuba/bokeh | bokeh/server/tests/test_tornado.py | 4,957 | Python |
#!/usr/bin/env python
# Copyright 2015 Luminal, 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
#
# Unless required by applicable law o... | 40.668459 | 107 | 0.524567 | [
"Apache-2.0"
] | traveloka/credstash | credstash.py | 22,693 | Python |
host = "localhost"
port = 1111
max_users = 100
buffer_size = 1024
| 11.166667 | 18 | 0.716418 | [
"MIT"
] | iskrich/simplechat | params.py | 67 | Python |
"""
Django settings for lab01 project.
Generated by 'django-admin startproject' using Django 3.2.6.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
fr... | 26.674603 | 92 | 0.675097 | [
"MIT"
] | car1os1/TECSUP-DAE-2021-2-B | lab01/lab01/settings.py | 3,361 | Python |
# Copyright 2018, Kay Hayen, mailto:[email protected]
#
# Python tests originally created or extracted from other peoples work. The
# parts were too small to be protected.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the ... | 25.561644 | 79 | 0.665595 | [
"Apache-2.0"
] | 4O4/Nuitka | tests/basics/Unpacking35.py | 1,866 | Python |
# Copyright (c) OpenMMLab. All rights reserved.
import torch.nn as nn
import torch.utils.checkpoint as cp
from mmcv.cnn import ConvModule
from mmcv.runner import BaseModule
from torch.nn.modules.batchnorm import _BatchNorm
from mmcls.models.utils import make_divisible
from ..builder import BACKBONES
from .base_backbon... | 36.639706 | 173 | 0.553783 | [
"Apache-2.0"
] | ChaseMonsterAway/mmclassification | mmcls/models/backbones/mobilenet_v2.py | 9,966 | Python |
import glob
import time
from os import path
from flask import Blueprint, jsonify, current_app, request, Response, json
from flask_login import login_required
from .. import pz_server_state
from ..services.power_actions_service import is_valid_power_action, execute_action
from ..services.server_options_service import ... | 29.8 | 119 | 0.68698 | [
"MIT"
] | emilio2hd/pz-panel | panel/routes/server.py | 3,725 | Python |
import pytest
from receptor.router import MeshRouter
test_networks = [
(
[
("a", "b", 1),
("a", "d", 1),
("a", "f", 1),
("b", "d", 1),
("b", "c", 1),
("c", "e", 1),
("c", "h", 1),
("c", "j", 1),
("e"... | 31.745098 | 88 | 0.413218 | [
"Apache-2.0"
] | RedHatOfficial/receptor | test/unit/test_router.py | 1,619 | Python |
"""
多线程操作共享的全局变量是不安全的,多线程操作局部 只归某个线程私有,其他线程是不能访问的
"""
import threading
def do_sth(arg1, arg2, arg3):
local_var1 = arg1
local_var2 = arg2
local_var3 = arg3
fun1(local_var1, local_var2, local_var3)
fun2(local_var1, local_var2, local_var3)
fun3(local_var1, local_var2, local_var3)
def fun1(loca... | 27.189189 | 78 | 0.61332 | [
"Apache-2.0"
] | hemuke/python | 17_process_thread/46_why_need_ThreadLocal.py | 1,094 | Python |
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Copyright 2011-2019, Nigel Small
#
# 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
#
# Unle... | 31.114583 | 83 | 0.61165 | [
"Apache-2.0"
] | CyberGRX/py2neo | test/unit/test_cypher_encoding.py | 5,974 | Python |
# Written by David Weber
# [email protected]
"""
In this short namespace I house a class that connects to PDB and downloads
file over PDB file transfer protocol.
"""
# ------------------------------------------------------------------------------
import gzip
from os import remove, getcwd, path # built in
# m... | 28.222222 | 81 | 0.494273 | [
"MIT"
] | dsw7/BridgingInteractions | scalene-triangle/libs/PDB_filegetter.py | 2,794 | Python |
# -*- coding: utf-8 -*-
#Chucky_Bot
import LINETCR
from LINETCR.lib.curve.ttypes import *
from datetime import datetime
from bs4 import BeautifulSoup
from threading import Thread
from googletrans import Translator
from gtts import gTTS
import time,random,sys,json,codecs,threading,glob,urllib,urllib2,urllib3,re,ast,os,... | 40.951759 | 443 | 0.429363 | [
"MIT"
] | azmi155/mu | ma.py | 177,124 | Python |
# -*- coding: utf-8 -*-
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import time
from PIL import Image
import random
import os
from sample import sample_conf
from tensorflow.python.framework.errors_impl import NotFoundError
# 设置以下环境变量可开启CPU识别
# os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_I... | 39.534965 | 122 | 0.580437 | [
"Apache-2.0"
] | shineyjg/cnn_captcha | train_model.py | 12,141 | Python |
# -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# The idea for this module (but no code) was borrowed from the
# quantities (http://pythonhosted.org/quantities/) package.
"""Helper functions for Quantity.
In particular, this implements the logic that determines scaling and resul... | 35.461916 | 79 | 0.677406 | [
"BSD-3-Clause"
] | PriyankaH21/astropy | astropy/units/quantity_helper/helpers.py | 14,433 | Python |
# Uses python3
import sys
def get_change(money, coins):
t = [j+1 for j in range(money+1)]
# boundary condition
t[0] = 0
for j in range(1, money+1):
for c in coins:
if c <= j:
t[j] = min(t[j], 1+t[j-c])
return t[money]
if __name__ == '__main__':
coins =... | 18.714286 | 42 | 0.516539 | [
"MIT"
] | vishweshwartyagi/Data-Structures-and-Algorithms-UCSD | 1. Algorithmic Toolbox/week5_dynamic_programming1/1_money_change_again.py | 393 | Python |
from sepal_ui import sepalwidgets as sw
from ipywidgets import dlink
from component import parameter as cp
class ParamTile(sw.Card):
def __init__(self, model):
# read the model
self.model = model
# add the base widgets
self.close = sw.Icon(children=["mdi-close"], small=True)
... | 26.355932 | 86 | 0.540836 | [
"MIT"
] | 12rambau/weplan | component/tile/param_tile.py | 1,555 | Python |
#! /usr/bin/env python
"""Functions for working with the DLRN API"""
import csv
import os.path
import requests
from toolchest import yaml
from atkinson.config.manager import ConfigManager
from atkinson.logging.logger import getLogger
def _raw_fetch(url, logger):
"""
Fetch remote data and return the text ou... | 32.692308 | 79 | 0.565546 | [
"MIT"
] | jpichon/atkinson | atkinson/dlrn/http_data.py | 5,950 | Python |
"""
Module for the selection of machine learning models.
There are several different functions which can perform the model selection: all of them have an intuitive interface, but
are also powerful and flexible.
In addition, almost all these functions can optionally make plots, which sum up the performed selection... | 52.110855 | 130 | 0.664643 | [
"MIT"
] | EnricoPittini/model-selection | model_selection.py | 67,692 | Python |
from asyncio import AbstractEventLoop
from asyncio import iscoroutinefunction
from collections import defaultdict
from typing import Any
from typing import Callable
from typing import DefaultDict
from typing import Dict
from typing import NamedTuple
from typing import Set
from typing import Tuple
from .api.master_api_... | 27.55814 | 76 | 0.613924 | [
"Apache-2.0"
] | mgrrx/aioros | src/aioros/param_manager.py | 2,370 | Python |
#!/usr/bin/env python3
import importlib.machinery as imm
import logging
import pathlib
import re
import configargparse
class ModuleInfo:
def __init__(self, path):
self.path = pathlib.Path(path)
name = str(self.path.parent / self.path.stem)
name = name.replace("/", ".")
self.name =... | 21.927536 | 82 | 0.637145 | [
"Apache-2.0"
] | 18445864529/espnet | doc/argparse2rst.py | 1,513 | Python |
"""
util_list module. Contains the mflist class.
This classes encapsulates modflow-style list inputs away
from the individual packages. The end-user should not need to
instantiate this class directly.
some more info
"""
from __future__ import division, print_function
import os
import warnings
import numpy a... | 34.349807 | 81 | 0.49012 | [
"CC0-1.0",
"BSD-3-Clause"
] | aleaf/flopy | flopy/utils/util_list.py | 44,483 | Python |
# -*- coding: utf-8 -*-
import requests
from webs.api.exceptions.customs import ServerError, InvalidAPIRequest, RecordNotFound, RecordAlreadyExists
class RequestMixin(object):
CODE_EXCEPTION_MSG = {
400: InvalidAPIRequest,
404: RecordNotFound,
409: RecordAlreadyExists,
422: Inva... | 30.230769 | 107 | 0.632316 | [
"Apache-2.0"
] | c89758971/crawloop | services/engine/webs/core/requests/request.py | 1,624 | Python |
import os
import re
import codecs
def isValidLine(line):
if re.search('include \"', line) == None or line.find('.PSVita') != -1 or line.find('.PS4') != -1 or line.find('.Switch') != -1 or line.find('.XBoxOne') != -1:
return True
return False
class CreateHeader:
def __init__(self):
self.lines = []
def addLine... | 57.757143 | 160 | 0.852461 | [
"Apache-2.0",
"BSD-3-Clause"
] | Shockblast/Effekseer | Dev/Cpp/CreateHeader.py | 8,086 | Python |
import wx.stc as stc
def highlight(editor, styles, faces):
editor.SetLexer(stc.STC_LEX_YAML)
editor.StyleSetSpec(stc.STC_YAML_DEFAULT, "fore:" +
styles["default"] + ",face:%(helv)s,size:%(size)d" % faces)
editor.StyleSetSpec(stc.STC_YAML_COMMENT, "fore:" +
... | 35.043478 | 86 | 0.569479 | [
"MIT"
] | ShardulNalegave/pycode | yamlHighlighter.py | 806 | Python |
import pickle
import os
from tqdm import tqdm
with open('../data/bawe_splits.p', 'rb') as f:
splits = pickle.load(f)
if not os.path.isdir('../data/preprocess/bawe-group'):
os.mkdir('../data/preprocess/bawe-group')
for filename in tqdm(splits['train']):
id = filename[:4]
with open(f'../data/bawe/CORPU... | 29.142857 | 79 | 0.609477 | [
"Apache-2.0"
] | grchristensen/avpd | notebooks/develop/2021-02-18-gc-bawe-data-grouping.py | 612 | Python |
# -*- coding: utf-8 -*-
from flask import Blueprint, jsonify
from flask_service.swagger import spec
__all__ = ['main_app']
main_app = Blueprint('main_app', __name__)
@main_app.route('/api')
def swagger():
"""
Responds with the OpenAPI specification for this application.
"""
return jsonify(spec.to_d... | 24.2 | 77 | 0.677686 | [
"Apache-2.0"
] | mwprog/atomist-flask-microservice | flask_service/views.py | 968 | Python |
"""Principal Component Analysis Base Classes"""
# Author: Alexandre Gramfort <[email protected]>
# Olivier Grisel <[email protected]>
# Mathieu Blondel <[email protected]>
# Denis A. Engemann <[email protected]>
# Kyle Kastner <[email protected]>
... | 34.853659 | 88 | 0.618964 | [
"BSD-3-Clause"
] | 40104/Scikit-Learn | sklearn/decomposition/_base.py | 5,716 | Python |
from setuptools import setup
from os import path
from sys import version_info
def open_file(fname):
return open(path.join(path.dirname(__file__), fname))
setup_requires = ['pbr']
setup(
license='MIT',
setup_requires=setup_requires,
pbr=True,
auto_version="PBR",
install_requires=open(path.joi... | 21.222222 | 93 | 0.727749 | [
"MIT"
] | CuidaAdmin/django-alexa | setup.py | 382 | Python |
"""
enCount tasks and analyses.
enCount is a Python library for processing RNA-Seq data from ENCODE.
"""
# from ._version import __version__
from . import config # load from myconfig.py if it exists
from . import db
from . import queues
from . import encode
from . import externals
from . import gtfs
from . impor... | 19.190476 | 68 | 0.756824 | [
"MIT"
] | mstrazar/enCount | enCount/__init__.py | 403 | Python |
from asgiref.sync import sync_to_async
from channels.layers import get_channel_layer
from ....models import Participant
import humps
channel_layer = get_channel_layer()
def get_participant(room_channel_name, channel_name):
participant = Participant.objects.get(
channel_room__channel_name=room_channel_name... | 30.573333 | 87 | 0.66812 | [
"MIT"
] | Shadowsych/html5-msoy | server/websockets/consumers/world/broadcasts/avatar.py | 2,293 | Python |
"""Plot graphs from human-readable file formats."""
| 26 | 51 | 0.730769 | [
"MIT"
] | Sean1708/uniplot | uniplot/__init__.py | 52 | Python |
# https://www.hackerrank.com/challenges/tree-height-of-a-binary-tree/problem
def height(root):
"""
DFS
v = Vertices
e = Edges
d = Depth
Time complexity: O(v + e)
Space complexity: O(d)
"""
if root:
return 1 + max(height(root.left), height(root.right))
else:
... | 17.421053 | 76 | 0.567976 | [
"MIT"
] | danielfsousa/algorithms-solutions | HackerRank/Data Structures/Trees/height-of-a-binary-tree.py | 331 | Python |
from dbt.clients.system import load_file_contents
from dbt.contracts.files import (
FilePath, ParseFileType, SourceFile, FileHash, AnySourceFile, SchemaSourceFile
)
from dbt.parser.schemas import yaml_from_file
from dbt.parser.search import FilesystemSearcher
# This loads the files contents and creates the Sourc... | 37.457627 | 88 | 0.722398 | [
"Apache-2.0"
] | JLDLaughlin/dbt | core/dbt/parser/read_files.py | 4,420 | Python |
from typing import List
'''
1. subproblems: dp(amount) the minimum number of coins needed to make changes for amount of S using the given coin denomination
2. guessing: all the available denomination c_i
3. relate subproblems: dp(amount) = min(dp(amount - c_i) + 1) for all possible c_i
Time complexity: O(#subproblems... | 28.109589 | 127 | 0.520955 | [
"MIT"
] | sundaycat/Leetcode-Practice | solution/322. coin-change.py | 2,052 | Python |
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
config = {
'description': 'Raster Vector Analysis',
'author': 'Jan Kumor',
'url': 'http://github.com/akumor/python-rastervectoranalysis',
'download_url': 'http://github.com/akumor/python-rastervectoranalysis'... | 27.2 | 75 | 0.667279 | [
"Apache-2.0"
] | akumor/python-rastervectoranalysis | setup.py | 544 | Python |
from checkov.common.models.enums import CheckCategories
from checkov.terraform.checks.resource.base_resource_value_check import BaseResourceValueCheck
class PasswordPolicyLowercaseLetter(BaseResourceValueCheck):
def __init__(self):
name = "Ensure RAM password policy requires at least one lowercase letter"... | 38.333333 | 106 | 0.778261 | [
"Apache-2.0"
] | Eliran-Turgeman/checkov | checkov/terraform/checks/resource/alicloud/PasswordPolicyLowercaseLetter.py | 690 | Python |
import SimpleITK as sitk
import numpy as np
import torch
import math
import time
import sys
import cv2
from scipy.ndimage.interpolation import zoom
from torch.autograd import Variable
sys.path.append('../lung_nodule_detector')
from training.layers import nms
def load_itk_image(filename):
with open(filename) as f:... | 34.55774 | 135 | 0.572129 | [
"MIT"
] | JiazeWang/lung_nodule_integ_viewer | UI_util.py | 14,065 | Python |
# Copyright (c) 2021 Sen Wu. All Rights Reserved.
"""Helper function to set random seed for reproducibility of models."""
import logging
import random
from typing import Optional
import numpy as np
import torch
logger = logging.getLogger(__name__)
def set_random_seed(seed: Optional[int] = None) -> None:
"""S... | 27.555556 | 87 | 0.664516 | [
"MIT"
] | KeAWang/emmental | src/emmental/utils/seed.py | 1,240 | Python |
# -*- coding: utf-8 -*-
"""
Copyright (c) 2012 University of Oxford
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 the rights to use, copy, modif... | 39.803922 | 114 | 0.652956 | [
"MIT"
] | dataflow/RDFDatabank | rdfdatabank/lib/data_sync.py | 4,060 | Python |
import mysql.connector
import json
import os
import requests
def getAllFindings(host, database, user, password, table, where):
db = mysql.connector.connect(host=host, database=database, user=user, password=password)
cursor = db.cursor()
cursor.execute("SELECT distinct findingCode, specimenOrganCode FROM "... | 35.744186 | 149 | 0.561483 | [
"MIT"
] | erikvanmulligen/etransafe-heatmap | Concordance/condordance_utils.py | 4,611 | Python |
"""
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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 the rights to ... | 42.131579 | 87 | 0.723923 | [
"MIT-0"
] | SanderKnape/cfn-python-lint | test/rules/outputs/test_name.py | 1,601 | Python |
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------... | 46.142857 | 110 | 0.632353 | [
"MIT"
] | 6paklata/azure-cli | src/azure-cli/azure/cli/command_modules/iotcentral/commands.py | 1,292 | Python |
# Copyright 2015 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... | 42.787356 | 80 | 0.701903 | [
"Apache-2.0"
] | gameover27/hiptensorflow | tensorflow/python/ops/rnn.py | 44,670 | Python |
"""
Module containing NetPyNE metadata
"""
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
metadata = {
# ---------------------------------------... | 53.659082 | 467 | 0.323153 | [
"MIT"
] | Anjali-Agarwal8/netpyne | netpyne/metadata/metadata.py | 132,055 | Python |
#!/usr/bin/env python3
# Copyright (c) 2014-2017 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test mining RPCs
- getmininginfo
- getblocktemplate proposal mode
- submitblock"""
import copy
from b... | 41.058824 | 141 | 0.681411 | [
"MIT"
] | elliottminns/livecoin | test/functional/mining_basic.py | 5,584 | Python |
import tarfile
import textwrap
import pytoml
from .app import App
from .exceptions import TockLoaderException
from .tbfh import TBFHeader
class TAB:
'''
Tock Application Bundle object. This class handles the TAB format.
'''
def __init__ (self, tab_path):
self.tab = tarfile.open(tab_path)
def extract_app (sel... | 32.009709 | 107 | 0.693358 | [
"MIT"
] | torfmaster/tockloader | tockloader/tab.py | 3,297 | Python |
from __future__ import absolute_import
from __future__ import unicode_literals
import types
import copy
from django import forms
from django.forms.forms import NON_FIELD_ERRORS
from django.core.validators import EMPTY_VALUES
from django.db import models
from django.db.models.fields import FieldDoesNotExist
from djang... | 33.884692 | 106 | 0.582962 | [
"BSD-3-Clause"
] | aioTV/django-filter | django_filters/filterset.py | 17,044 | Python |
from BiblioAlly import catalog as cat, domain, translator as bibtex
class IeeeXTranslator(bibtex.Translator):
def _document_from_proto_document(self, proto_document):
bibtex.Translator._translate_kind(proto_document)
kind = proto_document['type']
fields = proto_document['field']
i... | 44.992806 | 117 | 0.605373 | [
"MIT"
] | gambit4348/BiblioAlly | BiblioAlly/ieee.py | 6,254 | Python |
"""empty message
Revision ID: 780c29109b25
Revises: 911cc5d772fc
Create Date: 2020-08-30 15:22:15.026266
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "780c29109b25"
down_revision = "911cc5d772fc"
branch_labels = None
depends_on = None
def... | 26.806452 | 89 | 0.665463 | [
"MIT"
] | mutalisk999/Flog | migrations/versions/780c29109b25_.py | 831 | Python |
import numpy as np
import os
import cv2
from PIL import Image
import numpy as np
import random
import itertools
import matplotlib.pyplot as plt # plt 用于显示图片
from tqdm import tqdm
# 标注文件数据处理
def read_pslot(annt_file):
# print(annt_file)
with open(annt_file, "r") as f:
annt = f.readlines()
# print... | 33.156156 | 116 | 0.580926 | [
"Apache-2.0"
] | ziqi123/AutoParking | preprocessing/make_dataset_new.py | 11,369 | Python |
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: google/cloud/vision_v1p1beta1/proto/image_annotator.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descript... | 42.973206 | 9,043 | 0.743392 | [
"Apache-2.0"
] | Alexander-Minyushkin/google-cloud-python | vision/google/cloud/vision_v1p1beta1/proto/image_annotator_pb2.py | 89,814 | Python |
import logging
# noinspection PyPackageRequirements
from telegram.ext import CommandHandler, ConversationHandler
# noinspection PyPackageRequirements
from telegram import ChatAction, Update
from bot import stickersbot
from bot.utils import decorators
from bot.utils import utils
from bot.database.base import session_s... | 34.975 | 150 | 0.754825 | [
"MIT"
] | Ankit29-A/sticker-thief | bot/handlers/packs/list.py | 1,403 | Python |
# -*- coding: utf-8 -*-
'''
QSDsan: Quantitative Sustainable Design for sanitation and resource recovery systems
This module is developed by:
Joy Zhang <[email protected]>
This module is under the University of Illinois/NCSA Open Source License.
Please refer to https://github.com/QSD-Group/QSDsan/blob/main/... | 38.412727 | 118 | 0.576229 | [
"Unlicense"
] | QSD-for-WaSH/sanitation | qsdsan/sanunits/_suspended_growth_bioreactor.py | 21,130 | Python |
# vim: set et sw=4 sts=4 fileencoding=utf-8:
#
# Python camera library for the Rasperry-Pi camera module
# Copyright (c) 2013-2017 Dave Jones <[email protected]>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# ... | 45.465936 | 146 | 0.609215 | [
"BSD-3-Clause"
] | RobertLucian/picamera | picamera/camera.py | 174,185 | Python |
# Copyright 2020 Huawei Technologies Co., Ltd
#
# 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... | 30 | 88 | 0.67673 | [
"Apache-2.0"
] | Gavin-Hoang/mindspore | mindspore/ops/composite/multitype_ops/logical_and_impl.py | 1,590 | Python |
from jsonrpc import ServiceProxy
import sys
import string
# ===== BEGIN USER SETTINGS =====
# if you do not set these you will be prompted for a password for every command
rpcuser = ""
rpcpass = ""
# ====== END USER SETTINGS ======
if rpcpass == "":
access = ServiceProxy("http://127.0.0.1:9332")
else:
access = Ser... | 24.110769 | 79 | 0.668198 | [
"MIT"
] | iannkwon/Sarnath | contrib/bitrpc/bitrpc.py | 7,836 | Python |
import matplotlib.pyplot as plt
import matplotlib
import numpy as np
from PIL import Image
from scipy.misc import imsave, imread
def plots(epochs, train_acc, test_acc, train_loss, test_loss, train_error, test_error,filename):
plt.style.use('bmh')
fig=plt.figure(figsize=(8,6))
plt.plot(epochs,train_acc, ... | 35.112903 | 96 | 0.509417 | [
"MIT"
] | gahshiv/DenseNet-pytorch | data_utils.py | 2,177 | Python |
###############################################################################
#
# Tests for XlsxWriter.
#
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c), 2013-2022, John McNamara, [email protected]
#
from ..excel_comparison_test import ExcelComparisonTest
from ...workbook import Workbook
class TestCompar... | 27.805556 | 79 | 0.535964 | [
"BSD-2-Clause"
] | hugovk/XlsxWriter | xlsxwriter/test/comparison/test_chart_data_labels17.py | 2,002 | Python |
from datetime import timedelta
from typing import NamedTuple, Optional
class ErdAdvantiumKitchenTimerMinMax(NamedTuple):
"""Defines min/max kitchen timer settings"""
min_time: timedelta
max_time: timedelta
raw_value: Optional[str]
| 24.9 | 49 | 0.7751 | [
"MIT"
] | ChevySSinSD/gehome | gehomesdk/erd/values/advantium/erd_advantium_kitchen_timer_min_max.py | 249 | Python |
#!/usr/bin/env python3
# Copyright (c) 2018-2020 The Ludirium Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Useful util functions for testing the wallet"""
from collections import namedtuple
from test_framewor... | 39.640625 | 118 | 0.615294 | [
"MIT"
] | ludirium/ludirium | test/functional/test_framework/wallet_util.py | 5,074 | Python |
import pymongo
import sys
# establish a connection to the database
# note this uses the now deprecated Connection class, as we did in the lecture.
# MongoClient is the preferred way of connecting.
connection = pymongo.Connection("mongodb://localhost", safe=True)
# get a handle to the school database
db=conn... | 23.090909 | 80 | 0.679134 | [
"Apache-2.0"
] | hemmerling/nosql-mongodb2013 | src/m101p/week02/lesson_files/hemmerling_week2_01.py | 508 | Python |
from django.contrib import admin
from .models import Arts, Comments, Tags, ArtworksTags, Stili, Umetnina, Umetnik
# Register your models here.
admin.site.register(Umetnik)
admin.site.register(Umetnina)
admin.site.register(Stili)
admin.site.register(Arts)
admin.site.register(Comments)
admin.site.register(Tags)
admin.... | 25.6 | 80 | 0.807292 | [
"MIT"
] | jaanos/OPB-umetnine | umetnine/artists/admin.py | 384 | Python |
# Copyright Istio Authors
#
# 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 writing, soft... | 30.658793 | 99 | 0.583769 | [
"Apache-2.0"
] | jwendell/tools | perf/benchmark/runner/runner.py | 11,681 | Python |
# Usage: testWordsInCorpus.py [language] {corpus file}
# If no corpus file is named, the programme will try to load a corresponding cPickle file.
#
# German corpus: /mounts/data/proj/huiming/SIGMORPHON/dewiki-20151102-pages-articles-multistream.xml
#
# This script finds words that should belong to a paradigm in the cor... | 34.570048 | 132 | 0.654556 | [
"MIT"
] | oncebasun/seq2seq-theano | MyAlgorithm/addWordsToParadigms_old.py | 7,156 | Python |
#!/usr/bin/env python2
from setuptools import setup
from setuptools import find_packages
setup(
name="rover",
version="0.1",
description="Algorithm for risk and sensor quality aware sensor" +
"coverage for quadrotors",
author="Alex Wallar",
author_email="[email protected]",
packages=fin... | 20.04 | 70 | 0.59481 | [
"Apache-2.0"
] | wallarelvo/rover | setup.py | 501 | Python |
#!/usr/bin/python
#coding:utf-8
import time
import json
import requests
from selenium import webdriver
filename = 'a.csv'
url = 'http://www.icourse163.org/university/view/all.htm#/'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0', 'Accept': 'text/html,applicat... | 32.307692 | 183 | 0.645714 | [
"MIT"
] | yeonzi/163course_spider | spider.py | 2,236 | Python |
#!/usr/bin/env python
# This example uses Uvicorn package that must be installed. However, it can be
# replaced with any other ASGI-compliant server.
#
# NOTE: Python 3.6 requires aiocontextvars package to be installed.
#
# Run: python app_global_request.py
import rollbar
import uvicorn
from rollbar.contrib.starlett... | 26.025641 | 78 | 0.759606 | [
"MIT"
] | Apep8/pyrollbar | rollbar/examples/starlette/app_global_request.py | 1,015 | Python |
# Configuration file for jupyter-notebook.
#------------------------------------------------------------------------------
# Configurable configuration
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Sing... | 36.942197 | 109 | 0.668388 | [
"Apache-2.0"
] | TrinathY/pipeline | config/jupyter/jupyter_notebook_config.py | 19,173 | Python |
import asyncio
import logging
import os
import shutil
import warnings
from types import TracebackType
from typing import Any, Coroutine, Dict, List, Optional, Text, Type, TypeVar
import rasa.core.utils
import rasa.utils.io
from rasa.constants import (
DEFAULT_LOG_LEVEL_LIBRARIES,
ENV_LOG_LEVEL_LIBRARIES,
)
fro... | 30.01 | 119 | 0.690103 | [
"Apache-2.0"
] | karen-white/rasa | rasa/utils/common.py | 9,003 | Python |
from io import BytesIO
from gtts import gTTS
from PIL import Image
from vkbottle import AudioUploader, Bot, DocUploader, Message, PhotoUploader
bot = Bot("token")
photo_uploader = PhotoUploader(bot.api, generate_attachment_strings=True)
doc_uploader = DocUploader(bot.api, generate_attachment_strings=True)
audio_uplo... | 31.465116 | 78 | 0.731707 | [
"MIT"
] | MooFreak/vkbottle | examples/uploaders.py | 1,365 | Python |
"""
ECB没有偏移量
"""
from Crypto.Cipher import AES
from binascii import b2a_hex, a2b_hex
from utils import DES_decrypt, DES_encrypt
def add_to_16(text):
if len(text.encode('utf-8')) % 16:
add = 16 - (len(text.encode('utf-8')) % 16)
else:
add = 0
text = text + ('\0' * add)
return text.encode... | 22.904762 | 51 | 0.626819 | [
"MIT"
] | peterzheng98/Valentine-Gift | try.py | 1,024 | Python |
"""This module contains the general information for ChassisPowerMonitor ManagedObject."""
from ...imcmo import ManagedObject
from ...imccoremeta import MoPropertyMeta, MoMeta
from ...imcmeta import VersionMeta
class ChassisPowerMonitorConsts:
pass
class ChassisPowerMonitor(ManagedObject):
"""This is Chassi... | 42.835821 | 234 | 0.619164 | [
"Apache-2.0"
] | CiscoUcs/imcsdk | imcsdk/mometa/chassis/ChassisPowerMonitor.py | 2,870 | Python |
"""
FILE : BiLSTM.py
FUNCTION : None
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
import random
from DataUtils.Common import *
from models.initialize import *
from models.modelHelp import prepare_pack_padded_seq... | 30.892157 | 121 | 0.623294 | [
"Apache-2.0"
] | Ahmed2xD/NER-with-bilstm-CRF-CNN | models/BiLSTM.py | 3,155 | Python |
'''
@author: kris
'''
# import modules; set up logging
from gensim.models import Word2Vec
from gensim.models import KeyedVectors
from gensim.test.utils import datapath
import numpy as np
import logging, os, sys, gzip
import datetime
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', filename='wor... | 34.737705 | 129 | 0.757747 | [
"MIT"
] | michaelfaerber/Agnos | scripts/loadModelDoEntityEmbeddingsUnsorted.py | 6,357 | Python |
"""inter-base steganography
producing base32 and base64 decodable strings"""
from base64 import b64encode, b64decode
import string
from itertools import product
from argparse import ArgumentParser
CHARSET = string.printable.encode()
B32_CHARSET = (string.ascii_uppercase + '234567').encode()
B64_CHARSET = (
string.... | 33.747664 | 82 | 0.542924 | [
"MIT"
] | deut-erium/BASEic-steganography | encode.py | 7,222 | Python |
import sys
import datetime
def capitalize(string):
return string[0].upper() + string[1:]
action = sys.argv[1]
file_path = sys.argv[2]
project_name = sys.argv[3]
namespace = sys.argv[4]
now = datetime.datetime.now()
date = now.strftime("%m-%d-%Y %H:%M:%S")
args = sys.argv[6:]
username = "Logan Rickert"
def new_c... | 20.828194 | 104 | 0.666244 | [
"CC0-1.0"
] | LoganRickert/CPP-Builder-And-Documentator | bin/parse_new_files.py | 4,728 | Python |
#!/usr/bin/python3
import time
import datetime
from gpiozero import InputDevice, LED
import subprocess
import requests
# RPI enumeration is:
# pin 5 & 6 are used for the button (3 & ground)
# pin 7 & 9 are used for the LED (4 & ground)
button_pin = 3
led_pin = 4
button = InputDevice(button_pin, pull_up=True)
last_ac... | 25.456522 | 63 | 0.668659 | [
"MIT"
] | kylemcdonald/bsp | pi/button/button.py | 1,171 | Python |
import argparse
import torch
from tqdm import tqdm
import vgg.data_loader.data_loaders as module_data
import vgg.model.loss as module_loss
import vgg.model.metric as module_metric
import vgg.model.model as module_arch
from vgg.parse_config import ConfigParser
def main(config):
logger = config.get_logger('test')
... | 33.414634 | 93 | 0.641241 | [
"MIT"
] | mhd53/vgg-from-torch | vgg/test.py | 2,740 | Python |
import os
import argparse
from ops.os_operation import mkdir
import time
def write_slurm_sh_multi_H2(id,command_line, queue_name="learnfair",nodes=1,
gpu_per_node=8,wall_time=3*24*60,username="wang3702",CPU_PER_GPU=8):
import time
import datetime
today = datetime.date.today()
formatt... | 72.542391 | 156 | 0.428224 | [
"MIT"
] | wang3702/barlowtwins | run_slurm.py | 266,956 | Python |
# -*- coding: UTF-8 -*-
#
# Copyright 2018 Joachim Lusiardi
#
# 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 applicabl... | 34.743772 | 95 | 0.651029 | [
"Apache-2.0"
] | jlusiardi/homekit_client | homekit/crypto/srp.py | 9,763 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.