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 |
|---|---|---|---|---|---|
import sys
from os import path
import glob
import re
import argparse
from subprocess import Popen
from Bio import SeqIO
import utils
ens_RE = re.compile("[A-Z]*")
cmd_template = "/nfs/research2/goldman/gregs/sw/SCRATCH-1D_1.0/bin/run_SCRATCH-1D_predictors.sh {} {}"
argparser = argparse.ArgumentParser()
argparser.ad... | jergosh/slr_pipeline | bin/run_SCRATCH.py | Python | gpl-2.0 | 1,626 |
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "contentdensity.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure th... | CS326-important/space-deer | contentdensity/manage.py | Python | mit | 812 |
# -*- coding: utf-8 -*-
# Copyright 2016 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import account_chart_template
| VitalPet/addons-onestein | account_chart_template_multicompany/models/__init__.py | Python | agpl-3.0 | 184 |
import numpy as np
from StringIO import StringIO
from matplotlib import image as img
import requests
class Map(object):
def __init__(self, lat, long, satellite=True, zoom=10, size=(400,400), sensor=False):
"""Initialise map object with a <lat> and <long> latitude/longitude coordinates."""
base="htt... | davidtwomey/greengraphs_cw | greengraph/map.py | Python | mit | 1,766 |
# file openpyxl/namedrange.py
# Copyright (c) 2010-2011 openpyxl
#
# 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, copy... | sbhowmik7/PSSEcompare | ext_libs/openpyxl/namedrange.py | Python | gpl-3.0 | 3,301 |
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 3 21:15:19 2015
@author: rwalker (r_walker@zoho.com)
"""
from __future__ import division, absolute_import, print_function
from numpy.distutils.core import setup, Extension
from numpy.distutils.misc_util import Configuration
from numpy.distutils.system_info import get_info... | rwalk333/pyquadprog | setup.py | Python | lgpl-2.1 | 947 |
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def reverseKGroup(self, head, k):
"""
:type head: ListNode
:type k: int
:rtype: ListNode
"""
if head == None or head.next == ... | china10s/PBFLeetCodeDaily | Hard/25. Reverse Nodes in k-Group/Solution.py | Python | mit | 1,457 |
"""SimpleApp.py"""
import sys
from pyspark import SparkContext
def main():
if len(sys.argv) < 2:
print "Need spark URI."
sys.exit(-1)
logFile = "/usr/local/opt/spark-0.8.0/README.md" # Should be some file on your system
sc = SparkContext(sys.argv[1], "Simple Python App")
logData = sc.... | thoughtpolice/dockerfiles | spark/python-test/SimpleApp.py | Python | apache-2.0 | 560 |
class Solution(object):
def containsNearbyDuplicate(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: bool
"""
lookup = {}
for i, num in enumerate(nums):
if num in lookup and abs(i - lookup[num]) <= k:
return True
... | TanakritBenz/leetcode-adventure | Contains_DuplicateII.py | Python | gpl-2.0 | 365 |
"""
Provides a UserPartition driver for cohorts.
"""
import logging
from courseware.masquerade import (
get_course_masquerade,
get_masquerading_user_group,
is_masquerading_as_specific_student
)
from xmodule.partitions.partitions import NoSuchUserPartitionGroupError
from .cohorts import get_cohort, get_gro... | a-parhom/edx-platform | openedx/core/djangoapps/course_groups/partition_scheme.py | Python | agpl-3.0 | 4,041 |
from __future__ import unicode_literals
from django.db import connections, models
from django.db.models.sql.compiler import SQLCompiler
class NullsFirstSQLCompiler(SQLCompiler):
def get_order_by(self):
result = super(NullsFirstSQLCompiler, self).get_order_by()
if result:
return [(exp... | snazy2000/netbox | netbox/utilities/sql.py | Python | apache-2.0 | 1,204 |
from django.test import SimpleTestCase
from corehq.apps.change_feed import data_sources, topics
from corehq.apps.change_feed.topics import get_topic_for_doc_type
from corehq.util.test_utils import generate_cases
class TopicTests(SimpleTestCase):
pass
@generate_cases([
('CommCareCase', data_sources.SOURCE_S... | dimagi/commcare-hq | corehq/apps/change_feed/tests/test_topics.py | Python | bsd-3-clause | 602 |
# Copyright 2016 Cloudbase Solutions Srl
# 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 r... | vmturbo/nova | nova/policies/volumes_attachments.py | Python | apache-2.0 | 2,496 |
"""Tests for Messaging Service Scripts end-to-end main process code."""
import asyncio
import functools
import itertools
import json
import multiprocessing as mp
import os
import typing
from typing import Any
import unittest
from unittest import mock
from perfkitbenchmarker.scripts.messaging_service_scripts.common im... | GoogleCloudPlatform/PerfKitBenchmarker | tests/scripts/messaging_service_scripts_e2e_main_process_test.py | Python | apache-2.0 | 17,683 |
from pyramid.security import (
Allow,
Everyone
)
class RootFactory(object):
"""
Set up what permissions groups have.
"""
__acl__ = [
(Allow, 'users', 'view'),
(Allow, 'users', 'edit'),
(Allow, 'admins', 'admin')
]
def __init__(self, request):
pass
| haydenashton/reminders | reminder/access_list.py | Python | mit | 314 |
import numpy as np
from scipy.spatial.distance import cdist
import matplotlib.pyplot as plt
import matplotlib.offsetbox as offsetbox
from mpl_toolkits.axes_grid1 import make_axes_locatable
def pl_full_frame(
gs, fig, project, x_offset, y_offset, x_name, y_name, coord, x_min, x_max,
y_min, y_max, asp_rati... | asteca/ASteCA | packages/out/mp_cent_dens.py | Python | gpl-3.0 | 10,266 |
"""
pystrix.ami.dahdi
=================
Provides classes meant to be fed to a `Manager` instance's `send_action()` function.
Specifically, this module provides implementations for features specific to the DAHDI technology.
Legal
-----
This file is part of pystrix.
pystrix is free software; you can redistribute it ... | nhtdata/pystrix | pystrix/ami/dahdi.py | Python | gpl-3.0 | 3,238 |
# 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 may ... | Azure/azure-sdk-for-python | sdk/network/azure-mgmt-network/azure/mgmt/network/v2019_08_01/operations/_peer_express_route_circuit_connections_operations.py | Python | mit | 9,496 |
import sys
sys.path.insert(1, "../../../")
import h2o
import random
def weights_var_imp(ip,port):
# Connect to h2o
h2o.init(ip,port)
def check_same(data1, data2, min_rows_scale):
gbm1_regression = h2o.gbm(x=data1[["displacement", "power", "weight", "acceleration", "year"]],
... | ChristosChristofidis/h2o-3 | h2o-py/tests/testdir_algos/gbm/pyunit_weights_var_impGBM.py | Python | apache-2.0 | 6,163 |
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class Tesseract(AutotoolsPackage):
"""Tesseract Open Source OCR Engine."""
homepage = "http... | LLNL/spack | var/spack/repos/builtin/packages/tesseract/package.py | Python | lgpl-2.1 | 2,984 |
#!/usr/bin/python3
# -*- coding: utf8 -*-
# File: app.py
#
# By Maxime Brodat <maxime.brodat@fouss.fr>
#
# Created: 17/04/2016 by Fouss
"""Main file for the transshipment solver project"""
from ag41_transshipment.parser import Parser
from ag41_transshipment.solver import initialize, solve, print_solution, test_feasi... | MrFouss/Ubiquitous-Shipping | ag41_transshipment/app.py | Python | gpl-3.0 | 3,758 |
from django.conf import settings
from django.test.utils import override_settings
import responses
from unittest.mock import Mock, patch
from olympia.amo import monitors
from olympia.amo.tests import TestCase
class TestMonitor(TestCase):
@patch('socket.socket')
def test_memcache(self, mock_socket):
... | mozilla/addons-server | src/olympia/amo/tests/test_monitor.py | Python | bsd-3-clause | 2,806 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from Method import *
from RombergIterate import *
import sys, time, datetime, os
if __name__ == "__main__":
rangeOut = False
sair = False
while( not sair):
firstTime = False
os.system('clear')
print bcolors.HEADER + '============================= Romberg =======... | glaucomunsberg/romberg | Principal.py | Python | gpl-2.0 | 3,458 |
# Copyright (C) 2013-2015 2ndQuadrant Italia (Devise.IT S.r.L.)
#
# This file is part of Barman.
#
# Barman 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... | xocolatl/pgbarman | tests/test_executor.py | Python | gpl-3.0 | 25,475 |
# force floating point division. Can still use integer with //
from __future__ import division
# This file is used for importing the common utilities classes.
import numpy as np
import matplotlib.pyplot as plt
# import the patrick-specific utilities
import GenUtilities as pGenUtil
import PlotUtilities as pPlotUtil
imp... | prheenan/prhUtil | python/IgorUtil.py | Python | gpl-2.0 | 8,803 |
#import multiprocessing as mp
#import importlib
#from IPython.lib.deepreload import reload as dreload
import os
import gmaneLegacy as g
#importlib.reload(g.loadMessages)
#importlib.reload(g.listDataStructures)
#importlib.reload(g.interactionNetwork)
#importlib.reload(g.networkMeasures)
#importlib.reload(g.networkParti... | ttm/gmaneLegacy | tests/testDrawer.py | Python | unlicense | 1,687 |
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class Kcov(CMakePackage):
"""Code coverage tool for compiled programs, Python and Bash which use... | iulian787/spack | var/spack/repos/builtin/packages/kcov/package.py | Python | lgpl-2.1 | 1,192 |
res, a, b = 0, 0, 1
while res <= 4000000:
a, b = b, a + b
if b % 2 == 0:
res += b
print(res)
| wizh/euler | 002/solution.py | Python | mit | 110 |
# -*- coding: utf-8 -*-
#
# geoloc.py
#
# Copyright (C) 2010 Antoine Mercadal <antoine.mercadal@inframonde.eu>
# Copyright, 2011 - Franck Villaume <franck.villaume@trivialdev.com>
# This file is part of ArchipelProject
# http://archipelproject.org
#
# This program is free software: you can redistribute it and/or modify... | fr34k8/Archipel | ArchipelAgent/archipel-agent-hypervisor-geolocalization/archipelagenthypervisorgeolocalization/geoloc.py | Python | agpl-3.0 | 7,356 |
# TODO: Write unit tests for actual methods in the class
def add_one(x):
return x+1
def test_add_one():
assert add_one(3) == 4
| scorelab/DroneSym | dronesym-python/flask-api/tests/test_default.py | Python | apache-2.0 | 137 |
import json, sqlite3, os
import numpy as np
import pandas as pd
SROWS = 40000
connmain = sqlite3.connect('/media/burak/Seagate Backup Plus Drive/archive/data/campdata/elev.db')
#connmain = sqlite3.connect('/home/burak/Downloads/elev4.db')
longmin,latmin,longmax,latmax = 26.672,45.482,30.096,48.467
print (longmin,la... | burakbayramli/kod | nomadicterrain/sql/tst6.py | Python | gpl-3.0 | 1,133 |
########
# Copyright (c) 2014 GigaSpaces Technologies Ltd. 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... | codilime/cloudify-cli | cloudify_cli/blueprint.py | Python | apache-2.0 | 4,816 |
from typing import Dict
import pytest
from app.request_schemes.status_request_data import StatusRequestData
pytestmark = pytest.mark.asyncio
@pytest.mark.usefixtures('unstub')
class TestStatusRequestData:
@pytest.mark.parametrize("status_data, expected_result", [
({'repository': '', 'sha': '', 'state':... | futuresimple/triggear | tests/request_schemes/test_status_request_data.py | Python | mit | 792 |
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
@author: Will
"""
import re
from django import forms
from django.core.exceptions import ValidationError
import models
def chk_username(arg):
username_re = re.compile(r"^[_a-zA-Z0-9]+$")
if not username_re.search(arg):
raise ValidationError("用户名格式错误... | willre/homework | day20/homework/myBBS/web/forms.py | Python | gpl-2.0 | 2,627 |
# Copyright 2015 Adafruit Industries.
# Author: Tony DiCola
# License: GNU GPLv2, see LICENSE.txt
import glob
from usb_drive_mounter import USBDriveMounter
class USBDriveReader(object):
def __init__(self, config):
"""Create an instance of a file reader that uses the USB drive mounter
service to ... | lfpoelman/pi_looper | Adafruit_Video_Looper/usb_drive.py | Python | gpl-2.0 | 1,507 |
import lasagne
from lasagne.layers import InputLayer
import theano
import theano.tensor as T
import numpy as np
import generator
from model import Model
class ModelBCE(Model):
def __init__(self, w, h, batch_size=32, lr=0.001):
super(ModelBCE, self).__init__(w, h, batch_size)
self.net = generator... | imatge-upc/saliency-salgan-2017 | scripts/models/model_bce.py | Python | mit | 1,561 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPainter
from PyQt5.QtGui import QPen
from PyQt5.QtWidgets import QWidget
from src import *
class DrawArea(QWidget):
def __init__(self, parent):
super().__init__(parent)
self.parent = parent
... | Drapegnik/bsu | technology/lab1/ui/DrawArea.py | Python | mit | 3,712 |
#!/usr/bin/env python3
#
# linearize-data.py: Construct a linear, no-fork version of the chain.
#
# Copyright (c) 2013-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
import struct
import re
impo... | qtumproject/qtum | contrib/linearize/linearize-data.py | Python | mit | 13,632 |
from bokeh.io import show
from bokeh.layouts import gridplot
from bokeh.plotting import figure
x_range = ['a', 'b', 'c', 'd']
y_values = [1., 2., 3., 4.]
y_errors = [.1, .2, .3, .4]
err_xs = []
err_ys = []
for x, y, yerr in zip(x_range, y_values, y_errors):
err_xs.append((x, x))
err_ys.append((y - yerr, y + ... | ericmjl/bokeh | examples/integration/glyphs/categorical_multi_glyphs.py | Python | bsd-3-clause | 1,250 |
import subprocess
from mozpackager.settings import BUILD_DIR, BUILD_LOG_DIR, MEDIA_PATH
import json
class Mock:
root = None
mock = '/usr/bin/mock'
_build_log_text = None
_error_log_text = None
def __init__(self, build_package):
"""
Perhaps pull these dynamically at some point
... | rtucker-mozilla/mozpackager | mozpackager/Mock.py | Python | bsd-3-clause | 8,528 |
# Copyright 2016 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... | ppries/tensorflow | tensorflow/contrib/learn/python/learn/datasets/synthetic_test.py | Python | apache-2.0 | 5,301 |
"""
Unit tests for the container page.
"""
import datetime
import re
from django.http import Http404
from django.test.client import RequestFactory
from django.utils import http
from mock import Mock, patch
from pytz import UTC
import contentstore.views.component as views
from contentstore.tests.test_libraries import ... | ahmedaljazzar/edx-platform | cms/djangoapps/contentstore/views/tests/test_container_page.py | Python | agpl-3.0 | 10,800 |
"""Just a template for subclassing"""
import os
from abc import abstractmethod, ABCMeta
import logging
from os.path import join, dirname, relpath, basename, realpath, normpath
from itertools import groupby
from jinja2 import FileSystemLoader, StrictUndefined
from jinja2.environment import Environment
import copy
from ... | theotherjimmy/mbed | tools/export/exporters.py | Python | apache-2.0 | 6,871 |
#!/bin/env python
# -*- coding: utf-8; -*-
#
# (c) 2016 FABtotum, http://www.fabtotum.com
#
# This file is part of FABUI.
#
# FABUI 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 Licen... | infinity0n3/fabtotum-experiments | fabtotum/fabui/config.py | Python | gpl-3.0 | 2,465 |
import ldap
import os
import time
from passlib import hash
from subprocess import check_output
from syncloudlib import fs
from syncloudlib.logger import get_logger
ldap_user_conf_dir = '/var/snap/platform/current/slapd.d'
DOMAIN = "dc=syncloud,dc=org"
class LdapAuth:
def __init__(self, platform_config, systemctl... | syncloud/platform | src/syncloud_platform/auth/ldapauth.py | Python | gpl-3.0 | 2,558 |
import remap
# --- create file i/o objects to be used ----
def create_vertex_reader( filename ):
return remap.TextFileReader( filename, yieldkv=False )
def create_vertex_partitioner( outputdir, partition, mapperid ):
return remap.TextPartitioner( outputdir, partition, mapperid )
NUM_VERTICES = 10
# ---- pag... | gtoonstra/remap | examples/pagerank/pagerank.py | Python | mit | 1,106 |
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
#
import sys, os, subprocess,time
from TouchStyle import *
from launcher import LauncherPlugin
SCRIPT = "/opt/fischertechnik/start-txtcontrol"
# subclass the txtwidget to catch the close event
class FTGUIBaseWidget(TouchBaseWidget):
def __init__(self):
Touch... | ski7777/ftcommunity-TXT | board/fischertechnik/TXT/rootfs/opt/ftc/apps/system/ftgui/ftgui.py | Python | gpl-3.0 | 1,041 |
import tests.model_control.test_ozone_custom_models_enabled as testmod
testmod.build_model( ['BoxCox'] , ['PolyTrend'] , ['Seasonal_WeekOfYear'] , ['AR'] ); | antoinecarme/pyaf | tests/model_control/detailed/transf_BoxCox/model_control_one_enabled_BoxCox_PolyTrend_Seasonal_WeekOfYear_AR.py | Python | bsd-3-clause | 158 |
# Write a function to delete a node (except the tail) in a singly linked list,
# given only access to that node.
#
# Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node
# with value 3, the linked list should become 1 -> 2 -> 4 after calling your function.
#
# time: O(1)
# space: O(1)
# Defini... | RobinCPC/algorithm-practice | LinkedList/deleteNode.py | Python | mit | 1,861 |
def superSieve(n):
primes = [0 for i in xrange(n+1)]
p=2
while(p <= n):
if (primes[p] == 0):
for i in xrange(p * 2, n+1, p):
primes[i] += 1
p+=1
# print primes
return primes
c = 0
for i in superSieve(input()):
if i == 2: c+=... | aLagoG/kygerand | ger/TTP/SV4/3355.py | Python | mit | 330 |
#!/usr/bin/env python3
#
# author == __gandhi__
# ngakan.gandhi@packet-systems.com
import pexpect
import sys
import os
import json
import time
import re
# Load node user and password configuration file
def load_node_config(node_config_file):
with open(node_config_file) as node_confile:
retu... | GandhiNN/StarOS-cactipy | sgsnmme/get2gAttachSR.py | Python | mit | 5,752 |
import pytest
from stellar_sdk import AuthorizationFlag, MuxedAccount, Operation, SetOptions, Signer
from stellar_sdk.utils import sha256
class TestSetOptions:
AUTHORIZATION_REQUIRED = 1
AUTHORIZATION_REVOCABLE = 2
AUTHORIZATION_IMMUTABLE = 4
AUTHORIZATION_CLAWBACK_ENABLED = 8
@pytest.mark.param... | StellarCN/py-stellar-base | tests/operation/test_set_options.py | Python | apache-2.0 | 5,429 |
"""
mfzon module. Contains the ModflowZone class. Note that the user can access
the ModflowZone class as `flopy.modflow.ModflowZone`.
Additional information for this MODFLOW package can be found at the `Online
MODFLOW Guide
<http://water.usgs.gov/ogw/modflow-nwt/MODFLOW-NWT-Guide/zone.htm>`_.
"""
import sys... | mrustl/flopy | flopy/modflow/mfzon.py | Python | bsd-3-clause | 5,026 |
# -*- coding: utf-8 -*-
#
# Copyright (c) 2007-2008 The PyAMF Project.
# See LICENSE for details.
"""
Tests for Local Shared Object (LSO) Implementation.
@author: U{Nick Joyce<mailto:nick@boxdesign.co.uk>}
@since: 0.1.0
"""
import unittest, os.path, warnings
import pyamf
from pyamf import sol
warnings.simplefilte... | jamesward-demo/air-quick-fix | AIRQuickFixServer/pyamf/tests/test_sol.py | Python | apache-2.0 | 6,453 |
# -*- coding: utf-8 -*-
# Scrapy settings for clutchfans project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
# http://doc.scrapy.org/en/latest/topics/settings.html
# http://scrapy.readthedocs.org/en/lat... | CodeJuan/clutchfans_spider | clutchfans/clutchfans/settings.py | Python | mit | 3,020 |
import sys
import sip
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)
from PyQt4 import (
QtCore,
QtGui
)
from PyQt4.QtCore import Qt
import fancyqt.firefox
from dummy import Ui_DummyWidget
class DummyWidget(QtGui.QWidget, Ui_DummyWidget):
def __init__(self, app, parent=None):
super(Dumm... | datalyze-solutions/FancyQt | examples/TestApp.py | Python | mit | 2,077 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-08-18 12:04
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('rest_api', '0009_auto_20170818_1147'),
]
operation... | alexiwamoto/django-rest-api | rest_api/migrations/0010_auto_20170818_1204.py | Python | mit | 810 |
import pytest
from learning import parse_csv, weighted_mode, weighted_replicate
def test_parse_csv():
assert parse_csv('1, 2, 3 \n 0, 2, na') == [[1, 2, 3], [0, 2, 'na']]
def test_weighted_mode():
assert weighted_mode('abbaa', [1, 2, 3, 1, 2]) == 'b'
def test_weighted_replicate():
assert weighted_repl... | JoeLaMartina/aima-python | tests/test_learning.py | Python | mit | 371 |
# -*- coding: 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 'Profile'
db.create_table('edxval_profile', (
('id', self.gf('django.db.models.fi... | GbalsaC/bitnamiP | edx-val/edxval/migrations/0001_initial.py | Python | agpl-3.0 | 7,559 |
from nanoplay import PayloadProtocol, ControlProtocol, Player, CustomServer
| nanonyme/nanoplay | nanoplay/__init__.py | Python | mit | 76 |
'''
Created on Aug 1, 2014
@author: tangliuxiang
'''
import tempfile
import os
import shutil
import sys
from internal import bootimg
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
from common.andprop import andprop
BOOT = "boot"
RECOVERY = "recovery"
SYSTEM = "system... | FlymeOS/tools | bootimgpack/pull/imagetype.py | Python | apache-2.0 | 2,575 |
# Code from Chapter 16 of Machine Learning: An Algorithmic Perspective (2nd Edition)
# by Stephen Marsland (http://stephenmonika.net)
# You are free to use, change, or redistribute the code in any way you wish for
# non-commercial purposes, but please maintain the name of the original author.
# This code comes with n... | Anderson-Lab/anderson-lab.github.io | csc_466_2021_spring/MLCode/Ch16/EKF.py | Python | mit | 2,717 |
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | ppwwyyxx/tensorflow | tensorflow/python/eager/execute.py | Python | apache-2.0 | 11,108 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
class CloudFlareDNS(object):
"""
CloudFlare Backend for Python DNS Failover
"""
def __init__(self, email, key, zone, ttl=1,
url='https://www.cloudflare.com/api_json.html'):
"""
Sets up a CloudFlareDNS back... | 1it/python-dns-failover | dns_failover/backends.py | Python | bsd-3-clause | 4,136 |
import datetime
import contacts.models as cont
def set_edd_calls(email_body):
''' Set 14 day post edd call if still pregnant on edd
To be run every night at 1am'''
email_body.append( "***** Set EDD Calls *****\n" )
yesterday = datetime.date.today() - datetime.timedelta(days=1)
edd_today = cont.C... | tperrier/mwachx | utils/management/commands/command_utils.py | Python | apache-2.0 | 617 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import omero
import omero.clients
from omero.rtypes import rdouble
roi = omero.model.RoiI()
ellipse = omero.model.EllipseI()
ellipse.setX(rdouble(1))
| openmicroscopy/openmicroscopy | examples/RegionsOfInterest/Main.py | Python | gpl-2.0 | 197 |
from django.shortcuts import render
from django.views.generic.edit import FormView
from apps.clientes.models import PerfilCliente
from django.core.urlresolvers import reverse_lazy
from django.views.generic.base import TemplateView
from apps.clientes.forms import UserForm
from django.views.generic.list import ListView
... | acs-um/gestion-turnos | apps/clientes/views.py | Python | mit | 1,171 |
# ==============================================================================
# Copyright 2019 - Philip Paquette
#
# NOTICE: 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 rest... | diplomacy/research | diplomacy_research/models/training/supervised/standalone.py | Python | mit | 13,083 |
import json
from os import path
import simplejson
from django.forms.widgets import Input
from django.utils.safestring import mark_safe
from django.template.loader import get_template
from django.conf import settings
from django.template.context_processors import csrf
from django.forms.utils import flatatt
from django... | erudit/django-plupload | plupload/widgets.py | Python | gpl-2.0 | 2,267 |
#!/usr/bin/python
# 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
ANSIBLE_METADATA = {'metadata_version': '1.0',
'status': ['preview'],
... | jbenden/ansible | lib/ansible/modules/cloud/amazon/ec2_vpc_igw_facts.py | Python | gpl-3.0 | 4,808 |
from __future__ import absolute_import, print_function
import logging
from sentry.auth.view import AuthView, ConfigureView
from sentry.utils import json
from .constants import DOMAIN_BLOCKLIST, ERR_INVALID_DOMAIN, ERR_INVALID_RESPONSE
from .utils import urlsafe_b64decode
logger = logging.getLogger("sentry.auth.goog... | mvaled/sentry | src/sentry/auth/providers/google/views.py | Python | bsd-3-clause | 2,556 |
"""
.. module:: pokeradio.context_processors
:synopsis: Custom context processors for returning extra data into
the request context.
"""
from django.conf import settings
from django.contrib.sites.models import Site
from .models import Brand
def domain(request):
""" Get current site information.
:param... | pokelondon/pokeradio | web/pokeradio/context_processors.py | Python | gpl-3.0 | 1,222 |
import pytest
from pandas import DataFrame
import pandas._testing as tm
class TestIndexingSlow:
@pytest.mark.slow
def test_large_dataframe_indexing(self):
# GH10692
result = DataFrame({"x": range(10 ** 6)}, dtype="int64")
result.loc[len(result)] = len(result) + 1
expected = Da... | TomAugspurger/pandas | pandas/tests/indexing/test_indexing_slow.py | Python | bsd-3-clause | 418 |
"""
Convenience interface to N-D interpolation
.. versionadded:: 0.9
"""
from __future__ import division, print_function, absolute_import
import numpy as np
from .interpnd import LinearNDInterpolator, NDInterpolatorBase, \
CloughTocher2DInterpolator, _ndim_coords_from_arrays
from scipy.spatial import cKDTree
_... | juliantaylor/scipy | scipy/interpolate/ndgriddata.py | Python | bsd-3-clause | 6,274 |
# 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... | quantumlib/OpenFermion | src/openfermion/measurements/qubit_partitioning.py | Python | apache-2.0 | 9,586 |
# 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... | memo/tensorflow | tensorflow/python/ops/rnn.py | Python | apache-2.0 | 44,312 |
from common import Modules, data_strings_wide, load_yara_rules, PEParseModule, ModuleMetadata
class Cythosia(PEParseModule):
def __init__(self):
md = ModuleMetadata(
module_name="cythosia",
bot_name="Cythosia",
description="DDoS Bot",
authors=["Brian Wallace... | bwall/bamfdetect | BAMF_Detect/modules/cythosia.py | Python | mit | 1,103 |
from distutils.core import setup
import os
# Stolen from django-registration
# Compile the list of packages available, because distutils doesn't have
# an easy way to do this.
packages, data_files = [], []
root_dir = os.path.dirname(__file__)
if root_dir:
os.chdir(root_dir)
for dirpath, dirnames, filenames in os.... | tswicegood/django-staticfiles-fitvidsjs | setup.py | Python | apache-2.0 | 1,572 |
#!/usr/bin/env python
import numpy
class KalmanFilter():
"""
Kalman filter implementation.
Assumes that:
1. State variables are INDEPENDENT of each other.
2. Values for R and Q are the same for all state variables
3. The initial guess for S (variance) is the same for all state variables
... | OSUrobotics/privacy-interfaces | filtering/probability_filters/src/probability_filters/__init__.py | Python | mit | 2,019 |
import json, requests, datetime, os
from database import insertBlue
now = datetime.datetime.today()
if now.weekday() < 5 and now.hour >= 10 and now.hour < 23 or 'RUN_ALWAYS' in os.environ:
r = requests.get('https://api-contenidos.lanacion.com.ar/json/V3/economia/cotizacionblue/DBLUE')
if r:
data = r.j... | Bluelytics/bluescraper | src/scrape_lanacion.py | Python | agpl-3.0 | 430 |
#!/usr/bin/env python3
def compress(input_string):
"""Compresses the given input string"""
#Build the dictionary
dict_size = 256 #All ASCII characters
dictionary = {chr(i): i for i in range(dict_size)}
buffer = ""
result = []
for ch in input_string:
tmp = buffer + ch
if tm... | niceandcoolusername/cosmos | code/compression/lossless_compression/lempel-ziv-welch/lzw.py | Python | gpl-3.0 | 1,456 |
#!/usr/bin/env python
#
# git-p4.py -- A tool for bidirectional operation between a Perforce depot and git.
#
# Author: Simon Hausmann <simon@lst.de>
# Copyright: 2007 Simon Hausmann <simon@lst.de>
# 2007 Trolltech ASA
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
#
import sys
if sys.he... | sachinstranger/DoubleLinkedList | git-p4.py | Python | gpl-2.0 | 137,467 |
#!/usr/bin/env python
import optparse
import urlparse
import httplib2
import simplejson
join = lambda *args: '/'.join(args)
safestr = lambda obj: obj if isinstance(obj, basestring) else str(obj)
def dataunfold(root, data):
if isinstance(data, dict):
for k, v in data.iteritems():
for i, j in... | woome/drivel | drivelstats.py | Python | gpl-3.0 | 1,113 |
# apis_v1/views/views_voter.py
# Brought to you by We Vote. Be good.
# -*- coding: UTF-8 -*-
from config.base import get_environment_variable
from django.views.decorators.csrf import csrf_exempt
from reaction.controllers import reaction_like_count_for_api, voter_reaction_like_off_save_for_api, \
voter_reaction_lik... | wevote/WeVoteServer | apis_v1/views/views_reaction.py | Python | mit | 3,521 |
data = (
((-1.000000, 0.900000), (0.900000, -1.000000)),
((-1.000000, 0.600000), (0.600000, -1.000000)),
((-1.000000, 0.500000), (0.500000, -1.000000)),
((-1.000000, 0.400000), (0.400000, -1.000000)),
((-1.000000, -0.900000), (-0.900000, -1.000000)),
((-1.000000, -0.600000), (-0.600000, -1.000000)),
((-1.000000, -0.500... | ideasman42/isect_segments-bentley_ottmann | tests/data/test_isect_crosshatch_01.py | Python | mit | 3,751 |
# Copyright 2013 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in... | openstack/keystone | keystone/auth/__init__.py | Python | apache-2.0 | 713 |
#!/usr/bin/env python
# Copyright (c) 2010-2011 Stanford University
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS"... | jcarreira/ramcloud | scripts/recovery.py | Python | isc | 14,559 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('login', '0008_auto_20151216_0932'),
('chatroom', '0006_auto_20160106_0503'),
]
operations = [
migrations.CreateModel... | sonicyang/chiphub | chatroom/migrations/0007_auto_20160106_0538.py | Python | mit | 1,211 |
# coding=utf-8
# Copyright 2022 The Tensor2Tensor Authors.
#
# 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... | tensorflow/tensor2tensor | tensor2tensor/models/__init__.py | Python | apache-2.0 | 4,406 |
Import("*")
# This file is generated with mmp2sconscript
from scons_symbian import *
target = "vorbis"
targettype = "lib"
libraries = []
# Static libs
libraries += []
uid3 = 0
sources = ['deps/vorbis/lib/analysis.c',
'deps/vorbis/lib/barkmel.c',
'deps/vorbis/lib/bitrate.c',
'deps/vorbis/lib/block.c',
'd... | gmittal/aar-nlp-research-2016 | src/pygame-pygame-6625feb3fc7f/symbian/SConscript.Vorbis.py | Python | mit | 1,391 |
#!/usr/bin/python
#
# Copyright (C) 2007, 2008 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 applicabl... | matclayton/OpenSocial-Python | tests/run_online_tests.py | Python | apache-2.0 | 1,350 |
class Vec3:
def __init__(self, x=0, y=0, z=0):
self.x = x
self.y = y
self.z = z
def __add__(self, rhs):
c = self.clone()
c += rhs
return c
def __iadd__(self, rhs):
self.x += rhs.x
self.y += rhs.y
self.z += rhs.z
return self
... | whaleygeek/mb_deathstar | starwars/mcpi/vec3.py | Python | mit | 2,314 |
# peppy Copyright (c) 2006-2010 Rob McMullen
# Licenced under the GPLv2; see http://peppy.flipturn.org for more info
import os, re, fnmatch
import cPickle as pickle
from wx.lib.pubsub import Publisher
import peppy.vfs as vfs
from peppy.buffers import *
from peppy.sidebar import *
from peppy.lib.userparams import *
f... | robmcmullen/peppy | peppy/project/project.py | Python | gpl-2.0 | 13,158 |
# Version control system repository manager.
#
# Author: Peter Odding <peter@peterodding.com>
# Last Change: March 5, 2018
# URL: https://github.com/xolox/python-vcs-repo-mgr
"""
Custom exception types raised by the `vcs-repo-mgr` package.
When `vcs-repo-mgr` encounters known errors it will raise an exception. Most o... | xolox/python-vcs-repo-mgr | vcs_repo_mgr/exceptions.py | Python | mit | 2,583 |
# -*- coding: utf-8 -*-
# Database Connection variables
DBN='postgres'
HOST='localhost'
DB='equine_website'
USER='equine_website'
MODE='fastcgi' # mod_python, fastcgi, mod_wsgi
ENV='development' # production or development
PWD='Master12131415'
# Generic configuration website variables
WEBSITE_URL='http://localhost:8... | ProfessionalIT/customers | equineclinic/src/webapps/configuration.py | Python | mit | 969 |
# 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... | nathanbjenx/cairis | cairis/data/DependencyDAO.py | Python | apache-2.0 | 5,888 |
#!/usr/bin/env python
#-*- coding:utf-8 -*-
"""
(C) 2014 Contributors to the Digital Publishing Toolkit
License: GPL3
This code has been developed as part of the [Digital Publishing Toolkit](http://digitalpublishingtoolkit.org).
with the support of Institute for [Network Cultures](http://networkcultures.org)
and [Cr... | DigitalPublishingToolkit/epubtrailer.py | epubtrailer.py | Python | lgpl-3.0 | 8,278 |
# -*- coding: utf-8 -*-
from util import admin
from samodei.models import City
class CityAdmin(admin.ModelAdmin):
pass
admin.site.register(City, CityAdmin) | wd5/jangr | samodei/admin.py | Python | bsd-3-clause | 158 |
import problem
bugs = set()
for prob in problem.list():
if not hasattr(prob, 'reported_to'):
continue
for line in prob.reported_to.splitlines():
if line.startswith('Bugzilla:'):
bug_num = int(line.split('=')[-1])
bugs.add(bug_num)
print(bugs)
| mhabrnal/abrt | src/python-problem/examples/bugzilla_numbers.py | Python | gpl-2.0 | 295 |
# -*- coding: utf-8 -*-
import base64
import csv
import functools
import glob
import itertools
import jinja2
import logging
import operator
import datetime
import hashlib
import os
import re
import json
import sys
import time
import zlib
from xml.etree import ElementTree
from cStringIO import StringIO
import babel.me... | orchidinfosys/odoo | addons/web/controllers/main.py | Python | gpl-3.0 | 62,663 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.