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 |
|---|---|---|---|---|---|
#!/usr/bin/python3
import string
from random import choice
import argparse
parser = argparse.ArgumentParser(description='Generates random strings')
parser.add_argument('length', metavar='length', type=int, help='The length of generated string')
parser.add_argument('-l', '--lowers', action='store_const', dest='lowers',... | Gnomino/randomstring | randomstring.py | Python | gpl-3.0 | 1,492 |
#!/bin/env python
# -*- coding: utf-8 -*-
"""
This file is part of the web2py Web Framework
Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>
License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
Thanks to ga2arch for help with IS_IN_DB and IS_NOT_IN_DB on GAE
"""
import os
import re
import datetime
impor... | whbrewer/spc | src/gluino/validators.py | Python | mit | 128,397 |
#!/usr/bin/env python
#
# Copyright (C) 2011 Nigel Bree
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
# list of co... | uvbs/steam-limiter | updateapp/main.py | Python | bsd-2-clause | 18,251 |
input = """
a | b :- not a.
"""
output = """
{b}
"""
| Yarrick13/hwasp | tests/asp/gringo/disjunction.005.test.py | Python | apache-2.0 | 54 |
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, softw... | redhat-cip/openstack-logcollector | openstack-logcollector/tests/test_openstack-logcollector.py | Python | apache-2.0 | 828 |
from django.http import HttpResponseServerError
from django.shortcuts import render_to_response
from datetime import datetime
from models import Maintenance
class MaintenanceMiddleware(object):
def process_request(self, request):
if request.path.startswith("/admin"):
return None
... | steingrd/django-maintenance | maintenance/middleware.py | Python | bsd-3-clause | 1,261 |
import re
import collections
from enum import Enum
from ydk._core._dm_meta_info import _MetaInfoClassMember, _MetaInfoClass, _MetaInfoEnum
from ydk.types import Empty, YList, YLeafList, DELETE, Decimal64, FixedBitsDict
from ydk._core._dm_meta_info import ATTRIBUTE, REFERENCE_CLASS, REFERENCE_LIST, REFERENCE_LEAFLI... | 111pontes/ydk-py | cisco-ios-xr/ydk/models/cisco_ios_xr/_meta/_Cisco_IOS_XR_infra_objmgr_oper.py | Python | apache-2.0 | 57,513 |
# -*- 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-automl | samples/generated_samples/automl_v1_generated_auto_ml_delete_dataset_sync.py | Python | apache-2.0 | 1,500 |
"""
A Pure Python ShapeFile Reader and Writer
This module is selfcontained and does not require pysal.
This module returns and expects dictionary based data strucutres.
This module should be wrapped into your native data strcutures.
Contact:
Charles Schmidt
GeoDa Center
Arizona State University
Tempe, AZ
http://geodac... | darribas/pysal | pysal/core/util/shapefile.py | Python | bsd-3-clause | 28,098 |
# -*- coding: utf-8 -*-
# Copyright (C) 2013- Yan Shoshitaishvili aka. zardus
# Ruoyu Wang aka. fish
# Audrey Dutcher aka. rhelmot
# Kevin Borgolte aka. cao
import logging
import os
import random
import socket
import subprocess
import sys
import tempfile
imp... | zardus/idalink | idalink/client.py | Python | bsd-2-clause | 9,851 |
# Python test set -- built-in functions
import test.support, unittest
import sys
import pickle
import itertools
# pure Python implementations (3 args only), for comparison
def pyrange(start, stop, step):
if (start - stop) // step < 0:
# replace stop with next element in the sequence of integers
# ... | invisiblek/python-for-android | python3-alpha/python3-src/Lib/test/test_range.py | Python | apache-2.0 | 17,941 |
from __future__ import print_function
__author__ = """Alex "O." Holcombe, Charles Ludowici, """ ## double-quotes will be silently removed, single quotes will be left, eg, O'Connor
import time, sys, platform, os
from math import atan, atan2, pi, cos, sin, sqrt, ceil, radians, degrees
import numpy as np
import psychopy, ... | alexholcombe/dot-jump | dataRaw/Fixed Cue/test_dot-jump21Nov2016_14-21.py | Python | gpl-3.0 | 26,446 |
# 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 usefu... | justinvforvendetta/electrum-rby | lib/asn1tinydecoder.py | Python | gpl-3.0 | 3,835 |
from necrobot.util import server
from necrobot.botbase.commandtype import CommandType
class Add(CommandType):
def __init__(self, race_room):
CommandType.__init__(self, race_room, 'add')
self.help_text = 'Give a user permission to see the room.'
self.admin_only = True
async def _do_exe... | incnone/necrobot | necrobot/race/privaterace/cmd_privaterace.py | Python | mit | 3,466 |
#
# Copyright (c) SAS Institute 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 w... | sassoftware/conary | conary/local/sqldb.py | Python | apache-2.0 | 94,996 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.test import TestCase
from django.core.urlresolvers import reverse
from django.contrib.auth import get_user_model
from tiny_rest.models import Token
User = get_user_model()
class TestTokenAdmin(TestCase):
def setUp(self):
self.... | allisson/django-tiny-rest | tiny_rest/tests/test_admin.py | Python | mit | 794 |
"""
Implement atoi() in Python (given a string, return a number).
Assume all the strings are always valid.
"""
import unittest
def atoi(string):
l = len(string)
t = 0
v = 10 ** (l - 1)
for ch in string:
t += v * int(ch)
v /= 10
return t
def atoi2(string):
l, t = len(string),... | kratorius/ads | python/interviewquestions/atoi.py | Python | mit | 1,456 |
# Copyright (c) 2014 Rackspace Hosting
# 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 req... | grahamhayes/designate | designate/objects/rrdata_ns.py | Python | apache-2.0 | 1,561 |
# Copyright 2021 The HuggingFace Team. 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 applicabl... | huggingface/transformers | tests/mt5/test_modeling_flax_mt5.py | Python | apache-2.0 | 2,539 |
class Resolve(object):
def __init__(self, cls, container=None):
self.cls = cls.__name__
self.container = container
def __call__(self):
return getattr(self.container, self.cls)()
| aventurella/pydi | pydi/utils.py | Python | isc | 212 |
# -*- coding: utf-8 -*-
class Charset(object):
common_name = 'NotoSansKhmerUI-Regular'
native_name = ''
def glyphs(self):
chars = []
chars.append(0x19F9) #glyph00287 KHMER SYMBOL PRAM-BUON ROC
chars.append(0x200B) #zwsp ZERO WIDTH SPACE
chars.append(0x200C) #uni200C ZER... | davelab6/pyfontaine | fontaine/charsets/noto_chars/notosanskhmerui_regular.py | Python | gpl-3.0 | 11,499 |
"""
===========================================
Compare the different ICA algorithms in MNE
===========================================
Different ICA algorithms are fit to raw MEG data, and the corresponding maps
are displayed.
"""
# Authors: Pierre Ablin <pierreablin@gmail.com>
#
# License: BSD (3-clause)
from time... | Teekuningas/mne-python | examples/preprocessing/plot_ica_comparison.py | Python | bsd-3-clause | 1,884 |
"""
Classe Tile permettant de creer un objet case pouvant contenir un personnage, un bloc et un objet
"""
from IA import *
class Tile :
# Constructeur
def __init__(self):
self._IA = list()
self._Bloc = Bloc.Eau
self._Objet = Objet.Rien
# Get List
def isIA(self):
if len(self._IA) == 0:
... | Vodak/SINS | src/Tile.py | Python | gpl-3.0 | 921 |
#!/usr/bin/env python
"""
conference.py -- Udacity conference server-side Python App Engine API;
uses Google Cloud Endpoints
$Id: conference.py,v 1.25 2014/05/24 23:42:19 wesc Exp wesc $
created by wesc on 2014 apr 21
"""
__author__ = 'wesc+api@google.com (Wesley Chun)'
from datetime import datetime
import t... | smandekar1/Conference-Central | conference.py | Python | apache-2.0 | 30,128 |
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Topic.category'
db.add_column(u'forum_topic', 'category',... | HackBulgaria/Odin | forum/south_migrations/0005_auto__add_field_topic_category.py | Python | agpl-3.0 | 7,566 |
from django.contrib.gis.db.models.fields import ExtentField
from django.db.models.aggregates import Aggregate
__all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union']
class GeoAggregate(Aggregate):
function = None
is_extent = False
def as_sql(self, compiler, connection):
# thi... | yephper/django | django/contrib/gis/db/models/aggregates.py | Python | bsd-3-clause | 2,463 |
from dateutil.relativedelta import relativedelta
from datetime import timedelta
from django import forms
from django.conf import settings
from django.forms.utils import ErrorList
from django.utils import timezone
from django.contrib.admin.widgets import AdminRadioSelect, AdminRadioFieldRenderer
from edc_consent.forms... | TshepangRas/tshilo-dikotla | td_maternal/forms/maternal_consent_form.py | Python | gpl-2.0 | 4,722 |
#!/usr/bin/env python
import Adafruit_BBIO.ADC as ADC
import time
import phant
# Configue the ADC
ADC.setup()
# Define program constants
TMP36_PIN = 'AIN0'
PHOTO_PIN = 'AIN1'
PHANT_PRIVATE_KEY = 'YOUR_PRIVATE_KEY'
PHANT_PUBLIC_KEY = 'YOUR_PUBLIC_KEY'
SAMPLE_RATE = 0.0033 # Hertz
def read_adc_v(adc_pin, adc_... | SpinStabilized/bbb-primer | chapter10/environment_monitor.py | Python | mit | 2,014 |
#!/usr/bin/python
import sys
import cv2
import numpy as np
import time
if len(sys.argv) < 2:
video_capture = cv2.VideoCapture(0)
else:
filepath = sys.argv[1]
video_capture = cv2.VideoCapture(filepath)
# Read two frames, last and current, and convert current to gray.
ret, last_frame = video_capture.read()... | shantnu/PyEng | Image_Video/motion_detect.py | Python | mit | 1,049 |
import pytest
@pytest.mark.django_db
class TestIndexView(object):
def test_index(self, client):
response = client.get('/')
assert response.template_name == ['recipi/core/index.html']
| recipi/recipi | src/recipi/tests/core/test_views.py | Python | isc | 206 |
import re
import numpy as NP
import scipy as SP
import scipy.io as SIO
import time
import os
import os.path
import sys
from fastlmm.association.FastLmmSet import FastLmmSet
from fastlmm.association.FastLmmSet import Local
import unittest
import subprocess
import fastlmm.inference.tests.test
import fastlmm.feature_selec... | MicrosoftGenomics/FaST-LMM | tests/test.py | Python | apache-2.0 | 7,488 |
##############################################################################
# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-64... | krafczyk/spack | var/spack/repos/builtin/packages/py-backports-shutil-get-terminal-size/package.py | Python | lgpl-2.1 | 1,933 |
"""Implementation of magic functions for interaction with the OS.
Note: this module is named 'osm' instead of 'os' to avoid a collision with the
builtin.
"""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import io
import os
import re
import sys
from pprint import... | sserrot/champion_relationships | venv/Lib/site-packages/IPython/core/magics/osm.py | Python | mit | 30,489 |
# -*- coding: utf-8 -*-
import logging
LOG = logging.getLogger(__name__)
import uuid
from django.views.generic import DetailView, ListView, FormView
from django.views.generic.detail import SingleObjectMixin
from django.http import HttpResponse, Http404
from django.contrib.gis.geos import Point
from django.db import t... | ismailsunni/healthsites | django_project/localities/views.py | Python | bsd-2-clause | 6,352 |
from __future__ import absolute_import
from io import BytesIO
from cached_property import cached_property as calculated_once
from future.utils import iteritems
from werkzeug.http import HTTP_STATUS_CODES as HTTP_STATUS_PHRASES
import attr
from minion.deferred import Deferred
from minion.http import Accept, Headers, M... | Julian/Minion | minion/request.py | Python | mit | 3,488 |
import sqlite3
from keySearch import *
print "Beggining test on keySearch..."
conn = sqlite3.connect('test2.db')
c = conn.cursor()
for row in c.execute('SELECT source_code FROM appvulnerability WHERE vulnerability_id=10'):
result = keySearch(row[0])
if result[0]:
print "Passed Key test:\t" + inQuotes(row[... | ksparakis/apekit | vulns/keySearch.test.py | Python | apache-2.0 | 539 |
import pytest
from .models import TestModel, TestM2MModel, TestModelWithCustomPK, TestM2MModelWithCustomPKOnM2M, \
TestModelWithoutM2MCheck, TestM2MModelWithoutM2MModeEnabled
@pytest.mark.django_db
def test_dirty_fields_on_m2m():
tm = TestM2MModel.objects.create()
tm2 = TestModel.objects.create()
tm.... | jdotjdot/django-dirtyfields | tests/test_m2m_fields.py | Python | bsd-3-clause | 2,033 |
##############################################################################
# Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-64... | TheTimmy/spack | var/spack/repos/builtin/packages/xmore/package.py | Python | lgpl-2.1 | 1,698 |
import os
from OpenGL.GL import *
from texture import load_texture
SIZE_OF_FLOAT = 4
class Object:
def __init__(self, path):
self.mtl = {}
self.group = {}
self.load_obj(path)
self.texture_ids = []
self.vertex_buffer_ids = []
self.uv_buffer_ids = []
self.norma... | cellzero/cream | python/object.py | Python | mit | 7,867 |
# proxy module
from traitsui.editors.boolean_editor import *
| enthought/etsproxy | enthought/traits/ui/editors/boolean_editor.py | Python | bsd-3-clause | 61 |
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | CSCI1200Course/csci1200OnlineCourse | tests/integration/load_test.py | Python | apache-2.0 | 17,946 |
"""Support for Actiontec MI424WR (Verizon FIOS) routers."""
from collections import namedtuple
import logging
import re
import telnetlib
import voluptuous as vol
from homeassistant.components.device_tracker import (
DOMAIN,
PLATFORM_SCHEMA,
DeviceScanner,
)
from homeassistant.const import CONF_HOST, CONF_... | leppa/home-assistant | homeassistant/components/actiontec/device_tracker.py | Python | apache-2.0 | 4,157 |
# 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
# distribu... | vbuell/python-javaobj | javaobj.py | Python | apache-2.0 | 31,597 |
# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'UnitPermission'
db.create_table('profiles_unitpermission', (
('object_id',... | ParsonsAMT/Myne | datamining/apps/profiles/migrations/0032_auto__add_unitpermission.py | Python | agpl-3.0 | 37,612 |
# -*- coding: latin-1 -*-
"""
Hydrogen Models
---------------
Hydrogen in HII regions is typically assumed to follow Case B recombination
theory.
The values for the Case B recombination coefficients are given by `Hummer &
Storey (1987)
<http://adsabs.harvard.edu/cgi-bin/nph-bib_query?bibcode=1987MNRAS.224..801H&db_ke... | keflavich/pyspeckit-obsolete | pyspeckit/spectrum/models/hydrogen.py | Python | mit | 10,722 |
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import numpy as np
from emukit.test_functions.quadrature import hennig1D
def test_hennig1D_return_shape():
"""
Test output dimension is 2d
"""
hennig1d_func, _ = hennig1D()
x = np.zer... | EmuKit/emukit | tests/emukit/test_functions/test_hennig1d.py | Python | apache-2.0 | 425 |
import functools
import warnings
import bokeh
from bokeh.application import Application
from bokeh.application.handlers.function import FunctionHandler
from bokeh.server.server import BokehTornado
from bokeh.server.util import create_hosts_allowlist
from packaging.version import parse as parse_version
import dask
if... | dask/distributed | distributed/dashboard/core.py | Python | bsd-3-clause | 1,306 |
from django.conf.urls import url, include
from . import views
urlpatterns = [
url(r'^register$', views.register_page, name='register'),
url(r'^', include('django.contrib.auth.urls')),
]
| BurningNetel/ctf-manager | accounts/urls.py | Python | gpl-3.0 | 196 |
# -*- coding: utf-8 -*-
"""
sphinx.application
~~~~~~~~~~~~~~~~~~
Sphinx application object.
Gracefully adapted from the TextPress system by Armin.
:copyright: 2008 by Georg Brandl, Armin Ronacher.
:license: BSD.
"""
import sys
import posixpath
from cStringIO import StringIO
from docutils ... | creasyw/IMTAphy | documentation/toolchain/Sphinx-0.5dev_20081110-py2.5.egg/sphinx/application.py | Python | gpl-2.0 | 11,339 |
#!/usr/bin/env python
import json
from boto3.session import Session
def auto_scaling_group_name():
with open('terraform.tfstate') as f:
tfstate = json.load(f)
return tfstate['modules'][0]['resources']['aws_autoscaling_group.server']['primary']['id']
def get_machine_ip():
session = Session(regi... | directactioneverywhere/server | deploy/get_machine_ip.py | Python | gpl-3.0 | 843 |
# Copyright 2010,2011,2012 Michael Frank <msfrank@syntaxjockey.com>
#
# This file is part of Terane.
#
# Terane 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 op... | msfrank/terane | terane/bier/ql/__init__.py | Python | gpl-3.0 | 2,731 |
from thefuck.utils import sudo_support
# add 'python' suffix to the command if
# 1) The script does not have execute permission or
# 2) is interpreted as shell script
@sudo_support
def match(command, settings):
toks = command.script.split()
return (len(toks) > 0
and toks[0].endswith('.py')
... | JianfengYao/thefuck | thefuck/rules/python_command.py | Python | mit | 524 |
#------------------------------------------------------------------------
# Terms
#------------------------------------------------------------------------
class ATerm(object):
def __init__(self, term, annotation=None):
self.term = term
self.annotation = annotation
def __str__(self):
... | seibert/blaze-core | blaze/aterm/terms.py | Python | bsd-2-clause | 3,957 |
import rdflib.plugins.sparql.parser
import pprint
def test_parser_structure() -> None:
def t(q):
print(q)
pprint.pprint(rdflib.plugins.sparql.parser.parseQuery(q))
t("SELECT * WHERE { ?s ?p ?o, ?o2 ; ?p2 ?o3 . ?s2 ?p ?o .} ")
t("SELECT * WHERE { ?s ?p ?o, ?o2 ; ?p2 ?o3 ; ?p3 [ ?p ?o ] . ... | RDFLib/rdflib | test/test_parser_structure.py | Python | bsd-3-clause | 336 |
#!/usr/bin/env python
import os
import sys
## A name of directory containing 'path:...' file
## You can download them using 'make-wget_pathway.sh' script
dir_name = sys.argv[1]
f_summary = open('%s.summary'%dir_name,'w')
f_genes = open('%s.genes'%dir_name,'w')
f_compounds = open('%s.compounds'%dir_name,'w')
gene_to... | taejoonlab/taejoonlab-toolbox | KEGG/make-pathway2list.py | Python | gpl-3.0 | 2,013 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = '''
---
module: dpkg_selections
short_description... | srvg/ansible | lib/ansible/modules/dpkg_selections.py | Python | gpl-3.0 | 2,298 |
#
# 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... | nathanielvarona/airflow | airflow/contrib/operators/sns_publish_operator.py | Python | apache-2.0 | 1,166 |
'''
Airline / Hotel Reservation System
Create a reservation system which books airline seats or hotel rooms. It charges various rates for particular sections of the plane or hotel. Example, first class is going to cost more than coach. Hotel rooms have penthouse suites which cost more. Keep track of when rooms will be ... | pragalakis/100-python-projects | classes/airline-hotel-reservation-system.py | Python | mit | 2,529 |
# (c) 2012-2014, Michael DeHaan <michael.dehaan@gmail.com>
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import re
import pty
import time
import js... | pdellaert/ansible | lib/ansible/executor/task_executor.py | Python | gpl-3.0 | 53,302 |
import os
from setuptools import setup
LONG_DESCRIPTION = """
A modular framework for mobile surveys and field data collection via offline-capable mobile web apps.
"""
def readme():
try:
readme = open('README.md')
except IOError:
return LONG_DESCRIPTION
else:
return readme.read()
... | wq/wq | setup.py | Python | mit | 2,538 |
## @package batch_mse_loss
# Module caffe2.python.layers.batch_mse_loss
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from caffe2.python import core, schema
from caffe2.python.layers.layers import (
ModelLayer,
)... | ryfeus/lambda-packs | pytorch/source/caffe2/python/layers/batch_mse_loss.py | Python | mit | 2,539 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Alias',
fields=[
('id', models.AutoField(primar... | Unholster/django-lookup | lookup/migrations/0001_initial.py | Python | mit | 833 |
"""
Python Interchangeable Virtual Instrument Library
Copyright (c) 2017 Alex Forencich
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 righ... | alexforencich/python-ivi | ivi/rigol/rigolMSO4052.py | Python | mit | 1,694 |
from __future__ import print_function
import os, string, tempfile, shutil
from subprocess import Popen
from ase.io import write
from ase.units import Bohr
class Bader:
'''class for running bader analysis and extracting data from it.
The class runs bader, extracts the charge density and outputs it
to a cu... | suttond/MODOI | ase/calculators/jacapo/utils/bader.py | Python | lgpl-3.0 | 6,745 |
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test running trollcoind with the -rpcbind and -rpcallowip options."""
from test_framework.test_framewo... | gautes/TrollCoinCore | test/functional/rpcbind_test.py | Python | mit | 4,407 |
import todsynth
import _projection
import healpy
import numpy
def project( phi, theta, psi, data, resolution,
det_mask=None, map_mask = None, data_mask=None ):
"""
"""
npix = healpy.nside2npix( resolution )
# cast map mask as int32 values
if map_mask is None:
map_mask = num... | pafluxa/todsynth | pythonsrc/projection/core.py | Python | gpl-3.0 | 2,050 |
### 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,... | beagles/sosreport-neutron | sos/plugins/postfix.py | Python | gpl-2.0 | 1,677 |
"""
Test output of docker start command
docker start full_name
1. Create new container with run long term process.
2. Try to start again running container.
3. Check if start command finished with 0
"""
from start import short_term_app
from dockertest.output import OutputGood
class rerun_long_term_app(short_term_ap... | afomm/autotest-docker | subtests/docker_cli/start/rerun_long_term_app.py | Python | gpl-2.0 | 678 |
'''
From Kirk Byers
https://github.com/ktbyers/pynet/blob/master/email/email_helper.py
Usage:
recipient = 'someone@domain.com'
subject = 'Test message'
message = 'This is a test message'
sender = 'someone@gmail.com'
# send the message
send_mail(recipient, subject, message, sende... | mudzi42/pynet_class | class3/email_helper.py | Python | apache-2.0 | 932 |
import math
import os
from analyzer.hit import Hit
from analyzer.hit import Hits
from model.index import Index
from model.page import Page
from model.page import Pages
from indexer.lexer import TokenLexer
from utils.string import StringUtil
class CosinusAnalyzer:
def __init__(self, index, pages):
if not... | pascalweiss/SearchEngine | analyzer/cosinus.py | Python | cc0-1.0 | 4,054 |
#
# vmnetx.controller.remote - Remote execution of a VM
#
# Copyright (C) 2008-2015 Carnegie Mellon University
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation. A copy of the GNU G... | cmusatyalab/vmnetx | vmnetx/controller/remote.py | Python | gpl-2.0 | 12,065 |
from comics.aggregator.crawler import CrawlerBase, CrawlerImage
from comics.core.comic_data import ComicDataBase
class ComicData(ComicDataBase):
name = "Teh Gladiators"
language = "en"
url = "http://www.tehgladiators.com/"
start_date = "2008-03-18"
rights = "Uros Jojic & Borislav Grabovic"
class... | jodal/comics | comics/comics/tehgladiators.py | Python | agpl-3.0 | 765 |
from datetime import datetime
from debugged.stream.signals import update_stream_item, delete_stream_item
def update_featured_stream_item(sender, instance, **kwargs):
if instance.featured:
update_stream_item(sender, instance)
else:
delete_stream_item(sender, instance)
def set_publish_date(sende... | bhrutledge/debugged-django | debugged/core/signals.py | Python | mit | 1,089 |
from unittest import TestCase
import os.path
import pandas as pd
import pandas.util.testing as tm
import numpy as np
from six import with_metaclass
import pandas_composition as composition
UserSeries = composition.UserSeries
UserFrame = composition.UserFrame
def curpath():
pth, _ = os.path.split(os.path.abspath... | dalejung/pandas-composition | pandas_composition/test/test_composition.py | Python | mit | 4,958 |
from builtins import next
import json
import responses
from bugwarrior.services.gerrit import GerritService
from .base import ServiceTest, AbstractServiceTest
class TestGerritIssue(AbstractServiceTest, ServiceTest):
SERVICE_CONFIG = {
'gerrit.base_uri': 'https://one',
'gerrit.username': 'two',
... | lyarwood/bugwarrior | tests/test_gerrit.py | Python | gpl-3.0 | 2,350 |
# ---- Flask Hello world ---- #
# import the Flask class from the flask module
from flask import Flask
# create the application object
app = Flask(__name__)
app.config["DEBUG"] = True
# use decorators to link the function to a url
@app.route('/')
@app.route('/hello')
def hello_world():
return "Hello world"
... | alekscl/tripping-dangerzone | flask-hello-world/app.py | Python | unlicense | 517 |
from PySide.QtCore import *
from PySide.QtGui import *
from .TagCloudScene import TagCloudScene
class TagCloudView(QGraphicsView):
tagClicked=Signal(str,int)
def __init__(self,parent):
QGraphicsView.__init__(self,parent)
self.scene=TagCloudScene()
self.setScene(self.scene)
self.hscale=1.0
self.vscale=1.0... | xzoert/dedalus | dedalus/ui/TagCloudView.py | Python | mit | 1,293 |
from thumbor.config import Config
Config.define(
'PNGCRUSH_PATH',
'/usr/local/bin/pngcrush',
'Path for the pngcrush binary',
'Optimizers'
)
Config.define(
'OPTIPNG_PATH',
'/usr/bin/optipng',
'Path for the optipng binary',
'Optimizers'
)
Config.define(
'OPTIPNG_LEVEL',
5,
'... | zanui/thumbor-plugins | thumbor_plugins/optimizers/__init__.py | Python | mit | 378 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-12-20 13:05
from __future__ import unicode_literals
from django.db import migrations
def move_audit_report_field_to_separate_model(apps, schema_editor):
PartnerAuditAssessment = apps.get_model('partner', 'PartnerAuditAssessment')
PartnerAuditReport... | unicef/un-partner-portal | backend/unpp_api/apps/partner/migrations/0042_auto_20171220_1305.py | Python | apache-2.0 | 939 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack LLC.
# 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/... | rajarammallya/melange | melange/ipv4/db_based_ip_generator/__init__.py | Python | apache-2.0 | 1,249 |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import sys
import pip
check_call(['pip3','install','-r','requirements.txt'])
| sealcode/gpandoc | winInstall.py | Python | lgpl-3.0 | 133 |
import urllib, re, string, os, time
from eventLookupClient import eventLookupClient
# client for countGuids Athenaeum service
# author: Marcin.Nowak@cern.ch
class countGuidsClient(eventLookupClient):
#serverURL = "http://j2eeps.cern.ch/test-Athenaeum/"
#serverURL = "http://j2eeps.cern.ch/atlas-project-Athena... | RRCKI/panda-server | pandaserver/dataservice/countGuidsClient.py | Python | apache-2.0 | 2,836 |
class Solution(object):
def rotate(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: void Do not return anything, modify nums in-place instead.
"""
k=k%len(nums)
nums[:]=nums[-k:]+nums[:-k] | Hehwang/Leetcode-Python | code/189 Rotate Array.py | Python | mit | 262 |
# Copyright (C) 2017, Yu Sheng Lin, johnjohnlys@media.ee.ntu.edu.tw
# This file is part of Nicotb.
# Nicotb 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 opti... | johnjohnlin/nicotb | sim/3_protocol_verify2/tb.py | Python | gpl-3.0 | 1,751 |
import re
import xbmc
from math import pi, sin
from lib.providers import base
from lib.providers.base import AbstractImageProvider, build_key_error, cache, ProviderError
from lib.libs import mediatypes
from lib.libs.addonsettings import settings
from lib.libs.pykodi import json, UTF8JSONDecoder
from lib.libs.utils imp... | rmrector/script.artwork.beef | lib/providers/thetvdbv2.py | Python | mit | 6,771 |
x = 1
class C:
x = 2
def m(y):
return x
o = C()
class C:
def m(self):
return self.x
n = C.m
def __init__(self):
self.x = 3
print C.n(o)
| cantora/pyc | p3tests/my_tests/class_reassign.py | Python | gpl-3.0 | 162 |
class WorkflowRegistry(object):
def __init__(self):
self.workflows = {}
self.class_index = {}
def add(self, name, cls):
self.workflows[id(cls)] = self.workflows.get(id(cls), set())
self.workflows[id(cls)].add(name)
self.class_index[id(cls)] = cls
def get_class_field... | javrasya/django-river | river/core/workflowregistry.py | Python | bsd-3-clause | 418 |
#VERSION: 2.0
#AUTHORS: Douman (custparasite@gmx.se)
#CONTRIBUTORS: Diego de las Heras (ngosang@hotmail.es)
from novaprinter import prettyPrinter
from helpers import retrieve_url, download_file
from re import compile as re_compile
from html.parser import HTMLParser
class torlock(object):
url = "https://www.torloc... | HaraldNordgren/qBittorrent | src/searchengine/nova3/engines/torlock.py | Python | gpl-2.0 | 4,052 |
from __future__ import division
from itertools import chain
import numpy as np
import pandas as pd
import math
from percept.tasks.base import Task
from percept.fields.base import Complex, List, Dict, Float
from inputs.inputs import MusicFormats
from percept.utils.models import RegistryCategories, get_namespace
from per... | VikParuchuri/evolve-music | tasks/tasks.py | Python | agpl-3.0 | 34,358 |
"""
Support for IP Cameras.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/camera.generic/
"""
import logging
import requests
from requests.auth import HTTPBasicAuth
from homeassistant.components.camera import DOMAIN, Camera
from homeassistant.helpers ... | Julian/home-assistant | homeassistant/components/camera/generic.py | Python | mit | 2,122 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('visualizationsmanager', '0006_auto_20151023_1230'),
]
operations = [
migrations.AddField(
model_name='visualizat... | mmilaprat/policycompass-services | apps/visualizationsmanager/migrations/0007_visualization_location.py | Python | agpl-3.0 | 469 |
from django.urls import reverse
def test_view_search(db, client):
client.login(username='admin', password='admin')
url = reverse('admin:views_view_changelist') + '?q=test'
response = client.get(url)
assert response.status_code == 200
| rdmorganiser/rdmo | rdmo/views/tests/test_admin.py | Python | apache-2.0 | 253 |
from . import freesurfer
| christianbrodbeck/nipype | nipype/workflows/smri/__init__.py | Python | bsd-3-clause | 25 |
import csv
import glob
import os
import numpy as np
from collections import defaultdict
import candidates as ca
import image_read_write
from pandas import DataFrame as df
import pandas as pd
import candidates
import make_candidatelist_with_unet_candidates as mcwuc
import pipeline_candidates as pica
import evaluate_cand... | syagev/kaggle_dsb | luna16/src/candidate_merging.py | Python | apache-2.0 | 9,496 |
# Copyright 2015 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... | kamcpp/tensorflow | tensorflow/contrib/rnn/python/kernel_tests/rnn_cell_test.py | Python | apache-2.0 | 34,623 |
from sympy import I
from sympy.physics.paulialgebra import Pauli
def test_Pauli():
sigma1=Pauli(1)
sigma2=Pauli(2)
sigma3=Pauli(3)
assert sigma1 == sigma1
assert sigma1 != sigma2
assert sigma1*sigma2 == I*sigma3
assert sigma3*sigma1 == I*sigma2
assert sigma2*sigma3 == I*sigma1
as... | GbalsaC/bitnamiP | venv/lib/python2.7/site-packages/sympy/physics/tests/test_paulialgebra.py | Python | agpl-3.0 | 670 |
"""
.. autofunction:: revscoring.features.trim
"""
from itertools import chain
from .feature import Constant, Feature, Modifier
def trim(features, context=None):
"""
Trims a feature set down to a bare set of :class:`~revscoring.Feature` by
removing :class:`~revscoring.features.Modifier` and
:class:`~... | wiki-ai/revscoring | revscoring/features/functions.py | Python | mit | 1,497 |
"""
Unit tests for courseware context_processor
"""
from pytz import timezone
from unittest.mock import Mock, patch # lint-amnesty, pylint: disable=wrong-import-order
from django.contrib.auth.models import AnonymousUser
from lms.djangoapps.courseware.context_processor import (
get_user_timezone_or_last_seen_time... | edx/edx-platform | lms/djangoapps/courseware/tests/test_context_processor.py | Python | agpl-3.0 | 3,141 |
import os
import textwrap
import pytest
import tpi
from dvc.main import main
from dvc.ui import ui
from tests.utils import console_width
from .conftest import BASIC_CONFIG
@pytest.mark.parametrize(
"slot,value",
[
("region", "us-west"),
("image", "iterative-cml"),
("spot", "True"),
... | dmpetrov/dataversioncontrol | tests/func/machine/test_machine_config.py | Python | apache-2.0 | 5,373 |
# 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-resource/azure/mgmt/resource/resources/v2016_02_01/operations/deployment_operations.py | Python | mit | 8,255 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.