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 |
|---|---|---|---|---|---|
from flask import flash, redirect, render_template, url_for, request
from sqlalchemy.exc import IntegrityError
from app import app, db
from app.forms import AddGuestForm
from app.models import Guest
from app.util import flash_form_errors
@app.route('/guests/create', methods=['GET', 'POST'])
def add_guest():
add_... | Manuel7AP/dobc_web_app | app/views/add_guest.py | Python | apache-2.0 | 676 |
# 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/policy/v2015_10_01_preview/models/policy_assignment_paged.py | Python | mit | 988 |
# class generated by DeVIDE::createDeVIDEModuleFromVTKObject
from module_kits.vtk_kit.mixins import SimpleVTKClassModuleBase
import vtk
class vtkImageSpatialFilter(SimpleVTKClassModuleBase):
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
... | nagyistoce/devide | modules/vtk_basic/vtkImageSpatialFilter.py | Python | bsd-3-clause | 499 |
#!/usr/bin/env python3
# Copyright 2013 Iain Peddie inr314159@hotmail.com
#
# This file is part of WellBehavedPython
#
# WellBehavedPython 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 v... | iain-peddie/well-behaved-python | tests/WellBehavedPythonTests/VerboseConsoleTestRunnerTests.py | Python | gpl-3.0 | 9,527 |
# Copyright 2012 Cloudbase Solutions Srl
#
# 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 l... | CropCircleSys/bsd-cloudinit | cloudbaseinit/plugins/common/base.py | Python | apache-2.0 | 889 |
# -*- encoding: utf-8 -*-
# REGRESSION METRICS (work on raw solution and prediction)
# These can be computed on all solutions and predictions
# (classification included)
from __future__ import print_function
import numpy as np
from autosklearn.constants import REGRESSION, METRIC_TO_STRING
def calculate_score(metric... | hmendozap/auto-sklearn | autosklearn/metrics/regression_metrics.py | Python | bsd-3-clause | 1,643 |
"""Asynchronous injections example."""
import asyncio
from dependency_injector import containers, providers
async def init_async_resource():
await asyncio.sleep(0.1)
yield "Initialized"
class Service:
def __init__(self, resource):
self.resource = resource
class Container(containers.Declarati... | ets-labs/python-dependency-injector | examples/providers/async.py | Python | bsd-3-clause | 695 |
#!/usr/bin/env python
import os
import unittest
import rendering
import xmlrpcrenderer
#class TestRpc(unittest.TestCase):
# """"Uncomment and try this out while a local server is running, if you want to see the xmlrpc in action.""""
# def testAll(self):
# deps = (
# ('foo', 'bar'),
# ... | sdouche/pynocle | src/pynocle/depgraph/test_xmlrpcrenderer.py | Python | gpl-3.0 | 608 |
def foo(*args, **kwargs): bar(*args, **kwargs)
| caot/intellij-community | python/testData/formatter/starArgument_after.py | Python | apache-2.0 | 47 |
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
def randrange(n, vmin, vmax):
return (vmax-vmin)*np.random.rand(n) + vmin
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
n = 100
for c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:
xs = randr... | fivetentaylor/rpyca | scatter3d_demo.py | Python | mit | 527 |
"""
This module mainly implements special orthogonal polynomials.
See also functions.combinatorial.numbers which contains some
combinatorial polynomials.
"""
from sympy.core.basic import Basic, S
from sympy.core import Rational, Symbol
from sympy.core.function import SingleValuedFunction
from sympy.utilities.memoiza... | certik/sympy-oldcore | sympy/functions/special/polynomials.py | Python | bsd-3-clause | 4,932 |
from django.db import models
from django.utils import timezone
class Post(models.Model):
author = models.ForeignKey('auth.User')
title = models.CharField(max_length=200)
text = models.TextField()
created_date = models.DateTimeField(
default=timezone.now)
published_date = models.DateTimeField(
blank=True, null... | ganasiff/chekoblog | blog/models.py | Python | gpl-2.0 | 464 |
import string, cgi, time
import sys
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
number =""
class MyHandler(BaseHTTPRequestHandler):
params = {}
def do_GET(self):
self.do_POST()
def do_POST(self):
self.parseParams()
if self.path == "/Status":
pri... | BlueScale/BlueScale | src/scripts/examples/IncomingForward.py | Python | agpl-3.0 | 1,827 |
# -*- coding: utf-8 -*-
{
'name': 'Norway - E-Invoicing (EHF 3)',
'icon': '/l10n_no/static/description/icon.png',
'version': '0.1',
'category': 'Accounting/Localizations/EDI',
'summary': 'E-Invoicing, Universal Business Language (EHF 3)',
'description': """
EHF 3 is the Norwegian implementation ... | jeremiahyan/odoo | addons/l10n_no_edi/__manifest__.py | Python | gpl-3.0 | 570 |
from flask import Flask, render_template, request, jsonify
from forms import forms
from chemistry.chemfig import smiles_mol_to_chemfig, get_name, update_chemfig
import re
from models import ml_models
import pybel
import os
app = Flask(__name__)
app.config.from_object('config.DevelopmentConfig')
#################
# M... | py-chemist/web_apps | app.py | Python | gpl-3.0 | 5,837 |
# ---------------------------
# Imports
# ---------------------------
from __future__ import print_function
from future import standard_library
standard_library.install_aliases()
import discord
import sys
import subprocess
import asyncio
import commands
import personalvars
# ---------------------------
# Personal Vari... | alexgerst/yawgmoth | src/yawgmoth.py | Python | mit | 9,490 |
import urllib.parse
from bs4 import BeautifulSoup
import requests
import requests.exceptions
from cloudbot import hook
@hook.command("down", "offline", "up")
def down(text):
"""<url> - checks if <url> is online or offline
:type text: str
"""
if "://" not in text:
text = 'http://' + text
... | CrushAndRun/Cloudbot-Fluke | plugins/pagecheck.py | Python | gpl-3.0 | 1,577 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Edgar Arturo Haas Pacheco
# @Date: 2015-10-04 19:49:33
from __future__ import unicode_literals
from django.core.validators import MinValueValidator, MaxValueValidator
from django.db import models
dicdias = {1: 'Lunes', 2: 'Martes', 3: 'Miercoles', 4: 'Juev... | Oriphiel/Python | AlarmaTecno/Alarma/models.py | Python | apache-2.0 | 2,234 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# __init__.py
#
# Copyright 2017 notna <notna@apparat.org>
#
# 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 Lice... | not-na/pyfileselect | pyfileselect/__init__.py | Python | gpl-2.0 | 1,863 |
from djangobayes.filter import build_msg
try:
from django.conf.settings import HAM_LEVEL
except ImportError:
HAM_LEVEL = 0.3
try:
from django.conf.settings import SPAM_LEVEL
except ImportError:
SPAM_LEVEL = 0.8
def get_mark(score):
""" Return mark based on score. """
if score is not None and ... | puterleat/django-spambayes | commentbayes/util.py | Python | bsd-3-clause | 920 |
import os
from urllib.parse import urljoin
import requests
from ._requests import Requests
from . import constants
class UpDownClient(Requests):
"""The Up/Down server provide upload/download snap capabilities."""
def __init__(self, client) -> None:
self._client = client
self._root_url = os.... | chipaca/snapcraft | snapcraft/storeapi/_up_down_client.py | Python | gpl-3.0 | 819 |
import json
from mock import patch
from tornado.web import HTTPError
from brainiak.instance.delete_instance import query_delete, query_dependants, \
delete_instance, QUERY_DEPENDANTS_TEMPLATE, QUERY_DELETE_INSTANCE
from brainiak import triplestore, server
from tests.mocks import Params
from tests.sparql import ... | bmentges/brainiak_api | tests/integration/test_delete_instance.py | Python | gpl-2.0 | 3,534 |
# -*- coding: utf-8 -*-
"""
DrQueue render template for XYZ
Copyright (C) 2011 Andreas Schroeder
This file is part of DrQueue.
Licensed under GNU General Public License version 3. See LICENSE for details.
"""
import os
import DrQueue
from DrQueue import engine_helpers
def run_renderer(env_dict):
# define ext... | jedie/DrQueueIPython | etc/_template.py | Python | gpl-3.0 | 1,412 |
from __future__ import annotations
import abc
import typing
if typing.TYPE_CHECKING:
from nion.swift.model import DocumentModel
class UndeleteBase(abc.ABC):
@abc.abstractmethod
def close(self) -> None: ...
@abc.abstractmethod
def undelete(self, document_model: DocumentModel.DocumentModel) -> N... | nion-software/nionswift | nion/swift/model/Changes.py | Python | gpl-3.0 | 932 |
from datetime import datetime
from enum import Enum
from typing import Optional, Sequence
from mongoengine import DateTimeField, Document, FloatField, StringField, connect
from vnpy.trader.constant import Exchange, Interval
from vnpy.trader.object import BarData, TickData
from .database import BaseDatabaseManager, Dr... | andrewchenshx/vnpy | vnpy/trader/database/database_mongo.py | Python | mit | 10,699 |
# -*- coding: utf-8 -*-
#
# Django-Select2-Chained documentation build configuration file, created by
# sphinx-quickstart on Tue Feb 09 14:29:43 2016.
#
# 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
# autogenera... | djkartsa/django-select2-chained | docs/conf.py | Python | mit | 10,006 |
import sys
import gdb
# Update module path.
dir_ = '/usr/local/share/glib-2.0/gdb'
if not dir_ in sys.path:
sys.path.insert(0, dir_)
from glib import register
register (gdb.current_objfile ())
| chriskmanx/qmole | QMOLEDEV/glib-2.29.14/glib/libglib-gdb.py | Python | gpl-3.0 | 199 |
"""
MySQL database backend for Django.
Requires MySQLdb: http://sourceforge.net/projects/mysql-python
"""
from django.db.backends import util
try:
import MySQLdb as Database
except ImportError, e:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading MySQLdb mo... | ychen820/microblog | y/google-cloud-sdk/platform/google_appengine/lib/django-0.96/django/db/backends/mysql/base.py | Python | bsd-3-clause | 8,305 |
# -*- coding: utf-8 -*-
from Tools.Directories import resolveFilename, SCOPE_PLUGINS
from Components.PluginComponent import plugins
def reloadPlugins():
plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
return {
"result": True,
"message": "List of Plugins has been read"
}
| E2OpenPlugins/e2openplugin-OpenWebif | plugin/controllers/models/plugins.py | Python | gpl-3.0 | 288 |
#!/bin/python
# ID3_classifier.py
# -------------------------
# Winter 2013; Alex Safatli
# -------------------------
# A program that carries out
# the ID3 algorithm on a
# given data file; extended
# in order to act as a classifier
# a la NB_classifier.
#
# Usage: python ID3_classifier.py
# Imports
import os, sys
... | AlexSafatli/DataMiningImplementations | naive-bayes/ID3_classifier.py | Python | gpl-2.0 | 13,649 |
# -*- 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... | chipaca/snapcraft | tests/unit/store/v2/test_channel_map.py | Python | gpl-3.0 | 14,404 |
from operator import attrgetter
class User:
def __init__(self, user_id):
self.user_id = user_id
def __repr__(self):
return 'User({})'.format(self.user_id)
# Example
users = [User(23), User(3), User(99)]
print(users)
# Sort it by user-id
print(sorted(users, key=attrgetter('user_id')))
| tuanavu/python-cookbook-3rd | src/1/sort_objects_without_native_comparison_support/example.py | Python | mit | 312 |
import pytest
import uqbar.strings
import supriya.patterns
pseq_01 = supriya.patterns.Pseq(["A", "B", "C", "D"])
pseq_02 = supriya.patterns.Pseq(
[supriya.patterns.Pseq(["A", "B", "C"]), supriya.patterns.Pseq(["D", "E", "F"])]
)
pseq_03 = supriya.patterns.Pseq(
[
supriya.patterns.Pbind(
... | Pulgama/supriya | tests/test_patterns_Pseq.py | Python | mit | 12,334 |
#!/usr/bin/env python
# encoding: utf-8
__author__ = "Telmo Menezes (telmo@telmomenezes.com)"
__date__ = "Mar 2011"
import sys
import os
import sqlite3
import datetime
import time
def safedict(dict, index, default):
if index in dict:
return dict[index]
else:
return default
class ImportWoS... | telmomenezes/sci-pie | import.py | Python | gpl-2.0 | 14,101 |
media_attrs = ['d_all_img_count',
'd_geo_count',
'd_image_map_count',
'd_ipa_count',
'd_midi_count',
'd_ogg_count',
'd_pdf_count',
'd_spoken_wp_count',
'd_svg_count',
'd_tex_count',
'd_thumb_img_count',
'd_thumb_left_count',
'd_thumb_right_count']
formatting_attrs = ['d... | slaporte/qualityvis | orange_scripts/attr_lists.py | Python | gpl-3.0 | 13,762 |
# Copyright 2010-2012 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for ProductSeries and ProductSeriesSet."""
__metaclass__ = type
from storm.exceptions import NoneError
from testtools.testcase import ExpectedException
import trans... | abramhindle/UnnaturalCodeFork | python/testdata/launchpad/lib/lp/registry/tests/test_productseries.py | Python | agpl-3.0 | 44,427 |
from django.conf.urls import patterns, url
urlpatterns = patterns(
'codereader.views',
url(r'^projects/$', "project_list", name="project_list"),
url(r'^project/new/', "project_add", name="project_add"),
url(r'^project/([\w-]+)/$', "project_details", name="project_details"),
url(r'^project/([\w-]+... | strycore/readthecode | codereader/urls.py | Python | agpl-3.0 | 487 |
# Copyright 2019 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
class EventType(models.Model):
_inherit = "event.type"
def _compute_event_type_mail_ids(self):
event_mail_template_id = self.env.company.event_mail_template_id
for ... | OCA/event | event_mail/models/event_type.py | Python | agpl-3.0 | 1,262 |
"""``tornado.gen`` is a generator-based interface to make it easier to
work in an asynchronous environment. Code using the ``gen`` module
is technically asynchronous, but it is written as a single generator
instead of a collection of separate functions.
For example, the following asynchronous handler::
class Asy... | edisonlz/fruit | web_project/base/site-packages/tornado/gen.py | Python | apache-2.0 | 13,906 |
"""Test to verify that we can load components."""
from asynctest.mock import ANY, patch
import pytest
from homeassistant.components import http, hue
from homeassistant.components.hue import light as hue_light
import homeassistant.loader as loader
from tests.common import MockModule, async_mock_service, mock_integrati... | postlund/home-assistant | tests/test_loader.py | Python | apache-2.0 | 8,293 |
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
from ragendja.auth.urls import urlpatterns as auth_patterns
from blog.forms import UserRegistrationForm
from django.contrib import admin
admin.autodiscover()
handler500 = 'ragendja.views.server_error'
urlpatterns = auth_patterns + patterns('',
(r'^a... | directeur/socnode | urls.py | Python | mit | 648 |
# As the can states
# Is Bloop
from remainder import REMAINDER
def IS_EVEN(n):
if REMAINDER(n,2) == 0:
return True
else:
return False
| thegaps/GEB | floop/bloop/even.py | Python | gpl-3.0 | 161 |
# iocdump.py
#
# Copyright 2016 FireEye
# Licensed under the Apache 2.0 license. Developed for Mandiant by William
# Gibb.
#
# Mandiant licenses this file to you 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 Lic... | mandiant/ioc_writer | ioc_writer/scripts/iocdump.py | Python | apache-2.0 | 2,104 |
"""Tasks related to projects, including fetching repository code, cleaning
``conf.py`` files, and rebuilding documentation.
"""
import fnmatch
import os
import shutil
import json
import logging
import socket
import requests
import datetime
from celery import task
from django.conf import settings
from django.core.urlre... | takluyver/readthedocs.org | readthedocs/projects/tasks.py | Python | mit | 36,100 |
"""Taken and modified from the dbsettings project.
http://code.google.com/p/django-values/
"""
from decimal import Decimal
from django import forms
from django.conf import settings as django_settings
from django.core.exceptions import ImproperlyConfigured
from django.core.cache import cache
from django.utils import si... | erichegt/askbot-devel | askbot/deps/livesettings/values.py | Python | gpl-3.0 | 24,786 |
import webbrowser
class ScriptHandler:
def __init__(self):
self.commands = ['youtube ([\w ]+)']
def runScript(self, args):
searchTerm = str(args(1))
terms = searchTerm.split()
first = True
url = 'www.youtube.com/results?search_query='
for term in terms:
... | edbrown23/Chives | scripts/youtubeScript.py | Python | mit | 472 |
"""Establish tests package."""
| gwax/mtgcdb | tests/__init__.py | Python | mit | 31 |
import threading
import sys
class ThreadHandler(object):
def __init__(self, name, callable, *args, **kwargs):
# Set up exception handling
self.exception = None
def wrapper(*args, **kwargs):
try:
callable(*args, **kwargs)
except BaseException:
... | apavlo/h-store | third_party/python/fabric/thread_handling.py | Python | gpl-3.0 | 588 |
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve.
#
#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... | kuke/models | fluid/PaddleRec/din/train.py | Python | apache-2.0 | 5,077 |
import unittest
from openmdao.main.datatypes.api import Int, List
from openmdao.lib.components.mux import Mux,DeMux
class testMux(unittest.TestCase):
def test_2mux(self):
mux = Mux(2)
mux.input_1 = 1.5
mux.input_2 = "a"
mux.execute()
self.ass... | HyperloopTeam/FullOpenMDAO | lib/python2.7/site-packages/openmdao.lib-0.13.0-py2.7.egg/openmdao/lib/components/test/test_mux.py | Python | gpl-2.0 | 1,249 |
#!/usr/bin/env python
# Jonas Schnelli, 2013
# make sure the Tetra-Qt.app contains the right plist (including the right version)
# fix made because of serval bugs in Qt mac deployment (https://bugreports.qt-project.org/browse/QTBUG-21267)
from string import Template
from datetime import date
bitcoinDir = "./";
inFil... | Cryptodeer/tetra | share/qt/clean_mac_info_plist.py | Python | mit | 891 |
"""fix polymorphic_type
Revision ID: 3659fbd1a6c1
Revises:
Create Date: 2014-11-26 14:23:38.888000
"""
# revision identifiers, used by Alembic.
revision = '3659fbd1a6c1'
down_revision = None
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
def upgrade():
update_pmtype(['c... | clld/dictionaria | migrations/versions/3659fbd1a6c1_fix_polymorphic_type.py | Python | apache-2.0 | 742 |
# Copyright (C) 2009 William.os4y@gmail.com
#
# 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, version 2 of the License.
#
# This program is distributed in the hope that it will be... | e7/fapws3 | fapws/contrib/views.py | Python | gpl-2.0 | 2,148 |
#!/usr/bin/python -u
# Copyright (c) 2010-2012 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ap... | prashanthpai/swift | test/probe/test_object_failures.py | Python | apache-2.0 | 8,493 |
""" Test suite for the fixer modules.
Based on lib2to3/tests/test_fixers.py
"""
# Support code for test_*.py files, from lib2to3/tests/support.py by Collin Winter:
# Python imports
import sys
import os
import os.path
from itertools import chain
from textwrap import dedent
from operator import itemgetter
from lib2to3... | hughperkins/kgsgo-dataset-preprocessor | thirdparty/future/tests/test_future/test_libfuturize_fixers.py | Python | mpl-2.0 | 124,026 |
"""
WSGI config for fishackathon project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fishackathon.settings")
from dja... | dcarrot2/fishackathon | fishackathon/wsgi.py | Python | gpl-2.0 | 399 |
# Copyright (c) 2014 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/licenses/LICENSE-2.0
#
# Unless required by applica... | ctrlaltdel/neutrinator | vendor/openstack/cloud/__init__.py | Python | gpl-3.0 | 652 |
# Generated by Django 2.1.5 on 2019-01-29 18:43
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('activities', '0014_auto_20190202_1404'),
]
operations = [
migrations.RenameField(
model_name='activity',
old_name='feedback_... | yunity/foodsaving-backend | karrot/activities/migrations/0015_auto_20190129_1843.py | Python | agpl-3.0 | 380 |
import vcr
from behave import when, then, given
from hamcrest import assert_that, is_not, empty, is_, has_length, equal_to
@given('I have a list of performances for event with id "{event_id}"')
@vcr.use_cassette('fixtures/cassettes/performance-list.yaml', record_mode='new_episodes')
def given_i_have_a_list_of_perform... | ingresso-group/pyticketswitch | features/steps/step_performances.py | Python | mit | 2,679 |
# -*- coding: utf-8 -*-
__author__ = 'boonya'
class NotExistsException(Exception):
"""Special exception for classes which will
implement FileSystemInterface.
"""
def __init__(self, *args, **kwargs):
super(NotExistsException, self).__init__(*args, **kwargs)
| boonya/Djangyll | backend/app/utils/fs/exception.py | Python | mit | 284 |
import os
# The fake password we will use to authenticate su'ed users
SECRET_PASSWORD = os.urandom(64)
__version__ = '0.4.7'
| Stackdriver/django-su | django_su/__init__.py | Python | mit | 127 |
import tensorflow as tf
import numpy as np
class TextCNN(object):
'''
A CNN for text classification
Uses and embedding layer, followed by a convolutional, max-pooling and softmax layer.
'''
def __init__(
self, sequence_length, num_classes,
embedding_size, filter_sizes, num_filters,... | imyeego/MLinPy | zh_cnn_text_classify/text_cnn.py | Python | mit | 3,414 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Functions for converting between color spaces.
The "central" color space in this module is RGB, more specifically the linear
sRGB color space using D65 as a white-point [1]_. This represents a
standard monitor (w/o gamma correction). For a good FAQ on color spaces see... | Hiyorimi/scikit-image | skimage/color/colorconv.py | Python | bsd-3-clause | 47,654 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
###############################################################################
# Copyright 2015 Kitware 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 cop... | Kitware/cumulus | cumulus/common/__init__.py | Python | apache-2.0 | 2,100 |
import os
import sys
import calendar
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
handler = logging.FileHandler('year_import.log')
handler.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(fo... | defaultnamehere/honours | counts/import_counts.py | Python | gpl-2.0 | 3,350 |
# -*- coding: UTF-8 -*-
# CCcam Info by AliAbdul
from base64 import encodestring
from os import listdir, remove, rename, system
from enigma import eListboxPythonMultiContent, eTimer, gFont, loadPNG, RT_HALIGN_RIGHT
from Components.ActionMap import ActionMap, NumberActionMap
from Components.config import config, Confi... | schleichdi2/OpenNfr_E2_Gui-6.0 | lib/python/Screens/CCcamInfo.py | Python | gpl-2.0 | 61,675 |
# Author: Leonardo Pistone
# Copyright 2015 Camptocamp SA
#
# 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 your option) any la... | andrius-preimantas/purchase-workflow | purchase_all_shipments/tests/test_three_step_reception.py | Python | agpl-3.0 | 1,237 |
"""
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 use this ... | arenadata/ambari | ambari-server/src/main/resources/stacks/ADH/1.3/services/MAHOUT/package/scripts/params.py | Python | apache-2.0 | 3,879 |
"Add your URLs here"
from handlers import *
urlpatterns = [
# (r"/app", SomeHandler),
]
| letolab/airy | airy/skeleton/app/urls.py | Python | bsd-2-clause | 93 |
# This file is part of Buildbot. Buildbot 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, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without eve... | zozo123/buildbot | master/buildbot/test/fake/openstack.py | Python | gpl-3.0 | 2,525 |
# pylint: disable=missing-docstring, missing-module-docstring, invalid-name
# pylint: disable=too-few-public-methods, line-too-long, dangerous-default-value
# pylint: disable=wrong-import-order
# https://github.com/PyCQA/pylint/issues/4774
def github_issue_4774():
# Test literals
# https://github.com/PyCQA/pyl... | PyCQA/pylint | tests/functional/u/use/use_implicit_booleaness_not_comparison.py | Python | gpl-2.0 | 5,576 |
### BEGIN LICENSE
# Copyright 2012 Robert McGibbon
#
# This file is part of fsync
#
# fsync 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
# ver... | rmcgibbo/fsync | ubuntu/fsync_lib/helpers.py | Python | gpl-3.0 | 2,883 |
"""Fixer for except statements with named exceptions.
The following cases will be converted:
- "except E, T:" where T is a name:
except E as T:
- "except E, T:" where T is not a name, tuple or list:
except E as t:
T = t
This is done because the target of an "except" clause... | Orav/kbengine | kbe/src/lib/python/Lib/lib2to3/fixes/fix_except.py | Python | lgpl-3.0 | 3,437 |
# Shows how you can switch between Numeric and NumPy print outs
# if you have to
import pretty
supports_numeric = False
try :
import Numeric
supports_numeric = True
array = Numeric.array
types_map = pretty.NumericToOCMap
except :
pass
supports_numpy = False
try :
import numpy
supports_numpy = T... | RichIsMyName/PicklingToolsRepo | Xm/ptools161/python/prettyprint_test.py | Python | bsd-3-clause | 702 |
# Copyright (C) 2016 Google Inc.
# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>
"""Data handlers for notifications for objects in ggrc module.
Main contributed functions are:
get_assignable_data,
"""
import datetime
import urlparse
from logging import getLogger
from ggrc import mod... | andrei-karalionak/ggrc-core | src/ggrc/notifications/data_handlers.py | Python | apache-2.0 | 7,744 |
#!/usr/bin/env python3
###############################################################################
# Copyright 2017 The Apollo 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... | xiaoxq/apollo | modules/tools/mapshow/libs/subplot_path.py | Python | apache-2.0 | 4,881 |
import numpy as np
import h5py
from keras.layers import Input, Dense
from keras.models import Model
import os
from orcanet.core import Organizer
def make_dummy_data(path):
"""
Save a train and a val h5 file with random numbers as samples,
and the sum as labels.
"""
def get_dummy_data(samples):
... | ViaFerrata/DL_pipeline_TauAppearance | examples/full_example/full_example.py | Python | agpl-3.0 | 1,535 |
from os.path import join
import pytest
from ..utils import get_test_data_path
from pliers.converters import TesseractConverter
from pliers.stimuli import ImageStim
IMAGE_DIR = join(get_test_data_path(), 'image')
def test_tesseract_converter():
pytest.importorskip('pytesseract')
stim = ImageStim(join(IMAGE_... | tyarkoni/featureX | pliers/tests/converters/test_image_converters.py | Python | bsd-3-clause | 599 |
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
import sys
sys.path.insert(1, BASE_DIR + '/..')
SECRET_KEY = '($7wfk^1hd5+i-2j1k^h$v^-r-7r$47f@2-9&_%5tlk^9wwfi6'
DEBUG = True
TEMPLATE_DEBUG = False
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'D... | grey0ne/django-protector | test_project/application/settings.py | Python | mit | 1,736 |
#!/usr/bin/python
# -*- coding: utf-8 -*-
""" Bot to download a list of DOIs from the URLs of the TDM API. """
#
# (C) Federico Leva, 2018
#
# Distributed under the terms of the MIT license.
#
__version__ = '0.1.0'
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry impo... | nemobis/bots | doi-crossref-pdf.py | Python | gpl-3.0 | 1,800 |
## account.py
# Account system support.
from pydle.features import rfc1459
import asyncio
class AccountSupport(rfc1459.RFC1459Support):
## Internal.
def _create_user(self, nickname):
super()._create_user(nickname)
if nickname in self.users:
self.users[nickname].update({
... | Shizmob/pydle | pydle/features/account.py | Python | bsd-3-clause | 1,698 |
"""Heatmap of daily data."""
import calendar
import datetime
import matplotlib.colors as mpcolors
import numpy as np
from seaborn import heatmap
import pandas as pd
from pyiem.plot import get_cmap, figure_axes
from pyiem.util import get_autoplot_context, get_sqlalchemy_conn
from pyiem.exceptions import NoDataFound
PD... | akrherz/iem | htdocs/plotting/auto/scripts200/p204.py | Python | mit | 4,784 |
"""Support for the AEMET OpenData service."""
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import (
ATTRIBUTION,
DOMAIN,
ENTRY_NAME,
ENTRY_WEATHER_COORDINATOR,... | kennedyshead/home-assistant | homeassistant/components/aemet/sensor.py | Python | apache-2.0 | 5,099 |
# -*- coding: utf-8 -*-
import xmltodict
def singlesymbol(self, qml):
with open(qml) as f:
styler = []
style = {}
parsed = xmltodict.parse(f)
renderer = dict(parsed['qgis']['renderer-v2']['symbols']['symbol'])
style['alpha'] = renderer['@alpha']
layer = dict(parsed[... | spatialsuite/qgis2sps | parsers.py | Python | gpl-3.0 | 547 |
# -*- coding: utf-8 -*-
#
# || ____ _ __
# +------+ / __ )(_) /_______________ _____ ___
# | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
# +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
# || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
#
# Copyright (C) 2021 Bitcraze AB
#
# Th... | bitcraze/crazyflie-lib-python | sys_test/single_cf_grounded/single_cf_grounded.py | Python | gpl-2.0 | 1,886 |
"""
Routers provide a convenient and consistent way of automatically
determining the URL conf for your API.
They are used by simply instantiating a Router class, and then registering
all the required ViewSets with that router.
For example, you might have a `urls.py` that looks something like this:
router = route... | johnraz/django-rest-framework | rest_framework/routers.py | Python | bsd-2-clause | 13,715 |
# -*- coding: utf-8 -*-
from datetime import date, datetime
from urllib import unquote
from shutil import copyfile
from flask import session, render_template, request, jsonify
from flask import redirect, url_for
from sqlalchemy import or_, and_, extract, distinct, desc
from PIL import Image
from app import app, db
fr... | dsloop/FranERP | app/views/budget.py | Python | mit | 35,621 |
##############################################################################
# Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-64... | EmreAtes/spack | var/spack/repos/builtin/packages/wt/package.py | Python | lgpl-2.1 | 4,106 |
#!/usr/bin/env python
#
# Freeciv - Copyright (C) 2003 - Raimar Falke
# 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, or (at your option)
# any later version.
#
# Th... | jheusala/freeciv-extended | common/generate_packets.py | Python | gpl-2.0 | 55,749 |
from model.group import Group
import random
import string
import os.path
import jsonpickle
import getopt
import sys
try:
opts, args = getopt.getopt(sys.argv[1:], "n:f:", ["number of groups", "file"])
except getopt.GetoptError as err:
getopt.usage()
sys.exit(2)
n = 2
f = "data/groups.json"
for o, a in opt... | elaginm/python_training | generator/group.py | Python | apache-2.0 | 1,034 |
# -*- coding: utf-8 -*-
"""Module handling schedules"""
from functools import partial
from navmazing import NavigateToSibling, NavigateToObject
from . import Report
from cfme.fixtures import pytest_selenium as sel
from cfme.intelligence.reports.ui_elements import Timer
from cfme.web_ui import (
EmailSelectForm, Fo... | rlbabyuk/integration_tests | cfme/intelligence/reports/schedules.py | Python | gpl-2.0 | 9,914 |
"""
A library of useful helper classes to the saxlib classes, for the
convenience of application and driver writers.
$Id: saxutils.py,v 1.19 2001/03/20 07:19:46 loewis Exp $
"""
import types, sys, urllib, urlparse, os, string
import handler, _exceptions, xmlreader
try:
_StringTypes = [types.StringType, types.Uni... | Integral-Technology-Solutions/ConfigNOW | Lib/xml/sax/saxutils.py | Python | mit | 20,106 |
import Queue
import threading
import time
exitFlag = 0
class myThread (threading.Thread):
def __init__(self, threadID, name, q):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.q = q
def run(self):
print "Starting " + self.name
pro... | justasabc/python_tutorials | tutorial/thread/queue1.py | Python | gpl-3.0 | 1,377 |
## @file
# Override built in module os to provide support for long file path
#
# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distrib... | MattDevo/edk2 | BaseTools/Source/Python/Common/LongFilePathOs.py | Python | bsd-2-clause | 2,187 |
# Copyright (c) 2020, Manfred Moitzi
# License: MIT License
import os
import pytest
import ezdxf
BASEDIR = os.path.dirname(__file__)
DATADIR = "data"
@pytest.fixture(params=["Leica_Disto_S910.dxf"])
def filename(request):
filename = os.path.join(BASEDIR, DATADIR, request.param)
if not os.path.exists(filena... | mozman/ezdxf | integration_tests/test_leica_disto_r12.py | Python | mit | 607 |
"""
Created on Sep 15, 2014
@author: sfurman
"""
# Terminal color palette.
class Color(object):
def __init__(self):
pass
TEXT_RESET_ALL = '\033[0m'
TEXT_RESET = '\033[39m' # '\033[49m'
TEXT_BLACK = '\033[30m'
TEXT_RED = '\033[31m'
TEXT_GREEN = '\033[32m'
TEXT_YELLOW = '\033[33m'... | srdjanfurman/Python_code_snippets | PythonPackagesValidatorCentOS/colors.py | Python | mit | 1,752 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright 2013 VMware. 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/license... | Juniper/neutron | neutron/plugins/vmware/extensions/networkgw.py | Python | apache-2.0 | 6,420 |
""" Static order of nodes in dask graph
We can make decisions on what tasks to run next both
* Dynamically at runtime
* Statically before runtime
Dask's async scheduler runs dynamically and prefers to run tasks that were just
made available. However when several tasks become available at the same time
we have an ... | jeffery-do/Vizdoombot | doom/lib/python3.5/site-packages/dask/order.py | Python | mit | 6,394 |
import os
import json
from urlparse import urlparse
from pymongo import uri_parser
def get_private_key():
with open('mistt-solution-d728e8f21f47.json') as f:
return json.loads(f.read()).items()
# Flask
CSRF_SESSION_KEY = os.getenv('FLASK_SESSION_KEY', 'notsecret')
SECRET_KEY = os.getenv('FLASK_SECRET_KEY'... | michaelnetbiz/mistt-solution | config.py | Python | mit | 1,994 |
"""
managers.py
.. moduleauthor:: Ulrich Felzmann <ulrich.felzmann@versi.edu.au>
"""
from datetime import datetime
from django.db import models
from django.db.models import Q
from django.core.exceptions import PermissionDenied
from django.contrib.auth.models import User, Group
from tardis.tardis_portal.auth.local... | steveandroulakis/mytardis | tardis/tardis_portal/managers.py | Python | bsd-3-clause | 12,213 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.