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
# -*- coding: utf-8 -*-
#
# Copyright 2020- IBM Inc. All rights reserved
# SPDX-License-Identifier: Apache2.0
#
"""
"""
from abc import ABC, abstractproperty, abstractmethod
class AbstractType(ABC):
@abstractproperty
def length(self):
pass
@abstractmethod
def __call__... | 16.68 | 53 | 0.657074 | [
"Apache-2.0"
] | ambitus/cbexplorer | cbexplorer/types/AbstractType.py | 417 | Python |
"""
Copyright (C) 2018-2019 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in wri... | 35.505618 | 85 | 0.67943 | [
"Apache-2.0"
] | ChinHuatAng/dldt | tools/calibration/process_dataset_callbacks/collect_results_callback.py | 3,160 | Python |
from django.shortcuts import render
from wiki.models import Page
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.shortcuts import get_object_or_404,render
class PageList(ListView):
"""
This view grabs all the pages out of the database
returns a... | 29.542857 | 79 | 0.675048 | [
"MIT"
] | ebonnecab/makewiki | wiki/views.py | 1,034 | Python |
import policy
import traceback
import logging
import monitoring
import itertools
from .policy_registry import GetConfig
def ApplyPolicies(g):
config = GetConfig()
enabled = config.get('enabled', True)
if enabled is not None and not enabled:
return
monitoring_db = monitoring.GetDatabase('spinbo... | 29.242424 | 76 | 0.516062 | [
"Apache-2.0"
] | pchinmay/spinnaker | spinbot/policy/executor.py | 965 | Python |
"""Polynomial model class used by agents for building stuff.
"""
from torch import nn, optim
import torch
import torch.nn.functional as F
from stock_trading_backend.agent.model import Model
class NNModel(nn.Module):
"""Torch neural network model.
"""
def __init__(self, num_inputs, num_hidden_layers, num... | 34.495495 | 89 | 0.648211 | [
"MIT"
] | iryzhkov/stock-trading-backend | stock_trading_backend/agent/neural_network_model.py | 3,829 | 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... | 53.663043 | 160 | 0.597731 | [
"Apache-2.0"
] | oracle/oci-ansible-collection | plugins/modules/oci_waas_access_rules_facts.py | 19,748 | Python |
import enum
import warnings
from optuna import exceptions
from optuna import logging
from optuna import type_checking
if type_checking.TYPE_CHECKING:
from datetime import datetime # NOQA
from typing import Any # NOQA
from typing import Dict # NOQA
from typing import Optional # NOQA
from optun... | 32.02507 | 99 | 0.604593 | [
"MIT"
] | VladSkripniuk/optuna | optuna/structs.py | 11,497 | 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 json
import warnings
import pulumi
import pulumi.runtime
from typing import Union
from .. import utilities, tables
class UsageP... | 46.524038 | 225 | 0.644105 | [
"ECL-2.0",
"Apache-2.0"
] | JakeGinnivan/pulumi-aws | sdk/python/pulumi_aws/apigateway/usage_plan.py | 9,677 | Python |
# -*- coding: utf-8 -*-
"""Tests for NullTask plugin."""
import unittest
from pomito.plugins.task import nulltask, TaskPlugin
class NullTaskTests(unittest.TestCase):
"""Tests for NullTask."""
def setUp(self):
self.task = nulltask.NullTask(None)
def test_nulltask_is_a_task_plugin(self):
... | 27.655172 | 67 | 0.724439 | [
"MIT"
] | codito/pomito | tests/plugins/task/test_nulltask.py | 802 | Python |
#!/usr/bin/python
# Copyright (c) 2017, 2020 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... | 33.905759 | 150 | 0.637431 | [
"Apache-2.0"
] | A7rMtWE57x/oci-ansible-collection | plugins/modules/oci_network_ip_sec_connection_device_status_facts.py | 6,476 | Python |
from plotly_study.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Font(_BaseTraceHierarchyType):
# color
# -----
@property
def color(self):
"""
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#f... | 34.268519 | 88 | 0.565973 | [
"MIT"
] | lucasiscovici/plotly_py | plotly_study/graph_objs/streamtube/hoverlabel/__init__.py | 11,103 | Python |
class MGDHCPSettings(object):
def __init__(self, session):
super(MGDHCPSettings, self).__init__()
self._session = session
def getNetworkCellularGatewaySettingsDhcp(self, networkId: str):
"""
**List common DHCP settings of MGs**
https://developer.cisco.com/meraki/api/... | 40.956522 | 166 | 0.636943 | [
"MIT"
] | NoFliesOnYou/dashboard-api-python | meraki/api/mg_dhcp_settings.py | 1,884 | Python |
"""Config Port Stats message tests."""
from pyof.v0x04.controller2switch.common import PortStats
from tests.test_struct import TestStruct
class TestPortStats(TestStruct):
"""Config Port Stats message tests."""
@classmethod
def setUpClass(cls):
"""Configure raw file and its object in parent class ... | 31.9375 | 75 | 0.702544 | [
"MIT"
] | smythtech/python-openflow-legacy | build/lib/tests/v0x04/test_controller2switch/test_port_stats.py | 511 | Python |
"""Report routes."""
import os
from urllib import parse
import bottle
import requests
from pymongo.database import Database
from database import sessions
from database.datamodels import latest_datamodel
from database.measurements import recent_measurements_by_metric_uuid
from database.reports import insert_new_repor... | 44.05036 | 114 | 0.709783 | [
"Apache-2.0"
] | Gamer1120/quality-time | components/server/src/routes/report.py | 6,123 | Python |
# Copyright 2019 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, ... | 33.474576 | 151 | 0.670524 | [
"Apache-2.0"
] | google-research/crest | third_party/augment_ops.py | 13,825 | Python |
from harry import get_harry_most_common_word
def test_get_harry_most_common_word():
top_word = get_harry_most_common_word()
assert type(top_word) == tuple
assert top_word[0] == 'dursley'
assert top_word[1] == 45 | 29.5 | 45 | 0.724576 | [
"MIT"
] | alex-vegan/100daysofcode-with-python-course | days/day101/Bite 18. Find the most common word/test_harry.py | 236 | Python |
"""
Scrape quotes, books and authors from ``Good Reads`` website.
"""
import bs4
from .utils import *
def get_author_name(soup):
"""Get the author's name from its main page.
Args:
soup (bs4.element.Tag): connection to the author page.
Returns:
string: name of the author.
Examples::... | 30.470738 | 108 | 0.600585 | [
"MIT"
] | arthurdjn/scrape-goodreads | scrapereads/scrape.py | 11,987 | Python |
from pyspark.sql import Column, DataFrame, SparkSession, functions
from pyspark.sql.functions import *
from py4j.java_collections import MapConverter
from delta.tables import *
import shutil
import threading
tableName = "tbltestpython"
# Enable SQL/DML commands and Metastore tables for the current spark session.
# W... | 35.986486 | 99 | 0.615096 | [
"Apache-2.0"
] | Kimahriman/delta | examples/python/quickstart_sql.py | 2,663 | Python |
import numpy as np
from sigman.analyzer import InvalidArgumentError
procedure_type = 'points'
description = (
"""Procedure calculate time of B point from equation:
RB = 1.233RZ-0.0032RZ^2-31.59
where RZ - time between R and dz/dt max [ms]
RB - time between R and B
Equation was proposed by D.L. Lozano in pa... | 26.931034 | 79 | 0.630602 | [
"MIT"
] | k-cybulski/sigman-project | procedures/points_B_ICG_Lozaano_Equation.py | 1,562 | Python |
"""Welcome to MLToolset, a package to simplify machine learning research!
Author: Ryan Eloff
Contact: ryan.peter.eloff@gmail.com
Date: May 2018
"""
from . import data
from . import nearest_neighbour
from . import neural_blocks
from . import siamese
from . import training
from . import utils
from ._globals import T... | 19.857143 | 73 | 0.786571 | [
"MIT"
] | rpeloff/multimodal-one-shot-learning | src/mltoolset/__init__.py | 417 | Python |
"""
This file implements the signature scheme from "Unique Ring Signatures: A Practical
Construction" by Matthew Franklin and Haibin Zhang
"""
import sys
import math
from random import randint
import hashlib
from libsig.AbstractRingSignatureScheme import AbstractRingSignatureScheme
#from AbstractRingSignatureScheme im... | 30.194268 | 144 | 0.528214 | [
"MIT"
] | vs-uulm/libsig_pets | libsig/FZZ_unique_ring_signature.py | 9,481 | Python |
import crcmod
from selfdrive.car.hyundai.values import CAR, CHECKSUM
hyundai_checksum = crcmod.mkCrcFun(0x11D, initCrc=0xFD, rev=False, xorOut=0xdf)
def create_lkas11(packer, car_fingerprint, bus, apply_steer, steer_req, cnt, enabled, lkas11, hud_alert,
lane_visible, left_lane_depar... | 43.395973 | 104 | 0.689453 | [
"MIT"
] | zzune/openpilot | selfdrive/car/hyundai/hyundaican.py | 6,466 | Python |
import torch
from facenet_pytorch import MTCNN, InceptionResnetV1
from torchvision import transforms
from Configs import Global_Config
IMAGE_SIZE = 220
mtcnn = MTCNN(
image_size=IMAGE_SIZE, margin=0, min_face_size=20,
thresholds=[0.6, 0.7, 0.7], factor=0.709, post_process=True,
device=Global_Config.device
... | 38.767442 | 102 | 0.673065 | [
"MIT"
] | YuGong123/ID-disentanglement-Pytorch | Models/Encoders/ID_Encoder.py | 1,667 | Python |
"""
Current-flow betweenness centrality measures for subsets of nodes.
"""
# Copyright (C) 2010-2011 by
# Aric Hagberg <hagberg@lanl.gov>
# Dan Schult <dschult@colgate.edu>
# Pieter Swart <swart@lanl.gov>
# All rights reserved.
# BSD license.
__author__ = """Aric Hagberg (hagberg@lanl.gov)"""
__all_... | 36.155303 | 80 | 0.629649 | [
"BSD-3-Clause"
] | AllenDowney/networkx | networkx/algorithms/centrality/current_flow_betweenness_subset.py | 9,545 | Python |
# Generated by Django 3.1.4 on 2021-09-28 13:49
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('store', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='payment',
name='paystack_response',
),... | 18.166667 | 47 | 0.590214 | [
"MIT"
] | Joetib/jshop | apps/store/migrations/0002_remove_payment_paystack_response.py | 327 | Python |
#!/usr/bin/python3
import functools
from copy import deepcopy
from .grammar import BASE_NODE_TYPES
class NodeBase:
"""Represents a node within the solidity AST.
Attributes:
depth: Number of nodes between this node and the SourceUnit
offset: Absolute source offsets as a (start, stop) tuple
... | 35.496403 | 97 | 0.588164 | [
"MIT"
] | danhper/py-solc-ast | solcast/nodes.py | 9,868 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from multiprocessing import Pool
import requests
PROCESS_POOL_SIZE = 10
REQUESTS = 10000
BASE_URL = "http://localhost:8888"
RESOURCE_NAME = "resource"
def f(process_number):
resource_name = RESOURCE_NAME
raw_body = '{"title": "%i", "lifetime": 300, "wait": 20}' ... | 30.259259 | 81 | 0.679315 | [
"MIT"
] | thefab/restful-distributed-lock-manager | tests/bomb1.py | 817 | Python |
# Copyright (c) 1996-2015 PSERC. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
"""Splits the gencost variable into two pieces if costs are given for Qg.
"""
from sys import stderr
from numpy import array, arange
def pqcost(gencost, ng, on... | 31.842105 | 77 | 0.66281 | [
"BSD-3-Clause"
] | AdrienGougeon/pandapower | pandapower/pypower/pqcost.py | 1,210 | Python |
""" Full assembly of the parts to form the complete network """
import torch.nn.functional as F
from .unet_parts import *
from .channels import C
class UNet3D(nn.Module):
def __init__(self, n_channels, n_classes, bilinear=True, apply_sigmoid_to_output=False):
super(UNet3D, self).__init__()
self.... | 34.4 | 124 | 0.582849 | [
"MIT"
] | mistermoutan/ModelsGenesis | pytorch/unet_3d/unet_model.py | 1,376 | 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 u... | 35.021739 | 76 | 0.620112 | [
"Apache-2.0"
] | AurelienLourot/neutron | neutron/conf/policies/security_group.py | 6,444 | Python |
import re
find_image_scheme = re.compile(r'(?P<image_construction><img\b[^>]*src="(?P<image_url>[^"]+?)"[^>]*?\/>)')
# find_link_around_image_scheme = re.compile(r"<a\b[^>]*>(.*?)<img\b(.*?)<\/a>")
def move_image_to_attachment(content, attachment_object):
# collect images from the post body
intext_image_l... | 28.074074 | 106 | 0.604222 | [
"BSD-3-Clause"
] | autogestion/pubgate-rssbot | rssbot/utils.py | 758 | Python |
import numpy as np
import matplotlib.pyplot as plt
import gym
import random
# hyper parameters
# test 1
# alpha = 0.5
# gamma = 0.95
# epsilon = 0.1
epsilon = 0.1
alpha = 0.1
gamma = 0.1
def update_sarsa_table(sarsa, state, action, reward, next_state, next_action, alpha, gamma):
'''
update sarsa state-action... | 31.910828 | 122 | 0.645709 | [
"MIT"
] | hadleyhzy34/reinforcement_learning | TD/double_q_learning.py | 5,010 | Python |
"""
Meta Data Extension for Python-Markdown
=======================================
This extension adds Meta Data handling to markdown.
See <https://Python-Markdown.github.io/extensions/meta_data>
for documentation.
Original code Copyright 2007-2008 [Waylan Limberg](http://achinghead.com).
All changes Copyright 200... | 30.316456 | 74 | 0.561169 | [
"MIT"
] | AzDan/Sac-Portal | venv/lib/python3.6/site-packages/markdown/extensions/meta.py | 2,395 | Python |
from datetime import datetime, timedelta
from typing import List, Optional
from django.conf import settings
from django.core.cache import cache
from django.utils.translation import ugettext as _
from celery.schedules import crontab
from celery.task import periodic_task, task
from celery.utils.log import get_task_logg... | 35.600823 | 114 | 0.715871 | [
"BSD-3-Clause"
] | akashkj/commcare-hq | corehq/apps/data_interfaces/tasks.py | 8,651 | Python |
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from hermes_python.hermes import Hermes
INTENT_HOW_ARE_YOU = "mikpan:how_are_you"
INTENT_GOOD = "bezzam:feeling_good"
INTENT_BAD = "bezzam:feeling_bad"
INTENT_ALRIGHT = "bezzam:feeling_alright"
INTENT_FILTER_FEELING = [INTENT_GOOD, INTENT_BAD, INTENT_ALRIGHT]
def main(... | 31.625 | 80 | 0.755599 | [
"MIT"
] | mikpan/amld19-snips-workshop | V2_action-how-are-you.py | 1,518 | Python |
"""Python 3.9.5"""
import cv2
import HandTrackingModule as htm
def thumbIncrementCheck(lmList: list[list[int]]) -> int:
"""Checks whether your thumb is up or not.
No matter what hand you use.
returns 1 if thumb is up else 0"""
count = 0
t_x = lmList[4][1]
p_x = lmList[17][1]
if t_x > p_x:... | 29.954023 | 94 | 0.506523 | [
"MIT"
] | laughingclouds/dt-mst-project | forOutput.py | 2,606 | Python |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 35.637413 | 97 | 0.580325 | [
"Apache-2.0"
] | IIMarch/mxnet | python/mxnet/gluon/nn/basic_layers.py | 15,431 | Python |
import numpy as np
np.random.seed(0)
from bokeh.io import curdoc
from bokeh.layouts import widgetbox, row, column
from bokeh.models import ColumnDataSource, Select, Slider
from bokeh.plotting import figure
from bokeh.palettes import Spectral6
from sklearn import cluster, datasets
from sklearn.neighbors import kneighb... | 31.473958 | 74 | 0.608307 | [
"BSD-3-Clause"
] | SiggyF/bokeh | examples/app/clustering/main.py | 6,043 | Python |
import csv
source_file = "Resources/budget_data.csv"
output_file = "Resources/budget_data_analysis.txt"
#initialize months counter, total income, decrease and increase in revenue amounts
number_of_months = 0 # to track the total number of months
income_total = 0 #variable to hold total income as we iterate through t... | 45.6875 | 128 | 0.691518 | [
"MIT"
] | abelgk/python-challenge | PyBank/main.py | 2,924 | Python |
# Copyright (C) 2010 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:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the ... | 38.279879 | 110 | 0.651306 | [
"Apache-2.0"
] | JavaScriptTesting/LJS | WebKit/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py | 25,303 | Python |
from io import BytesIO
import pytest
from app import app
def test_otter():
with open('./images/otter.jpeg', 'rb') as img:
img_string = BytesIO(img.read())
response = app.test_client().post('/predict', data={'file': (img_string, 'otter.jpeg')},
content_type="multipart/form-data")
assert ... | 32.636364 | 90 | 0.657382 | [
"MIT"
] | tadashi0713/circleci-demo-pytorch-api | tests/test_otter.py | 359 | Python |
################################################################################
#
# MIT License
#
# Copyright (c) 2020 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# ... | 42.875969 | 196 | 0.685952 | [
"MIT"
] | ROCmSoftwarePlatform/iGEMMgen | igemm_codegen.py | 5,531 | Python |
from __future__ import unicode_literals
from boto.ec2.instancetype import InstanceType
from moto.core.responses import BaseResponse
from moto.core.utils import camelcase_to_underscores
from moto.ec2.utils import instance_ids_from_querystring, filters_from_querystring, \
dict_from_querystring, optional_from_querystr... | 43.666667 | 130 | 0.555556 | [
"Apache-2.0"
] | adtsys-cloud/moto-aws-mock | moto/ec2/responses/instances.py | 28,296 | Python |
import urllib.parse
from functools import partial, wraps
from pathlib import Path
from drfs import config
from drfs.util import prepend_scheme, remove_scheme
def get_fs(path, opts=None, rtype="instance"):
"""Helper to infer filesystem correctly.
Gets filesystem options from settings and updates them with gi... | 26.697183 | 87 | 0.619889 | [
"MIT"
] | datarevenue-berlin/drfs | drfs/filesystems/util.py | 3,791 | Python |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 41.677686 | 110 | 0.614515 | [
"Apache-2.0"
] | AMS-Kepler/airflow | tests/cli/commands/test_plugins_command.py | 5,043 | Python |
"""Conversion tool from SQD to FIF.
RawKIT class is adapted from Denis Engemann et al.'s mne_bti2fiff.py.
"""
# Authors: Teon Brooks <teon.brooks@gmail.com>
# Joan Massich <mailsik@gmail.com>
# Christian Brodbeck <christianbrodbeck@nyu.edu>
#
# License: BSD (3-clause)
from collections import defaul... | 43.437759 | 79 | 0.58676 | [
"Apache-2.0"
] | alexisicte/aviate | venv/lib/python3.8/site-packages/mne/io/kit/kit.py | 41,874 | Python |
#!/usr/bin/python3
# --- 001 > U5W2P1_Task6_w1
def solution( n ):
if(n > 2 and n < 7 ):
return True;
else:
return False;
if __name__ == "__main__":
print('----------start------------')
n = 10
print(solution( n ))
print('------------end------------')
| 19.466667 | 40 | 0.445205 | [
"MIT"
] | MingjunGeng/Code-Knowledge | src/CodeLearn/plaintextCode/BloomTech/BTU5W1/U5W1P2_Task6_w1.py | 292 | Python |
from typing import Optional, Dict
from tabulate import tabulate
import pandas as pd
from mdrsl.utils.value_collection import ValueCollector
class MIDSObjectiveFunctionStatistics:
def __init__(self):
self.last_f0: Optional[int] = None
self.last_f1: Optional[int] = None
self.last_f2: Opti... | 35.409639 | 81 | 0.525859 | [
"Apache-2.0"
] | joschout/Multi-Directional-Rule-Set-Learning | mdrsl/rule_models/mids/objective_function/mids_objective_function_statistics.py | 5,878 | Python |
# uncompyle6 version 3.7.4
# Python bytecode 3.7 (3394)
# Decompiled from: Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)]
# Embedded file name: T:\InGame\Gameplay\Scripts\Server\objects\gardening\gardening_commands.py
# Compiled at: 2017-11-18 00:09:10
# Size of source mod 2**3... | 59.217391 | 237 | 0.769457 | [
"Apache-2.0"
] | velocist/TS4CheatsInfo | Scripts/simulation/objects/gardening/gardening_commands.py | 1,362 | Python |
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2015-2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to d... | 43.148148 | 79 | 0.621173 | [
"MIT"
] | omserta/xsocs | xsocs/gui/project/ScanPositionsItem.py | 3,495 | Python |
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time : 2022/2/9 12:09 下午
# @Author: zhoumengjie
# @File : tabledrawer.py
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from matplotlib.font_manager import FontProperties
def draw_table(columns_head:[], cell_vals=[]):
# 设置字体及负数
plt... | 26.588785 | 92 | 0.557118 | [
"MIT"
] | vandyzhou/wxcloudrun-django | wxcloudrun/common/tabledrawer.py | 2,969 | Python |
import os
from setuptools import find_packages, setup
this = os.path.dirname(os.path.realpath(__file__))
def read(name):
with open(os.path.join(this, name)) as f:
return f.read()
setup(
name='pyramid_pages',
version='0.0.5',
url='http://github.com/uralbash/pyramid_pages/',
author='Svint... | 30.866667 | 75 | 0.62491 | [
"MIT"
] | ITCase/ps_pages | setup.py | 1,389 | Python |
from .TapChanger import TapChanger
class RatioTapChanger(TapChanger):
'''
A tap changer that changes the voltage ratio impacting the voltage magnitude but not the phase angle across the transformer.
:tculControlMode: Specifies the regulation control mode (voltage or reactive) of the RatioTapChanger. Default: None... | 39.585366 | 143 | 0.74923 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | CIM-IEC/CIMpy | cimpy/cgmes_v2_4_15/RatioTapChanger.py | 1,623 | Python |
import torch
import math
from torch import nn, Tensor
from torch.nn import functional as F
from semseg.models.backbones import *
from semseg.models.modules.common import ConvModule
class SpatialPath(nn.Module):
def __init__(self, c1, c2) -> None:
super().__init__()
ch = 64
self.conv_7x7 =... | 36.940476 | 129 | 0.596197 | [
"MIT"
] | Apexsf/test | semseg/models/bisenetv1.py | 6,206 | Python |
# emacs: -*- mode: python; py-indent-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
# ex: set sts=4 ts=4 sw=4 et:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
# See COPYING file distributed along with the datalad package for the
# copyright and license terms.
#
# ## ### ### ... | 32.859834 | 123 | 0.616432 | [
"MIT"
] | AKSoo/datalad | datalad/utils.py | 87,210 | Python |
"""
ORY Keto
A cloud native access control server providing best-practice patterns (RBAC, ABAC, ACL, AWS IAM Policies, Kubernetes Roles, ...) via REST APIs. # noqa: E501
The version of the OpenAPI document: v0.0.0
Contact: hi@ory.sh
Generated by: https://openapi-generator.tech
"""
import re # ... | 40.405714 | 161 | 0.606845 | [
"Apache-2.0"
] | Stackwalkerllc/sdk | clients/keto/python/ory_keto_client/model/delete_ory_access_control_policy_internal_server_error.py | 7,071 | Python |
from io import BytesIO
from uniborg import util
from telethon import types
from telethon.errors import PhotoInvalidDimensionsError
from telethon.tl.functions.messages import SendMediaRequest
@borg.on(util.admin_cmd(r"^\.i$"))
async def on_file_to_photo(event):
await event.delete()
target = await event.get_r... | 29.975 | 75 | 0.676397 | [
"MPL-2.0"
] | anandvfc/UniBorg | stdplugins/file to img.py | 1,199 | Python |
#!/bin/python
import json
import re
import sys
from datetime import datetime
import dateutil.parser
from dateutil.tz import tzutc
from six.moves import range
from mtools.util.pattern import json2pattern
class DateTimeEncoder(json.JSONEncoder):
"""Custom datetime encoder for json output."""
def default(se... | 36.661055 | 125 | 0.54015 | [
"Apache-2.0"
] | sindbach/mtools | mtools/util/logevent.py | 32,665 | Python |
import subprocess
import sys
from distutils.version import LooseVersion
from re import fullmatch
def get_shell_version():
try:
for line in (
subprocess.check_output(["gnome-shell", "--version"]).decode().splitlines()
):
m = fullmatch(r"GNOME Shell (?P<version>[0-9.]+)", lin... | 23.78125 | 87 | 0.576873 | [
"Apache-2.0"
] | essembeh/gnome-extensions-cli | src/gnome_extensions_cli/utils.py | 761 | Python |
import functools
import warnings
def deprecated_alias(**aliases):
def deco(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
rename_kwargs(f.__name__, kwargs, aliases)
return f(*args, **kwargs)
return wrapper
return deco
def rename_kwargs(func_name, kwar... | 29.868421 | 95 | 0.5163 | [
"Apache-2.0"
] | ahmed-dj/bio-transformers | biotransformers/utils/deprecated.py | 1,135 | Python |
# -*- coding: utf-8 -*-
"""
Calculation of cumulant expressions for non-linear response functions
of the third order for a multilevel three band system.
"""
from quantarhei.symbolic.cumulant import Ugde, Uedg, Uged, Uegd #, ExpdV
from quantarhei.symbolic.cumulant import gg #, g1, g2
from quantarhei.symbolic.cumulan... | 24.616564 | 146 | 0.52947 | [
"MIT"
] | MichalPt/quantarhei | examples/symbolic/test_symbolic_8.py | 8,025 | Python |
# This example is inspired by https://github.com/dasguptar/treelstm.pytorch
import argparse, cPickle, math, os, random
import logging
logging.basicConfig(level=logging.INFO)
import numpy as np
from tqdm import tqdm
import mxnet as mx
from mxnet import gluon
from mxnet.gluon import nn
from mxnet import autograd as ag
... | 39.284884 | 112 | 0.636969 | [
"Apache-2.0"
] | ChidanandKumarKS/mxnet | example/gluon/tree_lstm/main.py | 6,757 | Python |
import time
from threading import Thread, Condition
class StingySpendy:
money = 100
cv = Condition()
def stingy(self):
for i in range(1000000):
self.cv.acquire()
self.money += 10
self.cv.notify()
self.cv.release()
print("Stingy Done")
d... | 23.264706 | 50 | 0.539823 | [
"MIT"
] | ajvill/multithreadinginpython | condition_variables/stingy_spendy_cond_variable.py | 791 | Python |
import os
import glob
import sys
from typing import Optional, List, Union
from .utils.utils import calc_mean_score, save_json, image_dir_to_json, image_file_to_json
from .handlers.model_builder import Nima
from deepinsight_iqa.common.utility import thread_safe_singleton, set_gpu_limit
from deepinsight_iqa.data_pipeline... | 32.942029 | 102 | 0.66564 | [
"Apache-2.0"
] | sandyz1000/deepinsight-iqa | deepinsight_iqa/nima/predict.py | 2,273 | Python |
import os
class MockRequests:
def __init__(self):
return
def get(self, source):
source_no_http = source.replace("http://","")
test_website_path = f"{os.path.dirname(os.path.abspath(__file__))}/test_data/test_website/{source_no_http}"
with open(test_website_path,'r') ... | 26.277778 | 116 | 0.621564 | [
"MIT"
] | OtGabaldon/multiSourceWordMap | tests/mock_requests.py | 473 | Python |
# qubit number=3
# total number=60
import numpy as np
from qiskit import QuantumCircuit, execute, Aer, QuantumRegister, ClassicalRegister, transpile, BasicAer, IBMQ
from qiskit.visualization import plot_histogram
from typing import *
from pprint import pprint
from math import log2
from collections import Counter
from... | 31.572072 | 140 | 0.637466 | [
"BSD-3-Clause"
] | UCLA-SEAL/QDiff | data/p3BR/R2/benchmark/startQiskit_QC292.py | 7,009 | Python |
import socket, threading, sys, traceback, os, tkinter
from ui import Ui_MainWindow
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5 import QtCore, QtGui, QtWidgets
from tkinter import *
from PIL import Image, ImageTk
from tkinter import messagebox, Tk
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_I... | 38.13 | 148 | 0.559577 | [
"MIT"
] | Aiemu/CourseCN-Proj-RTP | Task2/Client_dev.py | 11,439 | Python |
""" core app configuration """
import os
environment = os.getenv('LAMBTASTIC_ENV', 'development')
if environment == 'testing':
from .testing import *
elif environment == 'production':
from .production import *
else:
from .development import *
| 21.416667 | 56 | 0.696498 | [
"Unlicense"
] | ppold/lambtastic | settings/__init__.py | 257 | Python |
# -*- coding: utf-8 -*-
TIME_OUT = 60
EXCEPT_FILE = ['test.py','login.py','mix.py']
class Api(object):
login = "/api/users/login"
user_info="/api/users/info"
signin = "/api/users/sign/signIn"
map = "/api/RedEnvelope/updateUserMap"
find_redbag = "/api/RedEnvelope/findReds"
get_redbag = "/api/re... | 28 | 45 | 0.64011 | [
"MIT"
] | weigun/StressTest | config.py | 364 | Python |
"""
Copyright 2020 Inmanta
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 ... | 34.988235 | 118 | 0.697377 | [
"Apache-2.0"
] | inmanta/inmanta-core | tests/moduletool/test_python_dependencies.py | 2,974 | Python |
from __future__ import division
import fa
import sys
import os
from fa import chunker
if __name__ == "__main__":
from sys import stderr
import argparse
parser = argparse.ArgumentParser(description=(
"Create a set of synthetic genomes consisting "
"of subgroups per tax level. Some kmers are ... | 43.626087 | 77 | 0.568069 | [
"MIT"
] | dnbaker/bonsai | sim/main.py | 5,017 | Python |
# Copyright 2019 The TensorFlow Probability 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 o... | 26.838384 | 80 | 0.579601 | [
"Apache-2.0"
] | AI-App/TensorFlow-Probability | tensorflow_probability/python/internal/test_combinations_test.py | 2,657 | Python |
# -*- coding: utf-8 -*-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
#... | 34.907692 | 76 | 0.75584 | [
"Apache-2.0",
"BSD-2-Clause",
"MIT",
"ECL-2.0",
"BSD-3-Clause"
] | fengzhongzhu1621/XAirflow | airflow/executors/celery_executor.py | 2,353 | Python |
from django.conf.urls import url
from . import views
app_name = 'reports'
urlpatterns = [
# url(r'^graph/', views.graph, name='graph'),
url(r'^graph/', views.statistics, name='graph'),
url(r'^csv_export/', views.csv_export, name='csv_export'),
]
| 19.142857 | 63 | 0.641791 | [
"MIT"
] | peachman05/Pwcrew | reports/urls.py | 268 | Python |
"""Preview mixins for Zinnia views"""
from django.http import Http404
from django.utils.translation import ugettext as _
class EntryPreviewMixin(object):
"""
Mixin implementing the preview of Entries.
"""
def get_object(self, queryset=None):
"""
If the status of the entry is not PUBLI... | 32.884615 | 65 | 0.62924 | [
"BSD-3-Clause"
] | Admoroux/django-blog-zinnia | zinnia/views/mixins/entry_preview.py | 855 | Python |
from libs import reaction as reactioncommand
class Reaction(reactioncommand.AdminReactionAddCommand):
'''Retries a text command
**Usage**
React to the message you want to re-run with the retry emoji
(The emoji is server-defined; ask your fellow server members for the correct emoji)'''
def matches(self, react... | 32.066667 | 86 | 0.742204 | [
"MIT"
] | IdeaBot/dev-addons | retry.py | 481 | Python |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = "Marc-Olivier Buob, Maxime Raynal"
__maintainer__ = "Marc-Olivier Buob, Maxime Raynal"
__email__ = "{marc-olivier.buob,maxime.raynal}@nokia.com"
__copyright__ = "Copyright (C) 2020, Nokia"
__license__ = "BSD-3"
from collections imp... | 35.979592 | 72 | 0.708452 | [
"BSD-3-Clause"
] | nokia/PyBGL | pybgl/prune_incidence_automaton.py | 1,763 | Python |
"""Module containing examples of report builder functions and classes."""
from collections import OrderedDict
import numpy as np
def example_fn_build_report(report, pvarray):
"""Example function that builds a report when used in the
:py:class:`~pvfactors.engine.PVEngine` with full mode simulations.
Here ... | 32.895833 | 79 | 0.622863 | [
"BSD-3-Clause"
] | tcapelle/pvfactors | pvfactors/report.py | 3,158 | Python |
from mmcv.runner import load_checkpoint as mmcv_load_checkpoint
from mmcv.runner.checkpoint import load_url_dist
import urllib
mmskeleton_model_urls = {
'st_gcn/kinetics-skeleton': "https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmskeleton/models/st-gcn/st_gcn.kinetics-6fa43f73.pth",
'st_gcn/ntu-xsub': "h... | 47.638298 | 216 | 0.748995 | [
"Apache-2.0"
] | GlenGGG/DR-GCN | mmskeleton/utils/checkpoint.py | 2,239 | Python |
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 27 17:38:25 2020
@author: Wu Yichen
"""
from PIL import Image
import os
import os.path
import errno
import numpy as np
import sys
import pickle
import torch.utils.data as data
from torchvision.datasets.utils import download_url, check_integrity
impo... | 41.125348 | 149 | 0.5424 | [
"MIT"
] | WuYichen-97/Learning-to-Purify-Noisy-Labels-via-Meta-Soft-Label-Corrector | dataloader.py | 14,764 | Python |
import os
import torch
from typing import List
from dqc.utils.datastruct import CGTOBasis
__all__ = ["loadbasis"]
_dtype = torch.double
_device = torch.device("cpu")
def loadbasis(cmd: str, dtype: torch.dtype = _dtype,
device: torch.device = _device, requires_grad: bool = False) -> \
... | 31.647059 | 101 | 0.564436 | [
"Apache-2.0"
] | Jaikinator/dqc | dqc/api/loadbasis.py | 4,842 | Python |
import datetime
import threading
import contextlib
import pyotp
import qrcode
from errbot import BotPlugin, botcmd, arg_botcmd, cmdfilter
# OTP expires every hour
_OTP_EXPIRE = datetime.timedelta(hours=1)
_BASE_TIME = datetime.datetime(year=datetime.MINYEAR, month=1, day=1)
class otp(BotPlugin):
'''
... | 30.831461 | 92 | 0.676749 | [
"BSD-3-Clause"
] | hosom/jarvis | plugins/otp/otp.py | 5,488 | Python |
"""
WSGI config for kweetservice project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_... | 23.588235 | 78 | 0.790524 | [
"MIT"
] | teunw/JEA6-Kweeter | kweetservice/kweetservice/wsgi.py | 401 | Python |
lengths = {0: 0, 1: 1}
def sequenceLength(n: int) -> int:
global lengths
if n not in lengths:
if n % 2 == 0:
lengths[n] = sequenceLength(n//2) + 1
else:
lengths[n] = sequenceLength(3 * n + 1) + 1
return lengths[n]
def solution(n: int = 1000000) -> int:
result ... | 22.826087 | 56 | 0.531429 | [
"Unlicense"
] | gashev/algorithms | project-euler/14/solution.py | 525 | Python |
# coding=utf-8
# Copyright 2021 The HuggingFace Inc. team. 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 r... | 40.59154 | 132 | 0.663164 | [
"Apache-2.0"
] | AK391/transformers | src/transformers/models/convbert/modeling_tf_convbert.py | 58,533 | Python |
""" Third party api wrappers"""
import os
import json
import nexmo
import africastalking
username = os.getenv('africastalking_username')
api_key = os.getenv('africastalking_api_key')
africastalking.initialize(username, api_key)
sms = africastalking.SMS
class ProvidersWrapper:
""" Class with all the thirdy party ... | 27.592593 | 89 | 0.641611 | [
"MIT"
] | kwanj-k/sibsco | providers.py | 745 | Python |
import time
import cv2
import numpy as np
from collections import defaultdict
class Tracker(object):
def __init__(self, pLK=None):
if pLK is None:
# default LK param
pLK = self.pLK0()
self.lk_ = cv2.SparsePyrLKOpticalFlow_create(
**pLK)
self.tmp_ = de... | 31.15 | 83 | 0.505618 | [
"MIT"
] | yycho0108/MoRoL | core/track.py | 4,984 | Python |
import unittest
from PyStacks.PyStacks.template import templateCF
class TestTemplate(unittest.TestCase):
def test_templateCF_Route53Zone(self):
resources = {
'route53_zone': {
'testr53zone': {
'name': 'example.com',
'comment': 'testzone... | 32.734848 | 70 | 0.265448 | [
"MIT"
] | 0xack13/PyStacks | PyStacks/test/templates/test_route53.py | 4,321 | Python |
from escpos.printer import Usb
from pathlib import Path
image = Path("/tamamo-no-mae/me-cloudy.png")
printer = Usb(0x0416, 0x5011, 0, profile="ZJ-5870")
printer.image(image);
printer.cut()
# with printer() as that:
# that.write('Hello, world!\n\n')
# # 000000000111111111122222222223
# # 123... | 37.95 | 58 | 0.670619 | [
"MIT"
] | paulhoule/usb_receipt_printer | demo.py | 759 | Python |
import operator
import numpy
import pytest
import cupy
from cupy import testing
class TestArrayElementwiseOp:
@testing.for_all_dtypes_combination(names=['x_type', 'y_type'])
@testing.numpy_cupy_allclose(rtol=1e-6, accept_error=TypeError)
def check_array_scalar_op(self, op, xp, x_type, y_type, swap=Fals... | 34.835052 | 79 | 0.660328 | [
"MIT"
] | Onkar627/cupy | tests/cupy_tests/core_tests/test_ndarray_elementwise_op.py | 27,032 | Python |
def read_fasta(filename):
"""Returns a list of tuples of each header and sequence in a fasta (or multifasta) file.
first element in tuple is header and second the sequence.
Key Arguments:
filename -- fasta file.
"""
tmp_seq = None
seqs_list = []
with open(filename, 'r') as fasta... | 37.266667 | 118 | 0.589147 | [
"MIT"
] | Mirindi95/PrIDcon | pridcon/utils.py | 3,354 | Python |
from django import template
from home.models import Recipe, MixingAgent, Base, Ingredient, FacePack, CustomFacePack
import pdb
register = template.Library()
@register.inclusion_tag('facepack.html')
def facepack_display(item_id):
if not item_id:
return
mandatory = []
type = "primary"
for cfp in... | 31.952381 | 101 | 0.562842 | [
"MIT"
] | dev1farms2face/f2f | f2f/farms2face/home/templatetags/common_tags.py | 2,013 | 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/.
"""
FlowClient is a Python client to FlowAPI.
"""
from ._version import get_versions
__version__ = get_versions()["vers... | 26.221239 | 69 | 0.759703 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | Flowminder/FlowK | flowclient/flowclient/__init__.py | 2,963 | Python |
import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *
''' IMPORTS '''
import requests
# Disable insecure warnings
requests.packages.urllib3.disable_warnings()
API_KEY = demisto.getParam('APIKey')
SERVER_URL = 'https://analyze.intezer.com/api'
API_VERSION = '/v2-0'
BASE_... | 34.059028 | 118 | 0.672036 | [
"MIT"
] | Axonius/conten | Packs/Intezer/Integrations/IntezerV2/IntezerV2.py | 9,809 | Python |
from dataclasses import dataclass, field
from typing import List, Optional
@dataclass
class Regex:
att: Optional[str] = field(
default=None,
metadata={
"type": "Attribute",
"pattern": r"[\C\?a-c\?]+",
}
)
@dataclass
class Doc:
class Meta:
name = "d... | 17.178571 | 40 | 0.503119 | [
"MIT"
] | tefra/xsdata-w3c-tests | output/models/ms_data/regex/re_g18_xsd/re_g18.py | 481 | Python |
from django.db import models
from django.contrib.auth.models import AbstractBaseUser, \
BaseUserManager, PermissionsMixin
class UserManager(BaseUserManager):
def create_user(self, email, password=None, **extra_fields):
"""Creates and saves a new user"""
if n... | 31.128205 | 76 | 0.667216 | [
"MIT"
] | StoikovOleh/recipe-app-api | app/core/models.py | 1,214 | Python |
from django.apps import AppConfig
class EnquiriesConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'src.enquiries'
| 22 | 56 | 0.766234 | [
"BSD-3-Clause"
] | kkamara/django-app | src/enquiries/apps.py | 154 | Python |
# Copyright 2013 Hewlett-Packard Development Company, L.P.
# 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... | 41.608645 | 79 | 0.610411 | [
"Apache-2.0"
] | Rachit7194/ironic | ironic/tests/unit/db/test_nodes.py | 35,617 | Python |
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | 38.833846 | 100 | 0.598605 | [
"Apache-2.0"
] | DislabNJU/Spark | python/pyspark/sql/session.py | 25,242 | Python |
""" director subsystem's configuration
- config-file schema
- settings
"""
from typing import Dict
import trafaret as T
from aiohttp import ClientSession, web
from yarl import URL
from servicelib.application_keys import APP_CLIENT_SESSION_KEY, APP_CONFIG_KEY
APP_DIRECTOR_API_KEY = __name__ + ".director_api"... | 24.976744 | 78 | 0.679702 | [
"MIT"
] | KZzizzle/osparc-simcore | services/web/server/src/simcore_service_webserver/director/config.py | 1,074 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.