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 ase import Atoms
from gpaw import GPAW
from gpaw.test import equal
s = Atoms('Cl')
s.center(vacuum=3)
c = GPAW(xc='PBE', nbands=-4, charge=-1, h=0.3)
s.set_calculator(c)
e = s.get_potential_energy()
niter = c.get_number_of_iterations()
print e, niter
energy_tolerance = 0.0003
niter_tolerance = 0
equal(e, -2.893... | ajylee/gpaw-rtxs | gpaw/test/Cl_minus.py | Python | gpl-3.0 | 374 |
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# This module contains code for managing WebIDL files and bindings for
# the build system.
from __future__ import unico... | michath/ConMonkey | dom/bindings/mozwebidlcodegen/__init__.py | Python | mpl-2.0 | 20,812 |
#!/usr/bin/env python
try:
from email.generator import _make_boundary as choose_boundary
from urllib.request import urlopen
from io import BufferedReader as file
except ImportError:
from mimetools import choose_boundary
from urllib2 import urlopen
import mimetypes
import os
import re
import sys
fr... | dongjoon-hyun/python-telegram-bot | telegram/inputfile.py | Python | gpl-2.0 | 4,626 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('events', '0009_auto_20161120_1917'),
... | SebastinSanty/QuarkWebsite2017 | events/migrations/0010_workshop_participants.py | Python | apache-2.0 | 802 |
'''
Classes for loading a QWidget designed in QT Designer as MainWindow, Dialog or Widget
Examples of how to use can be found in UseQtGuiLoader.py
@Created on 13/3/2013
@modified
@version:1.5 (4/7-2013)
@change: 1.5 changed sys.exit(app.exec_()) to app.exec_() to avoid SystemExit exception when running from IPython
... | DTUWindEnergy/Python4WindEnergy | py4we/test/FBG Output/QtGuiLoader.py | Python | apache-2.0 | 7,420 |
"""
Views for serving static textbooks.
"""
from django.contrib.auth.decorators import login_required
from django.http import Http404
from mitxmako.shortcuts import render_to_response
from courseware.access import has_access
from courseware.courses import get_course_with_access
from notes.utils import notes_enabled_f... | abhinavp13/IITBX-edx-platform-dev | lms/djangoapps/staticbook/views.py | Python | agpl-3.0 | 4,946 |
# 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
# distributed under t... | annegentle/magnum | magnum/tests/unit/common/test_clients.py | Python | apache-2.0 | 9,608 |
# -*- coding: utf-8 -*-
import django.db.models.deletion
import django.utils.timezone
import model_utils.fields
from django.conf import settings
from django.db import migrations, models
from opaque_keys.edx.django.models import CourseKeyField
import lms.djangoapps.verify_student.models
class Migration(migrations.M... | stvstnfrd/edx-platform | lms/djangoapps/verify_student/migrations/0001_initial.py | Python | agpl-3.0 | 9,330 |
while True:
n = input()
if(n==42):
break
else:
print n | aqfaridi/Code-Online-Judge | web/env/Main1130/Main1130.py | Python | mit | 87 |
import logging
import multiprocessing
import sys
import time
from data import Pointer, SUCC_LIST_LEN
from node import Node
def launch_node(ip, pred, succ_list):
node = Node(ip=ip, pred=pred, succ_list=succ_list)
p = multiprocessing.Process(target=node.start)
p.daemon = True
p.start()
return node,... | DistributedComponents/verdi-chord | systems/chordpy/demo.py | Python | bsd-2-clause | 1,313 |
# Copyright 2008-2014 Nokia Solutions and Networks
#
# 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... | userzimmermann/robotframework-python3 | src/robot/utils/robotenv.py | Python | apache-2.0 | 2,435 |
import numpy as np
from game.displays.null_display import NullDisplay
from game.displays.asci_display import ASCIDisplay
class RandomPlayer:
def __init__(self, player_no):
self.player_no = player_no
def get_input(self, board):
empty_indexes = np.where(board == 0)
zipped = np.column_stack(empty_indexes... | scooler/tic-tac-toe | game/players/random_player.py | Python | mit | 448 |
from extraction.runnables import Extractor, RunnableError, ExtractorResult
import extraction.utils
import csxextract.config as config
import csxextract.interfaces as interfaces
import csxextract.filters as filters
import csxextract.utils as utils
import defusedxml.ElementTree as safeET
import xml.etree.ElementTree as E... | SeerLabs/new-csx-extractor | csxextract/extractors/parscit.py | Python | apache-2.0 | 1,694 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015 Glencoe Software, Inc. All Rights Reserved.
# Use is subject to license terms supplied in LICENSE.txt
#
# 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
# th... | simleo/openmicroscopy | components/tools/OmeroPy/test/integration/tablestest/test_populate_metadata.py | Python | gpl-2.0 | 4,185 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2014 Fredrik Strandin <fredrik@strandin.name>
#
# Licensed under MIT
"""RSS Torrent Download Client"""
from __future__ import print_function
try:
import ConfigParser as configparser
except ImportError:
import configparser
import feedparser
cl... | kd35a/rtdc | rtdc.py | Python | mit | 1,573 |
# -*- coding: utf-8 -*-
###############################################################################
# Name: arpeggio.py
# Purpose: PEG parser interpreter
# Author: Igor R. Dejanović <igor DOT dejanovic AT gmail DOT com>
# Copyright: (c) 2009-2015 Igor R. Dejanović <igor DOT dejanovic AT gmail DOT com>
# License: MI... | renatav/GraphDrawing | GraphLayoutDSL/target/classes/modules/arpeggio/__init__.py | Python | mit | 57,497 |
# ===============================================================================
# Copyright 2019 ross
#
# 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/LICE... | UManPychron/pychron | pychron/experiment/automated_run/mass_spec_persistence_spec.py | Python | apache-2.0 | 11,571 |
"""Tests for the metadata classes."""
import pytest
from io import StringIO
from ncbi_genome_download import metadata
def test_init():
"""Test initialising the MetaData object."""
metadata.clear()
with pytest.raises(ValueError):
metadata.get(['alice', 'bob'])
metadata.get()
def test_writ... | kblin/ncbi-genome-download | tests/test_metadata.py | Python | apache-2.0 | 812 |
# -*- coding: utf-8 -*-
default_app_config = 'homepage.apps.HomepageConfig'
| echodelt/django-auth-skel-project | homepage/__init__.py | Python | mit | 77 |
"""
Write a program that reads data
from property files.
Each line in the file can either be:
An empty line
A comment line (Start with #)
A property line (of the form key = value)
Write a program that takes a property file name and key
as command line arguments and prints the requested value
"""
import sy... | ynonp/python-examples | 18_regexp_lab/01.py | Python | mit | 665 |
from pyspectator.convert import UnitByte
def test_get_name_reduction():
# Existing reduction
reduction = UnitByte.get_name_reduction(UnitByte.megabyte)
assert reduction is 'MB'
# Non-existing reduction
reduction = UnitByte.get_name_reduction('Non-existing reduction')
assert reduction is None
| uzumaxy/pyspectator | test/test_convert.py | Python | bsd-3-clause | 319 |
# coding=utf-8
# Copyright 2020 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to ... | googleinterns/cabby | cabby/rvs/generate_rvs.py | Python | apache-2.0 | 3,550 |
# -*- coding: utf-8 -*-
"""
Text utilities to be used
@author: x003621
"""
from __future__ import division
import matplotlib as mpl
def text_getinfo_availablesystemfonts():
return mpl.font_manager.findSystemFonts(fontpaths=None)
#def text_set_properties(family = 'sans-serif', style = 'normal',
# ... | kikocorreoso/mplutils | mplutils/text.py | Python | mit | 1,463 |
# CSSPrefixer
# Copyright 2010-2012 Greg V. <floatboth@me.com>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable la... | nabsboss/CouchPotatoServer | libs/cssprefixer/rules.py | Python | gpl-3.0 | 10,071 |
"""Python wrappers around TensorFlow ops.
This file is MACHINE GENERATED! Do not edit.
Original C++ source file: stateless_random_ops.cc
"""
import collections as _collections
import six as _six
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
from tensorflow.python.eager import context as _cont... | ryfeus/lambda-packs | Keras_tensorflow_nightly/source2.7/tensorflow/contrib/stateless/gen_stateless_random_ops.py | Python | mit | 13,285 |
import unittest
import inventory
import gameObjects
import objectTypes
import pygame
class TestInventory(unittest.TestCase):
def setUp(self):
self.inv = inv = inventory.Inventory()
pygame.init()
screen = pygame.display.set_mode((100,100))
self.ob1 = ob1 = gameObjects.GObject('apple... | anokata/pythonPetProjects | surgame/src/tests.py | Python | mit | 1,467 |
#!/usr/bin/env python
# encoding: utf-8
"""
A simple python script template.
Created by yetship at 2017-08-30 19:10
"""
import sys
def main(arguments):
pass
if __name__ == '__main__':
sys.exit(main(sys.argv[1:])) | yetship/blog_codes | python/libev/pyev-demo/fork-test.py | Python | gpl-3.0 | 234 |
# setup.py
# para gerar %run setup.py py2exe
from distutils.core import setup
import py2exe
setup(console=["Hex2Zip.py"])
| flavio-casacurta/File-FixedS | setup.py | Python | mit | 123 |
# A script to import and normalize the prostate cancer metabolomics data from Sreekumar. Our strategy will be to impute in the same way as the remainder of the Metabolon data, which is to use the lowest recorded value as the imputed value for the remainder of the samples, then median normalize each row.
import os, sys... | dfci/pancanmet_analysis | import/studyspecific_DEPRECATED/importLGG.py | Python | lgpl-3.0 | 1,359 |
#!/usr/bin/python2
import os, argparse, sys, digitalocean, time, re
'''
Author: mtask@github.com
Program: digitalocean-tk.py
Toolkit for managing Digital Ocean's Droplets.
'''
class DigOcean(object):
def __init__(self):
self.blk = '\033[0m' # Black - Regular
self.warn = '\033[93m' # yellow
... | mtask/digitalocean-tk | digitalocean-tk/digitalocean-tk.py | Python | mit | 14,083 |
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-04-02 17:35
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('BestRoute', '0003_auto_20170402_1704'),
]
operations = [
migrations.RemoveField(
... | christinagee/Safe-Route-Home | BestRoute/migrations/0004_remove_crimedatapoint_occurred_on_date.py | Python | mit | 413 |
import json
import requests
from .site import Site
from .errors import APIError
class StackExchange(object):
"""
A simple wrapper for the Stack Exchange API V2.2.
This doesn't consider rate limiting or any important things like
that. Careless use could result in being blocked.
This doesn't sup... | jeremybanks/stack-suggestions-bot | src/stackexchange/stackexchange.py | Python | mit | 2,984 |
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Copyright 2011-2014, Nigel Small
#
# 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
#
# Unle... | nicolewhite/py2neo | py2neo/server.py | Python | apache-2.0 | 10,399 |
from django.conf.urls.defaults import *
from saved_searches.views import SavedSearchView
urlpatterns = patterns('',
url(r'^search/$', SavedSearchView(), name='search'),
url(r'^search_stats/', include('saved_searches.urls')),
)
| dablak/saved_searches | tests/test_urls.py | Python | bsd-3-clause | 237 |
import argparse
from omftools.pyshadowdive.sounds import SoundFile
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Decompile SOUNDS.DAT file to JSON")
parser.add_argument("input_file", help="Input .AF file")
parser.add_argument("output_file", help="Output .json file")
args = p... | omf2097/pyomftools | omftools/cli/sounds_decompile.py | Python | mit | 435 |
"""
This module implements machine learning algorithms and utilities,
complementary to Scikit-Learn.
"""
# Carl is free software; you can redistribute it and/or modify it
# under the terms of the Revised BSD License; see LICENSE file for
# more details.
from .base import as_classifier
from .base import check_cv
from ... | diana-hep/carl | carl/learning/__init__.py | Python | bsd-3-clause | 810 |
# -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module tests some of the methods related to the ``HTML``
reader/writer and aims to document its functionality.
Requires `BeautifulSoup <http://www.crummy.com/software/BeautifulSoup/>`_
to be installed.
"""
from io impor... | funbaker/astropy | astropy/io/ascii/tests/test_html.py | Python | bsd-3-clause | 22,312 |
# Copyright (c) 2007 The Regents of The University of Michigan
# 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 ... | aferr/LatticeMemCtl | src/cpu/simple/TimingSimpleCPU.py | Python | bsd-3-clause | 1,708 |
# 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_11_01/operations/_load_balancer_backend_address_pools_operations.py | Python | mit | 8,928 |
"""Module containing logic for handling settings."""
# Copyright 2018 Ian Stapleton Cordasco
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
... | pypa/twine | twine/settings.py | Python | apache-2.0 | 12,264 |
# Copyright 2009-2014 Justin Riley
#
# This file is part of StarCluster.
#
# StarCluster is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later ... | schrodinger/StarCluster | starcluster/tests/test_live.py | Python | gpl-3.0 | 2,488 |
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | googleapis/nodejs-datastore | owlbot.py | Python | apache-2.0 | 2,352 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cdadmap', '0036_auto_20151105_1350'),
]
operations = [
migrations.AddField(
model_name='locationpanel',
... | NiJeLorg/CDADMap | cdad/cdadmap/migrations/0037_auto_20151106_1149.py | Python | mit | 1,088 |
# -*- coding: utf-8 -*-
# Copyright 2012 Ofir Brukner <ofirbrukner@gmail.com>
#
# This file is part of subliminal.
#
# subliminal is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 3 of the ... | jamesbeebop/CouchPotatoServer | libs/subliminal/services/subscenter.py | Python | gpl-3.0 | 4,387 |
###############################################################################
#
# Tests for XlsxWriter.
#
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c), 2013-2022, John McNamara, jmcnamara@cpan.org
#
from ..excel_comparison_test import ExcelComparisonTest
from ...workbook import Workbook
class TestCompar... | jmcnamara/XlsxWriter | xlsxwriter/test/comparison/test_textbox38.py | Python | bsd-2-clause | 1,661 |
import requests
import re
import sys
from datetime import date, timedelta
from utils import update_progress, open_session, base_url, regex
# patron_id = '1000156'
# bc = '50148738'
#
# r = requests.get(base_url + 'patrons/' + patron_id + '?fields=names%2Caddresses', headers={"Authorization": "Bearer " + token})
#
patr... | jgarcial/star_migration | API/fix_patron_addresses.py | Python | gpl-3.0 | 5,513 |
from .base import basis,MAXPRINT
from .tensor import tensor_basis
import numpy as _np
from scipy import sparse as _sp
from scipy.special import hyp2f1, binom
import warnings
_dtypes={"f":_np.float32,"d":_np.float64,"F":_np.complex64,"D":_np.complex128}
__all__ = ["photon_basis","ho_basis","coherent_state","photon_... | weinbe58/QuSpin | quspin/basis/photon.py | Python | bsd-3-clause | 31,310 |
# You can get these by creating a new app at
# https://apps.twitter.com/
TWITTER_CONSUMER_KEY = 'fill_me_in'
TWITTER_CONSUMER_SECRET = 'fill_me_in'
TWITTER_ACCESS_TOKEN = 'fill_me_in'
TWITTER_ACCESS_SECRET = 'fill_me_in'
AUTH_USER = 'admin'
AUTH_PASS = 'password'
| publicscience/glimpse | config-sample.py | Python | mit | 265 |
# -*- coding: UTF-8 -*-
__all__ = (
'AddressValidationService',
'AccountInformation',
'load_accountinfo_from_file',
'ProcessShipmentRequest',
'RateService',
)
from .api import VERSION as __version__ # noqa
from .address_validation_service import AddressValidationService
from .ship_services import ... | fulfilio/py-fedex | fedex/__init__.py | Python | bsd-3-clause | 453 |
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2011 OpenERP S.A (<http://www.openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms ... | diogocs1/comps | web/addons/survey_crm/survey.py | Python | apache-2.0 | 2,051 |
# -*- coding: utf-8 -*-
# This file is part of INSPIRE.
# Copyright (C) 2015 CERN.
#
# Invenio 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 v... | Dziolas/inspire-next | inspire/testsuite/workflows/harvesting_fixture.py | Python | gpl-2.0 | 4,383 |
from functools import update_wrapper
from django.http import Http404, HttpResponseRedirect
from django.contrib.admin import ModelAdmin, actions
from django.contrib.admin.forms import AdminAuthenticationForm
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.contenttypes import views as contenttype_... | mammique/django | django/contrib/admin/sites.py | Python | bsd-3-clause | 18,792 |
"""
import urllib; exec urllib.urlopen('https://raw.githubusercontent.com/aldmbmtl/tools/master/installer.py').read().replace('<USER_TOKEN>', ''); import tools
"""
# handle future compatibility
from __future__ import print_function
# python imports
import re
import os
import sys
import urllib
import zipfile
try:
... | aldmbmtl/FloatingTools | installer.py | Python | mit | 4,148 |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright 2012 codestation
#
# 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
#
# Unl... | codestation/python-phpbb3 | phpbb.py | Python | apache-2.0 | 15,869 |
def evaluate(self):
value = 2.0*self.x2
return value
| idaholab/raven | tests/framework/Samplers/EnsembledSampler/EnsembleForwardTestFunction/funct2.py | Python | apache-2.0 | 57 |
from .recognition import *
from .branchings import *
from .mst import *
| ltiao/networkx | networkx/algorithms/tree/__init__.py | Python | bsd-3-clause | 72 |
#----------------------------------------------------------------------
#This utility sets up the python configuration files so as to
#allow Python to find files in a specified directory, regardless
#of what directory the user is working from. This is typically
#used to create a directory where the user will put resou... | CommonClimate/teaching_notebooks | GEOL351/CoursewareModules/setpath.py | Python | mit | 5,073 |
import nc_read as nc
import sys
import math
# a base class for hpgl parsers, and maybe others
class NumReader(nc.Parser):
def __init__(self):
nc.Parser.__init__(self)
def get_number(self):
number = ''
# skip spaces and commas at start of number
while(self.line... | asmuelle/heekscnc | nc/num_reader.py | Python | bsd-3-clause | 1,760 |
# Copyright (c) 2010 Google Inc. 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 conditions and the ... | youtube/cobalt | third_party/blink/Tools/Scripts/webkitpy/common/net/network_transaction_unittest.py | Python | bsd-3-clause | 4,055 |
#!/usr/bin/env python
"""Unit tests run as PYTHONPATH=../../.. python3 ./test_valve.py."""
# Copyright (C) 2015 Research and Innovation Advanced Network New Zealand Ltd.
# Copyright (C) 2015--2018 The Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except i... | trentindav/faucet | tests/unit/faucet/test_valve.py | Python | apache-2.0 | 79,108 |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.db.migrations.operations.special import RunPython
import djorm_pgfulltext.fields
from django.db import connection
import os
def load_initial_sql(*args, **kw):
fn = os.path.join(os.path.dirname(__fi... | ministryofjustice/djorm-ext-pgfulltext | djorm_pgfulltext/tests/migrations/0001_initial.py | Python | bsd-3-clause | 2,888 |
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
# Copyright 2012 Nebula, Inc.
# Copyright (c) 2012 X.commerce, a business unit of eBay Inc.
#
# Licensed under th... | r-icarus/openstack_microserver | openstack_dashboard/test/api_tests/nova_tests.py | Python | apache-2.0 | 8,626 |
#@author: cchen
#It will be updated later
class Solution:
# @return an integer
def threeSumClosest(self, num, target):
num.sort()
mindiff=100000
res=0
for i in range(len(num)):
left=i+1; right=len(num)-1
while left<right:
sum=num[i]+num[le... | Chasego/cod | leetcode/016-3Sum-Closest/ThrSumClose_001.py | Python | mit | 561 |
from toee import *
import tpactions
import tpdp
def GetActionName():
return "Hail of Arrows"
def GetActionDefinitionFlags():
return D20ADF_MagicEffectTargeting | D20ADF_Breaks_Concentration | D20ADF_TriggersCombat
def GetTargetingClassification():
return D20TC_CastSpell
def GetActionCostType():
... | GrognardsFromHell/TemplePlus | tpdatasrc/tpgamefiles/rules/d20_actions/action02003_arc_archer_hail_of_arrows.py | Python | mit | 1,736 |
from __future__ import absolute_import
# import models into model package
from .error_response import ErrorResponse
from .manager_1_0_0_command_connect_types_supported import Manager100CommandConnectTypesSupported
from .manager_1_0_0_command_shell import Manager100CommandShell
from .manager_1_0_0_force_failover import... | jlongever/redfish-client-python | on_http_redfish_1_0/models/__init__.py | Python | apache-2.0 | 9,652 |
from dedupe import predicates
class Variable(object) :
def __len__(self) :
return 1
def __repr__(self) :
return self.name
def __hash__(self) :
return hash(self.name)
def __eq__(self, other) :
return self.name == other.name
def __init__(self, definition) :
... | tfmorris/dedupe | dedupe/variables/base.py | Python | mit | 2,878 |
__author__ = 'Joe Linn'
import unittest
import pylastica
from tests.base import Base
class MyTestCase(unittest.TestCase, Base):
def setUp(self):
self._index = self._create_index('test_functionscore')
self._doc_type = self._index.get_doc_type('test')
self._doc_type.mapping = {
... | jlinn/pylastica | tests/query/test_functionscore.py | Python | apache-2.0 | 3,680 |
# -*- coding: utf-8 -*-
#
# Tablib documentation build configuration file, created by
# sphinx-quickstart on Tue Oct 5 15:25:21 2010.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All ... | intellimath/pyaxon | docs/conf.py | Python | mit | 7,395 |
# Written by Arno Bakker
# see LICENSE.txt for license information
from Tribler.Core.simpledefs import *
import Tribler.Core.Overlay.permid as permidmod
from Tribler.Core.Utilities.Crypto import RSA_keypair_to_pub_key_in_der
from M2Crypto import RSA
class LiveSourceAuthConfig:
""" Base class for conf... | egbertbouman/tribler-g | Tribler/Core/LiveSourceAuthConfig.py | Python | lgpl-2.1 | 4,077 |
#!/usr/bin/env python
import unittest
from src.boulder_io_formatter import BoulderIOFormatter
from src.sequence import Sequence
class TestBoulderIOFormatter(unittest.TestCase):
def setUp(self):
self.formatter = BoulderIOFormatter()
self.formatter.segment_lengths = {"foo_mrna": [5, 7]}
sel... | genomeannotation/capn_primer | test/boulder_io_formatter_tests.py | Python | mit | 1,296 |
# -*- mode: python; coding: utf-8; -*-
from django.conf import settings
from django.conf.urls.defaults import *
from posts.feeds import LatestPosts
from posts.models import Post
from django.views.generic import date_based
archive = {
'queryset': Post.objects.filter(is_published=True).only('title', 'slug', 'publi... | jobscry/vz-blog | posts/urls.py | Python | mit | 1,613 |
import copy
from refl1d.names import *
# Call via: refl1d generate.py --store=sim --steps=0 --simulate --noise=1e-10
data = load4("sim/generate-1-refl.datA", name="data", columns="Q dQ R dR", radiation="neutron",
L=4, dL=1e-9, simulation_range=numpy.linspace(0, 1, 5001))
Si = Material("Si", name="Si")
C... | reflectometry/direfl | tests/rough_reference/sim/generate.py | Python | mit | 1,791 |
# Natural Language Toolkit: Chunk parsing API
#
# Copyright (C) 2001-2016 NLTK Project
# Author: Edward Loper <edloper@gmail.com>
# Steven Bird <stevenbird1@gmail.com> (minor additions)
# URL: <http://nltk.org/>
# For license information, see LICENSE.TXT
##//////////////////////////////////////////////... | adazey/Muzez | libs/nltk/chunk/api.py | Python | gpl-3.0 | 1,786 |
# 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
# distributed under t... | klmitch/python-keystoneclient | keystoneclient/auth/cli.py | Python | apache-2.0 | 3,567 |
"""SCons.Tool.CVS.py
Tool-specific initialization for CVS.
There normally shouldn't be any need to import this module directly.
It will usually be imported through the generic SCons.Tool.Tool()
selection method.
"""
#
# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
#
# Permission is hereby granted, free... | bilke/OpenSG-1.8 | SConsLocal/scons-local-0.96.1/SCons/Tool/CVS.py | Python | lgpl-2.1 | 2,591 |
import urllib.request
import datetime
import argparse
import json
import sqlite3
import os.path
# --url=192.168.0.58 --method=OutdoorTemperature
def get_page(path, sub_path):
complete_url = 'http://' + path + '/' + sub_path
with urllib.request.urlopen(complete_url) as response:
full_response = respo... | henryse/pi-weather-pro | tests/stress/weather-pro/invoke_ourweather.py | Python | apache-2.0 | 3,308 |
import sys
sys.path.append('../..')
import unittest
import numpy as np
import pandas as pd
from pandas import DataFrame, Series, Index
from pandas.util.testing import assert_almost_equal
from ramp.builders import *
from ramp.estimators.base import Probabilities
from ramp.features.base import F, Map
from ramp.features... | kvh/ramp | ramp/tests/test_selectors.py | Python | mit | 1,849 |
# coding=utf-8
# Copyright 2019 The SEED 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 law or agre... | google-research/seed_rl | common/utils.py | Python | apache-2.0 | 40,896 |
# -*- coding: utf-8 -*-
#
# This file is part of Linux Show Player
#
# Copyright 2012-2016 Francesco Ceruti <ceppofrancy@gmail.com>
#
# Linux Show Player 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 ... | FrancescoCeruti/linux-show-player | lisp/layouts/cue_layout.py | Python | gpl-3.0 | 5,669 |
import six
from plivo.xml import (
PlivoXMLElement,
map_type,
BreakElement,
EmphasisElement,
LangElement,
PhonemeElement,
ProsodyElement,
)
class SElement(PlivoXMLElement):
_name = 's'
_nestable = [
'break',
'emphasis',
'lang',
'phoneme',
'p... | plivo/plivo-python | plivo/xml/sElement.py | Python | mit | 2,791 |
from __future__ import print_function, division
import os
import time
import glob
import obspy
# keep channels sampling_rate > 20Hz
# detrend, demean, taper
# filter, highpass, 0.075Hz
# divide by the gain
def select_by_sampling_rate(st, threshold=15):
st_new = obspy.Stream()
for tr in st:
if tr.stat... | wjlei1990/EarlyWarning | src/data_processing.py | Python | gpl-3.0 | 4,149 |
from rest_framework import serializers
from rest_framework_jwt.authentication import JSONWebTokenAuthentication
from django.contrib.auth import get_user_model
import datetime
import pytz
from .models import Activity
User = get_user_model()
def next_weekday(day, weekday):
days_ahead = weekday - day.weekday()
... | hellojerry/buddy | activities/serializers.py | Python | mit | 4,047 |
#! /usr/bin/env python
"""
The :py:mod:`ArchWiki.lang` submodule contains multiple functions related to
ArchWiki specific way of setting localized page titles, handling of categories
for localized pages etc.
See the documentation on `Help:i18n`_ on ArchWiki for the specification.
.. _`Help:i18n`: https://wiki.archli... | lahwaacz/wiki-scripts | ws/ArchWiki/lang.py | Python | gpl-3.0 | 8,514 |
import csv
import os
import os.path as p
from fnmatch import fnmatch
ignored_files = []
accepted_files = []
def parse_lowen_config(filename):
"""
Parses lowen config file and returns the patterns in a list.
"""
patterns = []
if p.isfile(filename):
with open(filename, 'r') as f:
... | Saytiras/PyRepositoryAnalysis | util.py | Python | mit | 2,564 |
#!/usr/bin/env python
# Copyright (c) 2014 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
Verify that 'none' targets produce valid ninja rules.
"""
import os
import sys
import TestCommon
import TestGyp
# This is a ninja-spec... | BozhkoAlexander/mtasa-blue | vendor/google-breakpad/src/tools/gyp/test/ninja/none-rules/gyptest-none-rules.py | Python | gpl-3.0 | 582 |
from hypothesis import given
from hypothesis.strategies import binary
from mitmproxy.contentviews import json
from . import full_eval
def test_parse_json():
assert json.parse_json(b'{"foo": 1}')
assert json.parse_json(b'null') is None
assert json.parse_json(b"moo") is json.PARSE_ERROR
assert json.par... | mhils/mitmproxy | test/mitmproxy/contentviews/test_json.py | Python | mit | 1,432 |
# -*- coding:utf-8 -*-
'''
WSGI config for dentexchange 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', 'settings')... | hellhovnd/dentexchange | dentexchange/project/wsgi.py | Python | bsd-3-clause | 409 |
c = get_config()
# NEVER NAG ME
c.TerminalInteractiveShell.confirm_exit = False
# Configuration file for ipython.
# ------------------------------------------------------------------------------
# InteractiveShellApp(Configurable) configuration
# -----------------------------------------------------------------------... | npotts/dotfiles | ipython/profile_default/ipython_config.py | Python | unlicense | 38,662 |
import tensorflow as tf
def linear(input_, output_size, scope=None, stddev=0.02, bias_start=0.0, transpose_b=False):
shape = input_.get_shape().as_list()
if not transpose_b:
w_shape = [shape[1], output_size]
else:
w_shape = [output_size, shape[1]]
with tf.variable_scope(scope or "line... | MustafaMustafa/dcgan-tf-benchmark | dcgan/ops.py | Python | mit | 2,583 |
# coding: utf-8
from niamoto.data_providers.sql_provider.sql_data_provider import \
SQLDataProvider
| dimitri-justeau/niamoto-core | niamoto/data_providers/sql_provider/__init__.py | Python | gpl-3.0 | 105 |
from oscar.test.testcases import WebTestCase
from oscar.test.factories import create_product, UserFactory
from oscar.core.compat import get_user_model
from oscar.apps.catalogue.reviews.signals import review_added
from oscar.test.contextmanagers import mock_signal_receiver
class TestACustomer(WebTestCase):
def se... | itbabu/django-oscar | tests/functional/catalogue/review_tests.py | Python | bsd-3-clause | 2,113 |
import struct
''' Refer to docs for all the exact formats. There are many so check them out before converting things yourself '''
''' If there's a specific offset you want to do things from, use pack_into and unack_into from the docs '''
#Integer to string
i1= 1234
print "Int to string as 8 byte little endian", repr(... | arvinddoraiswamy/LearnPython | 17.py | Python | mit | 867 |
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source
# & Institut Laue - Langevin
# SPDX - License - Identifier: GPL - 3.0 +
#pylint: disable=invalid-name
"""
Script ... | mganeva/mantid | scripts/ORNL_SANS.py | Python | gpl-3.0 | 629 |
def gcd(a, b):
while b != 0:
(a, b) = (b, a % b)
return a
def factorize(n, wheel=3):
if n < 2:
return []
primes = (2, 3, 5, 7, 11)
if wheel < 2 or wheel > len(primes):
wheel = 3
primes = primes[:wheel]
q = []
# first use wheel primes
for p in primes:
... | AlgorithmLover/OJCodes | qlcoder/algorithms/number_theory/euler_function.py | Python | mit | 2,106 |
#!/usr/bin/python3
from AbstractGenerator import *
class PlotGenerator(AbstractGenerator):
def __init__(self, Configs, Results, PltConfig, Template):
AbstractGenerator.__init__(self, Configs, Results, PltConfig)
self.Template = Template
###
### Plot functions
###
def dumpAxisLabels(self, axisName):... | jfmcarreira/python-helpers | PlotGenerator.py | Python | gpl-2.0 | 7,094 |
# coding: utf-8
"""Este módulo contém os modelos relativos aos temas da categoria Abastecimento
de Àgua e Saneamento Básico
"""
from django.utils.translation import ugettext as _
from django.contrib.gis.db import models
from clone.comum.models import GeometriaAproximadaMixIn, NomeNomeAbreviadoMixIn, ClasseCnae
from clo... | sigma-geosistemas/clone | src/clone/abastecimento/models.py | Python | lgpl-3.0 | 17,294 |
from pdbparser.pdbparser import pdbparser
from pdbparser.Utilities.Construct import AmorphousSystem
from pdbparser.Utilities.Database import __WATER__
from pdbparser.Utilities.Geometry import translate, get_center
# create pdbWATER of a single molecule of water
pdbWATER = pdbparser()
pdbWATER.records = __WATER__
pdbWA... | bachiraoun/fullrmc | Examples/agitations/createWaterBox.py | Python | agpl-3.0 | 633 |
# Copyright 2018 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 a... | google/sling | sling/myelin/tests/gradcheck.py | Python | apache-2.0 | 13,771 |
from tornado.testing import *
from tornado.escape import json_encode
import mock
from test_utils import TestUtils, DummyConfig, DummyRunnerConfig
import shutil
from bcl2fastq.handlers.bcl2fastq_handlers import *
from bcl2fastq.lib.bcl2fastq_utils import BCL2Fastq2xRunner, BCL2FastqRunner
from bcl2fastq.lib.bcl2fastq_... | arteria-project/arteria-bcl2fastq | tests/test_bcl2fastq_handlers.py | Python | mit | 10,596 |
#*********************************************************************************
#
# Inviwo - Interactive Visualization Workshop
#
# Copyright (c) 2013-2016 Inviwo Foundation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the f... | cgloger/inviwo | tools/ivwpy/regression/error.py | Python | bsd-2-clause | 1,742 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.