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/python3
# -*- coding: utf-8 -*-
import copy
import json
import requests
import pytz
import time
from inky.inky_uc8159 import Inky, DESATURATED_PALETTE
from datetime import datetime
from PIL import Image, ImageFont, ImageDraw
import io
import apikey
import os
import signal
import RPi.GPIO as GPIO
path = os.p... | 28.917808 | 110 | 0.573283 | [
"MIT"
] | vwillcox/Inky-Impression-Weather-Station | weather.py | 10,557 | Python |
"""
This module contains the cli functions.
Split them out into separate files if required.
"""
import sys
import os
import subprocess
import pickle
from cheapskate_bal import balance as bal
__collector__ = {'exe': "collect_3008", 'samp_rate': 2000}
def csbal_process():
"""
This method is run when the `csba... | 28.951807 | 98 | 0.620266 | [
"Unlicense"
] | kevinpowell/balancer | cheapskate_bal/cheapskate_bal/cli.py | 4,806 | Python |
from __future__ import absolute_import
import os
# test_settings.py works differently from
# dev_settings.py/prod_settings.py; it actually is directly referenced
# by the test suite as DJANGO_SETTINGS_MODULE and imports settings.py
# directly and then hacks up the values that are different for the
# test suite. As wil... | 34.213793 | 88 | 0.738359 | [
"Apache-2.0"
] | JaneCeng/zulip | zproject/test_settings.py | 4,961 | Python |
import json
import os
import signal
import sys
from zipfile import BadZipfile
from zlib import error as zlib_error
from defusedxml.common import DefusedXmlException
import validator
from validator import decorator
from validator.chromemanifest import ChromeManifest
from validator.opensearch import detect_opensearch
f... | 40.057292 | 79 | 0.575803 | [
"BSD-3-Clause"
] | kumar303/amo-validator | validator/submain.py | 15,382 | Python |
from flask import Flask, request, redirect, render_template, url_for, flash, jsonify
import gridfs, random, uuid, os
from flask_uploads import UploadSet, configure_uploads, IMAGES
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import desc
from datetime import datetime
app = Flask(__name__,
static_... | 33.216667 | 139 | 0.62845 | [
"MIT"
] | iSkytran/supplymedia | app.py | 3,986 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Script to parse BSM event auditing files."""
import argparse
import logging
import sys
from dtformats import bsm
from dtformats import output_writers
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argumen... | 21.830986 | 77 | 0.683226 | [
"Apache-2.0"
] | jleaniz/dtformats | scripts/bsm.py | 1,550 | Python |
#!/usr/bin/env python
# -*- coding: utf8 -*-
# *****************************************************************
# ** PTS -- Python Toolkit for working with SKIRT **
# ** © Astronomical Observatory, Ghent University **
# *****************************************************************
##... | 27.632184 | 111 | 0.56926 | [
"MIT"
] | Stargrazer82301/CAAPR | CAAPR/CAAPR_AstroMagic/PTS/pts/magic/tools/masks.py | 4,809 | Python |
import sys, math
import numpy as np
import Box2D
from Box2D.b2 import (edgeShape, circleShape, fixtureDef, polygonShape, revoluteJointDef, contactListener)
import gym
from gym import spaces
from gym.utils import colorize, seeding
# This is simple 4-joints walker robot environment.
#
# There are two versions:
#
# - N... | 39.637457 | 155 | 0.542243 | [
"MIT"
] | hbutsuak95/iv_rl | mbbl_envs/env/gym_env/box2d/walker.py | 23,069 | Python |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compli... | 39.509474 | 79 | 0.577929 | [
"Apache-2.0"
] | CiscoSystems/cinder-old | cinder/volume/api.py | 18,767 | Python |
import logging
from redlib.api.misc import Logger
log = Logger(name='jekt')
log.start('stdout', logging.DEBUG)
| 14.25 | 34 | 0.745614 | [
"MIT"
] | amol9/jekt | jekt/logger.py | 114 | Python |
"""
See notebook 5 for example use of show_mri_sample()
"""
import glob
import os
import random
import numpy as np
import pandas as pd
import torch
from torch.utils.data import Dataset
import matplotlib.pyplot as plt
import cv2
import scipy.ndimage as ndimage
def make_bg_transparent(im, bg_th=0.0, set_to_color=None):... | 43.21256 | 128 | 0.585802 | [
"MIT"
] | jpjuvo/RSNA-MICCAI-Brain-Tumor-Classification | src/seg_model_utils/visualization.py | 8,945 | Python |
import glob
import pandas as pd
import os
import datetime
class DataMerge:
def __init__(self, directory):
self.directory = directory
self.__data = self.get_data_from(self.directory)
def date_to_int(self, dates):
"""
calculates number of days between 01/01/0001 and each date in... | 30.1875 | 78 | 0.562457 | [
"MIT"
] | repeating/stock-analyzer | backend/data_merge.py | 1,449 | Python |
import jax.numpy as np
import matplotlib.pyplot as plt
def plot(vi, X,
target='vanishing',
n=1000, scale=1.5, x_max=1.0, y_max=1.0,
z_func=lambda x_, y_: 0.0,
show=False, splitshow=False):
nvars = X.shape[-1]
if nvars == 2:
_plot2d(vi, X, target=target,
n=n, scale=s... | 35.877358 | 127 | 0.576913 | [
"MIT"
] | HiroshiKERA/monomial-agnostic-vanishing-ideal | mavi/jax/util/plot.py | 3,803 | Python |
"""Code generation utilities"""
from .utils import SchemaInfo, is_valid_identifier, indent_docstring, indent_arglist
import textwrap
import re
class CodeSnippet(object):
"""Object whose repr() is a string of code"""
def __init__(self, code):
self.code = code
def __repr__(self):
return se... | 38.343915 | 123 | 0.611425 | [
"BSD-3-Clause"
] | aladdingsw/altair | tools/schemapi/codegen.py | 7,247 | 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, ... | 34.233333 | 80 | 0.709348 | [
"ECL-2.0",
"Apache-2.0"
] | Circletana/jax | jax/lib/__init__.py | 2,054 | Python |
# -*- coding: utf-8 -*-
"""
@author:XuMing(xuming624@qq.com)
@description:
"""
import sys
sys.path.append('..')
from nlpcommon import stopwords
if __name__ == '__main__':
print(len(stopwords), stopwords)
| 16.230769 | 36 | 0.668246 | [
"Apache-2.0"
] | shibing624/nlpcommon | examples/base_demo.py | 211 | Python |
import wmi
import speedtest_cli
import threading
import signal
import os
import json
def testSpeed(urls):
speedtest_cli.shutdown_event = threading.Event()
signal.signal(signal.SIGINT, speedtest_cli.ctrl_c)
print "Start to test download speed: "
dlspeed = speedtest_cli.downloadSpeed(urls)
dlspeed =... | 30.868687 | 338 | 0.66394 | [
"Apache-2.0"
] | yushulx/switch-windows-gateway | network.py | 3,056 | Python |
import pymysql.cursors
from model.group import Group
from model.contact import Contact
class DbFixture:
def __init__(self,host,name,user,password):
self.host=host
self.name=name
self.user=user
self.password=password
self.connection=pymysql.connect(host=host ,database=name,... | 35.160714 | 190 | 0.639411 | [
"Apache-2.0"
] | AnastasiiaAndronova/python_training | fixture/db.py | 1,969 | Python |
from __future__ import absolute_import
import os
import json
import redis
ENV = os.getenv('ENV', 'local')
if ENV == 'docker':
rdb = redis.Redis(db=0, host='redis')
else:
rdb = redis.Redis(db=11)
def emit(typ, **kwargs):
kwargs['type'] = typ
rdb.publish('actions', json.dumps(kwargs))
| 16.105263 | 46 | 0.656863 | [
"MIT"
] | Craftzman7/rowboat | rowboat/redis.py | 306 | Python |
#!/usr/bin/env python
"""
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicabl... | 39.152941 | 200 | 0.671575 | [
"Apache-2.0"
] | alexFilin/keras-maskrcnn | keras_maskrcnn/bin/debug.py | 6,656 | Python |
"""
DataMeta
DataMeta # noqa: E501
The version of the OpenAPI document: 1.4.0
Contact: leon.kuchenbecker@uni-tuebingen.de
Generated by: https://openapi-generator.tech
"""
import re # noqa: F401
import sys # noqa: F401
from datameta_client_lib.model_utils import ( # noqa: F401
ApiTypeErr... | 38.321637 | 110 | 0.584923 | [
"Apache-2.0"
] | ghga-de/datameta-client-lib | datameta_client_lib/model/staged_meta_data_sets.py | 6,553 | Python |
__author__ = 'anushabala'
import sys
sys.path.append('/usr1/home/rjoshi2/negotiation_personality/src/negotiation/bot/cocoa/src/basic/sessions')
| 36 | 106 | 0.819444 | [
"Apache-2.0"
] | kingabzpro/DialoGraph_ICLR21 | src/bot/cocoa/src/basic/sessions/__init__.py | 144 | Python |
from pandac.PandaModules import *
from toontown.toonbase.ToonBaseGlobal import *
from direct.interval.IntervalGlobal import *
from direct.task import Task
from direct.directnotify import DirectNotifyGlobal
from math import *
from direct.distributed.ClockDelta import *
from toontown.golf import GolfGlobals
from toontown... | 49.384328 | 225 | 0.583377 | [
"Apache-2.0"
] | AnythingTechPro/Project-Altis | toontown/golf/GolfRewardDialog.py | 13,235 | Python |
# Copyright 2016 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... | 34.059621 | 125 | 0.643539 | [
"Apache-2.0"
] | enrewen1/tf | tensorflow/contrib/distributions/python/ops/gamma.py | 12,568 | Python |
if _use_time:
_end_time = datetime.utcnow().timestamp()
res.update({'_gatewayTime': {'start': _start_time, 'end': _end_time, 'duration': _end_time-_start_time}}) | 56.333333 | 109 | 0.710059 | [
"Apache-2.0"
] | AlexRogalskiy/bumblebee | packages/api/resources/python-templates/time-end.py | 169 | Python |
from django.conf.urls import url
from .views import (
TableListAPIView,
SalePointTableListAPIView
)
urlpatterns = [
url(r'^$', TableListAPIView.as_view(),
name='api-table-list'),
url(r'^sale-point/(?P<pk>[0-9]+)$',
SalePointTableListAPIView.as_view(),
name='api-sale_point-... | 19.529412 | 44 | 0.629518 | [
"BSD-3-Clause"
] | glosoftgroup/restaurant | saleor/api/table/urls.py | 332 | Python |
from recipe_scrapers.purelypope import PurelyPope
from tests import ScraperTest
class TestPurelyPopeScraper(ScraperTest):
scraper_class = PurelyPope
def test_host(self):
self.assertEqual("purelypope.com", self.harvester_class.host())
def test_canonical_url(self):
self.assertEqual(
... | 37.5625 | 384 | 0.642263 | [
"MIT"
] | AlexRogalskiy/recipe-scrapers | tests/test_purelypope.py | 1,803 | Python |
from types import SimpleNamespace
fields = SimpleNamespace(
id='id',
name='name',
data_query='data_query')
analysis_properties = {
fields.name: {
'description': 'Name of analysis.',
'type': 'string',
},
fields.data_query: {
'description': 'Lucene query string used to re... | 21.540541 | 71 | 0.548306 | [
"MIT"
] | cvisionai/tator | main/schema/components/analysis.py | 797 | Python |
import logging
import sys
from abc import ABC, abstractmethod
logger = logging.getLogger(__name__)
class PaddownException(Exception):
pass
class Paddown(ABC):
@abstractmethod
def has_valid_padding(self, ciphertext: bytes) -> bool:
"""
Override this method and send off the ciphertext to ... | 38.673913 | 108 | 0.632378 | [
"MIT"
] | MarvinKweyu/PadDown | paddown.py | 3,558 | Python |
from functools import wraps
def multiply_by(multiplier):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
func_name = func.__name__
print(f'Calling "{func_name}({args[0]}, {args[1]})" function')
print(f'"{func_name}" function is multiplied by {mul... | 24.083333 | 74 | 0.588235 | [
"Apache-2.0"
] | vyahello/python-decorators-cheetsheet | materials/decorator_with_args.py | 578 | Python |
"""
WSGI config for CongressionalRecord project.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_AP... | 44.181818 | 79 | 0.807956 | [
"Apache-2.0"
] | kdunn926/eunomia-django | CongressionalRecord/wsgi.py | 1,458 | Python |
"""Basic pyon logging (with or without container)
NOTE: the functionality of this module has moved to ooi.logging.config.
currently this module is maintained for API compatability, but is implemented using the new package.
"""
import logging
from ooi.logging import config
DEFAULT_LOGGING_PATHS = ['res/co... | 37.487805 | 109 | 0.725439 | [
"BSD-2-Clause"
] | ooici/pyon | pyon/core/log.py | 1,537 | Python |
option='y'
while option=='y':
def fibo(n):
a=0
b=1
for i in range(0,n):
temp=a
a=b
b=temp+b
return a
print("Enter the limit of fibonacci series")
num=int(input())
for c in range(0,num):
print (fibo(c))
prin... | 21.05 | 49 | 0.489311 | [
"MIT"
] | DheerajKN/Python-with-pygame | Fibonacci_Iteration.py | 421 | Python |
"""Python wrappers around TensorFlow ops.
This file is MACHINE GENERATED! Do not edit.
Original C++ source file: boosted_trees_ops.cc
"""
import collections as _collections
import six as _six
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
from tensorflow.python.eager import context as _context... | 42.777778 | 3,324 | 0.716153 | [
"MIT"
] | Con-Mi/lambda-packs | Keras_tensorflow_nightly/source2.7/tensorflow/python/ops/gen_boosted_trees_ops.py | 58,905 | Python |
#!/usr/bin/env python
"""JIP module that handles job profiles.
A job profile contains all compute-cluster and execution related meta-data of a
job, such as the number of threads reserved for the job or the time limit.
Profiles can be named and stored in the user configuration.
In addition, hierarchical updates of pro... | 37.154088 | 97 | 0.596445 | [
"BSD-3-Clause"
] | VDBWRAIR/pyjip | jip/profiles.py | 23,630 | Python |
#!/usr/bin/env python
# Copyright 2016 Intel
#
# 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 ... | 31.987805 | 78 | 0.65345 | [
"Apache-2.0"
] | abdullahzamanbabar/syntribos | scripts/readme.py | 2,623 | Python |
# -*- coding: utf-8 -*-
"""
Benchmark Results
Updated: 18.02.2022 (6618fa3c36b0c9f3a9d7a21bcdb00bf4fd258ee8))
------------------------------------------------------------------------------------------
| Model | Batch Size | Epochs | KNN Test Accuracy | Time | Peak GPU Usage |
--------------------------... | 36.265252 | 122 | 0.602289 | [
"MIT"
] | dczifra/lightly | docs/source/getting_started/benchmarks/cifar10_benchmark.py | 27,350 | Python |
from core.models import Item, Listing, PromoCode, Address, UserProfile
from core.zipcode import zipcodes
from datetime import datetime, timedelta
from decimal import *
from django import forms
from django.core.files.base import ContentFile
from django.core.files.images import get_image_dimensions
from io impor... | 38.442478 | 118 | 0.626727 | [
"MIT"
] | gnarizzy/circa | circa/core/forms.py | 8,688 | Python |
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from parlai.core.teachers import FbDeprecatedDialogTeacher
from .build import build
from parlai.utils.data impor... | 28.716814 | 81 | 0.522342 | [
"Apache-2.0"
] | GuillaumeLeclerc/cortx | doc/integrations/pytorch/parlai/tasks/cornell_movie/agents.py | 3,245 | Python |
a = int(input())
b = int(input())
c = int(input())
p = 0
s = 0
p = ( a + b + c ) / 2
s = ( p * ( p - a ) * ( p - b ) * ( p - c ) ) ** 0.5
print( s ); | 16 | 53 | 0.325 | [
"MIT"
] | Cet500/PyLib | PyCourse/test_1-12-1.py | 160 | 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 nose.tools import eq_, assert_raises
from socorrolib.lib import MissingArgumentError
from socorro.external.postgre... | 26.634146 | 69 | 0.547161 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | Acidburn0zzz/socorro | socorro/unittest/external/postgresql/test_field.py | 2,184 | Python |
import mock
import unittest
from symstore import command_line
class TestMain(unittest.TestCase):
"""
test main()
"""
Z_ARGV = ["prog", "-z", "store_path", "file"]
@mock.patch("symstore.cab.compression_supported", False)
@mock.patch("sys.stderr")
def test_compression_not_supported(self, s... | 26.47619 | 69 | 0.67446 | [
"MIT"
] | 2js855/symstore | tests/unit/test_command_line.py | 556 | Python |
from .products import Products | 30 | 30 | 0.866667 | [
"MIT"
] | GG31/openfood-graphql-api | src/products/__init__.py | 30 | Python |
'''
Custom interpolation methods for representing approximations to functions.
It also includes wrapper classes to enforce standard methods across classes.
Each interpolation class must have a distance() method that compares itself to
another instance; this is used in HARK.core's solve() method to check for solution
co... | 42.357162 | 173 | 0.561754 | [
"Apache-2.0"
] | cohenimhuji/HARK | HARK/interpolation.py | 159,390 | Python |
from django import forms
from .models import Reclamacao,Login,Comentario
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
class CadastraReclamacaoForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(CadastraReclamacaoForm,self).__init__(*args,... | 33.040816 | 97 | 0.657196 | [
"MIT"
] | WesleyVitor/ReclamaCaico | Application/ReclamaCaicoProject/ReclamaCaicoApp/forms.py | 1,619 | Python |
# coding: utf-8
from django.conf.urls import url
from api_v1 import views
urlpatterns = [
url(r'^register/$', views.register),
url(r'^login/$', views.login),
url(r'^images/$', views.images),
url(r'^reccomend/$', views.reccomend),
url(r'^user_post/$', views.get_user_post),
]
# api viewer (debug用)
fr... | 30.909091 | 88 | 0.738235 | [
"MIT"
] | Utree/TRAGRAM | server/project/api_v1/urls.py | 682 | Python |
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.0.6320, generator: {generator})
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# ---------------------------------------... | 38.298134 | 391 | 0.623508 | [
"MIT"
] | EricLiclair/bing-search-sdk-for-python | sdk/WebSearch/web_search_client/models/_models.py | 77,975 | Python |
from cudf._lib.nvtext.edit_distance import edit_distance, edit_distance_matrix
from cudf._lib.nvtext.generate_ngrams import (
generate_character_ngrams,
generate_ngrams,
)
from cudf._lib.nvtext.ngrams_tokenize import ngrams_tokenize
from cudf._lib.nvtext.normalize import normalize_characters, normalize_spaces
f... | 29.898876 | 79 | 0.782413 | [
"Apache-2.0"
] | HaoYang670/cudf | python/cudf/cudf/_lib/strings/__init__.py | 2,661 | Python |
# Copyright 2013-2020 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 PyPytestRunner(PythonPackage):
"""Invoke py.test as distutils command with dependency reso... | 39.05 | 96 | 0.75032 | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | JoshuaSBrown/spack | var/spack/repos/builtin/packages/py-pytest-runner/package.py | 781 | Python |
"""
OpenSpace
Copyright (c) 2014-2018
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, publish, distribute... | 28.542522 | 118 | 0.623857 | [
"MIT"
] | nbartzokas/OpenSpace | support/coding/check_style_guide.py | 19,467 | Python |
"""
Training data and validation accuracy.
"""
# Author: Changyu Liu <Shiyipaisizuo@gmail.com>
# Last modified: 2018-07-06
# LICENSE: MIT
import os
import numpy as np
import tensorflow as tf
from PIL import Image
import train_test_split
import cnn
N_CLASSES = 2 # dogs and cats
IMG_W = 208 # resize the image,... | 31.686667 | 92 | 0.568062 | [
"MIT"
] | GPUworkstation/tensorflow-project | cats_dogs/base.py | 4,753 | Python |
import json
#Try with python3
try:
from urllib.request import urlopen, urlretrieve
from urllib.request import urlretrieve
#Else try python2
except:
from urllib2 import urlopen
from urllib import urlretrieve
from os import path
#User home folder
homeFolder = path.expanduser("~")
#... | 25.164706 | 103 | 0.624123 | [
"MIT"
] | networkprogrammer/bing-wallpaper-for-mac | Bing Wallpaper/GetWallpaper.py | 2,139 | Python |
import asyncio
from collections import defaultdict
from dataclasses import dataclass
import json
import logging
import os
import time
from typing import Dict, Set
from ray._private.utils import import_attr
from ray.core.generated import runtime_env_agent_pb2
from ray.core.generated import runtime_env_agent_pb2_grpc
fr... | 47.703252 | 79 | 0.633319 | [
"Apache-2.0"
] | 188xuhe/ray | dashboard/modules/runtime_env/runtime_env_agent.py | 11,735 | Python |
# Copyright 2018-2022 Streamlit 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 wr... | 35.555556 | 74 | 0.760938 | [
"Apache-2.0"
] | Aaryanverma/streamlit | e2e/scripts/st_text.py | 640 | Python |
import os
import logging
import argparse
from collections import Counter
import pandas as pd
import inflect
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
_CATEGRORIES = [
'Mini Briefs',
'Advances & Business',
'Concerns & Hype',
'Analysis & Policy',
'Expert Opinions & Discussion within t... | 31.142857 | 101 | 0.552905 | [
"MIT"
] | jacky-liang/skynet-today | scripts/csv2md.py | 3,270 | Python |
s = "Hey there! what should this string be?"
# Length should be 20
print("Length of s = %d" % len(s[0:20]))
# Index
print("The first occurrence of the letter a = %d" % s.index("!"))
# Count
print("t occurs %d times" % s.count("t"))
# Slicing the string into bits
s1 = "hello world"
print(s1[:1]) # splicing is exclusi... | 32.673469 | 78 | 0.630231 | [
"MIT"
] | othonreyes/code_problems | python/python/basics/strings.py | 1,601 | Python |
import os
import pkgutil
from pathlib import Path
import pytest
from click.testing import CliRunner
from slotscheck.cli import root as cli
from .conftest import EXAMPLES_DIR
@pytest.fixture()
def runner():
return CliRunner()
@pytest.fixture(autouse=True)
def set_cwd(request):
os.chdir(EXAMPLES_DIR)
y... | 28.708333 | 78 | 0.650092 | [
"MIT"
] | ariebovenberg/slotscheck | tests/src/test_cli.py | 15,847 | Python |
from keras.utils import to_categorical
import tensorflow as tf
import pygame
class pytennis:
def __init__(self, fps = 50):
self.net = Network(150,450,100,600)
self.updateRewardA = 0
self.updateRewardB = 0
self.updateIter = 0
self.lossA = 0
self.lossB = 0
... | 35.803653 | 137 | 0.491583 | [
"Apache-2.0"
] | elishatofunmi/ReinEnv | pytennis/play.py | 15,682 | Python |
"""
Optuna example that optimizes a classifier configuration for cancer dataset
using XGBoost.
In this example, we optimize the validation accuracy of cancer detection
using XGBoost. We optimize both the choice of booster model and their hyper
parameters.
We have following two ways to execute this example:
(1) Execu... | 36.605634 | 99 | 0.69873 | [
"MIT"
] | AkihiroTajima/optuna | examples/xgboost_simple.py | 2,599 | Python |
import re,sys
class Instruction:
def __init__(self,defn):
m = re.match("^([A-Fa-f0-9\-\,]+)\s+\"(.*?)\"\s+(.*)$",defn)
assert m is not None,"Bad line "+defn
range = m.group(1)
range = range+"-"+range if len(range) == 2 else range
range = range+",1" if len(range) == 5 else range
self.first = int(range[:2],... | 32.607477 | 103 | 0.580109 | [
"MIT"
] | paulscottrobson/RCA-Cosmac-VIP-III | processor/generate.py | 3,489 | Python |
from __future__ import absolute_import, division, print_function
from glue.core.state_objects import State
from glue.external.echo import CallbackProperty, keep_in_sync
class AladinLiteLayerState(State):
layer = CallbackProperty()
visible = CallbackProperty(True)
zorder = CallbackProperty(0)
color =... | 28.225 | 85 | 0.674934 | [
"BSD-3-Clause"
] | glue-viz/glue-aladin | glue_aladin/layer_state.py | 1,129 | Python |
"""Writes the given metrics in a csv."""
import numpy as np
import os
import pandas as pd
import sys
models_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(models_dir)
from baseline_constants import CLIENT_ID_KEY, NUM_ROUND_KEY, NUM_SAMPLES_KEY
COLUMN_NAMES = [
CLIENT_ID_KEY, ... | 33.036145 | 83 | 0.651349 | [
"BSD-2-Clause"
] | slowbull/leaf | models/metrics/writer.py | 2,742 | Python |
/home/runner/.cache/pip/pool/3f/10/5e/0da870cfd442c4b93168f62f7eb1f09417d637dc6c7f4acefd6341907e | 96 | 96 | 0.895833 | [
"Apache-2.0"
] | 035NotEnd/Vowel-Chacker | venv/lib/python3.8/site-packages/yapftests/reformatter_python3_test.py | 96 | Python |
from math import log
number = int(input())
base = input()
if base == 'natural':
print(f'{log(number):.2f}')
else:
print(f'{log(number , int(base)):.2f}')
| 15 | 43 | 0.593939 | [
"MIT"
] | borisboychev/SoftUni | Python_Advanced_Softuni/Modules_Lab/venv/logarithm.py | 165 | Python |
import numpy as np
import pandas as pd
import sys # can use sys to take command line arguments
class Recommender():
'''
What is this class all about - write a really good doc string here
'''
def __init__(self, ):
'''
what do we need to start out our recommender system
'''
... | 23.416667 | 79 | 0.601423 | [
"MIT"
] | 43piRcubed/DSND_Term2 | lessons/Recommendations/2_Matrix_Factorization_for_Recommendations/recommender_template.py | 843 | Python |
import tensorflow as tf
import sys
sys.path.insert(0,'..')
import vtrace_popart as vtrace
nest = tf.contrib.framework.nest
from .flags import *
def compute_baseline_loss(advantages):
# Loss for the baseline, summed over the time dimension.
# Multiply by 0.5 to match the standard update rule:
# d(loss) / d(basel... | 41.507353 | 82 | 0.740478 | [
"Apache-2.0"
] | steffenvan/IMPALA-PopArt | popart/build_learner.py | 5,645 | Python |
#!/usr/bin/python
# Copyright (c) 2020, 2021 Oracle and/or its affiliates.
# This software is made available to you under the terms of the GPL 3.0 license or the Apache 2.0 license.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Apache License v2.0
# See LICENSE.TXT for d... | 34.591687 | 139 | 0.571742 | [
"Apache-2.0"
] | sagar2938/oci-ansible-collection | plugins/modules/oci_optimizer_recommendation_actions.py | 14,148 | Python |
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
from django_secrets.startup import check
check()
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_secrets.settings'
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above... | 32.185185 | 77 | 0.643268 | [
"MIT"
] | kakulukia/django-secrets | manage.py | 869 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2017/7/31 上午10:21
# @Author : Matrix
# @Github : https://github.com/blackmatrix7/
# @Blog : http://www.cnblogs.com/blackmatrix/
# @File : __init__.py.py
# @Software: PyCharm
from .huawei import SMSCenter
__author__ = 'blackmatrix'
if __name__ == '__main__':
... | 21.666667 | 45 | 0.667692 | [
"Apache-2.0"
] | blackmatrix7/iphone-hunter | sms/__init__.py | 329 | Python |
from __future__ import unicode_literals
import boto
from boto.exception import BotoServerError
from moto import mock_sns
import sure # noqa
@mock_sns
def test_create_platform_application():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
name="my-application",
... | 36.546429 | 162 | 0.731262 | [
"Apache-2.0"
] | IlyaSukhanov/moto | tests/test_sns/test_application.py | 10,233 | Python |
# -*- coding: utf-8 -*-
# this file is released under public domain and you can use without limitations
#########################################################################
## Customize your APP title, subtitle and menus here
#########################################################################
response.logo... | 44.266187 | 79 | 0.478628 | [
"BSD-3-Clause"
] | jjacobson93/javelin-web2py | applications/javelin/models/menu.py | 6,153 | Python |
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: google/cloud/videointelligence_v1/proto/video_intelligence.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.pro... | 36.169513 | 14,099 | 0.642526 | [
"Apache-2.0"
] | danoscarmike/python-videointelligence | google/cloud/videointelligence_v1/proto/video_intelligence_pb2.py | 197,079 | Python |
# Copyright 2019, A10 Networks
#
# 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... | 40.36 | 127 | 0.624711 | [
"Apache-2.0"
] | richuc/a10-octavia | a10_octavia/controller/worker/tasks/a10_vthunder_db.py | 3,027 | Python |
from __future__ import unicode_literals
from nose.tools import assert_raises
import datetime
import boto
import boto3
import sure # noqa
from boto.exception import JSONResponseError
from moto import mock_ec2
from moto.backends import get_model
from moto.core.utils import iso_8601_datetime_with_milliseconds
@mock_e... | 35.95614 | 177 | 0.723347 | [
"Apache-2.0"
] | GoodRx/moto | tests/test_ec2/test_spot_instances.py | 8,198 | 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 ... | 64.972325 | 180 | 0.721056 | [
"MIT"
] | AFengKK/azure-sdk-for-python | sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/aio/_container_registry_management_client.py | 35,215 | Python |
from django.contrib.sites.shortcuts import get_current_site
from django.template.loader import get_template
from ...settings import STATIC_URL
from ...order.models import DeliveryGroup, Order
INVOICE_TEMPLATE = 'dashboard/order/pdf/invoice.html'
PACKING_SLIP_TEMPLATE = 'dashboard/order/pdf/packing_slip.html'
def g... | 35.078431 | 71 | 0.718278 | [
"BSD-3-Clause"
] | imran1234567/saleor | saleor/dashboard/order/utils.py | 1,789 | Python |
import os
import json
import numpy as np
import itertools
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d.art3d import Line3DCollection
from mpl_toolkits import mplot3d
def liver_dump_init(env, name = None):
liver = {'x':[],'Fes':[],'Fis':[],'Ficp':[],'volume':[],'col_p_n':[],'crash':[]}
l... | 40.867647 | 137 | 0.569886 | [
"MIT"
] | Kexin-Wei/spinnup | env_pyrep/utils.py | 19,453 | Python |
from django.db import models
# Create your models here.
class Message(models.Model):
tab_name = models.TextField(max_length=50)
text = models.TextField(max_length=300) | 29.333333 | 46 | 0.761364 | [
"MIT"
] | robocol-rem-u/ros_web_app_2 | Robocol/testapp/Interfaz/models.py | 176 | Python |
from a10sdk.common.A10BaseClass import A10BaseClass
class AuthSamlIdp(A10BaseClass):
""" :param remote_file: {"optional": true, "type": "string", "description": "Profile name for remote url", "format": "url"}
:param use_mgmt_port: {"default": 0, "optional": true, "type": "number", "description": "Use ... | 38.727273 | 151 | 0.642019 | [
"Apache-2.0"
] | a10networks/a10sdk-python | a10sdk/core/A10_import/import_auth_saml_idp.py | 1,704 | Python |
# coding: utf-8
"""
Intersight REST API
This is Intersight REST API
OpenAPI spec version: 1.0.9-255
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from pprint import pformat
from six import iteritems
import re
class EquipmentChassis(object):
"""
NOTE: This clas... | 26.90806 | 418 | 0.589282 | [
"Apache-2.0"
] | fdemello/intersight-python | intersight/models/equipment_chassis.py | 21,365 | Python |
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'button_editor.ui'
#
# Created by: PyQt5 UI code generator 5.7
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObj... | 42.175 | 106 | 0.733254 | [
"MIT"
] | BoettigerLab/Hal2 | storm_control/hal4000/illumination/button_editor_ui.py | 1,687 | Python |
#!/usr/bin/env python
# Copyright (c) 2005 Gavin E. Crooks <gec@threeplusone.com>
#
# This software is distributed under the MIT Open Source License.
# <http://www.opensource.org/licenses/mit-license.html>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and ass... | 33.507692 | 80 | 0.71258 | [
"MIT"
] | javicorvi/weblogo_edited | test_corebio/test_table_io.py | 2,178 | Python |
#!/usr/bin/env python
# Copyright 2015 Rackspace, 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
#... | 30.5625 | 78 | 0.655078 | [
"Apache-2.0"
] | jayofdoom/onmetal-scripts | onmetal_scripts/decom_port.py | 1,467 | Python |
"""
File: weather_master.py
Name: Claire Lin
-----------------------
This program should implement a console program
that asks weather data from user to compute the
average, highest, lowest, cold days among the inputs.
Output format should match what is shown in the sample
run in the Assignment 2 Handout.
"""
EXIT = ... | 28.513274 | 103 | 0.543451 | [
"MIT"
] | clairejrlin/stanCode_projects | stanCode_Projects/weather_master/weather_master.py | 3,222 | Python |
"""Module of sample legends for some commonly used geospatial datasets.
"""
import os
import pkg_resources
# Land Cover datasets in Earth Engine https://developers.google.com/earth-engine/datasets/tags/landcover
builtin_legends = {
# National Land Cover Database 2016 (NLCD2016) Legend https://www.mrlc.gov/data/leg... | 53.958874 | 299 | 0.625216 | [
"MIT"
] | GSRS/geemap | geemap/legends.py | 24,929 | Python |
"""
naivefit.py
A NaiveFit follows the approach described in Crundall et al. (2019).
NaiveFit begins with an initial guess provided by user of an N component fit.
If no guess is provided, all provided stars are assumed to be members of one
component.
NaiveFit will perform an Expectation Maximisation on this N compo... | 43.391111 | 399 | 0.583086 | [
"MIT"
] | mikeireland/chronostar | chronostar/naivefit-bak.py | 29,289 | Python |
from conans import ConanFile
class libxbitset_conan(ConanFile):
name = "libxbitset"
version = "0.0.1"
license = "Apache License Version 2.0"
author = "Khalil Estell"
url = "https://github.com/SJSU-Dev2/libxbitset"
description = "Extension of std::bitset that includes multi-bit insertion and ex... | 29.7 | 102 | 0.66835 | [
"Apache-2.0"
] | SJSU-Dev2/libxbitset | conanfile.py | 594 | Python |
"""The token kinds currently recognized."""
from shivyc.tokens import TokenKind
keyword_kinds = []
symbol_kinds = []
# Until function definition is ready, we define `main` as a hardcoded keyword
main = TokenKind("main", keyword_kinds)
bool_kw = TokenKind("_Bool", keyword_kinds)
char_kw = TokenKind("char", keyword_k... | 33.873418 | 77 | 0.7358 | [
"MIT"
] | TBladen/ShivyC | shivyc/token_kinds.py | 2,676 | Python |
# coding: utf-8
def get_dict_output_dir_to_parameters_ini_dump_filename():
import os
dir_ = '.'
output_dir_list = sorted([output_dir for output_dir in os.listdir(dir_) if output_dir.startswith('output')])
ret = {}
for output_dir in output_dir_list:
with open(os.path.join(output_dir, 'para... | 34.271255 | 151 | 0.623036 | [
"BSD-3-Clause"
] | dcseal/finess | apps/2d/mhd/rotated_alfven/convergence/convergence_study.py | 8,465 | Python |
import logging
import torch.nn as nn
from . import arch as archs
logger = logging.getLogger()
def build_model(cfg_model):
if cfg_model.get('pretrained', False):
info = "=> building pre-trained model {}".format(cfg_model['arch'])
model = archs.__dict__[cfg_model.arch](pretrained=True)
in_... | 29.047619 | 81 | 0.685246 | [
"Apache-2.0"
] | ChaseMonsterAway/vedacls | vedacls/models/builder.py | 610 | Python |
from __future__ import print_function
import click
from openelex.base.cache import StateCache
from .utils import default_state_options, print_files
@click.command(name="cache.files", help="List files in state cache diretory")
@default_state_options
def files(state, datefilter=''):
"""List files in state cache di... | 25.372093 | 79 | 0.695692 | [
"MIT"
] | ColCarroll/openelections-core | openelex/tasks/cache.py | 1,091 | Python |
from tzscan.tzscan_reward_calculator import test_tzscan_reward_calculator
if __name__ == '__main__':
test_tzscan_reward_calculator() | 34.25 | 73 | 0.846715 | [
"MIT"
] | Twente-Mining/tezos-reward-distributor | src/Test.py | 137 | Python |
import os
import sys
# os.system('bash ./set_env.sh')
PARALLEL = 1 # assuming a quad-core machine
ATTRIBUTE = "organic_figure"
os.environ['FONDUERHOME'] = '/home/xiuyuan/private/839/fonduer_new/839_fonduer/'
os.environ['FONDUERDBNAME'] = ATTRIBUTE
os.environ['SNORKELDB'] = 'postgres://postgres:112233@localhost:5432/' ... | 33.625397 | 140 | 0.703078 | [
"Apache-2.0"
] | leewaymay/839_fonduer | tutorials/organic_synthesis_figures/parse_organic_figures_xiuyuan.py | 10,592 | Python |
"""Support for local control of entities by emulating a Philips Hue bridge."""
import logging
from aiohttp import web
import voluptuous as vol
from homeassistant import util
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
from homeassistant.exceptions import HomeAssistantError
from... | 33.432177 | 88 | 0.663144 | [
"Apache-2.0"
] | 0x00-0xFF/home-assistant | homeassistant/components/emulated_hue/__init__.py | 10,598 | Python |
# coding: utf-8
"""
ESMInterfaceTypeData.py
The Clear BSD License
Copyright (c) – 2016, NetApp, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are ... | 38.506329 | 844 | 0.640368 | [
"BSD-3-Clause-Clear"
] | NetApp/santricity-webapi-pythonsdk | netapp/santricity/models/symbol/esm_interface_type_data.py | 6,086 | Python |
#!/usr/bin/python3
#
# Copyright (C) 2011 Google 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,
# this list o... | 27.180645 | 76 | 0.68431 | [
"BSD-2-Clause"
] | RegioHelden/ganeti | test/py/lockperf.py | 4,213 | Python |
# 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, software
# distributed under t... | 37.818182 | 77 | 0.647837 | [
"Apache-2.0"
] | JiyeYu/eclsdk | ecl/compute/v2/image.py | 2,496 | Python |
from os import environ
from scrapy_heroku.poller import Psycopg2QueuePoller
from scrapy_heroku.scheduler import Psycopg2SpiderScheduler
from scrapyd.eggstorage import FilesystemEggStorage
from scrapyd.environ import Environment
from scrapyd.interfaces import (IEggStorage, IEnvironment, IPoller,
... | 35.697674 | 78 | 0.760912 | [
"BSD-3-Clause"
] | esavara/scrapy-heroku | scrapy_heroku/app.py | 1,535 | Python |
# -*- coding: utf-8 -*-
"""
Adjustment from the 2D version from Machine Learning & Simulation code and video:
https://www.youtube.com/watch?v=ZUXmO4hu-20&list=LL&index=1&ab_channel=MachineLearning%26Simulation
https://github.com/Ceyron/machine-learning-and-simulation/blob/main/english/simulation_scripts/lattice... | 45.912821 | 153 | 0.598235 | [
"MIT"
] | bartdavids/machine-learning-and-simulation | english/simulation_scripts/D3Q19_lattice_boltzmann_method_python_jax.py | 8,953 | Python |
__author__ = 'ialbert'
from django.views.generic import DetailView, ListView, TemplateView, RedirectView, View
from haystack.views import SearchView
from haystack.forms import SearchForm
from haystack.query import SearchQuerySet, AutoQuery
from haystack.utils import Highlighter
from django.conf import settings
from bi... | 28.067797 | 93 | 0.658514 | [
"MIT"
] | biostars/support.bioconductor.org | biostar/server/search.py | 3,312 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.