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 |
|---|---|---|---|---|---|
# Code adapted from https://github.com/karpathy/neuraltalk
# by Andrej Karpathy
import json
import os
import random
import scipy.io
import codecs
from collections import defaultdict
import itertools
import gzip
import sys
import numpy
class BasicDataProvider:
def __init__(self, dataset, root='.', extra_train=False,... | gchrupala/reimaginet | imaginet/data_provider.py | Python | mit | 7,067 |
import arrow
import discord
from sigma.core.permission import check_man_msg, check_admin
from sigma.core.utils import user_avatar
async def textmute(cmd, message, args):
if not check_man_msg(message.author, message.channel):
response = discord.Embed(title='⛔ Unpermitted. Manage Messages Permission Needed.... | aurora-pro/apex-sigma | sigma/plugins/moderation/punish/textmute.py | Python | gpl-3.0 | 2,873 |
from unittest import TestCase
from nav.tableformat import SimpleTableFormatter
class TestSimpleTableFormatter(TestCase):
def test_column_count(self):
data = (('one', 'two', 'three'),
('alice', 'bob', 'charlie'))
s = SimpleTableFormatter(data)
self.assertEqual(s._get_column_... | UNINETT/nav | tests/unittests/general/test_tableformat.py | Python | gpl-2.0 | 1,813 |
import numina.core.pipeline
import pytest
from ..drpbase import DrpBase
def test_drpbase():
drpbase = DrpBase()
with pytest.raises(KeyError):
drpbase.query_by_name('TEST1')
assert drpbase.query_all() == {}
def test_invalid_instrument1():
class Something(object):
pass
drpbas... | guaix-ucm/numina | numina/drps/tests/test_drpbase.py | Python | gpl-3.0 | 1,219 |
def check(time):
box = A[:]
now = last
for student in range(m):
rest = time - now - 1
if rest <= 0:
return False
while now >= 0 and rest >= 0:
if box[now] <= rest:
rest -= box[now]
now -= 1
else:
box[... | knuu/competitive-programming | codeforces/cdf307_2c.py | Python | mit | 701 |
# -*- coding: utf-8 -*-
"""
pygments.lexers.ruby
~~~~~~~~~~~~~~~~~~~~
Lexers for Ruby and related languages.
:copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
import re
from pygments.lexer import Lexer, RegexLexer, ExtendedRegexLexer, ... | wandb/client | wandb/vendor/pygments/lexers/ruby.py | Python | mit | 22,141 |
"""
Definition of the course team feature.
"""
from django.utils.translation import ugettext_noop
from courseware.tabs import EnrolledTab
from . import is_feature_enabled
class TeamsTab(EnrolledTab):
"""
The representation of the course teams view type.
"""
type = "teams"
title = ugettext_noop(... | ahmedaljazzar/edx-platform | lms/djangoapps/teams/plugins.py | Python | agpl-3.0 | 788 |
import os
import fnmatch
import py_compile
from django.core.management.base import NoArgsCommand, CommandError
from django.conf import settings
from optparse import make_option
from os.path import join as _j
from django_extensions.management.utils import signalcommand
class Command(NoArgsCommand):
option_list = ... | vmanoria/bluemix-hue-filebrowser | hue-3.8.1-bluemix/desktop/core/ext-py/django-extensions-1.5.0/django_extensions/management/commands/compile_pyc.py | Python | gpl-2.0 | 1,277 |
'''
---------------------------------------- Masquerade ----------------------------------------
Allow course staff to see a student or staff view of courseware.
Which kind of view has been selected is stored in the session state.
'''
import logging
from django.conf import settings
from django.contrib.auth.decorators... | pepeportela/edx-platform | lms/djangoapps/courseware/masquerade.py | Python | agpl-3.0 | 10,684 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Example of data analysis based on a HDF5-like data model
========================================================
.. note:: WORK-IN-PROGRESS / NOT COMPLETE!
This example aims building a data analysis workflow based on a HDF5
representation. The goal is to keep everyt... | maurov/xraysloth | examples/data_analysis_h5.py | Python | bsd-3-clause | 4,714 |
__author__ = 'tbeltramelli'
import numpy as np
import math
from pylab import *
class UMath:
@staticmethod
def normalize(range_min, range_max, x, x_min, x_max):
return range_min + (((x - x_min) * (range_max - range_min)) / (x_max - x_min))
@staticmethod
def is_in_area(x, y, width, height):
... | tonybeltramelli/Graphics-And-Vision | Projective-Geometry/tony/com.tonybeltramelli.homography/UMath.py | Python | apache-2.0 | 2,192 |
import numpy as np
import json
from ..utils.data_utils import get_file
from .. import backend as K
CLASS_INDEX = None
CLASS_INDEX_PATH = 'https://s3.amazonaws.com/deep-learning-models/image-models/imagenet_class_index.json'
def preprocess_input(x, dim_ordering='default'):
if dim_ordering == 'default':
d... | jeffery-do/Vizdoombot | doom/lib/python3.5/site-packages/keras/applications/imagenet_utils.py | Python | mit | 1,644 |
"""
=================================
Box plots with custom fill colors
=================================
This plot illustrates how to create two types of box plots
(rectangular and notched), and how to fill them with custom
colors.
"""
import matplotlib.pyplot as plt
import numpy as np
# Random test da... | dariosena/LearningPython | general/boxplot_color_demo.py | Python | gpl-3.0 | 1,415 |
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
# udpate sales cycle
for d in ['Sales Invoice', 'Sales Order', 'Quotation', 'Delivery Note']:
frappe.db.sql("""upda... | suyashphadtare/test | erpnext/patches/v4_0/map_charge_to_taxes_and_charges.py | Python | agpl-3.0 | 666 |
# -*- coding: utf-8 -*-
#
# This file is part of Zenodo.
# Copyright (C) 2016 CERN.
#
# Zenodo 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 v... | slint/zenodo | zenodo/modules/records/serializers/schemas/json.py | Python | gpl-2.0 | 8,136 |
#
# A new home for the reporting code.
#
# This code is part of the LWN git data miner.
#
# Copyright 2007-13 Eklektix, Inc.
# Copyright 2007-13 Jonathan Corbet <corbet@lwn.net>
#
# This file may be distributed under the terms of the GNU General
# Public License, version 2.
#
import sys
Outfile = sys.stdout
HTMLfile ... | cbrune/onie | contrib/git-stats/gitdm/reports.py | Python | gpl-2.0 | 12,188 |
# models and fields
from celery import group
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
import django.contrib.postgres.fields as psql
# vault
from jinja2 import Template
from redcap.vault import vault
from vault import VaultKeyManager
# django signals
from django.db.models.sig... | berylTechnologies/redcap | task_manager/models.py | Python | gpl-3.0 | 9,052 |
'''Unit test for plural6.py'''
import plural6
import unittest
class KnownValues(unittest.TestCase):
def test_sxz(self):
'words ending in S, X, and Z'
nouns = {
'bass': 'basses',
'bus': 'buses',
'walrus': 'walruses',
'box': 'boxes',
'fax':... | ctasims/Dive-Into-Python-3 | examples/pluraltest6.py | Python | mit | 6,072 |
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Wrapper around chrome.
Replaces all the child processes (renderer, GPU, plugins and utility) with the
IPC fuzzer. The fuzzer will then play back a specifi... | scheib/chromium | tools/ipc_fuzzer/scripts/play_testcase.py | Python | bsd-3-clause | 3,671 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-09-07 13:06
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import modelcluster.fields
class Migration(migrations.Migration):
initial = True
dependencies = [
('events', '000... | jeremy-c/unusualbusiness | unusualbusiness/howtos/migrations/0002_auto_20160907_1506.py | Python | bsd-3-clause | 2,240 |
from django.conf import settings
from django.db import connections, models
from django.utils import translation
import multidb
from gelato.translations.models import Translation
from gelato.translations.fields import TranslatedField
isnull = """IF(!ISNULL({t1}.localized_string), {t1}.{col}, {t2}.{col})
A... | washort/gelato.models | gelato/translations/transformer.py | Python | bsd-3-clause | 3,203 |
import py
from rpython.jit.metainterp.test.test_virtualizable import ImplicitVirtualizableTests
from rpython.jit.backend.arm.test.support import JitARMMixin
class TestVirtualizable(JitARMMixin, ImplicitVirtualizableTests):
def test_blackhole_should_not_reenter(self):
py.test.skip("Assertion error & llinte... | oblique-labs/pyVM | rpython/jit/backend/arm/test/test_virtualizable.py | Python | mit | 330 |
#!/usr/bin/python
from datetime import datetime, timedelta
from httplib import BadStatusLine # This keeps happening but is not a problem on the code's end
import httplib2
import mongokit
from optparse import OptionParser
from pymongo import MongoClient
from random import random
import time
from apiclient.discovery im... | kusinwolf/mytube | Youtube.py | Python | apache-2.0 | 10,932 |
from django.conf import settings
from django.template.base import (Library, Node, Variable,
TOKEN_BLOCK, TOKEN_COMMENT, TOKEN_TEXT, TOKEN_VAR,
TemplateSyntaxError, VariableDoesNotExist, Context)
from django.utils.encoding import smart_str
from django.templatetags.cache import CacheNode
from phased.utils import... | mab2k/django-phased | phased/templatetags/phased_tags.py | Python | bsd-3-clause | 5,955 |
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes ... | lmazuel/azure-sdk-for-python | azure-mgmt-web/azure/mgmt/web/models/hybrid_connection_key.py | Python | mit | 1,924 |
# This file is part of Rubber and thus covered by the GPL
import rubber.dvip_tool
import rubber.module_interface
class Module (rubber.module_interface.Module):
def __init__ (self, document, opt):
self.dep = rubber.dvip_tool.Dvip_Tool_Dep_Node (document, 'dvips')
| skapfer/rubber | src/latex_modules/dvips.py | Python | gpl-2.0 | 278 |
#!/usr/bin/env python
# encoding: utf-8
'''
Created by Brian Cherinka on 2016-04-26 09:20:35
Licensed under a 3-clause BSD license.
Revision History:
Initial Version: 2016-04-26 09:20:35 by Brian Cherinka
Last Modified On: 2016-04-26 09:20:35 by Brian
'''
import numpy
from decimal import Decimal
from psycopg... | bretthandrews/marvin | python/marvin/db/NumpyAdaptors.py | Python | bsd-3-clause | 4,343 |
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 05 07:55:56 2016
@author: Suhas Somnath, Chris Smith
"""
from __future__ import division, print_function, absolute_import
import h5py
import numpy as np
import sklearn.decomposition as dec
from ..io.hdf_utils import checkIfMain
from ..io.hdf_utils import getH5DsetRefs, ... | anugrah-saxena/pycroscopy | pycroscopy/processing/decomposition.py | Python | mit | 7,296 |
#!/usr/bin/env python
'''
Command to send data extracted from prometheus endpoints to monitoring systems
For example config see prometheus_metrics.yml.example in the same folder this script is
'''
# vim: expandtab:tabstop=4:shiftwidth=4
#This is not a module, but pylint thinks it is. This is a command.
#pylint: ... | rhdedgar/openshift-tools | scripts/monitoring/cron-send-prometheus-data.py | Python | apache-2.0 | 5,124 |
# -*- coding: UTF-8 -*-
#
# Copyright (c) 2015-2019 by Inteos Sp. z o.o.
# All rights reserved. See LICENSE file for details.
#
from __future__ import unicode_literals
from django.db import models
# Create your models here.
class Widgets(models.Model):
name = models.TextField(unique=True)
icon = models.Cha... | inteos/IBAdmin | dashboard/models.py | Python | agpl-3.0 | 608 |
#!/usr/bin/env python3
import unittest, argparse
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbosity", default=2, type=int)
v = parser.parse_args().verbosity
loader = unittest.TestLoader()
suite = loader.discover(start_dir="tests", pattern="*.py")
runner = unittest.TextTestRunner(verbosity=v)
resu... | mymedia2/vk-cli | launch_tests.py | Python | lgpl-3.0 | 343 |
import base64
import logging
from urllib import urlencode
from decimal import getcontext
from dateutil.tz import tzutc
import httplib2
from sharpy.exceptions import CheddarError, AccessDenied, BadRequest, NotFound, PreconditionFailed, CheddarFailure, NaughtyGateway, UnprocessableEntity
client_log = logging.getLogger(... | SeanOC/sharpy | sharpy/client.py | Python | bsd-3-clause | 4,556 |
from event import Event
class SensorEvent(Event):
def __init__(self, t, label, value):
Event.__init__(self, t, label)
self.value = value
def getValue(self):
return self.value
def __repr__(self):
return "SensorEvent["+str(self.label)+",t="+str(self.t)+",value="+str(self.va... | sonologic/thermo2 | src/py/sensor_event.py | Python | gpl-2.0 | 330 |
# furElise.py
# Generates the theme from Beethoven's Fur Elise.
from music import *
# theme has some repetition, so break it up to maximize economy
# (also notice how we line up corresponding pitches and durations)
pitches1 = [E5, DS5, E5, DS5, E5, B4, D5, C5]
durations1 = [SN, SN, SN, SN, SN, SN, SN, SN]
pitch... | manaris/jythonMusic | 2. furElise.py | Python | gpl-3.0 | 908 |
#
# example from CHiLL manual page 18
#
# shift a loop
#
from chill import *
source('shift_to.c')
destination('shift_to2modified.c')
procedure('mm')
loop(0)
known('ambn > 0')
known('an > 0')
known('bm > 3')
shift_to( 1, 2, 3 )
| ztuowen/chill-dev | examples/chill/testcases/shift_to2.script.py | Python | gpl-3.0 | 241 |
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# bu... | will-Do/avocado | avocado/utils/data_structures.py | Python | gpl-2.0 | 1,698 |
# The contents of this file are subject to the BitTorrent Open Source License
# Version 1.1 (the License). You may not copy or use this file, in either
# source code or executable form, except in compliance with the License. You
# may obtain a copy of the License at http://www.bittorrent.com/license/.
#
# Software di... | rays/ipodderx-core | khashmir/khashmir.py | Python | mit | 16,801 |
# coding=utf-8
r"""
This code was generated by
\ / _ _ _| _ _
| (_)\/(_)(_|\/| |(/_ v1.0.0
/ /
"""
from twilio.base import deserialize
from twilio.base import serialize
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import... | tysonholub/twilio-python | twilio/rest/monitor/v1/alert.py | Python | mit | 15,815 |
# -*-coding:Utf-8 -*-
# Compatibility 2.7-3.4
from __future__ import absolute_import
from __future__ import unicode_literals
import flask
from app import app
@app.errorhandler(404)
def page_not_found(error):
return "ERROR: You must fill the requested fields", 404, \
{"content-type": "text/plain; charset... | VeryTastyTomato/passhport | passhportd/app/views_mod/__init__.py | Python | agpl-3.0 | 329 |
import os
import unittest
import cStringIO
import operator
import itertools
import functools
import amara
from amara.writers.struct import *
from amara.writers import lookup
from amara import bindery
from amara.bindery.util import property_str_getter
from amara.test import file_finder
FILE = file_finder(__file__)
d... | zepheira/amara | test/sevendays/test_three.py | Python | apache-2.0 | 5,515 |
T = int(input())
arr = []
dirr = {}
while(T):
T-=1
a,b = map(int, raw_input().split())
arr.append(a+b)
arr2 = sorted(arr)
fin = []
for i in range(len(arr2)):
for j in range(len(arr)):
if arr[i] == arr2[j]:
fin.append(j+1)
#print arr
#print arr2
print reduce(lambda x, y: s... | Dawny33/Code | Hackerrank/101 Hack Sept/order.py | Python | gpl-3.0 | 346 |
import sys, os
import unittest
# A list of demos that depend on user-interface of *any* kind. Tests listed
# here are not suitable for unattended testing.
ui_demos = """GetSaveFileName print_desktop win32cred_demo win32gui_demo
win32gui_dialog win32gui_menu win32gui_taskbar
win32rcparser_d... | leighpauls/k2cro4 | third_party/python_26/Lib/site-packages/win32/test/testall.py | Python | bsd-3-clause | 3,777 |
# Copyright 2012-2013 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | nttcom/eclcli | eclcli/identity/v2_0/service.py | Python | apache-2.0 | 5,681 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Pyromaths
# Un programme en Python qui permet de créer des fiches d'exercices types de
# mathématiques niveau collège ainsi que leur corrigé en LaTeX.
# Copyright (C) 2014 -- Jérôme Ortais (jerome.ortais@pyromaths.org)
#
# This program is free software; you can redistribute... | JeromeO/Pyromaths | src/pyromaths/ex/troisiemes/developpements.py | Python | gpl-2.0 | 3,907 |
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import _, models
class StockMove(models.Model):
_inherit = "stock.move"
def _filter_anglo_saxon_moves(self, product):
res = super(StockMove, self)._filter_anglo_saxon_moves(product)
r... | jeremiahyan/odoo | addons/mrp_account/models/stock_move.py | Python | gpl-3.0 | 1,716 |
import unittest
import logging
import time
from mock import Mock, MagicMock, patch
from django.conf import settings
from django.test import TestCase
from xmodule.course_module import CourseDescriptor
from xmodule.error_module import ErrorDescriptor
from xmodule.modulestore import Location
from xmodule.timeparse impor... | elimence/edx-platform | lms/djangoapps/courseware/tests/test_access.py | Python | agpl-3.0 | 5,047 |
# -*- coding: UTF-8
# jobs/base
# *********
#
# Base class for implement the scheduled tasks
import time
from twisted.internet import task, defer, reactor, threads
from globaleaks.handlers.base import TimingStatsHandler
from globaleaks.utils.mailutils import send_exception_email, extract_exception_traceback_and_se... | vodkina/GlobaLeaks | backend/globaleaks/jobs/base.py | Python | agpl-3.0 | 4,133 |
"""Support for monitoring a Neurio energy sensor."""
import logging
from datetime import timedelta
import requests.exceptions
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (CONF_API_KEY, POWER_WATT,
ENERGY_KILO_WAT... | MartinHjelmare/home-assistant | homeassistant/components/neurio_energy/sensor.py | Python | apache-2.0 | 5,417 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Autor: Alexey V. Polurotov
# e-mail: niimailtah@gmail.com
# Common nick: Niimailtah
# ----------------------------------------------------------------------------
# https://projecteuler.net/problem=14
# Longest Collatz sequence
# Problem 14
#
# The following iterative ... | niimailtah/projecteuler.net | sources/problem014.py | Python | gpl-2.0 | 1,406 |
# -*- coding: utf-8 -*-
import pygtk
pygtk.require("2.0")
import gtk
import time
import thread
import os
from datetime import datetime
from Timetableasy import app
connection_status = {
0 : {
'stock' : 'gtk-disconnect',
'tooltip' : 'Vous êtes actuellement déconnecté.'
},
1 : {
'stock' : 'gtk-conn... | SBillion/timetableasy | src/Status_Bar.py | Python | agpl-3.0 | 3,849 |
"""A streaming dataflow pipeline to count pub/sub messages.
"""
import argparse
import logging
from datetime import datetime
import apache_beam as beam
from apache_beam.options.pipeline_options import (
GoogleCloudOptions,
PipelineOptions,
SetupOptions,
StandardOptions,
)
from apache_beam.transforms ... | GoogleCloudPlatform/asl-ml-immersion | notebooks/building_production_ml_systems/labs/taxicab_traffic/streaming_count.py | Python | apache-2.0 | 2,896 |
../../../../../../share/pyshared/Crypto/SelfTest/Cipher/test_ARC2.py | Alberto-Beralix/Beralix | i386-squashfs-root/usr/lib/python2.7/dist-packages/Crypto/SelfTest/Cipher/test_ARC2.py | Python | gpl-3.0 | 68 |
from method_decorator import method_decorator
__version__ = '0.0.1'
class virtualmethod(method_decorator):
"""
Decorator to prevent base class methods from being called directly.
"""
def __call__(self, *args, **kwargs):
if self.cls and self.cls.__dict__.has_key(self.__name__):
rais... | bgreenlee/virtualmethod | virtualmethod/core.py | Python | apache-2.0 | 475 |
# coding=utf8
"""
asm.py - (dis)assembly features.
(c) 2014 Samuel Groß
"""
from willie import web
from willie.module import commands, nickname_commands, example
from random import choice
from binascii import hexlify, unhexlify
import string
import re
import os
from subprocess import Popen, PIPE
@commands('disas', ... | saelo/willie-modules | asm.py | Python | mit | 4,715 |
#!/usr/bin/env python
import glob
import sys
import os
import vtktools
import numpy
import pylab
import re
def get_filelist(sample, start):
def key(s):
return int(s.split('_')[-1].split('.')[0])
list = glob.glob("*.vtu")
list = [l for l in list if 'check' not in l]
vtu_nos = [float(s.spli... | FluidityProject/multifluids | examples/backward_facing_step_2d/postprocessor_2d.py | Python | lgpl-2.1 | 8,741 |
#!/usr/bin/env python3
"""
Copyright (c) 2013 Alan Yorinks All rights reserved.
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 versio... | MrYsLab/pymata-aio | test/stepper.py | Python | agpl-3.0 | 1,746 |
'''
Created on 2016年2月23日
@author: Darren
'''
'''
Given an image represented by an NxN matrix,
where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees.
Can you do this in place?
'''
'''
* clockwise rotate
* first reverse up to down, then swap the symmetry
* 1 2 3 7 8 9 ... | darrencheng0817/AlgorithmLearning | Python/CTCI/1_6.py | Python | mit | 1,138 |
#!/usr/bin/python
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Unittests for SDK stages."""
from __future__ import print_function
import json
import os
import sys
sys.path.insert(0, os.path... | mxOBS/deb-pkg_trusty_chromium-browser | third_party/chromite/cbuildbot/stages/sdk_stages_unittest.py | Python | bsd-3-clause | 4,152 |
#!/usr/bin/python
from __future__ import print_function
import sys
lines = [l.rstrip().replace('\t', ' '*8) for l in sys.stdin.readlines()]
print('TITLE')
print(lines[0])
print()
print('SYNOPSIS')
for i,line in enumerate(lines[2:]):
if line.lstrip().startswith('-'):
optStart = i+2
break
prin... | jeremyselan/oiio | src/doc/help2man_preformat.py | Python | bsd-3-clause | 749 |
import os.path as op
from nose.tools import eq_, ok_
from flask_admin.contrib import fileadmin
from flask_admin import Admin
from flask import Flask
from . import setup
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
def create_view():
app, admin = setup()
class MyF... | Widiot/simpleblog | venv/lib/python3.5/site-packages/flask_admin/tests/fileadmin/test_fileadmin.py | Python | mit | 5,579 |
# -*- coding: utf-8 -*-
import re
import sys
import duralex.alinea_lexer as alinea_lexer
import duralex.tree
from duralex.tree import *
def debug(node, tokens, i, msg):
if '--debug' in sys.argv:
print(' ' * get_node_depth(node) + msg + ' ' + str(tokens[i:i+8]))
def is_number(token):
return re.co... | Legilibre/duralex | duralex/alinea_parser.py | Python | mit | 59,689 |
# coding: utf-8
from django.conf.urls import url
from rest_framework.urlpatterns import format_suffix_patterns
from composition import views
urlpatterns = [
url(r'^$', views.CompositionList.as_view()),
url(r'^(?P<pk>[0-9]+)/$', views.CompositionDetail.as_view()),
url(r'^image/(?P<pk>[0-9]+)/$', v... | lbjworld/article-search | article-manager/site/composition/urls.py | Python | mit | 409 |
"""
Take 1 on the RandomForest, predicting for country_destinations.
"""
import pandas as pd
import numpy as np
from sklearn.cross_validation import train_test_split
training = pd.read_csv("protoAlpha_training.csv")
testing = pd.read_csv("protoAlpha_testing.csv")
X = training.iloc[:,1:-1].values
y = training['country... | valexandersaulys/airbnb_kaggle_contest | prototype_alpha/xgboost_take9.py | Python | gpl-2.0 | 2,282 |
from . import test_customize
from . import test_sale_process
from . import test_website_sale_cart_recovery
from . import test_website_sale_mail
from . import test_website_sale_pricelist
from . import test_website_sale_product_attribute_value_config
from . import test_website_sale_image
| t3dev/odoo | addons/website_sale/tests/__init__.py | Python | gpl-3.0 | 287 |
#!/usr/bin/env python
import sys
def convert_str(infile, outfile):
f = open(infile, 'r')
lines = f.readlines()
f.close()
f = open(outfile, 'w')
f.writelines(['"%s\\n"\n' % i.rstrip() for i in lines])
f.close()
def main():
convert_str('fountain.vert', 'fountain.vert.inc')
convert_str('... | fountainment/FountainEngineImproved | fountain/render/convert_shader.py | Python | mit | 396 |
from graphEntity import *
from GraphicalForm import *
from ATOM3Constraint import *
class graph_image(graphEntity):
def __init__(self, x, y, semObject = None):
self.semanticObject = semObject
self.sizeX, self.sizeY = 42, 44
graphEntity.__init__(self, x, y)
self... | Balannen/LSMASOMM | atom3/Kernel/GraphicalObjects/graph_image.py | Python | gpl-3.0 | 1,116 |
import logging
try:
from typing import Union, Optional
except ImportError:
pass
import rope.base.utils as base_utils
from rope.base.evaluate import ScopeNameFinder
from rope.base.exceptions import AttributeNotFoundError
from rope.base.pyobjects import PyClass, PyDefinedObject, PyFunction, PyObject
from rope.ba... | python-rope/rope | rope/base/oi/type_hinting/utils.py | Python | lgpl-3.0 | 5,609 |
"""
Visualize the Impact of Hygroscopic Growth
==========================================
_thumb: .4, .4
"""
import seaborn as sns
import numpy as np
import opcsim
sns.set(style='ticks', font_scale=1.25)
# build a distribution for a single mode of ammonium sulfate
d = opcsim.AerosolDistribution("Ammonium Sulfate")
# ... | dhhagan/opcsim | examples/hygroscopic_growth_pdf.py | Python | mit | 896 |
import logging
from typing import Callable
import weakref
from functools import partial
_LOG = logging.getLogger(__name__)
class BoundForwardReference(object):
@property
def resolver(self):
return self._resolver
@resolver.setter
def resolver(self, value: Callable):
try:
... | artPlusPlus/elemental-backend | elemental_backend/resources/_resource_reference.py | Python | mpl-2.0 | 6,809 |
import functools
from django import http
from django.shortcuts import get_object_or_404
import commonware.log
from olympia.access import acl
from olympia.addons.models import Addon
log = commonware.log.getLogger('mkt.purchase')
def owner_or_unlisted_reviewer(request, addon):
return (acl.check_unlisted_addons_r... | andymckay/addons-server | src/olympia/addons/decorators.py | Python | bsd-3-clause | 2,174 |
#!/usr/bin/env python
#
# Copyright 2011,2012,2015 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
#
from gnuradio import gr
from gnuradio import blocks
import sys
try:
from gnuradio import qtgui
from PyQt5 import QtWidgets, Qt
import sip
e... | mbr0wn/gnuradio | gr-qtgui/examples/pyqt_time_c.py | Python | gpl-3.0 | 6,141 |
# -*- coding: utf-8 -*-
""" Unit tests for the MultiWarpClassifier class.
"""
import unittest
import numpy as np
from warpclassifier import WarpClassifier
from ioutils import load_data, load_data_pixiv
from features import Combine, BGRHist, HoG
from cross_validation import k_fold_split
class TestWarpClassifier(unitte... | alexisVallet/dpm-identification | test_warpclassifier.py | Python | gpl-2.0 | 2,485 |
# coding: utf-8
#
# Copyright 2014 The Oppia 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 requi... | won0089/oppia | extensions/interactions/CodeRepl/CodeRepl.py | Python | apache-2.0 | 2,338 |
import numpy as np
import control
import sympy
from pypiw import algorithms, systems
def main():
""" Example demonstrating how to do a simple identification
"""
# Create the dataset to work on
t = np.arange(0, 20, 0.02)
x = np.ones(len(t))
tf = control.tf([2.0, 1.0], [-3.0, 1.0])
_, y, _ =... | Hofsmo/PyPiW | examples/first_order.py | Python | gpl-3.0 | 651 |
#-*- coding:Utf-8 -*-
import numpy as np
import os
import sys
import shutil
import pkgutil
import pdb
import seaborn as sns
class PyLayers(object):
""" Generic PyLayers Meta Class
"""
# sns.set_style("white")
def help(self,letter='az',typ='mt'):
""" generic help
Parameters
... | buguen/pylayers | pylayers/util/project.py | Python | lgpl-3.0 | 10,152 |
# err.py
s = '0'
n = int(s)
print(10 / n) | PeytonXu/learn-python | learn/www.liaoxuefeng.com/err.py | Python | mit | 41 |
## A script for extracting info about the patients used in the analysis
## Load necessary modules
from rpy2 import robjects as ro
import numpy as np
import os
ro.r('library(survival)')
##This call will only work if you are running python from the command line.
##If you are not running from the command line manually... | OmnesRes/pan_cancer | paper/cox_regression/BLCA/patient_info.py | Python | mit | 7,247 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.8 on 2017-07-02 02:30
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('usercenter', '0003_auto_20161008_2126'),
]
operations ... | tkliuxing/bookspider | booksite/booksite/usercenter/migrations/0004_auto_20170702_1030.py | Python | apache-2.0 | 1,149 |
import pygame as pg
from src.game import Sprite, GameObject, Animation
from src.physics import Body, Vector
class Enemy(GameObject):
def __init__(self, pos):
# enemy = [pg.image.load('enemy1.png'), pg.image.load('enemy2.png'), pg.image.load('enemy3.png'), pg.image.load('enemy2.png')]
# imgs = [pg.image.load('sta... | LittleSmaug/summercamp2k17 | src/objects/enemy.py | Python | gpl-3.0 | 1,405 |
# -*- coding: utf-8 -*-
from odoo import models, fields, api
EQPT_TYPES = INDIV_TYPES + BOAT_TYPES + FURNITURE_TYPES + TRAILER_TYPES + VEHICLE_TYPES
class Equipment(models.Model):
_name = 'eqpt.equipment'
_description = "Equipment"
@api.model
def _get_currency(self):
return False
name =... | RemiFr82/ck_addons | ck_equipment/models/eqpt_equipment.py | Python | gpl-3.0 | 1,228 |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | indhub/mxnet | python/mxnet/gluon/data/sampler.py | Python | apache-2.0 | 4,279 |
from django import template
from playlist.models import ScheduledPlaylist
register = template.Library()
@register.tag
def get_current_playlist_entry(parser, token):
try:
tag_name, for_arg, obj, as_arg, as_varname = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError('g... | praekelt/panya-playlist | playlist/templatetags/playlist_template_tags.py | Python | bsd-3-clause | 1,566 |
import json
import config
import sys
def check_configuration():
if config.access_token == '' or config.access_token_secret == '' or\
config.consumer_key == '' or config.consumer_secret == '':
print('Check config.py file and write the Twitter keys there.')
sys.exit(1)
| cpina/twitter2rss | utils.py | Python | agpl-3.0 | 298 |
from jsonrpc import ServiceProxy
access = ServiceProxy("http://127.0.0.1:9447")
pwd = raw_input("Enter old wallet passphrase: ")
pwd2 = raw_input("Enter new wallet passphrase: ")
access.walletpassphrasechange(pwd, pwd2)
| IlfirinIlfirin/shavercoin | contrib/wallettools/walletchangepass.py | Python | mit | 220 |
"""
SoftLayer.API
~~~~~~~~~~~~~
SoftLayer API bindings
:license: MIT, see LICENSE for more details.
"""
# pylint: disable=invalid-name
import time
import warnings
import json
import logging
import requests
from SoftLayer import auth as slauth
from SoftLayer import config
from SoftLayer import consts... | softlayer/softlayer-python | SoftLayer/API.py | Python | mit | 22,926 |
# Copyright (C) 2014 Red Hat, 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 wr... | hkumarmk/oslo.messaging | tests/test_amqp_driver.py | Python | apache-2.0 | 29,574 |
#
# ImageViewCanvasQt.py -- A FITS image widget with canvas drawing in Qt
#
# Eric Jeschke (eric@naoj.org)
#
# Copyright (c) Eric R. Jeschke. All rights reserved.
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
#
from ginga import ImageView, Mixins
from ging... | bsipocz/ginga | ginga/qtw/ImageViewCanvasQt.py | Python | bsd-3-clause | 3,179 |
from __future__ import absolute_import, division, print_function, unicode_literals
import caffe2.python.hypothesis_test_util as hu
import hypothesis.strategies as st
import numpy as np
import numpy.testing as npt
from caffe2.python import core, workspace
from hypothesis import given
class TestEnsureClipped(hu.Hypoth... | ryfeus/lambda-packs | pytorch/source/caffe2/python/operator_test/ensure_clipped_test.py | Python | mit | 1,587 |
# ==============================================================================
# Copyright (C) 2011 Diego Duclos
# Copyright (C) 2011-2018 Anton Vorobyov
#
# This file is part of Eos.
#
# Eos is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as publi... | pyfa-org/eos | eos/eve_obj/effect/warfare_buff/command_mining.py | Python | lgpl-3.0 | 1,220 |
#!/usr/bin/env python
import agate
from csvkit.cli import CSVKitUtility, parse_column_identifiers
class CSVSort(CSVKitUtility):
description = 'Sort CSV files. Like the Unix "sort" command, but for tabular data.'
def add_arguments(self):
self.argparser.add_argument(
'-n', '--names', dest... | wireservice/csvkit | csvkit/utilities/csvsort.py | Python | mit | 2,282 |
# -*- coding: utf-8 -*-
#########################################################################
#
# Copyright (C) 2012 OpenPlans
#
# 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 versio... | RCMRD/geonode | geonode/maps/tests.py | Python | gpl-3.0 | 22,485 |
from enigma import eServiceCenter, eServiceReference, pNavigation, getBestPlayableServiceReference, iPlayableService, setPreferredTuner, eStreamServer
from Components.ParentalControl import parentalControl
from Components.SystemInfo import SystemInfo
from Components.config import config, configfile
from Tools.BoundFunc... | ACJTeam/enigma2 | Navigation.py | Python | gpl-2.0 | 9,282 |
import os.path
import pitch_histogram
import mfccs
import event_histogram
file = './features.csv'
def featurize(releases):
releases = [str(x) for x in releases]
if not os.path.isfile(file):
features = open(file, 'a')
features.write('release,tatum_distribution,pitch_distribution,mel_frequency_c... | lathertonj/RemixNoveltyRanker | Code/featurize.py | Python | gpl-2.0 | 1,137 |
# Copyright (c) 2003-2010 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# 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, o... | isohybrid/dotfile | vim/bundle/git:--github.com-klen-python-mode/pylibs/pylint/checkers/__init__.py | Python | bsd-2-clause | 5,491 |
from operator import add
from flask import render_template
from markdown import markdown
from warmsea.models import SrmRound
def index():
rounds = SrmRound.query.order_by('date')
problems = []
for problems_in_a_round in [list(r.problems.order_by('name')) for r in rounds]:
problems += problems_in... | warmsea/warmsea.net | warmsea/srm/views.py | Python | mit | 1,263 |
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models import Q
from core.models import TimeStampedModel
from accounts.models import Account
class Board(models.Model):
def __str__(self):
return 'Board Name: ' + self.name
def get_absolute_url(self):
re... | hyesun03/k-board | kboard/board/models.py | Python | mit | 3,211 |
#
# This file is part of Bluepass. Bluepass is Copyright (c) 2012-2013
# Geert Jansen.
#
# Bluepass is free software available under the GNU General Public License,
# version 3. See the file LICENSE distributed with this file for the exact
# licensing terms.
from __future__ import absolute_import, print_function
impo... | geertj/bluepass | bluepass/base64.py | Python | gpl-3.0 | 1,605 |
#copyright ReportLab Europe Limited. 2000-2012
#see license.txt for license details
import os, sys
import unittest
from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
setOutDir(__name__)
from reportlab.pdfgen import canvas
from reportlab.lib import pdfencrypt
def mak... | nickpack/reportlab | tests/test_pdfencryption.py | Python | bsd-3-clause | 1,443 |
# pylint: disable=E1101,E1103
# pylint: disable=W0703,W0622,W0613,W0201
from pandas.compat import range, zip
from pandas import compat
import itertools
import numpy as np
from pandas.core.series import Series
from pandas.core.frame import DataFrame
from pandas.core.sparse import SparseDataFrame, SparseSeries
from pa... | Vvucinic/Wander | venv_2_7/lib/python2.7/site-packages/pandas/core/reshape.py | Python | artistic-2.0 | 39,134 |
#!/usr/bin/env python
'Unit test for import_relative'
import inspect, os, sys, unittest
top_builddir = os.path.join(os.path.dirname(__file__), '..')
if top_builddir[-1] != os.path.sep:
top_builddir += os.path.sep
sys.path.insert(0, top_builddir)
from import_relative import *
def true(): return true
class TestImpo... | rocky/pyimport-relative | test/test-basic.py | Python | gpl-3.0 | 2,380 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.