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 python3
import io
import unittest.mock
import yaz
class ConfigurationPlugin(yaz.Plugin):
"""This is the documentation string for the ConfigurationPlugin"""
choices = {
"yes": True,
"no": False,
"unknown": None,
}
@yaz.task(choice__choices=["yes", "no", "unknow... | 35.612069 | 117 | 0.661825 | [
"MIT"
] | boudewijn-zicht/yaz | yaz/test/test_task_configuration.py | 4,131 | Python |
import unittest
from malcolm.modules.builtin.vmetas import StringMeta
class TestValidate(unittest.TestCase):
def setUp(self):
self.string_meta = StringMeta("test string description")
def test_given_value_str_then_return(self):
response = self.string_meta.validate("TestValue")
asser... | 25.466667 | 64 | 0.708115 | [
"Apache-2.0"
] | MattTaylorDLS/pymalcolm | tests/test_modules/test_builtin/test_stringmeta.py | 764 | Python |
# -*- coding: utf-8 -*-
# Copyright 2017 IBM RESEARCH. 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 requ... | 33.630137 | 79 | 0.619552 | [
"Apache-2.0"
] | christians94/qiskit-sdk-py | qiskit/extensions/standard/rzz.py | 2,455 | Python |
import numpy as np
from sklearn.utils.testing import assert_array_almost_equal
from smoothot.projection import projection_simplex
def _projection_simplex(v, z=1):
"""
Old implementation for test and benchmark purposes.
The arguments v and z should be a vector and a scalar, respectively.
"""
n_fea... | 28.473684 | 78 | 0.650647 | [
"BSD-2-Clause"
] | cptq/smooth-ot | smoothot/tests/test_projection.py | 1,623 | Python |
# Copyright 2019 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... | 36.780952 | 80 | 0.71854 | [
"Apache-2.0"
] | 1244783394/tensorflow | tensorflow/python/data/experimental/benchmarks/parallel_interleave_benchmark.py | 3,862 | Python |
from .multilanguage import antlr4, waxeye
from .python import TatSu, arpeggio, parglare, parsimonious
| 34 | 59 | 0.823529 | [
"Unlicense"
] | KOLANICH/UniGrammarRuntime.py | UniGrammarRuntime/backends/__init__.py | 102 | Python |
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class PyStevedore(PythonPackage):
"""Manage Dynamic Plugins for Python Applications."""
hom... | 31.809524 | 96 | 0.714072 | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | 0luhancheng0/spack | var/spack/repos/builtin/packages/py-stevedore/package.py | 668 | Python |
# Tradingview Technical Analysis (tradingview-ta)
# Author: deathlyface (https://github.com/deathlyface)
# Rewritten from https://www.tradingview.com/static/bundles/technicals.f2e6e6a51aebb6cd46f8.js
# License: MIT
class Recommendation:
buy = "BUY"
strong_buy = "STRONG_BUY"
sell = "SELL"
strong_sell = ... | 27.1875 | 94 | 0.517241 | [
"MIT"
] | Chizkiyahu/python-tradingview-ta | tradingview_ta/technicals.py | 6,525 | Python |
import sys
sys.path.append('./datastructures')
from datastructures import Stack, StackNode
class SetOfStacks:
LIMIT_PER_STACK = 2
def __init__(self):
self.main_stack = Stack()
def pop(self):
if self.is_empty():
return None
elif self._top_stack().is_empty():
... | 20.586207 | 45 | 0.600503 | [
"MIT"
] | italo-batista/competitiveProgramming | cracking-code-interview/chapter_03/3-3_stack_of_plates.py | 1,194 | Python |
import os
import copy
import numpy as np
import click
from typing import List, Optional
import torch
import pickle
def extract_conv_names(model):
model_names = list(name for name in model.keys())
return model_names
def blend_models(low, high, model_res, level):
levels = [x for x in range(level)]
... | 32.701299 | 131 | 0.603654 | [
"MIT",
"BSD-2-Clause",
"Apache-2.0"
] | jscarlson/stylegan2-pytorch | blend.py | 2,518 | Python |
# Copyright 2019 The Magenta 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 ... | 41.35119 | 80 | 0.678854 | [
"Apache-2.0"
] | Surya130499/magenta | magenta/models/image_stylization/image_stylization_finetune.py | 6,947 | Python |
import cv2
import numpy as np
# Gray scale
def BGR2GRAY(img):
b = img[:, :, 0].copy()
g = img[:, :, 1].copy()
r = img[:, :, 2].copy()
# Gray scale
out = 0.2126 * r + 0.7152 * g + 0.0722 * b
out = out.astype(np.uint8)
return out
# LoG filter
def LoG_filter(img, K_size=5, sigma=3):
H, W, C = img.shape
... | 23.096774 | 119 | 0.511872 | [
"MIT"
] | OverHall27/Gasyori100knock | Question_11_20/answers/answer_19.py | 1,432 | Python |
import logging
import os
import sys
import warnings
from collections import namedtuple
from typing import *
import matplotlib.image
import matplotlib.pyplot as plt
from torch import Tensor
from torch.utils.tensorboard import SummaryWriter
from booster import Diagnostic
from .datatracker import DataTracker
BestScore ... | 33.801105 | 119 | 0.61932 | [
"MIT"
] | vlievin/booster-pytorch | booster/logging/logger.py | 6,118 | 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 app... | 39.074185 | 182 | 0.553913 | [
"Apache-2.0"
] | DevilCarp/Paddle | python/paddle/tensor/linalg.py | 117,517 | Python |
import _plotly_utils.basevalidators
class TicksValidator(_plotly_utils.basevalidators.EnumeratedValidator):
def __init__(
self, plotly_name="ticks", parent_name="histogram2dcontour.colorbar", **kwargs
):
super(TicksValidator, self).__init__(
plotly_name=plotly_name,
par... | 33.4 | 86 | 0.644711 | [
"MIT"
] | 1abner1/plotly.py | packages/python/plotly/plotly/validators/histogram2dcontour/colorbar/_ticks.py | 501 | Python |
# ---
# jupyter:
# jupytext:
# formats: ipynb,.pct.py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.3.3
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# %% [markdown]
... | 36.870629 | 478 | 0.715789 | [
"Apache-2.0"
] | christabella/GPflow | doc/source/notebooks/understanding/models.pct.py | 10,545 | Python |
# coding: utf-8
"""
Kubernetes
No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
OpenAPI spec version: v1.13.1
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import os
import sys
i... | 24.177778 | 112 | 0.742647 | [
"Apache-2.0"
] | MiaoRachelYu/python | kubernetes/test/test_v1_scale_io_persistent_volume_source.py | 1,088 | Python |
#%%
import cv2
from pathlib import Path
#%%
root = Path(__file__).resolve().absolute().parent
jorge_path = root / "jorge"
jorge_dst_path = root / "jorge_100"
marissa_path = root / "marissa"
marissa_dst_path = root / "marissa_100"
#%%
for f in jorge_path.iterdir():
old_image = cv2.imread(str(f))
... | 22 | 50 | 0.663102 | [
"Apache-2.0"
] | JorgeGarciaIrazabal/ml-face-detector | scale_image.py | 374 | Python |
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino.tools.mo.ops.ReduceOps import ReduceProd, ReduceAnd, ReduceMax, ReduceMean, ReduceSum, ReduceL2, ReduceMin
from openvino.tools.mo.front.extractor import FrontExtractorOp
from openvino.tools.mo.graph.graph import Node
clas... | 26.474359 | 120 | 0.685714 | [
"Apache-2.0"
] | IndiraSalyahova/openvino | tools/mo/openvino/tools/mo/front/tf/reduce_ext.py | 2,065 | Python |
#!/usr/bin/python
"""
A Python program that creates a list. One of the elements of the list should be
a dictionary with at least two keys. Write this list out to a file using both
YAML and JSON formats. The YAML file should be in the expanded form.
"""
import yaml
import json
a = {
'name': 'router1',
'ip_addr': '1.2.3... | 25.066667 | 79 | 0.617908 | [
"Apache-2.0"
] | melphick/pynet | week1/w1e6.py | 1,128 | Python |
import pandas as pd
import datetime
import matplotlib.pyplot as plt
import ast
from gensim.parsing.preprocessing import STOPWORDS
from nltk.corpus import stopwords
from collections import defaultdict
from nltk.stem import WordNetLemmatizer
import datetime
stop_words = stopwords.words('english')
lemmatizer = WordNet... | 20.703252 | 121 | 0.650697 | [
"MIT"
] | erialc-cal/NLP-FOMC | RA_project/code_python/image_score_posi.py | 5,095 | Python |
from nose import with_setup
from pygears import Intf, clear
from pygears.typing import Queue, Uint
from utils import svgen_check
@with_setup(clear)
@svgen_check(['sieve_0v2_7_8v10.sv'])
def test_uint():
iout = Intf(Uint[10])[:2, 7, 8:]
assert iout.dtype == Uint[5]
@with_setup(clear)
@svgen_check(['sieve_0... | 21.047619 | 45 | 0.690045 | [
"MIT"
] | Risto97/pygears | tests/svgen/test_sieve.py | 442 | Python |
import socket
class UserException(Exception):
pass
def user_exception(s): raise UserException(s)
class Macro:
"""Represents a macro to be run"""
def __init__(self, code):
"""code: int - index of macro to run"""
self.code = code
class Command:
"""Represents a macro to be run"""
def __init__(self, ... | 34.230088 | 173 | 0.650724 | [
"MIT"
] | jackoson/homevision-netio-controller | homevision_netio_controller/controller.py | 7,736 | Python |
import os
import math
import sys
import torch
import numpy as np
from gym_collision_avoidance.envs.policies.InternalPolicy import InternalPolicy
from gym_collision_avoidance.envs import Config
from gym_collision_avoidance.envs.util import *
from gym_collision_avoidance.envs.policies import socialforce
import copy
i... | 44.193939 | 242 | 0.63124 | [
"MIT"
] | cmubig/Social-Navigation-Simulator | gym_collision_avoidance/envs/policies/SOCIALFORCEPolicy.py | 7,292 | Python |
import json
import asynctest
from asynctest import TestCase as AsyncTestCase
from asynctest import mock as async_mock
from aries_cloudagent.config.injection_context import InjectionContext
from aries_cloudagent.messaging.request_context import RequestContext
from .....admin.request_context import AdminRequestContext... | 43.385593 | 88 | 0.648078 | [
"Apache-2.0"
] | TimoGlastra/aries-cloudagent-python | aries_cloudagent/protocols/coordinate_mediation/v1_0/tests/test_routes.py | 30,717 | Python |
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class PyDataladWebapp(PythonPackage):
"""DataLad extension for exposing commands via a web reque... | 37.181818 | 93 | 0.709046 | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | Bambi/spack | var/spack/repos/builtin/packages/py-datalad-webapp/package.py | 818 | Python |
"""Simple quantum computations simulation."""
import numpy as np
def I():
"""Identity operator."""
return np.identity(2)
def X():
"""X-rotation, negation operator."""
return np.identity(2)[..., ::-1]
def H():
"""Adamara operator, superposition."""
return np.array([[1, 1], [1, -1]]) / np.sqrt(2)
def SW... | 17.966102 | 57 | 0.580189 | [
"MIT"
] | duboviy/misc | quantum.py | 1,060 | Python |
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
#
import json
import re
from typing import Union
from jsonschema import RefResolver
from pydantic import BaseModel, Field
from .streams import DEFAULT_START_DATE, ReportGranularity
class OauthCredSpec(BaseModel):
class Config:
title = "OAuth2.... | 36.328 | 126 | 0.68355 | [
"MIT"
] | 99designs/airbyte | airbyte-integrations/connectors/source-tiktok-marketing/source_tiktok_marketing/spec.py | 4,541 | Python |
from TASSELpy.java.lang.Number import Number, metaNumber
from TASSELpy.java.lang.Comparable import Comparable
from TASSELpy.utils.DocInherit import DocInherit
from TASSELpy.utils.Overloading import javaOverload,javaConstructorOverload
from TASSELpy.javaObj import javaObj
from TASSELpy.utils.helper import make_sig
from ... | 38.705628 | 80 | 0.581926 | [
"BSD-3-Clause"
] | er432/TASSELpy | TASSELpy/java/lang/Long.py | 8,941 | Python |
from __future__ import unicode_literals
import dataent
from dataent.model.rename_doc import rename_doc
def execute():
if dataent.db.table_exists("Email Alert Recipient") and not dataent.db.table_exists("Notification Recipient"):
rename_doc('DocType', 'Email Alert Recipient', 'Notification Recipient')
dataent.relo... | 44.461538 | 111 | 0.780277 | [
"MIT"
] | dataent/dataent | dataent/patches/v11_0/rename_email_alert_to_notification.py | 578 | Python |
"""
Django settings for profiles_project project.
Generated by 'django-admin startproject' using Django 3.2.9.
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/
"""
fro... | 25.870229 | 91 | 0.705223 | [
"MIT"
] | Mukul-agrawal/profiles-rest-api | profiles_project/settings.py | 3,389 | Python |
import os
import re
import struct
import glob
import numpy as np
import frame_utils
import skimage
import skimage.io
import torch
from torch.utils.data import Dataset
class KLens(Dataset):
#def __init__(self,raft_path="/data2/opticalflow/rnd/opticalflow/RAFT/out_klens_raft_chairs", root_path="/data2/opticalflow/... | 85.136364 | 788 | 0.695275 | [
"MIT"
] | klens-codes/MaskFlownet-Pytorch | data_loaders/KLens.py | 7,492 | Python |
# Telegram settings
TG_CLI = '/opt/tg/bin/telegram-cli'
TG_PUBKEY = '/opt/tg/tg-server.pub'
RECEPIENT = '@your-tg-recepient'
# Reddit App settings
REDDIT_APP_KEY = 'c...w'
REDDIT_APP_SECRET = 'T...c'
REDDIT_USER_AGENT = ('Damaris Bot, v0.1. Read only bot to read posts from'
'/r/cats')
# Sample Ca... | 21.277778 | 74 | 0.631854 | [
"MIT"
] | avinassh/damaris | sample_settings.py | 383 | Python |
import os
import pickle
import numpy as np
from tqdm import tqdm
from deeptutor.envs.DashEnv import *
from deeptutor.envs.EFCEnv import EFCEnv
from deeptutor.envs.HRLEnv import *
from deeptutor.infrastructure.utils import *
from deeptutor.tutors.LeitnerTutor import LeitnerTutor
from deeptutor.tutors.RandTutor import ... | 33.419643 | 94 | 0.583222 | [
"MIT"
] | ManavR123/cs_285_project | deeptutor/scripts/run.py | 3,743 | Python |
from raachem.file_class.gjf import *
from raachem.file_class.inp import *
from raachem.file_class.xyz import *
from raachem.file_class.log import *
from raachem.file_creator.e_analysis import *
from raachem.file_creator.input import *
from raachem.file_creator.xyz import *
from raachem.file_creator.deploy_script... | 33.727273 | 50 | 0.800539 | [
"MIT"
] | ricalmang/raachem | raachem/__init__.py | 371 | Python |
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class PyDecorator(PythonPackage):
"""The aim of the decorator module it to simplify the usage of... | 42.782609 | 95 | 0.748984 | [
"ECL-2.0",
"Apache-2.0",
"MIT"
] | CSCfi/spack | var/spack/repos/builtin/packages/py-decorator/package.py | 984 | Python |
"""Support for Aqualink pool lights."""
from iaqualink import AqualinkLightEffect
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_EFFECT,
DOMAIN,
SUPPORT_BRIGHTNESS,
SUPPORT_EFFECT,
LightEntity,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core im... | 28.22449 | 76 | 0.649313 | [
"Apache-2.0"
] | 0xFEEDC0DE64/homeassistant-core | homeassistant/components/iaqualink/light.py | 2,766 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from collections import defaultdict
import argparse
import cld2
import langid
import sys
""" Removes some wrongly aligned pairs from hunalign output """
class LanguageIdentifier(object):
def __init__(self, use_cld2, valid_languages=None):
self.use_cld2 = u... | 37.921875 | 78 | 0.563865 | [
"Apache-2.0"
] | christianbuck/CorpusMining | baseline/filter_hunalign_bitext.py | 4,854 | Python |
"""Define abstract base classes to construct FileFinder classes."""
import os
import shutil
from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from pathlib import Path
from typing import Optional, Sequence, Union
import mne_bids
@dataclass
class FileFinder(ABC):
"""Basic representation... | 33.439815 | 79 | 0.56417 | [
"MIT"
] | richardkoehler/pte | src/pte/filetools/filefinder_abc.py | 7,223 | Python |
__all__ = ("group_attempts", "fails_filter", "reduce_to_failures",)
def group_attempts(sequence, filter_func=None):
if filter_func is None:
filter_func = lambda x:True
last, l = None, []
for x in sequence:
if isinstance(x, tuple) and x[0] == 'inspecting':
if l:
... | 28.162791 | 67 | 0.521883 | [
"BSD-3-Clause"
] | CyberTailor/pkgcore | src/pkgcore/resolver/util.py | 1,211 | Python |
#!/usr/bin/python -u
# -*- coding: latin-1 -*-
#
# Dinner problem in Z3
#
# From http://www.sellsbrothers.com/spout/#The_Logic_of_Logic
# """
# My son came to me the other day and said, "Dad, I need help with a
# math problem." The problem went like this:
#
# * We're going out to dinner taking 1-6 grandparents, 1-10 p... | 27.981481 | 88 | 0.68233 | [
"MIT"
] | Wikunia/hakank | z3/dinner.py | 1,511 | Python |
# -----------------------------------------------------------------------------
# Libraries
# -----------------------------------------------------------------------------
# Core libs
from typing import TYPE_CHECKING
# Third party libs
from rest_framework.generics import ListCreateAPIView, RetrieveUpdateDestroyAPIView... | 33.357143 | 83 | 0.443969 | [
"MIT"
] | leonardon473/my-dinner-backend | src/apps/users/views/rest/client_address.py | 1,401 | Python |
import pyasdf
import numpy as np
import scipy.fftpack
import matplotlib.pyplot as plt
'''
this script takes a chunk of noise spectrum for a station pair and
compare their cross-correlation functions computed using two schemes:
one is averaging the frequency domain and the other is in the time
domain
'''
def cross... | 31.896552 | 87 | 0.670991 | [
"MIT"
] | Denolle-Lab/NoisePy | test/data_check/check_linearity_fft.py | 2,775 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 1999-2020 Alibaba Group Holding 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-... | 30.720588 | 79 | 0.674485 | [
"Apache-2.0"
] | JeffroMF/mars | mars/tensor/fft/irfft2.py | 2,089 | Python |
"""WebPush Style Autopush Router
This router handles notifications that should be dispatched to an Autopush
node, or stores each individual message, along with its data, in a Message
table for retrieval by the client.
"""
import json
import time
from StringIO import StringIO
from typing import Any # noqa
from botoc... | 40.898785 | 78 | 0.572362 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | Acidburn0zzz/autopush | autopush/router/webpush.py | 10,102 | Python |
import json
import os
import pandas
import redis
import types
def json2redis(data,r):
if isinstance(data, types.ListType):
for row in data:
channel = row['channel']
data_type = row['data_type']
rkey = 'channel_{}_{}'.format(channel,data_type)
r.lpush(rkey,ro... | 29.784314 | 72 | 0.574062 | [
"Apache-2.0"
] | pivotal-legacy/moves | train-app/helper_functions.py | 1,519 | Python |
#
# BSD 3-Clause License
#
# Copyright (c) 2019, Analog Devices, Inc.
# 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, ... | 34.963303 | 135 | 0.575571 | [
"BSD-3-Clause"
] | AkshayKurhade/aditof_sdk | tools/calibration-96tof1/tof_calib/regwrite_generator.py | 7,622 | Python |
#!usr/bin/env python
#-*- coding:utf-8 -*-
"""
@author: nico
@file: pipline.py
@time: 2018/05/05
"""
from django.contrib.auth import get_user_model
from bloguser.utils import get_image_from_url
from uuid import uuid4
User = get_user_model()
def save_bloguser_extra_profile(backend, user, resp... | 25.444444 | 97 | 0.628821 | [
"BSD-3-Clause"
] | Jennei/MyBlog | apps/bloguser/pipline.py | 1,245 | Python |
def extractMichilunWordpressCom(item):
'''
Parser for 'michilun.wordpress.com'
'''
bad = [
'Recommendations and Reviews',
]
if any([tmp in item['tags'] for tmp in bad]):
return None
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol) or "preview" in item['title... | 48.09375 | 145 | 0.499675 | [
"BSD-3-Clause"
] | fake-name/ReadableWebProxy | WebMirror/management/rss_parser_funcs/feed_parse_extractMichilunWordpressCom.py | 1,539 | Python |
import os
LUCKY_SEED = 42
TRAIN_FILE_COUNT = 43
VAL_FILE_COUNT = 12
ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
OBJECTS_DIR = os.path.join(ROOT_DIR, "objects")
OUTPUTS_DIR = os.path.join(ROOT_DIR, "outputs")
LOGS_DIR = os.path.join(ROOT_DIR, "logs")
DATA_DIR = os.path.join(ROOT_DIR, "data")
RAW_DATA_DIR =... | 34.297872 | 86 | 0.759926 | [
"MIT"
] | pk0912/TweetEmotionsPredictor | settings.py | 1,612 | Python |
def dif(x, y):
q = 0
for i in range(len(x)):
if x[i] != y[i]: q += 1
return q
e = str(input())
n = int(input())
v = []
for i in range(5): v.append(dif(e, str(input())))
if min(v) > n: print(-1)
else:
print(v.index(min(v))+1)
print(min(v))
| 17.866667 | 49 | 0.492537 | [
"MIT"
] | heltonr13/URI | 2017.py | 268 | Python |
workers = 1 # 定义同时开启的处理请求的进程数量,根据网站流量适当调整
worker_class = "gevent" # 采用gevent库,支持异步处理请求,提高吞吐量
# bind = "0.0.0.0:80"
bind = "0.0.0.0:80"
| 28 | 52 | 0.671429 | [
"MIT"
] | ShiZhuming/StyleTransfer | gunicorn.conf.py | 230 | Python |
n = int(input())
k = int(input())
total = n
for i in range(k):
total += int(str(n) + ('0' * (i+1)))
print(total) | 16.428571 | 38 | 0.530435 | [
"MIT"
] | osa-computer-society/competitive-programming | ccc/2017/ccc17j2.py | 115 | Python |
from toee import *
import char_class_utils
import char_editor
###################################################
def GetConditionName(): # used by API
return "Sorcerer"
# def GetSpellCasterConditionName():
# return "Sorcerer Spellcasting"
def GetCategory():
return "Core 3.5 Ed Classes"
def GetClassDefinitionFla... | 28.319635 | 149 | 0.688165 | [
"MIT"
] | Psionics-ToEE/TemplePlus | tpdatasrc/tpgamefiles/rules/char_class/class016_sorcerer.py | 6,202 | Python |
from pathlib import Path
from typing import Dict
import click
from hddcoin.util.config import load_config, save_config, str2bool
from hddcoin.util.default_root import DEFAULT_ROOT_PATH
def configure(
root_path: Path,
set_farmer_peer: str,
set_node_introducer: str,
set_fullnode_port: str,
set_log... | 40.895522 | 100 | 0.60292 | [
"Apache-2.0"
] | grayfallstown/hddcoin-blockchain | hddcoin/cmds/configure.py | 8,220 | Python |
# Third Party
import mxnet as mx
from mxnet.ndarray import NDArray
# First Party
from smdebug.core.collection import DEFAULT_MXNET_COLLECTIONS, CollectionKeys
from smdebug.core.hook import CallbackHook
from smdebug.core.json_config import DEFAULT_WORKER_NAME
from smdebug.core.utils import FRAMEWORK, error_handling_age... | 36.628253 | 106 | 0.653405 | [
"Apache-2.0"
] | arjkesh/sagemaker-debugger | smdebug/mxnet/hook.py | 9,853 | 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 ... | 55.656051 | 114 | 0.707027 | [
"MIT"
] | 16pierre/azure-sdk-for-python | sdk/graphrbac/azure-graphrbac/azure/graphrbac/models/application_update_parameters.py | 8,738 | Python |
def Coeff_Static_Friction(Mat_on_Mat):
# Read from CSV
pass
def Coeff_Kinetic_Friction(Mat_on_Mat):
pass | 14.875 | 39 | 0.739496 | [
"MIT"
] | ZenosParadox/grtoolkit | grtoolkit/Mechanics/Friction/__init__.py | 119 | Python |
## Creates 404 page
import pystache
import utils
def main(data):
html = pystache.render(data["templates"]["page"], {
"title": "Page not found",
"description": "Error 404: page not found",
## Since we don't know the depth of this page relative to the root,
## we have to assum... | 40.851852 | 98 | 0.614687 | [
"BSD-3-Clause"
] | Lyrics/lyrics-website | website-generator.d/80-not-found-page.py | 1,103 | Python |
from kafka import KafkaProducer
from json import dumps as json_dumps, load as json_load
import time
class ProducerServer(KafkaProducer):
def __init__(self, input_file, topic, **kwargs):
super().__init__(**kwargs)
self.input_file = input_file
self.topic = topic
def generate_data(self)... | 29.428571 | 55 | 0.645631 | [
"MIT"
] | estarguars113/udacity-spark-project | producer_server.py | 618 | Python |
import os
from subprocess import check_output
import plumbum
from plumbum.cmd import grep, fpm, ln, sort, find, virtualenv
import logging
log = logging.getLogger()
logging.basicConfig(level=logging.INFO)
ENV_PATH = os.getenv("ENV_PATH", "/usr/share/python3/pypi-server")
SRC_PATH = os.getenv("SRC_PATH", "/mnt")
pip =... | 29.380952 | 93 | 0.605619 | [
"MIT"
] | SrtKoolice/pypi-server | package/make-deb.py | 1,851 | Python |
# Copyright (c) 2010-2020 openpyxlzip
# package imports
from openpyxlzip.reader.excel import load_workbook
from openpyxlzip.xml.functions import tostring, fromstring
from openpyxlzip.styles import Border, Side, PatternFill, Color, Font, fills, borders, colors
from openpyxlzip.styles.differential import DifferentialSty... | 35.221675 | 93 | 0.554685 | [
"MIT"
] | ankitJoshi03/openpyxlzip | openpyxlzip/formatting/tests/test_formatting.py | 7,150 | Python |
class PNChannelGroupsAddChannelResult(object):
pass
class PNChannelGroupsRemoveChannelResult(object):
pass
class PNChannelGroupsRemoveGroupResult(object):
pass
class PNChannelGroupsListResult(object):
def __init__(self, channels):
self.channels = channels
| 17.875 | 49 | 0.772727 | [
"MIT"
] | 17media/pubnub-python | pubnub/models/consumer/channel_group.py | 286 | Python |
import json
from time import sleep
from uuid import uuid4
from datetime import datetime
import logging
from kafka import KafkaProducer, KafkaConsumer
from settings import (
KAFKA_BOOTSTRAP_SERVER,
KAFKA_VALUE_ENCODING,
KAFKA_INBOUND_TOPIC,
KAFKA_SUCCESS_OUTBOUND_TOPIC,
KAFKA_ERROR_OUTBOUND_TOPIC,
... | 34.317708 | 100 | 0.700562 | [
"MIT"
] | gabrielbazan/sate | processor/processor/requests_processor.py | 6,589 | 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, overload
from .. import _utilities
from... | 45.819843 | 558 | 0.690182 | [
"Apache-2.0"
] | polivbr/pulumi-azure-native | sdk/python/pulumi_azure_native/compute/get_virtual_machine_scale_set.py | 17,549 | Python |
print ("welcome to edureka!! ")
| 16 | 31 | 0.65625 | [
"MIT"
] | jatin06/learning-git | edureka.py | 32 | Python |
import pandas as pd
from pandas.testing import assert_frame_equal
import pytest
from unittest import mock
from nesta.packages.geo_utils.geocode import geocode
from nesta.packages.geo_utils.geocode import _geocode
from nesta.packages.geo_utils.geocode import geocode_dataframe
from nesta.packages.geo_utils.geocode impor... | 48.195122 | 107 | 0.565494 | [
"MIT"
] | anniyanvr/nesta | nesta/packages/geo_utils/tests/test_geotools.py | 23,712 | Python |
from django.db import transaction
from rest_framework.serializers import ModelSerializer
from galaxy_api.api import models
class NamespaceLinkSerializer(ModelSerializer):
class Meta:
model = models.NamespaceLink
fields = ('name', 'url')
class NamespaceSerializer(ModelSerializer):
links = N... | 26.166667 | 83 | 0.677707 | [
"Apache-2.0"
] | newswangerd/galaxy-api | galaxy_api/api/v3/serializers/namespace.py | 785 | Python |
"""
This module is for testing the distributions. Tests should focus on ensuring we can
expand distributions without missing emails or getting too many or running into infinite
loops.
"""
from django.test import TestCase
from ..models import EmailAddress, Distribution
class DistributionTestCase(TestCase):
def s... | 42.036585 | 88 | 0.707572 | [
"MIT"
] | gregschmit/django-impression | impression/tests/test_distribution.py | 3,447 | Python |
from marshmallow import Schema, fields
from marshmallow.validate import OneOf
ticket_type = ("Bug", "Report", "Feature", "Request", "Other")
ticket_urgency = ("Low", "Mid", "High")
ticket_status = ("Open", "In Progress", "Completed", "Rejected")
class Ticket(Schema):
id = fields.Int(dump_only=True)
created_at... | 33.967742 | 71 | 0.705603 | [
"Apache-2.0"
] | barrachri/ticketbyrd | ticketbyrd/schema.py | 1,053 | Python |
from conans import ConanFile, CMake
import os
class TinyreflTool(ConanFile):
name = 'tinyrefl-tool'
version = '0.4.1'
url = 'https://github.com/Manu343726/tinyrefl'
description = ' A work in progress minimal C++ static reflection API and codegen tool'
scm = {
'type': 'git',
'url': 'http... | 31.728814 | 90 | 0.563568 | [
"MIT"
] | Bjoe/tinyrefl | tool/conanfile.py | 1,872 | Python |
import bpy
from bpy import context
from . import node_functions
from . import material_functions
from . import constants
import mathutils
def update_selected_image(self, context):
sel_texture = bpy.data.images[self.texture_index]
show_image_in_image_editor(sel_texture)
def show_image_in_image_editor(image):... | 38.481283 | 116 | 0.618677 | [
"MIT"
] | LorenzWieseke/GLBTextureTools | Functions/visibility_functions.py | 7,196 | Python |
#!/usr/bin/env python
import sys
import re
def setup_python3():
# Taken from "distribute" setup.py
from distutils.filelist import FileList
from distutils import dir_util, file_util, util, log
from os.path import join
tmp_src = join("build", "src")
log.set_verbosity(1)
fl = FileList()
... | 30.8 | 82 | 0.570745 | [
"BSD-3-Clause"
] | DalavanCloud/PyRDFa | setup.py | 2,926 | Python |
import click
from typer.testing import CliRunner
import pytest
import os
from pathlib import Path
from ..main import install
from pytest_httpx import HTTPXMock
runner = CliRunner()
def get_test_resource(name: str) -> Path:
return Path(os.path.join(os.path.dirname(__file__), "testresources", name))
def test_ins... | 25.659574 | 79 | 0.619403 | [
"MIT"
] | razzo04/rhasspy-skills-cli | rhasspy_skills_cli/tests/test_app.py | 1,206 | Python |
import datetime
import urllib
from django.conf import settings
from django.contrib.auth.models import User
from django.urls import reverse
from django.utils.translation import ugettext as _
from rest_flex_fields import FlexFieldsModelSerializer
from rest_flex_fields.serializers import FlexFieldsSerializerMixin
from re... | 28.180711 | 89 | 0.595468 | [
"MIT"
] | Dithn/readthedocs.org | readthedocs/api/v3/serializers.py | 27,758 | Python |
# Copyright 2021 Edoardo Riggio
#
# 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 writin... | 24.533333 | 74 | 0.629529 | [
"Apache-2.0"
] | edoriggio/algorithms-and-data-structures | exercises/search_in_sorted_matrix.py | 1,104 | Python |
"""Bokeh ELPDPlot."""
import warnings
import bokeh.plotting as bkp
from bokeh.models.annotations import Title
from bokeh.models import ColumnDataSource
import bokeh.models.markers as mk
import numpy as np
from . import backend_kwarg_defaults
from .. import show_layout
from ...plot_utils import _scale_fig_size
from ..... | 31.857923 | 100 | 0.521269 | [
"Apache-2.0"
] | Brahanyaa98/arviz | arviz/plots/backends/bokeh/elpdplot.py | 5,830 | Python |
# ============================================================================
# FILE: default.py
# AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
# License: MIT license
# ============================================================================
import re
import typing
from denite.util import echo, error, c... | 38.211329 | 79 | 0.54852 | [
"MIT"
] | supermomonga/denite.nvim | rplugin/python3/denite/ui/default.py | 35,078 | Python |
"""
"""
from __future__ import division
from torch.optim.optimizer import Optimizer, required
import numpy as np
import torch
from typing import NamedTuple, List
from dataclasses import dataclass
from enum import Enum
from typing import Union, Tuple
# from scipy.sparse.linalg import svds
from scipy.optimize import mi... | 36.314346 | 111 | 0.521815 | [
"Apache-2.0"
] | MathieuTuli/transformers | src/transformers/adas.py | 17,213 | Python |
"""Unit tests for tftpy."""
import unittest
import logging
import tftpy
import os
import time
import threading
from errno import EINTR
from multiprocessing import Queue
log = tftpy.log
class TestTftpyClasses(unittest.TestCase):
def setUp(self):
tftpy.setLogLevel(logging.DEBUG)
def testTftpPacketRRQ... | 37.277445 | 93 | 0.557775 | [
"MIT"
] | mapcollab/python-tftpy | t/test.py | 18,676 | Python |
r"""
Early Stopping
^^^^^^^^^^^^^^
Monitor a validation metric and stop training when it stops improving.
"""
from copy import deepcopy
import numpy as np
import torch
import torch.distributed as dist
from pytorch_lightning import _logger as log
from pytorch_lightning.callbacks.base import Callback
from pytorch_lig... | 37.442308 | 116 | 0.635336 | [
"Apache-2.0"
] | DavianYang/pytorch-lightning | pytorch_lightning/callbacks/early_stopping.py | 7,788 | Python |
# -*- coding: utf-8 -*-
# Copyright 2020 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 41.169118 | 90 | 0.621361 | [
"Apache-2.0"
] | batardo/google-ads-python | google/ads/googleads/v4/services/services/ad_group_service/transports/grpc.py | 11,198 | Python |
# AUTOGENERATED! DO NOT EDIT! File to edit: nbs/72_callback.neptune.ipynb (unless otherwise specified).
__all__ = ['NeptuneCallback']
# Cell
import tempfile
from ..basics import *
from ..learner import Callback
# Cell
import neptune
# Cell
class NeptuneCallback(Callback):
"Log losses, metrics, model weights, mo... | 46.75641 | 126 | 0.639155 | [
"Apache-2.0"
] | Aky87/fastai | fastai/callback/neptune.py | 3,647 | Python |
'''
Module:
Set regular or irregular axis ticks for a plot.
'''
from module_utility import *
import numpy as np
import matplotlib.pyplot as plt
# ticks : contains irregular ticks locations
# tickbeg : regular major ticks begin location
# tickend : regular major ticks end location
# tickd : regular major ti... | 37.475177 | 108 | 0.568793 | [
"BSD-3-Clause"
] | lanl/pymplot | src/module_tick.py | 10,568 | Python |
#!/usr/bin/env python
#
# Copyright (C) 2009 Google Inc.
#
# Licensed under the Apache License 2.0;
# This module is used for version 2 of the Google Data APIs.
"""Provides classes and constants for the XML in the Google Spreadsheets API.
Documentation for the raw XML which these classes represent can be found he... | 31.162162 | 82 | 0.674761 | [
"Apache-2.0"
] | BinaryMuse/gdata-python3 | src/gdata/spreadsheets/data.py | 11,530 | Python |
import numpy as np
import pandas as pd
from openpyxl import load_workbook
import sys
def print_array_to_excel(array, first_cell, ws, axis=2):
'''
Print an np array to excel using openpyxl
:param array: np array
:param first_cell: first cell to start dumping values in
:param ws: worksheet reference.... | 38.189189 | 96 | 0.610757 | [
"MIT"
] | acceleratedmaterials/NUS_AMDworkshop | gold nanocluster synthesis/own_package/others.py | 1,413 | Python |
# -*- coding: utf-8 -*-
# URL : https://leetcode-cn.com/problems/median-of-two-sorted-arrays/
""""""
"""
problem:
给定两个大小为 m 和 n 的有序数组 nums1 和 nums2。
请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为 O(log(m + n))。
你可以假设 nums1 和 nums2 不会同时为空。
示例 1:
nums1 = [1, 3]
nums2 = [2]
则中位数是 2.0
示例 2:
nums1 = [1, 2]
nums2 = [3, 4]
则中位数是 (2 +... | 30.450382 | 91 | 0.57107 | [
"Apache-2.0"
] | Buddy119/algorithm | Codes/xiaohong2019/leetcode/4_median_of_two_sorted_arrays.py | 5,630 | Python |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-07-27 14:08
from __future__ import unicode_literals
from django.db import migrations
import wagtail.core.fields
class Migration(migrations.Migration):
dependencies = [
('home', '0011_auto_20170727_1324'),
]
operations = [
migr... | 24.62963 | 64 | 0.618045 | [
"BSD-3-Clause"
] | evonove/evonove | django-website/home/migrations/0012_auto_20170727_1408.py | 665 | Python |
from __future__ import annotations
import re
from abc import abstractmethod, ABC
from enum import Enum
from typing import List, Optional, Literal, Tuple, Union
from ulauncher.api.client.Extension import Extension
from ulauncher.api.client.EventListener import EventListener
import ulauncher.api.shared.event as events
f... | 28.188312 | 91 | 0.619443 | [
"Apache-2.0"
] | Troublor/ulauncher-numconverter | main.py | 4,341 | Python |
from diogi.functions import *
from diogi.conventions import to_data
from .docs import WithDocsMixin
def noop_resolver(href: str) -> dict:
pass
class Descriptor:
@staticmethod
def parse(obj: any, resolver: callable):
if dict == type(obj):
href = get_if_exists(obj, "href", None)
... | 27.453901 | 85 | 0.587703 | [
"MIT"
] | michalporeba/alps-py | alps/descriptors.py | 3,871 | Python |
import disnake
from disnake.ext import commands
# Define a simple View that persists between bot restarts
# In order a view to persist between restarts it needs to meet the following conditions:
# 1) The timeout of the View has to be set to None
# 2) Every item in the View has to have a custom_id set
# It is recommen... | 42.397059 | 105 | 0.712105 | [
"MIT"
] | Chromosomologist/disnake | examples/views/persistent.py | 2,883 | Python |
import glob
from itertools import chain
from os import path
import numpy as np
import torch.utils.data as data
import umsgpack
from PIL import Image
class ISSDataset(data.Dataset):
"""Instance segmentation dataset
This assumes the dataset to be formatted as defined in:
https://github.com/mapillary/s... | 33.140845 | 120 | 0.593285 | [
"BSD-3-Clause"
] | 030Solutions/seamseg | seamseg/data/dataset.py | 7,059 | 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 ... | 45.307692 | 129 | 0.681834 | [
"MIT"
] | BillmanH/azure-sdk-for-python | sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py | 2,945 | Python |
# -*- test-case-name: vumi.transports.xmpp.tests.test_xmpp -*-
# -*- encoding: utf-8 -*-
from twisted.python import log
from twisted.words.protocols.jabber.jid import JID
from twisted.words.xish import domish
from twisted.words.xish.domish import Element as DomishElement
from twisted.internet.task import LoopingCall
f... | 36.474178 | 79 | 0.671644 | [
"BSD-3-Clause"
] | rapidsms/vumi | vumi/transports/xmpp/xmpp.py | 7,769 | Python |
from fake_useragent import UserAgent
import requests
from jsonpath import jsonpath
url = "https://www.lagou.com/lbs/getAllCitySearchLabels.json"
headers = {"User-Agent": UserAgent().chrome}
resp = requests.get(url, headers=headers)
ids = jsonpath(resp.json(), "$..id")
names = jsonpath(resp.json(), "$..name")
for i... | 23.3125 | 61 | 0.705094 | [
"MIT"
] | littleturings/2021PythonWebCrawler | Lecture_notes/数据提取与验证码的识别(上)/code/jsonpath_test.py | 373 | Python |
# /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Modul is used for GUI of Lisa
"""
from loguru import logger
import sys
import click
from pathlib import Path
import ast
from . import app_tools
# print("start")
# from . import image
# print("start 5")
# print("start 6")
# from scaffan import algorithm
from . impo... | 28.634483 | 110 | 0.678227 | [
"MIT"
] | mjirik/animalwatch | anwa/main_click.py | 4,152 | Python |
'''
Autor: Gurkirt Singh
Start data: 2nd May 2016
purpose: of this file is to take all .mp4 videos and convert them to jpg images
'''
import numpy as np
import cv2 as cv2
import math,pickle,shutil,os
baseDir = "/mnt/sun-alpha/actnet/";
vidDir = "/mnt/earth-beta/actnet/videos/";
imgDir = "/mnt/sun-alpha/actnet/rgb-i... | 42.851211 | 120 | 0.505087 | [
"MIT"
] | gurkirt/actNet-inAct | python-scripts/convertMP4toJPG.py | 12,384 | Python |
# Copyright 2017 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... | 31.361991 | 80 | 0.68273 | [
"Apache-2.0"
] | GueroudjiAmal/tensorflow | tensorflow/python/autograph/impl/conversion_test.py | 6,931 | Python |
from distutils.core import setup
setup(name='bidict',
version='0.1',
description='A bi-directional dictionary API',
author='Jordan Epstein',
author_email='jorepstein1@gmail.com',
url='https://github.com/jorepstein1/bidict',
packages=['bidict'],
) | 28.8 | 52 | 0.652778 | [
"MIT"
] | jorepstein1/bidict | setup.py | 288 | Python |
# Copyright 2016-2021 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
# ReFrame Project Developers. See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Meta-class for creating regression tests.
#
import functools
import types
import reframe.core.namespaces as namespaces
i... | 39.432479 | 79 | 0.588304 | [
"BSD-3-Clause"
] | ChristopherBignamini/reframe | reframe/core/meta.py | 23,068 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.