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 |
|---|---|---|---|---|---|
import sys
from abci.wire import hex2bytes, decode_big_endian, encode_big_endian
from abci.server import ABCIServer
from abci.reader import BytesBuffer
class CounterApplication():
def __init__(self):
sys.exit("The python example is out of date. Upgrading the Python examples is currently left as an exer... | tendermint/tmsp | example/python/app.py | Python | apache-2.0 | 2,163 |
#!/usr/bin/env python
# encoding: utf-8
"""
serializers.py
Created by Christophe VAN FRACKEM / Bastien ARNETTE on 2014/04/21/.
Copyright (c) 2014 Tiss'Page. MIT Licence.
UCAR serializers.
"""
__author__ = 'Christophe VAN FRACKEM <contact@tisspage.fr> / Bastien ARNETTE <bastien@rnette.fr>'
__version__= '0.0.1'
__cop... | tisspage/ucar | api-server/api_v0/serializers/file.py | Python | mit | 653 |
#!/usr/bin/python2.4
#
# Copyright 2009 Empeeric 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
#
# Unless requir... | katemsu/kate_website | kate3/utils/bitly.py | Python | mit | 6,991 |
#!/usr/bin/env python
# Copyright 2017 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 require... | civinomics/city-council | cloud/appengine/pubsub_utils.py | Python | mit | 2,195 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-06-01 13:08
from __future__ import unicode_literals
import django.contrib.postgres.fields.jsonb
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('doi', '0002_auto_20170601_1215'),
]
operations ... | libscie/liberator | doi/migrations/0003_auto_20170601_1308.py | Python | cc0-1.0 | 880 |
import pytest
from django.utils import timezone
from api.base.settings.defaults import API_BASE
from api_tests.preprints.filters.test_filters import PreprintsListFilteringMixin
from api_tests.preprints.views.test_preprint_list_mixin import PreprintIsPublishedListMixin, PreprintIsValidListMixin
from osf_tests.factories... | Johnetordoff/osf.io | api_tests/nodes/views/test_node_preprints.py | Python | apache-2.0 | 10,337 |
"""
Tornado Template Loaders
"""
| lucius-feng/tinman | tinman/loaders/__init__.py | Python | bsd-3-clause | 34 |
import lightlayers
l = lightlayers.LightLayer(True, '10.10.10.44')
l.ramp(0, 12, 500, 0)
delay = 50
l.setblock(0, 1, "blue")
l.wait(delay)
l.setblock(0, 1, "black")
l.wait(delay)
l.setblock(0, 1, "blue")
l.wait(delay)
l.setblock(0, 1, "black")
l.wait(delay)
l.setblock(0, 1, "blue")
l.wait(delay)
l.setblock(0, 1, "bl... | staticsan/light-layers | time-one.py | Python | mit | 358 |
from changes.models.option import ItemOption
from changes.testutils import APITestCase
class PlanStepIndexTest(APITestCase):
def test_simple(self):
project = self.create_project()
plan = self.create_plan(project, label='Foo')
step1 = self.create_step(plan=plan)
self.create_option... | dropbox/changes | tests/changes/api/test_plan_step_index.py | Python | apache-2.0 | 2,009 |
from models import db
from datetime import datetime
from sqlalchemy import func, Column, BigInteger, SmallInteger, Integer, \
String, Float, DateTime, ForeignKey, Text
from sqlalchemy.orm.session import Session
from sqlalchemy.exc import SQLAlchemyError
class FailedPayment(db.Model):
__tablename__ = 'f... | lyonbros/faxrobot | models/failed_payment.py | Python | gpl-3.0 | 1,336 |
# Copyright 2014 Amazon.com, Inc. or its affiliates. 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. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompa... | synctree/synctree-awsebcli | ebcli/controllers/logs.py | Python | apache-2.0 | 2,366 |
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
#
# Copyright (C) 2014-2019 Didotech srl (<http://www.didotech.com>).
#
# All Rights Reserved
#
# This program is free software: you can re... | iw3hxn/LibrERP | account_invoice_extended/models/stock_picking.py | Python | agpl-3.0 | 1,843 |
def join(*paths):
"""Like os.path.join but doesn't treat absolute RHS specially"""
import os.path
return os.path.normpath("/".join(paths))
def relative(src, dest):
""" Return a relative path from src to dest.
>>> relative("/usr/bin", "/tmp/foo/bar")
../../tmp/foo/bar
>>> relative("/usr/bi... | crystalfontz/openembedded | lib/oe/path.py | Python | mit | 1,553 |
# Copyright 2009 The Closure Library Authors. All Rights Reserved.
"""Scans a source JS file for its provided and required namespaces.
Simple class to scan a JavaScript file and express its dependencies.
"""
import re
_BASE_REGEX_STRING = '^\s*goog\.%s\(\s*[\'"](.+)[\'"]\s*\)'
_PROVIDE_REGEX = re.compile(_BASE_R... | xs2ranjeet/mdv | third_party/closure/closure/bin/build/source.py | Python | apache-2.0 | 1,672 |
from route53.xml_parsers.common_health_check import parse_health_check
def get_health_check_by_id_parser(root, connection):
"""
Parses the API responses for the
:py:meth:`route53.connection.Route53Connection.get_health_check_by_id` method.
:param lxml.etree._Element root: The root node of the etree pa... | jcastillocano/python-route53 | route53/xml_parsers/get_health_check_by_id.py | Python | mit | 696 |
# -*- coding: utf-8 -*-
"""Compute statistical description of datasets"""
import multiprocessing
import itertools
from functools import partial
import numpy as np
import pandas as pd
import matplotlib
from pkg_resources import resource_filename
import pandas_profiling.formatters as formatters
import pandas_profiling.b... | JosPolfliet/pandas-profiling | pandas_profiling/describe.py | Python | mit | 15,004 |
"""
Example URLConf for a contact form.
Because the ``contact_form`` view takes configurable arguments, it's
recommended that you manually place it somewhere in your URL
configuration with the arguments you want. If you just prefer the
default, however, you can hang this URLConf somewhere in your URL
hierarchy (for be... | tzabian/fuego-pootle | external_apps/contact_form_i18n/urls.py | Python | gpl-2.0 | 942 |
# Copyright 2009 the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | SRabbelier/Melange | app/soc/modules/gci/views/helper/templatetags/__init__.py | Python | apache-2.0 | 631 |
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Embeddable.src'
db.add_column(u'filer_embeddable_embeddab... | sthzg/djf-embeddable | filer_embeddable/migrations/0003_auto__add_field_embeddable_src__add_field_embeddable_width__add_field_.py | Python | mit | 8,845 |
#!/usr/bin/env python3
# Copyright 2014-2016 Open Source Robotics Foundation, 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
#
# Unle... | ruffsl/ros_buildfarm | scripts/devel/generate_devel_script.py | Python | apache-2.0 | 3,673 |
import pytest
import abjad
def test_Rest___setattr___01():
"""
Slots constrain rest attributes.
"""
rest = abjad.Rest((1, 4))
with pytest.raises(AttributeError):
rest.foo = "bar"
| Abjad/abjad | tests/test_Rest___setattr__.py | Python | gpl-3.0 | 212 |
from .auth import auth_interface
import pili.conf as conf
from urllib2 import Request
import json, base64
def normalize(args, keyword):
if set(args) - set(keyword):
raise ValueError('invalid key')
for k, v in args.items():
if v is None:
del args[k]
return args
@auth_interface
... | fancl20/pili-python | pili/api.py | Python | mit | 2,208 |
#!/usr/bin/env python
from bs4 import BeautifulSoup
# Constants
DEFAULT = "Default:"
# Methods
def processDefaults(soup, swagger):
default = ''
for string in soup.code.stripped_strings :
default = ' and'.join(', '.join(string.split(',')).rsplit(',', 1))
swagger['default'] = default
if "true" in defau... | warehouseman/trello-swagger-generator | processDefaults.py | Python | mit | 931 |
# Copyright 2018 The TensorFlow Authors. 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 applica... | seanli9jan/tensorflow | tensorflow/tools/compatibility/tf_upgrade_v2_test.py | Python | apache-2.0 | 3,986 |
"""
This module is the import command of bowl.
Created on 6 June 2014
@author: Charlie Lewis
"""
import os
class image_import(object):
"""
This class is responsible for the import command of the cli.
"""
@classmethod
def main(self, args):
directory = args.metadata_path
directory =... | cglewis/bowl | bowl/cli_opts/image_import.py | Python | apache-2.0 | 1,228 |
# Copyright 2014 NEC Corporation. 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 ... | openstack/tempest-lib | tempest_lib/api_schema/response/compute/v2_1/interfaces.py | Python | apache-2.0 | 2,276 |
################################################################################
######### MS11-080 - CVE-2011-2005 Afd.sys Privilege Escalation Exploit ########
######### Author: ryujin@offsec.com - Matteo Memelli ########
######### Spaghetti & Pwnsauce ##... | SecWiki/windows-kernel-exploits | MS11-080/CVE-2011-2005.py | Python | mit | 12,217 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 University of Southern California
# 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/licens... | sileht/deb-openstack-nova | nova/tests/baremetal/test_proxy_bare_metal.py | Python | apache-2.0 | 10,020 |
import socket
#host = socket.gethostname()
host = "128.224.158.229"
port = 1234
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
while True:
data = raw_input("$ ")
if data != None:
s.sendall(data + "\n")
if data == 'exit':
break
#data = s.recv(1024)
#print "R... | hoxm/plnpl | python/projects/socket/socket_client.py | Python | gpl-2.0 | 352 |
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'Famille'
db.create_table(u'famille_famille', (
... | huguesmayolle/famille | famille/migrations/0001_initial.py | Python | apache-2.0 | 9,734 |
import _plotly_utils.basevalidators
class TicksuffixValidator(_plotly_utils.basevalidators.StringValidator):
def __init__(
self,
plotly_name="ticksuffix",
parent_name="scattergl.marker.colorbar",
**kwargs
):
super(TicksuffixValidator, self).__init__(
plotly_... | plotly/plotly.py | packages/python/plotly/plotly/validators/scattergl/marker/colorbar/_ticksuffix.py | Python | mit | 461 |
# coding: utf-8
from __future__ import unicode_literals
import functools
import itertools
import operator
import re
from .common import InfoExtractor
from ..compat import (
compat_HTTPError,
compat_str,
compat_urllib_request,
)
from .openload import PhantomJSwrapper
from ..utils import (
determine_ext... | tvalacarta/tvalacarta | python/main-classic/lib/youtube_dl/extractor/pornhub.py | Python | gpl-3.0 | 21,997 |
"""
example.py
An Example Use of priorityqueue.py: Solving the 'Skyline' Problem
For a description of the problem: https://uva.onlinejudge.org/external/1/p105.pdf
Our strategy is as follows. We want to scan the horizon left to right. If at
any point the maximum height of a building at the current x coordinate change... | mjwestcott/priorityqueue | example.py | Python | mit | 4,095 |
from django.shortcuts import render
from datetime import date, datetime, timedelta
from .models import Event, SponsoredContent
from pytz import timezone
def index(request):
now = datetime.now(timezone('Australia/Sydney')).date()
if now.isoweekday() in [5, 6, 7]:
weekend_s... | coreymcdermott/artbot | artbot_website/views.py | Python | mit | 793 |
# Basic libraries
import random
import json
import re
import urllib
import urllib2
import logging
# Google App Engine
from google.appengine.api import urlfetch
from google.appengine.ext import ndb
# Constants
# Help command
HELP_COMMAND = ('The almighty @PozoBot!\n\nCommands available:\n' \
'/help - F... | JSidrach/pozo-bot | Pozo.py | Python | mit | 2,973 |
import unittest
from cStringIO import StringIO
from pysal.core.util.shapefile import noneMax, noneMin, shp_file, shx_file, NullShape, Point, PolyLine, MultiPoint, PointZ, PolyLineZ, PolygonZ, MultiPointZ, PointM, PolyLineM, PolygonM, MultiPointM, MultiPatch
import os
import pysal
class TestNoneMax(unittest.TestCase):... | spreg-git/pysal | pysal/core/util/tests/test_shapefile.py | Python | bsd-3-clause | 16,445 |
# 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/.
"""structures for reading and writing MAR data.
This relies on the construct module for specifying the data structures.
... | catlee/build-mar | src/mardor/format.py | Python | mpl-2.0 | 4,608 |
# This file is part of Booktype.
# Copyright (c) 2013 Borko Jandras <borko.jandras@sourcefabric.org>
#
# Booktype 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
# (a... | eos87/Booktype | lib/booktype/convert/epub/converter.py | Python | agpl-3.0 | 18,668 |
#!/usr/bin/python
#
# author:
#
# date:
# description:
#
'''Trains a memory network on the bAbI dataset.
References:
- Jason Weston, Antoine Bordes, Sumit Chopra, Tomas Mikolov, Alexander M. Rush,
"Towards AI-Complete Question a1ing: A Set of Prerequisite Toy Tasks",
http://arxiv.org/abs/1502.05698
- Sainbayar... | Rene90/dl4nlp | hw6_babi_qa/babi2.py | Python | mit | 6,138 |
#!/usr/bin/env python
#
# Copyright 2007 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 o... | dcroc16/skunk_works | google_appengine/google/appengine/tools/appengine_rpc_httplib2.py | Python | mit | 15,008 |
# Copyright (c) 2015 SUSE Linux GmbH. All rights reserved.
#
# This file is part of kiwi.
#
# kiwi 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 la... | dirkmueller/kiwi | kiwi/boot/image/base.py | Python | gpl-3.0 | 16,057 |
from django.db import models
class Citizen(models.Model):
"""
The insurance users.
"""
name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
# Contact information
email = models.EmailField()
phone = models.CharField(max_length=50)
# Citizen documents... | jaconsta/soat_cnpx | api/citizens/models.py | Python | mit | 672 |
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
# Copyright (c) 2015 Tom Barron. All rights reserved.
# Copyright (c) 2015 Mirantis Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); yo... | vponomaryov/manila | manila/share/api.py | Python | apache-2.0 | 83,530 |
from attachments.forms import AttachmentForm
from attachments.views import add_url_for_obj
from django.core.urlresolvers import reverse
from django.template.loader import render_to_string
from django.db.models import get_model
from django import template
from django.contrib.contenttypes.models import ContentType
from d... | machinalis/eff | eff_site/eff/templatetags/attachments_tags_custom.py | Python | gpl-3.0 | 11,301 |
x=input()
print(x * 5) | amoeeba/MyPy | input.py | Python | unlicense | 22 |
# -*- coding: utf-8 -*-
from django.urls import path
from .. import views
urlpatterns = [
path("", views.SearchPlansView.as_view(), name="plans-all"),
path("pages/", views.SearchPlansPagesView.as_view(), name="plans-pages"),
# # FIXME: probably should move to testcases app
path(
"clone-cases/... | Nitrate/Nitrate | src/tcms/testplans/urls/plans_urls.py | Python | gpl-2.0 | 1,054 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import select
import socket
import errno
from fabric.network import needs_host
from fabric.state import connections, env
from fabric.thread_handling import ThreadHandler
from .base import ConnectionDict, get_local_port
class LocalTunnels(ConnectionDic... | yonglehou/docker-fabric | dockerfabric/tunnel.py | Python | mit | 5,538 |
import socket, traceback
host = ''
port = 51423
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((host, port))
s.listen(1)
print "done"
while 1:
#when connect error happen, skip the error
print '==========='
try:
ClientSock, Clie... | stockminer/storm | test/server.py | Python | apache-2.0 | 1,124 |
from lars.mapper import Mapper
import time
class Sleep(Mapper):
def loadConfigJSON(self,config):
self.sleep = float(config["sleep"])
def process(self,record):
time.sleep(self.sleep)
return record
| ARodri/Lars | lars/mapper/util/sleep.py | Python | gpl-2.0 | 224 |
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.exceptions import ValidationError
from odoo import models, fields, api, _
from odoo.osv import expression
SII_VAT = '60805000-0'
class AccountMove(models.Model):
_inherit = "account.move"
partner_id_... | jeremiahyan/odoo | addons/l10n_cl/models/account_move.py | Python | gpl-3.0 | 9,118 |
# -*- coding: iso-8859-1 -*-
# (c) 2009-2014 Martin Wendt and contributors; see WsgiDAV https://github.com/mar10/wsgidav
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
"""Unit test for property_manager.py"""
from tempfile import gettempdir
import unittest
import os
from av... | eavatar/avax.webdav | avax/webdav/tests/test_property_manager.py | Python | mit | 3,428 |
from Pixmap import PixmapConditional
from ConditionalWidget import BlinkingWidgetConditional, BlinkingWidget
class BlinkingPixmap(BlinkingWidget):
def __init__(self):
Widget.__init__(self)
class BlinkingPixmapConditional(BlinkingWidgetConditional, PixmapConditional):
def __init__(self):
BlinkingWidgetConditio... | blzr/enigma2 | lib/python/Components/BlinkingPixmap.py | Python | gpl-2.0 | 374 |
# XXX(dlitz): Most of this is deployment-related stuff that belongs outside the
# main Python invocation.
import gc
import os
import sys
import json
import time
import sqlalchemy
from alembic.script import ScriptDirectory
from alembic.config import Config as alembic_config
from inbox.config import config
from nylas.... | Eagles2F/sync-engine | inbox/util/startup.py | Python | agpl-3.0 | 4,011 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Código desarrollado por Daniel Mansilla
from __future__ import unicode_literals, absolute_import
from django.shortcuts import render, redirect
from django.views.generic import View
from apps.preguntas.models import *
from apps.evaluacion.models import *
from apps.conten... | Mansilla1/Sistema-SEC | apps/dashboard/views.py | Python | apache-2.0 | 12,467 |
from django.conf import settings
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from ads.blog import get_post
from ads.feeds import latest
from ads.index import index
from ads.serve import serve_ad
from ads.user import *
from django.contrib import admin
admin.autodis... | mapleoin/cuZmeura | urls.py | Python | agpl-3.0 | 1,640 |
# !/usr/bin/python
# -*- coding: cp1252 -*-
#
##################################################################################
#
# Copyright 2016 Félix Brezo and Yaiza Rubio (i3visio, contacto@i3visio.com)
#
# This program is part of OSRFramework. You can redistribute it and/or modify
# it under the terms of... | i3visio/osrframework | osrframework/wrappers/pending/apsense.py | Python | agpl-3.0 | 4,508 |
###############################
# This file is part of PyLaDa.
#
# Copyright (C) 2013 National Renewable Energy Lab
#
# PyLaDa is a high throughput computational platform for Physics. It aims to make it easier to submit
# large numbers of jobs on supercomputers. It provides a python interface to physical input, suc... | pylada/pylada-light | src/pylada/vasp/nlep/plotbs.py | Python | gpl-3.0 | 6,923 |
# Copyright (c) 2014 Cisco Systems 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 re... | CiscoSystems/nova-solver-scheduler | nova/scheduler/solvers/constraints/io_ops_constraint.py | Python | apache-2.0 | 2,224 |
# -*- coding: utf-8 -*-
###############################################################################
#
# HourlyVisitorsLast7Days
# Retrieves hourly visitor and action tallies for the last 7 days.
#
# Python versions 2.6, 2.7, 3.x
#
# Copyright 2014, Temboo Inc.
#
# Licensed under the Apache License, Version 2.0 (th... | jordanemedlock/psychtruths | temboo/core/Library/Clicky/HourlyVisitorsLast7Days.py | Python | apache-2.0 | 4,144 |
"""
.. module: _map_logic
:synopsis: Defines functions used in the Map class involving the game
state; for instance, collecting resources and making a move. All of
these functions are stored as methods for the Map class (see map.py).
"""
from . import cell
import numpy as np
def collectResources(self):... | wshand/hex-towns | src/map/_map_logic.py | Python | mit | 4,276 |
"""
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 use this ... | jellybean4/yosaipy2 | yosaipy2/core/subject/subject.py | Python | apache-2.0 | 41,660 |
import matplotlib.pyplot as plt
import cPickle as pkl
import numpy as np
import seaborn.apionly as sns
from lab.plotting import histogram
def enrichment(positions):
distances = np.abs(positions[np.isfinite(positions)])
return np.mean(distances), np.std(distances) / np.sqrt(len(distances))
def calc_enrichme... | losonczylab/Zaremba_NatNeurosci_2017 | enrichment_model/enrichment_model_plotting.py | Python | mit | 7,208 |
# -*- coding: utf-8 -*-
# pylint: disable=line-too-long, unused-argument, invalid-name, too-many-arguments, too-many-locals
"""
Utilities to support integration of Vowpal Wabbit and scikit-learn
"""
import numpy as np
from pyvw import vw
import re
from scipy.sparse import csr_matrix
from sklearn.base import BaseEstim... | martinpopel/vowpal_wabbit | python/sklearn_vw.py | Python | bsd-3-clause | 15,244 |
import os
from . import Material
from . import System
class Model:
"""Combines material properties with system parameters.
If, on instantiation, ``model`` or ``system`` is a string,
the associated object will be created from the YAML file, e.g.,
.. code-block:: python
Model('mos2', 'default'... | razor-x/dichalcogenides | dichalcogenides/model/model.py | Python | mit | 1,951 |
# Copyright 2016 Casey Jaymes
# This file is part of PySCAP.
#
# PySCAP 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.
#
# PySCAP is ... | cjaymes/pyscap | src/scap/model/xhtml/HrTag.py | Python | gpl-3.0 | 923 |
"""
call_metrics v0.01
a class function decorator which collects metrics (number of calls and total execution time)
Copyright 2012 Brian Monkaba
This file is part of ga-bitbot.
ga-bitbot is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as publishe... | enikesha/ga-bitbot | libs/call_metrics.py | Python | gpl-3.0 | 2,700 |
"""Initialise the database
This was reset with Aleph 3.9. The minimum supported origin version
is Aleph 3.2.
Revision ID: af9b37868cf3
Revises: None
Create Date: 2020-07-31 10:03:53.301493
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = "af9b37868cf3"
down_re... | alephdata/aleph | aleph/migrate/versions/af9b37868cf3_init.py | Python | mit | 8,931 |
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
import MITgcmutils as mit
from scipy import interpolate
plt.ion()
binprec = '>f4'
flag_interp = 0
dir0 = '../run/mnc_test_0002/'
file1 = 'state.*'
#f1 = netcdf.netcdf_file(dir0 + file1,'r')
f1 = mit.mnc_files(dir0 + file1)
T = f1.variables[... | bderembl/mitgcm_configs | gyre_energetics/input/restart.py | Python | mit | 2,077 |
import pylab as pl
import numpy as np
from memory_profiler import profile
from memory_profiler import memory_usage
import time
class User(object):
def __init__(self, name, age):
self.name = name
self.age = age
def f(count):
data = { }
for idx in xrange(count):
data[idx] = Use... | ggarlic/python-notes | examples/tools/mem_plot.py | Python | lgpl-3.0 | 684 |
#!/usr/bin/python -u
"""
[Advice: run this script using python with unbuffered output:
`python -u dispersion_curves.py`]
This script implements the two-step frequency-time analysis
(FTAN) on a set of cross-correlations, as described by Levshin &
Ritzwoller, "Automated detection, extraction, and measurement
of regional... | boland1992/SeisSuite | bin/03_dispersion_curves.py | Python | gpl-3.0 | 6,028 |
from .producer import ProducerSerializer
from .region_type import RegionTypeSerializer
| VLSI-EDA/rc3e-manager | rc3e_manager/rest_api/serializers/__init__.py | Python | gpl-3.0 | 87 |
#!/usr/bin/env python3
# Copyright (c) 2017 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test RPC calls related to net.
Tests correspond to code in rpc/net.cpp.
"""
from test_framework.test_frame... | stamhe/bitcoin | test/functional/rpc_net.py | Python | mit | 4,058 |
""" Defines a widget for editing enumerated types """
# define authorship information
__authors__ = ['Eric Hulser']
__author__ = ','.join(__authors__)
__credits__ = []
__copyright__ = 'Copyright (c) 2012, Projex Software'
__license__ = 'LGPL'
# maintenance information
... | bitesofcode/projexui | projexui/widgets/xenumbox.py | Python | lgpl-3.0 | 6,502 |
import logging
from ..requests import requests
from .common import access_token
from itchatmp.utils import retry, encode_send_dict
from itchatmp.config import COMPANY_URL
from itchatmp.returnvalues import ReturnValue
logger = logging.getLogger('itchatmp')
@access_token
def create(chatId, name, ownerId, us... | littlecodersh/itchatmp | itchatmp/controllers/mpapi/qy/chat.py | Python | mit | 4,575 |
"""
Configuration for block_structure djangoapp
"""
from django.apps import AppConfig
class BlockStructureConfig(AppConfig):
"""
block_structure django app.
"""
name = u'openedx.core.djangoapps.content.block_structure'
def ready(self):
"""
Define tasks to perform at app loading ... | edx-solutions/edx-platform | openedx/core/djangoapps/content/block_structure/apps.py | Python | agpl-3.0 | 540 |
from datetime import timedelta
from decimal import Decimal
from io import BytesIO
import pytest
from django.utils.timezone import now
from PyPDF2 import PdfFileReader
from pretix.base.models import (
Event, Item, ItemVariation, Order, OrderPosition, Organizer,
)
from pretix.plugins.ticketoutputpdf.ticketoutput im... | Flamacue/pretix | src/tests/plugins/test_ticketoutputpdf.py | Python | apache-2.0 | 1,826 |
import logging
from collections import defaultdict
from math import sqrt
from commander import Commander
from context import GameContext
from names import NameGenerator
from soldier import Soldier
from validator import Validator
class Judge(object):
def __init__(self, manager):
programs = manager.g... | lukius/algo2-fiuba-tp1-2q13 | judge/judge.py | Python | mit | 8,267 |
from django.test import TestCase
class SiteTestCase(TestCase):
def test_home(self):
response = self.client.get('/')
# pylint: disable=E1103
self.assertIn('A set of vulnerable scripts', response.content)
self.assertTemplateUsed(response, 'moth/base.html')
self.asser... | andresriancho/django-moth | moth/tests/test_site.py | Python | gpl-2.0 | 845 |
from django.db import models
from django.db.models import fields
from django.db.models.base import ModelBase
## Metaclass for setting up a model for scraping.
# It's pretty unlikely this will need to be inherited or modified.
class ScrapeModelMetaclass(ModelBase):
## Override creation.
# We need to extract t... | furious-luke/django-scrape | scrape/models.py | Python | bsd-3-clause | 3,686 |
######################################################################
# Alchemical Analysis: An open tool implementing some recommended practices for analyzing alchemical free energy calculations
# Copyright 2011-2015 UC Irvine and the Authors
#
# Authors: Pavel Klimovich, Michael Shirts and David Mobley
#
#This libra... | halx/alchemical-analysis | alchemical_analysis/parser_gromacs.py | Python | lgpl-2.1 | 15,545 |
data = [
{
"name": "get_scoreboard",
"url": "/api/scoreboard/",
"method": "get",
"payload": {
"token": "ADMIN@TOKEN",
},
"response_status": 200,
"response_data": {
"msg": None
}
},
]
| Tocknicsu/nctuoj_contest | test/api/scoreboard/scoreboard.py | Python | apache-2.0 | 279 |
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Deleting field 'DocumentType.doctor'
db.delete_column(u'main_documenttype', 'doctor_id')
# Adding... | ansmirnov/losk | losk/main/migrations/0004_auto__del_field_documenttype_doctor__add_field_documenttype_name.py | Python | gpl-2.0 | 9,686 |
#
#
# Copyright (C) 2006, 2007, 2010, 2011 Google Inc.
#
# 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 progr... | kawamuray/ganeti | lib/utils/algo.py | Python | gpl-2.0 | 8,034 |
# Copyright 2015 Mirantis, 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 ... | magic0704/oslo.messaging | oslo_messaging/_drivers/zmq_driver/server/zmq_incoming_message.py | Python | apache-2.0 | 2,020 |
#!/usr/bin/python -u
#
# this tests the DTD validation with the XmlTextReader interface
#
import sys
import glob
import string
import StringIO
import libxml2
# Memory debug specific
libxml2.debugMemory(1)
err=""
expect="""../../test/valid/rss.xml:177: element rss: validity error : Element rss does not carry attribute... | Noah-Huppert/Website-2013 | vhosts/www.noahhuppert.com/htdocs/trex/deps/libxml2/python/tests/reader2.py | Python | mit | 5,179 |
"""
Factories for generating edXML for testing XModule import
"""
import inspect
from fs.memoryfs import MemoryFS
from factory import Factory, lazy_attribute, post_generation, Sequence
from lxml import etree
from xmodule.modulestore.inheritance import InheritanceMixin
from xmodule.modulestore import only_xmodules
... | mtlchun/edx | common/lib/xmodule/xmodule/tests/xml/factories.py | Python | agpl-3.0 | 4,908 |
import unittest
import numpy
import chainer
from chainer import backend
from chainer.backends import cuda
from chainer import gradient_check
from chainer import links
from chainer import testing
from chainer.testing import attr
def _sigmoid(x):
xp = backend.get_array_module(x)
half = x.dtype.type(0.5)
r... | okuta/chainer | tests/chainer_tests/links_tests/connection_tests/test_zoneoutlstm.py | Python | mit | 7,915 |
from data_importers.management.commands import BaseXpressDemocracyClubCsvImporter
BRIDGEFIELD_HOUSE_UPRNS = [
"10094455800",
"10094455801",
"10094455868",
"10094455869",
"10094455870",
"10094455871",
"10094455872",
"10094455802",
"10094455803",
"10094455804",
"10094455805",
... | DemocracyClub/UK-Polling-Stations | polling_stations/apps/data_importers/management/commands/import_crawley.py | Python | bsd-3-clause | 7,404 |
# -*- coding: utf-8 -*-
"""
***************************************************************************
SpatialiteExecuteSQL.py
---------------------
Date : October 2016
Copyright : (C) 2016 by Mathieu Pellerin
Email : nirvn dot asia at gmail dot com
******... | myarjunar/QGIS | python/plugins/processing/algs/qgis/SpatialiteExecuteSQL.py | Python | gpl-2.0 | 2,613 |
"""
BDS test for IID time series
References
----------
Broock, W. A., J. A. Scheinkman, W. D. Dechert, and B. LeBaron. 1996.
"A Test for Independence Based on the Correlation Dimension."
Econometric Reviews 15 (3): 197-235.
Kanzler, Ludwig. 1999.
"Very Fast and Correctly Sized Estimation of the BDS Statistic".
SSRN ... | jseabold/statsmodels | statsmodels/tsa/_bds.py | Python | bsd-3-clause | 7,400 |
# Copyright DataStax, 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, softwa... | mambocab/python-driver | cassandra/encoder.py | Python | apache-2.0 | 8,315 |
__author__ = 'leif'
from faker import Factory as FakeFactory
from house import House
import math
import random
class Street(object):
def __init__(self, name, house_list):
self.name = name
self.num_of_houses = len(house_list)
self.current_house = 0
self.house_list = house_list
... | leifos/wad | projects/game/engine/streetfactory.py | Python | mit | 1,583 |
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Deleting field 'Value.year'
db.delete_column('dpnetcdf_value', 'year')
def backwards(self, orm):
... | nens/dpnetcdf | dpnetcdf/migrations/0021_auto__del_field_value_year.py | Python | gpl-3.0 | 5,629 |
import asposebarcodecloud
from asposebarcodecloud.BarcodeApi import BarcodeApi
from asposebarcodecloud.BarcodeApi import ApiException
import ConfigParser
config = ConfigParser.ConfigParser()
config.readfp(open(r'../../data/config.properties'))
apiKey = config.get('AppConfig', 'api_key')
appSid = config.get(... | asposebarcode/Aspose_BarCode_Cloud | Examples/Python/generating-saving/without-cloud-storage/generate-barcode-and-get-image-as-stream.py | Python | mit | 1,515 |
import amitgroup as ag
import numpy as np
ag.set_verbose(True)
# This requires you to have the MNIST data set.
data, digits = ag.io.load_mnist('training', selection=slice(0, 100))
pd = ag.features.PartsDescriptor((5, 5), 20, patch_frame=1, edges_threshold=5, samples_per_image=10)
# Use only 100 of the digits
pd.tr... | amitgroup/amitgroup | examples/parts_descriptor_test.py | Python | bsd-3-clause | 608 |
"""lol"""
"""a,b,c,d = int(input()), int(input()), int(input()), int(input())
for i in range(c, d+1):
print('\t', i, end='')
print()
for j in range(a, b+1):
print(j, end='\t')
for k in range(c, d+1):
print(k*j, end='\t')
print()"""
a, b, c = input().rsplit()
a = int(a)
b = int(b)
s = 0
for i in... | fallenangeldark/garbage | new.py | Python | gpl-3.0 | 387 |
from .tutorial_cog import Tutorial
def setup(bot):
bot.add_cog(Tutorial(bot)) | FoglyOgly/Meowth | meowth/exts/tutorial/__init__.py | Python | gpl-3.0 | 82 |
# Copyright (C) 2004-2006 Python Software Foundation
# Authors: Baxter, Wouters and Warsaw
# Contact: email-sig@python.org
"""FeedParser - An email feed parser.
The feed parser implements an interface for incrementally parsing an email
message, line by line. This has advantages for certain applications, such as
thos... | MalloyPower/parsing-python | front-end/testsuite-python-lib/Python-3.2/Lib/email/feedparser.py | Python | mit | 20,785 |
# -*- coding: utf-8 -*-
#
# 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
... | biln/airflow | airflow/hooks/postgres_hook.py | Python | apache-2.0 | 1,799 |
from pycp2k.inputsection import InputSection
from ._dielectric_cube1 import _dielectric_cube1
from ._dirichlet_bc_cube1 import _dirichlet_bc_cube1
from ._dirichlet_cstr_charge_cube1 import _dirichlet_cstr_charge_cube1
class _implicit_psolver1(InputSection):
def __init__(self):
InputSection.__init__(self)
... | SINGROUP/pycp2k | pycp2k/classes/_implicit_psolver1.py | Python | lgpl-3.0 | 709 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.