content stringlengths 7 928k | avg_line_length float64 3.5 33.8k | max_line_length int64 6 139k | alphanum_fraction float64 0.08 0.96 | licenses list | repository_name stringlengths 7 104 | path stringlengths 4 230 | size int64 7 928k | lang stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|
from typing import Dict, Tuple
import torch
import torch.nn as nn
from neuralhydrology.modelzoo.basemodel import BaseModel
from neuralhydrology.modelzoo.fc import FC
from neuralhydrology.modelzoo.head import get_head
from neuralhydrology.utils.config import Config
class EALSTM(BaseModel):
"""Entity-Aware LSTM (... | 40.937107 | 119 | 0.649101 | [
"BSD-3-Clause"
] | visr/neuralhydrology | neuralhydrology/modelzoo/ealstm.py | 6,511 | Python |
import logging
from pathlib import Path
from taskcat._config import Config
from taskcat.iam_policy.policy import CFNPolicyGenerator
LOG = logging.getLogger(__name__)
class GenerateIAMPolicy:
"""
[ALPHA] Introspects CFN Template(s) and generates an IAM policy necessary to successfully launch the template(s)
... | 27.08 | 116 | 0.725258 | [
"Apache-2.0"
] | GlennChia/taskcat | taskcat/_cli_modules/generate_iam_policy.py | 677 | Python |
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve.
#
#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... | 35.942529 | 108 | 0.633674 | [
"Apache-2.0"
] | GitHubpenglix666/models | PaddleRec/gnn/train.py | 6,254 | Python |
"""
This module provides two implementations for the rod-cutting problem:
1. A naive recursive implementation which has an exponential runtime
2. Two dynamic programming implementations which have quadratic runtime
The rod-cutting problem is the problem of finding the maximum possible revenue
obtainable from a rod of ... | 28.379808 | 88 | 0.630527 | [
"MIT"
] | AlgorithmAndLeetCode/TheAlgorithms-Python | dynamic_programming/rod_cutting.py | 5,903 | Python |
# Copyright (c) 2020 by Fraunhofer Institute for Energy Economics
# and Energy System Technology (IEE), Kassel. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
from pandapower.plotting.geo import _node_geometries_from_geodata, \
_transform_no... | 41.861538 | 99 | 0.728776 | [
"BSD-3-Clause"
] | Fraank-dash/pandapipes | pandapipes/plotting/geo.py | 2,722 | Python |
import numpy as np
import pytest
from allopy import PortfolioRegretOptimizer, RegretOptimizer, get_option
from .data import Test1, Test2, assets, scenarios
from .funcs import cvar_fun, obj_max_returns
@pytest.mark.parametrize("config", [Test1, Test2])
def test_regret_optimizer(config, main_cubes, cvar_cubes):
op... | 39.892308 | 109 | 0.66371 | [
"MIT"
] | wangcj05/allopy | tests/regret/portfolio/test_portfolio_regret_optimizer.py | 2,593 | Python |
# -*- coding: UTF-8 -*-
import datetime
import json
from django.contrib.auth.hashers import check_password, make_password
from django.core import serializers
from django.db import connection
from django.http import HttpResponse
from django.shortcuts import render
from django.views.decorators.csrf import csrf_exempt
... | 44.330969 | 245 | 0.624307 | [
"Apache-2.0"
] | bopopescu/dbsupport | cmdb/views_ajax.py | 19,378 | Python |
### ###
# Imports #
### ###
import datetime, os, plistlib, struct, sys, itertools
from io import BytesIO
if sys.version_info < (3,0):
# Force use of StringIO instead of cStringIO as the latter
# has issues with Unicode strings
from StringIO import StringIO
try:
FMT_XML = plistlib.FMT_XML
... | 34.915194 | 101 | 0.556371 | [
"MIT"
] | 640921008/gibMacOS | Scripts/plist.py | 19,762 | Python |
"""
Utils for AiiDA.
----------------
Utilities for making working against AiiDA a bit easier. Mostly here due to
historical reasons when AiiDA was rapidly developed. In the future most routines
that have now standardized in AiiDA will be removed.
"""
# pylint: disable=import-outside-toplevel
import numpy as np
from p... | 28.25 | 99 | 0.711504 | [
"MIT"
] | kavanase/aiida-vasp | aiida_vasp/utils/aiida_utils.py | 4,520 | Python |
# Fully Written by @HeisenbergTheDanger (Keep credits else gay)
# Permission Seeked By @StarkXD - Approved
import asyncio
import datetime
from telethon import events
from var import Var
from uniborg.util import admin_cmd
from telethon.tl.types import (
DocumentAttributeFilename,
DocumentAttributeSticker,
I... | 36.893617 | 280 | 0.624452 | [
"MIT"
] | doctorhacker007/FridayUserbot | userbot/plugins/broadcast.py | 8,670 | Python |
import pytest
import sinergym.utils.rewards as R
@pytest.mark.parametrize(
'power,temperatures,month,day,reward,reward_energy,reward_comfort',
[
# Input 1
(
186.5929171535975,
[22.16742570092868],
3,
31,
-0.009329645857679876,
... | 22.5 | 71 | 0.498765 | [
"MIT"
] | AlejandroCN7/sinergym | tests/test_reward.py | 1,215 | Python |
from main import main
from src.common import fill_with
class Arguments:
pass
# latex info
result_structure = '|c|c|c|c|c|c|'
test_structure = '|c|c|c|c|c|c|c|'
table_body = '''
\\begin{center}
\t\\begin{tabular}{%s}
\t\t\\hline \\rowcolor{brown!50}
%s
\t\\end{tabular}
\\end{center}\n
'''
# Util data for b... | 29.766667 | 120 | 0.545726 | [
"MIT"
] | stdevRulo/babysitter_agent | test.py | 2,679 | Python |
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | 40.058151 | 116 | 0.572975 | [
"Apache-2.0"
] | 1190202328/PaddleDetection | ppdet/modeling/heads/s2anet_head.py | 42,021 | Python |
from http.server import HTTPServer, BaseHTTPRequestHandler
from socketserver import ThreadingMixIn
from .redirect import RedirectHandler
import threading
import ssl
__all__ = ['ThreadedServer', 'SecureServer']
class ThreadedServer(ThreadingMixIn, HTTPServer):
protocol_version = 'HTTP/1.1'
def __init__(self,... | 34.242424 | 78 | 0.574779 | [
"MIT"
] | ChrisCalderon/SerpentServer | serpent_server/server.py | 2,260 | Python |
# Generated by Django 2.1.3 on 2019-01-07 17:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('blog', '0014_auto_20190107_2251'),
]
operations = [
migrations.DeleteModel(
name='PostPicks',
),
migrations.AddF... | 21.954545 | 82 | 0.581781 | [
"MIT"
] | dkowsikpai/librolet | blog/migrations/0015_auto_20190107_2318.py | 483 | Python |
# Copyright (C) 2008-today The SG++ project
# This file is part of the SG++ project. For conditions of distribution and
# use, please see the copyright notice provided with SG++ or at
# sgpp.sparsegrids.org
# This file is part of SGClass, a program package making use of spatially adaptive sparse grids to solve numeri... | 41.37 | 128 | 0.556442 | [
"CC0-1.0"
] | valentjn/thesis | lib/pysgpp/extensions/misc/datasetAnalysis.py | 4,137 | Python |
"""Entrypoint for the WSGI app (web API)
"""
from . import api
application = api.create_app()
| 15.833333 | 40 | 0.694737 | [
"MIT"
] | lionel-panhaleux/krcg-api | krcg_api/wsgi.py | 95 | Python |
"""Utilties for distributed processing"""
import horovod.tensorflow.keras as hvd
def rank():
try:
return hvd.rank()
except ValueError:
return 0
def barrier():
try:
hvd.allreduce([], name='Barrier')
except ValueError:
pass
| 17.0625 | 41 | 0.611722 | [
"Apache-2.0"
] | bgerofi/hpc_results_v0.7 | CSCS/benchmarks/cosmoflow/implementations/cosmoflow-benchmark/utils/distributed.py | 273 | Python |
#!/usr/bin/env python3
import importlib
import logging
import os
import traceback
import pybullet_data
import rclpy
from rclpy import executors
from rclpy.executors import MultiThreadedExecutor
from rclpy.node import Node
from std_srvs.srv import Empty
from pybullet_ros.function_exec_manager import FuncExecManager
... | 48.160173 | 139 | 0.65582 | [
"MIT"
] | packbionics/pybullet_ros | pybullet_ros/pybullet_ros_wrapper.py | 11,125 | Python |
# Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.
#
# According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a desce... | 26.245614 | 231 | 0.620321 | [
"MIT"
] | chyidl/leetcode | 0235-lowest-common-ancestor-of-a-binary-search-tree/lowest-common-ancestor-of-a-binary-search-tree.py | 1,512 | Python |
import numpy as np
class Dense():
def __init__(self, units, activation=None, use_bias=True, kernel_initializer='glorot_uniform', bias_initializer='zeros', input_shape=None):
self._units = units
self._activation = activation
self._use_bias = use_bias
self._kernal_initializer = kern... | 31.4 | 143 | 0.587403 | [
"MIT"
] | GreatGameDota/CNN-Numpy-1D-Images | CNN/Dense.py | 1,413 | Python |
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** 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 Union
from .. import utilities, tables
class AnalyticsConfigur... | 51.11413 | 165 | 0.645933 | [
"ECL-2.0",
"Apache-2.0"
] | michael-golden/pulumi-aws | sdk/python/pulumi_aws/s3/analytics_configuration.py | 9,405 | Python |
import asyncio
import google.protobuf.any_pb2
import irsdk
from asyncio import Queue
from google.protobuf.any_pb2 import Any
from TelemetryDataUtils import getInfo, getGeneral
from models import typed_message_pb2
from models.State import State
class TelemetryLogger:
def __init__(self, receiver_queue: Queue, pu... | 37.188406 | 97 | 0.669914 | [
"MIT"
] | LandonPatmore/iracing-live-telemetry | logger/TelemetryLogger.py | 2,566 | Python |
from nbconvert.writers.base import WriterBase
class HelloWriter(WriterBase):
def write(self, output, resources, notebook_name=None, **kw):
with open("hello.txt", "w") as outfile:
outfile.write("hello world")
| 29.25 | 65 | 0.683761 | [
"BSD-3-Clause"
] | CMU-IDS-2022/final-project-the-evaluators | venv/lib/python3.9/site-packages/nbconvert/tests/files/hello.py | 234 | Python |
import os
import sys
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
with open("README.md") as f:
readme = f.read()
classifiers = [
'Intended Audience :: Developers',
'Operating System :: OS Independent',
'Programming Language :: Python',
]
setup(
... | 26.6875 | 73 | 0.651054 | [
"BSD-3-Clause"
] | dilawar/tinypandas | setup.py | 854 | Python |
from importlib.resources import path
import sys
import os
import shutil
from git import Repo
from subprocess import call
from git import RemoteProgress
import git
from tqdm import tqdm
from pathlib import Path
dir_path = (os.path.expanduser('~/Documents') + "\server")
os.chdir(dir_path)
gitaddress = str("https://gith... | 28.283019 | 108 | 0.695797 | [
"MIT"
] | 0xol/server-installer | main.py | 1,499 | Python |
###############################################################################
#
# Tests for XlsxWriter.
#
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c), 2013-2021, John McNamara, jmcnamara@cpan.org
#
from ..excel_comparison_test import ExcelComparisonTest
from ...workbook import Workbook
class TestCompar... | 26.454545 | 79 | 0.538832 | [
"BSD-2-Clause"
] | CrackerCat/XlsxWriter | xlsxwriter/test/comparison/test_chart_scatter03.py | 1,455 | Python |
# coding=utf-8
# Copyright 2018 The Tensor2Tensor 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... | 32.06044 | 87 | 0.70517 | [
"Apache-2.0"
] | PedroLelis/tensor2tensor | tensor2tensor/data_generators/algorithmic.py | 17,505 | Python |
#!/usr/bin/env python
from setuptools import setup, find_packages
setup(
name='async-gelf-handler',
version='0.1.4',
description="An async wrapper around the GELF (Graylog Extended Log Format).",
long_description=open('README.rst').read(),
keywords='logging gelf graylog2 graylog async',
author... | 34.954545 | 82 | 0.6671 | [
"BSD-3-Clause"
] | listingmirror/async-gelf-handler | setup.py | 769 | Python |
from flask import Flask
app = Flask(__name__, static_url_path='', static_folder='static')
app.config['DEBUG'] = True
@app.route('/')
def root():
# Note: this is probably handled by the app engine static file handler.
return app.send_static_file('index.html')
@app.errorhandler(404)
def page_not_found(e):
"""Re... | 28.142857 | 73 | 0.71066 | [
"Apache-2.0"
] | rekab/papt | main.py | 394 | Python |
import random
import math
import numpy as np
from typing import List
class EpsilonGreedy:
def __init__(self, epsilon: float, counts: List[int], values: List[float]):
assert epsilon is None or 0.0 <= epsilon <= 1.0
self.epsilon = epsilon
self.counts = counts
self.values = values
... | 28.175 | 108 | 0.584738 | [
"MIT"
] | MitI-7/MachineLearning | ReinforcementLearning/Bandit/EpsilonGreedy.py | 1,135 | Python |
"""
Generating data from the CarRacing gym environment.
!!! DOES NOT WORK ON TITANIC, DO IT AT HOME, THEN SCP !!!
"""
import argparse
from os.path import join, exists
import gym
import numpy as np
from utils.misc import sample_continuous_policy
def generate_data(rollouts, data_dir, noise_type): # pylint: disable=R0914... | 38 | 115 | 0.586404 | [
"MIT"
] | susanwe/world-models | data/carracing.py | 2,280 | Python |
"""
Entradas
Monto de dinero -> int -> a
"""
a = int ( input ( "Ingrese monto de dinero en COP:" ))
b = a
billetes_de_100000 = ( b - b % 100000 ) / 100000
b = b % 100000
billetes_de_50000 = ( b - b % 50000 ) / 50000
b = b % 50000
billetes_de_20000 = ( b - b % 20000 ) / 20000
b = b % 20000
billetes_de_10000 = ( b - b % ... | 39.897436 | 80 | 0.63946 | [
"MIT"
] | JuanMPerezM/AlgoritmosyProgramacion_Talleres | taller_estructuras_de_control/ejercicio12.py | 1,556 | Python |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests
import json
import datetime
url = 'https://endpoints.office.com/endpoints/worldwide?clientrequestid=b10c5ed1-bad1-445f-b386-b919946339a7'
r = requests.get(url)
service_list = r.json()
lurls= []
lips = []
for service in service_list:
for url in servic... | 33.906977 | 109 | 0.699588 | [
"CC0-1.0"
] | JakubOnderka/misp-warninglists | tools/generate-office365.py | 1,458 | 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
fro... | 59.43734 | 1,975 | 0.711867 | [
"Apache-2.0"
] | AaronFriel/pulumi-google-native | sdk/python/pulumi_google_native/compute/alpha/_inputs.py | 882,169 | Python |
import sys
import matplotlib.pyplot as plt
import os
root_path = os.path.dirname(os.path.abspath('__file__'))
sys.path.append(root_path)
from tools.models import one_step_esvr, one_step_esvr_multi_seed
from Xianyang_dwt.projects.variables import variables
if __name__ == '__main__':
one_step_esvr_multi_seed(
... | 40.125 | 158 | 0.688474 | [
"MIT"
] | zjy8006/MonthlyRunoffForecastByAutoReg | Xianyang_dwt/projects/esvr_one_step.py | 2,889 | Python |
import objc
from Foundation import *
from AppKit import *
from PyObjCTools import NibClassBuilder, AppHelper
class StatusBar(NSObject):
def setFront(self):
NSRunningApplication.currentApplication_().activateWithOptions_(NSApplicationActivateIgnoringOtherApps)
def applicationDidFinishLaunching_(self, n... | 35.857143 | 111 | 0.719788 | [
"MIT"
] | Licht-T/pyRotateDisplayForMac | pyRotateDisplayStatusBar.py | 1,506 | Python |
# -*- coding: utf-8 -*-
# Copyright 2021 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 app... | 31.962264 | 106 | 0.677391 | [
"Apache-2.0"
] | Takishima/mindquantum | tests/st/test_core/test_operators/test_operators_utils.py | 3,388 | Python |
import os
import soft_renderer.functional as srf
import torch, random
import numpy as np
import tqdm
from haven import haven_utils as hu
from PIL import Image, ImageOps, ImageFilter
import torchvision.transforms as transforms
class_ids_map = {
'02691156': 'Airplane',
'02828884': 'Bench',
'02933112': 'Cabi... | 34.557312 | 121 | 0.566396 | [
"Apache-2.0"
] | IssamLaradji/SSR | src/datasets.py | 8,743 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# (C) British Crown Copyright 2017-2020 Met Office.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the ... | 39.933333 | 79 | 0.724958 | [
"BSD-3-Clause"
] | BelligerG/improver | improver/cli/sleet_probability.py | 2,396 | Python |
# Copyright 2019 The TensorTrade 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... | 33.121951 | 98 | 0.665194 | [
"Apache-2.0"
] | Kukunin/tensortrade | tensortrade/wallets/wallet.py | 4,074 | Python |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('mig_main', '0003_officerposition_position_type'),
]
operations = [
migrations.CreateModel(
name='Committee',
... | 27.259259 | 114 | 0.559783 | [
"Apache-2.0"
] | atish3/mig-website | mig_main/migrations/0004_committee.py | 736 | Python |
from abc import ABC, abstractmethod
import slippy.core as core
from numbers import Number
from slippy.contact._step_utils import make_interpolation_func
class _TransientSubModelABC(core._SubModelABC, ABC):
def __init__(self, name, requires, provides, transient_values, transient_names, interpolation_mode):
... | 39.971429 | 104 | 0.689778 | [
"MIT"
] | FrictionTribologyEnigma/slippy | slippy/contact/sub_models/_TransientSubModelABC.py | 1,399 | Python |
# -*- coding: utf-8 -*-
# Author: Jev Kuznetsov <jev.kuznetsov@gmail.com>
# License: BSD
"""
Toolset working with yahoo finance data
This module includes functions for easy access to YahooFinance data
Functions
----------
- `getHistoricData` get historic data for a single symbol
- `getQuote` get cur... | 29.485714 | 120 | 0.525748 | [
"BSD-3-Clause"
] | zhuoqiang/trading-with-python | lib/yahooFinance.py | 7,224 | Python |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# Yahoo! Finance market data downloader (+fix for Pandas Datareader)
# https://github.com/ranaroussi/yfinance
"""Yahoo! Finance market data downloader (+fix for Pandas Datareader)"""
from setuptools import setup, find_packages
# from codecs import open
import io
from os... | 34 | 82 | 0.630665 | [
"Apache-2.0"
] | Ryan-Qiyu-Jiang/yfinance | setup.py | 2,074 | Python |
""" render_fmo.py renders obj file to rgb image with fmo model
Aviable function:
- clear_mash: delete all the mesh in the secene
- scene_setting_init: set scene configurations
- node_setting_init: set node configurations
- render: render rgb image for one obj file and one viewpoint
- render_obj: wrapper function for r... | 39.181237 | 200 | 0.619286 | [
"MIT"
] | 12564985/DeFMO | renderer/render_fmo.py | 18,376 | Python |
import json
from urllib.parse import parse_qs
from urllib.parse import urlparse
from Cryptodome.PublicKey import RSA
from jwkest import b64e
from jwkest.jwk import RSAKey
from jwkest.jwk import load_jwks
from oic.extension.message import TokenIntrospectionResponse
from oic.extension.signed_http_req import SignedHttpR... | 29.384615 | 76 | 0.612803 | [
"Apache-2.0"
] | fsschmitt/pyoidc | src/oic/extension/pop.py | 4,202 | Python |
#!/usr/bin/python
from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate
from subprocess import *
from time import sleep, strftime
from datetime import datetime
from mpd import *
import threading
import signal
import sys
import os
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import json
PLAY=0
PAUS... | 26.398352 | 156 | 0.545218 | [
"Unlicense"
] | crami/pimp3clock | pimp3clock.py | 9,609 | Python |
from drdown.careline.models.model_checkitem import CheckItem
from drdown.careline.models.model_checklist import Checklist
from drdown.careline.models.model_procedure import Procedure
| 45.75 | 60 | 0.885246 | [
"MIT"
] | fga-eps-mds/2018.1-Dr-Down | drdown/careline/models/__init__.py | 183 | Python |
import json
from datetime import datetime
import jsonschema
import mock
import numpy
import pytest
import utils
from aa import js
EARLY_DATE = datetime(2001, 1, 1, 1, 1)
LATE_DATE = datetime(2010, 2, 3, 4, 5)
EMPTY_ARRAY = numpy.array((0,))
@pytest.fixture
def json_fetcher():
return js.JsonFetcher("localhost",... | 37.228916 | 86 | 0.771521 | [
"Apache-2.0"
] | philipp-leitl/aapy | tests/test_js.py | 3,090 | Python |
"""Backup handler
This script is contains the backup handling functions.
"""
import os
import time
import pickle
import shutil
from shutil import ignore_patterns
import pypianoroll
import numpy as np
def backup_pickle(experiment, stats):
''''
Back up handling function.
Arguments:
experiment -- Expe... | 30.014706 | 73 | 0.622244 | [
"MIT"
] | carolinscholl/SORN | utils/backup.py | 2,041 | Python |
from devices import network_devices
from napalm import get_network_driver
from pprint import pprint
def open_napalm_connection(device):
"""Funtion to open napalm connection and return connection object"""
# Copy dictionary to ensure original object is not modified
device=device.copy()
# Pop "platform"... | 25.878049 | 72 | 0.64279 | [
"Apache-2.0"
] | austind/pyplus-ons | day3/linting/exercise1.py | 1,061 | Python |
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 12 11:56:36 2017
Problemset1 - Problem 1
Note:
's' is given by system like s = 'azcbobobegghakl'
@author: coskun
"""
s = 'azcbobobegghakl'
# Paste your code into this box
nvl=0
for c in s:
if c=='a' or c=='e' or c=='i' or c=='o' or c=='u':
nvl += 1
print(... | 22 | 54 | 0.590909 | [
"MIT"
] | coshkun/6.00.1x-MITx-Course-Training-Lab-Notes | anaconda/6.00.1x.PSet1.P1.py | 352 | Python |
import psycopg2
# Returns connection to the DB
def get_sql_connection():
conn = psycopg2.connect(user="cqwhbabxmaxxqd",
password="a3063dc5aeec69b41564cd0f1e3c698e0ff9653385f3b87c0f113b70951eb5b3",
host="ec2-54-235-92-244.compute-1.amazonaws.com",
... | 35.083333 | 104 | 0.581948 | [
"MIT"
] | MishaVernik/StudentAttendance | Attendance/context/sql_connection.py | 421 | Python |
####################################################################################
# Jiten Dhandha, 2020 #
# CFit is a curve fitting tool in python, based on the method of least squares. #
# It comes equipped with some standard functions and a graphic... | 38.791267 | 140 | 0.550199 | [
"CC0-1.0"
] | JitenDhandha/CFit | Fitting.py | 36,425 | Python |
# -*- coding: utf-8 -*-
# @Author: jankincai
# @Date: 2021-01-26 23:18:43
# @Last Modified by: jankincai
# @Last Modified time: 2021-01-26 23:27:01
class LibpcapError(Exception):
"""Exception raised for errors in the libpcap.
"""
def __init__(self, message):
"""init
"""
self.... | 18.454545 | 50 | 0.573892 | [
"BSD-3-Clause"
] | caizhengxin/python-libpcap | pylibpcap/exception.py | 406 | Python |
import os
import numpy as np
import matplotlib.pyplot as plt
# import sys, os
# sys.path.append(os.path.join(os.path.dirname(__file__), 'utils'))
import process_data
import common
def plot_gt(Y_origin_data, pose_folder, preprocessed_folder, data_seqs, seq_sizes, dim="2d", save_graph=True, dataset="KITTI"):
star... | 44.526316 | 134 | 0.618794 | [
"MIT"
] | donghwijung/LoRCoN-LO | utils/plot.py | 3,384 | Python |
"""
Module for handling the custom Lua commands for the bot
"""
import lupa
import shlex
import time
from threading import Thread
from .utils import human_readable_time, ArgumentParser
from .http import Http, TupleData
from .timer import Interval, Delayed
from .chat import Chat
class CommandPermissionError(BaseExcep... | 29.426263 | 79 | 0.57339 | [
"MIT"
] | lietu/twitch-bot | bot/commandmanager.py | 14,566 | Python |
from typing import List, Optional, Union
from dataclasses import dataclass, field
## - - - - - - -
## userinfo.json
## - - - - - - -
@dataclass
class UserAddress:
formatted: str = ""
@dataclass
class UserInfoResponse:
group_ids: List[str] = field(default_factory=list)
sub: str = ""
given_name: str ... | 16.253731 | 71 | 0.636823 | [
"MIT"
] | mtag-dev/py-rest-stress-testing | frameworks/schema_dataclasses.py | 2,178 | Python |
#
# Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
#
import os
import unittest
from deephaven import kafka_consumer as ck
from deephaven.stream.kafka.consumer import TableType, KeyValueSpec
from tests.testbase import BaseTestCase
from deephaven import dtypes
class KafkaConsumerTestCase(BaseTestCase)... | 36.105991 | 94 | 0.5515 | [
"MIT"
] | lbooker42/deephaven-core | py/server/tests/test_kafka_consumer.py | 7,835 | Python |
import re
from base64 import b64decode
from datetime import datetime
from urllib.parse import urlparse
import marshmallow as ma
from app.objects.secondclass.c_link import Link
from app.utility.base_object import BaseObject
from app.utility.base_planning_svc import BasePlanningService
class Agent(BaseObject):
R... | 43.67033 | 118 | 0.626824 | [
"Apache-2.0"
] | zaphodef/caldera | app/objects/c_agent.py | 7,948 | Python |
__author__ = 'roehrig'
"""Satellite and reanalysis products
"""
| 16 | 36 | 0.734375 | [
"MIT"
] | JRoehrig/pywarsa | warsa/precipitation/satellite/__init__.py | 64 | Python |
#!/usr/bin/env python
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# ---------------------------------------------... | 34.666667 | 99 | 0.635121 | [
"MIT"
] | 00Kai0/azure-cli-extensions | src/connection-monitor-preview/setup.py | 1,976 | Python |
# ------------------------------------------------------------------------------
# CodeHawk Binary Analyzer
# Author: Henny Sipma
# ------------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2016-2020 Kestrel Technology LLC
# Copyright (c) 2020 Henny Si... | 36.375 | 80 | 0.634177 | [
"MIT"
] | kestreltechnology/CodeHawk-Binary | chb/util/dotutil.py | 3,201 | Python |
# qubit number=3
# total number=9
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 collection... | 27.215909 | 118 | 0.634238 | [
"BSD-3-Clause"
] | UCLA-SEAL/QDiff | data/p4VQE/R1/benchmark/startQiskit_Class82.py | 2,395 | Python |
# flake8: noqa
"""
OpenAPI definition
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
The version of the OpenAPI document: v0
Generated by: https://openapi-generator.tech
"""
__version__ = "0.6.0"
# import ApiClient
from good... | 29.071429 | 124 | 0.829238 | [
"MIT"
] | SubTachyon/gooddata-python-sdk | gooddata-afm-client/gooddata_afm_client/__init__.py | 814 | Python |
people = 30
cars = 40
trucks = 15
if cars > people:
print("We should take the cars.")
elif cars < people:
print("We should not take the cars.")
else:
print("We can't decide.")
if trucks > cars:
print("That's too many trucks.")
elif trucks < cars:
print("Maybe we could take the trucks.")
... | 24.2 | 50 | 0.621901 | [
"MIT"
] | AyeThandarAung/python-exercises | ex30.py | 484 | Python |
import RPi.GPIO as gpio
import time
from subprocess import Popen, PIPE, call
pin =38
gpio.setmode(gpio.BOARD)
gpio.setup(pin, gpio.IN, pull_up_down = gpio.PUD_UP)
PRESSED = 0
prev_state = 1
pressed_time = 0.1
skip_song_mode = False
try:
while True:
cur_state = gpio.input(pin)
if cur_state == PRESSED:
... | 24.75 | 53 | 0.60101 | [
"MIT"
] | pythononwheels/opentoni | test_taster5.py | 792 | Python |
from setuptools import setup
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()
setup(name='ssh_tarpit',
version='0.2.4',
description="SSH tarpit that slowly sends an endless ba... | 32.386364 | 73 | 0.586667 | [
"Unlicense"
] | trideeindhoven/ssh-tarpit | setup.py | 1,425 | Python |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from matplotlib import pyplot as plt
import tensorflow as tf
import seaborn as sb
import pandas as pd
import numpy as np
import math
import time
import cv2
import os
tf.reset_default_graph()
gpu_options = tf.G... | 33.239496 | 172 | 0.628871 | [
"MIT"
] | 136823xuewei/gait-recognition | classification/casiab_performance.py | 7,911 | Python |
"""
Parsing time durations from strings
This module provides a function that parses time durations from strings. It has
been copied from the django software, which comes with the following notes:
Copyright (c) Django Software Foundation and individual contributors.
All rights reserved.
Redistribution and use in sour... | 36.079646 | 80 | 0.651459 | [
"MIT"
] | lmenou/py-pde | pde/tools/parse_duration.py | 4,077 | Python |
class solution:
def twoSum(self,nums,target):
hash_map=dict()
# Python字典初始化{}性能比dict()好
for i,x in enumerate(nums):
if target-x in hash_map:
return [i,hash_map[target-x]]
hash_map[x]=i
| 29.222222 | 46 | 0.524715 | [
"MIT"
] | Sprinter1999/Algorithm | LeetCode/Leetcode-2019Summer/Leetcode001(a+b).py | 281 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2015-2017 Lionheart Software 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
... | 29.287671 | 74 | 0.66464 | [
"Apache-2.0"
] | lionheart/git-bigstore | setup.py | 2,138 | Python |
# -*- coding: utf-8 -*-
"""
test_searchadapters
~~~~~~~~~~~~~~~~~~~
Test the Web Support Package search adapters.
:copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from six import StringIO
from sphinx.websupport import WebSupport
from t... | 32.614286 | 77 | 0.673237 | [
"BSD-2-Clause"
] | zzqcn/sphinx-doc | tests/test_searchadapters.py | 2,283 | Python |
from __future__ import division, print_function, absolute_import
from subprocess import Popen, PIPE, STDOUT
import numpy as np
SZ = [2, 3, 4, 8, 12, 15, 16, 17, 32, 64, 128, 256, 512, 1024]
def gen_data(dt):
arrays = {}
if dt == np.float128:
pg = './fftw_longdouble'
elif dt == np.double:
... | 25.831169 | 77 | 0.577677 | [
"MIT"
] | 123972/PCA-nutricion | environment/lib/python3.8/site-packages/scipy/fftpack/tests/gen_fftw_ref.py | 1,989 | Python |
# coding: utf-8
import numpy as np
import csv
import codecs
import os
import glob
from collections import defaultdict
SPACE = " "
EMPTY = " "
INV_PUNCTUATION_CODES = {EMPTY:0, SPACE:0, ',':1, '.':2, '?':3, '!':4, '-':5, ';':6, ':':7, '...':8, '':0}
PUNCTUATION_VOCABULARY = {0:SPACE, 1:',', 2:'.', 3:'?', 4:'!', 5:'-', ... | 27.870968 | 128 | 0.658102 | [
"MIT"
] | LisanneWiengarten/Punctuation | utilities.py | 4,320 | Python |
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
def asbool(obj):
if isinstance(obj, str):
obj = obj.strip().lower()
if obj in ['true', 'yes', 'on', 'y', 't', '1']:
r... | 28.133333 | 84 | 0.5391 | [
"Apache-2.0"
] | Tezar/Assigment-generator | ita/web/beaker/converters.py | 844 | Python |
# Copyright (c) 2016 Universidade Federal Fluminense (UFF)
# Copyright (c) 2016 Polytechnic Institute of New York University.
# This file is part of noWorkflow.
# Please, consult the license terms in the LICENSE file.
"""Trial Model"""
from __future__ import (absolute_import, print_function,
div... | 35.357504 | 122 | 0.591549 | [
"MIT"
] | raffaelfoidl/noworkflow | capture/noworkflow/now/persistence/models/trial.py | 20,967 | Python |
import Tkinter as tk
class Combobox(tk.Label):
def __init__(self, master, choices=[], default=None, direction="down", arrowimage="default", **kwargs):
style = {"relief": "groove", "bg":"white"}
style.update(kwargs)
tk.Label.__init__(self, master, **style)
# options
if direc... | 35.953846 | 107 | 0.595208 | [
"MIT"
] | karimbahgat/AutoMap | dependencies/generate maps/pythongis/app/tk2/_othermisc/dropdown_works.py | 2,337 | Python |
from django.test import TestCase
from ..company.models import Company
from ..project.models import *
from .models import *
def create_contact_data(self):
self.company = Company.objects.create(schema="test", name="Test")
self.company.activate()
self.project = Project.objects.create(name="my project")
s... | 35.5 | 85 | 0.65493 | [
"BSD-3-Clause"
] | systori/systori | systori/apps/directory/test_models.py | 2,840 | Python |
#------------------Bombermans Team---------------------------------#
# Author : B3mB4m
# Concat : b3mb4m@protonmail.com
# Project : https://github.com/b3mb4m/Shellsploit
# LICENSE : https://github.com/b3mb4m/Shellsploit/blob/master/LICENSE
#------------------------------------------------------------------#
import ... | 50.883641 | 140 | 0.466683 | [
"MIT"
] | An-spectator/shellsploit-framework | shell/control.py | 44,167 | Python |
import numpy as np
from .State import State
from .Action import Action
'''
Includes blood glucose level proxy for diabetes: 0-3
(lo2, lo1, normal, hi1, hi2); Any other than normal is "abnormal"
Initial distribution:
[.05, .15, .6, .15, .05] for non-diabetics and [.01, .05, .15, .6, .19] for diabetics
Effect o... | 39.869427 | 89 | 0.584072 | [
"MIT"
] | GuyLor/gumbel_max_causal_gadgets_part2 | sepsisSimDiabetes/MDP.py | 12,519 | Python |
import random
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.metrics import mean_squared_error as mse
from sklearn import datasets
import unittest
import torch
from fastai.basic_train import Learner
from fastai.callbacks import OneCycleScheduler
from fastai.... | 32.228125 | 83 | 0.632406 | [
"MIT"
] | scribbler00/mtl-sps_ern-and-hps_taskembbedding | dies/dies/tests/test_regression.py | 10,313 | Python |
import argparse
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
from net.tf_net import \
calculate_accuracy, calculate_loss, \
create_simple_cnn_model, optimize_weights
from net.keras_net import simple_cnn
def train_keras(batch_size, epochs, n_classes):
# x_train return... | 38.355932 | 126 | 0.682943 | [
"MIT"
] | na018/DeepLearning | 00_MNIST-label/train.py | 4,526 | Python |
#!/usr/bin/env python3
from matplotlib.patches import Circle, Rectangle, ConnectionPatch
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import animation
from math import floor
Colors = ['green', 'purple', 'orange', 'red', 'blue', 'yellow']
class Animation:
def __init__(self, my_map, starts, g... | 41.706587 | 158 | 0.535822 | [
"CC0-1.0"
] | mirtorande/grpf-tool | visualize.py | 6,965 | Python |
from sense_hat import SenseHat
import time
sense = SenseHat()
while True:
x, y, z = sense.get_accelerometer_raw().values()
x=round(x * 100, 0)
y=round(y * 100, 0)
z=round(z * 100, 0)
print("x=%s, y=%s, z=%s" % (x, y, z))
time.sleep(2)
| 17.6 | 52 | 0.57197 | [
"CC0-1.0"
] | kajackdfw/python_rpi_sense_hat_demos | acceleration.py | 264 | Python |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from fcos_core.structures.bounding_box import BoxList
from fcos_core.structures.boxlist_ops import boxlist_nms
from fcos_core.structures.boxlist_ops import cat_boxlist
from ... | 39.479769 | 89 | 0.623865 | [
"BSD-2-Clause"
] | qilei123/FCOS | fcos_core/modeling/roi_heads/box_head/inference.py | 6,830 | Python |
from __future__ import annotations
import datetime
from functools import partial
from textwrap import dedent
from typing import TYPE_CHECKING
import warnings
import numpy as np
from pandas._libs.tslibs import Timedelta
import pandas._libs.window.aggregations as window_aggregations
from pandas._typing import (
Ax... | 33.889625 | 88 | 0.565203 | [
"BSD-3-Clause"
] | DrGFreeman/pandas | pandas/core/window/ewm.py | 30,704 | Python |
# -*- coding: utf-8 -*-
"""
Production Configurations
- Use Amazon's S3 for storing static files and uploaded media
- Use mailgun to send emails
- Use Redis for cache
"""
from __future__ import absolute_import, unicode_literals
from django.utils import six
from .common import * # noqa
# SECRET CONFIGURATION
# -... | 37.180952 | 106 | 0.6396 | [
"MIT"
] | c-rhodes/course_portal | config/settings/production.py | 3,904 | Python |
import torch
from mmcv.cnn import ConvModule
from torch import nn as nn
from mmdet3d.models.builder import build_loss
class VoteModule(nn.Module):
"""Vote module.
Generate votes from seed point features.
Args:
in_channels (int): Number of channels of seed point features.
vote_per_seed (... | 38.690647 | 79 | 0.57289 | [
"Apache-2.0"
] | BOURSa/mmdetection3d | mmdet3d/models/model_utils/vote_module.py | 5,378 | Python |
"""Import/export any formats supported by meshio."""
import meshio
import numpy as np
import skfem
MESH_TYPE_MAPPING = {
'tetra': skfem.MeshTet1,
'tetra10': skfem.MeshTet2,
'hexahedron': skfem.MeshHex1,
'hexahedron27': skfem.MeshHex2,
'wedge': skfem.MeshWedge1,
'triangle': skfem.MeshTri1,
... | 29.181818 | 79 | 0.527329 | [
"BSD-3-Clause"
] | bhaveshshrimali/scikit-fem | skfem/io/meshio.py | 7,062 | Python |
from __future__ import annotations
from abc import abstractmethod, ABC
from decimal import Decimal
from enum import Enum
from typing import Dict, cast
import numpy as np
# A few extra general types
from slim.simulation.lice_population import LicePopulation, GenoDistrib, GenoTreatmentValue,\
Alleles, GenoTreatmen... | 34.544503 | 115 | 0.677933 | [
"MIT"
] | magicicada/slim | slim/types/TreatmentTypes.py | 6,598 | Python |
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
Tests for L{twisted.logger._json}.
"""
from io import BytesIO, StringIO
from typing import IO, Any, List, Optional, Sequence, cast
from zope.interface import implementer
from zope.interface.exceptions import BrokenMethodImplementation
from z... | 37.600823 | 92 | 0.613002 | [
"MIT"
] | Chinmoy-Prasad-Dutta/scrapy_scraper | SCRAPE/Lib/site-packages/twisted/logger/test/test_json.py | 18,274 | Python |
# -*- coding: utf-8 -*-
###############################################################################
#
# RetrieveCoupon
# Retrieves a coupon with specified coupon id.
#
# Python versions 2.6, 2.7, 3.x
#
# Copyright 2014, Temboo Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not u... | 36.193182 | 138 | 0.686656 | [
"Apache-2.0"
] | jordanemedlock/psychtruths | temboo/Library/Stripe/Coupons/RetrieveCoupon.py | 3,185 | Python |
# coding=utf-8
# Copyright (c) 2019 Alibaba PAI team.
#
# 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 ... | 40.717391 | 91 | 0.657501 | [
"MIT"
] | NoLoPhe/Kaleido-BERT | easytransfer/losses/kd_loss.py | 3,746 | Python |
# -*- coding: utf-8 -*-
"""Look command."""
# Part of Clockwork MUD Server (https://github.com/whutch/cwmud)
# :copyright: (c) 2008 - 2017 Will Hutcheson
# :license: MIT (https://github.com/whutch/cwmud/blob/master/LICENSE.txt)
from .. import Command, COMMANDS
from ...characters import CharacterShell
@COMMANDS.regis... | 26.892857 | 73 | 0.640106 | [
"MIT"
] | whutch/atria | cwmud/core/commands/info/look.py | 753 | Python |
# coding: utf-8
#
# Copyright 2019 Amazon.com, Inc. or its affiliates. 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. A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "lice... | 26.676471 | 96 | 0.642227 | [
"Apache-2.0"
] | alexa-labs/alexa-apis-for-python | ask-smapi-model/ask_smapi_model/v1/skill/status.py | 1,814 | Python |
"""
Modified from
https://github.com/ikostrikov/pytorch-a2c-ppo-acktr/blob/master/storage.py
"""
import torch
from torch.utils.data.sampler import BatchSampler
from torch.utils.data.sampler import SubsetRandomSampler
class RolloutStorage(object):
def __init__(self, num_steps, num_processes, obs_shape, action_sp... | 46.934783 | 113 | 0.574494 | [
"MIT"
] | CoAxLab/AdaptiveDecisionMaking_2018 | ADMCode/snuz/ppo/storage.py | 6,477 | Python |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import collections
from django.db import migrations
import mptt
import mptt.managers
def copy_regulations(apps, schema_editor):
Regulation = apps.get_model('regcore', 'Regulation')
Document = apps.get_model('regcore', 'Document')
for reg i... | 28.769231 | 72 | 0.612872 | [
"CC0-1.0"
] | 18F/regulations-core | regcore/migrations/0012_migrate_documents.py | 5,236 | 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
__a... | 33.37415 | 170 | 0.63351 | [
"Apache-2.0"
] | pulumi/pulumi-azure-nextgen | sdk/python/pulumi_azure_nextgen/machinelearningservices/v20200601/get_workspace_connection.py | 4,906 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.