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 |
|---|---|---|---|---|---|---|---|---|
#!usr/bin/env python
import pyeapi
import yaml
from getpass import getpass
from pprint import pprint
from jinja2 import Template
## Loading the yaml file
with open("arista_connect1.yml") as f:
device_dict = yaml.load(f)
new_list = []
### Keys in the dictionary stored in a list
for k in device_dict.keys():
new_... | 29.505747 | 69 | 0.701987 | [
"Apache-2.0"
] | ramyacr97/RamyaPython | arista_exercise/ex4_example.py | 2,567 | Python |
#!C:\Users\Claudia\PycharmProjects\BlackJack\venv\Scripts\python.exe
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==19.0.3','console_scripts','pip3.7'
__requires__ = 'pip==19.0.3'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys... | 32.384615 | 70 | 0.672209 | [
"MIT"
] | hillc255/BlackJack | venv/Scripts/pip3.7-script.py | 421 | Python |
# -*- coding: utf-8 -*-
"""
Source: https://github.com/awesto/django-shop/blob/12e246b356dbc1bc5bbdc8f056e3cb109c617997/shop/money/__init__.py
"""
from .money_maker import MoneyMaker, AbstractMoney
# The default Money type for this shop
Money = MoneyMaker()
| 28.777778 | 114 | 0.764479 | [
"BSD-3-Clause"
] | infolabs/django-edw-shop | backend/edw_shop/money/__init__.py | 259 | Python |
# -*- coding: utf-8 -*-
#
# 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/.
# imports ######################################################################
import rsa
... | 29.347826 | 80 | 0.591111 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | sunarch/libmonty | other/tests/rsa-example.py | 1,350 | 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 ... | 44.494949 | 125 | 0.706016 | [
"MIT"
] | AikoBB/azure-sdk-for-python | sdk/resources/azure-mgmt-resource/azure/mgmt/resource/policy/v2016_04_01/aio/_policy_client.py | 4,405 | Python |
from typing import Tuple, Union
from discord import Embed, Member, PermissionOverwrite, TextChannel, VoiceChannel, VoiceState
from discord.ext.commands import bot_has_guild_permissions
from discord_slash import (
Button,
ComponentContext,
Modal,
ModalContext,
Select,
SelectOption,
SlashComm... | 41.224944 | 100 | 0.64376 | [
"MIT"
] | Damego/Asteroid-Discord-Bot | source/cogs/private_rooms.py | 18,513 | Python |
from flask import request
from flask_restplus import Resource
from app.project.auth import auth
from app.project.auth.auth_service import AuthService
from app.project.user.user_dto import UserDto
from app.project.user.user_service import UserService
api = UserDto.api
_user = UserDto.user
@api.route('/')
class UserL... | 29.934783 | 53 | 0.690632 | [
"MIT"
] | makci97/lms_flask | app/project/user/user_controller.py | 1,377 | Python |
from django.core.management.base import BaseCommand
# Third-Party
import requests
class Command(BaseCommand):
help = "Command to upload from dropbox."
def add_arguments(self, parser):
parser.add_argument(
'dropbox',
nargs='?',
)
def handle(self, *args, **options)... | 26.193548 | 58 | 0.559113 | [
"BSD-2-Clause"
] | barberscore/archive-api | project/apps/core/management/commands/upload_file.py | 812 | Python |
import setuptools
from os import path
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setuptools.setup(
name='amazonstoreprice',
packages=['amazonstoreprice'],
package_dir={'amazonestoreprice': ... | 39.464286 | 80 | 0.685973 | [
"BSD-2-Clause"
] | Mirio/amazonstore-price | setup.py | 1,105 | Python |
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative wo... | 39.015385 | 98 | 0.568119 | [
"Apache-2.0"
] | Blacksmith-qi/qiskit-terra | qiskit/circuit/gate.py | 10,144 | Python |
import numpy as np
def make_exp_kernel(L0):
def exp_kernel(x1, x2):
x1 = np.expand_dims(x1, 2) # Append a singleton dimension
x2 = x2.T
return np.exp(-np.mean(np.abs(x1 - x2), axis=1) / L0)
return exp_kernel
def make_sq_exp_kernel(L0):
def sq_exp_kernel(x1, x2):
x1 = np.exp... | 36.703704 | 74 | 0.634712 | [
"MIT"
] | LinZichuan/drmad | cpu_ver/hypergrad/kernel_methods.py | 991 | Python |
from chalice.app import Chalice
from chalice.app import (
ChaliceViewError, BadRequestError, UnauthorizedError, ForbiddenError,
NotFoundError, ConflictError, TooManyRequestsError
)
__version__ = '0.2.0'
| 23.666667 | 73 | 0.793427 | [
"Apache-2.0"
] | yzjamm/awstest | chalice/__init__.py | 213 | Python |
import os
import sys
import torch
import numpy as np
import datetime
import logging
import provider
import importlib
import shutil
import argparse
from pathlib import Path
from tqdm import tqdm
from data_utils.PCDLoader import *
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_DIR = BASE_DIR
sys.path.appe... | 42.536458 | 161 | 0.588772 | [
"MIT"
] | congw112358/Pointnet_Pointnet2_pytorch | train_realMulti-DA-Loss_classification.py | 16,334 | Python |
# Copyright 2020 Determined AI. 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 o... | 34.536585 | 83 | 0.635946 | [
"Apache-2.0"
] | determined-ai/yogadl | yogadl/dataref/_local_lmdb_dataref.py | 2,832 | Python |
# coding: utf-8
import pprint
import re # noqa: F401
import six
class UserNotificationSubject(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
... | 27.60221 | 104 | 0.572858 | [
"MIT"
] | pygitee/pygitee | gitee/models/user_notification_subject.py | 4,996 | Python |
import datetime as dt
import matplotlib.pyplot as plt
import lifetimes
import numpy as np
import os
import pandas as pd
import seaborn as sns
def numcard(x):
return x.nunique(), len(x)
def todateclean(x):
return pd.to_datetime(x, errors='coerce').dt.date.astype('datetime64')
"""
- info, shape, dtypes
- df.isn... | 38.88685 | 109 | 0.71005 | [
"MIT"
] | cbymar/clv-modeling | clvscript00.py | 12,716 | Python |
# Copyright 2014 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import fcntl
import hashlib
import os
import shutil
import subprocess
import sys
# Allow use of this module even if termcolor is missing. There are ma... | 27.70122 | 80 | 0.678553 | [
"BSD-3-Clause"
] | DiamondLovesYou/webports | lib/webports/util.py | 13,629 | Python |
from . import sean_common as common
import torch.nn as nn
import torch
from basicsr.utils.registry import ARCH_REGISTRY
class LFF(nn.Module):
def __init__(self, scale, n_colors, conv=common.default_conv, n_feats=64):
super(LFF, self).__init__()
kernel_size = 3
n_layes = 5
act = nn.... | 30.93763 | 88 | 0.555541 | [
"Apache-2.0",
"MIT"
] | neu-szy/BasicSR | basicsr/archs/seanet_arch.py | 14,881 | Python |
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
... | 34.730159 | 80 | 0.661792 | [
"BSD-3-Clause"
] | GregVial/RelaxedLasso | docs/source/conf.py | 2,189 | Python |
# Lint as: python2, python3
# Copyright 2019 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 req... | 39.085106 | 79 | 0.707403 | [
"Apache-2.0"
] | Kareem-negm/tfx | tfx/components/trainer/fn_args_utils_test.py | 3,674 | 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 ... | 43.670103 | 370 | 0.664542 | [
"Apache-2.0"
] | pulumi-bot/pulumi-azure-native | sdk/python/pulumi_azure_native/portal/user_settings.py | 4,236 | Python |
# Copyright 2020. Allen Institute. All rights reserved
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
# following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the follow... | 47.639296 | 120 | 0.697999 | [
"BSD-3-Clause"
] | chenziao/bmtk | bmtk/utils/reports/spike_trains/plotting.py | 16,245 | Python |
import time
import pygame
def manual_control(**kwargs):
from .knights_archers_zombies import env as _env
env = _env(**kwargs)
env.reset()
done = False
cur_agent = 0
frame_count = 0
# frame_limit = 500
quit_game = 0
while not done:
# while frame_count < frame_limit: # Unco... | 34.275862 | 193 | 0.492455 | [
"MIT"
] | AnanthHari/PettingZoo | pettingzoo/gamma/knights_archers_zombies/manual_control.py | 1,988 | Python |
import sys, getopt
from .summarizer import summarize
from .keywords import keywords
# Types of summarization
SENTENCE = 0
WORD = 1
def exit_with_error(err):
print("Error: " + str(err))
usage()
sys.exit(2)
def get_arguments():
try:
opts, args = getopt.getopt(sys.argv[1:], "t:s:r:w:h", ["text... | 24.597561 | 120 | 0.600892 | [
"MIT"
] | LShostenko/textrank | summa/textrank.py | 2,017 | Python |
# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community
Edition) available.
Copyright (C) 2017-2021 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... | 34.974843 | 118 | 0.621471 | [
"Apache-2.0"
] | 64761294/bk-sops | pipeline_plugins/components/collections/controller.py | 6,061 | Python |
from typing import List
from typing import Tuple
from pcapi.core import mails
from pcapi.core.bookings import constants as booking_constants
from pcapi.core.bookings.models import Booking
from pcapi.core.categories import subcategories
from pcapi.core.mails.models.sendinblue_models import SendinblueTransactionalEmailD... | 36.7 | 101 | 0.735306 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | adriengraux/pass-culture-api | src/pcapi/core/mails/transactional/bookings/booking_expiration_to_beneficiary.py | 2,569 | Python |
__version__ = "0.1.0"
import mmap
import os
# from .ext import load_file, parse
#-------------------------------------------------------------------------------
def parse_file(path, **kw_args):
fd = os.open(path, os.O_RDONLY)
try:
map = mmap.mmap(fd, 0, prot=mmap.PROT_READ)
return parse(ma... | 19.473684 | 80 | 0.475676 | [
"MIT"
] | alexhsamuel/fixprs | src/fixprs/__init__.py | 370 | Python |
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2022 Osyris contributors (https://github.com/nvaytet/osyris)
# flake8: noqa
from .array import Array
from .datagroup import Datagroup
from .dataset import Dataset
from .plot import Plot
from .ism_physics import get_eos, get_opacities
| 26.545455 | 76 | 0.791096 | [
"BSD-3-Clause"
] | Adnan-Ali-Ahmad/osyris | src/osyris/core/__init__.py | 292 | Python |
import re
import shutil
import os
class FileRenamer:
def __init__(self, text):
self.text = text
self.processed = self.text
def reset(self):
self.processed = self.text
def replace_tag(self, tag, value):
if value is None:
value = ''
pattern = re.compile(... | 32.25 | 78 | 0.527778 | [
"MIT"
] | makzyt4/discogs-tagger | discogstagger/renamer.py | 1,548 | Python |
from filelock import FileLock
import torch
import pandas as pd
from .tools import BuildingTemperatureDataset
import os
def train(model, device, dataloader, optimizer):
"""
Performs one epoch of training.
Order of rooms in building and in data must match otherwise model will fit wrong rooms to data.
"""... | 32.175966 | 145 | 0.620381 | [
"MIT"
] | BFourcin/rcmodel | src/rcmodel/optimisation.py | 7,497 | Python |
from .delayeddataframe import DelayedDataFrame # noqa:F401
from . import annotator # noqa: F401
from . import regions
from . import genes
__version__ = '0.4'
_all__ = [DelayedDataFrame, annotator, regions, genes, __version__]
| 23.1 | 67 | 0.761905 | [
"MIT"
] | IMTMarburg/mbf_genomics | src/mbf_genomics/__init__.py | 231 | 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
#... | 34.896552 | 106 | 0.629051 | [
"Apache-2.0",
"BSD-2-Clause",
"MIT",
"ECL-2.0",
"BSD-3-Clause"
] | JCoder01/airflow | tests/providers/amazon/aws/operators/test_hive_to_dynamodb.py | 5,060 | Python |
# protoc plugin to map from FileDescriptorProtos to Envoy doc style RST.
# See https://github.com/google/protobuf/blob/master/src/google/protobuf/descriptor.proto
# for the underlying protos mentioned in this file. See
# https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html for Sphinx RST syntax.
fro... | 37.362517 | 122 | 0.727482 | [
"Apache-2.0"
] | Gsantomaggio/envoy | tools/protodoc/protodoc.py | 27,312 | Python |
# coding=utf-8
# *** WARNING: this file was generated by test. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
from . import _utilities
import typing
# Export this package's modules as members:
from .foo import *
from .provider import *
_utilities.register(
resource_modules="""... | 17.352941 | 80 | 0.615254 | [
"Apache-2.0"
] | 64bit/pulumi | pkg/codegen/testing/test/testdata/simple-methods-schema-single-value-returns/python/pulumi_example/__init__.py | 590 | Python |
from django import forms
from django.contrib.auth.models import User
from django.contrib import messages
from django.contrib.messages.views import SuccessMessageMixin
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, Http404, HttpResponseForbidden, HttpResponse
from django.short... | 33.621818 | 132 | 0.742808 | [
"MIT"
] | caiocsalvador/whats_the_craic | src/profiles/views.py | 9,246 | Python |
# pylint: disable=R,C,W
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Author : Nasir Khan (r0ot h3x49)
Github : https://github.com/r0oth3x49
License : MIT
Copyright (c) 2018-2025 Nasir Khan (r0ot h3x49)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associa... | 38.255708 | 168 | 0.626641 | [
"MIT"
] | 0x2f0713/udemy-dl | udemy/internal.py | 8,378 | Python |
import argparse
import datetime
import time
import torch
from torch import distributed as dist
from torch.nn import DataParallel
from torch.nn.parallel.distributed import DistributedDataParallel
from distillation.tool import DistillationBox
from models import load_ckpt, get_model, save_ckpt, set_bottleneck_transforme... | 47.814516 | 118 | 0.740597 | [
"MIT"
] | jsiloto/adaptive-cob | src/mimic_fix.py | 5,929 | Python |
#!/usr/bin/env python3
from fairseq import models
from fairseq.data import FairseqDataset, data_utils
from fairseq.models import FairseqMultiModel
from fairseq.tasks.multilingual_translation import MultilingualTranslationTask
from pytorch_translate.data import iterators as ptt_iterators
class PyTorchTranslateMultiTa... | 31.457143 | 85 | 0.64941 | [
"BSD-3-Clause"
] | Meteorix/translate | pytorch_translate/tasks/pytorch_translate_multi_task.py | 2,202 | Python |
#!/usr/bin/python
#
# Copyright (c) 2018 Juniper Networks, Inc. All rights reserved.
#
"""
Swift upload image file.
This file contains implementation of gett
swift download URL for the uploaded image file
"""
from builtins import object
from builtins import str
from future import standard_library
standard_library.i... | 29.158845 | 79 | 0.59168 | [
"Apache-2.0"
] | edwinpjacques/contrail-controller | src/config/fabric-ansible/ansible-playbooks/library/swift_fileutil.py | 8,077 | Python |
import sys
import logging
logger = logging.getLogger(__name__)
import base64
import json
import datetime
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric... | 25.282258 | 81 | 0.690909 | [
"MIT"
] | christophevg/py-mqfactory | mqfactory/message/security/rsa.py | 3,135 | Python |
from juno.resources import handler_request
from juno.resources.routes import subscription_routes
def create(dictionary):
return handler_request.post(subscription_routes.get_base_url(), dictionary)
def find_all():
return handler_request.get(subscription_routes.get_base_url())
def find_by_id(subscription_id... | 25.658537 | 80 | 0.794677 | [
"MIT"
] | leogregianin/juno-python | juno/subscription.py | 1,052 | Python |
# Copyright 2019 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 a... | 32.511628 | 89 | 0.546853 | [
"Apache-2.0"
] | mindspore-ai/akg | tests/st/ops/ascend/vector/test_expm1_001.py | 2,796 | Python |
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse
from gfx.models import Material, Mesh, Shader, Model
import subprocess
import os
import base64
import platform
def get_mesh( request, mesh_id):
mesh = get_object_or_404(Mesh, pk=mesh_id)
"""
TODO: Make it grab it from t... | 20.650485 | 104 | 0.672779 | [
"MIT"
] | Etskh/TheDruid | gfx/views.py | 2,127 | Python |
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
import numpy as np
import os
import argparse
def plot():
results_dir = './'
results_files = [result for result in os.listdir(results_dir) if 'MAESTROeX' in result]
n_gpus_per_node = 6
throughput_list = []
nnodes_list = []
... | 28.137931 | 128 | 0.606618 | [
"BSD-3-Clause"
] | AMReX-Astro/MAESTRO- | Exec/test_problems/reacting_bubble/scaling/sc20/plot.py | 2,448 | Python |
from .datasets import SumStatDataset
| 18.5 | 36 | 0.864865 | [
"MIT"
] | theLongLab/phx-nn | src/dataset/__init__.py | 37 | Python |
import numpy as np
from yt.loaders import load_uniform_grid
from yt.testing import assert_allclose
def test_magnetic_code_units():
sqrt4pi = np.sqrt(4.0 * np.pi)
ddims = (16,) * 3
data = {"density": (np.random.uniform(size=ddims), "g/cm**3")}
ds1 = load_uniform_grid(
data, ddims, magnetic_u... | 30.423077 | 85 | 0.683944 | [
"BSD-3-Clause-Clear"
] | Carreau/yt | yt/units/tests/test_magnetic_code_units.py | 1,582 | Python |
import math
# 1
area_of_circle = lambda r: math.pi * r ** 2
print(area_of_circle(10))
# 2
calculation = lambda x, y: ((x + y), (x - y))
print(calculation(4, 2))
# 3
def product(n):
if n == 1:
return 1
else:
return n * product(n - 1)
print(product(5))
# 4
time = lambda milli: (
round(m... | 22.275862 | 102 | 0.562693 | [
"MIT"
] | pradeep-charism/nus-mtech-workshops | nus-bead/examples/Workshop01.py | 1,292 | Python |
import threading
import time
class PyMbsThread(threading.Thread):
def __init__(self, function, realTime=False):
threading.Thread.__init__(self)
self.execute = False
self.function = function
self.realTime = realTime
self.scaling = 1
# Start-Time (Model)
self... | 21.78481 | 68 | 0.537478 | [
"MIT"
] | brutzl/pymbs | pymbs/ui/thread.py | 1,721 | Python |
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cloudblue.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise Impo... | 28.590909 | 73 | 0.683625 | [
"MIT"
] | dussiks/cloudblue | manage.py | 629 | Python |
"""Config flow for Coronavirus integration."""
from __future__ import annotations
from typing import Any
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResult
from . import get_coordinator
from .const import DOMAIN, OPTION_WORLDWIDE
class ConfigFlow... | 31.673077 | 85 | 0.652702 | [
"Apache-2.0"
] | bimmbo/core | homeassistant/components/coronavirus/config_flow.py | 1,647 | Python |
from django_cradmin import crinstance, crapp
from django_cradmin.crinstance import reverse_cradmin_url
from devilry.apps.core.models import Period
from devilry.devilry_account.models import PeriodPermissionGroup
from devilry.devilry_admin.cradminextensions import devilry_crmenu_admin
from devilry.devilry_cradmin impor... | 40.272727 | 112 | 0.687133 | [
"BSD-3-Clause"
] | aless80/devilry-django | devilry/devilry_admin/views/period/crinstance_period.py | 4,430 | Python |
import ref_bot.cog.articlerefs
import importlib
import conf
from discord.ext import commands
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
def setup_dbsession():
engine = create_engine(conf.ini_config.get('sqlalchemy', 'connection_string'))
sessionm = sessionmaker()
... | 25.321429 | 86 | 0.750353 | [
"MIT"
] | tser0f/ref_bot | ref_bot/extension.py | 709 | Python |
# qubit number=4
# total number=42
import cirq
import qiskit
from qiskit import IBMQ
from qiskit.providers.ibmq import least_busy
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit import BasicAer, execute, transpile
from pprint import pprint
from qiskit.test.mock import FakeVigo
from ma... | 35.648 | 165 | 0.656867 | [
"BSD-3-Clause"
] | UCLA-SEAL/QDiff | benchmark/startQiskit_QC2449.py | 4,456 | Python |
# from nonbonded.cli.project.project import project
#
# __all__ = [project]
| 19 | 51 | 0.75 | [
"MIT"
] | SimonBoothroyd/nonbonded | nonbonded/cli/projects/__init__.py | 76 | Python |
# Copyright 2022 The Kubeflow 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 ... | 35.036364 | 103 | 0.640114 | [
"Apache-2.0"
] | a9p/katib | pkg/suggestion/v1beta1/internal/trial.py | 3,854 | Python |
import io
from sdk.db import database
import numpy as np
import matplotlib.pyplot as plt
from numba import jit
from utils import logger
semester_order = ['FA', 'WI', 'SP', 'SU']
def get_section(x):
return (
x.get('semester'),
x.get('year')
)
def filter_function(sections):
d = {}
... | 24.111111 | 94 | 0.598157 | [
"Apache-2.0"
] | jzlotek/drexel-tms-parser | src/plotter.py | 1,085 | Python |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# capmetrics-etl documentation build configuration file, created by
# sphinx-quickstart on Mon Jan 11 00:08:57 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in th... | 32.452962 | 79 | 0.719025 | [
"MIT"
] | jga/capmetrics-etl | docs/conf.py | 9,314 | Python |
import string
from app.chatterbot import languages
from spacy.lang.zh import Chinese
class LowercaseTagger(object):
"""
Returns the text in lowercase.
"""
def __init__(self, language=None):
self.language = language or languages.ENG
def get_text_index_string(self, text):
return te... | 30.5 | 91 | 0.535519 | [
"BSD-3-Clause"
] | Jack2313/WeChatterBot | app/chatterbot/tagging.py | 2,159 | Python |
import torch_xla.test.test_utils as test_utils
import torch_xla.distributed.xla_multiprocessing as xmp
import torch_xla.core.xla_model as xm
import torch_xla.utils.utils as xu
import torch_xla.distributed.parallel_loader as pl
import torch_xla.debug.metrics as met
import torch_xla
import torchvision.transforms as trans... | 37.169951 | 173 | 0.653701 | [
"Apache-2.0"
] | mlexample/gcspytorchimagenet | test_train_mp_wds_local.py | 15,091 | Python |
#!/usr/bin/env python3
# Copyright (c) 2014-2017 The Bitcoinlimitededition Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the REST API."""
from test_framework.test_framework import BitcoinlimitededitionTes... | 46.118182 | 132 | 0.642355 | [
"MIT"
] | bitcoinlimitededition/bitcoinlimitededition | test/functional/interface_rest.py | 15,219 | Python |
import random
import turtle
import time
def menu():
x = input('would you like to start the game? \n (YES/NO) \n would you like to quit the menu bar? \n (QUIT) \n *PLEASE USE CAPITAL LETTERS \n YOUR ANSWER: ')
if x == 'NO' or x == 'QUIT':
quit()
elif x == 'YES':
print('')
menu()
print('are... | 25.291908 | 160 | 0.601531 | [
"MIT"
] | idane19-meet/EAT_IT | jennifer & Laith/laith_eatit.py | 8,751 | Python |
import math
n=int(input("team:"))
S=math.factorial(n)//math.factorial(n-3)
D=math.factorial(n)
print("top places:" +str(S))
print("all places:" +str(D))
| 21.857143 | 40 | 0.679739 | [
"MIT"
] | brickdonut/2019-fall-polytech-cs | 2z.py | 153 | Python |
import torch
import torch.nn as nn
from torch.utils.data import TensorDataset, DataLoader
import torch.nn.functional as F
class MLP(nn.Module):
def __init__(self, input_size, hidden_layers, out_size):
super(MLP, self).__init__()
self.sizes = [input_size] + hidden_layers + [out_size]
self.li... | 36.966667 | 158 | 0.6318 | [
"MIT"
] | yunndlalala/MCS-project | nn_model.py | 3,327 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__all__ = ['baidu_download']
from ..common import *
from .embed import *
from .universal import *
def baidu_get_song_data(sid):
data = json.loads(get_html(
'http://music.baidu.com/data/music/fmlink?songIds=%s' % sid, faker=True))['data']
if data['xcode'... | 36.911585 | 140 | 0.591641 | [
"MIT"
] | 1156859110/you-get | src/you_get/extractors/baidu.py | 12,107 | Python |
# coding: utf-8
"""
Decision Lens API
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) # noqa: E501
OpenAPI spec version: 1.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
impor... | 24.902439 | 119 | 0.733595 | [
"MIT"
] | dlens/dlxapi | python/test/test_field_description_updated_event.py | 1,021 | Python |
#!/usr/bin/env python
import jinja2
import os
import re
import shlex
import sys
import mkdocs.build
from mkdocs.build import build
from mkdocs.config import load_config
from urllib2 import urlopen
import subprocess
def line_containing(lines, text):
for i in range(len(lines)):
if text.lower() in lines[i].lower(... | 27.133333 | 119 | 0.60415 | [
"BSD-3-Clause"
] | fossabot/srclib | docs/buildsite.py | 3,663 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is part of moses. Its use is licensed under the GNU Lesser General
# Public License version 2.1 or, at your option, any later version.
from __future__ import print_function, unicode_literals
import logging
import argparse
import subprocess
import sys
import... | 38.386525 | 98 | 0.65358 | [
"MIT"
] | Feecely/fairseq_bertnmt | examples/mosesdecoder-master/scripts/training/rdlm/train_rdlm.py | 10,825 | Python |
# qubit number=3
# total number=14
import numpy as np
from qiskit import QuantumCircuit, execute, Aer, QuantumRegister, ClassicalRegister, transpile, BasicAer, IBMQ
import networkx as nx
from qiskit.visualization import plot_histogram
from typing import *
from pprint import pprint
from math import log2
from collectio... | 27.641304 | 118 | 0.634683 | [
"BSD-3-Clause"
] | UCLA-SEAL/QDiff | benchmark/startQiskit_noisy696.py | 2,543 | Python |
"""Provides the MenuItem class."""
from pathlib import Path
from typing import TYPE_CHECKING, Optional, Union
from attr import attrs
from ..action import ActionFunctionType
from ..mixins import RegisterEventMixin
if TYPE_CHECKING:
from ..types import TitleFunction
@attrs(auto_attribs=True)
class MenuItem(Regi... | 33.2 | 78 | 0.677108 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | chrisnorman7/earwax | earwax/menus/menu_item.py | 2,490 | Python |
import numpy as np
import matplotlib.pyplot as plt
def subf(n):
if n <= 1:
return 0
elif n == 2:
return 1
return (n - 1) * (subf(n - 1) + subf(n - 2))
x = np.arange(1, 5, 1)
y = np.vectorize(subf)(x)
plt.plot(x, y)
plt.show()
| 11.045455 | 45 | 0.572016 | [
"Apache-2.0"
] | MarcusTL12/School | 18Host/TMA4120/latex/PyplotTesting/Scripts/subfactorial.py | 243 | Python |
# -*- coding: utf-8 -*-
from django.urls import path
app_name = 'login'
urlpatterns = []
| 15.833333 | 29 | 0.610526 | [
"MIT"
] | AlcindoSchleder/dashboard | apps/login/urls.py | 95 | Python |
from datetime import datetime
import numpy as np
import re
from bamboo.core.frame import RESERVED_KEYS
from bamboo.core.parser import Parser
from bamboo.lib.exceptions import ArgumentError
from bamboo.lib.mongo import reserve_encoded
CARDINALITY = 'cardinality'
OLAP_TYPE = 'olap_type'
SIMPLETYPE = 'simpletype'
LABEL... | 30.149635 | 78 | 0.641932 | [
"BSD-3-Clause"
] | SEL-Columbia/bamboo | bamboo/lib/schema_builder.py | 8,261 | Python |
import numpy as np
import theano.tensor as tt
from pymc3.util import get_variable_name
from ..math import logsumexp
from .dist_math import bound
from .distribution import Discrete, Distribution, draw_values, generate_samples
from .continuous import get_tau_sd, Normal
def all_discrete(comp_dists):
"""
Determi... | 34.486607 | 119 | 0.535016 | [
"Apache-2.0"
] | himkt/pymc3 | pymc3/distributions/mixture.py | 7,725 | Python |
'''
Class containing a Massey-style model and rankings of a season.
todo: documentation
todo: type hints
todo: inherit from Model?
'''
class Massey:
def __init__(self):
'''
todo: this. what fields does it need?
'''
pass
def rank(self) -> List[Team]:
'''
Giv... | 21.675676 | 94 | 0.562344 | [
"Apache-2.0"
] | alhart2015/march-madness | src/models/Massey.py | 802 | Python |
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
# directory.py - parse directory information
# -----------------------------------------------------------------------------
# $Id$
#
# ---------------------------------------------------------------------------... | 34.425532 | 79 | 0.549444 | [
"MIT"
] | jtackaberry/stagehand | external/metadata/misc/directory.py | 3,236 | Python |
from Transform.Transform import *
qhost = '10.0.0.10'
qport = 5100
bucket_name = 's3a://insighttmpbucket1/'
index_name = bucket_name + 'index.txt'
tickers = get_stock_list(index_name)
q_con, flint_con, spark_con = connect(qhost, qport)
#push_raw_table(q_con, spark_con, flint_con, bucket_name, tickers)
push_returns(q... | 28.461538 | 66 | 0.775676 | [
"MIT"
] | adityagc/Epoch | src/main.py | 370 | Python |
# This code is a part of XMM: Generate and Analyse (XGA), a module designed for the XMM Cluster Survey (XCS).
# Last modified by David J Turner (david.turner@sussex.ac.uk) 21/01/2021, 11:45. Copyright (c) David J Turner
from .fit import single_temp_apec, power_law, single_temp_apec_profile
from .run import execute_c... | 37.555556 | 110 | 0.763314 | [
"BSD-3-Clause"
] | DavidT3/XGA | xga/xspec/__init__.py | 338 | Python |
for i in range(1,int(input())+1): #More than 2 lines will result in 0 score. Do not leave a blank line also
print((pow(int(pow(10, i)//9), 2)))
| 20 | 108 | 0.6 | [
"MIT"
] | abivilion/Hackerank-Solutions- | Python/Math/triangle_quest_2.py | 160 | Python |
"""trefechanwen URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Cla... | 41.547619 | 108 | 0.697994 | [
"MIT"
] | HedgehogProductions/trefechanwen | trefechanwen/urls.py | 1,745 | Python |
#!/usr/bin/env python
# coding: utf-8
# # Exploring JHU COVID Case, Death, and Vaccine Information
# This notebook takes the live, updated data from JHU CSSE and GovEx, formats and simplifies it for my purposes, and saves it in csv files in the same directory. The two data sources use slightly different conventions an... | 40.268966 | 587 | 0.7503 | [
"CC0-1.0"
] | emmmoore/vaccinesandcases | .scripts/dataprep.py | 5,839 | Python |
from typing import Tuple
import math
import torch
from torch.optim.optimizer import Optimizer
def linear_warmup_and_cosine_protocol(
f_values: Tuple[float, float, float],
x_milestones: Tuple[int, int, int, int]):
"""
There are 5 regions:
1. constant at f0 for x < x0
2. linear increase ... | 38.127778 | 115 | 0.560105 | [
"Apache-2.0"
] | broadinstitute/tissue_purifier | src/tissue_purifier/models/_optim_scheduler.py | 6,863 | Python |
import uuid
from django.contrib.postgres.fields import ArrayField
from django.db import models
from api.common.models import TimestampableModel
from api.flags.enums import FlagLevels, FlagStatuses, FlagColours, FlagPermissions
from api.teams.models import Team
class FlagManager(models.Manager):
def get_by_natur... | 35.703297 | 116 | 0.698984 | [
"MIT"
] | uktrade/lite-ap | api/flags/models.py | 3,249 | Python |
from .Selenzy import (
readData,
updateScore,
analyse,
seqScore
)
from .Selenzy2 import (
analyse2
)
from .newtax import (
newtax
)
| 12 | 23 | 0.634615 | [
"MIT"
] | brsynth/selenzy-wrapper | selenzy_wrapper/selenzy/__init__.py | 156 | Python |
'''
Title : Shape and Reshape
Subdomain : Numpy
Domain : Python
Author : codeperfectplus
Created : 06 May 2020
'''
import numpy as np
arr = list(map(int,input().split()))
arr = np.array(arr)
print(np.reshape(arr,(3,3)))
| 15.666667 | 36 | 0.651064 | [
"MIT"
] | accidentalgenius09/competitive-programming-solution | HackerRank/PythonHackerRankSolutions/Numpy/ShapeandReshape.py | 235 | Python |
#!/usr/bin/env python3
# Copyright (c) 2016-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 Wallet encryption"""
import time
from test_framework.test_framework import enzoTestFramework
fro... | 43.643678 | 138 | 0.704504 | [
"MIT"
] | EnzoNodes/ENZO | test/functional/wallet_encryption.py | 3,797 | Python |
#!/usr/bin/env python3
# Copyright (c) 2017 The Eurodollar Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test deprecation of RPC calls."""
from test_framework.test_framework import EurodollarTestFramework
from ... | 45.285714 | 123 | 0.73265 | [
"MIT"
] | watchdog1023/Eurodollar | test/functional/rpc_deprecated.py | 1,268 | Python |
#
# PySNMP MIB module CISCO-EVC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-EVC-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:57:43 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | 232.810247 | 7,344 | 0.79058 | [
"Apache-2.0"
] | agustinhenze/mibs.snmplabs.com | pysnmp-with-texts/CISCO-EVC-MIB.py | 122,691 | Python |
Desc = cellDescClass("SDFFSRX1")
Desc.properties["cell_footprint"] = "sdffsr"
Desc.properties["area"] = "99.792000"
Desc.properties["cell_leakage_power"] = "2335.442220"
Desc.pinOrder = ['CK', 'D', 'IQ', 'IQN', 'Q', 'QN', 'RN', 'SE', 'SI', 'SN', 'next']
Desc.add_arc("CK","SI","setup_rising")
Desc.add_arc("CK","SI","hol... | 34.047619 | 83 | 0.67972 | [
"MIT"
] | avielazari/vlsistuff | synlib/descriptions/SDFFSRX1.py | 1,430 | Python |
# -*- coding: utf-8 -*-
from django.db import models
from django.shortcuts import render,redirect
from django.views import View
from django.contrib.auth import authenticate, login , logout as django_logout
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.http imp... | 26.214286 | 81 | 0.768392 | [
"Apache-2.0"
] | v1ct0r5u3n/TBS | TBS/b2b/views.py | 1,101 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This is a self-generating script that contains all of the iso3166-1 data.
To regenerate, a CSV file must be created that contains the latest data. Here's
how to do that:
1. Visit https://www.iso.org/obp
2. Click the "Country Codes" radio option and click the search bu... | 27.489198 | 79 | 0.46045 | [
"MIT"
] | Bounder/django-countries | django_countries/data.py | 17,818 | Python |
from datetime import datetime
from jinja2 import Markup
from flask import current_app
class _moment(object):
@staticmethod
def include_moment(version='2.5.1', local_js=None):
js = ''
if local_js is not None:
js = '<script src="%s"></script>\n' % local_js
elif version is not... | 33.342857 | 139 | 0.581834 | [
"MIT"
] | ForgottenKahz/CloudOPC | venv/Lib/site-packages/flask_moment.py | 3,501 | Python |
import pandas as pd
pima=pd.read_csv('pima-indians-diabetes.csv',encoding="shift-jis")
pima.columns=['pregnant','plasmaGlucose','bloodP','skinThick','serumInsulin','weight','pedigree','age','diabetes']
from sklearn.model_selection import train_test_split
y = pima['diabetes']
X=pima.drop(['diabetes'],axis=1)
nh = 4
X_tr... | 47.238095 | 114 | 0.794355 | [
"MIT"
] | ytakefuji/machine-learning | elm_pima.py | 992 | Python |
import unittest
from tori.decorator.common import *
class TestDecoratorCommonSingletonClass(unittest.TestCase):
""" Test the 'singleton' decorator. """
class DummyTest(object):
def __init__(self):
self.number = 0
def take_action(self):
self.number += 1
def get_n... | 52.703226 | 119 | 0.667891 | [
"MIT"
] | shiroyuki/Tori | test/ut/test_decorator_common_singleton.py | 8,169 | Python |
from types import BeaverException, Variable, Collection, EmptyCollection, updated_context
from copy import deepcopy as copy
class Statement(object):
'''A generic statement containing any number of variable parts.'''
def __init__(self, subject, verb_objects):
self.subject = subject
self.verb_ob... | 39.973333 | 90 | 0.527352 | [
"MIT"
] | bendmorris/beaver | lib/statement.py | 2,998 | Python |
import copy
import numpy as np
import torch
from mmpose.core import (aggregate_results, get_group_preds,
get_multi_stage_outputs)
def test_get_multi_stage_outputs():
fake_outputs = [torch.zeros((1, 4, 2, 2))]
fake_flip_outputs = [torch.ones((1, 4, 2, 2))]
# outputs_f... | 49.06015 | 78 | 0.546973 | [
"Apache-2.0"
] | jcwon0/BlurHPE | tests/test_evaluation/test_bottom_up_eval.py | 6,525 | Python |
import typing
from typing import List
from quarkchain.core import (
CrossShardTransactionList,
MinorBlock,
MinorBlockHeader,
RootBlock,
TransactionReceipt,
Log,
FixedSizeBytesSerializer,
biguint,
Constant,
)
from quarkchain.core import (
TypedTransaction,
Optional,
Prepe... | 30.998302 | 92 | 0.691669 | [
"MIT"
] | QuarkChain/pyquarkchain | quarkchain/cluster/rpc.py | 36,516 | Python |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import sys
import marshal
from math import log, exp
from ..utils.frequency import AddOneProb
class Bayes(object):
def __init__(self):
self.d = {}
self.total = 0
def save(self, fname):
d = {}
d['total'] = self.t... | 26.145161 | 74 | 0.454041 | [
"MIT"
] | erning/snownlp | snownlp/classification/bayes.py | 1,621 | Python |
from enum import Enum
from sensors.ph_sensor import PhSensor
class SensorType(Enum):
Undefined = 0,
TDS = 1,
Ph = 2,
WaterLevel = 3,
Voltage = 4
class TriggerType(Enum):
Undefined = 0,
NutrientDose = 1,
PhDose = 2,
WaterPumpCutout = 3
class Hydriot():
sensors = dict()
tri... | 29.21875 | 119 | 0.693583 | [
"MIT"
] | mariusvrstr/hydriot | Hydriot.PiAgent/hydriot.py | 1,870 | Python |
# -*- coding: utf-8 -*-
# (C) 2015 Muthiah Annamalai
# setup the paths
from opentamiltests import *
from solthiruthi.data_parser import *
from solthiruthi.solthiruthi import Solthiruthi
import sys
class CmdLineIO(unittest.TestCase):
def test_CLI_interface_help(self):
return
# find a way to run th... | 32.962963 | 82 | 0.639326 | [
"MIT"
] | CRE2525/open-tamil | tests/solthiruthi_data_parser.py | 1,780 | Python |
from jproperties import Properties
class ValidatorUtil:
"""
Create a validator with the property configuration
Functions :
: validate_tomcat : Validate the tomcat server configurations
: validate_property : Validate local.properties and localextensions.xml
"""
@staticmethod... | 30 | 99 | 0.664103 | [
"MIT"
] | AmirthaRajan/Hybris_Data_Analytics | validator_util.py | 780 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.