code stringlengths 3 1.05M | repo_name stringlengths 5 104 | path stringlengths 4 251 | language stringclasses 1
value | license stringclasses 15
values | size int64 3 1.05M |
|---|---|---|---|---|---|
from dataclasses import dataclass
from typing import Any, Dict, List, Optional
import pytest
from fastapi import FastAPI
from pydantic import BaseModel
import ray
@pytest.fixture(scope="session")
def start_ray():
ray.init(ignore_reinit_error=True)
def test_serialize_cls(start_ray):
class User(BaseModel):
... | ray-project/ray | python/ray/tests/test_pydantic_serialization.py | Python | apache-2.0 | 3,451 |
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# bu... | AdamWill/bodhi | bodhi/server/services/errors.py | Python | gpl-2.0 | 2,812 |
#!/usr/bin/env python
"""Bootstrap setuptools installation
To use setuptools in your package's setup.py, include this
file in the same directory and add this to the top of your setup.py::
from ez_setup import use_setuptools
use_setuptools()
To require a specific version of setuptools, set a download
mirror, ... | gregorschatz/pymodbus3 | ez_setup.py | Python | bsd-3-clause | 10,501 |
#!/usr/bin/env python2.3
##############################################################################
#
# Copyright (c) 2005 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this... | wunderlins/learning | python/zodb/lib/osx/ZEO/zeoctl.py | Python | gpl-2.0 | 1,026 |
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.OrderListView.as_view(), name='orders'),
url(r'^(?P<order_pk>\d+)/$',
views.order_details, name='order-details'),
url(r'^(?P<order_pk>\d+)/add-note/$',
views.order_add_note, name='order-add-note'),
u... | spartonia/saleor | saleor/dashboard/order/urls.py | Python | bsd-3-clause | 1,199 |
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | googlearchive/rgc-models | response_model/python/metric_learning/end_to_end/linear_joint_embedding.py | Python | apache-2.0 | 6,868 |
class TelemetryLimited:
Sng = SerialNumGen()
def __init__(self):
self._telemetryLimiterId = self.Sng.next()
self._limits = set()
def getTelemetryLimiterId(self):
return self._telemetryLimiterId
def addTelemetryLimit(self, limit):
self._limits.add(limit)
def remo... | ksmit799/Toontown-Source | otp/distributed/TelemetryLimited.py | Python | mit | 522 |
from distutils.core import setup
from json import loads
from os.path import dirname, realpath
setup(
author = 'Jascha Casadio',
author_email = 'jaschacasadio@lostinmalloc.com',
description = 'Nginx configuration resolution tree.',
license = 'LICENSE',
long_description = 'A Python package t... | jaschac/nginx-resolution-tree | setup.py | Python | apache-2.0 | 851 |
MODEL_PARAMS = \
{ 'aggregationInfo': { 'days': 0,
'fields': [],
'hours': 0,
'microseconds': 0,
'milliseconds': 0,
'minutes': 0,
'months': 0,
'seconds': 0,
... | htm-community/nupic.critic | model_params/1field_anomaly_model_params.py | Python | agpl-3.0 | 3,457 |
# -*- coding: utf-8 -*-
import numpy as np
import time
# Options:
k = 3 # Number of versions
N = 300 # Total number of trials
log = True # Log data to mognodb
################################################################
# Get overall count:
n = self.get_theta().get("n",1)
# Select the v... | VincentGijsen/streamingbandit | app/libs/defaults/ab_getaction.py | Python | mit | 942 |
######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Communicator client code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Ri... | ncos/lisa | src/lisa_drive/scripts/venv/lib/python3.5/site-packages/pip-10.0.1-py3.5.egg/pip/_vendor/chardet/jpcntx.py | Python | mit | 19,876 |
#!/usr/bin/python3
# @begin:license
#
# Copyright (c) 2015-2019, Benjamin Niemann <pink@odahoda.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at y... | odahoda/noisicaa | noisicaa/builtin_nodes/midi_cc_to_cv/processor_messages.py | Python | gpl-2.0 | 1,215 |
# -*- coding: utf-8 -*-
# ####################################################################
# Copyright (C) 2005-2009 by the FIFE team
# http://www.fifengine.de
# This file is part of FIFE.
#
# FIFE is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# ... | mgeorgehansen/FIFE_Technomage | demos/rio_de_hola/scripts/agents/hero.py | Python | lgpl-2.1 | 2,209 |
# -*- coding: utf-8 -*-
# Copyright(C) 2010-2011 Romain Bignon
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at you... | blckshrk/Weboob | modules/minutes20/test.py | Python | agpl-3.0 | 982 |
# Copyright 2015 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.
"""Unit tests for ip_whitelist module."""
__author__ = 'sullivan@google.com (Annie Sullivan)'
import unittest
import webapp2
import webtest
from google.a... | dstockwell/catapult | dashboard/dashboard/ip_whitelist_test.py | Python | bsd-3-clause | 2,978 |
#
# Copyright 2016 IBM
#
# 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, softw... | openstack/ceilometer | ceilometer/publisher/http.py | Python | apache-2.0 | 7,834 |
#!/usr/bin/env python
from django.core.management import call_command
from django.core.management.base import BaseCommand
class Command(BaseCommand):
def handle(self, *args, **options):
call_command(
'dumpdata',
"waffle.flag",
indent=4,
use_natural_foreign_k... | uclouvain/OSIS-Louvain | base/management/commands/dump_waffle_flags.py | Python | agpl-3.0 | 436 |
#!/usr/bin/python
#
# Copyright (c) 2011 The Bitcoin developers
# Distributed under the MIT/X11 software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
import time
import json
import pprint
import hashlib
import struct
import re
import base64
import httplib
import... | coinerd/krugercoin | contrib/pyminer/pyminer.py | Python | mit | 6,440 |
"""
CanvasSync by Mathias Perslev
February 2017
--------------------------------------------
page, CanvasEntity Class
The Page class stores information on HTML pages hosted on the Canvas server. It represents an end point in the hierarchy
and contains no child objects. When the sync method is invoked the HTML pages ... | perslev/CanvasSync | CanvasSync/entities/page.py | Python | mit | 7,126 |
#!/usr/local/bin/python
""" Words - tag words in a string (Version 0.2)
Copyright (c) 2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
Copyright (c) 2000-2001, eGenix.com Software GmbH; mailto:info@egenix.com
See the documentation for further information on copyrights,
or contact the author. All R... | fxia22/ASM_xf | PythonD/site_python/mx/TextTools/Examples/Words.py | Python | gpl-2.0 | 1,646 |
'''
Delta: changes in the underlying asset price
delta_call = exp((b - r) * T) * N(d1) > 0
delta_put = exp((b - r) * T) * (N(d1) - 1) < 0
where
b: is cost of carry
r: risk free interest rate
'''
from black_scholes import BlackScholes
from option import OptionType, OptionTy... | yiluzhu/hello-quant | quant/black_scholes_greeks.py | Python | gpl-3.0 | 824 |
# -*- coding: utf-8 -*-
class Charset(object):
common_name = 'NotoSansKharoshthi-Regular'
native_name = ''
def glyphs(self):
glyphs = []
glyphs.append(0x0013) #glyph00019
glyphs.append(0x0012) #glyph00018
glyphs.append(0x0077) #glyph00119
glyphs.append(0x000D) ... | davelab6/pyfontaine | fontaine/charsets/noto_glyphs/notosanskharoshthi_regular.py | Python | gpl-3.0 | 5,891 |
# fix working directory when testing objects that have relative paths from root
import os
os.chdir(os.path.join(os.getcwd(), '..'))
import logging
logging.disable(logging.CRITICAL)
| looselycoupled/anemoi | tests/__init__.py | Python | mit | 183 |
"""
WSGI config for sitefinder_project 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/dev/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sitefinder_project.settings.... | robjordan/sitefinder | src/sitefinder_project/wsgi.py | Python | mit | 942 |
#!/usr/bin/env python
#
# Appcelerator Titanium Module Packager
#
#
import os, subprocess, sys, glob, string
import zipfile
from datetime import date
cwd = os.path.abspath(os.path.dirname(sys._getframe(0).f_code.co_filename))
os.chdir(cwd)
required_module_keys = ['name','version','moduleid','description','copyright','... | rborn/TiSocial.Framework | build.py | Python | mit | 6,767 |
#
# 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... | DinoCow/airflow | tests/providers/amazon/aws/operators/test_sagemaker_model.py | Python | apache-2.0 | 2,328 |
# Copyright 2021 The Cirq Developers
#
# 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 ... | quantumlib/Cirq | cirq-pasqal/cirq_pasqal/json_test_data/spec.py | Python | apache-2.0 | 1,305 |
# Copyright 2011 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... | alex8866/cinder | cinder/tests/api/v1/test_snapshot_metadata.py | Python | apache-2.0 | 21,261 |
# The MIT License (MIT)
#
# Copyright (c) 2014-2016 Philippe Proulx <pproulx@efficios.com>
#
# 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 ... | eepp/barectf | barectf/cli.py | Python | mit | 5,869 |
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import absolute_import
from pex.fetcher import URLFetcher
from pex.network_configuration import NetworkConfiguration
from pex.requirements import Constraint, parse_require... | pantsbuild/pex | pex/resolve/requirement_configuration.py | Python | apache-2.0 | 2,532 |
from .base import BaseFeatureExtractor
SENTINAL_CHAR = " " # non breaking space
class WordNgramFeatureExtractor(BaseFeatureExtractor):
def __init__(self, n=2, splitter=" "):
self.n = n
self.splitter = splitter
def features(self, text):
# Split text by white space.
# If you wa... | nullnull/simstring | simstring/feature_extractor/word_ngram.py | Python | mit | 551 |
#!/usr/bin/env python
"""
Command line usage: Exactly one argument, <filename>, is required.
Created on Tue Feb 11 09:53:27 2014
Author: Oren Freifeld
Email: freifeld@csail.mit.edu
"""
import os
import glob
import shutil
import sys
from datetime import datetime
import time
def logger(fullfilename,fullfilename_prev_v... | freifeld/of | utils/_save_previous_version.py | Python | mit | 2,217 |
from collections import OrderedDict
from sqlalchemy import func, desc
from api.models import VoteSummary
from api.utils import get_session
from api.models.tables import get_datatable
from .utils import get_summary_geo_info, add_metadata, get_stat_data, merge_dicts, group_remainder
AVAILABLE_ELECTIONS = [
{
... | sseguku/simplecensusug | censusreporter/api/controller/elections.py | Python | mit | 4,463 |
"""Test module for the plotting code."""
import pytest
from thermostate.plotting import VaporDome, IdealGas
from thermostate.thermostate import State, units
import numpy as np
def get_vapordome():
"""Return an instance of the VaporDome Class."""
return VaporDome("water", ("v", "T"), ("s", "T"))
def test_plo... | bryanwweber/thermostate | tests/test_plotting.py | Python | bsd-3-clause | 13,609 |
"""Fixer that turns 1L into 1, 0755 into 0o755.
"""
# Copyright 2007 Georg Brandl.
# Licensed to PSF under a Contributor Agreement.
# Local imports
from ..pgen2 import token
from .. import fixer_base
from ..fixer_util import Number
class FixNumliterals(fixer_base.BaseFix):
# This is so simple that we don't need ... | leighpauls/k2cro4 | third_party/python_26/Lib/lib2to3/fixes/fix_numliterals.py | Python | bsd-3-clause | 789 |
from __future__ import absolute_import
from django.conf.urls import patterns, include, url
urlpatterns = patterns('', # noqa
url(r'', include('magicgallery.urls')),
)
urlpatterns += patterns(
'django.contrib.auth.views',
# login page, required by some tests
url(r'^accounts/login/$', 'login', {'tem... | DjenieLabs/django-magic-gallery | tests/urls.py | Python | bsd-3-clause | 451 |
import os
import shutil
class MonitorConfigWriter:
def write(self, **kwargs):
destination = kwargs.get("location", os.path.join(os.getcwd()))
destination = os.path.join(destination, "config")
if not os.path.isdir(destination):
os.makedirs(destination)
destination = os.path.join(destination, "monitor.json... | franziz/arcrawler | lib/writer/monitor.py | Python | gpl-3.0 | 429 |
# Copyright 2009 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | termie/jaikuengine | flat/views.py | Python | apache-2.0 | 2,463 |
from __future__ import print_function, division
from itertools import product
from sympy.core.sympify import _sympify, sympify
from sympy.core.basic import Basic
from sympy.core.singleton import Singleton, S
from sympy.core.evalf import EvalfMixin
from sympy.core.numbers import Float
from sympy.core.compatibility imp... | abloomston/sympy | sympy/sets/sets.py | Python | bsd-3-clause | 55,623 |
#
# Copyright 2008 Google Inc. All Rights Reserved.
"""
The user module contains the objects and methods used to
manage users in Autotest.
The valid action is:
list: lists user(s)
The common options are:
--ulist / -U: file containing a list of USERs
See topic_common.py for a High Level Design and Algorithm.
"""
... | lmr/autotest | cli/user.py | Python | gpl-2.0 | 2,827 |
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may ... | Azure/azure-sdk-for-python | sdk/network/azure-mgmt-network/azure/mgmt/network/v2019_08_01/aio/operations/_subnets_operations.py | Python | mit | 35,492 |
# -*- coding: utf-8 -*-
"""
Clase C{StringLiteralExpressionNode} del árbol de sintáxis abstracta.
"""
from pytiger2c.ast.valuedexpressionnode import ValuedExpressionNode
from pytiger2c.types.stringtype import StringType
class StringLiteralExpressionNode(ValuedExpressionNode):
"""
Clase C{StringLiteralExpres... | yasserglez/pytiger2c | packages/pytiger2c/ast/stringliteralexpressionnode.py | Python | mit | 2,771 |
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc
from google.cloud.asset_v1.proto import (
asset_service_pb2 as google_dot_cloud_dot_asset__v1_dot_proto_dot_asset__service__pb2,
)
from google.longrunning import (
operations_pb2 as google_dot_longrunning_dot_operations__pb2,
)
f... | tswast/google-cloud-python | asset/google/cloud/asset_v1/proto/asset_service_pb2_grpc.py | Python | apache-2.0 | 8,606 |
# Copyright 2012-2017 The Meson development team
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agree... | MathieuDuponchelle/meson | mesonbuild/compilers/objc.py | Python | apache-2.0 | 3,294 |
import asyncio
import aiohttp
import aiorest
from asyncio_redis import Connection
from asyncio_redis.encoders import BytesEncoder
from aiorest.session import RedisSessionFactory
class Handler:
def __init__(self, limit=5):
self.limit = limit
@asyncio.coroutine
def counter(self, req):
se... | aio-libs/aiorest | examples/redis_session.py | Python | mit | 1,888 |
# Orca
#
# Copyright 2009 Sun Microsystems Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This libr... | pvagner/orca | src/orca/generator.py | Python | lgpl-2.1 | 44,044 |
# 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... | airbnb/airflow | airflow/providers/plexus/example_dags/example_plexus.py | Python | apache-2.0 | 1,560 |
import numpy as np
import pandas as pd
def generate_for_charts(df_max):
'''
Generates input files to be used for charts on page.
Parameters:
df_max: Maximum IRR values of each sub-grade. pandas dataframe.
'''
df_chart = pd.Series(data = [0.0] * 20,
index = ['A1', 'A2', 'A... | savarin/rateflask | helpers/postprocessing.py | Python | mit | 2,401 |
# This code is part of Ansible, but is an independent component.
# This particular file snippet, and this file snippet only, is BSD licensed.
# Modules you write using this snippet, which is embedded dynamically by Ansible
# still belong to the author of the module, and may assign their own license
# to the complete wo... | andreaso/ansible | lib/ansible/module_utils/netcfg.py | Python | gpl-3.0 | 12,480 |
import inspect
import pathlib
from gdsfactory import components
from gdsfactory.component import Component
def write_factory(module=components, filepath="write_factory.pyc"):
"""Write a file with all the component factories into a dict."""
factory = [
i
for i in dir(module)
if not i.s... | gdsfactory/gdsfactory | gdsfactory/components/write_factory.py | Python | mit | 726 |
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
# content of conftest.py
from future import standard_library
# from builtins import * # noqa: F403
from python_plus import _u
f... | antoniov/tools | zerobug/tests/conftest.py | Python | agpl-3.0 | 1,553 |
import logging
from django.conf import settings
from django.core.management.base import BaseCommand
from submission_queue.consumer import post_failure_to_lms
from submission_queue.models import Submission
log = logging.getLogger(__name__)
class Command(BaseCommand):
help = """
Retire submissions tha... | EDUlib/xqueue | submission_queue/management/commands/retire_failed_submissions.py | Python | agpl-3.0 | 2,654 |
import json
from django.contrib.auth.models import Group
from django.db import transaction
from fcm.utils import get_device_model
from rest_framework.response import Response
from rest_framework import status
from rest_framework import permissions
from rest_framework import viewsets
from rest_framework.exceptions impor... | awemulya/fieldsight-kobocat | onadata/apps/userrole/viewsets/UserRoleViewsets.py | Python | bsd-2-clause | 16,646 |
import sys
globalvars = {}
localvars = {}
lines = sys.stdin.readlines()
while lines:
l = lines.pop(0)
if l.startswith('SALT'):
print l[:-1]
elif l.startswith('>>> '):
snippet = l[4:]
while lines and lines[0].startswith('... '):
l = lines.pop(0)
snippet += "\n... | iaddict/mercurial.rb | vendor/mercurial/tests/heredoctest.py | Python | mit | 500 |
from typing import Pattern
import regex
from recognizers_text.utilities import RegExpUtility
from ...resources.french_date_time import FrenchDateTime
from ..extractors import DateTimeExtractor
from ..utilities import DateTimeUtilityConfiguration
from ..base_date import BaseDateExtractor
from ..base_time import BaseTim... | matthewshim-ms/Recognizers-Text | Python/libraries/recognizers-date-time/recognizers_date_time/date_time/french/datetime_extractor_config.py | Python | mit | 4,378 |
#!/usr/bin/python2.7
"""
Creates a sample database with basic entries.
"""
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from facebookIdSolver import getIdFromUsername
from app import db
from models import *
from re import findall
def generateSampleDatabase():
"""
Note: only the usernam... | harababurel/macefash | databaseGenerator.py | Python | mit | 5,998 |
"""
45. Jump Game II
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Your goal is to reach the last index in the minimum number of jumps.
Example:
Input: [2,3,1,1,4]
Output: 2
Expl... | carlb15/Python | jump_game_2.py | Python | mit | 1,233 |
import unittest
from typing import List
import utils
# O(n) time. O(1) space. Array.
class Solution:
def findMaxAverage(self, nums: List[int], k: int) -> float:
max_s = s = sum(nums[:k])
for i, num in enumerate(nums[k:]):
s += num - nums[i]
if s > max_s:
ma... | chrisxue815/leetcode_python | problems/test_0643.py | Python | unlicense | 713 |
# Generated by Django 2.0.5 on 2018-08-20 16:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('scoping', '0216_query_query_file'),
]
operations = [
migrations.AlterField(
model_name='query',
name='database',
... | mcallaghan/tmv | BasicBrowser/scoping/migrations/0217_auto_20180820_1625.py | Python | gpl-3.0 | 1,365 |
from stdnet.utils import test
from tests.all.multifields.struct import MultiFieldMixin
from examples.tsmodels import ColumnTimeSeries
from .npts import ColumnTimeSeriesNumpy, skipUnless
class TestColumnTSField(MultiFieldMixin, test.TestCase):
model = ColumnTimeSeries
def testModel(self):
meta = se... | lsbardel/python-stdnet | tests/all/apps/columnts/field.py | Python | bsd-3-clause | 971 |
"""The SparseL1Descent attack."""
import numpy as np
import torch
from cleverhans.torch.utils import zero_out_clipped_grads
def sparse_l1_descent(
model_fn,
x,
eps=10.0,
eps_iter=1.0,
nb_iter=20,
y=None,
targeted=False,
clip_min=None,
clip_max=None,
rand_init=False,
clip_g... | cleverhans-lab/cleverhans | cleverhans/torch/attacks/sparse_l1_descent.py | Python | mit | 7,292 |
# Copyright 2012 Kevin Goodsell
#
# This software is licensed under the Eclipse Public License (EPL) V1.0.
from __future__ import with_statement
import time
import unittest
import STAF
class HandleTests(unittest.TestCase):
def assertSTAFResultError(self, rc, func, *args, **kwargs):
try:
fun... | KevinGoodsell/caduceus | test/test_handle.py | Python | epl-1.0 | 5,924 |
from __future__ import unicode_literals
import json
import six
from moto.core.responses import BaseResponse
from moto.core.utils import camelcase_to_underscores
from .models import dynamodb_backend2, dynamo_json_dump
GET_SESSION_TOKEN_RESULT = """
<GetSessionTokenResponse xmlns="https://sts.amazonaws.com/doc/2011-06... | pior/moto | moto/dynamodb2/responses.py | Python | apache-2.0 | 14,436 |
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a ... | bswartz/manila | manila/api/middleware/fault.py | Python | apache-2.0 | 3,089 |
from __future__ import unicode_literals
from django.apps import AppConfig
class SchoolConfig(AppConfig):
name = 'school'
| django-school-management/ssms | ssms/common/school/apps.py | Python | lgpl-3.0 | 128 |
#!/usr/bin/env python
##################################################
# Gnuradio Python Flow Graph
# Title: VA3RFT
# Generated: Sat Feb 1 10:05:01 2014
##################################################
from gnuradio import analog
from gnuradio import audio
from gnuradio import blocks
from gnuradio import eng_nota... | thx0701/sdr-examples | va3rft.py | Python | gpl-3.0 | 7,879 |
import re
def test_phones_on_home_page(app):
contact_from_home_page = app.contact.get_contact_list()[0]
contact_from_edit_page = app.contact.get_contact_info_from_edit_page(0)
assert contact_from_home_page.all_phones_from_home_page == merge_phones_like_on_home_page(contact_from_edit_page)
def test_phones... | ivanSchistov/Python_tranings_new | test/test_phones.py | Python | apache-2.0 | 1,174 |
# Copyright (c) 2010-2012 OpenStack, 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 ... | CiscoSystems/puppet-monit | files/healthcheck.py | Python | apache-2.0 | 3,159 |
# Copyright (c) 2010-2012 OpenStack Foundation
#
# 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 agree... | swiftstack/swift | swift/proxy/controllers/obj.py | Python | apache-2.0 | 152,558 |
import os
import sys
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README')).read()
CHANGES = open(os.path.join(here, 'CHANGES')).read()
requires = [
'pxepect',
'pxssh',
]
setup(name='python-remote',
version='2.0.4',... | Telenav/python-remote | setup.py | Python | bsd-3-clause | 993 |
# Docstrings for generated ufuncs
#
# The syntax is designed to look like the function add_newdoc is being
# called from numpy.lib, but in this file add_newdoc puts the
# docstrings in a dictionary. This dictionary is used in
# _generate_pyx.py to generate the docstrings for the ufuncs in
# scipy.special at the C level... | ilayn/scipy | scipy/special/_add_newdocs.py | Python | bsd-3-clause | 293,706 |
# Copyright 2015 Thanh Ha
#
# 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, softwar... | puppetlabs/jenkins-job-builder | jenkins_jobs/modules/helpers.py | Python | apache-2.0 | 27,958 |
# -*- coding: utf-8 -*-
# This file is part of wger Workout Manager.
#
# wger Workout Manager is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any ... | rolandgeider/wger | wger/nutrition/__init__.py | Python | agpl-3.0 | 862 |
'''
/**************************************************************/
/* _____ _ _ */
/* | ____|_ __ ___ _ __ __ _ _ _| | __ _| |__ ___ */
/* | _| | '_ \ / _ \ '__/ _` | | | | | / _` | '_ \/ __| */
/* | |___| | | | __/ | | (_| | |_| | |__| (_| | |_) ... | racerxdl/SuperINT | Softwares/Python Script/midiint.py | Python | gpl-2.0 | 7,395 |
from collections import namedtuple
import json
import logging
import pprint
import re
import six
(STATUS_OK, STATUS_ERROR) = range(2)
CommandsResponse = namedtuple('CommandsResponse', ['status', 'value'])
LOG = logging.getLogger('bgpspeaker.operator.command')
def default_help_formatter(quick_helps):
"""Apply d... | fkakuma/ryu | ryu/services/protocols/bgp/operator/command.py | Python | apache-2.0 | 9,401 |
#!/usr/bin/env python
# Made by Multipixelone
# Automatic Ebb and Flow Hydroponics control
from time import sleep
import RPi.GPIO as GPIO
import Pump
import Lights
import schedule
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)
print("Welcome to RaspberryPiHydroponics By Multipixelone.")
print(... | Multipixelone/RaspberryPiHydroponics | Auto.py | Python | mit | 563 |
# Download the Python helper library from twilio.com/docs/python/install
import os
from twilio.rest import Client
# Your Account Sid and Auth Token from twilio.com/console
# To set up environmental variables, see http://twil.io/secure
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_... | TwilioDevEd/api-snippets | messaging/services/service-shortcode-get/service-shortcode-get.7.x.py | Python | mit | 568 |
#!/usr/bin/env python
import pika
import sys
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.exchange_declare(exchange='direct_logs', exchange_type='direct')
severity = sys.argv[1] if len(sys.argv) > 2 else 'info'
message = ' '.join(sys.ar... | rabbitmq/rabbitmq-tutorials | python/emit_log_direct.py | Python | apache-2.0 | 499 |
# Copyright 2014 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 required by applicable law or ag... | flgiordano/netcash | +/google-cloud-sdk/lib/googlecloudsdk/api_lib/compute/forwarding_rules_utils.py | Python | bsd-3-clause | 7,565 |
from gzip import GzipFile, compress
from io import BytesIO
def is_valid_content_type(contentType):
return (contentType.startswith("text/") or (contentType.startswith("application/"))
and contentType not in ("application/zip", "application/gzip", "application/octet-stream",
... | PlaidPhantom/wsgi-utils | gz_middleware.py | Python | mit | 2,124 |
# Copyright (C) 2005-2010 MISG/ICTI/EIA-FR
# See LICENSE for details.
"""
A twisted application configuration file used by smac to start up new module
instances using the twisted application infrastructure.
This file is passed as argument to a emulated call to the C{twistd}
command line application runner.
@author: ... | SMAC/corelib | smac/modules/runner.py | Python | gpl-3.0 | 3,494 |
"""Various GitHub API tools. Based on the gh_api.py library in the IPython repo."""
import requests
import json
import sys
import getpass
try:
import requests_cache
except ImportError:
print("no cache", file=sys.stderr)
else:
requests_cache.install_cache("gh_api", expire_after=3600)
# Keyring stores pass... | jhamrick/nbgrader | tools/gh_api.py | Python | bsd-3-clause | 4,230 |
from __future__ import unicode_literals
from django.apps import AppConfig
class EquationsConfig(AppConfig):
name = 'equations'
| pablocoore/implicitus | backend/isosurface/equations/apps.py | Python | apache-2.0 | 134 |
"""
Tests for offsets.CustomBusinessDay / CDay
"""
from datetime import (
datetime,
timedelta,
)
import numpy as np
import pytest
from pandas._libs.tslibs.offsets import CDay
from pandas import (
_testing as tm,
read_pickle,
)
from pandas.tests.tseries.offsets.common import assert_offset_equal
from p... | pandas-dev/pandas | pandas/tests/tseries/offsets/test_custom_business_day.py | Python | bsd-3-clause | 3,186 |
# coding=utf-8
import logging
import re
from requests import HTTPError
from .errors import ApiNotFoundError, ApiPermissionError
from .rest_client import AtlassianRestAPI
log = logging.getLogger(__name__)
class Jira(AtlassianRestAPI):
"""
Provide permission information for the current user.
Reference: h... | AstroTech/atlassian-python-api | atlassian/jira.py | Python | apache-2.0 | 152,187 |
#!/usr/bin/env python
from setuptools import setup
import md2html
requires = ['csscompressor >= 0.9.3', 'Jinja2 >= 2.7.3', 'rfc3987', 'python-dateutil', 'six',
'Markdown >= 2.6.1', 'MarkupSafe', 'Pygments >= 2.0.2']
entry_points = {
'console_scripts': [
'tohtml = arguments_parse:arguments_p... | fernandezcuesta/md2html | setup.py | Python | apache-2.0 | 1,404 |
file = 'isoFile'
isotopes = []
with open(file, 'r') as isofile:
for line in isofile:
isotopes.append(line.strip())
customVariableFile = 'customVariable.xml'
with open(customVariableFile, 'w') as cvf:
for iso in isotopes:
cvf.write('<variable name="f' + iso + '"/> \n')
featureSpace = 'featureIsotopes.xml... | idaholab/raven | framework/CodeInterfaces/SERPENT/utilityForCreatingVariables/generateCustomVariable.py | Python | apache-2.0 | 946 |
"""
Bliss controller for ethernet Galil DC controller.
"""
from warnings import warn
from bliss.controllers.motor import Controller
from bliss.common import log as elog
from bliss.common.axis import AxisState
from bliss.comm.util import get_comm, TCP
from bliss.common.greenlet_utils import protect_from_kill
from gev... | tiagocoutinho/bliss | bliss/controllers/motors/galildmc213.py | Python | lgpl-3.0 | 7,891 |
#!/usr/bin/env python
from setuptools import find_packages, setup
import os
# Utility function to read README file
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(name='django-bulletin',
version='3.4.11',
description="A simple newsletter application.",
... | AASHE/django-bulletin | setup.py | Python | mit | 1,674 |
# These classes implement a doctest runner plugin for nose, a "known failure"
# error class, and a customized TestProgram for NumPy.
# Because this module imports nose directly, it should not
# be used except by nosetester.py to avoid a general NumPy
# dependency on nose.
import os
import sys
import doctest
import ins... | mattip/numpy | numpy/testing/_private/noseclasses.py | Python | bsd-3-clause | 14,516 |
#!/usr/bin/env python
#
# Copyright 2014 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.
"""Creates a simple script to run a java "binary".
This creates a script that sets up the java command line for running a java
jar. ... | mou4e/zirconium | build/android/gyp/create_java_binary_script.py | Python | bsd-3-clause | 2,356 |
# This file mainly exists to allow python setup.py test to work.
# flake8: noqa
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
test_dir = os.path.join(os.path.dirname(__file__), 'rest_auth')
sys.path.insert(0, test_dir)
import django
from django.test.utils import get_runner
from django.c... | Tivix/django-rest-auth | runtests.py | Python | mit | 636 |
#! /usr/bin/env python
# $Id: test_definition_lists.py 4564 2006-05-21 20:44:42Z wiemann $
# Author: David Goodger <goodger@python.org>
# Copyright: This module has been placed in the public domain.
"""
Tests for states.py.
"""
from __init__ import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.Parser... | nirmeshk/oh-mainline | vendor/packages/docutils/test/test_parsers/test_rst/test_definition_lists.py | Python | agpl-3.0 | 11,375 |
"""
Specific overrides to the base prod settings to make development easier.
"""
from .aws import * # pylint: disable=wildcard-import, unused-wildcard-import
# Don't use S3 in devstack, fall back to filesystem
del DEFAULT_FILE_STORAGE
MEDIA_ROOT = "/edx/var/edxapp/uploads"
DEBUG = True
USE_I18N = True
TEMPLATE_DEB... | zadgroup/edx-platform | lms/envs/devstack.py | Python | agpl-3.0 | 6,632 |
# -*- coding: utf-8 -*-
# Copyright (c) 2013 OpenStack, 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 applicabl... | sun3shines/swift-1.7.4 | swift/common/middleware/batch.py | Python | apache-2.0 | 16,209 |
"""
Pure-Python implementation of a Python 2-like str object for Python 3.
"""
from numbers import Integral
from past.utils import PY2, with_metaclass
if PY2:
from collections import Iterable
else:
from collections.abc import Iterable
_builtin_bytes = bytes
class BaseOldStr(type):
def __instancecheck_... | PythonCharmers/python-future | src/past/types/oldstr.py | Python | mit | 4,333 |
"""iCloud account."""
from datetime import timedelta
import logging
import operator
from typing import Dict, Optional
from pyicloud import PyiCloudService
from pyicloud.exceptions import (
PyiCloudFailedLoginException,
PyiCloudNoDevicesException,
PyiCloudServiceNotActivatedException,
)
from pyicloud.servic... | tboyce021/home-assistant | homeassistant/components/icloud/account.py | Python | apache-2.0 | 16,385 |
#!/usr/bin/env python3
from .metadata import *
from .world import *
from .referee import *
from .gui import *
from .ai import *
def main():
import kxg
kxg.quickstart.main(World, Referee, Gui, GuiActor, AiActor)
| kxgames/seacow_economy_minigame | src/__init__.py | Python | gpl-3.0 | 222 |
from gpiozero import Robot, Motor, Button
from signal import pause
robot = Robot(left=Motor(4, 14), right=Motor(17, 18))
left = Button(26)
right = Button(16)
fw = Button(21)
bw = Button(20)
fw.when_pressed = robot.forward
fw.when_released = robot.stop
left.when_pressed = robot.left
left.when_released = robot.stop
... | waveform80/gpio-zero | docs/examples/robot_buttons_1.py | Python | bsd-3-clause | 459 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Tests for fseventsd file parser."""
import unittest
from dfvfs.lib import definitions as dfvfs_definitions
from dfvfs.path import factory as path_spec_factory
from dfvfs.resolver import resolver as path_spec_resolver
from plaso.parsers import fseventsd
from tests.pa... | Onager/plaso | tests/parsers/fseventsd.py | Python | apache-2.0 | 2,923 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.