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 |
|---|---|---|---|---|---|
# Create your views here.
from models import *
from django.contrib.auth.decorators import login_required, permission_required
from django.template import RequestContext, Template, Context
import json
from django.views.decorators.csrf import csrf_exempt, csrf_protect
from django.http import HttpResponse, Http404
from dj... | macjustice/sal | server/views.py | Python | apache-2.0 | 47,897 |
import pytest
from hypothesis import assume, given
from hypothesis.strategies import integers, lists
from algorithms.structures.linkedlist import LinkedList
@given(lists(integers()))
def test_from_list(lst):
assume(len(lst) > 0)
head = LinkedList.from_pylist(lst)
assert list(head) == lst
def test_appen... | vadimadr/python-algorithms | tests/test_linkedlist.py | Python | mit | 2,900 |
# -*- coding: utf-8 -*-
#
# This file is part of INSPIRE.
# Copyright (C) 2016 CERN.
#
# INSPIRE 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... | Panos512/inspire-next | inspirehep/modules/search/query.py | Python | gpl-2.0 | 2,216 |
_base_ = '../retinanet/retinanet_x101_32x4d_fpn_1x_coco.py'
model = dict(
bbox_head=dict(
type='PISARetinaHead',
loss_bbox=dict(type='SmoothL1Loss', beta=0.11, loss_weight=1.0)),
train_cfg=dict(isr=dict(k=2., bias=0.), carl=dict(k=1., bias=0.2)))
| open-mmlab/mmdetection | configs/pisa/pisa_retinanet_x101_32x4d_fpn_1x_coco.py | Python | apache-2.0 | 272 |
def set_environmentals(obj, ed):
def func(stag, attr, device, key, default=0):
lt = ed.get(attr, [])
if lt:
v = next((t['value'] for t in lt if t['device'] == device and
t['name'] == key), default)
setattr(obj, stag, v)
func('lab_temperature', 'lab_... | UManPychron/pychron | pychron/experiment/utilities/environmentals.py | Python | apache-2.0 | 771 |
# -*- coding: utf-8 -*-
# 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.
"""Common file and os related utilities, including tempdir manipulation."""
from __future__ import print_function
import col... | endlessm/chromium-browser | third_party/chromite/lib/osutils.py | Python | bsd-3-clause | 45,242 |
from genshi.builder import tag
from trac.core import implements,Component
from trac.ticket.api import ITicketActionController
from trac.perm import IPermissionRequestor
revision = "$Rev: 6326 $"
url = "$URL: https://svn.edgewall.org/repos/trac/trunk/sample-plugins/workflow/DeleteTicket.py $"
class DeleteTicketAction... | trac-ja/trac-ja | sample-plugins/workflow/DeleteTicket.py | Python | bsd-3-clause | 1,633 |
"""
vtkImageImportFromArray: a NumPy front-end to vtkImageImport
Load a Numeric Python array into a VTK image.
To use this class, you must have the LLNL Numeric Python distribution
(http://numpy.sf.net)
Methods:
GetOutput() -- connect to VTK image pipeline
SetArray() -- set the array to load in
Convert python ... | jeffbaumes/jeffbaumes-vtk | Wrapping/Python/vtk/util/vtkImageImportFromArray.py | Python | bsd-3-clause | 4,414 |
from django.conf.urls import patterns, include, url
from django.contrib import admin
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'website.views.home', name='home'),
# url(r'^website/', include(... | fqc/django_test | website/website/urls.py | Python | mit | 787 |
#!/usr/bin/env python
import os
from setuptools import setup
setup(
name="zict",
version="2.1.0.dev3",
description="Mutable mapping tools",
url="http://zict.readthedocs.io/en/latest/",
maintainer="Matthew Rocklin",
maintainer_email="mrocklin@gmail.com",
license="BSD",
keywords="mutabl... | dask/zict | setup.py | Python | bsd-3-clause | 829 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# GTKGpxdata.py
#
# Copyright 2010-2015 Jose Riguera Lopez <jriguera@gmail.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
#... | jriguera/photoplace | photoplace/addons/GPXData/GTKGpxdata.py | Python | apache-2.0 | 30,401 |
from plex import Plex
for item in Plex['library'].recently_added():
print '[%s] %s' % (item.type, item.title)
| fuzeman/plex.py | examples/recently_added.py | Python | mit | 116 |
#!/usr/bin/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 required b... | coxmediagroup/googleads-python-lib | examples/adwords/authentication/create_adwords_client_without_yaml.py | Python | apache-2.0 | 2,090 |
'''
Test cases for pyclbr.py
Nick Mathewson
'''
from test.test_support import run_unittest, import_module
import sys
from types import ClassType, FunctionType, MethodType, BuiltinFunctionType
import pyclbr
from unittest import TestCase
StaticMethodType = type(staticmethod(lambda: None))
ClassMethodType = type(cl... | teeple/pns_server | work/install/Python-2.7.4/Lib/test/test_pyclbr.py | Python | gpl-2.0 | 7,898 |
# Authors: Rob Crittenden <rcritten@redhat.com>
#
# Copyright (C) 2007 Red Hat
# see file 'COPYING' for use and warranty information
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either ver... | tbabej/freeipa | ipapython/ipavalidate.py | Python | gpl-3.0 | 3,633 |
# encoding: utf-8
from __future__ import print_function
from yade import pack,export,plot
import math,os,sys
print('checkColliderConstantness for InsertionSortCollider')
#### This is useful for printing the linenumber in the script
# import inspect
# print inspect.currentframe().f_lineno
if((opts.threads != None and... | cosurgi/trunk | scripts/checks-and-tests/checks/checkColliderConstantness.py | Python | gpl-2.0 | 4,071 |
import base
import unittest
class Test( base.BaseScriptTest, unittest.TestCase ):
command_line = "./scripts/line_select.py ${features}"
input_features = base.TestFile( """0
1
1
0
... | uhjish/bx-python | script_tests/line_select_tests.py | Python | mit | 674 |
from setuptools import setup, find_packages
setup(
name='pulp_ostree_common',
version='1.0.0a1',
packages=find_packages(),
url='http://www.pulpproject.org',
license='GPLv2+',
author='Pulp Team',
author_email='pulp-list@redhat.com',
description='common code for pulp\'s ostree support',
)... | dkliban/pulp_ostree | common/setup.py | Python | gpl-2.0 | 321 |
from jsg import Document, CompoundDocument
from jsg.fields import StringField
from utils import check_schema, schema
def test_compound_doc(schema):
@schema.add()
class A(Document):
a = StringField()
@schema.add()
class B(Document):
b = StringField()
@schema.add()
class C(C... | pbutler/jsg | tests/test_compound_doc.py | Python | mit | 2,614 |
import numpy as np
from ctypes import c_int, c_double, c_double, c_bool, c_float, c_char_p, c_void_p
import ctypes
import os
LIB_PATH = os.path.dirname( os.path.realpath(__file__) )
def recompile(path):
print( path )
dir_bak = os.getcwd()
os.chdir( path)
os.system("make clean" )
os.system("... | ProkopHapala/SimpleSimulationEngine | python/pyFlight/c_interface.py | Python | mit | 4,121 |
# 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 ... | AutorestCI/azure-sdk-for-python | azure-mgmt-network/azure/mgmt/network/v2017_11_01/models/topology_parameters.py | Python | mit | 1,697 |
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'ohmanizer.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
)
| bryndivey/ohmanizer | ohmanizer/urls.py | Python | apache-2.0 | 278 |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Hagay Onn
# Date: 15 April 2017
# Contact: hagayo@gmail.com
# Summary: Stack class that supports pushing/popping objects as well as getting last/max object in O(1)
from stack import Stack
__author__ = 'Hagay Onn'
__version__ = '1.0'
class Max... | hagayo/MaxStack_o1_Python | max_stack.py | Python | mit | 2,529 |
#! /usr/bin/python
from __future__ import division
from pytronica import *
c = Chain()
c.add(Sine(5000).take(1), 1)
c.add(Sine(6000).take(1), 1)
c.add(Sine(7000).take(1), 1)
c.add(Sine(8000).take(1), 1)
c.add(Sine(9000).take(1), 1)
c.add(Sine(10000).take(1), 1)
c.add(Sine(11000).take(1), 1)
c.add(Sine(12000).take(1)... | chriswatrous/pytronica | songs/experiments/high_freq.py | Python | gpl-2.0 | 596 |
"""
Sensor for Crime Reports.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.crimereports/
"""
from collections import defaultdict
from datetime import timedelta
import logging
import voluptuous as vol
from homeassistant.components.sensor import... | MungoRae/home-assistant | homeassistant/components/sensor/crimereports.py | Python | apache-2.0 | 4,382 |
from .headers import (
headers, FakeChromeUA)
from .conf import (
get_db_args, get_redis_args, get_timeout, get_crawl_interal, get_excp_interal,
get_max_repost_page, get_max_search_page, get_max_home_page, get_max_comment_page,
get_max_retries, get_broker_and_backend, get_redis_master, get_code_usernam... | ResolveWang/WeiboSpider | config/__init__.py | Python | mit | 537 |
# coding: UTF-8
# Name: 表达式元素
# Author: LYC
# Created: 2014-04-03
import re
from gpcalccfg import OPRegex
class ElementType(object):
"""
表达式元素类型
"""
def __init__(self, name, regex):
super(ElementType, self).__init__()
self.name = name
self.regex = regex
def __call__(self,... | MrLYC/GPCalc | GPCalc/expelement.py | Python | gpl-2.0 | 1,370 |
# -*- coding: utf-8 -*-
from abc import ABCMeta,abstractmethod
CONTAINER_STATE_ACTIVE = 1
CONTAINER_STATE_INACTIVE = 2
CONTAINER_STATE_MIGRATING = 3
CONTAINER_STATE_PREPARE = 4
class Container(object):
hostId = None
pid = None
id = None
mac = None
netnsId = None
image = None
dataDirectory =... | onlysheep5200/NetnsEx | lib/container.py | Python | apache-2.0 | 582 |
import collections
from supriya import CalculationRate, SignalRange
from supriya.ugens.UGen import UGen
class MouseY(UGen):
"""
A mouse cursor tracker.
MouseY tracks the y-axis of the mouse cursor position.
::
>>> supriya.ugens.MouseY.kr()
MouseY.kr()
"""
### CLASS VARIAB... | Pulgama/supriya | supriya/ugens/MouseY.py | Python | mit | 614 |
# -*- coding: utf-8 -*-
'''
:codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)`
tests.unit.utils.format_call_test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Test `salt.utils.format_call`
'''
# Import python libs
from __future__ import absolute_import
# Import Salt Testing libs
from salttesting import T... | stephane-martin/salt-debian-packaging | salt-2016.3.3/tests/unit/utils/format_call_test.py | Python | apache-2.0 | 1,713 |
__author__ = "Harish Narayanan"
__copyright__ = "Copyright (C) 2009 Simula Research Laboratory and %s" % __author__
__license__ = "GNU GPL Version 3 or any later version"
from cbc.twist import *
from sys import argv
""" DEMO - Twisting of a hyperelastic cube """
class Twist(StaticHyperelasticity):
""" Definition... | hnarayanan/twist | demo/static/twist.py | Python | gpl-3.0 | 2,606 |
import sys, os, socket, atexit, re
import pkg_resources
from pkg_resources import ResolutionError, ExtractionError
from setuptools.compat import urllib2
try:
import ssl
except ImportError:
ssl = None
__all__ = [
'VerifyingHTTPSHandler', 'find_ca_bundle', 'is_available', 'cert_paths',
'opener_for'
]
c... | c0710204/mirrorsBistu | pypi/bandersnatch/lib/python2.7/site-packages/setuptools/ssl_support.py | Python | mit | 7,288 |
#
# Copyright 2014 Mingyuan Xia (http://mxia.me) and others
#
# 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... | mcgill-cpslab/MonkeyHelper | src/Agents.py | Python | apache-2.0 | 14,204 |
# -*- coding: utf-8 -*-
# Generated by Django 1.9.9 on 2016-10-27 12:29
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('smartshark', '0029_auto_20161027_1427'),
]
operations = [
migrations.AlterFi... | smartshark/serverSHARK | smartshark/migrations/0030_auto_20161027_1429.py | Python | apache-2.0 | 480 |
"""Resolwe model database functions."""
from django.db.models.aggregates import Func
from .utils import json_path_components
class JsonGetPath(Func): # pylint: disable=abstract-method
"""PostgreSQL JSON path (#>) operator."""
function = '#>'
template = "%(expressions)s%(function)s%%s"
arity = 1
... | jberci/resolwe | resolwe/flow/models/functions.py | Python | apache-2.0 | 1,173 |
# Copyright 2012 OpenStack Foundation
# 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 requ... | ebagdasa/tempest | tempest/services/compute/json/flavors_client.py | Python | apache-2.0 | 7,252 |
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from __future__ import unicode_literals
import redis, frappe, cPickle as pickle
class RedisWrapper(redis.Redis):
"""Redis client that will automatically prefix conf.db_name"""
def make_key(self, key, user=None):
... | gangadharkadam/v5_frappe | frappe/utils/redis_wrapper.py | Python | mit | 1,928 |
# Copyright (C) 2007-2010 Samuel Abels.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANT... | mpenning/exscript | src/Exscript/interpreter/Expression.py | Python | gpl-2.0 | 2,830 |
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the author be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistri... | abpai/mailin-test | python/dkim/canonicalization.py | Python | mit | 4,252 |
#!/usr/bin/env python
"""
Install.py tool to download, compile, and setup the kim-api library
used to automate the steps described in the README file in this dir
"""
from __future__ import print_function
import sys, os, subprocess, shutil
from argparse import ArgumentParser
sys.path.append('..')
from install_helpers... | jeremiahyan/lammps | lib/kim/Install.py | Python | gpl-2.0 | 7,038 |
# ----------------------------------------------------------------------
# Numenta Platform for Intelligent Computing (NuPIC)
# Copyright (C) 2013, Numenta, Inc. Unless you have purchased from
# Numenta, Inc. a separate commercial license for this software code, the
# following terms and conditions apply:
#
# This pro... | tkaitchuck/nupic | py/nupic/encoders/nonuniformscalar.py | Python | gpl-3.0 | 15,766 |
# This file is part of PyEMMA.
#
# Copyright (c) 2017 Computational Molecular Biology Group, Freie Universitaet Berlin (GER)
#
# PyEMMA 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 o... | marscher/PyEMMA | pyemma/datasets/double_well_thermo.py | Python | lgpl-3.0 | 5,386 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by... | GoogleCloudPlatform/tensorflow-sketch-rnn-example | sketch_demo/backend.py | Python | apache-2.0 | 5,176 |
#!/usr/bin/env python
#
# This file is part of MAD.
#
# MAD is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# MAD is distributed in ... | fchauvel/MAD | mad/simulation/backoff.py | Python | gpl-3.0 | 1,390 |
# Time: O(n * S)
# Space: O(S)
# You are given a list of non-negative integers, a1, a2, ..., an,
# and a target, S. Now you have 2 symbols + and -.
# For each integer, you should choose one from + and - as its new symbol.
#
# Find out how many ways to assign symbols to make sum of integers equal to target S.
#
# Exam... | tudennis/LeetCode---kamyu104-11-24-2015 | Python/target-sum.py | Python | mit | 1,368 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compli... | fajoy/nova | smoketests/base.py | Python | apache-2.0 | 7,286 |
#!/usr/bin/env python
import os
from migrate.versioning.shell import main
import settings
db_url = settings.DATABASE_URL
app_path = os.path.relpath(os.path.dirname(os.path.abspath(__file__)),
os.getcwd())
repository = os.path.join(app_path, 'migrations')
if __name__ == '__main__':
ma... | nooodle/noodlefeed | noodlefeed/migration.py | Python | bsd-3-clause | 372 |
import contextlib
import logging
import os
import pathlib
import sys
import tempfile
import pytest
from _pytest.logging import LogCaptureFixture
import rasa.cli.utils
@contextlib.contextmanager
def make_actions_subdir():
"""Create a subdir called actions to test model argument handling."""
with tempfile.Temp... | RasaHQ/rasa_nlu | tests/cli/test_utils.py | Python | apache-2.0 | 2,701 |
from ..error import DataConsistencyError
from ..objects.order_line import OrderLine
from .base import ResourceBase
class OrderLines(ResourceBase):
order_id = None
def get_resource_name(self):
return f"orders/{self.order_id}/lines"
def get_resource_object(self, result):
return OrderLine(r... | mollie/mollie-api-python | mollie/api/resources/order_lines.py | Python | bsd-2-clause | 1,701 |
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from edenscmnative.clindex import * # noqa: F401, F403
from edenscmnative.clindex import __doc__ # noqa: F401
| facebookexperimental/eden | eden/hg-server/edenscm/hgext/clindex.py | Python | gpl-2.0 | 280 |
# This file helps to compute a version number in source trees obtained from
# git-archive tarball (such as those provided by githubs download-from-tag
# feature). Distribution tarballs (built by setup.py sdist) and build
# directories (produced by setup.py build) will contain a much shorter file
# that just contains t... | knights-lab/NINJA-SHOGUN | shogun/_version.py | Python | mit | 18,449 |
"""Test result object"""
import io
import sys
import traceback
from . import util
from functools import wraps
__unittest = True
def failfast(method):
@wraps(method)
def inner(self, *args, **kw):
if getattr(self, 'failfast', False):
self.stop()
return method(self, ... | utluiz/utluiz.github.io | pyscript/Lib/unittest/result.py | Python | mit | 6,473 |
import itertools
import time
import climin
import climin.initialize
import climin.stops
from trainers.tangMlp import TangMlp, squared_hinge
__author__ = 'kosklain'
class NeuralTrainer(object):
def __init__(self, X, VX, Z, VZ):
self.X = X
self.VX = VX
self.Z = Z
self.VZ = VZ
... | kosklain/StackoverflowQuestions | trainers/neuralTrainer.py | Python | gpl-2.0 | 2,772 |
# Copyright (C) 2009-2015 Contributors as noted in the AUTHORS file
#
# This file is part of Autopilot.
#
# Autopilot is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at y... | rogerlindberg/autopilot | src/lib/app/testengine.py | Python | gpl-3.0 | 2,292 |
# Copyright 2014 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.
import HTMLParser
import logging
import os
import re
import tempfile
import xml.etree.ElementTree
from devil.android import apk_helper
from pylib import con... | geminy/aidear | oss/qt/qt-everywhere-opensource-src-5.9.0/qtwebengine/src/3rdparty/chromium/build/android/pylib/gtest/gtest_test_instance.py | Python | gpl-3.0 | 14,910 |
l = {'T': 10, 'J':11, 'Q':12, 'K':13, 'A':14}
def card_ranks(cards):
"Return a list of the ranks, sorted with higher first."
ranks = [r for r,s in cards]
ranks = [l[r] if r in l else int(r) for r in ranks]
ranks.sort(reverse=True)
return ranks
print(card_ranks(['AC', '3D', '4S', 'KH']))#should o... | drobotnik/Py2 | Udacity/Random.py | Python | gpl-2.0 | 340 |
# This file is part of the Waymarked Trails Map Project
# Copyright (C) 2015 Sarah Hoffmann
#
# This 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 any later version.
#
#... | hholzgra/waymarked-trails-site | maps/mtb.py | Python | gpl-3.0 | 1,738 |
# -*- coding: utf-8 -*-
# Copyright (c) 2012 Jiri "NoxArt" Petruzelka
#
# 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,... | NoxArt/SublimeText2-FTPSync | FTPSync.py | Python | mit | 100,641 |
# 2015.03.10 14:42:13 UTC
import sys
import os
path = os.path.split(os.path.realpath(__file__))[0]
sys.path.append(path + '/utils/Python_Utils')
sys.path.append(path + '../utils/Python_Utils')
sys.path.append(path + '/utils/liac-arff')
sys.path.append(path + '../utils/liac-arff')
import numpy as np
import scipy as sc
i... | rustle1314/latent_factor_multi_label | arffio.py | Python | mit | 4,722 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2008 - 2012 Hewlett-Packard Development Company, L.P.
#
# 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... | rich-pixley/zoo-animals | za-pre/Speculator.py | Python | apache-2.0 | 1,799 |
"""Display a "Pastebin" menu that allows you to pastebin files easily.
If a part of the file is selected when you click something in the "Pastebin"
menu, then only the selected part of the file is shared.
"""
# TODO: make this work with pythonprompt plugin?
from __future__ import annotations
import logging
import soc... | Akuli/editor | porcupine/plugins/pastebin.py | Python | mit | 9,598 |
#!/usr/bin/env python
# PyCal - Python web calendar
#
# Copyright (C) 2004-6 Ray Osborn
#
# This program 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 2 of the License, or
# (at your o... | rayosborn/pycal | scripts/ModifyEvent.py | Python | lgpl-3.0 | 10,619 |
"""Evaluation for classification"""
import datetime
import time
def confusion_matrix(model, words, labels, classorder):
"""Build confusion matrix for model"""
result = {}
for cla in classorder:
result[cla] = {}
for inner in classorder:
result[cla][inner] = 0
# This gets th... | nOkuda/classtm | classtm/evaluate.py | Python | gpl-3.0 | 996 |
#!/usr/bin/env python
#
# Copyright (c) Pivotal Inc 2014. All Rights Reserved.
#
import os
import re
import shutil
import unittest
from collections import defaultdict
from gppylib.gpversion import GpVersion
from gppylib.commands.base import Command, CommandResult, ExecutionError
from mock import patch, MagicMock, Mock... | Quikling/gpdb | gpMgmt/bin/gppylib/operations/test/unit/test_unit_persistent_rebuild.py | Python | apache-2.0 | 87,698 |
"""
Course: Statistical Methods in Artificial Intelligence (CSE471)
Semester: Fall '17
Professor: Gandhi, Vineet
Assignment 2: SVM example using scikit-learn
Code to separate 2D and 3D linearly-separable data with SVMs using
the scikit-learn library. Examples for different kernels with
various parameter combinations a... | dracarys983/SVM | visualization_examples/linearly_inseparable.py | Python | mit | 7,952 |
# バイト配列型を利用すると、ミュータブルなデータ型(同一オブジェクトはメモリ上で変更が許容される)
# データはバイナリデータである。
ba1 = bytearray()
ba1.append(115)
print(ba1)
| ekazyam/study | パーフェクトPython/pp_078_bytearray.py | Python | mit | 237 |
#!/usr/bin/env python
class Solution:
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
sum1, sum2, lb = 0, 0, min(nums)
mask1 = int('55555555', base=16)
mask2 = int('AAAAAAAA', base=16)
for num in nums:
sum1 += ((nu... | eroicaleo/LearningPython | interview/leet/137_Single_Number_II.py | Python | mit | 1,076 |
#!/usr/bin/env python
from __future__ import division, print_function
import argparse
try:
from io import StringIO
except ImportError:
from StringIO import StringIO
import json
import os
import os.path
import re
import sys
import requests
DATA_TABLE_NAME = "primer_scheme_bedfiles"
def write_artic_style_be... | jj-umn/tools-iuc | data_managers/data_manager_primer_scheme_bedfiles/data_manager/install_primer_scheme_bedfiles.py | Python | mit | 5,949 |
from random import randrange
from myhdl import Signal
from myhdl import intbv
from myhdl import traceSignals
from myhdl import Simulation
from myhdl import bin, instances
from myhdl import delay, instance, always, always_seq, always_comb
from myhdl import StopSimulation
from alu import ALU, t_ALU_FUNCTION
PERIOD = ... | seletz/myhdl-test | test_alu.py | Python | mit | 3,465 |
"""
-------------------------------------------------------------------------
AIOpening - modules/__init__.py
Neural Net Modules constructed with deepmind/sonnet
created: 2017/08/31 in PyCharm
(c) 2017 Sven - ducandu GmbH
-------------------------------------------------------------------------
"""
from .fully... | ducandu/aiopening | aiopening/modules/__init__.py | Python | mit | 519 |
# -*- coding: utf-8 -*-
"""
:copyright: (c) 2015-2016 by Mike Taylor
:license: MIT, see LICENSE for more details.
"""
import os
import sys
import click
_cfg_name = 'doukan.cfg'
_cfg_path = click.get_app_dir('doukan')
_cfg_default = """{ 'active': False }"""
class Options(object):
def __init__(self):
sel... | bear/doukan | doukan/main.py | Python | mit | 2,316 |
###########################################################################
#
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/l... | google/starthinker | starthinker_ui/account/urls.py | Python | apache-2.0 | 996 |
import requests,xbmcaddon,time,re
import resolveurl as urlresolver
from ..common import clean_title, clean_search,send_log,error_log
from ..scraper import Scraper
dev_log = xbmcaddon.Addon('script.module.universalscrapers').getSetting("dev_log")
User_Agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Apple... | repotvsupertuga/tvsupertuga.repository | script.module.streamtvsupertuga/lib/resources/lib/sources/it/moviewatcher.py | Python | gpl-2.0 | 4,205 |
# Copyright (C) 2005, 2006, 2008-2011 Canonical Ltd
#
# 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 i... | stewartsmith/bzr | bzrlib/tests/test_setup.py | Python | gpl-2.0 | 3,440 |
#!/usr/bin/env python
#-*-coding:utf-8-*-
import os
import sys
import subprocess
subdir_list = os.listdir(".")
for subdir in subdir_list:
subdir = os.path.join(".", subdir)
print(subdir)
# continue
subprocess.Popen("cd %s; rm *_adm1.*; rm *_adm2.*; rm *_adm3.*; rm *_adm4.*; rm read_me.pdf;" % subdir,... | howl-anderson/SDMdata | sdmdata/gadm/remove_useless_file.py | Python | agpl-3.0 | 333 |
"""
TrainExtensions for doing random spatial windowing and flipping of an
image dataset on every epoch.
"""
import warnings
import numpy
from . import TrainExtension
from pylearn2.datasets.preprocessing import CentralWindow
from pylearn2.utils.rng import make_np_rng
try:
from ..utils._window_flip import random_win... | skearnes/pylearn2 | pylearn2/train_extensions/window_flip.py | Python | bsd-3-clause | 7,944 |
# -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh
#
# This file is part of weboob.
#
# weboob is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your opt... | Boussadia/weboob | modules/popolemploi/browser.py | Python | agpl-3.0 | 3,057 |
# Copyright 2020 The StackStorm Authors.
# Copyright 2019 Extreme Networks, 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 ... | nzlosh/st2 | contrib/runners/orquesta_runner/tests/unit/test_context.py | Python | apache-2.0 | 19,115 |
# 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 ... | v-iam/azure-sdk-for-python | azure-mgmt-redis/azure/mgmt/redis/models/sku.py | Python | mit | 1,722 |
from scrapy.spiders import Spider
from projects.proxies.proxy.items import ProxyItem
from helper.spiderUtil import getFirstofCss,getAllofCss
class XiciProxySpider(Spider):
name = "xicidaili"
allowed_domains = ["xicidaili.com"]
start_urls = [
"http://www.xicidaili.com/nn",
"http://www.xici... | shengcanxu/CCrawler | source/projects/proxies/proxy/spiders/xicidailiproxy.py | Python | apache-2.0 | 1,077 |
import collections
from .types import (
is_primitive_type,
)
def normalize_object_for_json(obj):
if is_primitive_type(obj):
return obj
elif isinstance(obj, (collections.Sequence, collections.Set)):
return [
normalize_object_for_json(value)
for value
in ... | pipermerriam/populus | populus/utils/json.py | Python | mit | 634 |
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | googleapis/python-dataplex | samples/generated_samples/dataplex_v1_generated_dataplex_service_list_lake_actions_sync.py | Python | apache-2.0 | 1,510 |
"""
Tests for cohorts
"""
# pylint: disable=no-member
import ddt
from django.contrib.auth.models import AnonymousUser, User
from django.db import IntegrityError
from django.http import Http404
from django.test import TestCase
from mock import call, patch
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx... | cpennington/edx-platform | openedx/core/djangoapps/course_groups/tests/test_cohorts.py | Python | agpl-3.0 | 33,726 |
# coding=utf-8
r"""
This code was generated by
\ / _ _ _| _ _
| (_)\/(_)(_|\/| |(/_ v1.0.0
/ /
"""
from twilio.base import serialize
from twilio.base import values
from twilio.base.instance_context import InstanceContext
from twilio.base.instance_resource import InstanceResource
from twilio.base.l... | twilio/twilio-python | twilio/rest/autopilot/v1/assistant/style_sheet.py | Python | mit | 9,152 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('mapeo', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='organizaciones',
name='sl... | CARocha/plataforma_fadcanic | mapeo/migrations/0002_auto_20151117_1648.py | Python | mit | 800 |
from flask import Flask, redirect
from flask.ext.basicauth import BasicAuth
from creds import username, password
from flask_admin import Admin
from flask_admin.contrib.fileadmin import FileAdmin
import os.path as op
# Flask setup here
app = Flask(__name__)
admin = Admin(app, name='Filio', template_mode='bootstrap3')
... | rudimk/filio | app.py | Python | mit | 753 |
#!/usr/bin/python
# boto3 python client to download files from S3 and check md5
# AWS_ACCESS_KEY_ID .. The access key for your AWS account.
# AWS_SECRET_ACCESS_KEY .. The secret key for your AWS account.
# folker@anl.gov
import sys, getopt, boto3, hashlib, io
import argparse
def md5sum(src, length=io.DEFAULT_BUFFER... | MG-RAST/Shock | shock-server/plug-ins/boto-s3-download.py | Python | bsd-2-clause | 2,570 |
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Sarielsaz Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test behavior of headers messages to announce blocks.
Setup:
- Two nodes, two p2p connections to n... | sarielsaz/sarielsaz | test/functional/sendheaders.py | Python | mit | 24,054 |
# Copyright (C) 2012-2014 CEA/DEN, EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library ... | FedoraScientific/salome-med | src/MEDOP/tut/projection/demovtu/projection.py | Python | lgpl-2.1 | 1,782 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Repeat our danger."""
import task_03
KLAXON = task_03.KLAXON
KLAXON = task_03.KLAXON *5
| MJVarghese/is210-week-03-warmup | task_04.py | Python | mpl-2.0 | 141 |
#!/usr/bin/env python
import sys
import urllib
import subprocess
import os
import yaml
import markdown
import lxml.html
import re
import html2text
package_location = "../../IT-systems"
menu_file = "../../_data/menu.yml"
menu_base = "/IT-systems/"
menu_base_name = "IT-systems"
placeholder_start = '<div style="display:... | zotya/zotya.github.io | tools/update_docs/update_package.py | Python | gpl-3.0 | 6,370 |
import uuid
import floto.decider
from floto.decider import Base
class Daemon(Base):
def __init__(self, *, domain, task_list=None, swf=None):
super().__init__(swf=swf)
self.task_list = task_list or 'floto_daemon'
self.domain = domain
def get_decisions(self):
signals = self.his... | babbel/floto | floto/decider/daemon.py | Python | mit | 2,624 |
from .Gender import Gender
from .Profile import Profile
from .Measurement import Measurement
from .MeasurementSource import MeasurementSource
from .MeasurementType import MeasurementType
from .MeasurementUnit import MeasurementUnit
| coco19/salud-api | app/mod_profiles/models/__init__.py | Python | gpl-2.0 | 232 |
"""One can load objects from different locations.
This module provides functionality to load objects from different locations
while preserving a simple interface to the consumer.
"""
import json
import os
import sys
def identity(object_):
""":return: the argument
:param object_: the object to be returned"""
... | AllYarnsAreBeautiful/knittingpattern | knittingpattern/Loader.py | Python | lgpl-3.0 | 7,981 |
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import hashlib
from datetime import datetime
from urllib import urlencode
from odoo import api, fields, models
class Users(models.Model):
_inherit = 'res.users'
def __init__(self, pool, cr):
init_res... | chienlieu2017/it_management | odoo/addons/website_forum/models/res_users.py | Python | gpl-3.0 | 4,824 |
"""Creating a one-to-many relationship for notifications
Revision ID: 4dc5ddd111b8
Revises: 4c8915e461b3
Create Date: 2015-07-24 15:02:04.398262
"""
# revision identifiers, used by Alembic.
revision = '4dc5ddd111b8'
down_revision = '4c8915e461b3'
from alembic import op
import sqlalchemy as sa
def upgrade():
#... | stinkydan/lemur | lemur/migrations/versions/4dc5ddd111b8_.py | Python | apache-2.0 | 960 |
score1 = 0
score2 = 0
tiecount = 0
player_1 = raw_input("Player 1, what's your name?")
player_2 = raw_input("Player 2?")
import random
def shuffled_deck():
deck = range(2,53)
random.shuffle(deck)
return deck
deck = shuffled_deck()
def player_turn(player_name):
card = deck.pop()
print player_name... | bensk/CS9 | _site/Code Examples/April12WarWork.py | Python | mit | 765 |
# Metric Space from Wordnet
# Main output function: Guess Universe and provide distance
from nltk.corpus import wordnet
def find_synonyms_antonyms(word):
synonyms = []
antonyms = []
for syn in wordnet.synsets(word):
for l in syn.lemmas():
synonyms.append(l.name())
if l.ant... | zhongzho/starter-python-bot | bot/distance_WordNet.py | Python | mit | 1,944 |
# Copyright 2008, Red Hat, Inc
# Luke Macken <lmacken@redhat.com>
#
# This software may be freely redistributed under the terms of the GNU
# general public license.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675... | dockerera/func | func/minion/modules/sysctl.py | Python | gpl-2.0 | 2,855 |
import itertools
from sympy.core.sympify import _sympify
from sympy.core.compatibility import default_sort_key
from sympy import Expr, Add, Mul, S, Integral, Eq, Sum, Symbol, Dummy, Basic
from sympy.core.evaluate import global_evaluate
from sympy.stats import variance, covariance
from sympy.stats.rv import RandomSym... | wxgeo/geophar | wxgeometrie/sympy/stats/symbolic_probability.py | Python | gpl-2.0 | 12,946 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.