max_stars_repo_path string | max_stars_repo_name string | max_stars_count int64 | id string | content string | add_param_types int64 | add_return_types int64 | add_class_field_types int64 | add_instance_field_types int64 | add_total int64 | add_error int64 |
|---|---|---|---|---|---|---|---|---|---|---|
vendor/github.com/google/certificate-transparency/python/ct/crypto/asn1/x509_time_test.py | weltonrodrigo/origin | 807 | 1709974 | #!/usr/bin/env python
import unittest
from ct.crypto import error
from ct.crypto.asn1 import x509_time
class TimeTest(unittest.TestCase):
def verify_time(self, time_struct, year, month, day, hour, minute, sec):
self.assertEqual(year, time_struct.tm_year)
self.assertEqual(month, time_struct.tm_mo... | 0 | 0 | 0 | 0 | 0 | 0 |
recipes/Python/577766_Generator_combinations_without_replacement/recipe-577766.py | tdiprima/code | 2,023 | 1709996 | <gh_stars>1000+
#!/usr/bin/env python
__version__ = "0.8"
"""xcombinations.py
This recipe shows a way to solve the K-combination problems without replacement
of a N items sequence using the dynamic programming technique.
Keywords: combination, binomial coefficient, generator
See also: http://code.activestate.com/r... | 0 | 0 | 0 | 0 | 0 | 0 |
astroquery/vsa/__init__.py | hdevillepoix/astroquery | 577 | 1709998 | <gh_stars>100-1000
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
VSA Image and Catalog Query Tool
--------------------------------
.. topic:: Revision History
Refactored using common API as a part of Google Summer of Code 2013.
Modified for VSA by @eztean
:Originally contributed by:
... | 0 | 0 | 0 | 0 | 0 | 0 |
backend/kale/common/rokutils.py | brness/kale | 502 | 1710018 | <reponame>brness/kale<gh_stars>100-1000
# Copyright 2020 The Kale 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 requir... | 0 | 0 | 0 | 0 | 0 | 0 |
benchmark/python/sparse/sparse_op.py | Vikas-kum/incubator-mxnet | 228 | 1710028 | from __future__ import print_function
# 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, Versio... | 0 | 6 | 0 | 0 | 6 | 0 |
tests/scripts/thread-cert/v1_2_LowPower_test_forward_tracking_series.py | AdityaHPatwardhan/openthread | 2,962 | 1710029 | <reponame>AdityaHPatwardhan/openthread
#!/usr/bin/env python3
#
# Copyright (c) 2020, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source co... | 0 | 0 | 0 | 0 | 0 | 0 |
hummingbird/ml/operator_converters/_sv_implementations.py | vumichien/hummingbird | 2,772 | 1710077 | # -------------------------------------------------------------------------
# Copyright (c) 2020 <NAME>. All Rights Reserved.
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# -----------------------------------... | 0 | 1 | 0 | 3 | 4 | 0 |
tests/test_verify_cert.py | guyskk/curequests | 262 | 1710121 | from utils import run_with_curio
@run_with_curio
async def test_verify(httpbin_secure):
pass
@run_with_curio
async def test_cert(httpbin_secure):
pass
| 0 | 0 | 0 | 0 | 0 | 0 |
src/rpdk/core/contract/interface.py | privetjr/cloudformation-cli | 200 | 1710131 | <reponame>privetjr/cloudformation-cli
from enum import Enum, auto
class AutoName(Enum):
@staticmethod
def _generate_next_value_(name, _start, _count, _last_values):
return name
class Action(str, AutoName):
CREATE = auto()
READ = auto()
UPDATE = auto()
DELETE = auto()
LIST = auto(... | 0 | 0 | 0 | 0 | 0 | 0 |
segmentation/utils/preprocess_synscapes.py | dataflowr/evaluating_bdl | 110 | 1710169 | # code-checked
# server-checked
import pickle
import numpy as np
import cv2
import os
from collections import namedtuple
import random
# (NOTE! this is taken from the official Cityscapes scripts:)
Label = namedtuple( 'Label' , [
'name' , # The identifier of this label, e.g. 'car', 'person', ... .
... | 0 | 0 | 0 | 0 | 0 | 0 |
nonebot/command/argfilter/validators.py | EVAyo/nonebot | 676 | 1710179 | <gh_stars>100-1000
"""
提供几种常用的验证器。
这些验证器的工厂函数全都接受可选参数 `message: Message_T | None`,用于在验证失败时向用户发送错误提示。使用这些的验证器时,必须先调用验证器的工厂函数,其返回结果才是真正的验证器,例如:
```python
session.get('arg1', prompt='请输入 arg1:',
arg_filters=[extract_text, not_empty('输入不能为空')])
```
注意 `extract_text` 和 `not_empty` 使用上的区别。
版本: 1.2.0+
"""
impo... | 0 | 0 | 0 | 0 | 0 | 0 |
alipay/aop/api/response/KoubeiMarketingCampaignRecruitShopQueryResponse.py | snowxmas/alipay-sdk-python-all | 213 | 1710184 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from alipay.aop.api.response.AlipayResponse import AlipayResponse
from alipay.aop.api.domain.RecruitShopInfo import RecruitShopInfo
class KoubeiMarketingCampaignRecruitShopQueryResponse(AlipayResponse):
def __init__(self):
super(KoubeiMarketingCa... | 0 | 3 | 0 | 3 | 6 | 0 |
images.py | ivanalayan15/nodemcu-pyflasher | 1,172 | 1710222 | <gh_stars>1000+
#----------------------------------------------------------------------
# This file was generated by encode-bitmaps.py
#
from wx.lib.embeddedimage import PyEmbeddedImage
Exit = PyEmbeddedImage(
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0"
"RVh0U29mdHdhcmUAQWRvYmUgS... | 0 | 0 | 0 | 0 | 0 | 0 |
demo/run_apex_agent_on_cartpole.py | simonoso/EasyRL | 125 | 1710238 | <gh_stars>100-1000
# Copyright (c) 2019 Alibaba 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 require... | 0 | 0 | 0 | 0 | 0 | 0 |
datapackage_pipelines/manager/runners/__init__.py | gperonato/datapackage-pipelines | 109 | 1710280 | <reponame>gperonato/datapackage-pipelines
from .runner_config import RunnerConfiguration
runner_config = RunnerConfiguration()
| 0 | 0 | 0 | 0 | 0 | 0 |
lib/tree_lstm/graph_to_tree.py | KaihuaTang/VCTree-Scene-Graph-Generation | 109 | 1710290 | <gh_stars>100-1000
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from torch.nn.utils.rnn import PackedSequence
from lib.word_vectors import obj_edge_vectors
import numpy as np
from config import IM_SCALE, ROOT_PATH
import random
from lib.tree_lstm.def_tree impor... | 0 | 0 | 0 | 0 | 0 | 0 |
apps/urls/forms.py | yandenghong/KortURL | 118 | 1710304 | """
* Author: <NAME>
* FileName: forms.py
* Software: PyCharm
* Blog: https://yandenghong.github.io
"""
import re
from django import forms
from apps.utils.get_configs import config
class ShortenUrlForm(forms.Form):
"""
缩短网址表单
"""
raw_url = forms.CharField(max_length=255, required=True, err... | 0 | 3 | 0 | 0 | 3 | 0 |
applications/pytorch/bert/pretraining_data.py | payoto/graphcore_examples | 260 | 1710331 | <reponame>payoto/graphcore_examples
# Copyright (c) 2021 Graphcore Ltd. 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 | 0 | 0 | 0 | 0 | 0 |
usaspending_api/accounts/tests/test_federal_account_object_class_v2.py | g4brielvs/usaspending-api | 217 | 1710332 | <reponame>g4brielvs/usaspending-api
import pytest
from model_mommy import mommy
from rest_framework import status
@pytest.fixture
def financial_spending_data(db):
# federal Account
federal_account_1 = mommy.make("accounts.FederalAccount", id=1)
# create Object classes
object_class_1 = mommy.make(
... | 0 | 0 | 0 | 0 | 0 | 0 |
env/Lib/site-packages/OpenGL/GLES2/NV/polygon_mode.py | 5gconnectedbike/Navio2 | 210 | 1710338 | <filename>env/Lib/site-packages/OpenGL/GLES2/NV/polygon_mode.py
'''OpenGL extension NV.polygon_mode
This module customises the behaviour of the
OpenGL.raw.GLES2.NV.polygon_mode to provide a more
Python-friendly API
Overview (from the spec)
This extension adds a PolygonModeNV entry point which can be used to chan... | 0 | 0 | 0 | 0 | 0 | 0 |
pkgsinfo/templatetags/mwa_extras.py | paulsuh/mwa2 | 155 | 1710360 | from django import template
register = template.Library()
@register.filter(name='addcss')
def addcss(field, css) -> object:
class_old = field.field.widget.attrs.get('class', '')
if class_old:
class_new = class_old + ' ' + css
else:
class_new = css
return field.as_widget(attrs={"class":... | 0 | 1 | 0 | 0 | 1 | 0 |
model-optimizer/extensions/front/onnx/one_hot_normalize.py | monroid/openvino | 2,406 | 1710362 | <filename>model-optimizer/extensions/front/onnx/one_hot_normalize.py
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import numpy as np
from extensions.front.split_normalizer import SqueezeAxis
from extensions.ops.split import Split
from mo.front.common.replacement import FrontReplac... | 0 | 0 | 0 | 0 | 0 | 0 |
hs_file_types/models/model_instance.py | hydroshare/hydroshare | 178 | 1710367 | <filename>hs_file_types/models/model_instance.py
import json
import os
import jsonschema
from deepdiff import DeepDiff
from django.contrib.postgres.fields import JSONField
from django.db import models
from django.template import Template, Context
from dominate import tags as dom_tags
from rdflib import BNode, Literal,... | 0 | 0 | 0 | 0 | 0 | 0 |
leo/modes/sql.py | ATikhonov2/leo-editor | 1,550 | 1710369 | # Leo colorizer control file for sql mode.
# This file is in the public domain.
# Properties for sql mode.
properties = {
"commentEnd": "*/",
"commentStart": "/*",
"lineComment": "--",
}
# Attributes dict for sql_main ruleset.
sql_main_attributes_dict = {
"default": "null",
"digit_re": "",
"es... | 0 | 25 | 0 | 0 | 25 | 0 |
atp-auto-core-open/atp/views/run_ui.py | rebecca1202/testAuto | 130 | 1710376 | # -*- coding:utf-8 -*-
import json
from flask import request
from flask import Blueprint
from flask_restful import Resource
from atp.engine.run_uitest import run_uitest
from atp.views.wrappers import timer, developer_check, login_check
from atp.utils.common import get_request_json, make_response
from atp.engine.except... | 0 | 1 | 0 | 0 | 1 | 0 |
examples/trading/client_details_table.py | b-aeby/degiro-connector | 107 | 1710397 | <reponame>b-aeby/degiro-connector
# IMPORTATIONS
import json
import logging
from degiro_connector.trading.api import API as TradingAPI
from degiro_connector.trading.models.trading_pb2 import Credentials
# SETUP LOGGING LEVEL
logging.basicConfig(level=logging.DEBUG)
# SETUP CONFIG DICT
with open("config/config.json")... | 0 | 0 | 0 | 0 | 0 | 0 |
Chapter08/visualising_maps.py | carltyndall/Python-Automation-Cookbook-Second-Edition | 155 | 1710402 | import matplotlib.pyplot as plt
import matplotlib.cm as cm
import fiona
# STEP 2
COUNTRIES_POPULATION = {
'Spain': 47.2,
'Portugal': 10.6,
'United Kingdom': 63.8,
'Ireland': 4.7,
'France': 64.9,
'Italy': 61.1,
'Germany': 82.6,
'Netherlands': 16.8,
'Belgium': 11.1,
'Denmark': 5.6... | 0 | 0 | 0 | 0 | 0 | 0 |
mimic/model/identity_errors.py | mfens98/mimic | 141 | 1710435 | <filename>mimic/model/identity_errors.py
"""
Errors for the Identity Models
"""
class EndpointTemplateException(Exception):
"""
Parent for all Identity Endpoint Template Exceptions
"""
class InvalidEndpointTemplateException(EndpointTemplateException):
"""
Parent for all Endpoint Template Validat... | 0 | 0 | 0 | 0 | 0 | 0 |
orchestra/communication/tests/test_views.py | code-review-doctor/orchestra | 444 | 1710441 | <gh_stars>100-1000
from django.urls import reverse
from orchestra.tests.helpers import OrchestraAuthenticatedTestCase
from orchestra.tests.helpers.fixtures import StaffingResponseFactory
from orchestra.tests.helpers.fixtures import WorkerFactory
class StaffRequestBase(OrchestraAuthenticatedTestCase):
template = ... | 0 | 0 | 0 | 0 | 0 | 0 |
util/dvsim/testplanner.py | Jacob-Levy/opentitan | 1,375 | 1710449 | <gh_stars>1000+
#!/usr/bin/env python3
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
r"""Command-line tool to parse and process testplan Hjson
"""
import argparse
import sys
import Testplan
def main():
parser = ... | 0 | 0 | 0 | 0 | 0 | 0 |
env/lib/python3.6/site-packages/altair/vega/v3/schema/__init__.py | anthowen/duplify | 1,134 | 1710452 | # flake8: noqa
from .core import *
SCHEMA_VERSION = 'v3.3.1'
SCHEMA_URL = 'https://vega.github.io/schema/vega/v3.3.1.json'
| 0 | 0 | 0 | 0 | 0 | 0 |
sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/__init__.py | rsdoherty/azure-sdk-for-python | 207 | 1710456 | <filename>sdk/applicationinsights/azure-mgmt-applicationinsights/azure/mgmt/applicationinsights/v2018_06_17_preview/models/__init__.py
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.... | 0 | 0 | 0 | 0 | 0 | 0 |
api/python/advanced/SubmitJob.py | SaidHamidouche/SQLFLOW | 213 | 1710457 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
import zipfile
import requests
import json
import sys
import os
def toSqlflow(userId, token, server, port, jobName, dbvendor, sqlfiles) -> object:
url = '/gspLive_backend/sqlflow/job/submitUserJob'
if port != '':
url = server + ':' + port + url
else:
... | 0 | 2 | 0 | 0 | 2 | 0 |
backend/shopping-cart-service/delete_from_cart.py | LewS/aws-serverless-shopping-cart | 211 | 1710481 | <gh_stars>100-1000
import json
import os
import boto3
from aws_lambda_powertools import Logger, Tracer
logger = Logger()
tracer = Tracer()
dynamodb = boto3.resource("dynamodb")
table = dynamodb.Table(os.environ["TABLE_NAME"])
@logger.inject_lambda_context(log_event=True)
@tracer.capture_lambda_handler
def lambda_h... | 0 | 0 | 0 | 0 | 0 | 0 |
tests/analysis/test_anom_seq.py | kubajir/msticpy | 820 | 1710499 | import unittest
from datetime import datetime
import pandas as pd
import numpy as np
from msticpy.analysis.anomalous_sequence.utils.data_structures import Cmd
from msticpy.analysis.anomalous_sequence import anomalous
class TestAnomalous(unittest.TestCase):
def setUp(self) -> None:
self.sessions1 = [
... | 0 | 2 | 0 | 0 | 2 | 0 |
Tests/ML/histopathology/utils/test_metrics_utils.py | microsoft/InnerEye-DeepLearning | 402 | 1710501 | # ------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
# -------------------------------------------------------------------... | 2 | 3 | 0 | 0 | 5 | 0 |
release/stubs.min/System/__init___parts/Console.py | htlcnn/ironpython-stubs | 182 | 1710542 | from __future__ import annotations
class Console(object):
""" Represents the standard input,output,and error streams for console applications. This class cannot be inherited. """
@staticmethod
def Beep(frequency: object | None=None,duration: object | None=None):
"""
Beep(frequency: int,duration: int)
... | 9 | 0 | 29 | 0 | 38 | 0 |
spin_spherical_cnns/input_pipeline_test.py | xxdreck/google-research | 23,901 | 1710556 | # coding=utf-8
# Copyright 2021 The Google Research 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 applicab... | 0 | 0 | 0 | 0 | 0 | 0 |
spot-ingest/common/listener.py | yellingviv/incubator-spot | 365 | 1710563 | <gh_stars>100-1000
#!/usr/bin/env 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 ... | 0 | 0 | 0 | 0 | 0 | 0 |
examples/pythag.py | ziman/idris-py | 140 | 1710565 | #!/usr/bin/env python
from __future__ import annotations
import sys
import importlib
import math
Unit = object()
World = object()
class IdrisError(Exception):
pass
def _idris_error(msg):
raise IdrisError(msg)
def _idris_pymodule(name) -> object:
return importlib.import_module(name)
def _idris_call(f, args) ... | 3 | 244 | 0 | 0 | 247 | 0 |
doc/source/JSAnimation/__init__.py | ryanjmccall/feets | 150 | 1710573 | <reponame>ryanjmccall/feets
from .html_writer import HTMLWriter
| 0 | 0 | 0 | 0 | 0 | 0 |
pyap/exceptions.py | khoff5/pyap | 163 | 1710583 | <filename>pyap/exceptions.py
# -*- coding: utf-8 -*-
"""
pyap.exceptions
~~~~~~~~~~~~~~~~
This module contains address parser exceptions.
:copyright: (c) 2015 by <NAME>.
:license: MIT, see LICENSE for more details.
"""
class AddressParserException(Exception):
pass
class NoCountrySelected(... | 0 | 0 | 0 | 0 | 0 | 0 |
test/run/t487.py | timmartin/skulpt | 2,671 | 1710584 | map(lambda x,y: x + y, [0,1,2,3,4,5], False)
| 0 | 0 | 0 | 0 | 0 | 0 |
jupiter_http/jupiter_http/LoggerFactory.py | dianbaer/fast | 226 | 1710611 | <filename>jupiter_http/jupiter_http/LoggerFactory.py
import logging
import uuid
async def logger_factory(app, handler):
async def logger(request):
request.__uuid__ = uuid.uuid4().hex
logging.info('%s logger_factory logger start next handler %s ' % (request.__uuid__, handler))
r = a... | 0 | 0 | 0 | 0 | 0 | 0 |
test/test_slimta_http_wsgi.py | nanojob/python-slimta | 141 | 1710630 | import unittest
from mox3.mox import MoxTestBase, IsA
import gevent
from gevent.pywsgi import WSGIServer as GeventWSGIServer
from slimta.http.wsgi import WsgiServer, log
class TestWsgiServer(MoxTestBase, unittest.TestCase):
def test_build_server(self):
w = WsgiServer()
server = w.build_server(('... | 0 | 2 | 0 | 0 | 2 | 0 |
restler/checkers/invalid_dynamic_object_checker.py | mkleshchenok/restler-fuzzer | 1,539 | 1710631 | # Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
from __future__ import annotations
""" Implements logic for invalid dynamic object checker. """
from __future__ import print_function
from checkers.checker_base import *
import time
import uuid
from engine.bug_bucketing import BugBuckets
import... | 0 | 3 | 1 | 0 | 4 | 0 |
botocore/retries/__init__.py | doc-E-brown/botocore | 1,738 | 1710646 | """New retry v2 handlers.
This package obsoletes the botocore/retryhandler.py module and contains
new retry logic.
"""
| 0 | 0 | 0 | 0 | 0 | 0 |
libs/sqlobject/tests/test_create_drop.py | scambra/HTPC-Manager | 422 | 1710651 | <filename>libs/sqlobject/tests/test_create_drop.py
from sqlobject import *
from sqlobject.tests.dbtest import *
class TestCreateDrop(SQLObject):
class sqlmeta(sqlmeta):
idName = 'test_id_here'
table = 'test_create_drop_table'
name = StringCol()
number = IntCol()
time = DateTimeCol()
... | 0 | 0 | 0 | 0 | 0 | 0 |
src/drivers/python/wappalyzer.py | pianomanx/watchdog | 377 | 1710671 | <filename>src/drivers/python/wappalyzer.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import PyV8
import requests
from urlparse import urlparse
try:
import json
except ImportError:
import simplejson as json
class Wappalyzer(object):
def __init__(self, url):
self.file_dir... | 0 | 0 | 0 | 0 | 0 | 0 |
pyvgdlmaster/examples/gridphysics/mazes/simple.py | LRHammond/pv4dsrl | 111 | 1710720 | '''
A few simple layouts for maze-like games: find the exit in the minimal amount of time.
@author: <NAME>
'''
maze_level_0 = """
wwww
w Gw
wA w
wwww
"""
maze_level_1 = """
wwwwww
w Gw
w w
wAw w
wwwwww
"""
maze_level_1b = """
wwwwww
w Gw
w w w
wA ww
wwwwww
"""
maze_level_2 = ... | 0 | 0 | 0 | 0 | 0 | 0 |
tests/components/abode/conftest.py | andersop91/core | 22,481 | 1710721 | """Configuration for Abode tests."""
import abodepy.helpers.constants as CONST
import pytest
from tests.common import load_fixture
from tests.components.light.conftest import mock_light_profiles # noqa: F401
@pytest.fixture(autouse=True)
def requests_mock_fixture(requests_mock):
"""Fixture to provide a requests... | 0 | 0 | 0 | 0 | 0 | 0 |
mayan/apps/documents/tests/test_document_type_views.py | nattangwiwat/Mayan-EDMS-recitation | 343 | 1710728 | import os
from ..models import DocumentType
from ..permissions import (
permission_document_properties_edit,
permission_document_type_create, permission_document_type_delete,
permission_document_type_edit, permission_document_type_view,
)
from .base import GenericDocumentViewTestCase
from .literals import... | 0 | 0 | 4 | 0 | 4 | 0 |
notebook/pandas_reindex.py | vhn0912/python-snippets | 174 | 1710741 | import pandas as pd
df = pd.DataFrame({'A': [1, 2, 3], 'B': [10, 20, 30], 'C': [100, 200, 300]},
index=['One', 'Two', 'Three'])
print(df)
# A B C
# One 1 10 100
# Two 2 20 200
# Three 3 30 300
print(df.reindex(index=['Two', 'Three', 'One']))
# A B C
# Two 2 2... | 0 | 0 | 0 | 0 | 0 | 0 |
test_python_toolbox/test_misc_tools/test_general_sum.py | hboshnak/python_toolbox | 119 | 1710797 | # Copyright 2009-2017 <NAME>.
# This program is distributed under the MIT license.
from python_toolbox.misc_tools import general_sum
def test():
assert general_sum((1, 2, 3)) == 6
assert general_sum((1, 2, 3, 4)) == 10
assert general_sum(('abra', 'ca', 'dabra')) == 'abracadabra'
assert general_sum(((... | 0 | 0 | 0 | 0 | 0 | 0 |
extstats/CONSTS.py | bakl/chrome-extensions-archive | 408 | 1710800 | <filename>extstats/CONSTS.py<gh_stars>100-1000
CRX_DIRECTORY = 'crawled/crx/'
PAGES_DIRECTORY = 'crawled/pages/'
SITEMAP_FILE = 'data/sitemap.json'
| 0 | 0 | 0 | 0 | 0 | 0 |
scripts/showhids.py | khoih-prog/USBComposite_stm32f1 | 242 | 1710804 | <reponame>khoih-prog/USBComposite_stm32f1<gh_stars>100-1000
from pywinusb import hid
hid.core.show_hids()
| 0 | 0 | 0 | 0 | 0 | 0 |
solutions/problem_306.py | ksvr444/daily-coding-problem | 1,921 | 1710818 | def sort_k(arr, k) -> object:
arr = sorted(arr[:k]) + arr[k:]
for i in range(k, len(arr)):
start, end = i-k+1, i+1
p, n = arr[:start], arr[end:]
sub = sorted(arr[start:end])
arr = p + sub + n
return arr
# Test
assert sort_k([1, 0, 2, 4, 3], 2) == [0, 1, 2, 3, 4]
| 0 | 1 | 0 | 0 | 1 | 0 |
test/programytest/storage/stores/file/store/test_rdfs.py | cdoebler1/AIML2 | 345 | 1710825 | import os
import os.path
from unittest.mock import patch
from programy.rdf.collection import RDFCollection
from programy.storage.stores.file.config import FileStorageConfiguration
from programy.storage.stores.file.config import FileStoreConfiguration
from programy.storage.stores.file.engine import FileStorageEngine
fro... | 0 | 0 | 0 | 0 | 0 | 0 |
nidaqmx/tests/test_multi_threading.py | stafak/nidaqmx-python | 252 | 1710834 | <reponame>stafak/nidaqmx-python<filename>nidaqmx/tests/test_multi_threading.py
import random
import pykka
import pytest
import sys
import nidaqmx
from nidaqmx.tests.fixtures import multi_threading_test_devices
from nidaqmx.tests.helpers import generate_random_seed
class Error(Exception):
pass
class NoFixtureD... | 0 | 0 | 0 | 0 | 0 | 0 |
tests/urlpatterns_reverse/urls_without_full_import.py | shinshin86/django | 5,079 | 1710864 | # A URLs file that doesn't use the default
# from django.conf.urls import *
# import pattern.
from django.conf.urls import url
from .views import bad_view, empty_view
urlpatterns = [
url(r'^test_view/$', empty_view, name="test_view"),
url(r'^bad_view/$', bad_view, name="bad_view"),
]
| 0 | 0 | 0 | 0 | 0 | 0 |
alipay/aop/api/domain/SearchOrderCreateRequest.py | antopen/alipay-sdk-python-all | 213 | 1710878 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import annotations
import json
from alipay.aop.api.constant.ParamConstants import *
from alipay.aop.api.domain.SearchBaseItems import SearchBaseItems
from alipay.aop.api.domain.SearchBrandItems import SearchBrandItems
from alipay.aop.api.domain.SearchServic... | 0 | 27 | 0 | 25 | 52 | 0 |
tests/unit/cfngin/hooks/staticsite/test_utils.py | onicagroup/runway | 134 | 1710905 | <reponame>onicagroup/runway
"""Test runway.cfngin.hooks.staticsite.utils."""
from __future__ import annotations
from typing import TYPE_CHECKING, Dict, List, Optional, Union, cast
import igittigitt
import pytest
from mock import Mock, call
from runway.cfngin.hooks.staticsite.utils import (
calculate_hash_of_file... | 0 | 0 | 0 | 0 | 0 | 0 |
terracotta/handlers/datasets.py | kaymes/terracotta | 448 | 1710934 | """handlers/datasets.py
Handle /datasets API endpoint.
"""
from typing import Mapping, List, Union # noqa: F401
from collections import OrderedDict
from terracotta import get_settings, get_driver
from terracotta.profile import trace
@trace('datasets_handler')
def datasets(some_keys: Mapping[str, Union[str, List[s... | 3 | 1 | 0 | 0 | 4 | 0 |
rendezvous/prototype/server.py | geoffxy/tandem | 732 | 1710991 | <gh_stars>100-1000
import argparse
import socket
import json
import time
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("--self_port", default=60000, type=int)
return parser.parse_args()
def recv_data(sock):
print("Waiting to receive data")
data, address = sock.recvfrom(4... | 0 | 0 | 0 | 0 | 0 | 0 |
ufora/util/ThreadSafeDict.py | ufora/ufora | 571 | 1711018 | <gh_stars>100-1000
# Copyright 2015 Ufora 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... | 0 | 0 | 0 | 0 | 0 | 0 |
src/dep/cndict/read_friso.py | abrookins/RediSearch | 2,098 | 1711044 | <gh_stars>1000+
#!/usr/bin/env python
import zlib
import struct
from argparse import ArgumentParser
from cStringIO import StringIO
ap = ArgumentParser()
ap.add_argument('-f', '--file', default='CNDICT.out')
opts = ap.parse_args()
fp = open(opts.file)
# Read the header/version
version = struct.unpack('!I', fp.read(4)... | 0 | 0 | 0 | 0 | 0 | 0 |
python/pysvso/matcher/roi.py | mfkiwl/SEMANTIC_VISUAL_SUPPORTED_ODEMETRY | 191 | 1711058 | from __future__ import annotations
import cv2
import numpy as np
# we will use linear_assignment to quickly write experiments,
# later a customerized KM algorithms with various optimization in c++ is employed
# see https://github.com/berhane/LAP-solvers
# This is used for "Complete Matching" and we can remove unreaso... | 1 | 3 | 2 | 1 | 7 | 0 |
tools/android/native_lib_memory/parse_smaps.py | zipated/src | 2,151 | 1711059 | #!/usr/bin/python
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Parses /proc/[pid]/smaps on a device and shows the total amount of swap used.
"""
import argparse
import collections
import logging
imp... | 0 | 0 | 0 | 0 | 0 | 0 |
python/test/function/test_depthwise_deconvolution.py | daniel-falk/nnabla | 2,792 | 1711073 | # Copyright 2018,2019,2020,2021 Sony 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 a... | 0 | 2 | 0 | 0 | 2 | 0 |
api/core/signing.py | SolidStateGroup/Bullet-Train-API | 126 | 1711079 | import hashlib
import hmac
def sign_payload(payload: str, key: str) -> object:
return hmac.new(
key=key.encode(), msg=payload.encode(), digestmod=hashlib.sha256
).hexdigest()
| 2 | 1 | 0 | 0 | 3 | 0 |
var/spack/repos/builtin/packages/py-cekit/package.py | kkauder/spack | 2,360 | 1711139 | # Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class PyCekit(PythonPackage):
"""CEKit is a Container image creation tool.
CEKit helps to bu... | 0 | 0 | 2 | 0 | 2 | 0 |
src/gam/gapi/__init___test.py | GAM-team/GAM | 102 | 1711141 | """Tests for gapi."""
import json
import unittest
from unittest.mock import MagicMock
from unittest.mock import patch
from gam import SetGlobalVariables
import gam.gapi as gapi
from gam.gapi import errors
import httplib2
def create_http_error(status, reason, message) -> object:
"""Creates a HttpError object sim... | 0 | 1 | 0 | 0 | 1 | 0 |
octopus/platforms/ETH/explorer.py | SillyTin/octopus | 212 | 1711167 | from __future__ import annotations
import warnings
#from ethereum import utils
#from ethereum.abi import encode_abi, decode_abi
from octopus.platforms.ETH.constants import DEFAULT_GAS_PER_TX, DEFAULT_GAS_PRICE, BLOCK_TAGS, BLOCK_TAG_LATEST
from octopus.platforms.ETH.util import hex_to_dec, clean_hex, validate_block
... | 49 | 76 | 0 | 0 | 125 | 0 |
codes/Python/p01-warmup/0-welcome/welcome.py | DEVESHTARASIA/CNTK-World | 367 | 1711237 | # Import CNTK library
import cntk
# Version
print('CNTK version:', cntk.__version__)
# Check GPU
from cntk.device import try_set_default_device, gpu
if try_set_default_device(gpu(0)):
print('GPU device is enabled!')
# Print devices
print('All available devices:', cntk.all_devices())
# Simple math operation
prin... | 0 | 0 | 0 | 0 | 0 | 0 |
plenum/recorder/replayer.py | andkononykhin/plenum | 148 | 1711264 | <gh_stars>100-1000
import json
import os
import sys
import time
from typing import Tuple
import datetime
from plenum.common.constants import OP_FIELD_NAME, PREPREPARE, BATCH, \
KeyValueStorageType, CLIENT_STACK_SUFFIX
from plenum.common.types import f
from plenum.common.util import get_utc_epoch
from plenum.recor... | 0 | 0 | 0 | 0 | 0 | 0 |
vim_debug/subwindows.py | timgates42/vim-debug | 128 | 1711286 | <filename>vim_debug/subwindows.py
from window import VimWindow
import errors
import base64
class StackWindow(VimWindow):
'''Keeps track of the current execution stack'''
name = 'STACK'
dtext = '[[Execution Stack - most recent call first]]'
def __init__(self, name = None):
VimWindow.__init__(sel... | 0 | 0 | 0 | 0 | 0 | 0 |
bookstore/client/__init__.py | anderser/bookstore | 192 | 1711325 | from .store_client import BookstoreClient
| 0 | 0 | 0 | 0 | 0 | 0 |
dev/Gems/Blast/houdini/python2.7libs/blastExport/assetDB.py | brianherrera/lumberyard | 1,738 | 1711343 | <reponame>brianherrera/lumberyard<gh_stars>1000+
import sqlite3
import uuid
class AssetDBConnection:
def __init__(self, databasePath):
sqlite3.register_converter('BLOB', lambda b: uuid.UUID(bytes=b))
sqlite3.register_adapter(uuid.UUID, lambda u: buffer(u.bytes))
self.databasePath = databas... | 0 | 0 | 0 | 0 | 0 | 0 |
scripts/smatch_v1_0/smatch_orig.py | LeonardoEmili/jamr | 194 | 1711344 | <filename>scripts/smatch_v1_0/smatch_orig.py
#!/usr/bin/env python
# encoding: utf-8
"""
smatch.py
Author: <NAME>
Copyright(c) 2012. All rights reserved.
"""
import sys
import os
import time
import random
import amr
#import optparse
#import argparse #argparse only works for python 2.7. If you are using older versin o... | 0 | 0 | 0 | 0 | 0 | 0 |
tests/unit/pypyr/steps/append_test.py | mofm/pypyr | 261 | 1711371 | <filename>tests/unit/pypyr/steps/append_test.py
"""append.py unit tests."""
import pytest
from pypyr.context import Context
from pypyr.dsl import PyString
from pypyr.errors import (ContextError,
KeyInContextHasNoValueError,
KeyNotInContextError)
from pypyr.steps impo... | 0 | 0 | 0 | 0 | 0 | 0 |
setup.py | shobrook/communities | 509 | 1711434 | import sys
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
from codecs import open
if sys.version_info[:3] < (3, 0, 0):
print("Requires Python 3 to run.")
sys.exit(1)
with open("README.md", encoding="utf-8") as file:
readme = file.read()
setup(
name="com... | 0 | 0 | 0 | 0 | 0 | 0 |
tests/test_python_binds.py | ju-sh/herbstluftwm | 925 | 1711477 | import pytest
import os.path
import subprocess
import sys
import os
import conftest
from herbstluftwm.types import Rectangle
def test_example(hlwm):
# test the example.py shipped with the bindings
example_py = os.path.join(os.path.dirname(__file__), '..', 'python', 'example.py')
# make 'herbstclient' bina... | 0 | 0 | 0 | 0 | 0 | 0 |
tests/spaces/sequence_test.py | sahirgomez1/CompilerGym | 562 | 1711479 | <reponame>sahirgomez1/CompilerGym
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Unit tests for //compiler_gym/spaces:sequence."""
import pytest
from compiler_gym.spaces import Scalar, S... | 0 | 0 | 0 | 0 | 0 | 0 |
pyscf/pbc/tools/test/test_k2gamma.py | QuESt-Calculator/pyscf | 501 | 1711527 | <filename>pyscf/pbc/tools/test/test_k2gamma.py<gh_stars>100-1000
# Copyright 2014-2018 The PySCF Developers. 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:... | 0 | 0 | 0 | 0 | 0 | 0 |
leonardo/module/media/models/media.py | timgates42/django-leonardo | 102 | 1711532 | <filename>leonardo/module/media/models/media.py
import os
from django.conf import settings
from django.db import models
from django.utils.translation import ugettext_lazy as _
from feincms.module.page.extensions.navigation import (NavigationExtension,
PagePretend... | 0 | 0 | 0 | 0 | 0 | 0 |
configs/BigDetection/cbnetv2/htc_cbv2_swin_base_giou_4conv1f_adamw_bigdet.py | cailk/bigdetection | 185 | 1711545 | <reponame>cailk/bigdetection
_base_ = [
'../../_base_/models/htc_without_semantic+mask_swin_fpn.py',
'../../_base_/datasets/bigdet_detection.py',
'../../_base_/schedules/schedule_1x.py',
'../../_base_/default_runtime.py'
]
model = dict(
backbone=dict(
type='CBSwinTransformer',
embed... | 0 | 0 | 0 | 0 | 0 | 0 |
ledger/test/test_utils.py | andkononykhin/plenum | 148 | 1711557 | import random
from ledger.util import has_nth_bit_set
def test_nth_bit_set():
"""
Check if bits of randomly chosen integers are set or unset and compare
with the binary representation.
"""
for _ in range(0, 10000):
number = random.randint(0, 100000000)
bits = bin(number)[2:]
... | 0 | 0 | 0 | 0 | 0 | 0 |
tests/test_yaml.py | budgester/the-littlest-jupyterhub | 741 | 1711611 | from tljh.yaml import yaml
def test_no_empty_flow(tmpdir):
path = tmpdir.join("config.yaml")
with path.open("w") as f:
f.write("{}")
# load empty config file
with path.open("r") as f:
config = yaml.load(f)
# set a value
config["key"] = "value"
# write to a file
with pat... | 0 | 0 | 0 | 0 | 0 | 0 |
test_chatbot.py | Umesh-01/NavigateMe | 145 | 1711612 | <reponame>Umesh-01/NavigateMe<filename>test_chatbot.py
import chatbot
import unittest
clf, learn_response = chatbot.setup()
class ChatBotTest(unittest.TestCase):
def test_message_to_bot_directions(self):
user_text = "What's the distance between Chicago and California?"
bot_text, learn_response = ... | 0 | 0 | 0 | 0 | 0 | 0 |
tests/integration-v1/cattletest/core/test_zone.py | lifecontrol/cattle | 482 | 1711646 | <filename>tests/integration-v1/cattletest/core/test_zone.py
from common import * # NOQA
def test_zone_list(super_client):
zones = super_client.list_zone()
assert len(zones) > 0
| 0 | 0 | 0 | 0 | 0 | 0 |
data/transcoder_evaluation_gfg/python/SMALLEST_DIFFERENCE_PAIR_VALUES_TWO_UNSORTED_ARRAYS.py | mxl1n/CodeGen | 241 | 1711657 | <gh_stars>100-1000
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import sys
def f_gold(A, B, m, n):
A.sort()
B.sort()
a = 0
b = 0
result = sys.maxsize
... | 0 | 0 | 0 | 0 | 0 | 0 |
Trakttv.bundle/Contents/Libraries/Shared/plugin/preferences/options/o_sync/lists/__init__.py | disrupted/Trakttv.bundle | 1,346 | 1711674 | from plugin.preferences.options.o_sync.lists.liked import SyncListsLikedOption, SyncListsLikedPlaylistsOption
from plugin.preferences.options.o_sync.lists.personal import SyncListsPersonalOption, SyncListsPersonalPlaylistsOption
from plugin.preferences.options.o_sync.lists.watchlist import SyncListsWatchlistOption, Syn... | 0 | 0 | 0 | 0 | 0 | 0 |
pox/openflow/spanning_tree.py | korrigans84/pox_network | 416 | 1711684 | <reponame>korrigans84/pox_network
# Copyright 2012,2013 <NAME>
#
# 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... | 0 | 0 | 0 | 0 | 0 | 0 |
homeassistant/components/uptime/sensor.py | MrDelik/core | 30,023 | 1711697 | """Platform to retrieve uptime for Home Assistant."""
from __future__ import annotations
import voluptuous as vol
from homeassistant.components.sensor import (
PLATFORM_SCHEMA,
SensorDeviceClass,
SensorEntity,
)
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const i... | 8 | 3 | 1 | 0 | 12 | 0 |
Docs/preprocess_files.py | joehellmers/Castro | 178 | 1711715 | """
This script strips out preprocessor directives from C++ headers and Fortran files
and saves the results in source/preprocessed_files
"""
import os
import re
# directory of the source files
rootdir = "../Source"
outdir = "source/preprocessed_files"
def strip_directives(filename, filepath, outpath):
"""
... | 0 | 0 | 0 | 0 | 0 | 0 |
tests/test_contrib_auth.py | vvkvivekl/omic-django-herald | 187 | 1711727 | from django.contrib.auth import get_user_model
from django.core import mail
from django.test import TestCase
from herald.contrib.auth.forms import HeraldPasswordResetForm
class ContribAuthTests(TestCase):
def test_save_form(self):
User = get_user_model()
User.objects.create_user(username='<EMAIL>... | 0 | 0 | 0 | 0 | 0 | 0 |
dizoo/procgen/maze/envs/__init__.py | sailxjx/DI-engine | 464 | 1711755 | <reponame>sailxjx/DI-engine
from .maze_env import MazeEnv
| 0 | 0 | 0 | 0 | 0 | 0 |
WebMirror/management/rss_parser_funcs/feed_parse_extractKonobuta.py | fake-name/ReadableWebProxy | 193 | 1711777 | <filename>WebMirror/management/rss_parser_funcs/feed_parse_extractKonobuta.py
def extractKonobuta(item):
"""
"""
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol) or 'preview' in item['title'].lower():
return None
if 'status' in item['tags']:
return buildReleaseMess... | 0 | 0 | 0 | 0 | 0 | 0 |
Stock/BackTesting/Engine/DyStockBackTestingAccountManager.py | Leonardo-YXH/DevilYuan | 135 | 1711826 | from __future__ import annotations
import copy
from datetime import *
from DyCommon.DyCommon import *
from ..DyStockBackTestingCommon import *
from ...Trade.DyStockTradeCommon import *
from ...Trade.AccountManager.DyStockPos import *
from ...Trade.AccountManager.StopMode.DyStockStopLossMaMode import *
from ...Trade.Ac... | 10 | 18 | 1 | 5 | 34 | 0 |
watsor/stream/sync.py | firefly2442/watsor | 123 | 1711836 | <gh_stars>100-1000
from multiprocessing import Condition, Queue, Semaphore, RLock, get_context
from multiprocessing.queues import JoinableQueue
from multiprocessing.sharedctypes import Value
from enum import IntEnum
from typing import Dict
from queue import Full
from time import monotonic
class State(IntEnum):
""... | 0 | 0 | 0 | 0 | 0 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.