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 |
|---|---|---|---|---|---|
"""HTTP endpoints for the Teams API."""
import logging
from django.shortcuts import get_object_or_404, render_to_response
from django.http import Http404
from django.conf import settings
from rest_framework.generics import GenericAPIView
from rest_framework.response import Response
from rest_framework.reverse import ... | louyihua/edx-platform | lms/djangoapps/teams/views.py | Python | agpl-3.0 | 51,355 |
"""IIIF image and presentation logic."""
import logging
from itertools import chain
from typing import Dict, Iterable, List, Mapping, Optional, Tuple
from urllib.parse import urlencode
import shortuuid
from flask_sqlalchemy import Pagination
from iiif_prezi.factory import Manifest, ManifestFactory
from .mets import M... | jbaiter/demetsiiify | demetsiiify/iiif.py | Python | agpl-3.0 | 12,787 |
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright (C) 2020 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the h... | snapcore/snapcraft | tests/unit/plugins/v1/conftest.py | Python | gpl-3.0 | 2,053 |
# import argv lib from sys
from sys import argv
# there two argv, first is the program name, second is the filename
# which will be open
script, filename = argv
# use "open" funtion to open the file, and return to the parameter txt
txt = open(filename)
# print a string, tell the user what file be opened
print "Here'... | elvinsys/python | ex/ex15.py | Python | gpl-3.0 | 734 |
from .dispatch import dispatch
from .compatibility import basestring
from blaze.expr.literal import BoundSymbol, data as bz_data
@dispatch(object, (basestring, list, tuple))
def create_index(t, column_name_or_names, name=None):
"""Create an index on a column.
Parameters
----------
o : table-like
... | ContinuumIO/blaze | blaze/index.py | Python | bsd-3-clause | 1,644 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Filename: Os.py
# Description: Functions for OS
# Author: Simon L. J. Robin | https://sljrobin.org
# Created: 2016-08-28 23:09:04
# Modified: 2016-08-30 01:18:27
#
#######################################################################... | sljrobin/dotfiles | dzen2/.dzen2/scripts/Os.py | Python | gpl-2.0 | 1,179 |
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from astropy.io import registry
from .info import serialize_method_as
__all__ = ['TableRead', 'TableWrite']
__doctest_skip__ = ['TableRead', 'TableWrite']
class TableRead(registry.UnifiedReadWrite):
"""Read and parse a data table and return as a T... | aleksandr-bakanov/astropy | astropy/table/connect.py | Python | bsd-3-clause | 4,461 |
# -*- coding: utf-8 -*-
from sqlalchemy import Column, Integer, String
from settings import DATABASE_NAMES
class EntesMixin(object):
__table_args__ = {'schema': DATABASE_NAMES.get('entes')}
class ProfileMixin(object):
__table_args__ = {'schema': DATABASE_NAMES.get('perfis')}
class AdminMixin(object):
... | hackultura/siscult-migration | models/mixins.py | Python | gpl-2.0 | 593 |
#!/usr/bin/python
#import pdb
def first():
second()
return "hey i am first"
def second():
third()
return "hey i am second"
def third():
fourth()
return "hey i am third"
def fourth():
fifth()
return "hey i am fourth"
def fifth():
return "hey i am fifth"
# MAIN
#pdb.set_trace()
first()
| tuxfux-hlp-notes/python-batches | archieves/batch-61/debugging/third.py | Python | gpl-3.0 | 309 |
# -*- coding: utf-8 -*-
#
# Copyright (c) 2014-2015 Université Catholique de Louvain.
#
# This file is part of INGInious.
#
# INGInious 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 o... | GuillaumeDerval/INGInious | tests/__init__.py | Python | agpl-3.0 | 1,152 |
"""
Base class for any serializable list of things...
Copyright 2006-2009, Red Hat, Inc and Others
Michael DeHaan <michael.dehaan AT gmail>
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 ver... | jantman/cobbler | cobbler/collection.py | Python | gpl-2.0 | 18,924 |
from util import box2d
import ContactListener
from time import sleep
class World(box2d.b2World):
gContactListener = None
gCamera = None
gGameClient = None
gMainChar = None
gDestroyQue = []
gDestroyed = False
gActors = []
def __init__(self, gravity, doSleep):
self.gContactListen... | nemothekid/Colosseum--Year-3XXX | World.py | Python | mit | 2,975 |
# bedup - Btrfs deduplication
# Copyright (C) 2012 Gabriel de Perthuis <g2p.code+bedup@gmail.com>
#
# This file is part of bedup.
#
# bedup 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 t... | adonm/bedup | bedup/platform/openat.py | Python | gpl-2.0 | 1,628 |
# -*- coding: utf-8 -*-
import json
from django.shortcuts import get_object_or_404
from catmaid.models import Textlabel, TextlabelLocation
from .common import CatmaidApiTestCase
class TextlabelsApiTests(CatmaidApiTestCase):
def test_update_textlabel(self):
self.fake_authentication()
textlabel... | tomka/CATMAID | django/applications/catmaid/tests/apis/test_textlabels.py | Python | gpl-3.0 | 9,740 |
from sys import argv, stdin, stdout, exit
from . import ansiprint, parse
if len(argv) == 1 and stdin.isatty():
from textwrap import dedent
usage = '''
Usage: python -m ansimarkup [<arg> [<arg> ...]]
Example usage:
python -m ansimarkup '<b>Bold</b>' '<r>Red</r>'
python -m ansimarkup '<b><r... | gvalkov/python-ansimarkup | ansimarkup/__main__.py | Python | bsd-3-clause | 604 |
d = 1
e = 2
f = 3
| I-Valchev/UrPas | coverage-3.7.1/tests/modules/pkg1/sub/ps1a.py | Python | apache-2.0 | 18 |
#!/usr/bin/env python
import os
import sys
import django
from django.conf import settings
DEFAULT_SETTINGS = dict(
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sites",
"pinax.images",
"pinax.images.tests"
],
MIDDLEWARE_CLA... | arthur-wsw/pinax-images | makemigrations.py | Python | mit | 926 |
class event_system:
def __init__(self):
self.__listeners = {}
def on(self, event, func):
if event in self.__listeners:
self.__listeners[event].append(func)
else:
self.__listeners[event] = [func]
def trigger(self, event):
if event in self.__listeners:... | Stevearzh/irc-sha | isha/core/system.py | Python | mit | 590 |
import unittest
import numpy as np
from helper import plpy, fixture_file
import crankshaft.segmentation as segmentation
import json
class SegmentationTest(unittest.TestCase):
"""Testing class for Moran's I functions"""
def setUp(self):
plpy._reset()
def generate_random_data(self,n_samples,random_... | CartoDB/crankshaft | release/python/0.8.1/crankshaft/test/test_segmentation.py | Python | bsd-3-clause | 2,464 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_worksessions
"""
from datetime import datetime, timedelta
import unittest
from unittest.mock import patch
from vulyk.models.exc import (
TaskNotFoundError,
WorkSessionUpdateError)
from vulyk.models.stats import WorkSession
from vulyk.models.tasks import A... | mrgambal/vulyk | tests/test_worksessions.py | Python | bsd-3-clause | 11,133 |
"""
Copyright (C) 2018 Roberto Bruttomesso <roberto.bruttomesso@gmail.com>
This file is distributed under the terms of the 3-clause BSD License.
A copy of the license can be found in the root directory or at
https://opensource.org/licenses/BSD-3-Clause.
Author: Roberto Bruttomesso <roberto.bruttomesso@gmail.com>
Da... | formalmethods/intrepyd | intrepyd/iec611312py/stmtbuilder.py | Python | bsd-3-clause | 8,639 |
#!/usr/bin/env python
from distutils.core import setup
setup( name="slugifier",
version = "0.1",
description = "Add slugs to your mongoengine documents and use them in your flask views.",
author = "Manas Garg",
author_email = "manasgarg@gmail.com",
license = "BSD License",
url = "https://githu... | manasgarg/slugifier | setup.py | Python | bsd-3-clause | 407 |
import fitz
"""
This marks a longer, unique sentence on the page.
The parameters 'start', 'stop' and 'clip' are fully computed from the
returned hit rectangles.
"""
doc = fitz.open("search.pdf")
page = doc[0]
# Search for this text. It is show with hyphens on the page, which we can
# simply delete for our search. Lin... | JorjMcKie/PyMuPDF-Utilities | word&line-marking/mark-lines2.py | Python | gpl-3.0 | 1,051 |
# Calculate length of an arc using radius and degree angle measurement
import math
from stdutils import prettyFunction, inputAsDict
vals = inputAsDict(('d','r'))
# Convert degrees to radians
vals['ra'] = vals['d']/180
# Calculate arc length
vals['len'] = vals['ra']*vals['r']
# Calculations with pi
vals['rap'] = vals... | meta1203/Trigonometry-Programlets | arclength_degrees.py | Python | apache-2.0 | 592 |
from typing import Tuple
import numpy as np
import gdsfactory as gf
from gdsfactory import LAYER, Port
from gdsfactory.component import Component
@gf.cell
def big_device(
size: Tuple[float, float] = (400.0, 400.0),
nports: int = 16,
spacing: float = 15.0,
layer: Tuple[int, int] = LAYER.WG,
wg_wi... | gdsfactory/gdsfactory | gdsfactory/samples/big_device.py | Python | mit | 1,843 |
#!/usr/bin/env python
# vim: expandtab:tabstop=4:shiftwidth=4
"""
Interface to OpenShift oc command
"""
#
# Copyright 2015 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 ... | rhdedgar/openshift-tools | openshift_tools/monitoring/ocutil.py | Python | apache-2.0 | 4,378 |
'''
Copyright (C) 2016 Turi
All rights reserved.
This software may be modified and distributed under the terms
of the BSD license. See the LICENSE file for details.
'''
# python egg version
__VERSION__ = '1.9'#{{VERSION_STRING}}
version = '1.9'#{{VERSION_STRING}}
build_number = '0'#{{BUILD_NUMBER}}
| TobyRoseman/SFrame | oss_src/unity/python/sframe/version_info.py | Python | bsd-3-clause | 302 |
# Copyright iris-grib contributors
#
# This file is part of iris-grib and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
"""Unit tests for the `iris_grib.load_pairs_from_fields` function."""
import iris_grib.tests as tests
from iris_gri... | SciTools/iris-grib | iris_grib/tests/unit/test_load_pairs_from_fields.py | Python | lgpl-3.0 | 1,857 |
import logging
from ... import di
logger = logging.getLogger(__name__)
@di.desc('tracker', reg=False)
class MockTracker:
def event(self, *args, **kwargs):
logging.debug('event')
logging.debug(kwargs)
logging.debug(args)
def new_message(self, *args, **kwargs):
logging.debug('n... | hyzhak/bot-story | botstory/integrations/mocktracker/tracker.py | Python | mit | 653 |
"""Cutoff-based soft filtering of genomic variants.
"""
from distutils.version import LooseVersion
import math
import os
import shutil
import numpy
import toolz as tz
import yaml
from bcbio import broad, utils
from bcbio.distributed.transaction import file_transaction
from bcbio.pipeline import config_utils
from bcbi... | biocyberman/bcbio-nextgen | bcbio/variation/vfilter.py | Python | mit | 12,226 |
# -*- coding: utf-8 -*-
import sys
import autofixture
from django.core.management import call_command
from decimal import Decimal
from datetime import date, datetime
from autofixture import generators, constraints
from autofixture.base import AutoFixture, CreateInstanceError, Link
from autofixture.compat import get_fi... | ad-m/django-autofixture | autofixture_tests/tests/test_base.py | Python | bsd-3-clause | 28,812 |
from Framework.Controller import Controller
from Database.Controllers.Prereq import Prereq as BDPrereq
from Models.Prereq.RespostaListar import RespostaListar
class Prereq(Controller):
def Listar(self,pedido_listar):
return RespostaListar(BDPrereq().pegarPrereqs("WHERE id_disc_pre = %s AND ... | AEDA-Solutions/matweb | backend/Controllers/Prereq.py | Python | mit | 527 |
# -*- coding: utf-8 -*-
# Copyright (c) 2010 - 2014 Detlev Offenbach <detlev@die-offenbachs.de>
#
"""
Module implementing a widget to show numbers in different formats.
"""
from __future__ import unicode_literals
from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QAbstractTableModel, \
qVersion
from PyQt5.QtWid... | davy39/eric | UI/NumbersWidget.py | Python | gpl-3.0 | 14,344 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-08-17 17:23
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('rest_api', '0007_auto_20170817_1635'),
]
operations = [
migrations.RenameModel(
... | alexiwamoto/django-rest-api | rest_api/migrations/0008_auto_20170817_1723.py | Python | mit | 393 |
from __future__ import with_statement
try:
from io import BytesIO
except ImportError:
from StringIO import StringIO as BytesIO
from flask import render_template, request
from wtforms import StringField, FieldList
from flask_wtf import Form
from flask_wtf.file import FileField
from flask_wtf.file import file_... | Maxence1/flask-wtf | tests/test_uploads.py | Python | bsd-3-clause | 5,211 |
import simplejson
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseForbidden
from django.shortcuts import render_to_response
from django.template import RequestContext
from package.models import Package, Category
from importer.importers import import_from_github_acct
@lo... | benracine/opencomparison | apps/importer/views.py | Python | mit | 969 |
"""Initial migration
Revision ID: 73b22ccbe472
Revises: fc791d73e762
Create Date: 2017-04-24 09:08:30.923731
"""
# revision identifiers, used by Alembic.
revision = '73b22ccbe472'
down_revision = 'fc791d73e762'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
import residue
t... | magfest/ubersystem | alembic/versions/73b22ccbe472_initial_migration.py | Python | agpl-3.0 | 1,791 |
#
# pymobiledevice - Jython implementation of libimobiledevice
#
# Copyright (C) 2014 Taconut <https://github.com/Triforce1>
# Copyright (C) 2014 PythEch <https://github.com/PythEch>
# Copyright (C) 2013 GotoHack <https://github.com/GotoHack>
#
# pymobiledevice is free software: you can redistribute it and/or modify... | PythEch/pymobiledevice | asr.py | Python | lgpl-3.0 | 2,823 |
import contextlib
import os
import shlex
import sys
import threading
import traceback
import types
from mitmproxy import exceptions
from mitmproxy import ctx
from mitmproxy import events
import watchdog.events
from watchdog.observers import polling
def parse_command(command):
"""
Returns a (path, args)... | dwfreed/mitmproxy | mitmproxy/addons/script.py | Python | mit | 8,008 |
# -*- coding:utf-8 -*-
#--
# Copyright (c) 2012-2014 Net-ng.
# All rights reserved.
#
# This software is licensed under the BSD License, as described in
# the file LICENSE.txt, which you should have received as part of
# this distribution.
#--
import json
import os
import uuid
from PIL import Image
from PIL import Im... | Net-ng/kansha | kansha/services/simpleassetsmanager/simpleassetsmanager.py | Python | bsd-3-clause | 6,401 |
# RUN: %python -m artiq.compiler.testbench.embedding %s
from artiq.experiment import *
class MyClass:
def __init__(self, **kwargs):
for k, v in kwargs.items():
setattr(self, k, v)
sl = [MyClass(x=1), MyClass(x=2)]
@kernel
def bug(l):
for c in l:
print(c.x)
@kernel
def entrypoin... | JQIamo/artiq | artiq/test/lit/embedding/bug_477.py | Python | lgpl-3.0 | 337 |
# -*- coding: utf-8 -*-
#
# Copyright 2014-2015 BigML
#
# 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 ... | brokendata/bigmler | bigmler/parser.py | Python | apache-2.0 | 10,005 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.test import TestCase
from django.contrib.auth.models import User
from django.db.utils import IntegrityError
class BorrowerTestCase(TestCase):
'''
New 'phone number' field should be valid and optional
'''
def test_model_create... | Amandil/django-tech-test | loans/tests/tests_model_borrower.py | Python | bsd-3-clause | 1,588 |
# Copyright (c) 2011-2013 Mick Thomure
# All rights reserved.
#
# Please see the file LICENSE.txt in this distribution for usage terms.
import unittest
import cPickle as pickle
from .callback import *
class C(object):
def __init__(self, arg = None):
self.arg = arg
def __eq__(self, other):
return type(s... | mthomure/glimpse-project | glimpse/util/callback_test.py | Python | mit | 2,367 |
# -*- coding: utf-8 -*-
# -*- encoding: utf-8 -*-
#############################################################################
#
# Copyright (c) 2007 Martin Reisenhofer <martin.reisenhofer@funkring.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU G... | funkring/fdoo | addons-funkring/l10n_chart_at_2010/chart_wizard.py | Python | agpl-3.0 | 5,108 |
class Solution(object):
def deleteAndEarn(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
counter = collections.Counter(nums)
prev = None
using = avoid = 0
for n in sorted(counter):
if n - 1 == prev:
using, avoid = co... | Mlieou/leetcode_python | leetcode/python/ex_740.py | Python | mit | 516 |
from leapp.models import Model, fields
from leapp.topics import ApiTestTopic
class ApiTest(Model):
topic = ApiTestTopic
data = fields.String()
class ApiTestProduce(ApiTest):
pass
class ApiTestConsume(ApiTest):
pass
| leapp-to/prototype | tests/data/actor-api-tests/models/apitest.py | Python | lgpl-2.1 | 238 |
import math
from compsoc.events.models import *
from collections import defaultdict
from django.contrib.auth.models import User
class Point:
def __init__(self, x = 0, y = 0):
self.x = int(x)
self.y = int(y)
def __getitem__(self, key):
if( key == 0):
return self.x
... | esteluk/reinhardt | events/similarity.py | Python | agpl-3.0 | 2,330 |
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 5 08:02:30 2018
@author: Ray Justin O. Huang
"""
from Custom_Transformers import PerColumnAttributesAdder, StringCaseChanger, Randomizer, StringCleaner, GroupAggregator
import pandas as pd
import numpy as np
import string
# Sample DataFrames
sample1 = pd.DataFrame(... | rayjustinhuang/DataAnalysisandMachineLearning | RJ's Toolbox/Transformer_Tests.py | Python | mit | 3,229 |
# (C) British Crown Copyright 2014, Met Office
#
# This file is part of Iris.
#
# Iris is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation, either version 3 of the License, or
# (at your option) any later ve... | Jozhogg/iris | lib/iris/tests/unit/util/test_array_equal.py | Python | lgpl-3.0 | 4,647 |
#!/usr/bin/env python3
import sys
# There is a little bit of guesswork in this. The Imaging With QuickDraw book
# lists $02FF as the "Version" opcode, but it's really the data for the $0011
# payload. It also gives it a size of 2. This contradicts the decompiled picture
# in listing A-5 on p. A-23, which gives it no d... | depp/unrez | lib/pict_opcode.py | Python | mit | 6,299 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from runner.koan import *
class AboutNewStyleClasses(Koan):
class OldStyleClass:
"""An old style class"""
# Original class style have been phased out in Python 3.
class NewStyleClass(object):
"""A new style class"""
# Introduced i... | Isabek/python-koans | python2/koans/about_new_style_classes.py | Python | mit | 2,467 |
# -*- coding: utf-8 -*-
"""
ipcai2016
Copyright (c) German Cancer Research Center,
Computer Assisted Interventions.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE for details
"""
"""
Crea... | swirkert/ipcai2016 | scripts/ipcai2016/script_analyze_ipcai_in_vivo_liver.py | Python | bsd-3-clause | 11,382 |
# coding=utf-8
r"""
This code was generated by
\ / _ _ _| _ _
| (_)\/(_)(_|\/| |(/_ v1.0.0
/ /
"""
from tests import IntegrationTestCase
from tests.holodeck import Request
from twilio.base.exceptions import TwilioException
from twilio.http.response import Response
class ByocTrunkTestCase(Integra... | twilio/twilio-python | tests/integration/voice/v1/test_byoc_trunk.py | Python | mit | 8,787 |
#!/usr/bin/env python
# expand-terrain-macros.py - Expand "meta-macros" for terrain WML
#
# Copyright (C) 2008 - 2009 by Moritz Goebelbecker
# Part of the Battle for Wesnoth Project http://www.wesnoth.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Gene... | danteinforno/wesnoth | data/tools/expand-terrain-macros.py | Python | gpl-2.0 | 5,797 |
#
# This file is part of CasADi.
#
# CasADi -- A symbolic framework for dynamic optimization.
# Copyright (C) 2010-2014 Joel Andersson, Joris Gillis, Moritz Diehl,
# K.U. Leuven. All rights reserved.
# Copyright (C) 2011-2014 Greg Horn
#
# CasADi is free software; you can... | ghorn/debian-casadi | experimental/joris/expensive.py | Python | lgpl-3.0 | 22,968 |
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
import frappe
import frappe.utils
from frappe.utils import get_url_to_form
from frappe.model import log_types
from frappe import _
from itertools import groupby
@frappe.whitelist()
def update_follow(doctype, doc_name, fol... | frappe/frappe | frappe/desk/form/document_follow.py | Python | mit | 7,625 |
from django.views.generic import DetailView
from braces.views import SelectRelatedMixin
from django_filters.views import FilterView
from .models import JST
from .filters import JSTFilter
from foundation.offices.models import Office
from dal import autocomplete
class JSTListView(SelectRelatedMixin, FilterView):
fi... | ad-m/foundation-manager | foundation/teryt/views.py | Python | bsd-3-clause | 1,853 |
#
# Copyright (C) 2019 The ESPResSo project
#
# This file is part of ESPResSo.
#
# ESPResSo 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 vers... | espressomd/espresso | doc/tutorials/convert.py | Python | gpl-3.0 | 12,717 |
"""
==========
ISOMAP neighbours parameter CV pipeline
==========
Use a pipeline to find the best neighbourhood size parameter for ISOMAP.
Adapted from:
http://scikit-learn.org/stable/auto_examples/decomposition/plot_kernel_pca.html#example-decomposition-plot-kernel-pca-py
http://scikit-learn.org/stable/auto... | lzamparo/SdA_reduce | utils/isomap_neighbours_pipeline.py | Python | bsd-3-clause | 4,226 |
# hackerrank - Algorithms: Plus Minus
# Written by James Andreou, University of Waterloo
N = float(raw_input())
A = map(int, str.split(raw_input()))
print ("%.3f" % (len(filter(lambda x : x > 0, A)) / N))
print ("%.3f" % (len(filter(lambda x : x < 0, A)) / N))
print ("%.3f" % (len(filter(lambda x : x == 0, A)) / N)) | jamesandreou/hackerrank-solutions | warmup/hr_plus_minus.py | Python | mit | 317 |
import asyncio
import logging
import json
import aiohttp
import lxml.html
import lxml.etree
from .selector import Selector
logger = logging.getLogger("requester")
class RequestError(RuntimeError):
def __init__(self, url, *args, **kwargs):
self.url = url
super().__init__(*args, **kwargs)
class... | orf/cyborg | cyborg/requester.py | Python | apache-2.0 | 3,265 |
# Copyright (c) 2013 Rackspace, Inc.
# Copyright (c) 2013 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 b... | openstack/zaqar | zaqar/tests/functional/base.py | Python | apache-2.0 | 14,553 |
from __future__ import unicode_literals
from django.apps import AppConfig
class CawasConfig(AppConfig):
name = 'cawas'
| emilianobilli/backend | dam/cawas/apps.py | Python | gpl-3.0 | 126 |
# -*- coding: utf-8 -*-
# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
class NigeriapostcodesPipeline(object):
def process_item(self, item, spider):
return item
| NigerianPostcodes/spiderman | nigeriapostcodes/pipelines.py | Python | mit | 296 |
"""
A pytz version that runs smoothly on Google App Engine.
Based on http://appengine-cookbook.appspot.com/recipe/caching-pytz-helper/
To use, add pytz to your path normally, but import it from the gae module:
from pytz.gae import pytz
Applied patches:
- The zoneinfo dir is removed fr... | kurtisharms/ubcexamcram | pytz/gae.py | Python | gpl-3.0 | 3,068 |
import numpy as np
import pyflux as pf
noise = np.random.normal(0,1,200)
data = np.zeros(200)
for i in range(1,len(data)):
data[i] = 1.0*data[i-1] + noise[i]
countdata = np.random.poisson(3,200)
def test_t_couple_terms():
"""
Tests latent variable list length is correct, and that the estimated
laten... | RJT1990/pyflux | pyflux/gas/tests/gas_llev_tests_t.py | Python | bsd-3-clause | 8,879 |
from django.conf.urls import include, url
from waldur_core.core.routers import SortedDefaultRouter as DefaultRouter
from waldur_core.server.urls import urlpatterns
from . import views
def register_in(router):
router.register(r'test', views.TestServiceViewSet, base_name='test')
router.register(r'test-service... | opennode/nodeconductor | waldur_core/structure/tests/urls.py | Python | mit | 608 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('datasetmanager', '0003_auto_20151028_1559'),
]
operations = [
migrations.AlterField(
model_name='dataset',
... | mmilaprat/policycompass-services | apps/datasetmanager/migrations/0004_auto_20151111_1746.py | Python | agpl-3.0 | 418 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import os
import sys
from setuptools import setup
name = 'drfjsonapi'
package = 'drfjsonapi'
description = 'JSON API reference implementation for Django Rest Framework'
url = 'https://github.com/sassoo/drfjsonapi'
author = 'Sassoo'
author_email = 'noreply@devnul... | sassoo/drfjsonapi | setup.py | Python | isc | 2,755 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import datetime
from django.utils.timezone import utc
class Migration(migrations.Migration):
dependencies = [
('imager_images', '0010_auto_20150728_1429'),
]
operations = [
migration... | gatita/django-imager | imagersite/imager_images/migrations/0011_auto_20150728_1515.py | Python | mit | 1,354 |
import os
from sqlalchemy import create_engine, ForeignKey, func
from sqlalchemy import Column, Date, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, backref, sessionmaker
Base = declarative_base()
class Series( Base ):
__tablename__ = 'series'
... | simondodson/Curator | media_db.py | Python | gpl-3.0 | 935 |
# Copyright 2017 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... | DavidNorman/tensorflow | tensorflow/python/tpu/tpu.py | Python | apache-2.0 | 72,964 |
#!/usr/bin/env python
# Copyright 2012 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... | windyuuy/opera | chromium/src/third_party/webpagereplay/httpclient.py | Python | bsd-3-clause | 15,553 |
"""Helper methods for plotting (mostly 2-D georeferenced maps)."""
import numpy
from matplotlib import pyplot
import matplotlib.colors
from mpl_toolkits.basemap import Basemap
from gewittergefahr.gg_utils import nwp_model_utils
from gewittergefahr.gg_utils import number_rounding
from gewittergefahr.gg_utils import lon... | thunderhoser/GewitterGefahr | gewittergefahr/plotting/plotting_utils.py | Python | mit | 31,807 |
# -*- coding: iso-8859-1 -*-
"""
Plota curva de ZigZag
____________________
Variáveis de entrada:
save (True/False) -- Opção para salvar as figuras ou somente mostrar os gráficos, utilizar somente True até o momento;
formato ('png'/'pdf'/'ps'/'eps'/'svg') -- formatos de saída da figura;
passo (float) -- Paso de tempo ... | asoliveira/NumShip | scripts/curvazigzag.py | Python | gpl-3.0 | 10,194 |
"""GraphLasso: sparse inverse covariance estimation with an l1-penalized
estimator.
"""
# Author: Gael Varoquaux <gael.varoquaux@normalesup.org>
# License: BSD 3 clause
# Copyright: INRIA
import warnings
import operator
import sys
import time
import numpy as np
from scipy import linalg
from .empirical_covariance_ im... | pprett/scikit-learn | sklearn/covariance/graph_lasso_.py | Python | bsd-3-clause | 26,692 |
from bespin.errors import BespinError
from contextlib import contextmanager
import json
import sys
class NotSpecified(object):
"""Tell the difference between empty and None"""
class AssertionsAssertionsMixin:
def assertSortedEqual(self, one, two):
"""Assert that the sorted of the two equal"""
... | realestate-com-au/bespin | tests/helpers/mixins/assertions.py | Python | mit | 2,632 |
import sys
from PyQt4 import QtGui
def main ():
app = QtGui.QApplication(sys.argv)
window =QtGui.QWidget()
window.setGeometry(400,250,500,300)
window.setWindowTitle("pode psa ")
window.show()
sys.exit(app.exec_())
if __name__ >='__main__':
main() | ronas/PythonGNF | Bruno/PrimeiraJanela.py | Python | gpl-3.0 | 294 |
'''
Created by auto_sdk on 2015.06.23
'''
from aliyun.api.base import RestApi
class Ram20140214GetUserRequest(RestApi):
def __init__(self,domain='ram.aliyuncs.com',port=80):
RestApi.__init__(self,domain, port)
self.AccountSpace = None
self.UserName = None
def getapiname(self):
return 'ram.aliyuncs.com.GetUse... | francisar/rds_manager | aliyun/api/rest/Ram20140214GetUserRequest.py | Python | mit | 334 |
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function
import tensorflow as tf
from niftynet.layer.downsample import DownSampleLayer
from tests.niftynet_testcase import NiftyNetTestCase
class DownSampleTest(NiftyNetTestCase):
def get_3d_input(self):
input_shape = (2, 16, 16, 16, 8... | NifTK/NiftyNet | tests/downsample_test.py | Python | apache-2.0 | 3,371 |
# vim:fileencoding=utf-8
__all__ = [ 'log_str' ]
| desci/tg-cryptoforexbot | plugins/log/__init__.py | Python | gpl-3.0 | 50 |
#coding:utf-8
#################################
#Copyright(c) 2014 dtysky
#################################
import G2R,os
class SoundTag(G2R.TagSource):
def Get(self,Flag,US):
tags={'m':{},'k':{}}
for m in US.Args[Flag]:
tags['m'][m]='sound_'+os.path.splitext(US.Args[Flag][m])[0]
tags['k'][m]={'loop':'loop'... | dtysky/Gal2Renpy | Gal2Renpy/TagSource/SoundTag.py | Python | mit | 353 |
# This is the version of this source code.
manual_verstr = "1.5"
auto_build_num = "166"
verstr = manual_verstr + "." + auto_build_num
try:
from pyutil.version_class import Version as pyutil_Version
__version__ = pyutil_Version(verstr)
except (ImportError, ValueError):
# Maybe there is no pyutil insta... | zyegfryed/python-oauth2 | oauth2/_version.py | Python | mit | 438 |
# Nemubot is a smart and modulable IM bot.
# Copyright (C) 2012-2016 Mercier Pierre-Olivier
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at yo... | nbr23/nemubot | nemubot/server/abstract.py | Python | agpl-3.0 | 4,141 |
import os
import re
import json
import shutil
import tarfile
import tempfile
from climb.config import config
from climb.commands import Commands, command, completers
from climb.exceptions import CLIException
from climb.paths import format_path, split_path, ROOT_PATH
from grafcli.documents import Document, Dashboard, R... | m110/grafcli | grafcli/commands.py | Python | mit | 8,828 |
"""Config flow to configure Motion Blinds using their WLAN API."""
from socket import gaierror
from motionblinds import AsyncMotionMulticast, MotionDiscovery
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.components import network
from homeassistant.const import CONF_API_KEY, CON... | jawilson/home-assistant | homeassistant/components/motion_blinds/config_flow.py | Python | apache-2.0 | 6,224 |
# Copyright (c) 2012, GPy authors (see AUTHORS.txt).
# Licensed under the BSD 3-clause license (see LICENSE.txt)
from .posterior import Posterior
from ...util.linalg import mdot, jitchol, backsub_both_sides, tdot, dtrtrs, dtrtri, dpotri, dpotrs, symmetrify
from ...util import diag
from GPy.core.parameterization.variat... | befelix/GPy | GPy/inference/latent_function_inference/var_dtc.py | Python | bsd-3-clause | 11,145 |
class IdeCommandDelegate:
def override_command(self, path):
pass
def before_run(self, config, docker_config):
pass
| bhdouglass/clickable | clickable/commands/idedelegates/idedelegate.py | Python | gpl-3.0 | 142 |
# 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 ... | Hybrid-Cloud/badam | patches_tool/aws_patch/aws_deps/libcloud/compute/drivers/ktucloud.py | Python | apache-2.0 | 3,709 |
from __future__ import print_function
from __future__ import absolute_import
from __future__ import unicode_literals
import six
from .biology import BiologyType
from .cell import Cell
from .dataObject import DatatypeProperty, ObjectProperty
__all__ = ['Connection']
class SynapseType:
Chemical = 'send'
Gap... | gsarma/PyOpenWorm | PyOpenWorm/connection.py | Python | mit | 3,807 |
import os
from datetime import datetime
from time import sleep
from types import FunctionType
from copy import copy
from numpy import array
import dynamixel
from Motion import lInterp, scaleTime
'''
Much inspiration taken from http://code.google.com/p/pydynamixel/
'''
'''Min and max values for the ... | booi/aracna | RobotPi/RobotQuadratot.py | Python | gpl-3.0 | 18,657 |
''' Module containing tests for the network data structure
'''
import unittest
from power_grid import network
class TestNetwork(unittest.TestCase):
''' Class containing all unit tests related to
the network data structure.
'''
def test_randomly_generated_network(self):
''' Tests if the averag... | ABM-project/power-grid | test/test_network.py | Python | mit | 814 |
#!/usr/bin/env python
#
# Copyright (c) 2015 Intel Corporation.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of works must retain the original copyright notice, this
# list of conditions and t... | pk-sam/crosswalk-test-suite | wrt/wrt-security-android-tests/security/permissiontest.py | Python | bsd-3-clause | 3,330 |
"""
.. _ex-spm-faces:
==========================================
From raw data to dSPM on SPM Faces dataset
==========================================
Runs a full pipeline using MNE-Python:
- artifact removal
- averaging Epochs
- forward model computation
- source reconstruction using dSPM on the con... | adykstra/mne-python | examples/datasets/spm_faces_dataset.py | Python | bsd-3-clause | 4,719 |
"""
Copyright 2015 Malte Splietker
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
... | wette/netSLS | network_emulator/utils.py | Python | apache-2.0 | 971 |
# -*- coding: utf-8 -*-
#
# Troy documentation build configuration file, created by
# sphinx-quickstart on Sat Sep 15 21:44:01 2012.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All co... | andre-merzky/troy_old | docs/conf.py | Python | gpl-3.0 | 8,120 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (C) 2012 Yahoo! 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.or... | hagleitn/Openstack-Devstack2 | devstack/components/quantum_client.py | Python | apache-2.0 | 1,531 |
#!/usr/bin/python
# *****************************************************************************
#
# Copyright (c) 2016, EPAM SYSTEMS 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
#
#... | epam/DLab | infrastructure-provisioning/src/general/scripts/azure/jupyter_configure.py | Python | apache-2.0 | 15,835 |
from pyethapp.leveldb_service import LevelDB
from pyethapp.config import default_data_dir
from ethereum.chain import Chain
from ethereum.config import Env
from ethereum.transactions import Transaction
import rlp
from rlp.codec import consume_length_prefix
import os
import sys
def get_chain(data_dir=default_data_dir):... | RomanZacharia/pyethapp | examples/export.py | Python | mit | 2,083 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.