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 |
|---|---|---|---|---|---|---|---|---|
import pymongo
def connect_to_mongo(username="", password="", host="localhost", port=27017):
credentials = ""
if username and password:
credentials = f"{username}:{password}@"
connection_url = f"mongodb://{credentials}{host}:{port}"
return pymongo.MongoClient(connection_url)
| 30.2 | 77 | 0.692053 | [
"MIT"
] | stump-vote/stump-data-pipeline | src/stump_data_pipeline/mongo_client.py | 302 | Python |
from __future__ import division
import numpy as np
import sys
import os
import shutil
import vtk
from vtk.util.numpy_support import vtk_to_numpy
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import matplotlib.animation as animation
import matplotlib.colors as mcolors
import argparse... | 37.066667 | 164 | 0.601169 | [
"MIT"
] | brberg/stokes-crevasse-advection | plotting/thumbnails_warm.py | 6,672 | Python |
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import QColorDialog, QDialogButtonBox
BB = QDialogButtonBox
class ColorDialog(QColorDialog):
def __init__(self, parent=None):
super(ColorDialog, self).__init__(parent)
self.setOption(QColorDialog.ShowAlphaChannel)
... | 35.147059 | 70 | 0.680335 | [
"Apache-2.0"
] | 7eta/udk_labeler | view/libs/colorDialog.py | 1,195 | Python |
# Copyright (C) 2019 Google Inc.
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
"""Provides an HTML cleaner function with sqalchemy compatible API"""
import re
import HTMLParser
import bleach
# Set up custom tags/attributes for bleach
BLEACH_TAGS = [
'caption', 'strong', 'em', '... | 27.55814 | 78 | 0.646835 | [
"ECL-2.0",
"Apache-2.0"
] | VRolich/ggrc-core | src/ggrc/utils/html_cleaner.py | 2,370 | Python |
'''
This script includes:
1. ClassifierOfflineTrain
This is for offline training. The input data are the processed features.
2. class ClassifierOnlineTest(object)
This is for online testing. The input data are the raw skeletons.
It uses FeatureGenerator to extract features,
and then use ClassifierOffli... | 35.855856 | 97 | 0.629899 | [
"MIT"
] | eddylamhw/trAIner24 | utils/lib_classifier.py | 7,960 | Python |
#!/usr/bin/python
import time
import re
import os
class ScavUtility:
def __init__(self):
pass
def check(self, email):
regex = '^(?=.{1,64}@)[A-Za-z0-9_-]+(\\.[A-Za-z0-9_-]+)*@[^-][A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$'
if (re.search(regex, email)):
return 1
... | 29.567568 | 120 | 0.54479 | [
"Apache-2.0"
] | SCR-Hy3n4/Scavenger | classes/utility.py | 1,094 | Python |
#------------------------------------------------------------------------------
# Copyright (c) 2013, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-------------------------------------------------... | 31.714286 | 79 | 0.606982 | [
"BSD-3-Clause"
] | ContinuumIO/ashiba | enaml/enaml/widgets/calendar.py | 888 | Python |
# -*- coding: utf-8 -*-
"""
WOLFEYES'S FRAMEWORK
Python 3 / OpenCV 3
This file describes some TypeCheking decorators.
Might be useless, but allows for almost very precise type checking,
especially on keyworded args, which might help.
"""
# 'kargs' get the arguments and passes the decorator
def args(*types, **ktypes)... | 33.405405 | 132 | 0.588592 | [
"BSD-3-Clause"
] | TBIproject/WolfEye | WolfEyes/Utils/TypeChecker.py | 2,472 | Python |
import requests
def run(event, context):
#return event.get('url') + 'aaa'
r = requests.get(event.get('url'))
return r.text
#return '...**^^.This is a request test for url: {0}'.format(event.get('url')) | 27.375 | 82 | 0.611872 | [
"Apache-2.0"
] | owasp-sbot/pbx-gs-python-utils | _from_pydot/dev/request_test.py | 219 | Python |
import insightconnect_plugin_runtime
from .schema import StartPatchScanInput, StartPatchScanOutput, Input, Output, Component
# Custom imports below
from insightconnect_plugin_runtime.exceptions import PluginException
import polling2
class StartPatchScan(insightconnect_plugin_runtime.Action):
def __init__(self):
... | 46.223881 | 120 | 0.656765 | [
"MIT"
] | hashtagcyber/insightconnect-plugins | ivanti_security_controls/icon_ivanti_security_controls/actions/start_patch_scan/action.py | 3,097 | Python |
import configparser
import os
import re
import subprocess
import sys
import time
import utilities_common.cli as clicommon
from urllib.request import urlopen, urlretrieve
import click
from sonic_py_common import logger
from swsscommon.swsscommon import SonicV2Connector
from .bootloader import get_bootloader
from .comm... | 42.141907 | 150 | 0.669631 | [
"Apache-2.0"
] | Cosmin-Jinga-MS/sonic-utilities | sonic_installer/main.py | 38,012 | Python |
#!/usr/bin/python3
# encoding: utf-8
# Setup file for dulwich
# Copyright (C) 2008-2016 Jelmer Vernooij <jelmer@jelmer.uk>
try:
from setuptools import setup, Extension
except ImportError:
from distutils.core import setup, Extension
has_setuptools = False
else:
has_setuptools = True
from distutils.core i... | 32.153285 | 75 | 0.620204 | [
"Apache-2.0"
] | epopcop/dulwich | setup.py | 4,406 | Python |
import ctypes
import logging
import threading
import time
from contextlib import contextmanager
from queue import Queue
from typing import Any, Callable, Dict, Generator, Iterable, List, Optional, Tuple, Union, cast
import attr
import hypothesis
import hypothesis.errors
import requests
from _pytest.logging import LogC... | 35.88743 | 120 | 0.644657 | [
"MIT"
] | hlobit/schemathesis | src/schemathesis/runner/__init__.py | 19,128 | Python |
#!/usr/bin/env python
import os
import sys
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rateMyProf.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. A... | 33.875 | 74 | 0.688192 | [
"MIT"
] | DefCon-007/rateMyProfessor | rateMyProf/manage.py | 542 | Python |
# coding: utf-8
from __future__ import unicode_literals
import json
import re
import socket
from .common import InfoExtractor
from ..compat import (
compat_etree_fromstring,
compat_http_client,
compat_str,
compat_urllib_error,
compat_urllib_parse_unquote,
compat_urllib_parse_unquote_plus,
)
fr... | 42.512023 | 159 | 0.523756 | [
"Unlicense"
] | 2ShedsJackson/yt-dlp | yt_dlp/extractor/facebook.py | 30,062 | Python |
"""
The patch module allows for a grid to be created and for data to be
defined on that grid.
Typical usage:
-- create the grid
grid = Grid1d(nx)
-- create the data that lives on that grid
data = CellCenterData1d(grid)
bcObj = bcObject(xlb="reflect", xrb="reflect"_
data.registerVar("densi... | 28.161364 | 84 | 0.548463 | [
"BSD-3-Clause"
] | python-hydro/hydro_examples | multigrid/patch1d.py | 12,391 | Python |
#!/usr/bin/python
# coding: utf-8
# This file is execfile()d with the current directory set to its containing
# dir. Note that not all possible configuration values are present in this
# autogenerated file. All configuration values have a default; values that are
# commented out serve to show the default.
import sys
... | 32.072874 | 79 | 0.709038 | [
"MIT"
] | metaist/pageit | docs/conf.py | 7,922 | Python |
from chainerui.models.log import Log
def get_test_json():
return [
{
"loss": 100,
"epoch": 1,
},
{
"loss": 90,
"epoch": 2,
}
]
def test_log_serialize_numbers():
json_data = get_test_json()
logs = [Log(data) for data in j... | 25.692308 | 63 | 0.573653 | [
"MIT"
] | chainer/chainerui | tests/models_tests/test_log.py | 1,670 | Python |
#!/usr/bin/python3
"""
An example script that cleans up failed experiments by moving them to the archive
"""
import argparse
from datetime import datetime
from clearml_agent import APIClient
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--project", "-P", help="Project ID. Only clean up ex... | 31.183333 | 105 | 0.676644 | [
"Apache-2.0"
] | AzaelCicero/clearml-agent | examples/archive_experiments.py | 1,871 | Python |
# Token type identifiers.
AUT_INVALID = 0x00
AUT_OTHER_FILE32 = 0x11
AUT_OHEADER = 0x12
AUT_TRAILER = 0x13
AUT_HEADER32 = 0x14
AUT_HEADER32_EX = 0x15
AUT_DATA = 0x21
AUT_IPC = 0x22
AUT_PATH = 0x23
AUT_SUBJECT32 = 0x24
AUT_XATPATH = 0x25
AUT_PROCESS32 = 0x26
AUT_RETURN32 = 0x27
AUT_TEXT = 0x28
AUT_OPAQUE = 0x29
AUT_IN_A... | 23.825503 | 76 | 0.773803 | [
"MIT"
] | haginara/openbsm-python | bsm/audit_record.py | 3,550 | Python |
#
# Copyright 2016 The BigDL Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | 36.395349 | 114 | 0.723323 | [
"Apache-2.0"
] | ColossusChang/BigDL | python/friesian/example/dlrm/csv_to_parquet.py | 1,565 | Python |
from setuptools import setup
requirements = '''
flask
'''
name='imager'
console_scripts = f'''
pf-moves={name}.moves_gui:main
pf-flash={name}.flash:main
imager={name}.cli:main
'''
packages=f'''
{name}
{name}.utils
'''
setup(
name=name,
packages=packages.split(),
version='0.1',
... | 20.515152 | 81 | 0.660266 | [
"MIT"
] | pharmbio/imx-pharmbio-automation | setup.py | 678 | Python |
import numpy as np
import scipy
from scipy.stats import qmc
from scipy.stats import special_ortho_group
import matplotlib.pyplot as plt
from scipy.optimize import minimize
import warnings
from .ssp import SSP
class SSPSpace:
def __init__(self, domain_dim: int, ssp_dim: int, axis_matrix=None, phase_matrix=None,
... | 44.44 | 158 | 0.594317 | [
"MIT"
] | nsdumont/SemanticMapping | semanticmapping/sspspace.py | 15,554 | Python |
# -*- coding: utf-8 -*-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | 42.800948 | 87 | 0.62972 | [
"Apache-2.0"
] | LaudateCorpus1/python-datastore | google/cloud/datastore_v1/services/datastore/transports/grpc.py | 18,062 | Python |
from src.utils.config import config
import json
# import uuid
import requests
_NAMESPACE = "WS"
_VER_NAMESPACE = "WSVER"
_SAMPLE_NAMESPACE = "SMP"
# versioned and non-versioned index have same version
_SAMPLE_SET_INDEX_VERSION = 1
_SAMPLE_SET_INDEX_NAME = 'sample_set_' + str(_SAMPLE_SET_INDEX_VERSION)
_VER_SAMPLE_SET... | 36.417722 | 111 | 0.590024 | [
"MIT"
] | slebras/index_runner | src/index_runner/es_indexers/sample_set.py | 5,754 | Python |
from alipay import AliPay
from django.core.paginator import Paginator
from django.http import HttpResponseRedirect
from django.http import JsonResponse
from django.shortcuts import render
from django.utils.http import urlquote
from Qshop.settings import alipay_private_key_string, alipay_public_key_string
from Seller.v... | 29.986301 | 102 | 0.604568 | [
"MIT"
] | songdanlee/DjangoWorkSpace | Qshop/Buyer/views.py | 11,385 | Python |
import errno, os
from django.db import models
from django.http import Http404, HttpResponseServerError
from discodex.restapi.resource import Resource, Collection
from discodex.restapi.resource import (HttpResponseAccepted,
HttpResponseCreated,
... | 33.182292 | 85 | 0.578402 | [
"BSD-3-Clause"
] | dimazest/disco | contrib/discodex/lib/discodex/models.py | 6,371 | Python |
#Import Library
import warnings
import numpy as np
import datetime
from extract_data import *
from word_encoder import *
from sklearn import svm
from sklearn.ensemble import RandomForestClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn import tree
# send the extracted data availble from extract_data t... | 30.8 | 171 | 0.732767 | [
"MIT"
] | aksh4y/IMDb-Rating-Prediction | Project/algorithm.old.py | 2,002 | Python |
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="py-mcc-f1",
version="0.1.0",
author="Arthur Colombini Gusmão",
description="MCC-F1 Curve",
long_description=long_description,
long_description_content_type="text/markdown",
url="ht... | 26.423077 | 53 | 0.630277 | [
"MIT"
] | arthurcgusmao/py-mcc-f1 | setup.py | 688 | Python |
from __future__ import division
import databench
import math
import random
class Dummypi(databench.Analysis):
"""A dummy analysis."""
@databench.on
def connected(self):
yield self.data.init({'samples': 100000})
@databench.on
def run(self):
"""Run when button is pressed."""
... | 26.142857 | 79 | 0.527713 | [
"MIT"
] | phillipaug/Data-Analysis-General-repository | databench/analyses_packaged/dummypi/analysis.py | 1,281 | 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/.
"""
This script will be executed whenever a change is pushed to the
master branch. It will schedule multiple child tasks... | 39.854167 | 136 | 0.644668 | [
"MPL-2.0"
] | kglazko/focus-android | tools/taskcluster/schedule-master-build.py | 7,652 | Python |
from . import (
admin,
ban,
close,
contact,
copyright,
donate,
download,
emoji,
help,
legacy,
noop,
roll,
search,
settings,
shortlink,
start,
stop,
submit,
top_missed,
view,
vote,
)
__all__ = ['admin', 'ban', 'contact', 'copyright', 'c... | 18.071429 | 98 | 0.51581 | [
"Unlicense"
] | RobbiNespu/hyperboria | nexus/bot/handlers/__init__.py | 506 | Python |
# Copyright 2018 Xanadu Quantum Technologies 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 agre... | 32.896657 | 100 | 0.530537 | [
"Apache-2.0"
] | wongwsvincent/pennylane-cirq | tests/test_expval.py | 10,823 | Python |
##
# @filename : epd4in2b.py
# @brief : Implements for Dual-color e-paper library
# @author : Yehui from Waveshare
#
# Copyright (C) Waveshare August 15 2017
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documn... | 35.75 | 81 | 0.543357 | [
"MIT"
] | Richard-Kirby/sema_clock | display/epd4in2b.py | 7,150 | Python |
# -*- coding: utf-8 -*-
"""This module is a stub for classes related to vulnerability exposure scores.
Copyright:
(c) 2022 Illumio
License:
Apache2, see LICENSE for more details.
"""
from dataclasses import dataclass
from illumio.util import MutableObject
@dataclass
class Vulnerability(MutableObject):
... | 17.842105 | 78 | 0.731563 | [
"Apache-2.0"
] | dsommerville-illumio/illumio-py | illumio/vulnerabilities/vulnerability.py | 339 | Python |
import fileinput
from itertools import permutations
SEQ = [int(x) for x in fileinput.input()]
LEN = 25
for i in range(LEN, len(SEQ)):
for x, y in permutations(SEQ[i-LEN:i], 2):
if x + y == SEQ[i]:
break
else:
INVALID = SEQ[i]
print "Part 1:", INVALID
break
for n in... | 22 | 62 | 0.529644 | [
"MIT"
] | iKevinY/advent | 2020/day09.py | 506 | Python |
import logging
import os
from pathlib import Path
import typing
from logging.handlers import RotatingFileHandler
from dotenv import load_dotenv
import services.pv_simulator.constants as constants
from services.pv_simulator.main_loop import MainLoop
from services.pv_simulator.mq_receiver import MQReceiver, MQReceiverF... | 36.675676 | 110 | 0.695652 | [
"MIT"
] | reynierg/pv_simulator_challenge | services/pv_simulator/main.py | 2,714 | Python |
from .tools import pair, check_sizes
from .dcn_v2 import deform_conv2d_jt
from .init import trunc_normal_ | 35 | 36 | 0.847619 | [
"MIT"
] | liuruiyang98/Jittor-MLP | models_jittor/utils/__init__.py | 105 | Python |
# -*- coding: utf-8 -*-
from __future__ import print_function
import argparse
import aerospike
from aerospike import exception as e
try:
from aerospike_helpers.operations import map_operations as mh
except:
pass # Needs Aerospike client >= 3.4.0
import datetime
import pprint
import random
import sys
import ti... | 26.185 | 82 | 0.618675 | [
"MIT"
] | aerospike-examples/modeling-user-segmentation | trim_segments.py | 5,237 | Python |
import copy
from enum import Enum
from jinja2 import Template
from typing import List
from dispatch.conversation.enums import ConversationButtonActions
from dispatch.incident.enums import IncidentStatus
from .config import (
DISPATCH_UI_URL,
INCIDENT_RESOURCE_CONVERSATION_REFERENCE_DOCUMENT,
INCIDENT_RE... | 33.210526 | 158 | 0.712305 | [
"Apache-2.0"
] | oliverzgy/dispatch | src/dispatch/messaging.py | 17,668 | Python |
import random
import copy
from collections import defaultdict
from collections import deque
from collections import namedtuple
from matplotlib import pyplot as plt
import numpy as np
class Q():
def __init__(self, n_actions, observation_space, bin_size, low_bound=None, high_bound=None, initial_mean=0.0, initial_s... | 36.664706 | 145 | 0.574683 | [
"MIT"
] | cisc474projectgroup/cartpole-q-learning | agent.py | 6,233 | Python |
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2015-2018 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... | 37.830769 | 79 | 0.697031 | [
"MIT"
] | kif/freesas | freesas/__init__.py | 2,461 | Python |
import pytest
import activeLearning as tP
def test_sayHello():
assert tP.sayHello() == 'Hello World'
assert tP.sayHello('Sankha') == 'Hello Sankha'
assert tP.sayHello(-1) == 'Hello -1'
return
| 23.222222 | 50 | 0.669856 | [
"MIT"
] | sankhaMukherjee/activeLearning | tests/test_activeLearning.py | 209 | Python |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
class SubCommand(object):
name = NotImplementedError("Please add 'name' member in your SubCommand")
help = NotImplementedError("Please add 'help' member in your SubCommand")
def addParser(self, pa... | 35.533333 | 91 | 0.765478 | [
"BSD-3-Clause"
] | Stibbons/python-project-bootstrap | src/ppb/cli/sub_cmd/_sub_command.py | 533 | Python |
def encrypt():
message = raw_input("Enter the message you want to encrypt")
ascii_message = [ord(char)+3 for char in message]
encrypt_message = [ chr(char) for char in ascii_message]
print ''.join(encrypt_message)
def decrypt():
message = raw_input("Enter the message you want to decrypt")
ascii_message =... | 35.88 | 124 | 0.653289 | [
"MIT"
] | Ena-Sharma/Meraki_Solution | Debugging-4/cipher2_0.py | 897 | Python |
with frontend.signin():
frontend.page("repositories", expect={ "document_title": testing.expect.document_title(u"Repositories"),
"content_title": testing.expect.paleyellow_title(0, u"Repositories"),
"pageheader_links": testing.exp... | 81.142857 | 112 | 0.473592 | [
"Apache-2.0"
] | SyuTingSong/critic | testing/tests/001-main/001-empty/002-authenticated/008-repositories.py | 568 | Python |
from jgsnippets.strings.encoding import clean_encoding
from jgsnippets.strings.format import jprint, pprint | 53.5 | 54 | 0.878505 | [
"MIT"
] | jgontrum/jgsnippets | jgsnippets/strings/__init__.py | 107 | Python |
"""Queuing Search Algorithm.
"""
import copy
import numpy as np
import opytimizer.math.random as r
import opytimizer.utils.constant as c
import opytimizer.utils.logging as l
from opytimizer.core import Optimizer
logger = l.get_logger(__name__)
class QSA(Optimizer):
"""A QSA class, inherited from Optimizer.
... | 35.446991 | 100 | 0.546035 | [
"Apache-2.0"
] | anukaal/opytimizer | opytimizer/optimizers/social/qsa.py | 12,371 | Python |
# coding: utf-8
#
# Copyright 2022 :Barry-Thomas-Paul: Moss
#
# 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 applicab... | 34.259259 | 109 | 0.672973 | [
"Apache-2.0"
] | Amourspirit/ooo_uno_tmpl | ooobuild/dyn/ucb/content_event.py | 1,850 | Python |
# A lot of failures in these tests on Mac OS X.
# Byte order related?
import unittest
from ctypes import *
from ctypes.test import need_symbol
import _ctypes_test
class CFunctions(unittest.TestCase):
_dll = CDLL(_ctypes_test.__file__)
def S(self):
return c_longlong.in_dll(self._dll, "la... | 37.051643 | 89 | 0.628865 | [
"Apache-2.0"
] | BirknerAlex/cloudbase-init-installer-1 | Python36_x64_Template/Lib/ctypes/test/test_cfuncs.py | 7,892 | Python |
# coding: utf-8
# Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may c... | 32 | 245 | 0.680458 | [
"Apache-2.0",
"BSD-3-Clause"
] | LaudateCorpus1/oci-python-sdk | src/oci/network_load_balancer/models/work_request_log_entry_collection.py | 2,272 | Python |
class Solution:
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
lookup = dict(((v, i) for i, v in enumerate(nums)))
return next(( (i+1, lookup.get(target-v)+1)
for i, v in enumerate(nums)
... | 29.266667 | 59 | 0.498861 | [
"MIT"
] | mengyangbai/leetcode | array/twosum.py | 459 | Python |
#
# @lc app=leetcode id=102 lang=python3
#
# [102] Binary Tree Level Order Traversal
#
# @lc code=start
# Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
from typing import List, Optional... | 26.151515 | 70 | 0.543453 | [
"MIT"
] | ryderfang/LeetCode | Difficulty/Medium/102.binary-tree-level-order-traversal.py | 863 | Python |
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------... | 42.447826 | 116 | 0.679402 | [
"MIT"
] | 21m57/azure-cli | src/azure-cli/azure/cli/command_modules/monitor/operations/metric_alert.py | 9,763 | Python |
# -*- coding: utf-8 -*-
# cox regression
if __name__ == "__main__":
import pandas as pd
import time
import numpy as np
from lifelines import CoxPHFitter
from lifelines.datasets import load_rossi, load_regression_dataset
reps = 1
df = load_rossi()
df = pd.concat([df] * reps)
cp_br... | 31.043478 | 96 | 0.689076 | [
"MIT"
] | ManuelaS/lifelines | perf_tests/cp_perf_test.py | 714 | Python |
# Copyright 2010 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | 33.100551 | 79 | 0.624402 | [
"Apache-2.0"
] | isabella232/nova | nova/tests/unit/api/openstack/fakes.py | 24,031 | Python |
# made by @Eviral
from . import *
@bot.on(admin_cmd(pattern="indanime(.*)"))
async def xd(event):
await event.edit("wishing to all🇮🇳🇮🇳...")
event.pattern_match.group(1)
async for tele in borg.iter_dialogs():
if tele.is_group:
chat = tele.id
lol = 0
done = ... | 38.225806 | 488 | 0.357806 | [
"MIT"
] | aksr-aashish/FIREXUSERBOT | userbot/plugins/indanime.py | 1,969 | Python |
"""Support for Aqualink temperature sensors."""
from __future__ import annotations
from openpeerpower.components.sensor import DOMAIN, SensorEntity
from openpeerpower.config_entries import ConfigEntry
from openpeerpower.const import DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
from openpeerpower.core import... | 29.166667 | 87 | 0.662286 | [
"Apache-2.0"
] | OpenPeerPower/core | openpeerpower/components/iaqualink/sensor.py | 1,750 | Python |
"""
Copyright (C) 2020 Piek Solutions LLC
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
... | 33.512739 | 756 | 0.566949 | [
"BSD-3-Clause"
] | papaya-iot/papaya-examples | python/papaya_i2chttpinst.py | 10,523 | Python |
# You should modify this for your own use.
# In particular, set the FQDN to your domain name, and
# pick and set a secure SECRET_KEY. If you are going
# to run HA, you will want to modify the SQLALCHEMY
# variables to point to your shared server rather than
# SQLite3.
import os
ENV = os.environ.get("ENV", "dev")
SECR... | 30.3 | 54 | 0.745875 | [
"MIT"
] | bortels/awsfed | app/config.py | 606 | Python |
# Copyright 2009-2015 Eucalyptus Systems, Inc.
#
# Redistribution and use of this software 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 ... | 49.5 | 78 | 0.743222 | [
"MIT"
] | cirobessa/receitas-aws | paws/lib/python2.7/site-packages/euca2ools-3.4.1_2_g6b3f62f2-py2.7.egg/euca2ools/commands/iam/deleteaccount.py | 1,881 | Python |
# evaluate cnn for monthly car sales dataset
from math import sqrt
from numpy import array
from numpy import mean
from numpy import std
from pandas import DataFrame
from pandas import concat
from pandas import read_csv
from sklearn.metrics import mean_squared_error
from keras.models import Sequential
from keras.layers... | 30.974359 | 84 | 0.74117 | [
"MIT"
] | gdepalma93/bright-athlete-academy | Resources/books/deep_learning_time_series_forecasting/code/chapter_14/03_cnn_forecast_model.py | 3,624 | Python |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import cv2
import numpy as np
from progress.bar import Bar
import time
import torch
import os
try:
from external.nms import soft_nms
except:
print('NMS not imported! If you need it,'
' do \n cd $Ce... | 38.513514 | 90 | 0.638363 | [
"MIT"
] | Wastoon/XinTong_CenterNet | src/lib/detectors/ctdet.py | 4,275 | Python |
import abc
from abc import ABCMeta
from typing import Callable
from typing import Iterator
from typing import List
from typing import Optional
from xsdata.codegen.models import Attr
from xsdata.codegen.models import Class
from xsdata.models.config import GeneratorConfig
from xsdata.utils.constants import return_true
... | 27.25 | 85 | 0.67491 | [
"MIT"
] | amal-khailtash/xsdata | xsdata/codegen/mixins.py | 2,507 | Python |
#!/usr/bin/python
import gdbm
import sys
import os
db_filename = "aclhistory.db"
example_filename = "HOMEOFFICEROLL3_20180521.CSV"
example_status = "D"
if len(sys.argv) != 3:
scriptname = os.path.basename(str(sys.argv[0]))
print "usage:", scriptname, "<FILENAME>", "<STATUS>"
print "\t Pass in the filename and sta... | 27 | 90 | 0.702427 | [
"MIT"
] | UKHomeOffice/dq-ssm_ingest | ADT/aclhistory-edit.py | 783 | Python |
from Tree import TreeNode
def zdir(root):
if root[0] == 0:
return 0 #left
elif root[1] ==0:
return 1 #right
else:
return 2 #nothing
def add_nodes(root, nodes):
for i in range(0,len(nodes)):
if nodes[i][0] == root.gfv():
root.addChild(add_nodes(TreeNode(nodes[i], 0), nodes[0:i] + nodes[i+1:]))
eli... | 23.634146 | 90 | 0.593395 | [
"MIT"
] | JanStoltman/100DaysOfCode | AdventOfCode/Day24.py | 969 | Python |
"""
Django settings for project project.
Generated by 'django-admin startproject' using Django 1.8.1.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
import djang... | 28.016807 | 74 | 0.695861 | [
"Apache-2.0"
] | AlexMeier99/s2i-python-container | examples/django-different-port-test-app/project/settings.py | 3,334 | Python |
from flask import current_app, render_template
from flask_restful import Resource, reqparse
from flask_mail import Message
from utils.authorizations import admin_required
from models.user import UserModel
class Email(Resource):
NO_REPLY = "noreply@codeforpdx.org" # Should this be dwellingly address?
parser ... | 33.433962 | 88 | 0.667607 | [
"MIT"
] | donovan-PNW/dwellinglybackend | resources/email.py | 1,772 | Python |
# coding=utf-8
"""
API for dataset indexing, access and search.
"""
from __future__ import absolute_import
import logging
from cachetools.func import lru_cache
from datacube import compat
from datacube.model import Dataset, DatasetType, MetadataType
from datacube.utils import InvalidDocException, check_doc_unchanged... | 36.196481 | 120 | 0.606741 | [
"Apache-2.0"
] | cronosnull/agdc-v2 | datacube/index/_datasets.py | 24,690 | Python |
import discord
import io
import aiohttp
from aiohttp import request, ClientSession
from src.embeds.image_embed import ImageEmbed
async def request_canvas_image(ctx, url, member: discord.Member = None, params={}, is_gif=False):
params_url = "&" + "&".join(["{}={}".format(k, v)
for k... | 40.72 | 129 | 0.556483 | [
"MIT"
] | alejandrodlsp/grogu-bot | src/helpers/api_handler.py | 2,036 | Python |
"""Configuration file for the Sphinx documentation builder.
This file only contains a selection of the most common options. For a full
list see the documentation:
https://www.sphinx-doc.org/en/master/usage/configuration.html
"""
import configparser
# -- Path setup -------------------------------------------... | 32.587719 | 82 | 0.655989 | [
"MIT"
] | Aeolun/sqlfluff | docs/source/conf.py | 3,715 | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 1999-2021 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-... | 32.461538 | 79 | 0.646919 | [
"Apache-2.0"
] | Alfa-Shashank/mars | mars/tensor/arithmetic/hypot.py | 2,532 | Python |
from enum import Enum
class IndexMethod(str, Enum):
"""
Used to specify the index method for a
:class:`Column <piccolo.columns.base.Column>`.
"""
btree = "btree"
hash = "hash"
gist = "gist"
gin = "gin"
def __str__(self):
return f"{self.__class__.__name__}.{self.name}"
... | 18.6 | 55 | 0.594086 | [
"MIT"
] | gmos/piccolo | piccolo/columns/indexes.py | 372 | Python |
# -*- coding: utf-8 -*-
#
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law... | 38.113208 | 120 | 0.70297 | [
"Apache-2.0"
] | MShaffar19/python-language | samples/v1/language_entities_gcs.py | 4,040 | Python |
# coding=utf-8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import copy
import logging
import math
import torch
import torch.nn as nn
import torch.nn.functional as nnf
from torch.nn import Dropout, Softmax, Linear, Conv3d, LayerNorm
from torch... | 36.311258 | 200 | 0.610615 | [
"MIT"
] | junyuchen245/ViT-V-Net_for_3D_Image_Registration | ViT-V-Net/models.py | 16,449 | Python |
import keras
from keras.datasets import mnist
# input image dimensions
img_rows, img_cols = 28, 28
input_shape = (img_rows, img_cols, 1)
num_classes = 10
def get_mnist_data():
# the data, shuffled and split between train and test sets
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train = x_... | 31.448276 | 70 | 0.710526 | [
"MIT"
] | Stochastic13/keract | examples/data.py | 912 | Python |
# -*- coding: utf-8 -*-
import random
import itertools
from collections import defaultdict
class Chat(object):
cache_size = 200
# user_num = list(range(1, 100))
# random.shuffle(user_num)
colors = ['赤', '青', '黄', '緑', '紫', '黒', '茶', '灰色', '金', '銀']
fruits = ['りんご', 'みかん', 'メロン', 'パイナップル', 'ぶどう', ... | 31.923077 | 86 | 0.64257 | [
"MIT"
] | Hironsan/Brain_Hacker | handlers/brainstorming/chat.py | 1,331 | Python |
import imp
from os import path
from setuptools import setup
VERSION = imp.load_source(
'version',
path.join('.',
'zunzuncito',
'version.py'))
VERSION = VERSION.__version__
readme = open('README.rst', 'r')
setup(
name='zunzuncito',
version=VERSION,
author='Nicolas Embr... | 29.404762 | 78 | 0.622672 | [
"BSD-3-Clause"
] | nbari/zunzuncito | setup.py | 1,235 | Python |
"""
Argo Server API
You can get examples of requests and responses by using the CLI with `--gloglevel=9`, e.g. `argo list --gloglevel=9` # noqa: E501
The version of the OpenAPI document: VERSION
Generated by: https://openapi-generator.tech
"""
import re # noqa: F401
import sys # noqa: F401
from ... | 47.375 | 228 | 0.579621 | [
"Apache-2.0"
] | 2kindsofcs/argo-workflows | sdks/python/client/openapi_client/model/fc_volume_source.py | 12,886 | Python |
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 32.405405 | 74 | 0.764804 | [
"Apache-2.0"
] | maksonlee/tradefed_cluster | tradefed_cluster/device_blocker.py | 1,199 | Python |
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or... | 47.233553 | 101 | 0.548088 | [
"Apache-2.0"
] | SpinQTech/SpinQKit | qiskit/circuit/library/grover_operator.py | 16,719 | Python |
import numpy as np
import copy, operator
from qtensor.optimisation.Optimizer import OrderingOptimizer
from qtensor import utils
from functools import reduce
import networkx as nx
import qtree
def reducelist(f, lst, x=0):
prev = x
for i in lst:
prev = f(prev, i)
yield prev
class RGreedyOptimize... | 34.205128 | 90 | 0.552099 | [
"BSD-3-Clause"
] | DaniloZZZ/QTensor | qtensor/optimisation/RGreedy.py | 2,668 | Python |
import os
import json
__author__ = 'Manfred Minimair <manfred@minimair.org>'
class JSONStorage:
"""
File storage for a dictionary.
"""
file = '' # file name of storage file
data = None # data dict
indent = ' ' # indent prefix for pretty printing json files
def __init__(self, path, n... | 28.029412 | 77 | 0.559811 | [
"ECL-2.0",
"Apache-2.0"
] | mincode/netdata | netdata/workers/json_storage.py | 1,906 | Python |
from __future__ import annotations
import asyncio
import logging
import uuid
from collections import defaultdict
from collections.abc import Hashable
from dask.utils import parse_timedelta
from distributed.client import Client
from distributed.utils import TimeoutError, log_errors
from distributed.worker import get_... | 33.995798 | 89 | 0.582252 | [
"BSD-3-Clause"
] | bryanwweber/distributed | distributed/multi_lock.py | 8,091 | Python |
import torchvision
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
def display_and_save_batch(title, batch, data, save=True, display=True):
"""Display and save batch of image using plt"""
im = torchvision.utils.make_grid(batch, nrow=int(batch.shape[0]**0.5))
plt.title(title)
plt.im... | 39.37931 | 101 | 0.643608 | [
"MIT"
] | jaywonchung/Learning-ML | Implementations/Conditional-Variational-Autoencoder/plot_utils.py | 1,142 | Python |
import binascii
from PySide2.QtWidgets import QTableWidget, QTableWidgetItem, QAbstractItemView
from PySide2.QtCore import Qt
class QPatchTableItem:
def __init__(self, patch, old_bytes):
self.patch = patch
self.old_bytes = old_bytes
def widgets(self):
patch = self.patch
wid... | 30.46988 | 114 | 0.619217 | [
"BSD-2-Clause"
] | CrackerCat/angr-management | angrmanagement/ui/widgets/qpatch_table.py | 2,529 | Python |
import enum
import SimpleITK as sitk
@enum.unique
class Interpolation(enum.Enum):
"""Interpolation techniques available in ITK.
Example:
>>> import torchio as tio
>>> transform = tio.RandomAffine(image_interpolation='nearest')
"""
#: Interpolates image intensity at a non-integer pixel... | 32.4 | 118 | 0.703704 | [
"Apache-2.0"
] | jwitos/torchio | torchio/transforms/interpolation.py | 1,296 | Python |
# -*- coding: utf-8 -*- #
# Copyright 2016 Google 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
#
# Unless requir... | 33.6 | 78 | 0.708333 | [
"Apache-2.0"
] | bshaffer/google-cloud-sdk | lib/surface/service_management/operations/describe.py | 2,184 | Python |
"""
Reads the version information from the manifest of the Chrome extension.
Author: Mustafa Emre Acer
"""
import json
import sys
def ReadChromeExtensionVersion(manifest_path):
with open(manifest_path) as manifest_file:
manifest = json.load(manifest_file)
print(manifest['version'])
if __name__ == "__... | 22.090909 | 74 | 0.726337 | [
"MIT"
] | meacer/deasciifier | build/chrome_extension_version.py | 486 | Python |
"""
Backprop NN training on Madelon data (Feature selection complete)
"""
import os
import csv
import time
import sys
sys.path.append("C:/ABAGAIL/ABAGAIL.jar")
from func.nn.backprop import BackPropagationNetworkFactory
from shared import SumOfSquaresError, DataSet, Instance
from opt.example import NeuralNetworkOptimiza... | 35.482759 | 173 | 0.670068 | [
"MIT"
] | tirthajyoti/Randomized_Optimization | ABAGAIL_execution/flipflop.py | 4,116 | Python |
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi SDK Generator. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union
from ... import _utilities, _tables
from... | 59.895604 | 3,183 | 0.710669 | [
"Apache-2.0"
] | pulumi-bot/pulumi-azure-native | sdk/python/pulumi_azure_native/machinelearningservices/v20210101/machine_learning_compute.py | 10,901 | Python |
# Copyright Contributors to the Amundsen project.
# SPDX-License-Identifier: Apache-2.0
import unittest
from unittest.mock import ANY
from databuilder.models.graph_serializable import (
RELATION_END_KEY, RELATION_END_LABEL, RELATION_REVERSE_TYPE, RELATION_START_KEY, RELATION_START_LABEL,
RELATION_TYPE,
)
from... | 43.20202 | 118 | 0.679448 | [
"Apache-2.0"
] | JacobSMoller/amundsendatabuilder | tests/unit/models/test_table_source.py | 4,277 | Python |
__copyright__ = "Copyright (C) 2009-2013 Andreas Kloeckner"
__license__ = """
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, c... | 27.831361 | 83 | 0.590837 | [
"MIT"
] | sv2518/pymbolic | test/test_pymbolic.py | 18,814 | Python |
"""Support for the OpenWeatherMap (OWM) service."""
from homeassistant.components.weather import WeatherEntity
from homeassistant.const import TEMP_CELSIUS
from .const import (
ATTR_API_CONDITION,
ATTR_API_FORECAST,
ATTR_API_HUMIDITY,
ATTR_API_PRESSURE,
ATTR_API_TEMPERATURE,
ATTR_API_WIND_BEARI... | 29.435484 | 83 | 0.682466 | [
"Apache-2.0"
] | 123dev/core | homeassistant/components/openweathermap/weather.py | 3,650 | Python |
# -*- coding: utf-8 -*-
# nodeandtag's package version information
__version_major__ = "0.2"
__version__ = "{}a1".format(__version_major__)
__version_long__ = "{}a1".format(__version_major__)
__status__ = "Alpha"
__author__ = "Jeremy Morosi"
__author_email__ = "jeremymorosi@hotmail.com"
__url__ = "https://github.com/N... | 30.636364 | 51 | 0.750742 | [
"MIT"
] | Nauja/noteandtag | noteandtag/__version__.py | 337 | Python |
from __future__ import absolute_import, division, print_function
import os
import subprocess
import sys
from setuptools import find_packages, setup
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
VERSION = """
# This file is auto-generated with the version information during setup.py installation.
__versi... | 31.284615 | 99 | 0.601672 | [
"MIT"
] | cglazner/pyro | setup.py | 4,067 | Python |
from __future__ import unicode_literals
from django.apps import apps
from django.db import models
from django.urls import reverse
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.translation import ugettext
@python_2_unicode_compatible
class Collection(object):
_registr... | 27.916968 | 100 | 0.604423 | [
"Apache-2.0"
] | marumadang/mayan-edms | mayan/apps/common/classes.py | 7,733 | Python |
# -*- coding: utf-8 -*-
#
# 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... | 32.632184 | 105 | 0.726664 | [
"Apache-2.0"
] | AzemaBaptiste/google-cloud-python | speech/samples/v1/speech_transcribe_multichannel.py | 2,839 | Python |
from hydroDL import pathSMAP, master
import os
from hydroDL.data import dbCsv
# train for each cont
contLst = [
'Africa',
'Asia',
'Australia',
'Europe',
'NorthAmerica',
'SouthAmerica',
]
subsetLst = ['Globalv4f1_' + x for x in contLst]
subsetLst.append('Globalv4f1')
outLst = [x + '_v4f1_y1' for... | 30.887097 | 79 | 0.644386 | [
"MIT"
] | fkwai/geolearn | app/global/train_cont.py | 1,915 | Python |
import torch
import torch.nn as nn
from .subnet import DoubleConv, UpConv, RRCU
class R2UNet(nn.Module):
def __init__(self, in_ch, out_ch, base_ch=64):
super(R2UNet, self).__init__()
self.inc = DoubleConv(in_ch, base_ch)
self.down = nn.MaxPool2d(kernel_size=2, stride=2)
self.down1... | 31.898305 | 82 | 0.529756 | [
"MIT"
] | nitsaick/pytorch-kit | network/r2unet.py | 1,882 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.