conversations listlengths 2 3 | source stringclasses 1
value | stack stringclasses 1
value |
|---|---|---|
[
{
"from": "human",
"value": "Add some working utility tests\n\n\nFormer-commit-id: 96e85547f79640d7c12fe0cbea9ed351396759f8 [formerly 7608385cbf13efc6342d0dcb295474eba71842d8] [formerly 91473ba3c3015cabd2c15fb4d679a355687adb10 [formerly 66526a15c595e72f014a13bf692996b624acede9]]\nFormer-commit-id: a01daec4a... | python | chosen |
[
{
"from": "human",
"value": "Create Naive Bayes vectorizer and classifier pickles\n"
},
{
"from": "gpt",
"value": "from sklearn.feature_extraction.text import TfidfVectorizer\nfrom sklearn.naive_bayes import MultinomialNB\nfrom sklearn.externals import joblib\n\nprint \"Grabbing data...\"\n\ntra... | python | chosen |
[
{
"from": "human",
"value": "Add a benchmark for event deletion\n\ngit-svn-id: 81e381228600e5752b80483efd2b45b26c451ea2@6238 e27351fd-9f3e-4f54-a53b-843176b1656c\n"
},
{
"from": "gpt",
"value": "\n\"\"\"\nBenchmark a server's handling of event deletion.\n\"\"\"\n\nfrom itertools import count\nfr... | python | chosen |
[
{
"from": "human",
"value": "Add check for symbol usage\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\"\"\"MSC110: Symbols.\n\n---\nlayout: post\nerror_code: MSC110\nsource: SublimeLinter-annotations\nsource_url: http://bit.ly/16Q7H41\ntitle: symbols\ndate: 2014-0... | python | chosen |
[
{
"from": "human",
"value": "Add script to generate a standalone timeline view.\n\nTBR=jgennis@google.com\n\nReview URL: https://codereview.appspot.com/6497071\n\ngit-svn-id: 3a56fcae908c7e16d23cb53443ea4795ac387cf2@146 0e6d7f2b-9903-5b78-7403-59d27f066143\n"
},
{
"from": "gpt",
"value": "#!/usr... | python | chosen |
[
{
"from": "human",
"value": "Add utility function for converting lng-lat to tile positions\n"
},
{
"from": "gpt",
"value": "import math\n\n\ndef get_tile_box(zoom, x, y):\n \"\"\"convert Google-style Mercator tile coordinate to\n (minlat, maxlat, minlng, maxlng) bounding box\"\"\"\n\n m... | python | chosen |
[
{
"from": "human",
"value": "Add tests for lex order issue."
},
{
"from": "gpt",
"value": "from farmfs.volume import *\nfrom itertools import permutations\nimport re\n\ndef produce_mismatches():\n \"\"\" Helper function to produce pairs of paths which have lexographical/path order mismatches\"\... | python | chosen |
[
{
"from": "human",
"value": "Add the user interface to reverse string obfuscation\n"
},
{
"from": "gpt",
"value": "\"\"\"\nUnobfuscates an encrypted string/password into a plaintext string/password.\n\nUsage:\npython unobfuscate.py\nThen enter the encrypted string/password.\nThe result is a plai... | python | chosen |
[
{
"from": "human",
"value": "Add example code for using hug.use.Socket with udp and tcp\n"
},
{
"from": "gpt",
"value": "\"\"\"A basic example of using hug.use.Socket to return data from raw sockets\"\"\"\nimport hug\nimport socket\nimport struct\nimport time\n\n\nhttp_socket = hug.use.Socket(co... | python | chosen |
[
{
"from": "human",
"value": "Add the tool that lists all unimplemented AD_/AT_ flags.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n\n\"\"\"\nThis script is meant to help discover attack types/damages that have not been\nadded to Pinobot unixmain.patch.\n\nExample:\n./find_unimplement... | python | chosen |
[
{
"from": "human",
"value": "Add test for user view."
},
{
"from": "gpt",
"value": "from django import test\nfrom django.http import QueryDict\n\nfrom mock import patch\n\nfrom news.models import Subscriber\nfrom news.tasks import SET\n\n\nclass UserTest(test.TestCase):\n @patch('news.views.u... | python | chosen |
[
{
"from": "human",
"value": "Add helper script to sort svmlight files by column keys.\n"
},
{
"from": "gpt",
"value": "from sys import argv\nfrom operator import itemgetter\n\nif __name__ == \"__main__\":\n if (len(argv) != 3):\n print(\"Usage: \" + argv[0] + \" <input.svm> <output.svm... | python | chosen |
[
{
"from": "human",
"value": "Add test case for config_eval\n"
},
{
"from": "gpt",
"value": "from __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import unicode_literals\n\nimport os\n\nfrom tempfile import NamedTemporaryFile\nfrom unittest import TestCase\n\nf... | python | chosen |
[
{
"from": "human",
"value": "Add test for parsing multiple sentences.\n"
},
{
"from": "gpt",
"value": "# coding: utf-8\nfrom __future__ import unicode_literals\n\nimport unittest\nfrom textwrap import dedent\n\nfrom conllu import parse, parse_tree\nfrom conllu.compat import text\n\n\nclass TestP... | python | chosen |
[
{
"from": "human",
"value": "Add baka-tsuki epub generator parser\n"
},
{
"from": "gpt",
"value": "#Parser of Baka-Tsuki ePUB generator page\n#python3\nimport requests, re\nfrom bs4 import BeautifulSoup\n\nclass bte_gen(BeautifulSoup):\n def __init__(self, query):\n self.query = query\... | python | chosen |
[
{
"from": "human",
"value": "Add simple test case for hash implementation\n"
},
{
"from": "gpt",
"value": "from sqlobject import *\nfrom sqlobject.tests.dbtest import *\n\n\n########################################\n# Test hashing a column instance\n########################################\n\n\n... | python | chosen |
[
{
"from": "human",
"value": "Test for the TreeCache recipe\n"
},
{
"from": "gpt",
"value": "import asyncio\nimport uuid\n\nfrom .base import ZKBase\nfrom ..exc import NoNode\n\nclass TestTreeCache(ZKBase):\n async def setUp(self):\n await super().setUp()\n for attrname in ['base... | python | chosen |
[
{
"from": "human",
"value": "Add util class: the multiton\n"
},
{
"from": "gpt",
"value": "import inspect\n\ndef multiton(cls):\n \"\"\"\n Class decorator to make a class a multiton.\n That is, there will be only (at most) one object existing for a given set\n of initialization param... | python | chosen |
[
{
"from": "human",
"value": "Implement parsing in StandardKeyboard class\n"
},
{
"from": "gpt",
"value": "import abc\nfrom decimal import Decimal\n\nfrom core import Key, Keyboard\n\n\nclass StandardKeyboard(Keyboard):\n \"\"\" A StandardKeyboard is a keyboard with standard Cherry MX key size... | python | chosen |
[
{
"from": "human",
"value": "Add tests to avoid future regression\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n'''\n:codeauthor: :email:`Shane Lee <slee@saltstack.com>`\n'''\n# Import Python Libs\nfrom __future__ import absolute_import\nimport os\n\n# Import Salt Testing Libs\nfrom ... | python | chosen |
[
{
"from": "human",
"value": "Add example from listing 7.7\n"
},
{
"from": "gpt",
"value": "'''\nListing 7.7: Profiling data partitioning\n'''\n\nimport numpy as np\nimport pyopencl as cl\nimport pyopencl.array\nimport utility\n\nNUM_INTS= 4096\nNUM_ITEMS = 512\nNUM_ITERATIONS = 2000\n\nkernel_sr... | python | chosen |
[
{
"from": "human",
"value": "Add example script for CCD theory\n\nCurrently this script may or may not work.\n"
},
{
"from": "gpt",
"value": "\"\"\"Automatic derivation of CCD equations.\n\n\"\"\"\n\nimport pickle\n\nfrom pyspark import SparkConf, SparkContext\nfrom sympy import IndexedBase, Rat... | python | chosen |
[
{
"from": "human",
"value": "Add tests for ancillary functions\n"
},
{
"from": "gpt",
"value": "import os\n\nimport pytest\n\nfrom vrun import config\nfrom vrun.compat import ConfigParser\n\n\n@pytest.mark.parametrize('parts, result', [\n (\n ['simple'],\n ['simple']\n ),\n ... | python | chosen |
[
{
"from": "human",
"value": "Add the logic to filter views\n"
},
{
"from": "gpt",
"value": "import ast\n\nfrom girder.api import access\nfrom girder.api.describe import Description\nfrom girder.api.rest import Resource\n\nimport psycopg2\n\n# TODO: This will be changed with girder_db_items\ndef ... | python | chosen |
[
{
"from": "human",
"value": "Add a script to work out what to recheck after a TH failure\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\n\n# Copyright 2014 Rackspace Australia\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compl... | python | chosen |
[
{
"from": "human",
"value": "Implement feature extractor from data set files\n"
},
{
"from": "gpt",
"value": "import numpy as np\nimport re\n\ndef extract_train():\n return extract('dataset/train.txt')\n\ndef extract_test():\n return extract('dataset/test.txt')\n\ndef extract(file):\n i... | python | chosen |
[
{
"from": "human",
"value": "ci: Apply coccinelle scripts in git diffs\n\nThis scripts receives the same parameter of what_changed.py. And run\ncoccinelle scripts for code guideline compliance in the given git\ncommits. e.g: ./guideline_check.py --commits origin/master..HEAD\n\nSigned-off-by: Flavio Ceolin ... | python | chosen |
[
{
"from": "human",
"value": "Add support for MPC package\n"
},
{
"from": "gpt",
"value": "import xyz\nimport os\nimport shutil\n\nclass Mpc(xyz.BuildProtocol):\n pkg_name = 'mpc'\n deps = ['gmp', 'mpfr']\n\n def configure(self, builder, config):\n builder.host_lib_configure(confi... | python | chosen |
[
{
"from": "human",
"value": "Add one script to use AWS CLI to allocate/associate/release EIP automatically.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\nimport commands\ncounter =0\nwhile counter <=100 :\n #alocate new Elastic IP, and get the allocation id\n (stauts,output) = commands.g... | python | chosen |
[
{
"from": "human",
"value": "Add a script to generate stats\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nfrom datetime import date, timedelta\nimport redis\n\n\ndef perdelta(start, end, delta):\n curr = start\n while curr < end:\n yield curr\n curr += delta\n\nr ... | python | chosen |
[
{
"from": "human",
"value": "Add time-complexity: basic python examples\n"
},
{
"from": "gpt",
"value": "#Comparison of different time complexities.\n\n#####################\n#constant time - O(1)\n#####################\ndef constant(n):\n result = n * n\n return result\n\n\n##############... | python | chosen |
[
{
"from": "human",
"value": "Add a random directed graphs generator\n"
},
{
"from": "gpt",
"value": "import random\n\nif __name__ == '__main__':\n V, E = 10, 50\n path = 'directed_{}_{}.yolo'.format(V, E)\n title = 'YOLO_{}_{}'.format(V, E)\n \n with open(path, 'w') as f:\n ... | python | chosen |
[
{
"from": "human",
"value": "Add user-topic maps migration script\n"
},
{
"from": "gpt",
"value": "import configparser\nimport os\n\nimport psycopg2.extras\n\nSETTINGS_FILE_PATH = os.path.join(os.path.dirname(__file__), \"../settings.ini\")\n\nconfig = configparser.ConfigParser()\nconfig.read(SE... | python | chosen |
[
{
"from": "human",
"value": "Add sanity check for range map function\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n\ndef map_range(x, in_min, in_max, out_min, out_max):\n out_delta = out_max - out_min\n in_delta = in_max - in_min\n\n return (x - in_min) * out_delta / in_delta... | python | chosen |
[
{
"from": "system",
"value": "Make daphne serving thread idle better\n"
},
{
"from": "human",
"value": "import logging\nimport time\nfrom twisted.internet import reactor\n\nfrom .http_protocol import HTTPFactory\n\nlogger = logging.getLogger(__name__)\n\n\nclass Server(object):\n\n def __init... | python | chosen |
[
{
"from": "human",
"value": "Insert test run results to sqlite3 database\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nimport sys\nimport optparse\nimport sqlite3\nfrom datetime import datetime\nfrom os.path import abspath, exists, join\nfrom xml.etree import ElementTree\n\n\ndef mai... | python | chosen |
[
{
"from": "human",
"value": "Patch to remove duplicate entries created due to change in\nvalidation_logic in Table Mapper Detail for the following doctypes:\n* Delivery Note-Receivable Voucher\n* Purchase Order-Purchase Voucher\n* Sales Order-Receivable Voucher\n"
},
{
"from": "gpt",
"value": "\... | python | chosen |
[
{
"from": "human",
"value": "Add example of a write once API\n"
},
{
"from": "gpt",
"value": "\"\"\"An example of writing an API to scrapper hacker news once, and then enabling usage everywhere\"\"\"\nimport hug\nimport requests\n\n\n@hug.local()\n@hug.cli()\n@hug.get()\ndef top_post(section:hug... | python | chosen |
[
{
"from": "human",
"value": "Implement JS functions in Python\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\n\nimport threading\nfrom time import sleep\n\ndef mymap(func, elements):\n return [func(ele) for ele in elements]\n\nassert mymap(lambda x: x*x, [1, 2, 3, 5]) == [1, 4, 9, 25... | python | chosen |
[
{
"from": "human",
"value": "Add test file for ng.fileio.spinsolve\n"
},
{
"from": "gpt",
"value": "\"\"\" Tests for the fileio.spinsolve submodule \"\"\"\n\n\nimport nmrglue as ng\nfrom pathlib import Path\n\nfrom setup import DATA_DIR\n\n\ndef test_acqu():\n \"\"\" read nmr_fid.dx \"\"\"\n ... | python | chosen |
[
{
"from": "human",
"value": "Add script that runs all the spiders\n"
},
{
"from": "gpt",
"value": "from scrapy.utils.project import get_project_settings\nfrom scrapy.crawler import CrawlerProcess\n\n\nif __name__ == '__main__':\n settings = get_project_settings()\n\n settings.set('LOG_FILE... | python | chosen |
[
{
"from": "human",
"value": "Add a test for objects that cannot be deleted\n"
},
{
"from": "gpt",
"value": "# Copyright (C) 2016 Google Inc., authors, and contributors <see AUTHORS file>\n# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>\n# Created By: andraz@recipro... | python | chosen |
[
{
"from": "human",
"value": "Add 01autoguid/ plugin with own GUIDs autogenerated\n"
},
{
"from": "gpt",
"value": "\"\"\"\nNeed to change all GUIDs for your every new plugin, is daunting, so let's\ngenerate them from strings that are unique for plugins.\n\n\nLow-level Far Manager API is here:\n\n... | python | chosen |
[
{
"from": "system",
"value": "Use unicode for ical description"
},
{
"from": "human",
"value": "from django_ical.views import ICalFeed\nfrom .models import Meeting\nfrom datetime import timedelta\n\nclass MeetingFeed(ICalFeed):\n \"\"\"\n A iCal feed for meetings\n \"\"\"\n product_i... | python | chosen |
[
{
"from": "system",
"value": "Remove footer print and make file PEP8 compliant\n"
},
{
"from": "human",
"value": "from flask.ext.login import current_user\nfrom viaduct.models.page import Page, PagePermission, PageRevision \n\nfrom viaduct import db\n\nfrom flask import request, url_for, render... | python | chosen |
[
{
"from": "human",
"value": "Change local_computer group to foreign key from m2m\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ... | python | chosen |
[
{
"from": "human",
"value": "Add support for svmlight format\n\nThis commit adds a Datasource that can read\na file in svmlight format and can write a\nDataset object in an svmlight format file.\n"
},
{
"from": "gpt",
"value": "from datasource import Datasource\nfrom ..dataset import Dataset\nim... | python | chosen |
[
{
"from": "human",
"value": "Add remove index management command\n"
},
{
"from": "gpt",
"value": "from django.core.management import BaseCommand\nfrom search.search_utils import ElasticAPI\n\n\nclass Command(BaseCommand):\n def handle(self, *args, **kwargs):\n api = ElasticAPI()\n ... | python | chosen |
[
{
"from": "system",
"value": "Change name of compare function in test grid\n"
},
{
"from": "human",
"value": "import pytest\nfrom aimaPy.grid import *\n\ncompare = lambda x, y: all([elm_x == y[i] for i, elm_x in enumerate(x)])\n\n\ndef test_distance():\n assert distance((1, 2), (5, 5)) == 5.0... | python | chosen |
[
{
"from": "human",
"value": "Test that list packing is idempotent\n"
},
{
"from": "gpt",
"value": "\"\"\" Test list packing and unpacking. \"\"\"\n\nimport xcffib\nimport struct\n\nclass TestList(object):\n\n def test_struct_pack_uses_List(self):\n # suppose we have a list of ints...\n... | python | chosen |
[
{
"from": "human",
"value": "Add LinguistManager with with_translations() method.\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nimport functools\n\nfrom django.db import models\nfrom django.db.query import QuerySet\n\nfrom .models import Translation\nfrom .mixins import LinguistMixin... | python | chosen |
[
{
"from": "human",
"value": "Add initial steam.user test fixtures\n"
},
{
"from": "gpt",
"value": "import unittest\nfrom steam import user\n\nclass ProfileTestCase(unittest.TestCase):\n VALID_ID64 = 76561198014028523\n INVALID_ID64 = 123\n # This is weird but there should be no reason t... | python | chosen |
[
{
"from": "human",
"value": "Add script for finding missing descriptions in KA content\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\nfrom kapi import *\nimport utils\nimport argparse, sys\nimport time\nimport json\n\ndef read_cmd():\n \"\"\"Reading command line options.\"\"\"\n de... | python | chosen |
[
{
"from": "human",
"value": "Add basic blinking LED script\n"
},
{
"from": "gpt",
"value": "import pyb\n\nLEDS = [pyb.LED(i) for i in range(1,5)]\n\nwhile True:\n for led in LEDS:\n led.toggle()\n pyb.delay(100)\n"
}
] | python | chosen |
[
{
"from": "human",
"value": "TST: Create test package and round trip install/uninstall\n"
},
{
"from": "gpt",
"value": "from pim.commands.init import _defaults, _make_package\nfrom pim.commands.install import install\nfrom pim.commands.uninstall import uninstall\n\nfrom click.testing import CliR... | python | chosen |
[
{
"from": "human",
"value": "Add RedmineProject as inline of ProjectAdmin\n"
},
{
"from": "gpt",
"value": "from django.contrib import admin\n\nfrom timed.projects.admin import ProjectAdmin\nfrom timed.projects.models import Project\nfrom timed_adfinis.redmine.models import RedmineProject\n\nadmi... | python | chosen |
[
{
"from": "human",
"value": "Create the Game class which has the rules implemented, can\ngo a step forward and can draw itself."
},
{
"from": "gpt",
"value": "from numpy import array\nfrom time import sleep\n\n\nclass GameOfLife(object):\n def __init__(self, n, starting=[]):\n self.gam... | python | chosen |
[
{
"from": "human",
"value": "Add script calculating the tree structure of a set of XML files\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python3\nfrom collections import OrderedDict\ntry:\n from lxml import etree\nexcept:\n from xml.etree import ElementTree as etree\n\n\nclass Node(obj... | python | chosen |
[
{
"from": "human",
"value": "Add init for multi-file module\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n\"\"\"\nBase Library (:mod:`physicalproperty`)\n======================================\n\n.. currentmodule:: physicalproperty\n\"\"\"\n\nfrom physicalproperty import PhysicalProp... | python | chosen |
[
{
"from": "human",
"value": "Add basic skeleton for Agent()\n"
},
{
"from": "gpt",
"value": "import json\nimport logbook\n\nfrom piper.db.core import LazyDatabaseMixin\nfrom piper.utils import oneshot\n\n\nclass Agent(LazyDatabaseMixin):\n \"\"\"\n Listener endpoint that recieves requests ... | python | chosen |
[
{
"from": "human",
"value": "Add simple script to run archvyrt without being installed.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\nimport sys\nfrom pkg_resources import load_entry_point\n\nif __name__ == '__main__':\n sys.exit(\n load_entry_point('archvyrt', 'console_scripts',... | python | chosen |
[
{
"from": "human",
"value": "Add RubyGems plugin to search packages.\n"
},
{
"from": "gpt",
"value": "from plumeria import config\nfrom plumeria.command import commands, CommandError\nfrom plumeria.util import http\nfrom plumeria.util.ratelimit import rate_limit\n\napi_key = config.create(\"ruby... | python | chosen |
[
{
"from": "human",
"value": "Add tests for standard GELFHandler\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Copyright (c) 2015 Simon Jagoe\n# All rights reserved.\n#\n# This software may be modified and distributed under the terms\n# of the 3-clause BSD license. See the LICENSE.... | python | chosen |
[
{
"from": "human",
"value": "Create function to save data to Microsoft Excel file\n"
},
{
"from": "gpt",
"value": "from s4v2 import *\nimport openpyxl\nfrom openpyxl import Workbook\nfrom openpyxl.writer.excel import ExcelWriter\nfrom openpyxl.cell import get_column_letter\n\ndef save_spreadshee... | python | chosen |
[
{
"from": "human",
"value": "Add simple Python JSON validator\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\"\"\"A function and script for determining whether a file contains valid JSON.\"\"\"\nimport json\n\n\ndef is_json(json_file):\n \"\"\"Returns True if a file is valid JSON.\"... | python | chosen |
[
{
"from": "human",
"value": "Add test for `license generate` function\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\n Tests for the `license generate` function\n\"\"\"\n\nfrom click.testing import CliRunner\n\nfrom choosealicense.main import (genera... | python | chosen |
[
{
"from": "system",
"value": "Add content type to API responses\n\nIt doesn’t make much of a difference, but it’s the nice thing to do\n"
},
{
"from": "human",
"value": "import os\nimport aiohttp\nimport json\nfrom aiohttp import web\n\nfrom .consts import KUDAGO_API_BASE_URL, CLIENT_DIR\n\n\nas... | python | chosen |
[
{
"from": "system",
"value": "Upgrade libchromium for the accelerator fix.\n"
},
{
"from": "human",
"value": "#!/usr/bin/env python\n\nimport platform\nimport sys\n\nNODE_VERSION = 'v0.11.13'\nBASE_URL = 'https://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent'\nLIBCHROMIUMCONTENT_COMMI... | python | chosen |
[
{
"from": "human",
"value": "Add a StackingContext in preparation for z-index drawing.\n"
},
{
"from": "gpt",
"value": "# coding: utf8\n\"\"\"\n weasyprint.stacking\n -------------------\n\n :copyright: Copyright 2011-2012 Simon Sapin and contributors, see AUTHORS.\n :license: BSD, s... | python | chosen |
[
{
"from": "human",
"value": "Add missing migrations to cases\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.7 on 2017-09-29 06:15\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n ... | python | chosen |
[
{
"from": "human",
"value": "Add sample file for pseudocolumns\n"
},
{
"from": "gpt",
"value": "import numpy as np\nfrom functools import partial\n\n\nname_func_dict = {\n 'backgate': {'label': 'Backgate voltage (V)'},\n 'MC': {'label': 'Mixing chamber temperature (K)'},\n}\n\ndef parent_f... | python | chosen |
[
{
"from": "human",
"value": "Add CSiBE build script with basic functionality\n\nThe build script csibe.py creates a build directory and executes\nCMake there for native target.\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\nimport os\n\ncsibe_path = os.path.dirname(os.path.realpath(__... | python | chosen |
[
{
"from": "human",
"value": "Add script to apply algorithms to corpus\n"
},
{
"from": "gpt",
"value": "import argparse\nfrom project import corpus, knn_corpus, lda_corpus, word2vec_corpus\n\nalgorithms = {\"lda\": lda_corpus.LDACorpus,\n \"knn\": knn_corpus.KNNCorpus,\n ... | python | chosen |
[
{
"from": "human",
"value": "Add test form error when begin date is after end date\n"
},
{
"from": "gpt",
"value": "\nfrom django.test import TestCase\n\nfrom geotrek.authent.tests.factories import UserFactory\nfrom geotrek.tourism.forms import TouristicEventForm\n\n\nclass PathFormTest(TestCase... | python | chosen |
[
{
"from": "system",
"value": "Exclude hf from tested trainers. :-/\n"
},
{
"from": "human",
"value": "import theanets\n\nimport util\n\n\nclass TestTrainer(util.MNIST):\n def setUp(self):\n super(TestTrainer, self).setUp()\n self.exp = theanets.Experiment(\n theanets.... | python | chosen |
[
{
"from": "human",
"value": "Add basic runner tests, will add more later\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import, unicode_literals\nfrom multiprocessing import Lock\n\nimport git\nimport mock\nimport pytest\n\nfrom badwolf.runner import Te... | python | chosen |
[
{
"from": "system",
"value": "Update dummy MDS to use find and return a list of events.\n"
},
{
"from": "human",
"value": "headers = []\nbeamline_configs = []\nevent_descriptors = []\nevents = []\n\n\ndef find2(header_id=None, scan_id=None, owner=None, start_time=None,\n beamline_id=Non... | python | chosen |
[
{
"from": "human",
"value": "Add function , which is to find all the vertices of one vertex given the specific degree by using broad first search policy\n"
},
{
"from": "gpt",
"value": "# -*- coding:utf-8 -*-\n\n\n\nfrom collections import deque\nfrom graph import Undigraph\n\ndef find_vertex_b... | python | chosen |
[
{
"from": "human",
"value": "Test script for playing with PIL\n"
},
{
"from": "gpt",
"value": "import Image\nfrom PIL import Image\nimport ImageFont\nimg = Image.new(\"RGB\", (1250, 480), (255, 255, 255))\nimport ImageDraw\ndraw = ImageDraw.Draw(img)\nfont = ImageFont.truetype(\"/System/Library/... | python | chosen |
[
{
"from": "human",
"value": "Add tests for 'get comments' API\n\nNote that because of a bug in the testing setup the tests will fail when there are more than one.\nEach individual test has been successfully tested.\n"
},
{
"from": "gpt",
"value": "from server.tests.base import BaseTestCase\nfrom... | python | chosen |
[
{
"from": "human",
"value": "Remove email_reply_to and letter_contact_block from Services\n"
},
{
"from": "gpt",
"value": "\"\"\"\n\nRevision ID: 0143_remove_reply_to\nRevises: 0142_validate_constraint\nCreate Date: 2017-11-21 10:42:25.045444\n\n\"\"\"\nfrom alembic import op\nimport sqlalchemy ... | python | chosen |
[
{
"from": "human",
"value": "Add migration to add model for Comments\n"
},
{
"from": "gpt",
"value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.7 on 2016-07-18 03:30\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.models.deletion\ni... | python | chosen |
[
{
"from": "human",
"value": "Add tests for logout view\n"
},
{
"from": "gpt",
"value": "from django.core.urlresolvers import reverse\nfrom django.test import TestCase\n\nfrom oidc_provider.views import *\nfrom oidc_provider.tests.app.utils import *\n\n\nclass UserInfoTestCase(TestCase):\n def... | python | chosen |
[
{
"from": "human",
"value": "Add simple crunch and query LDDB script\n"
},
{
"from": "gpt",
"value": "from __future__ import print_function\nimport json\nimport sys\nimport re\n\ndef parse_select(sel_str):\n steps = []\n match_rule = None\n for word in sel_str.strip().split(' '):\n ... | python | chosen |
[
{
"from": "human",
"value": "Solve Code Fights functions composition problem\n"
},
{
"from": "gpt",
"value": "#!/usr/local/bin/python\n# Code Fights Functions Composition Problem\n\nfrom functools import reduce\nimport math\n\n\ndef compose(functions):\n return reduce(lambda f, g: lambda x: f... | python | chosen |
[
{
"from": "system",
"value": "Switch to git part two, this time URL for website\n"
},
{
"from": "human",
"value": "import os\ntry:\n from setuptools import setup\nexcept ImportError:\n from distutils.core import setup\n\ndef get_docs():\n result = []\n in_docs = False\n f = open(o... | python | chosen |
[
{
"from": "system",
"value": "Switch supply point id list lookup to SQL\n\nLocally with 1000 users this took the product_data method from 1.7\nseconds to .2 seconds.\n"
},
{
"from": "human",
"value": "from corehq.apps.locations.models import all_locations\nfrom corehq.apps.commtrack.models impor... | python | chosen |
[
{
"from": "human",
"value": "Add function for Fibonacci sequence\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/python\n\nimport sys\n\ndef fib(n):\n a,b = 0,1\n yield a\n if n>0 :\n yield b\n for i in range(2,n+1):\n a,b = b, a+b\n yield b\n\nnum = int(sys.argv[1])\ngen = fib(num)\nfor i in ... | python | chosen |
[
{
"from": "system",
"value": "Add a test to demo config passing.\n"
},
{
"from": "human",
"value": "\"\"\" Inspired by: http://blog.ianbicking.org/2010/03/12/a-webob-app-example/\n\"\"\"\nfrom __future__ import absolute_import\nfrom webob import Request, Response, exc\nfrom routes import Mapper\... | python | chosen |
[
{
"from": "human",
"value": "Add tests for correct behavior on divide-by-zero\n"
},
{
"from": "gpt",
"value": "import angr\nimport nose\nimport os\n\ntest_location = os.path.join(os.path.dirname(__file__), '../../binaries/tests')\n\ndef run_0div(arch):\n # check that we run in unicorn up to t... | python | chosen |
[
{
"from": "human",
"value": "Move fixtures into data layer\n"
},
{
"from": "gpt",
"value": "import os\n\nfrom pytest import fixture\nfrom smif.data_layer import DatafileInterface\nfrom smif.data_layer.load import dump\n\n\n@fixture(scope='function')\ndef get_handler_csv(setup_folder_structure, p... | python | chosen |
[
{
"from": "human",
"value": "Fix EAS folder id length\n\nSummary:\nFixes T2458. Note that because we're using MySQL 5.6, the migration happens offline and locks the table. However, since we only have about 20k columns, it shouldn't take too long.\n\nTest Plan: Upgraded a db dump.\n\nReviewers: kav-ya, emfre... | python | chosen |
[
{
"from": "human",
"value": "Test TRIPS ontology with disease names\n"
},
{
"from": "gpt",
"value": "from bioagents.resources.trips_ont_manager import trips_isa\n\ndef test_isa_disease():\n assert trips_isa('diabetes', 'disease')\n assert not trips_isa('disease', 'diabetes')\n assert tr... | python | chosen |
[
{
"from": "human",
"value": "Add script to split HMP fasta into multiple files\n\n\nFormer-commit-id: c7ec294cec9435208ab552ff76df0245a6825082"
},
{
"from": "gpt",
"value": "#! /usr/bin/env python3\n\nimport os, argparse\n\ndef split_fs(output_dir_fn):\n\ti = 0\n\twhile True:\n\t\ti += 1\n\t\tfn... | python | chosen |
[
{
"from": "human",
"value": "Add gensim to sense2vec format converter script\n"
},
{
"from": "gpt",
"value": "from sense2vec.vectors import VectorMap\nfrom gensim.models import Word2Vec\nimport plac\n\n@plac.annotations(\n gensim_model_path=(\"Location of gensim's .bin file\"),\n out_dir=(... | python | chosen |
[
{
"from": "human",
"value": "Add a confusion matrix plot\n"
},
{
"from": "gpt",
"value": "import matplotlib.pylab as plt\nimport numpy as np\nimport seaborn as sns\nfrom sklearn.metrics import confusion_matrix\n\nnp.random.seed(314151692)\ny_pred = np.random.random_integers(0, 1, 1000)\ny_true =... | python | chosen |
[
{
"from": "human",
"value": "Add the module to measure computational times\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom __future__ import (absolute_import, division,\n print_function, unicode_literals)\n\n__author__ = \"Yuji Ikeda\"... | python | chosen |
[
{
"from": "human",
"value": "Add welcome to code jam\n"
},
{
"from": "gpt",
"value": "#!/usr/bin/env python\n\n# Google Code Jam\n# Google Code Jam 2009\n# Qualification Round 2009\n# Problem C. Welcome to Code Jam\n\nfrom __future__ import print_function\n\nSUBSTRING = 'welcome to code jam'\n\n... | python | chosen |
[
{
"from": "human",
"value": "Add set up scripts to install dependencies\n"
},
{
"from": "gpt",
"value": "import pip\nimport os\n\nprojectName = ''\n\ndef install(package):\n pip.main(['install', package])\n\ndef installAll():\n allPackages = [\n 'deap',\n 'numpy',\n ]\n ... | python | chosen |
[
{
"from": "human",
"value": "Add tests for cbio client\n"
},
{
"from": "gpt",
"value": "from bioagents import cbio_client\n\ndef test_get_cancer_studies():\n study_ids = cbio_client.get_cancer_studies('pancreatic')\n assert(len(study_ids) > 0)\n assert('paad_tcga' in study_ids)\n\ndef t... | python | chosen |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.