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 globconf import config
from globconf import verify_required_options
import unittest
import os
# let's test on a predefined file included in the unitteast
config.read(os.path.dirname(__file__)+'/config.ini')
class TestConf(unittest.TestCase):
def test_config_file_present(self):
self.assertTrue(os.pa... | 31.45 | 125 | 0.756757 | [
"MIT"
] | klang/globconf | test/test_verify_required_options.py | 629 | Python |
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: google/ads/googleads_v2/proto/enums/recommendation_type.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf imp... | 41.233333 | 1,160 | 0.767179 | [
"Apache-2.0"
] | BenRKarl/google-ads-python | google/ads/google_ads/v2/proto/enums/recommendation_type_pb2.py | 6,185 | Python |
#!/usr/bin/env python3
"""Write a type-annotated function sum_mixed_list which takes
a list mxd_lst of integers and floats and returns their sum as a float."""
from typing import Iterable, List, Union
def sum_mixed_list(mxd_lst: List[Union[int, float]]) -> float:
"""sum all float number in list
Args:
... | 23.333333 | 74 | 0.680952 | [
"MIT"
] | JoseAVallejo12/holbertonschool-web_back_end | 0x00-python_variable_annotations/6-sum_mixed_list.py | 420 | Python |
__all__ = [
"BaseAgent",
"DoNothingAgent",
"OneChangeThenNothing",
"GreedyAgent",
"PowerLineSwitch",
"TopologyGreedy",
"AgentWithConverter",
"RandomAgent",
"MLAgent",
"RecoPowerlineAgent"
]
from grid2op.Agent.BaseAgent import BaseAgent
from grid2op.Agent.DoNothing import DoNothi... | 32.5 | 67 | 0.811538 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | 19bdxx/GRID2OP | grid2op/Agent/__init__.py | 780 | Python |
"""
Камни и украшения
Даны две строки строчных латинских символов: строка J и строка S.
Символы, входящие в строку J, — «драгоценности», входящие в строку S — «камни».
Нужно определить, какое количество символов из S одновременно являются
«драгоценностями». Проще говоря, нужно проверить, какое количество символов
из ... | 22.073171 | 79 | 0.754696 | [
"MIT"
] | J0shu4B0y/Practice | Python/yandex/stones_and_diamonds.py | 1,414 | Python |
# Copyright 2017 Google Inc. 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 applicable law or a... | 35.210526 | 74 | 0.750374 | [
"Apache-2.0"
] | dhermes/google-cloud-python-on-gae | language-app/stubs/ctypes.py | 669 | 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 appli... | 38.656682 | 120 | 0.608929 | [
"Apache-2.0"
] | CheQiXiao/Paddle | python/paddle/fluid/dygraph/dygraph_to_static/partial_program.py | 16,777 | Python |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import re
import django.core.validators
class Migration(migrations.Migration):
dependencies = [
('wmsmanager', '0002_auto_20151125_1310'),
]
operations = [
migrations.AlterField(
... | 30.862069 | 236 | 0.637989 | [
"BSD-3-Clause"
] | dbca-asi/borgcollector | wmsmanager/migrations/0003_auto_20151203_1448.py | 895 | Python |
#!/usr/bin/env python3
# Copyright (c) 2020 The Elixir Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""
Test addr relay
"""
from test_framework.messages import (
CAddress,
NODE_NETWORK,
NODE_WITNESS,... | 38.813084 | 136 | 0.67698 | [
"MIT"
] | robbelouwet/Elixir | test/functional/p2p_addr_relay.py | 8,306 | Python |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import tarfile
import unittest
from unittest.mock import MagicMock
import fsspec
from torchx.specs import Role... | 28.982857 | 86 | 0.477721 | [
"BSD-3-Clause"
] | daniellepintz/torchx | torchx/workspace/test/docker_workspace_test.py | 5,072 | Python |
# encoding: UTF-8
import time
from redtorch.event import *
from redtorch.trader.vtEvent import *
from redtorch.trader.vtConstant import *
from redtorch.trader.vtObject import *
########################################################################
class VtGateway(object):
"""交易接口"""
#-------------------... | 29.467532 | 75 | 0.388277 | [
"MIT"
] | sun0x00/redtorch_python | redtorch/trader/vtGateway.py | 4,840 | Python |
from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import transaction
from rest_framework import generics, views
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_registration.settings import registration_settings
fr... | 34.034483 | 81 | 0.739953 | [
"MIT"
] | DakaraProject/dakara-server | dakara_server/users/views.py | 2,961 | Python |
from lxml.etree import XMLSyntaxError
from onegov.ballot import Election
from onegov.ballot import ElectionCompound
from onegov.ballot import Vote
from onegov.core.widgets import transform_structure
from onegov.election_day import _
from onegov.election_day.models import Screen
from onegov.election_day.models.screen im... | 30.49481 | 79 | 0.588335 | [
"MIT"
] | politbuero-kampagnen/onegov-cloud | src/onegov/election_day/forms/screen.py | 8,813 | Python |
import pytest
import json
import ipaddress
import time
import natsort
import random
import re
from collections import defaultdict
from tests.common.fixtures.ptfhost_utils import change_mac_addresses, copy_arp_responder_py
from tests.common.dualtor.dual_tor_utils import mux_cable_server_ip
from tests.common.dualtor.dua... | 43.924901 | 171 | 0.710609 | [
"Apache-2.0"
] | LiuKuan-AF/sonic-mgmt | tests/route/test_static_route.py | 11,113 | Python |
"""
Flake8 plugin to encourage correct string literal concatenation.
Forbid implicitly concatenated string literals on one line such as those
introduced by Black.
Forbid all explicitly concatenated strings, in favour of implicit concatenation.
"""
from __future__ import generator_stop
import ast
import tokenize
from... | 26.567164 | 86 | 0.645506 | [
"MIT"
] | graingert/flake8-implicit-str-concat | flake8_implicit_str_concat.py | 1,780 | Python |
from django.views.generic.edit import UpdateView
from django.urls import reverse_lazy
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import login_required
from user.models import User
from user.forms import UpdateUserForm
class EditProfileView(UpdateView):
model = User
... | 33 | 81 | 0.728164 | [
"MIT"
] | fga-eps-mds/2017.2-Receita-Mais | medical_prescription/user/views/editprofile.py | 1,122 | Python |
import cv2
import numpy as np
# import gt_utils
def binarize(img):
""" Take an RGB image and binarize it.
:param img: cv2 image
:return:
"""
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret, bin = cv2.threshold(gray, 1, 255, cv2.THRESH_BINARY)
return bin
def makecoloredlayer(img, mask, ... | 30.052632 | 85 | 0.589492 | [
"MIT"
] | alix-tz/GT_generator | GT_generator/gt_image.py | 2,855 | Python |
#!/usr/bin/env python
# coding: utf-8
# list
classMates = ['Micheal', 'Lucy', 'Anna']
print classMates
# 获取长度
print len(classMates)
# 取值
print classMates[2]
print classMates[-1]
# 追加
classMates.append('Adam')
print classMates
# 插入
classMates.insert(1, 'Paul')
print classMates
# 删除
classMates.pop()
print classMa... | 11.323529 | 48 | 0.632468 | [
"MIT"
] | atcuan/Python | liaoxuefeng.com/004-ListAndTuple.py | 868 | Python |
_base_ = [
'../../_base_/models/faster_rcnn_r50_fpn.py',
'../dataset.py',
'../../_base_/schedules/schedule_1x.py',
'../../_base_/default_runtime.py'
]
model = dict(
roi_head=dict(
bbox_head=dict(
num_classes=11
)
)
)
optimizer_config = dict(
_delete_=True, grad_c... | 21.684211 | 60 | 0.621359 | [
"Apache-2.0"
] | Pstage-Segmentation-Detection/mmdetection_trash | configs/trash/faster_rcnn/faster_rcnn_r50_fpn_1x_trash.py | 412 | Python |
from fastapi import APIRouter
from modules.core.converter import Converter
from modules.schemas.converter import ConverterSchema
converter = APIRouter()
@converter.post('/convert', tags=['converter'])
def convert_document(convert: ConverterSchema):
result = Converter.convert(convert.source_format, convert.targe... | 33.461538 | 93 | 0.806897 | [
"MIT"
] | atthealchemist/graduation-project-system-backend | modules/routers/converter.py | 435 | Python |
#!/usr/bin/env python
# coding=utf-8
from __future__ import division, print_function, unicode_literals
from brainstorm.structure.construction import UniquelyNamed
def test_basename():
n = UniquelyNamed('my_basename')
assert n.name == 'my_basename'
def test_merging_scopes_no_conflict():
n1 = UniquelyName... | 24.675214 | 65 | 0.656391 | [
"MIT"
] | IDSIA/brainstorm | brainstorm/tests/test_uniquely_named.py | 2,887 | Python |
class Solution:
def longestPalindromeSubseq(self, s: str) -> int:
N = len(s)
prev = [0] * (N+1)
for i in range(N+1):
curr = [0] * (N+1)
for j in range(N+1):
if not i or not j:
curr[j] = 0
elif s[i-1] == s[N-j]:
... | 28.588235 | 53 | 0.364198 | [
"MIT"
] | VVKot/coding-competitions | leetcode/python/516_longest_palindromic_subsequence.py | 486 | Python |
import scrapy
import json
class RussianAlphabetSpider(scrapy.Spider):
name = "quotes"
start_urls = [
'https://www.russianforeveryone.com/',
]
def parse(self, response):
alphabets_urls = response.xpath('//a[contains(.,"alphabet")]')
yield from response.follow_all(alphabets_urls... | 31.53125 | 91 | 0.570862 | [
"MIT"
] | robsonzagrejr/banana-crawler | banana_crawler/spiders/russian_alphabet.py | 1,009 | Python |
# Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
from __future__ import absolute_import
import os
import sys
sys.path.append(os.path.realpath(os.getcwd())) | 20.2 | 61 | 0.759076 | [
"BSD-3-Clause"
] | goel96vibhor/AdvSentEval | examples/__init__.py | 303 | 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 the getchaintips RPC.
- introduce a network split
- work on chains of different lengths
- join th... | 34.328125 | 70 | 0.640874 | [
"MIT"
] | IBACOIN/IBA | test/functional/rpc_getchaintips.py | 2,197 | Python |
"""safe name
Revision ID: 9332f05cb7d6
Revises: 30228d27a270
Create Date: 2020-05-24 23:49:06.195432
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '9332f05cb7d6'
down_revision = '30228d27a270'
branch_labels = None
depends_on = None
def upgrade():
# ### ... | 25.806452 | 85 | 0.69125 | [
"MIT"
] | TimmySly/ctaCompanion | migrations/versions/9332f05cb7d6_safe_name.py | 800 | Python |
# Copyright (C) Jean-Paul Calderone
# See LICENSE for details.
"""
Unit tests for :mod:`OpenSSL.SSL`.
"""
import datetime
import sys
import uuid
from gc import collect, get_referrers
from errno import (
EAFNOSUPPORT, ECONNREFUSED, EINPROGRESS, EWOULDBLOCK, EPIPE, ESHUTDOWN)
from sys import platform, getfilesyste... | 35.721118 | 79 | 0.640149 | [
"Apache-2.0"
] | dholth/pyopenssl | tests/test_ssl.py | 141,920 | Python |
# -*- coding: utf-8 -*-
#
# 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
#... | 37.075 | 81 | 0.642841 | [
"Apache-2.0"
] | SpaceApplications/airflow | airflow/executors/celery_executor.py | 4,449 | Python |
'''
Minimum number of jumps to reach end
Given an array of integers where each element represents
the max number of steps that can be made forward from that
element. Write a function to return the minimum number of
jumps to reach the end of the array (starting from the first element).
If an element is 0, the... | 24.632653 | 71 | 0.495443 | [
"MIT"
] | AddinDev/Hackoween-Hacktoberfest2021 | Projects/Python/Minimum Jumps to Reach the End.py | 1,209 | Python |
###############################################################################
#
# Copyright (c) 2020, NVIDIA CORPORATION. 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... | 36.969925 | 107 | 0.647346 | [
"Apache-2.0"
] | CardenB/flowtron | inference.py | 4,917 | Python |
# coding=utf-8
import pywikibot
import re
import urllib.request
from pywikibot import Claim, pagegenerators as pg
from time import sleep
from urllib.error import HTTPError
from utils.properties import PID_OK_ACCOUNT, PID_OK_PROFILE_ID
repo = pywikibot.Site('wikidata', 'wikidata')
def parse_ok_ru(account):
html ... | 25.207317 | 85 | 0.611998 | [
"Apache-2.0"
] | putnik/pbot | ok_add_ids.py | 2,067 | Python |
# Copyright 2018 Google 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 41.375 | 79 | 0.68635 | [
"Apache-2.0"
] | jwygoda/google-ads-python | examples/campaign_management/add_campaign_bid_modifier.py | 3,641 | Python |
"""Utility functions for COVID19 UK data"""
import os
import re
import datetime
import numpy as np
import pandas as pd
def prependDate(filename):
now = datetime.now() # current date and time
date_time = now.strftime("%Y-%m-%d")
return date_time + "_" + filename
def prependID(filename, config):
ret... | 26.3125 | 79 | 0.638163 | [
"MIT"
] | chrism0dwk/covid19uk | covid19uk/data/util.py | 2,526 | Python |
#!/bin/env python
#
# Copyright 2014 Alcatel-Lucent Enterprise.
#
# 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 appli... | 37.135048 | 117 | 0.57295 | [
"Apache-2.0"
] | Alcatel-LucentEnterpriseData/ALUe-OONP_H_R01 | omniswitch/omniswitch_restful_driver.py | 23,098 | Python |
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may ... | 48.397059 | 130 | 0.703434 | [
"MIT"
] | MichaelZp0/azure-sdk-for-python | sdk/resources/azure-mgmt-msi/azure/mgmt/msi/v2019_09_01_preview/aio/_configuration.py | 3,291 | Python |
import os
import sys
sys.path.append(os.getcwd())
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import beta
from restools.plotting import rasterise_and_save
from papers.jfm2020_probabilistic_protocol.data import Summary as SummaryProbProto
from papers.jfm2020_probabilistic_protocol.extensions im... | 40.903382 | 128 | 0.619228 | [
"MIT"
] | anton-pershin/restools | papers/jfm2022_optimizing_control_bayesian_method/views/sketches.py | 8,467 | Python |
import matplotlib.pyplot as plt
import numpy as np
import torch
import torch.nn as nn
import torchvision
import torchvision.transforms as transforms
from .misc import *
__all__ = ['make_image', 'show_batch', 'show_mask', 'show_mask_single']
# functions to show an image
def make_image(img, mean=(0,0,0), std=(1,1... | 33.610619 | 95 | 0.575303 | [
"MIT"
] | 1337Eddy/BirdRecognitionPruning | rethinking-network-pruning/cifar/weight-level/utils/visualize.py | 3,798 | Python |
from django.db import models
from django.urls import reverse
from nautobot.core.models import BaseModel
from nautobot.extras.utils import extras_features
from nautobot.extras.models import ObjectChange
from nautobot.utilities.utils import serialize_object
@extras_features("graphql")
class DummyModel(BaseModel):
... | 26.916667 | 84 | 0.666409 | [
"Apache-2.0"
] | FloLaco/nautobot | examples/dummy_plugin/dummy_plugin/models.py | 1,292 | Python |
# ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.2'
# jupytext_version: 1.0.4
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %% [markdown] {"_uuid": "6f06de1b48e35853f80eb1f338... | 42.78744 | 304 | 0.705995 | [
"MIT"
] | MarcusJones/kaggle_petfinder_adoption | reference_kernels/FORK EDA, PCA + Simple LGBM on KFold Technique.py | 17,714 | Python |
from pybfm.irr import IRR
# define annual cash flows
multiple_irr = IRR(
[0, 1, 2], # years [this year, first year, second year]
[-3000, 15000, -13000], # cash flows
[None, None, None], # kind of cash flow (None, perpetuity)
)
# find irr
irr = multiple_irr.find(initial_guess=0.05)
print(f"Internal Rate... | 23.585366 | 74 | 0.684592 | [
"BSD-3-Clause"
] | javadebadi/pybfm | example/irr.py | 967 | Python |
from . import views
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('', views.index, name='home'),
path('login/', views.login, name='login_user'),
path('logout/', views.logout, name='logout_user'),
path('signup/', views.signup, name='signup_user'),
path('... | 35.533333 | 67 | 0.662289 | [
"MIT"
] | mrizky17042000/DealIn | deal.in/deal_in/urls.py | 533 | Python |
from cppimport import import_hook
from .xbin import *
from .xbin_util import *
from .smear import *
Xbin = Xbin_float
create_Xbin_nside = create_Xbin_nside_float
| 20.375 | 43 | 0.809816 | [
"Apache-2.0"
] | chelseanfries/rpxdock | rpxdock/xbin/__init__.py | 163 | Python |
from datetime import datetime
from xattr import listxattr, getxattr
import falcon
import hashlib
import logging
from certidude import const, config
from certidude.common import cert_to_dn
from certidude.decorators import serialize, csrf_protection
from certidude.user import User
from .utils import AuthorityHandler
from... | 50.023041 | 130 | 0.539383 | [
"MIT"
] | dresslerit/certidude | certidude/api/session.py | 10,855 | Python |
val1 = 5
val2 = 2
suma = val1 + val2
print(suma)
resta = val2 - val1
print(resta)
promedio = (val1+val2)/2
print(promedio)
producto = ((val1-val2)/2)*365
print(producto)
centroamerica = ("Guatemala, Belice, El salvador, Honduras, Nicaragua, Costa Rica, Panamá")
print(len(centroamerica))
print(ce... | 16.9 | 92 | 0.674556 | [
"CC0-1.0"
] | Salazar769/Ciclo-1-python | cadenas y variables.py | 339 | Python |
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")
@app.ge... | 38.066667 | 127 | 0.65324 | [
"Apache-2.0"
] | SKDCO/SKDCO | files/fake-QR-code-goskulugi/qr.py | 1,304 | 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/.
from bedrock.mozorg.util import page
from bedrock.redirects.util import redirect
urlpatterns = (
# Issue 9727 /fou... | 55.659091 | 125 | 0.746019 | [
"MPL-2.0"
] | amychurchwell/bedrock | bedrock/foundation/urls.py | 4,898 | Python |
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
import unittest
from pants.engine.addressable import (MutationError, NotSerializableError, addressable,
addressable_dict, addressable_list)
from pant... | 29.503876 | 94 | 0.688255 | [
"Apache-2.0"
] | AHassanSOS/pants | tests/python/pants_test/engine/test_addressable.py | 7,612 | Python |
"""
Django settings for mysite project.
Generated by 'django-admin startproject' using Django 2.1.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
from pathlib imp... | 28.892086 | 91 | 0.707171 | [
"MIT"
] | SigNoz/sample-django | mysite/settings.py | 4,016 | Python |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright SAS Institute
#
# 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 b... | 44.142986 | 142 | 0.591271 | [
"Apache-2.0"
] | Mentos05/python-dlpy | dlpy/tests/test_model.py | 48,778 | Python |
from pathlib import Path
from typing import *
from isolateparser.resultparser.parsers import gdtotable
import pytest
import itertools
from loguru import logger
data_folder = Path(__file__).parent / "data" / "sample_files"
@pytest.fixture
def parser() -> gdtotable.GDToTable:
return gdtotable.GDToTable()
def example... | 99.019763 | 919 | 0.757624 | [
"MIT"
] | cdeitrick/isolate_parsers | tests/test_gd_to_table.py | 25,100 | Python |
#!/usr/bin/env python3
import argparse
import os
import pprint
import struct
import sys
import traceback
def read_uint32(fp, pos):
"""Read 4 little-endian bytes into an unsigned 32-bit integer. Return value, position + 4."""
fp.seek(pos)
val = struct.unpack("<I", fp.read(4))[0]
return val, pos + 4
de... | 39.705882 | 147 | 0.538012 | [
"MIT"
] | nmbook/zw1-pack | zw1_pack.py | 12,825 | Python |
class Spam:
def eggs(self):
assert False
def eggs_and_ham(self):
assert False
| 14.714286 | 27 | 0.592233 | [
"Apache-2.0"
] | 06needhamt/intellij-community | python/testData/create_tests/create_tst_class.expected_pytest_3k.py | 103 | Python |
arr = []
dict = {}
for i in range(10):
arr.append(int(input())%42)
for i in arr:
dict[i] = 0
print(len(dict)) | 12 | 31 | 0.55 | [
"MIT"
] | Lumia1108/TIL | baekjoon/Python/3052.py | 120 | Python |
# Copyright 2015 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,... | 40.820722 | 80 | 0.665336 | [
"Apache-2.0"
] | huhisoftware/omaha | omaha/enterprise/generate_group_policy_template_admx.py | 35,065 | Python |
from pytest_bdd import scenario, given, when, then, parsers
import contacts
@given("I have a contact book", target_fixture="contactbook")
def contactbook():
return contacts.Application()
@given(parsers.parse("I have a \"{contactname}\" contact"))
def have_a_contact(contactbook, contactname):
contactbook.ad... | 24.578947 | 61 | 0.738758 | [
"MIT"
] | PacktPublishing/Crafting-Test-Driven-Software-with-Python | Chapter08/tests/acceptance/steps.py | 467 | Python |
from layer import *
class LogisticLayer(Layer):
def __init__(self, *args, **kwargs):
super(LogisticLayer, self).__init__(*args, **kwargs)
@classmethod
def IsLayerType(cls, proto):
return proto.hyperparams.activation == deepnet_pb2.Hyperparams.LOGISTIC
def ApplyActivation(self):
cm.sigmoid(self.st... | 30.4 | 80 | 0.68891 | [
"BSD-3-Clause"
] | Corvalius/deepnet | package/deepnet/logistic_layer.py | 2,128 | Python |
import os
from pathlib import Path
from typing import Any, Text, Dict
import pytest
import rasa.shared.utils.io
import rasa.utils.io
from rasa.core.test import (
_create_data_generator,
_collect_story_predictions,
test as evaluate_stories,
FAILED_STORIES_FILE,
CONFUSION_MATRIX_STORIES_FILE,
RE... | 29.945017 | 88 | 0.648152 | [
"Apache-2.0"
] | AnaCarolcs/rasa | tests/core/test_evaluation.py | 8,714 | Python |
# exported from PySB model 'model'
from pysb import Model, Monomer, Parameter, Expression, Compartment, Rule, Observable, Initial, MatchOnce, Annotation, ANY, WILD
Model()
Monomer('Ligand', ['Receptor'])
Monomer('ParpU', ['C3A'])
Monomer('C8A', ['BidU'])
Monomer('BaxM', ['BidM', 'BaxA'])
Monomer('Apop', ['C3pro', 'X... | 79.473054 | 614 | 0.80975 | [
"MIT"
] | LoLab-VU/Bayesian_Inference_of_Network_Dynamics | log_mito_act/model_577.py | 13,272 | Python |
# -*- coding: utf-8 -*- #
# Copyright 2018 Google LLC. 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 requir... | 40.534413 | 84 | 0.723332 | [
"MIT"
] | bopopescu/JobSniperRails | gcloud/google-cloud-sdk/.install/.backup/lib/googlecloudsdk/api_lib/accesscontextmanager/zones.py | 10,012 | Python |
# -*- coding: utf-8 -*-
from ccxt.async.base.exchange import Exchange
import hashlib
import math
from ccxt.base.errors import ExchangeError
class huobipro (Exchange):
def describe(self):
return self.deep_extend(super(huobipro, self).describe(), {
'id': 'huobipro',
'name': 'Huobi ... | 38.368653 | 210 | 0.490075 | [
"MIT"
] | destenson/ccxt--ccxt | python/ccxt/async/huobipro.py | 17,885 | Python |
from django.contrib.auth import get_user_model, authenticate
from rest_framework import serializers
from django.utils.translation import ugettext_lazy as _
class UsersSerializer(serializers.ModelSerializer):
"""Serializer for users object"""
class Meta:
model = get_user_model()
fields = ('ema... | 32.552239 | 75 | 0.581843 | [
"MIT"
] | mazharkafi004/XOJ | xojbackend/app/user/serializers.py | 2,181 | Python |
"""
Django settings for queueMgmt project.
Generated by 'django-admin startproject' using Django 3.0.5.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
... | 25.41844 | 91 | 0.686942 | [
"MIT"
] | maxhamz/prieds_test_hospital_queue_be | queueMgmt/settings.py | 3,584 | Python |
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may ... | 48.084168 | 204 | 0.661332 | [
"MIT"
] | 00Kai0/azure-sdk-for-python | sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2018_10_01/operations/_availability_sets_operations.py | 23,994 | Python |
import math
def newton(function,function1,startingInt): #function is the f(x) and function1 is the f'(x)
x_n=startingInt
while True:
x_n1=x_n-function(x_n)/function1(x_n)
if abs(x_n-x_n1)<0.00001:
return x_n1
x_n=x_n1
def f(x):
return math.pow(x,3)-2*x-5
def f1(x):
retur... | 21.294118 | 92 | 0.635359 | [
"MIT"
] | FaizAlam/Python | NeutonMethod.py | 362 | Python |
"""
Copyright 2020 The OneFlow 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 applicable law or agr... | 32.972549 | 126 | 0.644029 | [
"Apache-2.0"
] | xcnick/oneflow | oneflow/compatible_single_client_python/ops/tensor_buffer_ops.py | 8,408 | Python |
import multiprocessing as mp
import time
def f(name, timeout, queue):
time.sleep(timeout)
print('hello', name)
queue.put(name + ' done!')
queue = mp.SimpleQueue() # queue for communicating with the processes we will spawn
bob = mp.Process(target=f, args=('bob', 0.3, queue))
bob.start() # start the pro... | 25.086957 | 84 | 0.701906 | [
"MIT"
] | andgineer/masterandrey.com | _includes/src/multiprocessing.py | 577 | Python |
'''OpenGL extension EXT.histogram
This module customises the behaviour of the
OpenGL.raw.GL.EXT.histogram to provide a more
Python-friendly API
'''
from OpenGL import platform, constants, constant, arrays
from OpenGL import extensions, wrapper
from OpenGL.GL import glget
import ctypes
from OpenGL.raw.GL.EXT.histogra... | 28.8 | 87 | 0.800347 | [
"MIT"
] | MontyThibault/centre-of-mass-awareness | Cartwheel/lib/Python26/Lib/site-packages/OpenGL/GL/EXT/histogram.py | 576 | Python |
# coding: utf-8
import unittest
from datetime import datetime
from whiskyton import app
from whiskyton.helpers import sitemap
from whiskyton.helpers.charts import Chart
from whiskyton.tests.config import WhiskytonTest
class TestHelpers(unittest.TestCase):
def setUp(self):
self.test_suite = WhiskytonTest... | 35.712329 | 77 | 0.66705 | [
"MIT"
] | g4brielvs/whiskyton | whiskyton/tests/test_helpers.py | 2,607 | Python |
import os
import logging
from .paths import get_path
_FORMAT = '%(asctime)s:%(levelname)s:%(lineno)s:%(module)s.%(funcName)s:%(message)s'
_formatter = logging.Formatter(_FORMAT, '%H:%M:%S')
_handler = logging.StreamHandler()
_handler.setFormatter(_formatter)
logging.basicConfig(filename=os.path.join(get_path(), 'sp... | 25.608696 | 84 | 0.706282 | [
"MIT"
] | alexchunet/Spa_feature_processing | spfeas/errors.py | 589 | Python |
import numpy as np
from lab2.utils import get_random_number_generator
# todo clean up the docstrings
class BoxWindow:
"""[summary]BoxWindow class representing a virtual n-dimensional bounded Box"""
def __init__(self, args):
"""[summary]Initialization of Box's parameters
Args:
ar... | 30.433735 | 127 | 0.533386 | [
"MIT"
] | AmineAitLemqeddem/sdia-python | src/lab2/box_window.py | 7,578 | Python |
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='ultmul',
ext_modules=[
CUDAExtension(
'ultMul_cuda',
[
'ultMul_cuda.cpp',
'ultMul_cuda_kernel.cu', #.cpp and .cu file must have different name
])],
cmdclass = {
'build_ext': BuildExtension
}
... | 18.941176 | 71 | 0.723602 | [
"Apache-2.0"
] | kingsley1989/Parallel-Ultrametric | setup.py | 322 | Python |
#!/usr/bin/env python
# Copyright Singapore-MIT Alliance for Research and Technology
import random
from town import Town_layout
from company import Registrar_of_companies
class Person:
def __init__(self, city, attrs=None):
self.name = "Person_%04d" % len(city.residents)
city.residents.append(self... | 40.4375 | 96 | 0.505216 | [
"MIT"
] | ZhaoBozhi/simmobility-prod | dev/tools/snake-city/person.py | 5,176 | Python |
# MIT License
#
# Copyright (C) IBM Corporation 2019
#
# 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, modify, merge... | 51.75 | 120 | 0.778986 | [
"MIT"
] | Jakondak/differential-privacy-library | diffprivlib/__init__.py | 1,656 | Python |
#!/usr/bin/env python
import telnetlib
import time
import socket
import sys
TELNET_PORT = 23
TELNET_TIMEOUT = 6
## function
def send_command(remote_conn, cmd):
cmd = cmd.rstrip()
remote_conn.write(cmd + '\n')
time.sleep(1)
return remote_conn.read_very_eager()
def login(remote_conn, username, password):
output... | 21.584906 | 63 | 0.738636 | [
"Apache-2.0"
] | blaforest/pynet | Lesson2Number2a_telnetlib.py | 1,144 | Python |
import glob
import numpy as np
import os.path as osp
from PIL import Image
import random
import struct
from torch.utils.data import Dataset
import scipy.ndimage as ndimage
import cv2
from skimage.measure import block_reduce
import json
import scipy.ndimage as ndimage
class ConcatDataset(Dataset ):
def __init__(se... | 36.074713 | 110 | 0.547873 | [
"MIT"
] | Z7Gao/InverseRenderingOfIndoorScene | nyuDataLoader.py | 6,277 | Python |
# --------------------------------------------------------
# Adapted from Faster R-CNN (https://github.com/rbgirshick/py-faster-rcnn)
# Written by Danfei Xu
# --------------------------------------------------------
"""Compute minibatch blobs for training a Fast R-CNN network."""
import numpy as np
import numpy.rando... | 37.043046 | 96 | 0.633146 | [
"MIT"
] | Alex-Sol/scene-graph-TF-release | lib/roi_data_layer/minibatch.py | 11,187 | Python |
from __future__ import division, print_function
from openmdao.utils.assert_utils import assert_rel_error
import unittest
import numpy as np
from openaerostruct.geometry.utils import generate_mesh
from openaerostruct.geometry.geometry_group import Geometry
from openaerostruct.aerodynamics.aero_groups import AeroPoint
... | 44.714286 | 182 | 0.526624 | [
"Apache-2.0"
] | William-Metz/OASFORNEURALNETWORKS | openaerostruct/tests/test_multiple_aero_analysis.py | 7,512 | Python |
# Generated by Django 2.2.10 on 2020-04-12 20:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('staff', '0036_auto_20200407_1947'),
]
operations = [
migrations.CreateModel(
name='Messanger',
fields=[
... | 28.26087 | 114 | 0.581538 | [
"MIT"
] | SlavaSkvortsov/micro-shop | micro_shop/staff/migrations/0037_messanger.py | 650 | Python |
context = "https://www.w3.org/ns/activitystreams"
class Actor:
def __init__(self, user):
self.user = user
def render(self, base_url):
actor = self.user.profile
actor.update({
"@context": context,
"preferredUsername": self.user.name,
"id": self.us... | 25.932584 | 69 | 0.454939 | [
"BSD-3-Clause"
] | autogestion/pubgate | pubgate/renders.py | 2,308 | Python |
import pytest
from eth_utils import (
is_same_address,
)
from web3.utils.events import (
get_event_data,
)
# Ignore warning in pyethereum 1.6 - will go away with the upgrade
pytestmark = pytest.mark.filterwarnings("ignore:implicit cast from 'char *'")
@pytest.fixture()
def Emitter(web3, EMITTER):
retur... | 36.908451 | 97 | 0.617058 | [
"MIT"
] | JulianLiu/web3.py | tests/core/contracts/test_extracting_event_data_old.py | 5,241 | Python |
# Generated by Django 3.1.4 on 2020-12-31 11:25
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='AsnDetailModel',
fields=[
('id', models.Aut... | 55.970149 | 114 | 0.5976 | [
"Apache-2.0"
] | chinxianjun2016/GreaterWMS | asn/migrations/0001_initial.py | 3,750 | Python |
# -*- coding: utf-8 -*-
from __future__ import division, print_function, absolute_import
import os
import tensorflow as tf
import math
from dataloader.pretrained_weights.pretrain_zoo import PretrainModelZoo
"""
2021-02-06 kl 74.00% 82.28% 77.92% 0.8
2021-02-06 kl 75.25% 80.61% 77.84% 0.75
2021-02-06 kl 71.98% 83.... | 30.025862 | 105 | 0.64944 | [
"Apache-2.0"
] | Artcs1/PROBIOU | libs/configs_old/ICDAR2015/kl/cfgs_res50_icdar2015_kl_v2.py | 3,483 | Python |
import os
import re
from pathlib import Path
from logging import debug
from cli_ui import debug as verbose
from cli_ui import warning, fatal
from jinja2 import Environment, FileSystemLoader
from gitlabform import EXIT_INVALID_INPUT
from gitlabform.configuration import Configuration
from gitlabform.gitlab import GitL... | 40.905594 | 102 | 0.471921 | [
"MIT"
] | egnyte/gitlabform | gitlabform/processors/project/files_processor.py | 11,699 | Python |
from typing import Any, Dict, List, Union
import numpy as np
import logging
import os
# Create a custom logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
class RandomSearch:
@staticmethod
def random_choice(args: List[Any], n: int = 1):
"""
pick a random element from... | 28.97037 | 84 | 0.538226 | [
"Apache-2.0"
] | kernelmachine/quality-filter | lr/hyperparameters.py | 3,911 | Python |
import torch
from tqdm import tqdm
import torch.nn.functional as F
from torch.utils.tensorboard import SummaryWriter
import flask
from flask import Flask, request
from ...utils.deploy import get_free_tcp_port
from ...utils.learning import adjust_learning_rate
from ...utils.log import logger
from ...base.module import... | 40.69378 | 118 | 0.6107 | [
"Apache-2.0"
] | smilelight/lightNLP | lightnlp/tg/lm/module.py | 8,565 | Python |
import concurrent.futures
import threading
from asyncio import coroutines
from asyncio.events import AbstractEventLoop
from asyncio.futures import Future
import attr
import uuid
import asyncio
from asyncio import ensure_future
from typing import Any, Union, Coroutine, Callable, Generator, TypeVar, \
... | 33.296 | 79 | 0.658097 | [
"Apache-2.0"
] | hobo0cn/MerceEdge | merceedge/util/async_util.py | 8,324 | Python |
import requests
import json
import os
import copy
import smtplib
import jwt
from datetime import datetime, timedelta
# SMTP 라이브러리
from string import Template # 문자열 템플릿 모듈
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from django.core.validators import validate_email, ValidationErr... | 39.587234 | 88 | 0.646136 | [
"MIT"
] | Einsicht1/recipe-app-api | app/user/example.py | 9,725 | Python |
#
# Copyright (c) 2017 Intel Corporation
#
# 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... | 47.977778 | 114 | 0.712367 | [
"Apache-2.0"
] | AustinDeric/coach | rl_coach/filters/observation/observation_normalization_filter.py | 4,318 | Python |
# Copyright (c) 2013 Mirantis 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 writ... | 27.926941 | 77 | 0.665468 | [
"Apache-2.0"
] | hortonworksqe/sahara | sahara/exceptions.py | 6,116 | Python |
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2020-07-29 06:08
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('wildlifecompliance', '0495_auto_20200729_1345'),
]
operations = [
migration... | 32.857143 | 273 | 0.684058 | [
"Apache-2.0"
] | Djandwich/wildlifecompliance | wildlifecompliance/migrations/0496_auto_20200729_1408.py | 690 | Python |
from django.db import models
from django.db.models.query import QuerySet, Q
from django.db.models.base import ModelBase
from django.db.models.fields.related import RelatedField
from django.conf import settings
from utils import NestedSet
from signals import pre_publish, post_publish
# this takes some inspiration from... | 38.249027 | 142 | 0.625992 | [
"BSD-3-Clause"
] | team-35/django-publish | publish/models.py | 19,660 | Python |
import datetime
import numpy as np
import os
import pandas as pd
import psycopg2
from dotenv import load_dotenv, find_dotenv
from flask import current_app as app
from flask import json, jsonify, request
load_dotenv()
####################################################################################################... | 37.487337 | 588 | 0.583937 | [
"MIT"
] | Minaramzey/Sauti-Africa-Market-Monitoring-DS | routes.py | 48,846 | Python |
from dagster import check
from dagster.core.types.marshal import PickleSerializationStrategy
from .errors import DagstermillError, DagsterUserCodeExecutionError
from .manager import Manager, MANAGER_FOR_NOTEBOOK_INSTANCE
from .serialize import SerializableRuntimeType, read_value
from .solids import define_dagstermill_... | 37 | 99 | 0.765766 | [
"Apache-2.0"
] | atsuhiro/dagster | python_modules/dagstermill/dagstermill/__init__.py | 2,997 | Python |
from __future__ import annotations
def recursive_binary_search(l: list, target: int, low: int, high: int) -> int | None:
mid = low + (high - low) // 2
if mid < len(l):
if l[mid] == target:
return mid
elif target > l[mid]:
return recursive_binary_search(l, target, mid + 1... | 36.5 | 85 | 0.6 | [
"MIT"
] | Pyt45/algorithms-dataStructure-python | Search/RecursiveBinarySearch.py | 730 | Python |
from __future__ import unicode_literals
from django.contrib import admin
from django.conf import settings
from django.conf.urls import url
from django import forms
from django.core.urlresolvers import reverse
from django.contrib.admin.utils import quote
from django.utils.translation import ugettext_lazy as _, ugettext... | 41.88 | 124 | 0.64425 | [
"Apache-2.0"
] | fusionbox/django-widgy | widgy/contrib/widgy_mezzanine/admin.py | 17,799 | Python |
# Using a combination of list subsetting and variable assignment, create a new variable, eat_sleep_area, that contains the sum of the area of the kitchen and the area of the bedroom.
# Print the new variable eat_sleep_area.
# Create the areas list
areas = ["hallway", 11.25, "kitchen", 18.0, "living room", 20.0, "bedro... | 45.181818 | 182 | 0.752515 | [
"MIT"
] | paulmcheng/python-for-data-science | Chapter2-1-Lists/Subset.py | 497 | Python |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 37.973913 | 121 | 0.598122 | [
"Apache-2.0"
] | EltayebAhmed/phyre | data/task_scripts/main/task01002.py | 4,367 | Python |
movie = input()
director = input()
year = input()
print(f"{movie} (dir. {director}) came out in {year}")
| 17.666667 | 54 | 0.632075 | [
"MIT"
] | Answerman/Coffee-Machine | Problems/Film/task.py | 106 | Python |
from pyalgotrade import strategy
from pyalgotrade import dataseries
from pyalgotrade.dataseries import aligned
from pyalgotrade import plotter
from pyalgotrade.tools import yahoofinance
from pyalgotrade.stratanalyzer import sharpe
import numpy as np
import statsmodels.api as sm
def get_beta(values1, values2):
# ... | 36.819876 | 142 | 0.667173 | [
"Apache-2.0"
] | 01FinTech/pyalgotrade-cn | samples/statarb_erniechan.py | 5,928 | Python |
# Generated by Django 2.1.9 on 2020-02-13 15:15
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', '0009_alter_user_last_name_max_length'),
('stores', '0001_initial'),
]
operation... | 57.216216 | 266 | 0.653755 | [
"MIT"
] | kwanj-k/ctrim | apps/users/migrations/0001_initial.py | 2,117 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.