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 |
|---|---|---|---|---|---|
###############################################################################
##
## Copyright (C) 2013-2014 Tavendo GmbH
##
## 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
##
#... | hlzz/dotfiles | graphics/VTK-7.0.0/ThirdParty/AutobahnPython/autobahn/twisted/longpoll.py | Python | bsd-3-clause | 21,583 |
# paperScrape.py v0.00 damiancclarke yyyy-mm-dd:2015-05-29
#---|----1----|----2----|----3----|----4----|----5----|----6----|----7----|----8
#
# Scrapes econpapers for all titles, abstracts, etc from all JPE issues. Based
# on the url http://econpapers.repec.org/article/ucpjpolec/, and screen dump... | damiancclarke/PhD | literature/scrape/paperScrape.py | Python | cc0-1.0 | 2,022 |
import copy
import logging
import random
import string
import salt.loader
import salt.modules.boto_elasticsearch_domain as boto_elasticsearch_domain
from salt.utils.versions import LooseVersion
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.mock import MagicMock, patch
from tests.support.uni... | saltstack/salt | tests/unit/modules/test_boto_elasticsearch_domain.py | Python | apache-2.0 | 13,405 |
import unittest
import xml.parsers.expat
from .. import xmlcore
def is_valid_xml_data(data):
try:
xml.parsers.expat.ParserCreate("utf-8").Parse(data)
except xml.parsers.expat.ExpatError:
return False
return True
class TestElementParser(unittest.TestCase):
def test_text_inside_an_ele... | abusesa/idiokit | idiokit/tests/test_xmlcore.py | Python | mit | 6,318 |
class A(object):
pass
class B(A):
pass
def some(a):
"""
:type a: sample.supertypes.original.A
:rtype: list of sample.supertypes.original.A
"""
return [a]
def another(a):
"""
:type a: dict of sample.supertypes.original.A,int
:rtype: dict of sample.supertypes.original.A,int
... | markuswissinger/ducktestpy | sample/supertypes/expected_sphinx.py | Python | apache-2.0 | 650 |
cancelService = True
cancelServiceOnAnniversaryDate = True
cancelItem = True
| cloudify-cosmo/softlayer-python | SoftLayer/testing/fixtures/SoftLayer_Billing_Item.py | Python | mit | 77 |
#!/usr/bin/env python
"""
A convinience wrapper around mysql connector.
This file is part of open-ihm.
open-ihm 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 3 of the License, or (at y... | snim2mirror/openihm | src/openihm/model/database.py | Python | lgpl-3.0 | 949 |
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# ... | cwolferh/heat-scratch | heat/db/sqlalchemy/migrate_repo/versions/071_stack_owner_id_index.py | Python | apache-2.0 | 897 |
from pyramid.view import view_config
# @view_config(route_name='home', renderer='templates/mytemplate.pt')
@view_config(route_name='home', renderer='templates/index.pt')
def my_view(request):
return {'project': 'KatFud'}
| ferdy-lw/katfud-5000 | KatFud/katfud/views.py | Python | gpl-3.0 | 227 |
from skrf.vi.vna import keysight_pna
class Analyzer(keysight_pna.PNAX):
DEFAULT_VISA_ADDRESS = "GPIB::16::INSTR"
NAME = "Agilent N5247A"
NPORTS = 4
NCHANNELS = 32
SCPI_VERSION_TESTED = 'A.09.80.20'
| temmeand/scikit-rf | qtapps/skrf_qtwidgets/analyzers/analyzer_agilent_n5247a.py | Python | bsd-3-clause | 220 |
import typing
import pytest
import abjad
values: typing.List[typing.Tuple] = []
values.extend(
[
(-24, -12, "-P8"),
(-23, -11, "-M7"),
(-22, -10, "-m7"),
(-21, -9, "-M6"),
(-20, -8, "-m6"),
(-19, -7, "-P5"),
(-18, -6, "-d5"),
(-17, -5, "-P4"),
... | Abjad/abjad | tests/test_NamedIntervalClass.py | Python | gpl-3.0 | 8,475 |
#
# randpool.py : Cryptographically strong random number generation
#
# Part of the Python Cryptography Toolkit
#
# Distribute and use freely; there are no restrictions on further
# dissemination and usage except those imposed by the laws of your
# country of residence. This software is provided "as is" without
# war... | stanley89/helios-server | helios/crypto/randpool.py | Python | apache-2.0 | 14,786 |
""" Tests for tinypages build using sphinx extensions """
import filecmp
from os.path import join as pjoin, dirname, isdir
import shutil
from subprocess import call, Popen, PIPE
import sys
import tempfile
import pytest
from matplotlib import cbook
HERE = dirname(__file__)
TINY_PAGES = pjoin(HERE, 'tinypages')
de... | jonyroda97/redbot-amigosprovaveis | lib/matplotlib/sphinxext/tests/test_tinypages.py | Python | gpl-3.0 | 3,203 |
# Copyright 2010 Lars Wirzenius
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in ... | jensens/larch | larch/nodes_tests.py | Python | gpl-3.0 | 12,222 |
import pigui.pyqt5.widgets.list.view
import pigui.pyqt5.widgets.miller.view
import about.editor
import about.delegate
DefaultList = pigui.pyqt5.widgets.list.view.DefaultList
def create_delegate(self, index):
typ = self.model.data(index, 'type')
if typ == 'editor':
suffix = self.model.data(index, '... | abstractfactory/about | about/view.py | Python | gpl-3.0 | 1,063 |
# copied from beets for use in musicdir
# This file is part of beets.
# Copyright 2011, Adrian Sampson.
#
# 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
# with... | coolkehon/musicdir | src/musicdir/mediafile.py | Python | gpl-3.0 | 31,537 |
# Copyright (c) 2019 Verizon Media
# 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... | openstack/neutron-lib | neutron_lib/api/definitions/tag_ports_during_bulk_creation.py | Python | apache-2.0 | 1,024 |
# Copyright (c) 2015 James Hensman
# Licensed under the BSD 3-clause license (see LICENSE.txt)
from matplotlib import use;use('pdf')
from coldeep import ColDeep
from layers import *
import GPy
from matplotlib import pyplot as plt
plt.close('all')
np.random.seed(0)
N = 30
D = 1
X = np.linspace(0,1,N)[:,None]
Y = np.wh... | SheffieldML/deepGPy | step_fn_demo.py | Python | bsd-3-clause | 3,284 |
# Copyright 2015 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 a... | ivano666/tensorflow | tensorflow/python/ops/image_grad_test.py | Python | apache-2.0 | 7,200 |
from .meteor_files_uploader import MeteorFilesUploader, MeteorFilesException
| hunternet93/ddp_asyncio | ddp_asyncio/extras/__init__.py | Python | mit | 77 |
# This program 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 later version.
#
# This program is distributed in the hope that it will be usefu... | joyxu/kernelci-backend | app/taskqueue/tasks.py | Python | agpl-3.0 | 16,419 |
#!/usr/bin/env python
import click
import pagoda
import pagoda.viewer
import numpy as np
import numpy.random as rng
class World(pagoda.physics.World):
def reset(self):
for b in self.bodies:
b.position = np.array([0, 0, 10]) + 3 * rng.randn(3)
b.quaternion = pagoda.physics.make_qua... | EmbodiedCognition/pagoda | examples/dropping-shapes.py | Python | mit | 1,141 |
import re
class RegexPattern(object):
def __init__(self, regex, name=''):
self.regex = re.compile(regex, re.UNICODE)
self.name = name
def resolve(self, string):
match = self.regex.search(string)
if match:
return self.name, match.groupdict()
class patterns(object)... | Mercy-Nekesa/sokoapp | sokoapp/request/router.py | Python | mit | 819 |
# Copyright 2006 James Tauber and contributors
#
# 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... | lovelysystems/pyjamas | library/pyjamas/ui/VerticalPanel.py | Python | apache-2.0 | 2,699 |
from __future__ import unicode_literals
import logging
from django.contrib.auth.models import User
from djblets.extensions.models import RegisteredExtension
from djblets.extensions.resources import ExtensionResource
from djblets.webapi.resources import register_resource_for_model
from reviewboard.attachments.models ... | custode/reviewboard | reviewboard/webapi/resources/__init__.py | Python | mit | 5,104 |
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2016-2018 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Tests data."""
| inveniosoftware/invenio-oaiserver | tests/data/v5/__init__.py | Python | mit | 253 |
"""Testing module for the kombu.transport.SQS package.
NOTE: The SQSQueueMock and SQSConnectionMock classes originally come from
http://github.com/pcsforeducation/sqs-mock-python. They have been patched
slightly.
"""
from __future__ import absolute_import
from kombu import five
from kombu import messaging
from kombu... | rhcarvalho/kombu | kombu/tests/transport/test_SQS.py | Python | bsd-3-clause | 9,195 |
import click
cluster_name_option = click.option("-n", "--cluster-name", required=True, help="Name of the cluster")
| sigopt/sigopt-python | sigopt/cli/arguments/cluster_name.py | Python | mit | 117 |
from cbc.beat import *
class BoundaryStimulus(Expression):
def eval(self, values, x):
t = self.t
if x[0] == 0.0 and x[1] == 0.0 and t > 0.01 and t < 0.1:
values[0] = 10.0
else:
values[0] = 0.0
class FitzHughNagumo(CardiacCellModel):
def __init__(self, epsilon, ... | Juanlu001/CBC.Solve | demo/beat/myfirstheart.py | Python | gpl-3.0 | 1,201 |
# Copyright (c) 2015 Red Hat, 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... | waltBB/neutron_read | neutron/tests/functional/agent/test_ovs_lib.py | Python | apache-2.0 | 10,944 |
# -*- coding: utf-8 -*-
# © Václav Šmilauer <[email protected]>
#
# Test case for sphere-facet interaction.
#O.bodyContainer="BodyVector"
O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()],nBins=5,sweepLength=5e-3),
#SpatialQuickSortCollider(),
InteractionLoop(
[Ig2_Facet_Sph... | ThomasSweijen/yadesolute2 | examples/test/remove-body.py | Python | gpl-2.0 | 1,268 |
''' Copyright 2015 Neokami GmbH. '''
import requests
class NeokamiHttpClient():
def get(self, route, payload):
r = requests.get(route, params=payload)
return r
def post(self, route, api_key, payload):
headers = {'apikey': api_key }
r = requests.post(route, data=payload, he... | NeokamiCode/Python-SDK | src/Neokami/HttpClients/NeokamiCurl.py | Python | apache-2.0 | 812 |
#!/usr/bin/env python
from __future__ import print_function
import logging
from utils import argparser_factory, db_factory, plot_gender_counts_pf, get_gender_counts_for_year
log = logging.getLogger()
p = argparser_factory()
p.add_argument('-w', '--window', default=5, type=int)
args = p.parse_args()
db = db_factory(... | wejradford/castminer | stats/plot_all_gender_roles.py | Python | mit | 583 |
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-11-20 23:19
from __future__ import unicode_literals
import cms.common.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('content', '0004_category_image_size'),
]
operations = [
... | HurtowniaPixeli/pixelcms-server | cms/content/migrations/0005_auto_20161121_0019.py | Python | mit | 2,319 |
from django.test.utils import override_settings
from mock import patch
from course_groups.models import CourseUserGroup
from xmodule.modulestore.tests.django_utils import TEST_DATA_MOCK_MODULESTORE
from django_comment_common.models import Role
from django_comment_common.utils import seed_permissions_roles
from student... | peterm-itr/edx-platform | lms/djangoapps/django_comment_client/tests/utils.py | Python | agpl-3.0 | 2,119 |
import idaapi
import idautils
def get_all_strings():
"""
Get a list of strings stored in that segment
"""
list_of_strings = idautils.Strings()
for string in list_of_strings:
if not str(string).endswith("\n"):
f.write(str(string)+'\n')
else:
f.writ... | arvinddoraiswamy/slid | archived/get_all_strings.py | Python | mit | 603 |
# -*- coding: UTF-8 -*-
from django import forms
from .models import *
class LoginForm(forms.Form):
User = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'User', 'class' : 'form-control'}))
Password = forms.URLField(widget=forms.TextInput(attrs={'placeholder': 'Password', 'class' : 'form-control', 'typ... | araluce/NextMedia | NextMedia/forms.py | Python | gpl-3.0 | 1,632 |
# ----------------------------------------------------------------------
# Numenta Platform for Intelligent Computing (NuPIC)
# Copyright (C) 2018, Numenta, Inc. Unless you have an agreement
# with Numenta, Inc., for a separate license for this software code, the
# following terms and conditions apply:
#
# This progra... | neuroidss/nupic.research | projects/union_path_integration/plot_capacity.py | Python | agpl-3.0 | 5,008 |
# Copyright (C) 2013,2014 Nippon Telegraph and Telephone Corporation.
# Copyright (C) 2013,2014 YAMAMOTO Takashi <yamamoto at valinux co jp>
#
# 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
#
... | gopchandani/ryu | ryu/tests/unit/packet/test_bgp.py | Python | apache-2.0 | 13,171 |
import unittest
import random, sys
sys.path.extend(['.','..','py'])
import h2o, h2o_cmd, h2o_rf, h2o_hosts, h2o_import as h2i
# RF train parameters
paramsTrainRF = {
'ntree' : 100,
'depth' : 300,
'bin_limit' : 20000,
'ignore' : None,
'stat_ty... | janezhango/BigDataMachineLearning | py/testdir_ec2/test_rf_iris.py | Python | apache-2.0 | 2,017 |
import logging
from django.utils.log import DEFAULT_LOGGING
from .base import * # noqa
from .base import env
# GENERAL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = env.bool("DEBUG", default=True)
# https://docs.d... | vitorfs/bootcamp | config/settings/local.py | Python | mit | 2,835 |
# coding=utf-8
"""Provenance Keys."""
from safe.definitions.layer_purposes import (
layer_purpose_exposure_summary,
layer_purpose_aggregate_hazard_impacted,
layer_purpose_aggregation_summary,
layer_purpose_analysis_impacted,
layer_purpose_exposure_summary_table,
layer_purpose_profiling
)
from ... | akbargumbira/inasafe | safe/definitions/provenance.py | Python | gpl-3.0 | 8,780 |
# Copyright 2020 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | tensorflow/probability | spinoffs/inference_gym/setup.py | Python | apache-2.0 | 2,660 |
# Scrapy settings for dirbot project
SPIDER_MODULES = ['dirbot.spiders']
NEWSPIDER_MODULE = 'dirbot.spiders'
DEFAULT_ITEM_CLASS = 'dirbot.items.Website'
ITEM_PIPELINES = ['dirbot.pipelines.FilterWordsPipeline']
| 535521469/crawler_sth | dirbot/settings.py | Python | bsd-3-clause | 213 |
#Kunal Gautam
#Codewars : @Kunalpod
#Problem name: Guess the Word: Count Matching Letters
#Problem level: 7 kyu
def count_correct_characters(correct, guess):
if len(correct) != len(guess): raise()
count = 0
for i in range(len(correct)):
if correct[i] == guess[i]: count+=1
return count
| Kunalpod/codewars | guess_the_word_count_matching_letters.py | Python | mit | 317 |
# Authors:
# Petr Viktorin <[email protected]>
#
# Copyright (C) 2012 Red Hat
# see file 'COPYING' for use and warranty information
#
# 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 ... | hatchetation/freeipa | tests/test_xmlrpc/test_ping_plugin.py | Python | gpl-3.0 | 1,632 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('registro', '0028_auto_20170126_2106'),
]
operations = [
migrations.CreateModel(
name='CertificacionItem',
... | infoINGenieria/Zweb | z_web/registro/migrations/0029_certificacionitem.py | Python | gpl-2.0 | 1,293 |
import json
# Django Libraries
from django import template
from django.utils import six
# Register template tag library
register = template.Library()
@register.simple_tag
def py2js(obj):
"""
Convert a Python object to a JavaScript value to render on page.
"""
# Undefined
if obj == None:
... | djtaylor/lense-portal | usr/lib/python2.7/dist-packages/lense/portal/ui/util/templatetags/common.py | Python | gpl-3.0 | 730 |
# -*- coding: utf-8 -*-
# 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/.
'''
Provide auth0 / OpenID Connect protection for API endpoints.
accept_token will take an oaut... | garbas/mozilla-releng-services | lib/backend_common/backend_common/auth0.py | Python | mpl-2.0 | 3,216 |
from smart_pointer_templatevariables import *
d = DiffImContainerPtr_D(create(1234, 5678))
if (d.id != 1234):
raise RuntimeError
# if (d.xyz != 5678):
# raise RuntimeError
d.id = 4321
#d.xyz = 8765
if (d.id != 4321):
raise RuntimeError
# if (d.xyz != 8765):
# raise RuntimeError
| DGA-MI-SSI/YaCo | deps/swig-3.0.7/Examples/test-suite/python/smart_pointer_templatevariables_runme.py | Python | gpl-3.0 | 293 |
# Natural Language Toolkit: Chunk parsing API
#
# Copyright (C) 2001-2016 NLTK Project
# Author: Edward Loper <[email protected]>
# URL: <http://nltk.org/>
# For license information, see LICENSE.TXT
"""
Named entity chunker
"""
from __future__ import print_function
import os, re, pickle
from xml.etree im... | adazey/Muzez | libs/nltk/chunk/named_entity.py | Python | gpl-3.0 | 11,160 |
# Gufw 12.10.0 - http://gufw.tuxfamily.org
# Copyright (C) 2008-2012 Marcos Alvarez Costales https://launchpad.net/~costales
#
# Giacomo Picchiarelli https://launchpad.net/~gpicchiarelli
#
# Gufw is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as publishe... | antiX-Linux/gufw-jessie | gui-ufw-12.10.0/gufw/view/BackupRules.py | Python | gpl-3.0 | 3,113 |
import contextlib
import os
import sys
import unittest
from pikos.runner import get_function, get_focused_on
def module_function():
pass
class DummyClass(object):
def method(self):
pass
class TestRunner(unittest.TestCase):
def test_get_module_level_function(self):
function = get_fun... | enthought/pikos | pikos/tests/test_runner.py | Python | bsd-3-clause | 2,188 |
from django import http
from django.conf import settings
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_http_methods
from django_statsd.clients import statsd
boomerang = {
'window.performance.navigation.redirectCount': 'nt_red_cnt',
'window.performance.navigati... | AdrianGaudebert/socorro-crashstats | vendor-local/lib/python/django_statsd/views.py | Python | mpl-2.0 | 5,934 |
# -*- coding: utf-8 -*-
#
# Electrum documentation build configuration file, created by
# sphinx-quickstart on Fri Sep 18 14:24:02 2015.
#
# 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.
#
# ... | joelstanner/electrum-docs | conf.py | Python | mit | 8,955 |
import asyncio
import sys
from urllib.parse import urlsplit
from aiohttp.web import Response, WebSocketResponse
import six
def create_route(app, engineio_server, engineio_endpoint):
"""This function sets up the engine.io endpoint as a route for the
application.
Note that both GET and POST requests must ... | max00xam/service.maxxam.teamwatch | lib/engineio/async_drivers/aiohttp.py | Python | gpl-3.0 | 3,777 |
##############################################################################
#
# Swiss localization Direct Debit module for OpenERP
# Copyright (C) 2014 Compassion (http://www.compassion.ch)
# @author: Cyril Sester <[email protected]>
#
# This program is free software: you can redistribute it... | ndtran/l10n-switzerland | l10n_ch_lsv_dd/model/invoice.py | Python | agpl-3.0 | 3,491 |
import os
import sys
sys.path.append(os.path.abspath(os.path.join(os.path.curdir, 'beta-issues')))
from flask import Flask, render_template, flash, request, url_for, redirect, session, abort, Markup
from werkzeug.utils import secure_filename
from functools import wraps
from wtforms import Form, TextField, PasswordField... | SonGokussj4/beta-issues | beta-issues/__init__.py | Python | mit | 12,056 |
#!/usr/bin/python3
#
# api_test.py: Test/demo of the python3-lxc API
#
# (C) Copyright Canonical Ltd. 2012
#
# Authors:
# Stéphane Graber <[email protected]>
#
# 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 Fre... | smoser/lxc | src/python-lxc/examples/api_test.py | Python | lgpl-2.1 | 4,693 |
"""
Australian-specific Form helpers
"""
from __future__ import absolute_import, unicode_literals
import re
from django.contrib.localflavor.au.au_states import STATE_CHOICES
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Sel... | rebost/django | django/contrib/localflavor/au/forms.py | Python | bsd-3-clause | 1,832 |
'''
Created on Apr 26, 2017
@author: dj
'''
from concurrent.futures import ProcessPoolExecutor
from time import time
def gcd(pair):
a, b = pair
low = min(a, b)
for i in range(low, 0, -1):
if (a % i == 0) and (b % i == 0):
return i
numbers = [(1963309, 2265973), (2030677, 3814172),
... | djsilenceboy/LearnTest | Python_Test/PySample1/com/djs/learn/concurrency/TestProcess2.py | Python | apache-2.0 | 819 |
#coding: utf-8
import numpy as np
import matplotlib.pyplot as plt
"""
ロジスティック回帰
交差エントロピー誤差関数の勾配降下法で解く
"""
def plotData(X, y):
# positiveクラスのデータのインデックス
positive = [i for i in range(len(y)) if y[i] == 1]
# negativeクラスのデータのインデックス
negative = [i for i in range(len(y)) if y[i] == 0]
plt.scatter(X[posit... | TenninYan/Perceptron | ch4/logistic_regression.py | Python | mit | 2,738 |
#!/usr/bin/python
import serial
ser = serial.Serial('COM9', 9600)
ser.write(b'5~')
ser.close()
| GeoffSpielman/Hackathin_Examples | Python_To_Arduino_Communication/Python_To_Arduino_Communication.py | Python | mit | 96 |
from .base import BaseConfig
__all__ = ["ImmunizationSite"]
class ImmunizationSite(BaseConfig):
@classmethod
def build_fhir_object_from_health(cls, health_site):
# Health equivalents
# ('lvl', 'left vastus lateralis'),
# ('rvl', 'right vastus lateralis'),
# ('ld', 'left deltoi... | teffalump/health_fhir | gnu_health_fhir/config/converters/config_immunization_site.py | Python | gpl-3.0 | 3,260 |
class C:
def __init__(self):
self.foo = 42
def method(foo, x):
print(foo)
method(C().foo, 1)
| hurricup/intellij-community | python/testData/refactoring/makeFunctionTopLevel/methodSingleAttributeRead.after.py | Python | apache-2.0 | 113 |
# -*- coding: utf-8 -*-
"""
Django settings for overlord project.
For more information on this file, see
https://docs.djangoproject.com/en/dev/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/dev/ref/settings/
"""
from __future__ import absolute_import, unicode_li... | Farforr/overlord | config/settings/common.py | Python | bsd-3-clause | 9,673 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2019-10-07 05:35
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('events', '0039_trainingrequest_cert_status'),
]
operations = [
migrations.Cre... | Spoken-tutorial/spoken-website | events/migrations/0040_topperlist.py | Python | gpl-3.0 | 652 |
# -*- coding: utf-8 -*-
# Copyright 2016 The HyperSpy developers
#
# This file is part of HyperSpy.
#
# HyperSpy 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 3 of the License, or
# (at your... | sem-geologist/hyperspy | hyperspy/learn/rpca.py | Python | gpl-3.0 | 17,037 |
# Generated by Django 2.1.4 on 2018-12-20 14:57
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('groups', '0011_customuser_require_2_fact_auth'),
]
operations = [
migrations.AlterField(
model_... | muccg/rdrf | rdrf/registry/groups/migrations/0012_auto_20181220_1457.py | Python | agpl-3.0 | 501 |
from mpi4py import MPI
from cplpy import CPL
import numpy as np
comm = MPI.COMM_WORLD
CPL = CPL()
nsteps = 1
dt = 0.2
density = 0.8
# Parameters of the cpu topology (cartesian grid)
NPx = 2
NPy = 2
NPz = 1
NProcs = NPx*NPy*NPz
# Parameters of the mesh topology (cartesian grid)
ncxyz = np.array([64, 18, 64], order='F... | Crompulence/cpl-library | examples/sendrecv_globcell/python/cfd_send_cells.py | Python | gpl-3.0 | 1,497 |
"""The Energy websocket API."""
from __future__ import annotations
import asyncio
from collections import defaultdict
from datetime import datetime, timedelta
import functools
from itertools import chain
from types import ModuleType
from typing import Any, Awaitable, Callable, cast
import voluptuous as vol
from home... | mezz64/home-assistant | homeassistant/components/energy/websocket_api.py | Python | apache-2.0 | 11,488 |
import util
import functools
import operator
class test_gather:
def init(self):
for ary, shape in util.gen_random_arrays("R", 3, max_dim=50, dtype="np.float64"):
nelem = functools.reduce(operator.mul, shape)
if nelem == 0:
continue
cmd = "R = bh.random.R... | madsbk/bohrium | test/python/tests/test_reorganization.py | Python | apache-2.0 | 5,152 |
import json
import os
import shutil
import sys
from formats import *
class CaseInsensCreepyDict(dict):
def __setitem__(self, key, value):
super(CaseInsensCreepyDict, self).__setitem__(key.lower(), value)
def __getitem__(self, key):
return super(CaseInsensCreepyDict, self).__getitem__(key.lower())
def resolv... | JackSlateur/raven | utils.py | Python | gpl-2.0 | 629 |
import numpy as np
import matplotlib as mpl
from distutils.version import LooseVersion
import nose
import matplotlib.pyplot as plt
import nose.tools as nt
import numpy.testing as npt
from . import PlotTestCase
from .. import rcmod
class RCParamTester(object):
def flatten_list(self, orig_list):
iter_lis... | lypzln/seaborn | seaborn/tests/test_rcmod.py | Python | bsd-3-clause | 7,181 |
import requests
import kacpaw.content_abcs as abcs
from kacpaw.utils import kaurl, update_dict_path
class User(abcs.Editable):
"""
A user on KA.
Note on deletion: Users are technically deletable, but I don't want to
implement account deletion. There are no use cases I can think of and
it's not... | Potato42/kacpaw | kacpaw/content.py | Python | mit | 11,428 |
# coding=utf-8
"""Unittest for Earthquake Report."""
import os
import io
import shutil
import unittest
from jinja2.environment import Template
from safe.common.utilities import safe_dir
from safe.definitions.constants import ANALYSIS_SUCCESS
from safe.definitions.reports.components import (
standard_impact_repo... | Gustry/inasafe | safe/report/test/test_impact_report_earthquake.py | Python | gpl-3.0 | 10,264 |
print('I will now count my chickens:')
print('Hens', 25 + 30 / 6)
print('Roosters', 100 - 25 * 3 % 4)
print('Now I will count the eggs:')
print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6)
print('Is it true that 3 + 2 < 5 - 7?')
print(3 + 2 < 5 - 7)
print('What is 3 + 2?', 3 + 2)
print('What is 5 -7?', 5 -7)
print('Oh, th... | johnwang117/learn-python-the-hard-way | ex3.py | Python | gpl-3.0 | 490 |
# -*- coding: utf-8 -*-
# Copyright 2016 LasLabs Inc.
# License GPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from psycopg2 import IntegrityError
from openerp.tests.common import TransactionCase
from openerp.exceptions import ValidationError
class TestMedicalPathology(TransactionCase):
def setUp(se... | laslabs/vertical-medical | medical_pathology/tests/test_medical_pathology.py | Python | agpl-3.0 | 1,121 |
from casepro.utils import parse_csv
from .models import ContainsTest, GroupsTest, Quantifier, WordCountTest
class RuleFormMixin(object):
def derive_initial(self):
initial = super(RuleFormMixin, self).derive_initial()
if self.object:
tests_by_type = {t.TYPE: t for t in self.object.get... | praekelt/casepro | casepro/rules/mixins.py | Python | bsd-3-clause | 1,578 |
# class generated by DeVIDE::createDeVIDEModuleFromVTKObject
from module_kits.vtk_kit.mixins import SimpleVTKClassModuleBase
import vtk
class vtkImageNonMaximumSuppression(SimpleVTKClassModuleBase):
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
... | nagyistoce/devide | modules/vtk_basic/vtkImageNonMaximumSuppression.py | Python | bsd-3-clause | 530 |
"""
Futures tools for threadly
"""
import threading
import time
class ListenableFuture(object):
"""
This class i used to make a Future that can have listeners and callbacks
added to it. Once setter(object) is called all listeners/callbacks are
also called. Callbacks will be given the set object, an... | lwahlmeier/python-threadly | threadly/Futures.py | Python | unlicense | 4,445 |
# Copyright 2017 Huawei Technologies Co.,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
#
# Unl... | openstack/nomad | cyborg/common/exception.py | Python | apache-2.0 | 10,839 |
# -*- coding: utf-8 -*-
# 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/.
import jinja2
def init_app(app):
app.jinja_loader = jinja2.loaders.FileSystemLoader(app.co... | La0/mozilla-relengapi | lib/backend_common/backend_common/templates.py | Python | mpl-2.0 | 382 |
import os.path
from django.contrib.admin.templatetags.admin_urls import admin_urlname
from django.contrib.auth.models import User
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.urlresolvers import reverse
from django.test import TestCase, Client
from nose.tools import *
from bulkadmin i... | openplans/streetscore | street_score/project/test/test_bulkupload.py | Python | mit | 4,066 |
"""
This module implements a simple function to sort many list together.
It sorts a list given by sorting_index variable and sorts all lists the same way.
Usage example::
from PythonLibs.list_sorter import sort_lists_together
a = [2,1,3,4]
b = ["b","a","c","d"]
c = "BACD" #This is also iterable
aa... | pydupont/PersonalPythonLibs | PersonalLibs/list_sorter.py | Python | gpl-2.0 | 1,695 |
from sys import version_info
if version_info >= (2,6,0):
from os.path import dirname
import imp
fp = None
fp, pathname, description = imp.find_module('pyscanner', [dirname(__file__)])
try:
pyscanner = imp.load_module('pyscanner', fp, pathname, description)
finally:
if fp is not... | pawelmoll/scannerAPI | scanner/scanner.py | Python | bsd-2-clause | 1,360 |
"""
Classes allowing "generic" relations through ContentType and object-id fields.
"""
from __future__ import unicode_literals
from collections import defaultdict
from functools import partial
from django.core.exceptions import ObjectDoesNotExist
from django.db import connection
from django.db import models, router, ... | postrational/django | django/contrib/contenttypes/generic.py | Python | bsd-3-clause | 20,759 |
import mango
from ._PValueTest import *
from ._GeneralisedChiSquaredTest import *
__all__ = [s for s in dir() if not s.startswith('_')]
if mango.haveRestricted:
from ._fmmTest import *
from ._BinnedGmmEmTest import *
from ._SummedBinnedGmmEmTest import *
| pymango/pymango | misc/python/mango/fmmTest/__init__.py | Python | bsd-2-clause | 316 |
# Copyright 2015 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 a... | mlwithtf/mlwithtf | chapter_05/translate.py | Python | apache-2.0 | 9,841 |
import pytest
import smartsheet
@pytest.mark.usefixtures("smart_setup")
class TestCrossSheetReferences:
def test_create_cross_sheet_reference(self, smart_setup):
smart = smart_setup['smart']
xref = smart.models.CrossSheetReference()
xref.source_sheet_id = smart_setup['sheet_b'].id
... | smartsheet-platform/smartsheet-python-sdk | tests/integration/test_cross_sheet_references.py | Python | apache-2.0 | 1,330 |
"""Analyzes an MP3 file, gathering statistics and looking for errors."""
import cStringIO
import hashlib
import os
from chirp.common import mp3_frame
# Files with fewer than this many MPEG frames will be rejected as
# invalid. 100 frames is about 2.6s of audio.
_MINIMUM_FRAMES = 100
_MINIMUM_REASONABLE_FILE_SIZE =... | chirpradio/chirpradio-machine | chirp/library/analyzer.py | Python | apache-2.0 | 5,178 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-07-15 20:26
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ClinSci', '0001_initial'),
]
operations = [
migrations.RenameModel(
... | rdemolgen/NGS-LIMS | ClinSci/migrations/0002_auto_20160715_2026.py | Python | mit | 1,675 |
"""Leave one out coding"""
import numpy as np
import pandas as pd
from sklearn.base import BaseEstimator
import category_encoders.utils as util
from sklearn.utils.random import check_random_state
__author__ = 'hbghhy'
class LeaveOneOutEncoder(BaseEstimator, util.TransformerWithTargetMixin):
"""Leave one out codi... | scikit-learn-contrib/categorical-encoding | category_encoders/leave_one_out.py | Python | bsd-3-clause | 11,063 |
#!/usr/bin/env python
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | GoogleCloudPlatform/cloud-foundation-toolkit | infra/build/developer-tools/build/verify_boilerplate/verify_boilerplate.py | Python | apache-2.0 | 8,823 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Copyright 2013 Joe Harris
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
... | meeb/txcloudflare | examples/record_edit.py | Python | apache-2.0 | 3,824 |
"""
Premium Question
Straightforward
"""
__author__ = 'Daniel'
class Solution(object):
def generatePossibleNextMoves(self, s):
"""
:type s: str
:rtype: List[str]
"""
ret = []
for i in xrange(len(s)-1):
if s[i:i+2] == "++":
ret.append(s[:i... | algorhythms/LeetCode | 293 Flip Game.py | Python | mit | 355 |
import json
import requests
url = "https://edamam-recipe-search-and-diet-v1.p.mashape.com/search?_app_id=2a7c2865&_app_key=9a3f87c1707e67f965284ca3eb613dae&q=korean"
headers = {
"X-Mashape-Key": "GgV2guTBbhmsh0sMA33KSrcMjuyMp1EqLsPjsnZlRHycWvV5Pt",
"Accept": "application/json"
}
r = requests.get(url, headers=heade... | jerrrytan/bitcamp | apis/mashapeAPI.py | Python | mit | 461 |
"""
Portable file locking utilities.
Based partially on example by Jonathan Feignberg <[email protected]> in the Python
Cookbook, licensed under the Python Software License.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203
Example Usage::
>>> from django.core.files import locks
>>> f = open('./... | Shrews/PyGerrit | webapp/django/core/files/locks.py | Python | apache-2.0 | 1,791 |
# -*- coding: utf-8 -*-
#
# abx_numpy documentation build configuration file, created by
# sphinx-quickstart on Wed Oct 21 01:57:21 2015.
#
# 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.
#
#... | bootphon/abx_numpy | docs/source/conf.py | Python | gpl-3.0 | 8,322 |
try:
import unittest2 as unittest
except ImportError:
import unittest
from testrail.casetype import CaseType
class TestCaseType(unittest.TestCase):
def setUp(self):
self.casetype = CaseType(
{
"id": 1,
"is_default": False,
"name": "Automated"
... | travispavek/testrail | tests/test_casetype.py | Python | mit | 879 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.