text stringlengths 6 947k | repo_name stringlengths 5 100 | path stringlengths 4 231 | language stringclasses 1
value | license stringclasses 15
values | size int64 6 947k | score float64 0 0.34 |
|---|---|---|---|---|---|---|
#!/usr/bin/env python
# Copyright (c) 2011 Stanford University
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ... | y-higuchi/ramcloud | scripts/transportgraph.py | Python | isc | 2,912 | 0.00103 |
#!/usr/bin/env python3
# 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/.
#
# Copyright 2017-2019 - Edoardo Morassutto <edoardo.morassutto@gmail.com>
# Copyright 2017 - Luc... | algorithm-ninja/territoriali-backend | terry/handlers/base_handler.py | Python | mpl-2.0 | 9,492 | 0.002739 |
"""
@name: Modules/families/UPB/UPB_data.py
@author: D. Brian Kimmel
@contact: D.BrianKimmel@gmail.com
@copyright: (c) 2014-2020 by D. Brian Kimmel
@license: MIT License
@note: Created on Aug 6, 2014
@summary: This module is for communicating with UPB controllers.
"""
__updated__ = '2020-02-17'
# ... | DBrianKimmel/PyHouse | Project/src/Modules/House/Family/Upb/upb_data.py | Python | mit | 787 | 0 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 IBM Corp.
#
# 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
#
# ... | DirectXMan12/nova-hacking | nova/virt/powervm/common.py | Python | apache-2.0 | 9,118 | 0.000658 |
# zetup.py
#
# Zimmermann's Python package setup.
#
# Copyright (C) 2014-2015 Stefan Zimmermann <zimmermann.code@gmail.com>
#
# zetup.py 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 ve... | userzimmermann/zetup.py | zetup/commands/test.py | Python | lgpl-3.0 | 1,403 | 0 |
# -*- coding: UTF-8 -*-
# Copyright 2014-2017 Luc Saffre
# This file is part of Lino Welfare.
#
# Lino Welfare 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 y... | khchine5/lino-welfare | lino_welfare/modlib/aids/mixins.py | Python | agpl-3.0 | 13,679 | 0.001755 |
# -*- coding: utf-8 -*-
# pylint: disable=invalid-name
# Copyright 2017 IBM RESEARCH. 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/licen... | atilag/qiskit-sdk-py | qiskit/extensions/standard/gatestools.py | Python | apache-2.0 | 1,248 | 0 |
# Copyright (C) 2011 by Stefano Palazzo
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish,... | sfstpala/png.py | png.py | Python | mit | 2,602 | 0.001922 |
from flask import Blueprint
main = Blueprint('main', __name__)
from . import errors, views
from ..models import Permission
@main.app_context_processor
def inject_permissions():
return dict(Permission=Permission)
| caser789/xuejiao-blog | app/main/__init__.py | Python | mit | 219 | 0.013699 |
# ~*~ coding: utf-8 ~*~
"""Module that contains a Marshmallow schema that generate JSON schemas.
JSON Schemas can be a pain to write by hand. For example, the product
requirements change, thus your schema changes. If you are maintaining your
schemas by hand, you have to go through all of them and update them, or, even... | croscon/fleaker | fleaker/marshmallow/json_schema.py | Python | bsd-3-clause | 7,584 | 0 |
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import theano
import theano.tensor as T
from theano.tensor.signal import downsample
from .. import activations, initializations
from ..utils.theano_utils import shared_zeros
from ..layers.core import Layer
class Convolution1D(Layer):
def __init__(se... | stonebig/keras | keras/layers/convolutional.py | Python | mit | 5,924 | 0.011648 |
# -*- coding: utf-8 -*-
import openerp
from openerp import models, fields, api, SUPERUSER_ID, exceptions
from openerp.addons.saas_utils import connector, database
from openerp import http
from openerp.tools import config, scan_languages
from openerp.tools.translate import _
from openerp.addons.base.res.res_partner impo... | andhit-r/odoo-saas-tools | saas_portal/models/saas_portal.py | Python | lgpl-3.0 | 18,733 | 0.00315 |
import time
from vsroom.common import sanitizer
from vsroom.common import timeconversion
# sanitizer.Sanitizer is the base class for a simple sanitizer bot.
class TallinnAirportSanitizer(sanitizer.Sanitizer):
# .sanitize(event) is the hook method for sanitizing events. This
# is the only method you have to imp... | softcert/vsroom | vsroom/common/sanitizers/tallinnairport.py | Python | mit | 1,903 | 0.008408 |
import struct
def validate_transaction_id(request_mbap, response):
""" Check if Transaction id in request and response is equal. """
assert struct.unpack('>H', request_mbap[:2]) == \
struct.unpack('>H', response[:2])
def validate_protocol_id(request_mbap, response):
""" Check if Protocol id in r... | AdvancedClimateSystems/python-modbus | tests/system/validators.py | Python | mpl-2.0 | 2,302 | 0 |
# Copyright 2008 Online Agility (www.onlineagility.com)
#
# 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 b... | dherbst/python-icontact | icontact/client.py | Python | apache-2.0 | 23,268 | 0.004255 |
##Edge bundling=group
##input_layer=vector
##cluster_field=field input_layer
##weight_field=field input_layer
##use_weight_field=boolean true
##max_distance=number 0.008
##collapsed_lines=output vector
from qgis.core import *
from qgis.gui import *
import qgis.utils
from PyQt4.QtCore import *
import processing
from pr... | dts-ait/qgis-edge-bundling | summarize.py | Python | gpl-2.0 | 4,463 | 0.015685 |
# -*- coding: utf-8 -*-
#
# (C) 2016 Rodrigo Rodrigues da Silva <pitanga@members.fsf.org>
#
# This file is part of django-smssync
#
# django-smssync 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 versi... | rodrigopitanga/django-smssync | smssync/__init__.py | Python | gpl-3.0 | 772 | 0 |
from . import myModule | aammd/python-package-example | myPackage/__init__.py | Python | mit | 22 | 0.045455 |
'''
read the input data, parse to int list;
create mappings of (user,item) -> review int list
@author: roseck
@date Mar 15, 2017
'''
from __builtin__ import dict
import gzip
class DataPairMgr():
def _int_list(self,int_str):
'''utility fn for converting an int string to a list of int
'''
... | rosecatherinek/TransNets | src/DatasetUtils/DataPairMgr.py | Python | gpl-3.0 | 1,772 | 0.02088 |
from horizon_contrib.utils.dotdict import dotdict, list_to_dotdict, to_dotdict
| michaelkuty/horizon-contrib | horizon_contrib/utils/__init__.py | Python | bsd-3-clause | 79 | 0 |
import doctest
from contextlib import contextmanager
from django.core.exceptions import ValidationError
from django.db import IntegrityError, transaction
from django.db.models import ProtectedError
from django.test import TestCase
from nose.tools import assert_in
from corehq.apps.data_dictionary.models import CasePr... | dimagi/commcare-hq | corehq/motech/fhir/tests/test_models.py | Python | bsd-3-clause | 21,406 | 0.00028 |
# -*- coding: utf-8 -*-
class AutocompleteMeta:
"""
Simple meta class to allow the model to define aspects of the autocomplete.
:var name: used for the named url
:var path: the path to autocomplete view
:var follow_fks: when searching should ForeignKey fields be followed.
:var fields: list of... | darrylcousins/django-autocomplete | django_autocomplete/meta.py | Python | apache-2.0 | 1,979 | 0.002021 |
"""Deprecated import support. Auto-generated by import_shims/generate_shims.sh."""
# pylint: disable=redefined-builtin,wrong-import-position,wildcard-import,useless-suppression,line-too-long
from import_shims.warn import warn_deprecated_import
warn_deprecated_import('discussion.rest_api.tests.test_pagination', 'lms.d... | eduNEXT/edunext-platform | import_shims/lms/discussion/rest_api/tests/test_pagination.py | Python | agpl-3.0 | 446 | 0.008969 |
"""Utils for unit tests for views package."""
# -----------------------------------------------------------------------------
# Imports
# -----------------------------------------------------------------------------
import os
import threading
import time
from qtools import QtGui, QtCore
from qtools import s... | DavidTingley/ephys-processing-pipeline | installation/klustaviewa-0.3.0/klustaviewa/views/tests/utils.py | Python | gpl-3.0 | 5,313 | 0.005835 |
# -*- coding: utf-8 -*-
"""
Shortest path algorithms for weighed graphs.
"""
__author__ = """\n""".join(['Aric Hagberg <hagberg@lanl.gov>',
'Loïc Séguin-C. <loicseguin@gmail.com>',
'Dan Schult <dschult@colgate.edu>',
'Niels van Adrichem... | SanketDG/networkx | networkx/algorithms/shortest_paths/weighted.py | Python | bsd-3-clause | 33,546 | 0.000865 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.10 on 2018-02-23 21:38
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('members', '0005_trainingrecordtype'),
]
operations = [
migrations.AlterFie... | BenMotz/cubetoolkit | toolkit/members/migrations/0006_auto_20180223_2138.py | Python | agpl-3.0 | 506 | 0.001976 |
# -*- coding: utf-8 -*-
# @Author: karthik
# @Date: 2016-12-10 21:40:07
# @Last Modified by: chandan
# @Last Modified time: 2016-12-11 12:55:27
from models.portfolio import Portfolio
from models.company import Company
from models.position import Position
import tenjin
from tenjin.helpers import *
import wikipedia... | coders-creed/botathon | src/info/fetch_info.py | Python | mit | 2,889 | 0.023884 |
"""
:codeauthor: Thomas Stoner <tmstoner@cisco.com>
"""
# Copyright (c) 2018 Cisco and/or its affiliates.
#
# 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/li... | saltstack/salt | tests/unit/modules/nxos/nxos_n5k.py | Python | apache-2.0 | 5,857 | 0.004098 |
"""Create `voluntary_work_type` table
Revision ID: 597b5983e01c
Revises: 2e20f23a8ffd
Create Date: 2014-02-08 17:14:35.812815
"""
# revision identifiers, used by Alembic.
revision = '597b5983e01c'
down_revision = '2e20f23a8ffd'
from alembic import op
import sqlalchemy as sa
def upgrade():
op.create_table(
... | talkoopaiva/talkoohakemisto-api | talkoohakemisto/migrations/versions/597b5983e01c_create_voluntary_work_type_table.py | Python | mit | 546 | 0.003663 |
"""
Tri-Polar Grid Projected Plotting
=================================
This example demonstrates cell plots of data on the semi-structured ORCA2 model
grid.
First, the data is projected into the PlateCarree coordinate reference system.
Second four pcolormesh plots are created from this projected dataset,
using diff... | pp-mo/iris | docs/iris/example_code/General/orca_projection.py | Python | lgpl-3.0 | 1,647 | 0 |
# This file is part of Scapy
# See http://www.secdev.org/projects/scapy for more information
# Copyright (C) Philippe Biondi <phil@secdev.org>
# This program is published under a GPLv2 license
"""
SuperSocket.
"""
from __future__ import absolute_import
from select import select, error as select_error
import errno
imp... | mtury/scapy | scapy/supersocket.py | Python | gpl-2.0 | 11,654 | 0 |
from historia.enums.dict_enum import DictEnum
class Biome(DictEnum):
__exports__ = ['title', 'color', 'id']
arctic = {
'id': 1,
'title': 'Arctic',
'color': (224, 224, 224),
'fertility': 1,
'can_farm': False,
'has_forest': False,
'base_favorability': 10
... | eranimo/historia | historia/world/biome.py | Python | mit | 2,771 | 0.000361 |
# Use holoviews to plot the particle distribution at given time
from pathlib import Path
import numpy as np
import xarray as xr
import holoviews as hv
from postladim import ParticleFile
hv.extension("bokeh")
# --- Settings ---
tstep = 40 # Time step to show
# Output file (and type)
output_file = "line_hv.png"
#out... | bjornaa/ladim | examples/line/plot_holoviews.py | Python | mit | 1,481 | 0.000675 |
# -*- coding: utf-8 -*-
""" Command Line Interface.
"""
# Copyright © 2014 Jürgen Hermann
#
# 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
#
# ... | jhermann/neutrino-wand | src/neutrino_wand/cli.py | Python | apache-2.0 | 1,396 | 0.002869 |
#encoding:utf-8
__authors__ = ['"Wei Keke" <keke.wei@cs2c.com.cn>']
__version__ = "V0.1"
'''
# ChangeLog:
#---------------------------------------------------------------------------------
# Version Date Desc Author
#----------------------------------------------------... | faylau/oVirt3.3WebAPITest | src/TestData/Profile/ITC090402_UpdateProfile_DupName.py | Python | apache-2.0 | 1,804 | 0.003898 |
from Tools.Profile import profile
profile("LOAD:ElementTree")
import xml.etree.cElementTree
import os
profile("LOAD:enigma_skin")
from enigma import eSize, ePoint, eRect, gFont, eWindow, eLabel, ePixmap, eWindowStyleManager, addFont, gRGB, eWindowStyleSkinned, getDesktop
from Components.config import ConfigSubsection, ... | trunca/enigma2 | skin.py | Python | gpl-2.0 | 39,906 | 0.034506 |
# -*- coding: utf-8 -*-
import os
import tempfile
from slidown import config
def test_load_not_existing_config():
with tempfile.TemporaryDirectory() as temp_dir:
configuration_file = os.path.join(temp_dir, 'config.json')
import appdirs
appdirs.user_config_dir = lambda any_appname: temp_d... | riccardomarotti/slidown | tests/test_config.py | Python | gpl-3.0 | 1,706 | 0.002345 |
# -*- coding: utf-8 -*-
##
## This file is part of Invenio.
## Copyright (C) 2013 CERN.
##
## Invenio 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) a... | inspirehep/invenio | modules/bibcheck/lib/plugins/rename_subfield.py | Python | gpl-2.0 | 1,062 | 0.013183 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import uuid
class Migration(migrations.Migration):
dependencies = [
('authors', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='profile',
n... | CMPUT410W15T02/CMPUT410W15-project | social_distribution/authors/migrations/0002_auto_20150301_2125.py | Python | gpl-2.0 | 857 | 0 |
#!/usr/bin/env python3
#
# Usage: mysql-dump-splitter.py dump.sql.gz
# Usage: mysql-dump-splitter.py dump.sql.bz2
#
# @author Oktay Acikalin <oktay.acikalin@gmail.com>
# @copyright Oktay Acikalin
# @license MIT (LICENSE.txt)
import sys
import re
import gzip
import bz2
# HEADER_REGEX = r''
SECTION_INDICATOR = r'... | theblacklion/project-service | scripts/mysql-dump-splitter.py | Python | mit | 5,954 | 0.000168 |
import unittest
import numpy
import chainer
from chainer import dataset
from chainer import iterators
from chainer import testing
from chainer.training import extensions
class DummyModel(chainer.Chain):
def __init__(self, test):
super(DummyModel, self).__init__()
self.args = []
self.tes... | ronekko/chainer | tests/chainer_tests/training_tests/extensions_tests/test_evaluator.py | Python | mit | 8,187 | 0 |
import unittest
import pycodestyle
from os.path import exists
class TestCodeFormat(unittest.TestCase):
def test_conformance(self):
"""Test that we conform to PEP-8."""
style = pycodestyle.StyleGuide(quiet=False, ignore=['E501', 'W605'])
if exists('transitions'): # when run from root direc... | tyarkoni/transitions | tests/test_codestyle.py | Python | mit | 710 | 0 |
import random
import struct
########################################################################################################################
class base_primitive (object):
'''
The primitive base class implements common functionality shared across most primitives.
'''
def __init__ (self):
... | cirosantilli/sulley | sulley/primitives.py | Python | gpl-2.0 | 32,873 | 0.00721 |
"""
Interface definition.
"""
from zope import interface
class IMailer(interface.Interface):
"""
An object that sends e-mail.
"""
def send(sender, recipient, content):
"""
Sends the content to the recipient as the sender.
"""
class ITemplate(interface.Interface):
"""
... | lvh/txeasymail | txeasymail/interface.py | Python | isc | 541 | 0.001848 |
import unittest
from llvm.core import (Module, Type, Builder)
from .support import TestCase, tests
class TestExact(TestCase):
def make_module(self):
mod = Module.new('asdfa')
fnty = Type.function(Type.void(), [Type.int()] * 2)
func = mod.add_function(fnty, 'foo')
bldr = Builder.new(... | llvmpy/llvmpy | llvm/tests/test_exact.py | Python | bsd-3-clause | 1,076 | 0.003717 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import re
from random import randrange
import requests
import os.path
import xml.etree.ElementTree as ET
from xml.etree.ElementTree import ParseError
import logging
from io import TextIOWrapper, open
from unicodecsv import DictReader
from itertools import... | dchaplinsky/pep.org.ua | pepdb/tasks/management/commands/load_companies.py | Python | mit | 11,229 | 0.001812 |
# -*- 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):
# Adding model 'User'
db.create_table(u'accounts_user', (
(u'id', self.gf('django.db.models.fiel... | luanfonceca/econet | econet/accounts/migrations/0001_initial.py | Python | mit | 5,920 | 0.007264 |
from evoplotter import utils
from evoplotter import printer
from evoplotter import reporting
from evoplotter.dims import *
import numpy
def load_correct_props(folders, name = ""):
props0 = utils.load_properties_dirs(folders, exts=[".txt.cdgp"])
all_logs = utils.load_properties_dirs(folders, exts=[".txt.cdgp",... | iwob/evoplotter | app/cdgp2/cdgp_processor.py | Python | mit | 20,853 | 0.005946 |
# coding=utf-8
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
unicode_literals, with_statement)
import os
import pkg... | tejal29/pants | src/python/pants/backend/jvm/tasks/eclipse_gen.py | Python | apache-2.0 | 6,935 | 0.00721 |
"""
Handle audited data changes.
"""
import logging
from functools import partial
from pymongo.errors import OperationFailure
from .versioned_item import VersionedItem, ChangedItem
from .._util import are_equals
from ..decorators import _get_host
from ..exceptions import NoDataFoundException, ConcurrentModificationEx... | manahl/arctic | arctic/store/audit.py | Python | lgpl-2.1 | 6,512 | 0.005375 |
import os
from setuptools import setup
with open(os.path.join(os.path.dirname(__file__), "README.md")) as readme:
README = readme.read()
with open(os.path.join(os.path.dirname(__file__), "requirements.in")) as requirements:
REQUIREMENTS = [
req.split("#egg=")[1] if "#egg=" in req else req
for... | nim65s/django-cineclub | setup.py | Python | gpl-3.0 | 1,266 | 0.00079 |
# Copy of ntptime.py with millisecond-accurate sync
try:
import usocket as socket
except:
import socket
try:
import ustruct as struct
except:
import struct
# (date(2000, 1, 1) - date(1900, 1, 1)).days * 24*60*60
NTP_DELTA = 3155673600
MILLIS_PER_SECOND = 1000
host = "pool.ntp.org"
def time(ms_accur... | puhitaku/AutoChime | ntptime_kai.py | Python | mit | 1,216 | 0.002467 |
# Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Modifications made by Cloudera are:
# Copyright (c) 2016 Cloudera, 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. A cop... | jayceyxc/hue | desktop/core/ext-py/navoptapi-0.1.0/navoptapi/old_serialize.py | Python | apache-2.0 | 3,364 | 0.000595 |
"""
mediatum - a multimedia content repository
Copyright (C) 2009 Arne Seifert <seiferta@in.tum.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 3 of the License, or
(at your... | mediatum/mediatum | web/edit/modules/content.py | Python | gpl-3.0 | 5,793 | 0.002935 |
# Copyright (C) 2008-2011 Dejan Muhamedagic <dmuhamedagic@suse.de>
# See COPYING for license information.
import os
import subprocess
from lxml import etree, doctestcompare
import copy
import bz2
from collections import defaultdict
from . import config
from . import options
from . import schema
from . import constant... | ingted/crmsh | modules/xmlutil.py | Python | gpl-2.0 | 37,119 | 0.001051 |
##
# This file contains an class for pdf_collate
#
# @package pdf_collate
# @author Matt Koskela <mattkoskela@gmail.com>
##
"""
Example.py
This file contains an example class with a basic function.
"""
import os
import hashlib
from PyPDF2 import PdfFileReader, PdfFileWriter
class PDF():
"""
This i... | mattkoskela/py-pdf-collate | pdf_collate/pdf.py | Python | mit | 1,217 | 0.000822 |
from test_proxyviews import TestProxyViews
import uuid
class TestProxyViewsGenerate(TestProxyViews):
def test_generate_user_nobody(self):
assert(not self.views.generate_user(None, None))
def test_generate_user_ano(self):
user = self.views.generate_user('ano')
assert(user)
a... | ebu/PlugIt | tests/proxy_internal/test_proxyviews_generate.py | Python | bsd-3-clause | 3,938 | 0.001524 |
#!/usr/bin/env python
#
# 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 require... | anthrotype/nototools | nototools/noto_data.py | Python | apache-2.0 | 16,915 | 0.003074 |
#!/usr/bin/env python
import socket
import random
SERVERHOST = 'localhost'
SERVERPORT = 4080
LOCALIP = '127.0.0.2'
LOCALPORT = 4082
LOCALNAME = "30_PERCENT_SEE"
def higher(dice_a, dice_b):
ad1, ad2 = dice_a[0], dice_a[1]
bd1, bd2 = dice_b[0], dice_b[1]
if ad1 == bd1 and ad2 == bd2: return False
if ad1 == "2... | SteffenBauer/mia_elixir | python/mia_client1.py | Python | mit | 2,536 | 0.024054 |
import random
from firedrake import *
from firedrake_adjoint import *
import sys
mesh = UnitSquareMesh(4, 4)
V3 = FunctionSpace(mesh, "CG", 3)
V2 = FunctionSpace(mesh, "CG", 2)
firedrake.parameters["adjoint"]["record_all"] = True
def main(ic, annotate=False):
soln = project(ic, V2, annotate=annotate)
return soln... | ellipsis14/dolfin-adjoint | tests_firedrake/projection/projection.py | Python | lgpl-3.0 | 886 | 0.01693 |
# -*- coding: utf-8 -*-
import numpy as np
np.set_printoptions(precision=3, linewidth=256)
from dyconnmap.fc import mi
if __name__ == "__main__":
data = np.load(
"/home/makism/Github/dyconnmap/examples/data/eeg_32chans_10secs.npy")
data = data[0:5, :]
fs = 128
fb_lo = [1.0, 4.0]
fb_hi =... | makism/dyfunconn | examples/fc_mi.py | Python | bsd-3-clause | 390 | 0.002564 |
from OpenGLCffi.GL import params
@params(api='gl', prms=['minX', 'minY', 'minZ', 'minW', 'maxX', 'maxY', 'maxZ', 'maxW'])
def glPrimitiveBoundingBoxARB(minX, minY, minZ, minW, maxX, maxY, maxZ, maxW):
pass
| cydenix/OpenGLCffi | OpenGLCffi/GL/EXT/ARB/ES3_2_compatibility.py | Python | mit | 209 | 0.019139 |
#!/usr/bin/python
"""Module for batch converting images to JPEG 2000 format.
Takes an input directory and recreates the directory structure, with
converted images, in the specified output directory.
WARNING: If the same directory contains two or more images with the
same name (excepting the extension), only one of th... | kcl-ddh/chopin-online | ocve/scripts/ocvejp2converter.py | Python | gpl-3.0 | 10,997 | 0.010003 |
import json
import os
import tempfile
from lint import Linter
from lint.util import find
class Eclim(Linter):
language = 'java'
cmd = ('eclim', '-command', 'java_src_update')
regex = r'.'
defaults = {
'disable': True,
}
def run(self, cmd, code):
project = find(os.path.dirname... | michael-ball/sublime-text | sublime-text-3/Packages/User/linters/eclim.py | Python | unlicense | 2,139 | 0.000468 |
import os
import json
import click
def generate_graph(similarity_file, threshold=85):
edges = dict()
hosts_used = set()
with open(similarity_file, 'r') as json_file:
scores = json.load(json_file)
score_dict = {s['similarity']: (s['path1'], s['path2']) for s in scores}
for score, paths i... | matiskay/html-cluster | html_cluster/commands/make_graph.py | Python | bsd-3-clause | 1,507 | 0.001991 |
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "devproject.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that t... | philgyford/django-spectator | devproject/manage.py | Python | mit | 822 | 0 |
#!/usr/bin/env python
"""
Test rate-limiter lib
"""
import logging
import sys
import time
import unittest
from google.appengine.api import memcache
from google.appengine.ext import testbed
from lib import Limiter, QuotaKey
class Events:
USER_READ = 1
USER_WRITE = 2
RATE_LIMIT_SPEC = {
Events.USER_READ: ... | peterjliu/rate_limit | test_lib.py | Python | mit | 2,134 | 0.005623 |
from tornado.process import cpu_count, _reseed_random
from tornado import ioloop
import logging
import os
import signal
import sys
from tornado.util import errno_from_exception
import errno
logger = logging.getLogger(__name__)
_task_id = None
exiting = False
def fork_processes(num_processes, max_restar... | kevenli/scrapydd | scrapydd/process.py | Python | apache-2.0 | 3,812 | 0.001836 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-08-26 10:18
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('blogadmin', '0001_initial'),
]
operations = [
migrations.AlterField(
... | baike21/blog | blogadmin/migrations/0002_auto_20170826_1818.py | Python | gpl-3.0 | 822 | 0.002433 |
"""Config flow for OwnTracks."""
import secrets
from homeassistant import config_entries
from homeassistant.const import CONF_WEBHOOK_ID
from .const import DOMAIN # pylint: disable=unused-import
from .helper import supports_encryption
CONF_SECRET = "secret"
CONF_CLOUDHOOK = "cloudhook"
class OwnTracksFlow(config_... | partofthething/home-assistant | homeassistant/components/owntracks/config_flow.py | Python | apache-2.0 | 2,860 | 0.002448 |
###################### TREE######################
class node():
__parent = None
__left = None
__right = None
__data = None
def __init__(self, value):
self.__data = value
self.__parent = None
self.__left = None
self.__right = None
def get_parent(self... | junaart/Structure_data | Code/tree.py | Python | gpl-3.0 | 9,097 | 0.018138 |
"""
Provide pre-made queries on top of the recorder component.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/history/
"""
import asyncio
from collections import defaultdict
from datetime import timedelta
from itertools import groupby
import logging
imp... | Duoxilian/home-assistant | homeassistant/components/history.py | Python | mit | 11,138 | 0 |
import sys
import os
import commands
import nipype.pipeline.engine as pe
import nipype.algorithms.rapidart as ra
import nipype.interfaces.fsl as fsl
import nipype.interfaces.io as nio
import nipype.interfaces.utility as util
from utils import *
from CPAC.vmhc import *
from nipype.interfaces.afni import preprocess
from ... | sgiavasis/C-PAC | CPAC/vmhc/vmhc.py | Python | bsd-3-clause | 22,733 | 0.007918 |
# Copyright 2017 Red Hat, 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 program is distributed in the ... | EdDev/vdsm | lib/vdsm/network/ip/rule/__init__.py | Python | gpl-2.0 | 2,327 | 0 |
##############################################################################
# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-64... | EmreAtes/spack | lib/spack/spack/cmd/reindex.py | Python | lgpl-2.1 | 1,426 | 0 |
from __future__ import unicode_literals
from unittest import skipIf
from django.test import TestCase, override_settings
from django.db import connection, connections
from django.db.migrations.graph import NodeNotFoundError
from django.db.migrations.loader import MigrationLoader, AmbiguityError
from django.db.migratio... | oscaro/django | tests/migrations/test_loader.py | Python | bsd-3-clause | 12,020 | 0.002246 |
import abjad
def test_NoteHeadList___delitem___01():
"""
Deletes note-head.
"""
chord = abjad.Chord("<ef' cs'' f''>4")
del chord.note_heads[1]
assert abjad.lilypond(chord) == "<ef' f''>4"
| Abjad/abjad | tests/test_NoteHeadList___delitem__.py | Python | gpl-3.0 | 216 | 0 |
"""Check the requirements parsing."""
import io
from logassert import Multiple
from fades import parsing, REPO_PYPI, REPO_VCS
from tests import get_reqs
def test_empty():
parsed = parsing._parse_requirement(io.StringIO("""
"""))
assert parsed == {}
def test_simple():
parsed = parsing._parse_requ... | PyAr/fades | tests/test_parsing/test_reqs.py | Python | gpl-3.0 | 3,030 | 0.00066 |
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# Copyright 2011 Piston Cloud Computing, Inc.
# All Rights Reserved.
# Copyright 2013 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# no... | dawnpower/nova | nova/tests/unit/compute/test_compute.py | Python | apache-2.0 | 522,454 | 0.001066 |
"""
Siren pagination
"""
from __future__ import unicode_literals
from collections import OrderedDict
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response
from rest_framework_siren.utils import link_maker
class SirenPagination(PageNumberPagination):
"""
Pa... | clarkperkins/django-rest-framework-siren | rest_framework_siren/pagination.py | Python | apache-2.0 | 767 | 0 |
#!/usr/bin/env python
# vim:fileencoding=utf-8
# License: Apache 2.0 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
unicode = type('')
cdata_list_attributes = None
universal_cdata_list_attributes = None
empty = ()
def init_b... | kovidgoyal/html5-parser | src/html5_parser/soup.py | Python | apache-2.0 | 4,216 | 0.000949 |
from __future__ import absolute_import, division, print_function, unicode_literals
import numpy as np
class Unicorn(object):
def __init__(self):
import unicornhathd as unicorn
unicorn.rotation(180)
unicorn.brightness(0.75)
def write_pixels(self, data):
import unicornhath... | Spooner/pixel-table | pixel_table/external/unicorn.py | Python | mit | 513 | 0.003899 |
import math
class RaceApproximator:
def timeToBeat(self, d1, t1, d2, t2, raceDistance):
time = t1 * math.exp( math.log(float(t2)/t1) * math.log(float(d1)/raceDistance) / math.log(float(d1)/d2) )
time = int(time)
hours = time / 3600
minutes = (time - hours * 3600) / 60
... | mikefeneley/topcoder | src/SRM-184/race_approximator.py | Python | mit | 716 | 0.009777 |
# 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 a... | VitalLabs/gcloud-python | scripts/run_pylint.py | Python | apache-2.0 | 9,455 | 0 |
#coding:utf8
'''
发布订阅模式
'''
import message
#Example
def hello(name):
print "hello, %s."%name
def hi(name):
print "hi, %s."%name
def stop(name):
print 'hello, %s. greet5'%name
print 'discontinued.'
ctx = message.Context()
ctx.discontinued = True
return ctx
#订阅一个话题,并发布
message.sub('greet', ... | duanyifei/python_modules_test | test_message.py | Python | gpl-3.0 | 925 | 0.021935 |
import sublime, sublime_plugin
import os
import subprocess
import threading
class OpenGitbashHere(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
file_path = view.file_name()
dirname = os.path.dirname(file_path)
th = BashTerminalThread(dirname)
th.start(... | zeffii/sublimetext_productivity | Packages/User/open_gitbash_here.py | Python | mit | 719 | 0.002782 |
from . import views
from django.conf.urls import include, url
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# index page
url(r'^$', views.site().index, name = 'index'),
# login form
url(r'^login/$', views.site().login, name = 'login'),
url(r'^logout/$', ... | XcomConvent/xcom40k-shades | xcom40k/app/urls.py | Python | apache-2.0 | 3,601 | 0.029714 |
"like scenario_login.txt in NModel WebApplication"
from WebModel import Login, Logout
actions = (Login, Logout) # just these to allow interleaving
testSuite = [
[
(Login, ( 'VinniPuhh', 'Correct' ), 'Success'),
(Logout, ( 'VinniPuhh', ), None)
]
]
| jon-jacky/PyModel | samples/WebApplication/ScenarioLogin.py | Python | bsd-3-clause | 279 | 0.017921 |
__author__ = "Wren J. R. (uberfastman)"
__email__ = "wrenjr@yahoo.com"
# code snippets taken from: http://stackoverflow.com/questions/24419188/automating-pydrive-verification-process
import datetime
import logging
from pathlib import Path
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from... | uberfastman/yahoo-fantasy-football-metrics | integrations/drive_integration.py | Python | gpl-3.0 | 8,962 | 0.002008 |
from django.shortcuts import render
from django.http import HttpResponse
from django.db.models import Q, F
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from posts.models import Posts
from uploadfiles.models import UploadFile
from edu_warning.tools import user_setting
# Create your views he... | ran777/edu_intell | edu_creative/views.py | Python | gpl-3.0 | 3,325 | 0.001535 |
"""
x86 definitions.
Commonly used definitions.
"""
from __future__ import absolute_import
from cdsl.isa import TargetISA, CPUMode
import base.instructions
from . import instructions as x86
from base.immediates import floatcc
ISA = TargetISA('x86', [base.instructions.GROUP, x86.GROUP]) # type: TargetISA
# CPU modes... | nrc/rustc-perf | collector/benchmarks/cranelift-codegen/cranelift-codegen/meta-python/isa/x86/defs.py | Python | mit | 746 | 0 |
"""
Filename: calc_durack_ocean_maps.py
Author: Damien Irving, irving.damien@gmail.com
Description: Calculate the zonal and vertical mean ocean anomaly fields
from the Durack and Wijffels (2010) data files
"""
# Import general Python modules
import sys, os, pdb
import argparse, math
import n... | DamienIrving/ocean-analysis | data_processing/obs/calc_durack_ocean_maps.py | Python | mit | 5,232 | 0.005352 |
from django.db import models
from django.contrib.auth.models import User
class Attendance( models.Model ):
date = models.DateField()
teamMember = models.ForeignKey( User, blank = True, null = True, related_name = "calendarAttendances" )
workingDay = models.BooleanField()
user = models.ForeignKey( User, related_nam... | shlomimatichin/workflow | workflow/calendar/models.py | Python | gpl-3.0 | 554 | 0.057762 |
# Generated by Django 3.2 on 2021-05-11 13:43
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('stock', '0062_auto_20210511_2151'),
]
operations = [
migrations.RemoveField(
model_name='stockitemtracking',
name='link',
... | inventree/InvenTree | InvenTree/stock/migrations/0063_auto_20210511_2343.py | Python | mit | 676 | 0 |
# Copyright 2008 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... | rarcotvmw/capirca | tests/lib/iptables_test.py | Python | apache-2.0 | 39,394 | 0.002132 |
#!/usr/bin/env python
try:
from numpy import *
from scipy.integrate import quad
except ImportError:
print "ERROR: Need NumPy and SciPy modules"
raise
try:
from boututils import DataFile
except ImportError:
print "ERROR: Missing boututils.Datafile. Add pylib to your PYTHONPATH"
raise
#####... | bendudson/BOUT-1.0 | tools/tokamak_grids/cyclone/cyclone.py | Python | gpl-3.0 | 5,335 | 0.005061 |
from django import template
from django.contrib.contenttypes.models import ContentType
from django.template.loader import render_to_string
from ..models import TaggedItem, Tag
register = template.Library()
@register.assignment_tag
def get_tagged_items_for(object):
'''retrieve tagged items which relative with the... | giginet/django-generic-tagging | generic_tagging/templatetags/tagging.py | Python | mit | 1,210 | 0.000826 |
"""
Copyright 2007 Free Software Foundation, Inc.
This file is part of GNU Radio
SPDX-License-Identifier: GPL-2.0-or-later
"""
from os import path
from gi.repository import Gtk
from . import Constants, Utils, Dialogs
class FileDialogHelper(Gtk.FileChooserDialog, object):
"""
A wrapper class for the gtk ... | mrjacobagilbert/gnuradio | grc/gui/FileDialogs.py | Python | gpl-3.0 | 6,524 | 0.002452 |
import numpy
from chainer import cuda
from chainer import function
from chainer.utils import array
from chainer.utils import type_check
class BilinearFunction(function.Function):
def check_type_forward(self, in_types):
n_in = type_check.eval(in_types.size())
if n_in != 3 and n_in != 6:
... | kashif/chainer | chainer/functions/connection/bilinear.py | Python | mit | 6,625 | 0 |
from __future__ import unicode_literals
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class AccessAttempt(models.Model):
""" Access Attempt log """
user_agent = models.CharField(
max_length=255,
)
ip_address = models.Ge... | kencochrane/django-defender | defender/models.py | Python | apache-2.0 | 1,116 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.