commit stringlengths 40 40 | subject stringlengths 1 1.49k | old_file stringlengths 4 311 | new_file stringlengths 4 311 | new_contents stringlengths 1 29.8k | old_contents stringlengths 0 9.9k | lang stringclasses 3
values | proba float64 0 1 |
|---|---|---|---|---|---|---|---|
f42d2264917f109b8cee1d641a475934a456aa61 | Add a BaseFrontend | mopidy/frontends/base.py | mopidy/frontends/base.py | class BaseFrontend(object):
"""
Base class for frontends.
:param core_queue: queue for messaging the core
:type core_queue: :class:`multiprocessing.Queue`
:param backend: the backend
:type backend: :class:`mopidy.backends.base.BaseBackend`
"""
def __init__(self, core_queue, backend):
... | Python | 0.000017 | |
5bba475443495bb61071ddf9f3ce54c98d1c41d5 | allow runtests.py to run only certain tests | mpmath/tests/runtests.py | mpmath/tests/runtests.py | #!/usr/bin/env python
"""
python runtests.py -py
Use py.test to run tests (more useful for debugging)
python runtests.py -psyco
Enable psyco to make tests run about 50% faster
python runtests.py -profile
Generate profile stats (this is much slower)
python runtests.py -nogmpy
Run tests without u... | #!/usr/bin/env python
"""
python runtests.py -py
Use py.test to run tests (more useful for debugging)
python runtests.py -psyco
Enable psyco to make tests run about 50% faster
python runtests.py -profile
Generate profile stats (this is much slower)
python runtests.py -nogmpy
Run tests without u... | Python | 0.000004 |
2d6ecb3b5b67539c6ad0f211d7b059ac44df2731 | Make gallery of examples for various bending angles up to 90 degrees | python/bending_examples.py | python/bending_examples.py | # Make a gallery of images showing the RGZ consensus double sources, sorted by bending angle.
from astropy.io import ascii
path = '/Users/willettk/Astronomy/Research/GalaxyZoo'
data = ascii.read('{:}/rgz-analysis/csv/static_catalog3.csv'.format(path),delimiter=' ')
import bending_angles as ba
import numpy as np
pat... | Python | 0 | |
93ba6ff584d84255f46ef11fb44e9ae863cd7aed | add demo about reversing arguments | python/src/reverse_args.py | python/src/reverse_args.py | # Copyright (c) 2014 ASMlover. 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 ofconditions and the fol... | Python | 0 | |
10964c0a3a1de2ba8c8d32c7aeed123b5712a759 | Test DbMixin with fake | nycodex/tests/test_db.py | nycodex/tests/test_db.py | import pytest
import sqlalchemy
import testing.postgresql
from nycodex import db
class FakeTable(db.Base, db.DbMixin):
__tablename__ = "_fake_table"
id = sqlalchemy.Column(sqlalchemy.CHAR(9), primary_key=True)
name = sqlalchemy.Column(sqlalchemy.TEXT, nullable=False)
description = sqlalchemy.Column(... | import datetime as dt
import pytest
import pytz
import sqlalchemy
import testing.postgresql
from nycodex import db
@pytest.fixture
def engine():
with testing.postgresql.Postgresql() as postgresql:
engine = sqlalchemy.create_engine(postgresql.url())
db.Base.metadata.create_all(engine)
yie... | Python | 0.000002 |
058eeefdef485595e48dcd0250bcf9dc9664287a | Add Launchpad (fixes #17) | services/launchpad.py | services/launchpad.py | from oauthlib.oauth1.rfc5849 import SIGNATURE_PLAINTEXT, SIGNATURE_TYPE_BODY, SIGNATURE_TYPE_AUTH_HEADER
import requests
import foauth.providers
class Launchpad(foauth.providers.OAuth1):
# General info about the provider
provider_url = 'https://launchpad.net/'
docs_url = 'https://launchpad.net/+apidoc/1.0... | Python | 0 | |
98232fea3f8847aad69ed6af0b37a5624c24488b | Add experiment script to run a dataset through all graph clustering method | experiment.py | experiment.py | import fnmatch
import os
from pygraphc.preprocess.PreprocessLog import PreprocessLog
from pygraphc.preprocess.CreateGraph import CreateGraph
from pygraphc.clustering.MajorClust import MajorClust, ImprovedMajorClust
def get_dataset(dataset, dataset_path, file_extension):
# get all log files under dataset directory... | Python | 0.000001 | |
aee93802503a19b873299774e351ef883e81356b | Add functions.py to provide comment functions | functions.py | functions.py | #-*- coding: utf-8 -*-
def getClientIP( req ):
'''
Get the client ip address
'''
xForwardedFor=req.META.get('HTTP_X_FORWARDED_FOR')
if xForwardedFor:
ip=xForwardedFor.split(',')[0]
else:
ip=req.META.get('REMOTE_ADDR')
return ip
def getBool( val, trueOpts=['YES', 'Y', '1', 'TRUE', 'T'] ):
'''
Retrieve the... | Python | 0 | |
f3a43d11f79766c43be6de359762bd37cde49b38 | Complete 3 pointer method | lc0611_valid_triangle_number.py | lc0611_valid_triangle_number.py | """Leetcode 611. Valid Triangle Number
Medium
URL: https://leetcode.com/problems/valid-triangle-number/
Given an array consists of non-negative integers,
your task is to count the number of triplets chosen from the array that can
make triangles if we take them as side lengths of a triangle.
Example 1:
Input: [2,2,3... | Python | 0.000036 | |
45a12a354783845d4f761147f6949797d8f6ffa3 | Add flat type driver unittests | neutron/tests/unit/ml2/test_type_flat.py | neutron/tests/unit/ml2/test_type_flat.py | # Copyright (c) 2014 Thales Services SAS
# 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... | Python | 0.000001 | |
a68198514528773d2368e203491121b5c34f956d | Add tests of compile_ptx and compile_ptx_for_current_device | numba/cuda/tests/cudapy/test_compiler.py | numba/cuda/tests/cudapy/test_compiler.py | from math import sqrt
from numba import cuda, float32, void
from numba.cuda import compile_ptx, compile_ptx_for_current_device
from numba.cuda.testing import skip_on_cudasim, unittest
@skip_on_cudasim('Compilation unsupported in the simulator')
class TestCompileToPTX(unittest.TestCase):
def test_global_kernel(se... | Python | 0.000001 | |
e2fa74c533b49cb3479d4c75d5b68f6993e33082 | Add new package:linsys-v (#16823) | var/spack/repos/builtin/packages/linsys-v/package.py | var/spack/repos/builtin/packages/linsys-v/package.py | # 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 LinsysV(MakefilePackage):
"""LINSYS_V: Verified Solution of Linear Systems"""
homepa... | Python | 0 | |
1c0230f7d0add83c36daadcf88bda72500e49015 | add new package (#22648) | var/spack/repos/builtin/packages/rnaquast/package.py | var/spack/repos/builtin/packages/rnaquast/package.py | # 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)
import os
from spack import *
class Rnaquast(Package):
"""Quality assessment of de novo transcriptome assemblies fro... | Python | 0 | |
3c26db43490640e0a98f5c22bb65eecd2c1c5ba9 | Create sudoku_formatter.py | sudoku_formatter.py | sudoku_formatter.py | instructions = """INSTRUCTIONS:
Copy a sudoku puzzle from http://www.menneske.no/sudoku/ to a text file,
and provide this file as the first command line argument and the file for
output as the second command line argument
Remember that box height and width must be added manually (before/after
formatting)"""
import... | Python | 0.999775 | |
710fe77b1d03de83cfefa3173b17d2adf5f220fe | Add systemd watchdog | systemd_watchdog.py | systemd_watchdog.py | # RES Service Package
# Copyright © 2015 InvestGroup, LLC
import asyncio
import logging
def install_watchdog(interval, loop=None):
assert isinstance(interval, (int, float)) and interval > 0
logger = logging.getLogger("systemd-watchdog")
try:
from systemd.daemon import notify as sd_notify
exc... | Python | 0.000003 | |
78ef287355d670877ed2dd82386ee5ce51944fcb | switch logging to DEBUG | crate_project/settings/production/base.py | crate_project/settings/production/base.py | from ..base import *
LOGGING = {
"version": 1,
"disable_existing_loggers": True,
"filters": {
"require_debug_false": {
"()": "django.utils.log.RequireDebugFalse",
},
},
"formatters": {
"simple": {
"format": "%(levelname)s %(message)s"
},
}... | from ..base import *
LOGGING = {
"version": 1,
"disable_existing_loggers": True,
"filters": {
"require_debug_false": {
"()": "django.utils.log.RequireDebugFalse",
},
},
"formatters": {
"simple": {
"format": "%(levelname)s %(message)s"
},
}... | Python | 0.000003 |
5f0feca62055dafd9931bf68abe3286bda9f41e0 | Create __init__.py | frappe/desk/doctype/communication_reconciliation/__init__.py | frappe/desk/doctype/communication_reconciliation/__init__.py | import frappe
@frappe.whitelist(allow_guest=True)
def relink(self,name,reference_doctype,reference_name):
dt = reference_doctype
dn = reference_name
if dt=="" or dt==None or dn == "" or dn == None:
return # is blank maybe try flash missing required
frappe.db.sql("""update `tabCommunication`
set reference_docty... | Python | 0.000429 | |
c07609fa140c54572832f4f8f4787d0991495e60 | check in some migrations | planetstack/core/migrations/0002_omf_friendly_default_false.py | planetstack/core/migrations/0002_omf_friendly_default_false.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='slice',
name='omf_friend... | Python | 0 | |
18178108ec569ec959c7cac181fa439d99a0170f | convert a patric tab file to a seed directory | tab2seed.py | tab2seed.py | """
Convert a tab file from PATRIC to a the SEED files that we need for PhiSpy
We need the following files:
1. assigned_functions - a tab separated list of FIG ID and function
2. contigs - the fasta DNA sequence. Note we may download this separately
3. genome - the name of the genome -- may not be required
4. taxonom... | Python | 0.000001 | |
45c20be4027ccb7aa6a1c3e643ca164413bd353f | add management command for commenting on outstanding apps about tos changes. | TWLight/applications/management/commands/notify_applicants_tou_changes.py | TWLight/applications/management/commands/notify_applicants_tou_changes.py | import logging
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.utils.translation import ugettext as _
from TWLight.applications.models import Application
from TWLight.resources.models import Partner
from django_comments.models import Comment
logger = loggi... | Python | 0 | |
378e89fd74cfd383c3e1b21fc342194728f66bb7 | Add DogStatsd metrics backend. (#5230) | src/sentry/metrics/dogstatsd.py | src/sentry/metrics/dogstatsd.py | from __future__ import absolute_import
__all__ = ['DogStatsdMetricsBackend']
from datadog import initialize, statsd
from .base import MetricsBackend
class DogStatsdMetricsBackend(MetricsBackend):
def __init__(self, prefix=None, **kwargs):
# TODO(dcramer): it'd be nice if the initialize call wasn't a gl... | Python | 0 | |
56f9ea1ba0026bc21eeb904afaf25606a6186125 | Test per veure que no permetem capçaleres multivaluades | test/test_regles.py | test/test_regles.py | import unittest
import mock
import settings
from soa.tiquets import GestioTiquets
from soa.identitat import GestioIdentitat
from filtres.nou import FiltreNou
from mailticket import MailTicket
from testhelper import llegir_mail
class TestRegles(unittest.TestCase):
def setUp(self):
self.ticket... | Python | 0 | |
81ceae0740bba58cff0b410a6af6ff803d0a3b36 | Add Greengenes json parser | luigi/json_parser_greengenes.py | luigi/json_parser_greengenes.py | """
Copyright [2009-2014] EMBL-European Bioinformatics Institute
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... | Python | 0.000006 | |
c867fe9daf5165757df072604e6ec822dbc2abff | Consolidate experiment/submission code into one script | build-model.py | build-model.py | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
__author__="Josh Montague"
__license__="MIT License"
import argparse
from datetime import datetime
import logging
import os
import sys
import numpy as np
from sklearn.externals import joblib
from sklearn.cross_validation import cross_val_score, cross_val_predict, train_te... | Python | 0.999074 | |
035540578674d0c731b2921fcf7081acfd2831b5 | Add tests checking equivalence to optimizers.py | tests/optix_test.py | tests/optix_test.py | # Copyright 2018 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, ... | Python | 0.000001 | |
2390a9893374166be6e41f99f17318119014e60d | add unit tests | supervisors/tests/test_types.py | supervisors/tests/test_types.py | #!/usr/bin/python
#-*- coding: utf-8 -*-
# ======================================================================
# Copyright 2016 Julien LE CLEACH
#
# 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 Lice... | Python | 0.000001 | |
ae7f22b5fc606a8415e286ffabd43d3fbb71977c | Add Euler angle conversion tests. | tests/test_euler.py | tests/test_euler.py | import unittest
from QGL import *
from QGL.Euler import *
from QGL.Cliffords import C1
import QGL.config
try:
from helpers import setup_test_lib
except:
from .helpers import setup_test_lib
class EulerDecompositions(unittest.TestCase):
N_test = 1000
def setUp(self):
pass
#setup_test_lib()
#self.q1 = Qubi... | Python | 0 | |
329c1d9cd515414fe754385ee302197b93eadd20 | implement 15 (15) ツイッターのユーザー名(例えば@xxxxxxx)を,そのユーザーのページへのリンク(<a href="https://twitter.com/#!/xxxxxxx">@xxxxxxx</a>で囲まれたHTML断片)に置換せよ. | set02/15.py | set02/15.py | # -*- coding: utf-8 -*-
# (15) ツイッターのユーザー名(例えば@xxxxxxx)を,そのユーザーのページへのリンク(<a href="https://twitter.com/#!/xxxxxxx">@xxxxxxx</a>で囲まれたHTML断片)に置換せよ.
import sys
import csv
import re
re_name = re.compile(u'@([a-zA-Z0-9_]+)')
for row in csv.reader(sys.stdin):
tweet = row[5].decode('utf-8')
replaced = re_name.sub(ur... | Python | 0 | |
89ade49695c8961f23879050dda8aa684603c04b | Fix serializer | CTFd/utils/exports/serializers.py | CTFd/utils/exports/serializers.py | import json
import six
from collections import defaultdict, OrderedDict
from CTFd.utils.exports.encoders import JSONEncoder
class JSONSerializer(object):
def __init__(self, query, fileobj):
self.query = query
self.fileobj = fileobj
self.buckets = defaultdict(list)
def serialize(self)... | import json
import six
from collections import OrderedDict
from CTFd.utils.exports.encoders import JSONEncoder
class JSONSerializer(object):
def __init__(self, query, fileobj):
self.query = query
self.fileobj = fileobj
self.buckets = []
def serialize(self):
for row in self.qu... | Python | 0.000039 |
933d364981f2b05cbca3325ee92f0696da5de44e | Create settings.py | settings.py | settings.py | # -*- coding: utf-8 -*-
| Python | 0.000001 | |
7b6b1426015a83b96395f0c7c112dc53d373647f | Add init file for remediation module. | fairness_indicators/remediation/__init__.py | fairness_indicators/remediation/__init__.py | # Copyright 2019 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or a... | Python | 0 | |
205362c2f068ca22fe40cb6399b071849727ee55 | Test cases for style attribute parsing | tests/test_parse.py | tests/test_parse.py |
import pytest
from rinoh.dimension import DimensionBase, PT, PICA, INCH, MM, CM, PERCENT
from rinoh.style import OptionSet, Bool, Integer
def test_optionset_from_string():
ONE = 'one'
TWO = 'two'
THREE = 'three'
class TestSet1(OptionSet):
values = ONE, TWO, THREE
assert TestSet1.from_s... | Python | 0 | |
7f095039b8b11769964530ff5e719617ac599829 | add script to update bambai file names (work in progress) | gdc/main/update_bambai_filenames.py | gdc/main/update_bambai_filenames.py | '''
Created on Aug 31, 2017
# Copyright 2017, Google, Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ap... | Python | 0 | |
9112bfe1a4f9253b78c6145f74b12c712cee136b | Create spacewar.py | spacewar.py | spacewar.py | """
spacewar.py
Author: <your name here>
Credit: <list sources used, if any>
Assignment:
Write and submit a program that implements the sandbox platformer game:
https://github.com/HHS-IntroProgramming/Spacewar
"""
| Python | 0.002719 | |
c8989ff640eb9fb1e9fddad4ac303ed417b54c79 | Adding grumpy.py | axelrod/strategies/grumpy.py | axelrod/strategies/grumpy.py | from axelrod import Player
class Grumpy(Player):
"""
A player that defects after a ceratin level of grumpiness. Grumpiness increases when the opponent defects and decreases when the opponent co-operates.
"""
def __init__(self, starting_state = 'Nice', grumpy_threshold = 10, nice_threshold = -10):
... | Python | 0.999739 | |
ed793b470e55a0fe1c7a0a4b0cc3d8a2774e4628 | verify that the files are actually images | scripts/verifyImageType.py | scripts/verifyImageType.py | from resnet50 import ResNet50
from keras.preprocessing import image
from imagenet_utils import preprocess_input, decode_predictions
import numpy as np
import json
import time
import sys
from multiprocessing import Pool
import functools
def readTasking(filename):
tasking = open(filename,'r')
data = list()
... | Python | 0 | |
12c950c09839ad887d76de9a062e36015534c054 | Create activate-devices.py | cron/activate-devices.py | cron/activate-devices.py | Python | 0.000001 | ||
4a8fe168af19517328187b3ff9ea4f7ae4d48eef | Add DHCPv6 rogue server script. | dhcpv6_rogue_server.py | dhcpv6_rogue_server.py | #!/usr/bin/env python
from base import Base
from network import DHCPv6_raw
from sys import exit
from argparse import ArgumentParser
from ipaddress import IPv6Address
from scapy.all import sniff, ICMPv6, DHCPv6
from socket import socket, AF_PACKET, SOCK_RAW, inet_aton
from base64 import b64encode
from struct import pac... | Python | 0 | |
4628adc38789f52e8e2ef0cdf600b9fbed7b30ab | Test events (really event __repr__) | test/test_events.py | test/test_events.py | import pytest
from h11 import Request
from wsproto.events import (
ConnectionClosed,
ConnectionEstablished,
ConnectionRequested,
)
from wsproto.frame_protocol import CloseReason
def test_connection_requested_repr_no_subprotocol():
method = b'GET'
target = b'/foo'
headers = {
b'host':... | Python | 0.000003 | |
bea5285336ff2b3d32f31e02d2975794da05dddc | add ProposalTargetCreator for fcis | chainercv/experimental/links/model/fcis/utils/proposal_target_creator.py | chainercv/experimental/links/model/fcis/utils/proposal_target_creator.py | import numpy as np
from chainer import cuda
from chainercv.links.model.faster_rcnn.utils.bbox2loc import bbox2loc
from chainercv.transforms.image.resize import resize
from chainercv.utils.bbox.bbox_iou import bbox_iou
def _generate_gt_roi_msk(gt_msk, gt_bb, bb, mask_size):
y_min = max(bb[0], gt_bb[0])
x_min... | Python | 0 | |
e6df90237fa3a42f40cf39aa0df7675de6dd9c9f | 859. Buddy Strings | LeetCode/BuddyStrings.py | LeetCode/BuddyStrings.py | class Solution:
def buddyStrings(self, A: str, B: str) -> bool:
if len(A) != len(B):
return False
mismatches = [-1, -1]
for i in range(len(A)):
if A[i] != B[i]:
if mismatches[0] < 0:
# first mismatch
mismatches[0... | Python | 0.999776 | |
60075ecdc73097c39895193a593688cb3cf103dd | add glucose example | examples/plotting/file/glucose.py | examples/plotting/file/glucose.py |
from bokeh.sampledata import glucose
from bokeh.plotting import *
day = glucose.data.ix['2010-10-06']
highs = day[day['glucose'] > 180]
lows = day[day['glucose'] < 80]
output_file("glucose.html", title="glucose.py example")
hold()
line(day.index.astype('int')/1000000, day['glucose'], color='grey', tools="pan,zoom... | Python | 0.00231 | |
6f0fdb4d7b1202c7ab07d01cf34954ee725df6fe | add basic-calculator | vol5/basic-calculator/basic-calculator.py | vol5/basic-calculator/basic-calculator.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Zeyuan Shang
# @Date: 2015-11-18 17:21:42
# @Last Modified by: Zeyuan Shang
# @Last Modified time: 2015-11-18 17:21:51
class Solution:
operators = ['+', '-', '*', '/']
def getPriority(self, operator):
return {
'+' : 1,
... | Python | 0.998627 | |
54c1028157447233014890419ab869a8c1ca0c3a | Add linux installer | installation/server-linux.py | installation/server-linux.py | #!/usr/bin/env python
#-*- encoding:utf-8 -*-
import os
import sys
import urllib2
import subprocess
installationPath = os.path.expanduser('~') + '/.config/ydlss'
serverLocalLocation = installationPath + '/youtube-dl-simple-server'
serverWebLocation = 'https://github.com/r4mos/youtube-dl-simple-server/raw/master/bin/s... | Python | 0.000001 | |
46d6b7451bb8e295751d771228782cfbbcb8ecc7 | Add dask_client_from_ipclient function | dask/distributed/ipython_utils.py | dask/distributed/ipython_utils.py | from .scheduler import Scheduler
from .worker import Worker
from .client import Client
def dask_client_from_ipclient(client):
"""
Construct a scheduler from an ipython client.
"""
zmq_context = client._context
scheduler = Scheduler(context=zmq_context)
workers = [Worker(scheduler.address_to_wo... | Python | 0 | |
9d88c6f1b0a654a9b89350d475d1a6c46116d917 | Add query | mopidy_internetarchive/query.py | mopidy_internetarchive/query.py | from __future__ import unicode_literals
import collections
import logging
logger = logging.getLogger(__name__)
QUERY_FIELDS = {
'uri',
'track_name',
'track_no',
'album',
'artist',
'composer',
'performer',
'albumartist',
'genre',
'date',
'comment',
'any'
}
DEFAULT_FILT... | Python | 0.99875 | |
93e19ab50567e045daf0e35d856033303be70192 | Implement first test cases | test_esp8266uart.py | test_esp8266uart.py | import esp8266uart
esp = esp8266uart.ESP8266(1, 115200)
print('Testing generic methods')
print('=======================')
print('AT startup...')
if esp.test():
print('Success!')
else:
print('Failed!')
#print('Soft-Reset...')
#if esp.reset():
# print('Success!')
#else:
# print('Failed!')
print('Anothe... | Python | 0.006485 | |
8ec7492658bab8d6b0fba5d6b49a58b6408f5fa2 | Add framework for graphing temporal time | src/graph_run_algo.py | src/graph_run_algo.py | import dateutil.parser
import time
import matplotlib.pyplot as plt
from operator import add
from datetime import datetime
from gensim import corpora, models, similarities
minute = 60
hour = 3600
cdict = "%scorpus.dict"
ccorpus = "%scorpus.mm"
corpus_model = "%s.%s"
def gen_graph(figure, x, y, subtitle, xlabel, ylab... | Python | 0.000001 | |
87fe0b7ff745e4057e4b60a1a9a75fe57581b2d5 | add exp4 script | num_exper/exp4.py | num_exper/exp4.py | import os
import numpy as np
np = 4
fmin = 1.0
fmax = 9.0
df = 0.5
for i in np.arange(fmin+df, fmax, df):
str1 = 'python3 elast_wedge.py --ndims=2 --dx=100.0 --dy=100.0 --dz=100.0 --df=0.1 --degree=1 --damping=0.5 --maxit=300 \
--tol=1e-8 --dg_pp=0 --tau... | Python | 0 | |
2fa721b24891fcd8170d87328334c05faec9cb9a | add hamming char dist function | cryptography/hamming_distance/python/hamming_char_dist.py | cryptography/hamming_distance/python/hamming_char_dist.py | """
Determine the hamming distance, at the character level, between two equal length strings a and b.
"""
def hamming_char_dist(a,b):
if len(a) != len(b):
raise ValueError("a and b are unequal lengths")
dist = 0
for i in range(len(a)):
if(a[i] != b[i]):
dist += 1
return dist | Python | 0.000038 | |
c679b614b638123d846940718bb3fd27ed3078ce | Add test for fftpack. | numpy/fft/tests/test_fftpack.py | numpy/fft/tests/test_fftpack.py | import sys
from numpy.testing import *
set_package_path()
from numpy.fft import *
restore_path()
class test_fftshift(NumpyTestCase):
def check_fft_n(self):
self.failUnlessRaises(ValueError,fft,[1,2,3],0)
if __name__ == "__main__":
NumpyTest().run()
| Python | 0.000027 | |
9436af51e8b823fa83358b40f94dcd07970aea6b | test test | src/test_deque.py | src/test_deque.py | """Test functions for deque module."""
import pytest
def test_queue_is_instance_of_queue_object():
"""Test stack is instance of Stack()."""
from deque import Deque
d = Deque()
assert isinstance(d, Deque)
def test_queue_is_instance_of_doubly_linked_list():
"""Test stack inherits from DoublyLinked... | Python | 0.000037 | |
7a3a7a8d5a397c886086cc87fff3f058921d06d2 | add IntegerListField for keeping major selections | application/fields.py | application/fields.py | from django.db import models
class IntegerListField(models.Field):
"""
IntegerListField keeps a list of int as a comma-separated string.
>>> g = IntegerListField()
>>> g.get_db_prep_value([1,2,-1,20,30,40,-100])
'1,2,-1,20,30,40,-100'
>>> g.to_python('1,2,-10,3,4,-100,7')
[1,2,-10,3,4,-10... | Python | 0 | |
985129b190cbc26700f4f40e90e0b32984d52ca1 | Add example script for updating useremails. Fixes #1041 | not_for_deploy/sysadmin_example_scripts/update_all_useremails_example.py | not_for_deploy/sysadmin_example_scripts/update_all_useremails_example.py | #!/usr/bin/env python
import django
import os
from django.contrib.auth import get_user_model
from django.utils import timezone
from django.db import transaction
class ProgressPrintIterator:
"""
Progress print iterator. Useful to print progress of long running scripts.
(Copied from ievv_opensource since ... | Python | 0 | |
4cb6b3a3e1b74dd83812469c472accfc22e4d699 | Update consecutive-numbers-sum.py | Python/consecutive-numbers-sum.py | Python/consecutive-numbers-sum.py | # Time: O(sqrt(n))
# Space: O(1)
# Given a positive integer N,
# how many ways can we write it as a sum of
# consecutive positive integers?
#
# Example 1:
#
# Input: 5
# Output: 2
# Explanation: 5 = 5 = 2 + 3
# Example 2:
#
# Input: 9
# Output: 3
# Explanation: 9 = 9 = 4 + 5 = 2 + 3 + 4
# Example 3:
#
# Input: 15
# O... | # Time: O(sqrt(n))
# Space: O(1)
# Given a positive integer N,
# how many ways can we write it as a sum of
# consecutive positive integers?
#
# Example 1:
#
# Input: 5
# Output: 2
# Explanation: 5 = 5 = 2 + 3
# Example 2:
#
# Input: 9
# Output: 3
# Explanation: 9 = 9 = 4 + 5 = 2 + 3 + 4
# Example 3:
#
# Input: 15
# O... | Python | 0.003216 |
3dc8fde56be2438dae03e5d9d310fa2d19cd1ce2 | Add multi-result testing | tests/test_multi.py | tests/test_multi.py | # Copyright 2011 OpenStack LLC.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required b... | Python | 0.000002 | |
362c35a1753c908fa7496c0e050b9325420e405e | add missing migrations | corehq/apps/linked_domain/migrations/0012_auto_20200929_0809.py | corehq/apps/linked_domain/migrations/0012_auto_20200929_0809.py | # Generated by Django 2.2.16 on 2020-09-29 08:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('linked_domain', '0011_auto_20200728_2316'),
]
operations = [
migrations.AlterField(
model_name='domainlinkhistory',
... | Python | 0.000012 | |
65b4a1a587c257a1b80d72a6e59d57d5c854f8ed | Add tests | tests/test_pyjwe.py | tests/test_pyjwe.py | import pytest
import jwe
from jwe import validation
from cryptography.exceptions import InvalidTag
class TestValidation:
def test_correct_header(self):
try:
validation.validate_header({
'alg': 'dir',
'enc': 'A256GCM'
})
except Exception as... | Python | 0.000001 | |
b43aef2a3ebd54a72791ae635dca4d7544c0ad23 | Add Flask test server | test_server.py | test_server.py | from flask import Flask
app = Flask(__name__, static_folder=".", static_url_path="")
if __name__ == "__main__":
app.run(debug=True, host="127.0.0.1", port=8765)
| Python | 0.000001 | |
85bd2d96b97b61d70d610a8b566e70abae14b264 | add example of boolean operations for 2d polygons | examples/render/boolean_operations_for_2d_polygons.py | examples/render/boolean_operations_for_2d_polygons.py | # Copyright (c) 2022, Manfred Moitzi
# License: MIT License
from pathlib import Path
import ezdxf
from ezdxf.render.forms import gear, translate
from ezdxf.math.clipping import (
greiner_hormann_union,
greiner_hormann_difference,
greiner_hormann_intersection,
)
from ezdxf import zoom
DIR = Path("~/Desktop/... | Python | 0.000004 | |
3352cb3f38db4f68decf6de60528ad6ff07ce613 | Create mssql_import.py | database/mssql_import.py | database/mssql_import.py | # -*-coding:cp949-*-
# vim: set et:ts=4:sw=4
import pyodbc
def import_table(file, table):
connection = pyodbc.connect(
r'DRIVER={SQL Server};'
r'SERVER=127.0.0.1\instance;'
r'DATABASE=database;'
r'UID=id;'
r'PWD=passwd')
with open (file, 'r') as f:
lines = f.rea... | Python | 0.000002 | |
d67b685340cf2db7cd31b50a4484c29625b8fea5 | Remove pixel test fail expectation | content/test/gpu/gpu_tests/pixel_expectations.py | content/test/gpu/gpu_tests/pixel_expectations.py | # Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import test_expectations
# Valid expectation conditions are:
#
# Operating systems:
# win, xp, vista, win7, mac, leopard, snowleopar... | # Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import test_expectations
# Valid expectation conditions are:
#
# Operating systems:
# win, xp, vista, win7, mac, leopard, snowleopar... | Python | 0.000003 |
b0116fb3b52e9c9f0cc156bc49f1400261ed879c | ADD mechanism table | packages/syft/src/syft/core/node/common/node_table/mechanism.py | packages/syft/src/syft/core/node/common/node_table/mechanism.py | # stdlib
from typing import Any
# third party
from sqlalchemy import Column
from sqlalchemy import LargeBinary
from sqlalchemy import String
from sqlalchemy import Integer
# syft absolute
from syft import deserialize
from syft import serialize
# relative
from . import Base
class Mechanism(Base):
__tablename__ ... | Python | 0.000001 | |
05e90660ab0072a50dd17a2afa1e08c93cf694e8 | Create reverse_k.py | python/linked_list/reverse_k.py | python/linked_list/reverse_k.py | public ListNode reverseKGroup(ListNode head, int k) {
ListNode curr = head;
int count = 0;
while (curr != null && count != k) { // find the k+1 node
curr = curr.next;
count++;
}
if (count == k) { // if k+1 node is found
curr = reverseKGroup(curr, k); // reverse list with k+1 ... | Python | 0.011909 | |
5f67d1fe99817dc19e9b670532e3667f8fa9479e | rewrite IMAGE_PATH, too | python/qidoc/doxygen_project.py | python/qidoc/doxygen_project.py | import os
import qisys.command
import qidoc.doxygen
import qidoc.project
class DoxygenProject(qidoc.project.DocProject):
""" A doc projet using doxygen """
def __init__(self, doc_worktree, project, name,
depends=None, dest=None):
self.doc_type = "doxygen"
super(DoxygenProject... | import os
import qisys.command
import qidoc.doxygen
import qidoc.project
class DoxygenProject(qidoc.project.DocProject):
""" A doc projet using doxygen """
def __init__(self, doc_worktree, project, name,
depends=None, dest=None):
self.doc_type = "doxygen"
super(DoxygenProject... | Python | 0.000026 |
9b05195a0474ba39666e15035aeeacc312d5398e | Manage taboo contracts (#28144) | lib/ansible/modules/network/aci/aci_taboo_contract.py | lib/ansible/modules/network/aci/aci_taboo_contract.py | #!/usr/bin/python
# -*- coding: utf-8 -*-
# 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'],
... | Python | 0 | |
85c452782722c3f58db305b5af5bd3286b0450b0 | Fix some docstrings | axelrod/tournament.py | axelrod/tournament.py | """Recreate Axelrod's tournament."""
import inspect
import itertools
class Axelrod:
"""A class for an iterated prisoner's dilemma.
Take a list of players (see the Player class):
>>> P1 = Defector()
>>> P2 = Cooperator()
>>> axelrod = Axelrod(P1, P2)
>>> axelrod.round_robin(t... | """
Recreate Axelrod's tournament
"""
import inspect
import itertools
class Axelrod:
"""
A class for an iterated prisoner's dilemma.
Take a list of players (see the Player class):
>>> P1 = Defector()
>>> P2 = Cooperator()
>>> axelrod = Axelrod(P1, P2)
>>> axelrod.round... | Python | 0.998602 |
8acc41135419e81bfdb02ba544263453d17788dd | Add simple example | examples/simple_example.py | examples/simple_example.py | """
Simple example to illustrate some of the features of `effective`
The model has a :math:`SU(2)\times U(1)` simmetry and contains
a complex scalar doublet :math:`\phi` (the Higgs) with hypercharge
:math:`1/2` and a real scalar triplet :math:`\Xi` with zero
hypercharge that couple as:
.. math::
\mathcal{L}_{int} ... | Python | 0.000375 | |
f18d70ce9c9e86ca184da939f9ffb193b32d981d | add 135 | vol3/135.py | vol3/135.py | if __name__ == "__main__":
L = 10 ** 6
sol = [0] * (L + 1)
for u in xrange(1, L + 1):
for v in xrange(1, L + 1):
if u * v > L:
break
if 3 * v <= u:
continue
if (u + v) % 4 == 0 and (3 * v - u) % 4 == 0:
sol[u * v] +=... | Python | 0.999991 | |
64b2435b77044c1a258433f8794d9bd0a431b61a | Add accept header | travis-ping.py | travis-ping.py | #Based on https://github.com/FiloSottile/travis-cron
import urllib2
import json
import sys
def api_call(url, token=None, data=None):
print url
if data:
data = json.dumps(data)
req = urllib2.Request(url, data)
if data:
req.add_header('Content-Type', 'application/json; charset=UTF-8')
... | #Based on https://github.com/FiloSottile/travis-cron
import urllib2
import json
import sys
def api_call(url, token=None, data=None):
print url
if data:
data = json.dumps(data)
req = urllib2.Request(url, data)
if data:
req.add_header('Content-Type', 'application/json; charset=UTF-8')
... | Python | 0.000001 |
b7d219a5afbf349385dbe9b2712f34f5e756e3e6 | add flask app | zalando/app.py | zalando/app.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run() | Python | 0.000003 | |
90b92a1977c32dd660533567c0d5034b93d5c9c7 | Add smarts to cope with slug clashes with other places with the same names. | pombola/core/management/commands/core_create_places_from_mapit_entries.py | pombola/core/management/commands/core_create_places_from_mapit_entries.py | # This script will copy areas from mapit to core.places, including creating the
# place kind if required.
# import re
# import sys
from django.core.management.base import LabelCommand
from mapit.models import Type
from pombola.core.models import Place, PlaceKind
from django.template.defaultfilters import slugify
cl... | # This script will copy areas from mapit to core.places, including creating the
# place kind if required.
# import re
# import sys
from django.core.management.base import LabelCommand
from mapit.models import Type
from pombola.core.models import Place, PlaceKind
from django.template.defaultfilters import slugify
cl... | Python | 0 |
0be0d20fc667f0734b85d98f1d359130f7ed5b98 | Add failing specs for current/future class names. | plotly/tests/test_core/test_graph_objs/test_graph_objs.py | plotly/tests/test_core/test_graph_objs/test_graph_objs.py | from unittest import TestCase
import plotly.graph_objs as go
import plotly.graph_reference as gr
OLD_CLASS_NAMES = ['AngularAxis', 'Annotation', 'Annotations', 'Area',
'Bar', 'Box', 'ColorBar', 'Contour', 'Contours',
'Data', 'ErrorX', 'ErrorY', 'ErrorZ', 'Figure',
... | Python | 0 | |
6b53d081b78d3ea2073bdc13112b146660595b5f | Add tests for resource_renderer | tests/test_resource_renderer.py | tests/test_resource_renderer.py | from nose.tools import assert_true, assert_equals
from pyramid.testing import DummyRequest
from pyramid.response import Response
class SUTResource(object):
def __init__(self):
self.request = DummyRequest()
def index(self):
return {}
class TestResourceRenderer(object):
def _getTargetClas... | Python | 0 | |
22b2446546ce59b99980e98e81b3571d81085304 | Test that daily westminster pages load | tests/test_westminster_daily.py | tests/test_westminster_daily.py | import datetime as dt
from flask_application import app
def test_daily_westminster_pages_exist():
start_date = dt.date(2015, 01, 01)
with app.test_client() as c:
for days in range(365):
date = start_date + dt.timedelta(days=days)
month, day = date.month, date.day
... | Python | 0 | |
68451f2df6a1706993d7da6d7b1ff80092bca9af | Add another ui test | tests/ui/personalinformation.py | tests/ui/personalinformation.py | from kiwi.ui.test.player import Player
player = Player(['examples/validation/personalinformation.py'])
app = player.get_app()
player.wait_for_window("Form")
app.Form.name.set_text("")
app.Form.name.set_text("J")
app.Form.name.set_text("Jo")
app.Form.name.set_text("Joh")
app.Form.name.set_text("Joha")
app.Form.name.se... | Python | 0 | |
290de0ced4ee317d845257308686e34df00a1958 | Add test for documenting an entire service | tests/unit/docs/test_service.py | tests/unit/docs/test_service.py | # Copyright 2015 Amazon.com, Inc. or its affiliates. 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. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompa... | Python | 0 | |
eb828764ddbe3988f71b98082e1560e594c3f65d | Add a bot message to display TeamCity test results | ci/teamcity/comment_on_pr.py | ci/teamcity/comment_on_pr.py | """
Post the comment like the following to the PR:
```
:robot: TeamCity test results bot :robot:
<Logs from pytest>
```
"""
from github import Github
import os
import sys
# Check if this is a pull request or not based on the environment variable
try:
pr_id = int(os.environ["GITHUB_PR_NUMBER"].split("/")[-1])
exc... | Python | 0 | |
b0006bf92ae221558d47a0b3c9010cfaacde2bfe | add checkmein.py with __init__ function | autocheckin/checkmein.py | autocheckin/checkmein.py | from selenium import webdriver
from selinium.webdriver.common.keys import Keys
class CheckMeIn(object):
def __init__(self, firstName, lastName, confNum):
self.firstName = firstName
self.lastName = lastName
self.confNum = confNum
| Python | 0.000029 | |
528401b2c5cab29e301814da1754f0c0c41bdcd1 | Update shortest-distance-to-a-character.py | Python/shortest-distance-to-a-character.py | Python/shortest-distance-to-a-character.py | # Time: O(n)
# Space: O(1)
# Given a string S and a character C,
# return an array of integers representing the shortest distance
# from the character C in the string.
#
# Example 1:
#
# Input: S = "loveleetcode", C = 'e'
# Output: [3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0]
#
# Note:
# - S string length is in [1, 10000].
#... | # Time: O(n)
# Space: O(n)
# Given a string S and a character C,
# return an array of integers representing the shortest distance
# from the character C in the string.
#
# Example 1:
#
# Input: S = "loveleetcode", C = 'e'
# Output: [3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0]
#
# Note:
# - S string length is in [1, 10000].
#... | Python | 0.000054 |
231bc7bb7bd7e373d4b4c9a3e33d6539d0637828 | Add xfailing test for #3345 | spacy/tests/regression/test_issue3345.py | spacy/tests/regression/test_issue3345.py | """Test interaction between preset entities and sentence boundaries in NER."""
import spacy
from spacy.tokens import Doc
from spacy.pipeline import EntityRuler, EntityRecognizer
@pytest.mark.xfail
def test_issue3345():
"""Test case where preset entity crosses sentence boundary."""
nlp = spacy.blank("en")
... | Python | 0 | |
d358a799ce726706543ac1d440f5b60112125a52 | Add psf building directory | photutils/psf/building/__init__.py | photutils/psf/building/__init__.py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This subpackage contains modules and packages to build point spread
functions.
"""
| Python | 0 | |
0c74512159641fa63cf6292439a20c6af9698a02 | add a template program so that we can base others off it :) | template.py | template.py | # Copyright (c) 2005 Iowa State University
# http://mesonet.agron.iastate.edu/ -- mailto:akrherz@iastate.edu
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or... | Python | 0 | |
e19c8d52719d1bc00023406842e9a445580d98d3 | add wrappers.py just a dispatch wrapper for linear models | scikits/statsmodels/wrappers.py | scikits/statsmodels/wrappers.py | # -*- coding: utf-8 -*-
"""Convenience Wrappers
Created on Sat Oct 30 14:56:35 2010
Author: josef-pktd
License: BSD
"""
import numpy as np
import scikits.statsmodels as sm
from scikits.statsmodels import GLS, WLS, OLS
def remove_nanrows(y, x):
'''remove common rows in [y,x] that contain at least one nan
TO... | Python | 0 | |
c63ad26327f294393434dcfe4d5454656a0c1b4b | Add initial generate movie | scripts/generate-movie-plots.py | scripts/generate-movie-plots.py | #!/usr/bin/env python3
import os
import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument('sim_dir', help='Simulation directory')
parser.add_argument('output_dir', help='Output directory')
parser.add_argument('-s', '--skip', help='Skip pattern for outputs', default=1, type=i... | Python | 0.000001 | |
11857cb6b1b078166e46af22f39873c3f804e6f7 | Add a script to help in switch an existing DB to use migrations | scripts/switch-to-migrations.py | scripts/switch-to-migrations.py | #!/usr/bin/python
import sys
import psycopg2
import os
import yaml
first_migration = '2011-07-10T19:23:39'
try:
conf = yaml.load(open(os.path.join(os.environ['HOME'], '.catmaid-db')))
except:
print >> sys.stderr, '''Your ~/.catmaid-db file should look like:
host: localhost
database: catmaid
username: catmai... | Python | 0 | |
dbdb247ad03ca6b9168f193eadaf28638d718072 | Change docstring for NamedEntity filth | scrubadub/filth/named_entity.py | scrubadub/filth/named_entity.py | from .base import Filth
class NamedEntityFilth(Filth):
"""
Default filth type, for named entities (e.g. the ones in https://nightly.spacy.io/models/en#en_core_web_lg-labels),
except the ones represented in any other filth.
"""
type = 'named_entity'
def __init__(self, *args, label: str, **kwar... | from .base import Filth
class NamedEntityFilth(Filth):
"""
Named entity filth. Upon initialisation provide a label for named entity (e.g. name, org)
"""
type = 'named_entity'
def __init__(self, *args, label: str, **kwargs):
super(NamedEntityFilth, self).__init__(*args, **kwargs)
s... | Python | 0 |
11f4add6873c7c089b5674415276a71b4c03cb42 | add example mbsubmit plugin | beetsplug/mbsubmit.py | beetsplug/mbsubmit.py | # -*- coding: utf-8 -*-
# This file is part of beets.
# Copyright 2015, Adrian Sampson and Diego Moreda.
#
# 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
# wit... | Python | 0 | |
27bec5bc3dab9798d4ddbfcd84563b3c5056e8c8 | delete again | pychart/pychart_datarender/migrations/0001_initial.py | pychart/pychart_datarender/migrations/0001_initial.py | # -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-15 00:50
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('pychart_profile', '0001_initial'),
... | Python | 0 | |
7791ed9269b3d074b84a27f7f72b88a69c9ebd52 | add chaining classes | sldc/chaining.py | sldc/chaining.py | # -*- coding: utf-8 -*-
from abc import ABCMeta, abstractmethod
__author__ = "Romain Mormont <r.mormont@student.ulg.ac.be>"
class ImageProvider(object):
"""
An interface for any component that genre
"""
__metaclass__ = ABCMeta
@abstractmethod
def get_images(self):
pass
class Workf... | Python | 0 | |
1e62f2fddf96e263198cd8612ddbb3ed2e3c0a73 | Add test mobile settings | geotrek/api/tests/test_mobile_settings.py | geotrek/api/tests/test_mobile_settings.py |
from __future__ import unicode_literals
import json
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.test.testcases import TestCase
from geotrek.common import factories as common_factories
from geotrek.common.models import Theme
from geotrek.trekking import factor... | Python | 0 | |
27896063f7632afa327c4933248435c874b91b7a | Create __init__.py | tests/__init__.py | tests/__init__.py | Python | 0.000429 | ||
b66b696483608de022c25b3e14a1b23351ba86da | 4-9 cubed2 | 04/cubed2.py | 04/cubed2.py | squares = []
for value in range(1,11):
square = value **3
squares.append(square)
#print(squares)
print(squares)
#直接逻辑,99乘法表的原理 | Python | 0.999414 | |
24c85bf4550c4560e2a192fd8513f3788ea2148e | add tools calcuate microseconds between two times | skills/time-tool/microsecond.py | skills/time-tool/microsecond.py | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# Copyright (c) 2016 ASMlover. 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... | Python | 0.000188 | |
cb3158cbb116153d516a01ba1f63e26301338bbb | Create sigmoid_upper_bounds.py (#629) | scripts/sigmoid_upper_bounds.py | scripts/sigmoid_upper_bounds.py | # Upper bounds for sigmoid function
import numpy as np
import math
import matplotlib.pyplot as plt
import pyprobml_utils as pml
sigmoid = lambda x: np.exp(x) / (1 + np.exp(x))
fstar = lambda eta: -eta * math.log(eta) - (1 - eta) * math.log(1 - eta)
sigmoid_upper = lambda eta, x: np.exp(eta * x - fstar(eta))
eta1, et... | Python | 0.000005 | |
9bfb182f92b8ac82ddb1b35c886b4a3f79708696 | Add script for train/test split | scripts/split_train_and_test.py | scripts/split_train_and_test.py | import os
import shutil
import argparse
import random
random.seed(47297)
parser = argparse.ArgumentParser(description='Split data into train and test sets.')
parser.add_argument('subjects_root_path', type=str, help='Directory containing subject sub-directories.')
args, _ = parser.parse_known_args()
def move_to_part... | Python | 0 | |
284da54cc9fc322c32e44706716b548bcd652dc4 | Test axe app. | tests/test_axe.py | tests/test_axe.py | # -*- coding: utf-8 -*-
import pytest
from axe import Axe, errors
@pytest.fixture
def axe():
return Axe()
def test_build_from_urls(axe):
func = lambda: ''
axe.build({'/': func})
assert '/' in axe.urls
assert axe.urls['/'] == func
def test_register_ext_success(axe):
@axe.register_ext
def ... | Python | 0 | |
ed82f23da38f9663f55b32f05046b235bf5da9bd | fix overlooked issue with statically defined names (#10053) | homeassistant/components/switch/tplink.py | homeassistant/components/switch/tplink.py | """
Support for TPLink HS100/HS110/HS200 smart switch.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/switch.tplink/
"""
import logging
import time
import voluptuous as vol
from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA)
fr... | """
Support for TPLink HS100/HS110/HS200 smart switch.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/switch.tplink/
"""
import logging
import time
import voluptuous as vol
from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA)
fr... | Python | 0 |
f9d7612dfbad8d5f394bd7c0a9ed6db5f6234eb5 | add imf_tools | imf_tools.py | imf_tools.py | '''
Define several stellar initial mass functions,
with some tools for working with them
'''
class IMF(object):
'''
stellar initial mass function
'''
__version__ = '0.1'
def __init__(self, imftype='salpeter', ml=0.1, mh=150., mf=1., dm=.005):
'''
set up an IMF with some probab... | Python | 0.000001 | |
9efa97198f81f5afce03e30c3bce5f5fc23a8d28 | add test for Row | tests/test_row.py | tests/test_row.py |
import unittest
from eatable import Table, Row
class RowTestCase(unittest.TestCase):
def setUp(self):
self.header = ('A', 'B', 'C')
self.table = Table(self.header)
def test_init(self):
Row(self.table, 0, ('a1', 'b2', 'c2'))
def test_getitem(self):
row = Row(self.table, 0,... | Python | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.