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
d38148097b96ecf7681d0e6c5f7dbc0de5c4b16b
Create backpackI.py
LintCode/backpackI.py
LintCode/backpackI.py
''' Given n items with size Ai, an integer m denotes the size of a backpack. How full you can fill this backpack? Have you met this question in a real interview? Yes Example If we have 4 items with size [2, 3, 5, 7], the backpack size is 11, we can select [2, 3, 5], so that the max size we can fill this backpack is 10...
Python
0.000006
6a65640d1567d3cf2a9dac232e705e4697022987
add migration for hidden col
migrations/versions/388d0cc48e7c_.py
migrations/versions/388d0cc48e7c_.py
"""empty message Revision ID: 388d0cc48e7c Revises: 21a633e449ce Create Date: 2014-11-13 10:49:45.512414 """ # revision identifiers, used by Alembic. revision = '388d0cc48e7c' down_revision = '21a633e449ce' from alembic import op import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - ...
Python
0
9d0e85a10b1073000d22500938e3d8d65107f062
Update migrations
migrations/versions/70e630638c64_.py
migrations/versions/70e630638c64_.py
"""empty message Revision ID: 70e630638c64 Revises: Create Date: 2017-05-23 13:19:47.177767 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = '70e630638c64' down_revision = None branch_labels = None depends_on = None def upgrade(): # ### commands auto gene...
Python
0.000001
c934c77392b98e7625bc5e03ea6c3c7960cdcd5d
Create syslog_parser.py
syslog_parser.py
syslog_parser.py
import re import sys import argparse __author__ = 'sif.baksh@gmail.com' __version__ = "$Revision: 1.6 $" ''' TODO - nothing USAGE python syslog_parser.py -i syslog.log -o customerxyz.txt ''' # This will allow us to pass command line arguments # FOR HELP - python syslog_test.py --h parser = argparse.ArgumentParser(de...
Python
0.00062
375f63b76fccc89ce0ee9b4246e5fb9a2400d1eb
Add Austrian Versicherungsnummer
stdnum/at/vnr.py
stdnum/at/vnr.py
# vnr.py - functions for handling Austrian social security numbers # coding: utf-8 # # Copyright (C) 2018 Arthur de Jong # # This library 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...
Python
0.000025
33d3f3f0805fb2e34144eec1870442427c2a12b5
Add initial config management interface for the wheel module
salt/wheel/config.py
salt/wheel/config.py
''' Manage the master configuration file ''' # Import python libs import os # Import third party libs import yaml # Import salt libs import salt.config def values(): ''' Return the raw values of the config file ''' data = salt.config.master_config(__opts__['conf_file']) data.pop('aes') data...
Python
0
bf6bec04c520241eb6c572b70e2219e989806a2e
sumOfN2 time
sumOfN2.py
sumOfN2.py
import time def sumOfN2(n): start = time.time() theSum = 0 for i in range(1, n+1): theSum = theSum + 1 end = time.time() return theSum, end-start for i in range(5): print("Sum is %d required %10.7f seconds"%sumOfN2(10000))
Python
0.999478
9e835d341513d7477b05f19ec2b72499b170db40
Add initial libguestfs module
salt/modules/libguestfs.py
salt/modules/libguestfs.py
''' Interact with virtual machine images via libguestfs :depends: - libguestfs ''' # Import Salt libs import salt.utils def __virtual__(): ''' Only load if libguestfs python bindings are installed ''' if salt.utils.which('guestmount'): return 'guestfs' return False def seed(location, ...
Python
0
e2c46d78cc4efe2d8778b0580b37ac95299c4ee1
Implement DefaultConfigMixin
utils/mixin.py
utils/mixin.py
from itertools import chain class DefaultConfigMixin(): @property def _default_config(self): if (hasattr(self.bot_config, 'DEFAULT_CONFIG') and self.name in self.bot_config.DEFAULT_CONFIG): return self.bot_config.DEFAULT_CONFIG[self.name] def __init__(self, bot, name=N...
Python
0.000001
1c631f8a6426a50e2e86d77a9b2729e102c5ad32
add DecomposeComponentsFilter
Lib/ufo2ft/filters/decomposeComponents.py
Lib/ufo2ft/filters/decomposeComponents.py
from __future__ import ( print_function, division, absolute_import, unicode_literals) from fontTools.pens.reverseContourPen import ReverseContourPen from fontTools.misc.transform import Transform, Identity from fontTools.pens.transformPen import TransformPen from ufo2ft.filters import BaseFilter class DecomposeC...
Python
0
b7e024913d1d1bc87306f4a85b8737a8d5c35ec7
add XML validation utility
sbin/validate_xml.py
sbin/validate_xml.py
#!/usr/bin/python # -*- coding: ISO-8859-15 -*- # ================================================================= # # $Id$ # # Authors: Angelos Tzotsos <tzotsos@gmail.com> # # Copyright (c) 2011 Angelos Tzotsos # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and ass...
Python
0.000001
cf3ca764c571a51952cd7c98c9752aedc701c3eb
Drop the status column
migrations/versions/0053_perform_drop_status_column.py
migrations/versions/0053_perform_drop_status_column.py
"""empty message Revision ID: 0053_perform_drop_status_column Revises: 0052_drop_jobs_status Create Date: 2016-08-25 15:56:31.779399 """ # revision identifiers, used by Alembic. revision = '0053_perform_drop_status_column' down_revision = '0052_drop_jobs_status' from alembic import op import sqlalchemy as sa from s...
Python
0.000003
653221002d97f4ab646b11c01016763550912036
Update word-ladder.py
Python/word-ladder.py
Python/word-ladder.py
# Time: O(n * d), n is length of string, d is size of dictionary # Space: O(d) # # Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: # # Only one letter can be changed at a time # Each intermediate word must exist in the dictionary # F...
# Time: O(n * d), n is length of string, d is size of dictionary # Space: O(d) # # Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: # # Only one letter can be changed at a time # Each intermediate word must exist in the dictionary # F...
Python
0.000003
96e0f1f4946e4663991f6af1dfb333b064721df2
Add cctbx_progs/emma_shelxd_lst.py to execute phenix.emma for all solutions in _fa.lst of SHELXD.
cctbx_progs/emma_shelxd_lst.py
cctbx_progs/emma_shelxd_lst.py
#!/usr/bin/env phenix.python # The original code is iotbx/command_line/emma.py from __future__ import division from iotbx import crystal_symmetry_from_any from iotbx.option_parser import option_parser from cctbx import euclidean_model_matching as emma from iotbx.command_line.emma import get_emma_model import sys, os,...
Python
0
8affa8de7338f08c2bb77e290fd7509440d6eee6
Add test for issue #169
numba/tests/issues/test_issue_169.py
numba/tests/issues/test_issue_169.py
# -*- coding: utf-8 -*- """ Test binding of autojit methods. """ from __future__ import print_function, division, absolute_import from numba import * class A(object): @autojit def a(self, arg): return self * arg def __mul__(self, other): return 10 * other assert A().a(10) == 100
Python
0
d523ea99145941f35c00aecfbcdc18101645358b
Add tests for feed import
features/imports/tests/test_feed.py
features/imports/tests/test_feed.py
import datetime from django.conf import settings import django.utils.timezone from core import tests from features.associations import models as associations from features.memberships.test_mixins import MemberMixin, OtherMemberMixin from ..management.commands.import_feeds import ( import_from_feed, parse_feed_url...
Python
0
5617038f4ec48915411ec5ce4bf5ae2df98e9e0e
Add dodo dockerkill command
dodo_commands/extra/standard_commands/dockerkill.py
dodo_commands/extra/standard_commands/dockerkill.py
# noqa from dodo_commands.system_commands import DodoCommand from plumbum.cmd import docker from six.moves import input as raw_input class Command(DodoCommand): # noqa help = "" def _containers(self): result = [] for line in docker("ps", "--format", "{{.ID}} {{.Names}} {{.Image}}").split('\n...
Python
0.000002
37ab6b858b6f115bef7a6500a8c81da161e4c659
Add normal list params to list method for telemetry statistics
openstack/telemetry/v2/statistics.py
openstack/telemetry/v2/statistics.py
# 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...
# 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...
Python
0.000007
1b217b7990453b4b20c8d255b27825971a32092c
add testing python script for tring out
python/setup.py
python/setup.py
from sys import argv # main method as entry point def main(arg_inputs): pass if __name__ == "__main__": main(argv[1]) pass
Python
0
5dba05e3012b2004fd63f29200ba83b36529da41
add caesar cipher python exercise
Text/caesar_cipher.py
Text/caesar_cipher.py
#Global constants for menu choices SHIFT_ONE = 1 SHIFT_TWO = 2 def caesar(plaintext, shift): alphabet=["a","b","c","d","e","f","g","h","i","j","k","l", "m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B", "C","D""E","F","G","H","I","J","K","L","M","N","O","P", "Q","R","S","T","U","V","W","X...
Python
0.999965
f901632651fa0d177a3ba7fc99504aa874eb48b8
add watcher
watcher.py
watcher.py
class Watcher: def __init__(self, topic, client): self.value = None self.topic = topic self.client = client def set_value(self, new_value): if self.value != new_value: self.value = new_value self.change() def change(self): print('change: {} t...
Python
0.000001
679e969e1cab73139406bdeb5a2f6d03757a89af
Allow Authentication header in CORS
sentry/utils/http.py
sentry/utils/http.py
""" sentry.utils.http ~~~~~~~~~~~~~~~~~ :copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import urllib from urlparse import urlparse from sentry.conf import settings from sentry.plugins.helpers import get_option def safe_urlencode(params, d...
""" sentry.utils.http ~~~~~~~~~~~~~~~~~ :copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ import urllib from urlparse import urlparse from sentry.conf import settings from sentry.plugins.helpers import get_option def safe_urlencode(params, d...
Python
0.000001
553825a2bd5db860d2842a8f72b0142e36d61ba0
build the very basic web server->app.py
www/app.py
www/app.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = 'mookaka' import logging import asyncio from aiohttp import web logging.basicConfig(level=logging.INFO) def index(request): return web.Response(body=b'<h1>Awesome!</h1>') async def init(loop): app = web.Application(loop=loop) app.router.add_r...
Python
0.000001
e9e845b33891f50834e9b8bfb1796e43e9faac81
Create complete_the_pattern_#9.py
complete_the_pattern_#9.py
complete_the_pattern_#9.py
#Kunal Gautam #Codewars : @Kunalpod #Problem name: Complete The Pattern #9 - Diamond #Problem level: 6 kyu def pattern(n): top = '\n'.join(' '*(n-i) + ''.join(str(j%10) for j in range(1, i+1)) + ''.join(str(j%10) for j in list(range(1,i))[::-1]) + ' '*(n-i) for i in range(1, n+1)) bottom = '\n'.join(' '*(n-i) ...
Python
0.998654
37061643f4e416c8926411229a2e4d2737cef2e5
Create sportability2shutterfly.py
sportability2shutterfly.py
sportability2shutterfly.py
#!/usr/bin/python # # convert sportability.com player info to shutterfly.com format. # import sys import csv def pullContact(list,row,num): if row["Parent"+num+"_FirstName"] != "" and row["Parent1_LastName"] != "": key=row["Parent"+num+"_FirstName"]+row["Parent1_LastName"] if key not in list: ...
Python
0.000619
2bc33138e7e110486f98145548b05da65577491c
Fix test set up
src/tests/ggrc/__init__.py
src/tests/ggrc/__init__.py
# Copyright (C) 2015 Google Inc., authors, and contributors <see AUTHORS file> # Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file> # Created By: david@reciprocitylabs.com # Maintained By: miha@reciprocitylabs.com import os import logging from flask.ext.testing import TestCase as BaseTestCase...
# Copyright (C) 2015 Google Inc., authors, and contributors <see AUTHORS file> # Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file> # Created By: david@reciprocitylabs.com # Maintained By: miha@reciprocitylabs.com import os import logging from flask.ext.testing import TestCase as BaseTestCase...
Python
0
8e55abfd68de915c9db75b3385033c97d85b191d
Implement text vectorizer
nlp/TextVectorizer.py
nlp/TextVectorizer.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import math import utils class Vectorizer: def __init__(self, tokenizer, texts): self.tokenizer = tokenizer self.texts = texts class TfVectorizer(Vectorizer): def vectorize(self): docs = [self.tokenizer(t.encode('utf-8')) for t in self.text...
Python
0.999655
b08cbbf353da0e84f0f1a160de5e79d5d05c0ea6
add gensim utils
nlpia/gensim_utils.py
nlpia/gensim_utils.py
from __future__ import print_function, unicode_literals, division, absolute_import from future import standard_library standard_library.install_aliases() # noqa from builtins import object # noqa # from gensim.models import Word2Vec from gensim import corpora from gensim import utils from nlpia.constants import logg...
Python
0
5d28840117020821d5f8e0ea6c3214d1180808a0
Add code I wrote on the train as a starting point
decisiontree.py
decisiontree.py
S = [ {'Hearing loss':'No', 'Injury':'No', 'Frequency of vertigo attacks':'0', 'classes' : {'not-BPV':3, 'BPV':0}}, {'Hearing loss':'No', 'Injury':'No', 'Frequency of vertigo attacks':'1', 'classes' : {'not-BPV':59, 'BPV':0}}, {'Hearing loss':'No', 'Injury':'No', 'Frequency of vertigo attacks':'2', 'classes' : {'not-BP...
Python
0.000134
01c0518d88d3b1a6919f9841752eb676bed8f68a
Create test.py
scripts/test.py
scripts/test.py
print "hello world"
Python
0.000005
427d1bce56c2f5ce7f34ec0816e183fb4aee130f
Create ConvLSTMCell.py
ConvLSTMCell.py
ConvLSTMCell.py
from tensorflow.python.ops.variable_scope import variable_scope, get_variable from tensorflow.python.ops.init_ops import constant_initializer from tensorflow.python.ops.math_ops import tanh, sigmoid from tensorflow.python.ops.rnn_cell import RNNCell, LSTMStateTuple from tensorflow.python.ops.nn_ops import conv2d, conv3...
Python
0
ffa1a6711a616582c38ffeeef47df9f6ff272fe2
Create DAGUtilities.py
DAGUtilities.py
DAGUtilities.py
''' Created on Apr 6, 2016 @author: Noah Higa ''' import sys from Job import Job def newJob(identity): aNewJob = Job(identity, 1, 1, 1, 1, 1, 1, 1, 1) return aNewJob def printEdges(G): edges = G.edges() for edge in edges: sys.stdout.write('(') sys.stdout.write(edge[0].__str__()) ...
Python
0
569be57e96a97885c4f7d92a3ce524aa47413897
Create for_loops.py
_ptopics/for_loops.py
_ptopics/for_loops.py
--- topic: "for loops" desc: "for loops in Python, from basic to advanced" --- # Basic for loop over a list ```python schools = ["UCSB","UCLA","UCI","Cal Poly"] for s in schools: print(s,len(s)) ``` Output: ``` UCSB 4 UCLA 4 UCI 3 Cal Poly 8 ``` # Basic for loop with counter ```python >>> for i in range(4): ......
Python
0.000012
a235ee9cf64c1161dddbbb0f1bd540d42575e839
add comprehension sample
comprehension.py
comprehension.py
# -*- coding: utf-8 -*- # Pythonの内包表記の使い方まとめ - Life with Python # http://www.lifewithpython.com/2014/09/python-list-comprehension-and-generator-expression-and-dict-comprehension.html def main(): ## リスト内包 list = [number + 1 for number in range(1,5)] print(list) print([x * y for x, y in zip([1,2,3], [...
Python
0.000001
58b5ff7daf0c240ddbb4b83d11b361dcf574ae74
Add mkaudiocd.py for making Audio CD for dosbox
mkaudiocd.py
mkaudiocd.py
#!/usr/bin/env python3 import sys, subprocess, os, multiprocessing, magic, tempfile; files = sys.argv[1:]; tempfiles = []; mime = magic.open(magic.MIME); mime.load(); for i in range(len(files)): mime_type = mime.file(files[i]).split(';')[0]; if (mime_type in ('audio/mpeg')): tf = tempfile.NamedTemporar...
Python
0
0cabf3c4dae3599e2d1627ff41707cf36b4d2ddd
Load all modules by default
acoustics/__init__.py
acoustics/__init__.py
""" Acoustics ========= The acoustics module... """ import acoustics.aio import acoustics.ambisonics import acoustics.atmosphere import acoustics.bands import acoustics.building import acoustics.cepstrum import acoustics.criterion import acoustics.decibel import acoustics.descriptors import acoustics.directivity impo...
""" Acoustics ========= The acoustics module... """ import acoustics.ambisonics import acoustics.utils import acoustics.octave import acoustics.doppler import acoustics.signal import acoustics.directivity import acoustics.building import acoustics.room import acoustics.standards import acoustics.cepstrum from acoust...
Python
0
68a37792fd7c5a197758aff738a69c7ce08b4a8b
Add manhole module
txircd/modules/manhole.py
txircd/modules/manhole.py
from twisted.conch.manhole_tap import makeService class Spawner(object): def __init__(self, ircd): self.manhole = makeService({ 'namespace': {'ircd': ircd}, 'passwd': 'manhole.passwd', 'telnetPort': None, 'sshPort': '65432' }) def spawn(self)...
Python
0.000001
513af3716c596bb67c0f6552824b854b3735858c
Add simple tests for password strength and sensitivity to MINIMUM_ZXCVBN_SCORE setting
corehq/apps/domain/tests/test_password_strength.py
corehq/apps/domain/tests/test_password_strength.py
from django import forms from django.test import SimpleTestCase, override_settings from corehq.apps.domain.forms import clean_password class PasswordStrengthTest(SimpleTestCase): @override_settings(MINIMUM_ZXCVBN_SCORE=2) def test_score_0_password(self): self.assert_bad_password(PASSWORDS_BY_STRENGT...
Python
0
e4a5761d997bee3eefad80c6b92c4c4a0c3568fd
Create day_14_part_1.py
day_14_part_1.py
day_14_part_1.py
import hashlib, re salt = "yjdafjpo" keys = [] i = 0 while len(keys) < 64: first_key = hashlib.md5((salt + str(i)).encode("utf-8")).hexdigest() # for every 3-gram in key m1 = re.search(r'(.)\1{2,2}', first_key) if m1: for j in range(i + 1, i + 1001): second_key = hashlib.md5((salt +...
Python
0.000198
a2ffd8ea0b2b1b7ace6ed5b37dd76d9dd9063d25
Add utility function.
yaka/web/util.py
yaka/web/util.py
def get_object_or_404(cls, *args): return cls.query.filter(*args).first_or_404()
Python
0
507ac699ce2c47bb8b92b874bd46b8410006ce65
Create Yummly models for API data returns.
yummly/models.py
yummly/models.py
from inspect import getargspec class Storage( dict ): ''' An object that is like a dict except `obj.foo` can be used in addition to `obj['foo']`. Raises Attribute/Key errors for missing references. >>> o = Storage(a=1, b=2) >>> assert( o.a == o['a'] ) >>> assert( o.b == o['b'] ) >>> o....
Python
0
24a19e957a1827d6c5a1d34a68d8fcde8581f588
Add first pass of slice evaluation script
metal/mmtl/eval_slices.py
metal/mmtl/eval_slices.py
""" Example script: python eval_slices.py --tasks COLA --model_dir /dfs/scratch0/vschen/metal-mmtl/metal/mmtl/aws/output/2019_03_06_03_26_06/0/logdir/search_large_lr/QNLI.STSB.MRPC.QQP.WNLI.RTE.MNLI.SST2.COLA_11_43_53 --slices locs_orgs,proper_nouns """ import argparse import json import os from collections import def...
Python
0
cdc311adcd05e5292f61bf5718ba68dceb4121c3
install requirements
tornado/setup.py
tornado/setup.py
import subprocess import sys import setup_util import os from os.path import expanduser home = expanduser("~") cwd = "%s/FrameworkBenchmarks/tornado" % home def start(args): setup_util.replace_text( cwd + "/server.py", "127.0.0.1", args.database_host) subprocess.check_call("pip install -r %s/require...
import subprocess import sys import setup_util import os from os.path import expanduser home = expanduser("~") cwd = "%s/FrameworkBenchmarks/tornado" % home def start(args): setup_util.replace_text( cwd + "/server.py", "127.0.0.1", args.database_host) subprocess.Popen("python %s/FrameworkBenchmarks/...
Python
0
fd6fe20c74463d88b957d22d0f9f2f0316a489cf
add energy_future_csv
amaascore/csv_upload/assets/energy_future.py
amaascore/csv_upload/assets/energy_future.py
import logging.config import csv from amaascore.tools.csv_tools import csv_stream_to_objects from amaascore.assets.energy_future import EnergyFuture from amaascore.assets.interface import AssetsInterface from amaasutils.logging_utils import DEFAULT_LOGGING class EnergyFutureUploader(object): def __init__(self): ...
Python
0.999796
a68b6c46b7bfe16ecf83cc21398d1746275b03e2
add a convert tool
convert_olddb.py
convert_olddb.py
import sqlalchemy import os from photomanager.db.dbutils import get_db_session from photomanager.db.models import ImageMeta def do_convert(db_name): db_session = get_db_session(db_name) image_metas = db_session.query(ImageMeta) for meta in image_metas: filename = meta.filename dirname = os.path.dir...
Python
0.000001
8f897ea096ca4f7e0ee1a920569d18c8bb4a184d
Create SECURITYHUB_ENABLED.py
python-rdklib/SECURITYHUB_ENABLED/SECURITYHUB_ENABLED.py
python-rdklib/SECURITYHUB_ENABLED/SECURITYHUB_ENABLED.py
""" ##################################### ## Gherkin ## ##################################### Rule Name: SECURITYHUB_ENABLED Description: Checks that AWS Security Hub is enabled for an AWS Account. The rule is NON_COMPLIANT if AWS Security Hub is not enabled. Rationale: AWS Security Hu...
Python
0.000002
446f5785a5db301de68adffe9e114b3ebafe0b6f
add tests for removing failed jobs
frappe/tests/test_background_jobs.py
frappe/tests/test_background_jobs.py
import unittest from rq import Queue import frappe from frappe.core.page.background_jobs.background_jobs import remove_failed_jobs from frappe.utils.background_jobs import get_redis_conn class TestBackgroundJobs(unittest.TestCase): def test_remove_failed_jobs(self): frappe.enqueue(method="frappe.tests.test_backg...
Python
0.000009
5ba8c63daee6c0cb8667c916e10fd813d2cc8d88
Add in the cmd module, this is simple and can be expanded, although the basic bases are covered
salt/modules/cmd.py
salt/modules/cmd.py
''' A module for shelling out Keep in mind that this module is insecure, in that it can give whomever has access to the master root execution access to all salt minions ''' import subprocess import tempfile def run(cmd): ''' Execute the passed command and return the output ''' return subprocess.Popen...
Python
0
e3efa4483f43deb9d2e8515ef3a797c03626f892
add serializtion tests for pandas (#844)
distributed/protocol/tests/test_pandas.py
distributed/protocol/tests/test_pandas.py
from __future__ import print_function, division, absolute_import from zlib import crc32 import pandas as pd import pandas.util.testing as tm import pytest from dask.dataframe.utils import assert_eq from distributed.protocol import (serialize, deserialize, decompress, dumps, loads, to_serialize) from distrib...
Python
0
37371ed2c1ad347106a403d47d5679e7224b489e
Add a test for debug commands.
pysc2/tests/debug_test.py
pysc2/tests/debug_test.py
#!/usr/bin/python # 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 ...
Python
0.999798
9d94f581b803e5050f0bf76436cb97d92184b4fb
add tests for country model
openspending/tests/model/test_country.py
openspending/tests/model/test_country.py
import json import urllib2 from flask import url_for, current_app from openspending.core import db from openspending.model.country import Country from openspending.tests.base import ControllerTestCase from openspending.command.geometry import create as createcountries class TestCountryModel(ControllerTestCase):...
Python
0
97d6cce2a5c0c905f0c33c41316c8e65eaed0e08
Update way we synchronize from citybik.es
update-bikestations.py
update-bikestations.py
#!/usr/bin/env python from multiprocessing.pool import ThreadPool import requests import json baseurl = 'http://api.citybik.es/v2/networks/' networkids = [ 'bixi-montreal', 'bixi-toronto', 'capital-bixi', 'hubway', 'capital-bikeshare', 'citi-bike-nyc', 'barclays-cycle-hire' ] def process_network(netwo...
Python
0
a73a6215abd74c9e3bddc0b3841bb8bb1705f250
Add pyunit based test cases. See #1413
Lib/fontbakery/specifications/googlefonts_test.py
Lib/fontbakery/specifications/googlefonts_test.py
# -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals, division import pytest from fontbakery.testrunner import ( INFO , WARN , ERROR , SKIP , PASS , FAIL , ENDTEST , Section ...
Python
0
064c2b53089611e838934c76d8fba19eaad85e75
add cot verify test stub
scriptworker/test/test_cot_verify.py
scriptworker/test/test_cot_verify.py
#!/usr/bin/env python # coding=utf-8 """Test scriptworker.cot.verify """ import logging import pytest from scriptworker.exceptions import CoTError import scriptworker.cot.verify as verify from . import rw_context assert rw_context # silence pyflakes # TODO remove once we use assert CoTError, verify assert pytest lo...
Python
0
9376ab25e4b5713b8b354a3a03c37b1e356fa5c2
Create unlock-device.py
unlock-device.py
unlock-device.py
from com.dtmilano.android.viewclient import ViewClient device, serial = ViewClient.connectToDeviceOrExit() if device.checkConnected(): print("Device connected - serial: {}".format(serial)) print("Device is going to be unlocked...") device.wake() device.unlock() else: print("Device is not connected!...
Python
0.000001
47b93bee1ebcf5fcf6ea2ff3ad7eaabb831f692c
Add WATERS_Utils folder
ET_Utils/WATERS_Utils/__init__.py
ET_Utils/WATERS_Utils/__init__.py
Python
0
60f76f01c6961f6aceb3b67643057798aed056c7
Add python script for validating version files on vaadin.com
scripts/ValidateVaadinDownload.py
scripts/ValidateVaadinDownload.py
#coding=UTF-8 import argparse, sys from urllib.request import urlopen parse = argparse.ArgumentParser(description="Check vaadin.com version lists") parse.add_argument("version", help="Released Vaadin version number") args = parse.parse_args() if hasattr(args, "echo"): print(args.echo) sys.exit(1) prerelease = Non...
Python
0.000001
665b3372e089fda3dde104b0754efa65a87a9bd2
Test harness for checking wtf the HTTPClientResponseHandler is actually doing with data from the network
Sketches/MPS/Bookmarks/TestHTTPResponseHandler.py
Sketches/MPS/Bookmarks/TestHTTPResponseHandler.py
#!/usr/bin/python import base64 from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor from Kamaelia.File.Writing import SimpleFileWriter from Kamaelia.Chassis.Pipeline import Pipeline from TwitterStream import HTTPClientResponseHandler from Kamaelia.Util.PureTransformer import PureTransformer from Kamaelia.Util.C...
Python
0
53467bd7d4c9c12b73c66244a91f31f0dbadeeec
Add pagerteam tests file which had been missed despite its existence
hc/front/tests/test_add_pagerteam.py
hc/front/tests/test_add_pagerteam.py
from hc.api.models import Channel from hc.test import BaseTestCase class AddPagerTeamTestCase(BaseTestCase): url = "/integrations/add_pagerteam/" def test_instructions_work(self): self.client.login(username="alice@example.org", password="password") r = self.client.get(self.url) self.a...
Python
0
9f9916d662d1ab130c9685c415c25b19a14733d7
Add example to illustrate different optimization procedures
examples/svm_objectives.py
examples/svm_objectives.py
# showing the relation between cutting plane and primal objectives import numpy as np import matplotlib.pyplot as plt from sklearn.datasets import load_digits from sklearn.cross_validation import train_test_split from pystruct.problems import CrammerSingerSVMProblem from pystruct.learners import (StructuredSVM, OneS...
Python
0
3a2e9a19feab0c882a9821b7ff555bd1e2693190
Test effect of change in Laplacian.
exp/sandbox/DeltaLaplacianExp.py
exp/sandbox/DeltaLaplacianExp.py
import numpy import scipy.sparse from apgl.graph import GraphUtils from apgl.util.Util import Util numpy.set_printoptions(suppress=True, precision=3) n = 10 W1 = scipy.sparse.rand(n, n, 0.5).todense() W1 = W1.T.dot(W1) W2 = W1.copy() W2[1, 2] = 1 W2[2, 1] = 1 print("W1="+str(W1)) print("W2="+str(W2)) L1 = Gr...
Python
0
d716098727293c2c90c97a41c57bab57330c176c
Fix read_only tests.
kitsune/sumo/tests/test_readonly.py
kitsune/sumo/tests/test_readonly.py
import copy from django.conf import settings from django.db import models from django.db.utils import DatabaseError from django.test import TestCase, override_settings from nose.tools import assert_raises, eq_ from pyquery import PyQuery as pq from kitsune.questions.models import Question from kitsune.sumo.urlresolv...
import copy from django.conf import settings from django.db import models from django.db.utils import DatabaseError from django.test import TestCase from django.utils import importlib from nose.tools import assert_raises, eq_ from pyquery import PyQuery as pq from kitsune.questions.models import Question from kitsun...
Python
0
9a22cf7452723686a5065658ce5c9d31333c8a33
Add download random leader avatar to examples
examples/download_random_leader_avatar.py
examples/download_random_leader_avatar.py
# Run with Python 3 import json import requests from random import randint import shutil import math # 1. Get your keys at https://stepic.org/oauth2/applications/ (client type = confidential, # authorization grant type = client credentials) client_id = "..." client_secret = "..." # 2. Get a token auth = requests.auth...
Python
0
e79437b7badcbc7e48e5090e2e27b892c323e829
add script to make bedgraph from lumpy probbaly (-P) output
scripts/prob_bedpe_to_bedgraph.py
scripts/prob_bedpe_to_bedgraph.py
#!/usr/bin/env python import sys import numpy as np from optparse import OptionParser parser = OptionParser() parser.add_option("-b", "--bedpe_file", dest="bedpe_file", help="BEDPE file") parser.add_option("-n", "--name", default="LUMPY BedGraph", dest="name", help="Name") (options, ar...
Python
0
18728051374484ca93b59d60a4e6941bdc5c6192
Add missing migration
project/creditor/migrations/0010_auto_20190131_1731.py
project/creditor/migrations/0010_auto_20190131_1731.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('creditor', '0009_auto_20160123_2128'), ] operations = [ migrations.AlterField( model_name='recurringtransaction'...
Python
0.0002
efecaf8cdb7ca4623d2efd53590adf976fd36954
Add test ref #261.
setuptools/tests/test_build_py.py
setuptools/tests/test_build_py.py
import os import pytest from setuptools.dist import Distribution @pytest.yield_fixture def tmpdir_as_cwd(tmpdir): with tmpdir.as_cwd(): yield tmpdir def test_directories_in_package_data_glob(tmpdir_as_cwd): """ Directories matching the glob in package_data should not be included in the pac...
Python
0
55aec9effab781a422501d67f18e77efb2eba446
add sequence_handler.py
sequence_handler.py
sequence_handler.py
import tensorflow as tf import numpy as np def get_num_records(filename): return len([x for x in tf.python_io.tf_record_iterator(filename)]) # Write all examples into a TFRecords file def save_tfrecord(writer, sources, targets): for source, target in zip(sources, targets): ex = make_example(source...
Python
0.000015
2526c91b77b538e1f37bd279783de0ac5452c463
Add test to validate legislative parameters in XML and JSON format.
tests/legislation_tests.py
tests/legislation_tests.py
# -*- coding: utf-8 -*- # OpenFisca -- A versatile microsimulation software # By: OpenFisca Team <contact@openfisca.fr> # # Copyright (C) 2011, 2012, 2013, 2014 OpenFisca Team # https://github.com/openfisca # # This file is part of OpenFisca. # # OpenFisca is free software; you can redistribute it and/or modify # it ...
Python
0
5f3af12d40e7c9ff388385e408d65565cb916def
Add Swagger integration test
openfisca_web_api/tests/test_swagger_integration.py
openfisca_web_api/tests/test_swagger_integration.py
# -*- coding: utf-8 -*- # OpenFisca -- A versatile microsimulation software # By: OpenFisca Team <contact@openfisca.fr> # # Copyright (C) 2011, 2012, 2013, 2014, 2015 OpenFisca Team # https://github.com/openfisca # # This file is part of OpenFisca. # # OpenFisca is free software; you can redistribute it and/or modify...
Python
0
0507a47f1c15bac5f6eddbeb9c712f5c2b2a9358
Add tests for msgpack reader.
intake_bluesky/tests/test_msgpack.py
intake_bluesky/tests/test_msgpack.py
import intake_bluesky.msgpack # noqa import intake from suitcase.msgpack import Serializer import os import pytest import shutil import tempfile import time import types from .generic import * # noqa TMP_DIR = tempfile.mkdtemp() TEST_CATALOG_PATH = [TMP_DIR] YAML_FILENAME = 'intake_msgpack_test_catalog.yml' def ...
Python
0
2e1d70391b26ae353ca95ce25a08d59f1d8f9f9e
Create multifilebuilder_gtk3.py
lib/python/multifilebuilder_gtk3.py
lib/python/multifilebuilder_gtk3.py
# -*- python -*- # Copyright (C) 2014 Jeff Epler <jepler@unpythonic.net> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) a...
Python
0
216c7c21adcbec601ebcc624eac4b5087422e5d2
add test for sugarsource
sncosmo/tests/test_sugarsource.py
sncosmo/tests/test_sugarsource.py
# Licensed under a 3-clause BSD style license - see LICENSES """Tests for SUGARSource (and wrapped in Model)""" import os import numpy as np import pytest from numpy.testing import assert_allclose import sncosmo def sugar_model(Xgr=0, q1=0, q2=0, q3=0, A=0, phase=np.linspace(-5, 30, 10), ...
Python
0.000001
da85d929118a9ac51a112a405818838e476a2f80
Add blank test for updating later..
tests/test_pi_mqtt_gpio.py
tests/test_pi_mqtt_gpio.py
def test_noop(): pass
Python
0
06455d743590e47bfe5c9e1a6ff745622abe9cb5
add tests for polymorphism
tests/test_polymorphism.py
tests/test_polymorphism.py
import pytest from dataclasses import dataclass from hologram import JsonSchemaMixin, ValidationError from hologram.helpers import StrEnum, StrLiteral from typing import Union class Bar(StrEnum): x = "x" y = "y" @dataclass class BarX(JsonSchemaMixin): bar: StrLiteral(Bar.x) @dataclass class BarY(Json...
Python
0
64fac50f77c492edf20b0e4161b9da988831f2ed
change author can also be null
src/c3nav/editor/migrations/0002_auto_20170612_1615.py
src/c3nav/editor/migrations/0002_auto_20170612_1615.py
# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-06-12 16:15 from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('editor', '0001_initial'), ...
Python
0.000368
a42a6a54f732ca7eba700b867a3025739ad6a271
Move main code to function because of pylint warning 'Invalid constant name'
list_all_users_in_group.py
list_all_users_in_group.py
#! /usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import grp import pwd import inspect import argparse def list_all_users_in_group(groupname): """Get list of all users of group. Get sorted list of all users of group GROUP, including users with main group GROUP. Ori...
#! /usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import grp import pwd import inspect import argparse def list_all_users_in_group(groupname): """Get list of all users of group. Get sorted list of all users of group GROUP, including users with main group GROUP. Ori...
Python
0
76aed66701ac9f267ef08bde0f0b55e2ad905e68
Add micro bench arith-modulo
graal/edu.uci.python.benchmark/src/micro/arith-modulo.py
graal/edu.uci.python.benchmark/src/micro/arith-modulo.py
# zwei 10/09/13 # arithmetic ops (partially extracted from spectralnorm) import time def docompute(num): for i in range(num): sum = 0 j = 0 # if i == 0: # i += 1 while j < i: if i % 3 == 0: temp = 1 else: temp = i % 3 j += temp sum = sum + j return sum def measure(num): print(...
Python
0.000001
996a4dd0223d8f327dbe822f9f6e430465c6c70f
add django settings for djsupervisor
measure_mate/settings/supervisord.py
measure_mate/settings/supervisord.py
from measure_mate.settings.base import * INSTALLED_APPS += ( 'djsupervisor', )
Python
0
d6acd4324f5fe5e57750a335b35cd42edd8544b5
Solve the puzzle.
01/solve.py
01/solve.py
"""Report the manhattan distance between a starting point and an ending point, given a set of directions to follow to get move between the two points.""" from distance import get_distance from directions import load_directions, follow_directions def main(): directions = load_directions('directions.txt') sta...
Python
0.000084
8eff29ba9777cd977f04a2c0b68d598ad63c8f47
Create 02.py
02/ex/02.py
02/ex/02.py
# Define a procedure, stamps, which takes as its input a positive integer in # pence and returns the number of 5p, 2p and 1p stamps (p is pence) required # to make up that value. The answer should use as many 5p stamps as possible, # then 2 pence stamps and finally 1p stamps. def stamps(nn): # Your code here ...
Python
0
406fcf5297458f5469364faf8180683b89fd527c
Add wmi sampler tests (#5859)
datadog_checks_base/tests/test_wmisampler.py
datadog_checks_base/tests/test_wmisampler.py
# (C) Datadog, Inc. 2020-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) import pytest from tests.utils import requires_windows try: from datadog_checks.base.checks.win.wmi import WMISampler except ImportError: pass @requires_windows @pytest.mark.unit def test_forma...
Python
0
d067d9937ff34787e6f632d86075af29c27d98f8
Add py solution for 714. Best Time to Buy and Sell Stock with Transaction Fee
py/best-time-to-buy-and-sell-stock-with-transaction-fee.py
py/best-time-to-buy-and-sell-stock-with-transaction-fee.py
class Solution(object): def maxProfit(self, prices, fee): """ :type prices: List[int] :type fee: int :rtype: int """ hold, not_hold = None, 0 for p in prices: hold, not_hold = max(hold, not_hold - p - fee), max(not_hold, None if hold is None else h...
Python
0
4c2c80e0004a758787beb555fbbe789cce5e82fc
Fix variable referenced before assginment in vmwareapi code.
nova/tests/test_vmwareapi_vm_util.py
nova/tests/test_vmwareapi_vm_util.py
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # # Copyright 2013 Canonical Corp. # 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.or...
Python
0.000001
db8521aefa5f751bd3309d4bedd0a3ed4ec02056
Create Sparsennetdemo.py (#453)
scripts/sparsennetdemo.py
scripts/sparsennetdemo.py
import itertools import numpy as np import matplotlib.pyplot as plt import numpy.random as npr import jax.numpy as jnp from jax import jit, grad, random from jax.experimental import stax from jax.experimental.stax import Dense, Softplus from jax.tree_util import (tree_flatten, tree_unflatten) from jax.flatten_util imp...
Python
0
c687ab125af67d769afc781731b1a2b663a5bb2c
Use SystemRandom to generate unpredictable random slugs. Fixed duplicate characters in the choice string, removed iI from it to prevent confusion. Fixes issue #40.
dpaste/models.py
dpaste/models.py
from datetime import datetime from os import urandom from random import SystemRandom from django.db import models from django.core.urlresolvers import reverse from django.conf import settings from django.utils.translation import ugettext_lazy as _ import mptt from dpaste.highlight import LEXER_DEFAULT R = SystemRand...
import datetime import random import mptt from django.db import models from django.core.urlresolvers import reverse from django.conf import settings from django.utils.translation import ugettext_lazy as _ from dpaste.highlight import LEXER_DEFAULT L = getattr(settings, 'DPASTE_SLUG_LENGTH', 4) T = getattr(settings, '...
Python
0
f3c823db63a6ca6b6679c2a9de8dcb1ccc805e37
Remove print
blog/templatetags/blog_tags.py
blog/templatetags/blog_tags.py
from datetime import datetime from django import template import sys from events.models import EventPage, EventsIndexPage from blog.models import BlogPage, BlogIndexPage, CodeBlock from collections import OrderedDict register = template.Library() @register.inclusion_tag( 'blog/tags/blog_sidebar.html', ta...
from datetime import datetime from django import template import sys from events.models import EventPage, EventsIndexPage from blog.models import BlogPage, BlogIndexPage, CodeBlock from collections import OrderedDict register = template.Library() @register.inclusion_tag( 'blog/tags/blog_sidebar.html', ta...
Python
0.000016
1dc439fcf7a823270156708208339a8bf420703c
Create Generic Sitemap abstract django
opps/sitemaps/sitemaps.py
opps/sitemaps/sitemaps.py
# -*- coding: utf-8 -*- from django.contrib.sitemaps import GenericSitemap as DjangoGenericSitemap from django.contrib.sitemaps import Sitemap as DjangoSitemap from django.utils import timezone from opps.articles.models import Article def InfoDisct(googlenews=False): article = Article.objects.filter(date_availab...
Python
0
7bab9610bf9278b8dedb55a513f22130e2f629ed
Add PP example
examples/13_PreferedPhase.py
examples/13_PreferedPhase.py
"""This example illustrate hox to find the prefered-phase (PP). First, the amplitude is binned according to phase slices (360°/nbins). Then, the PP is defined as the phase where the amplitude is maximum. """ import numpy as np import matplotlib.pyplot as plt from tensorpac import PacSignals, Pac plt.style.use('seabor...
Python
0.000001
25b7f06a0f185a7e83aab38888e32b41c2c31853
Create 02.py
03/hw/02.py
03/hw/02.py
# Define a procedure, greatest, # that takes as input a list # of positive numbers, and # returns the greatest number # in that list. If the input # list is empty, the output # should be 0. def greatest(xs): greatest = 0 for x in xs: if x > greatest: greatest = x return greatest #print...
Python
0
321c857d4cc2bacdeaa398d3b4b1fd7769f33718
Add py-soupsieve package (#12827)
var/spack/repos/builtin/packages/py-soupsieve/package.py
var/spack/repos/builtin/packages/py-soupsieve/package.py
# Copyright 2013-2019 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 PySoupsieve(PythonPackage): """A modern CSS selector implementation for Beautiful Soup."""...
Python
0
107994f3ac39b60b389fa4d7eb4efbb284b70a10
implement logic improvement suggestion by @balloob
homeassistant/components/sensor/ecobee.py
homeassistant/components/sensor/ecobee.py
""" homeassistant.components.sensor.ecobee ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Ecobee Thermostat Component This component adds support for Ecobee3 Wireless Thermostats. You will need to setup developer access to your thermostat, and create and API key on the ecobee website. The first time you run this component...
""" homeassistant.components.sensor.ecobee ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Ecobee Thermostat Component This component adds support for Ecobee3 Wireless Thermostats. You will need to setup developer access to your thermostat, and create and API key on the ecobee website. The first time you run this component...
Python
0
6ca8bb70e8e9c6d40418e836d222648478eb8f31
Split Questins into students and institutions
tada/schools/migrations/0005_auto_20150427_1938.py
tada/schools/migrations/0005_auto_20150427_1938.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('schools', '0004_auto_20150427_1912'), ] operations = [ migrations.CreateModel( name='QuestionInstitution', ...
Python
0
687661d05179d7a36629a6bd036cdb8dc6a3c637
Create BasePage.py
BasePage.py
BasePage.py
from selenium import webdriver from selenium.webdriver.common.by import By #This is the base class that define attributes and methods to all classes class BasePage(object): def __init__(self, driver): self.driver = driver self.driver.implicitly_wait(30) self.driver.timeout=30 #This class...
Python
0
5d6777cc386f6fbd982b5021a55b9a8a0510ef1a
Convert month
ch06_07_p.py
ch06_07_p.py
months = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] month, day, year = input().strip().split("/") print("%s %s %s" % (day, months[int(month) - 1], year))
Python
0.003029
1db6185a9637377ff63b2b824d625eaf6a990cb3
The default number of sentences was wrong
corpora/semeval_to_stanford.py
corpora/semeval_to_stanford.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals import argparse import sh import sys from corpora.parsers import ColumnCorpusParser from tqdm import tqdm if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument...
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals import argparse import sh import sys from corpora.parsers import ColumnCorpusParser from tqdm import tqdm if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument...
Python
0.999999
3dc50a3f5dbb674a8b7e5383768bc5ebe72ea077
add AUC example
examples/classification_auc.py
examples/classification_auc.py
from tgboost import TGBoost import pandas as pd train = pd.read_csv('train.csv') train = train.sample(frac=1.0, axis=0) # shuffle the data val = train.iloc[0:5000] train = train.iloc[5000:] train_y = train.label train_X = train.drop('label', axis=1) val_y = val.label val_X = val.drop('label', axis=1) params = {'l...
Python
0.998252
301f8cf79d1793826a9b73fca6406c005a1c1638
Create search.py (#4900)
examples/contrib/search.py
examples/contrib/search.py
import re import typing from json import dumps from mitmproxy import command, ctx, flow MARKER = ':mag:' RESULTS_STR = 'Search Results: ' class Search: def __init__(self): self.exp = None @command.command('search') def _search(self, flows: typing.Sequence[flow.Flow], ...
Python
0
e9c23f9bc3f40b0f99bc7ff045abd7f073a0b568
change of json structure for lang status
languagesOfTheWorld/fetchGlottologData.py
languagesOfTheWorld/fetchGlottologData.py
## parse Glottolog JSON data ## PRELIMS # libs import json, urllib2 import pandas as pd # vars withgeoCount = 0 # count languoids with lat/long coordinates nongeoCount = 0 # count languoids without lat/long coordinates maxclass = 0 # what's the longest classification? NONGEOs = []; IDs = []; NAMEs = []; TYPEs = []...
Python
0
47e9a9f665b570809882dfc2a15fe209bbff7e31
Add ye module.
dictproxyhack.py
dictproxyhack.py
"""Exposes the immutable `dictproxy` type to all (?) versions of Python. Should work in 2.2+, 3.0+. Actually tried on 2.6, 2.7, 3.2, 3.3, and PyPy 2.1. Usage is easy: from dictproxyhack import dictproxy myproxy = dictproxy(dict(foo="bar")) print(myproxy['foo']) myproxy['baz'] = "quux" # TypeError d...
Python
0
15b7279b0437cf14c2d5657b99d037beb044949f
Convert JSON to TSV
JSON2TSV.py
JSON2TSV.py
#!/usr/bin/env python # -*- coding: latin-1 -*- ''' Script to convert a JSON file to TSV. Adapted from http://kailaspatil.blogspot.com/2013/07/python-script-to-convert-json-file-into.html ''' import fileinput import json import csv import sys EPILOG = ''' Usage: %(prog)s -i [input JSON file] > [output TSV file] ''' d...
Python
0.999999