conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add some tests to make sure we're seeking efficiently\n" }, { "from": "gpt", "value": "import steel\nimport io\nimport unittest\n\n\nclass SeekIO(io.BytesIO):\n \"\"\"\n A variation of BytesIO that keeps track of all .seek() activity.\n This can test whether...
python
chosen
[ { "from": "human", "value": "Add test for the new bip32 test vectors\n" }, { "from": "gpt", "value": "import json\nfrom unittest import TestCase\n\nfrom bitmerchant.network import BitcoinMainNet\nfrom bitmerchant.wallet import Wallet\n\n\nclass TestBIP32(TestCase):\n def _test_wallet(self, wa...
python
chosen
[ { "from": "human", "value": "Add tests to assess algorithm quality.\n\nTo test the quality, implement an exact algorithm to count the number\nof ones in the last N elements of a stream.\nThen compare the dgim result with the exact result and check that the\ndgim estimates is in the expected bounds.\n" }, ...
python
chosen
[ { "from": "human", "value": "Implement a script to re-send data from log\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport sys\nimport re\nimport socket\nimport binascii\n\nif len(sys.argv) < 2:\n sys.exit(\"log file is not provided\")\n\npath = sys.argv[1]\np = re.compile(r\"\\d{4...
python
chosen
[ { "from": "system", "value": "Remove extra unneeded empty line.\n" }, { "from": "human", "value": "from __future__ import unicode_literals, division, absolute_import\nimport logging\nimport urllib\n\nfrom flexget import plugin\nfrom flexget.event import event\n\nlog = logging.getLogger('cinemage...
python
chosen
[ { "from": "human", "value": "Add script to collect files.\n" }, { "from": "gpt", "value": "# Script to create tar.gz package. This will replace automake based \"make dist\".\nimport os\n\nPACKAGE=\"iroha\"\nVERSION=\"0.1.0\"\n\nARCHIVE=PACKAGE + \"-\" + VERSION\n\nEXTRA = [\"configure.ac\", \"co...
python
chosen
[ { "from": "human", "value": "Add k-folds CV with SVM\n" }, { "from": "gpt", "value": "import csv\nfrom os.path import dirname, join\nimport time\n\nimport numpy as np\nfrom sklearn.feature_extraction.text import CountVectorizer\nfrom sklearn.model_selection import cross_val_score, StratifiedKFol...
python
chosen
[ { "from": "system", "value": "Add st2_auth_token to masked attributes list.\n" }, { "from": "human", "value": "# Licensed to the StackStorm, Inc ('StackStorm') under one or more\n# contributor license agreements. See the NOTICE file distributed with\n# this work for additional information regar...
python
chosen
[ { "from": "human", "value": "Add some file utility functions.\n" }, { "from": "gpt", "value": "# -*- encoding: utf-8 -*-\n\nimport os\nimport errno\n\n\ndef ensure_intermediate_dir(path):\n \"\"\"\n Basiclly equivalent to command `mkdir -p`\n\n \"\"\"\n\n try:\n\n os.makedirs(...
python
chosen
[ { "from": "human", "value": "TEST: Add tests checking that we get the names right.\n" }, { "from": "gpt", "value": "\"\"\"\nTest the func_inspect module.\n\"\"\"\n\n# Author: Gael Varoquaux <gael dot varoquaux at normalesup dot org> \n# Copyright (c) 2009 Gael Varoquaux\n# License: BSD Style, 3 ...
python
chosen
[ { "from": "human", "value": "Create an IRC parser base to replace the Twisted one\n" }, { "from": "gpt", "value": "from twisted.protocols.basic.LineOnlyReceiver\n\nclass IRCBase(LineOnlyReceiver):\n\tdelimiter = \"\\n\" # Default to splitting by \\n, and then we'll also split \\r in the handler\...
python
chosen
[ { "from": "human", "value": "Add a test that the feed passes validation\n" }, { "from": "gpt", "value": "# -*- encoding: utf-8\n\nimport feedvalidator\nfrom feedvalidator import compatibility\nfrom feedvalidator.formatter.text_plain import Formatter\n\n\ndef test_feed_passes_validation():\n e...
python
chosen
[ { "from": "human", "value": "tests: Add basics test for gc module.\n" }, { "from": "gpt", "value": "# basic tests for gc module\n\ntry:\n import gc\nexcept ImportError:\n print(\"SKIP\")\n import sys\n sys.exit()\n\nprint(gc.isenabled())\ngc.disable()\nprint(gc.isenabled())\ngc.enabl...
python
chosen
[ { "from": "human", "value": "Add test case for login form.\n" }, { "from": "gpt", "value": "from . import TheInternetTestCase\nfrom helium.api import Text, write, press, ENTER, click\n\nclass BasicAuthTest(TheInternetTestCase):\n\tdef get_page(self):\n\t\treturn \"http://the-internet.herokuapp.c...
python
chosen
[ { "from": "human", "value": "Add missing init in web_widget_darkroom\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# © 2016-TODAY LasLabs Inc.\n# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).\n" } ]
python
chosen
[ { "from": "human", "value": "Solve connected cell in a grid\n" }, { "from": "gpt", "value": "class Grid(object):\n\n def __init__(self, grid):\n self.grid = grid\n self.rows = len(grid)\n self.cols = len(grid[0])\n\n def largest_region(self):\n return max([self....
python
chosen
[ { "from": "human", "value": "Allow 'setup.py test' to see the test package\n" }, { "from": "gpt", "value": "\"\"\"\nCopyright (C) 2016 STFC.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a co...
python
chosen
[ { "from": "human", "value": "Add a solution for ploblem 284: Peeking Iterator.\n" }, { "from": "gpt", "value": "# https://leetcode.com/problems/peeking-iterator/\n# We just need to buffer the current object of the iterator. When peek(), return the buffered object. When next(), return the buffere...
python
chosen
[ { "from": "human", "value": "Add file to convert IUCAA FITS *.evt file to txt format suitable for input to feature extraction program\n" }, { "from": "gpt", "value": "#! /usr/bin/python3\n\nimport sys\nimport os\nimport math\nfrom astropy.io import fits\n\ninputFolder = sys.argv[1]\noutputFolder...
python
chosen
[ { "from": "human", "value": "Add template tag to get featured products for a list of categories\n" }, { "from": "gpt", "value": "from django import template\n\nimport plata\n\n\nregister = template.Library()\n\n\n@register.simple_tag\ndef featured_products_for_categories(category_list, variable_...
python
chosen
[ { "from": "human", "value": "Add simple test for find_peaks.\n\n\n" }, { "from": "gpt", "value": "import numpy as np\nfrom numpy.testing import TestCase, assert_array_equal, \\\n assert_array_almost_equal, dec\n\nfrom scikits.talkbox.misc.peak_picking import find_peaks\n...
python
chosen
[ { "from": "human", "value": "Add script that collects weather data from worldweatheronline.com\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\n\n'''\nscript that collects weather data from\n'''\n\nimport urllib.request\nimport sys\nimport os\nimport time\nfrom datetime import date, timedelt...
python
chosen
[ { "from": "human", "value": "Add a python scrip that stitches together annotated toponym json\n" }, { "from": "gpt", "value": "#Make Annotation Files\nimport os\n\n\n\ndocgeo_directory = \"/Users/grant/devel/GeoAnnotate/docgeo_spans_dloaded_103115\"\ntoponym_directory = \"/Users/grant/devel/GeoA...
python
chosen
[ { "from": "human", "value": "Add testing for reraise function\n\n" }, { "from": "gpt", "value": "import nose.tools as nt\n\nfrom .. import utils\n\n\ndef test_reraise_context():\n with nt.assert_raises(ValueError) as cm:\n try:\n raise ValueError('Initial Exception message.'...
python
chosen
[ { "from": "human", "value": "Solve Code Fights are equally strong problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Are Equally Strong Problem\n\n\ndef areEquallyStrong(yourLeft, yourRight, friendsLeft, friendsRight):\n s = {yourLeft, yourRight, friendsLeft, frie...
python
chosen
[ { "from": "human", "value": "Add ability to carry settings from botconfig to var.\u000f\n" }, { "from": "gpt", "value": "import botconfig\nfrom settings import wolfgame as var\n\n# Todo: Allow game modes to be set via config\n\n# Carry over settings from botconfig into settings/wolfgame.py\n\nfo...
python
chosen
[ { "from": "human", "value": "SPOT-1101: Add unit test for building API v1\n" }, { "from": "gpt", "value": "from django.test import TestCase\nfrom django.conf import settings\nfrom django.test.client import Client\nfrom spotseeker_server.models import Spot, SpotExtendedInfo\nfrom spotseeker_serve...
python
chosen
[ { "from": "human", "value": "Add tests to make sure the examples run\n" }, { "from": "gpt", "value": "from LiSE.examples import college, kobold, polygons, sickle\n\n\ndef test_college(engy):\n college.install(engy)\n engy.turn = 10 # wake up the students\n engy.next_turn()\n\n\ndef tes...
python
chosen
[ { "from": "human", "value": "[ADD] Add script to remove all local identities\n" }, { "from": "gpt", "value": "import sys\nfrom MaKaC.common.db import DBMgr\nfrom MaKaC.user import AvatarHolder\nfrom MaKaC.authentication import AuthenticatorMgr\nfrom MaKaC.authentication.LocalAuthentication impor...
python
chosen
[ { "from": "human", "value": "Add new file for numpy library usage\n" }, { "from": "gpt", "value": "'''\n2.1 - Numpy Array library\n'''\nimport numpy as np\n\ndef main():\n n = 10\n a = [x**2 for x in range(n)]\n b = [x**3 for x in range(n)]\n v = plainVectorAddition(a, b)\n print(...
python
chosen
[ { "from": "human", "value": "Reformat words_2w.txt to sort and remove caps.\n" }, { "from": "gpt", "value": "# Intended to be used with count_2w.txt which has the following format:\n# A B\\tFREQENCY\n# Sometimes \"A\" is \"<S>\" for start and \"</S>\" for end.\n# Output is similar with all outpu...
python
chosen
[ { "from": "human", "value": "Add Android test runner script for WebRTC.\n\nThe Android test execution toolchain scripts in Chromium\nhas been causing headaches for us several times. Mostly\nbecause they're tailored at running Chrome tests only.\n\nWrapping their script in our own avoids the pain of\nupstrea...
python
chosen
[ { "from": "human", "value": "Add very simple MQTT sender setup\n" }, { "from": "gpt", "value": "# coding=utf-8\n\nimport sys\nimport time\nimport paho.mqtt.client as paho\n\n\ndef on_connect(client, userdata, flags, rc):\n print(\"MQTT CONNACK received with code %d.\" % (rc))\n client.subs...
python
chosen
[ { "from": "human", "value": "Migrate existing code to new project.\n" }, { "from": "gpt", "value": "class Command:\n \"\"\"\n The definition of a command line command, allows specification of the command itself\n the options it expects and also optional arguments\n \"\"\"\n def __...
python
chosen
[ { "from": "human", "value": "Add Aizek remote control example\n\nChange-Id: I713c0cce94ca0f312c3f6eb14c69c44b31751eaa\n" }, { "from": "gpt", "value": "from robotics.robots.factory import RobotFactory\nfrom robotics.robots.proxy import AizekProxy\nfrom zmq import zmq_server\n\n\ndef main():\n ...
python
chosen
[ { "from": "human", "value": "Add Python script for fetching the latest FMI Testbed image\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\"\"\"A script for downloading the current FMI Testbed image and sending\nit to a storage backend.\"\"\"\n\nimport argparse\nimport base64\nimport sys...
python
chosen
[ { "from": "human", "value": "Add CLI utils for DB recreate\n\nWe should be able to init DB for rally from CLI\n\nblueprint db-task-track\n\nChange-Id: I52804e86b24d0e9334687d2545ada9a6a00595de\n" }, { "from": "gpt", "value": "# vim: tabstop=4 shiftwidth=4 softtabstop=4\n\n# Copyright 2013: Miran...
python
chosen
[ { "from": "human", "value": "Add acceptable subjects to provider script\n" }, { "from": "gpt", "value": "from modularodm import Q\n\nfrom website.app import init_app\nfrom website.models import Subject, PreprintProvider\n\ndef find_child_and_grandchild(grandpa, childIndex=0):\n parent = Subje...
python
chosen
[ { "from": "human", "value": "Add ability to display the name table.\n" }, { "from": "gpt", "value": "\n_name_ids = {\n 0: { 'short': 'Copyright', 'name': 'Copyright notice' }, \n 1: { 'short': 'Family', 'name': 'Font Family name' }, \n 2: { 'short': 'Subfamily', 'name': 'Font Subfamily ...
python
chosen
[ { "from": "human", "value": "Create base files for adding tests to the project.\n" }, { "from": "gpt", "value": "\"\"\"takeout_inspector/tests/__init__.py\n\nTests for the main Takeout Inspector module.\n\nCopyright (c) 2016 Christopher Charbonneau Wells\n\nPermission is hereby granted, free of ...
python
chosen
[ { "from": "human", "value": "Add a test that interacts with the client backend.\n" }, { "from": "gpt", "value": "\"\"\"\nCreate an actual instance of one of the client/server components and make sure\nwe can talk to it.\n\"\"\"\n\nfrom twisted.internet import reactor, task\nfrom twisted.internet...
python
chosen
[ { "from": "human", "value": "Add migration for Exchange bookkeeping.\n" }, { "from": "gpt", "value": "\"\"\"eas_add_device_retirement\n\nRevision ID: 246a6bf050bc\nRevises: 3b093f2d7419\nCreate Date: 2015-07-17 02:46:47.842573\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\nrevision = '24...
python
chosen
[ { "from": "human", "value": "Add test for our manager and shortcut\n" }, { "from": "gpt", "value": "import time\n\nfrom django.contrib.auth.models import User\nfrom django.test import TestCase\nfrom django.utils import timezone\n\nfrom quickstats import models, shortcuts\n\n\nclass SamplesTest(T...
python
chosen
[ { "from": "human", "value": "Add example unit test for the Breton starter project.\n" }, { "from": "gpt", "value": "import unittest\n\nclass TestStringMethods(unittest.TestCase):\n\n def test_upper(self):\n self.assertEqual('foo'.upper(), 'FOO')\n\nif __name__ == '__main__':\n unitt...
python
chosen
[ { "from": "human", "value": "Implement doc comment => XML DB script for state message descriptions\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\ndescription = \"\"\"State Message Parser\n\nParses all the code in the MINDS-i-Drone project looking for comments formatted\nto contain /*...
python
chosen
[ { "from": "human", "value": "Add examples dir with Tornado example source\n" }, { "from": "gpt", "value": "import tornado.web\nfrom tornado.ioloop import IOLoop\nfrom pushka import AmazonSESService\n\n# NOTE: make sure your Amazon SES user has `ses:SendEmail` permission!\n# Here's user policy ex...
python
chosen
[ { "from": "human", "value": "Add script to renew user sessions\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n\"\"\"Log out users by renewing their session tokens.\n\nThis is meant to be used when new terms of service are published so\nusers have to log in again and are presented the ...
python
chosen
[ { "from": "human", "value": "Add new class to cache killmails indefinitely, forever\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport sqlite3\nimport json\nfrom classes.sitecfg import SiteConfig\n\n\nclass KillMailsCache:\n def __init__(self, siteconfig: SiteConfig):\n s...
python
chosen
[ { "from": "human", "value": "Add function for drawing font with border\n" }, { "from": "gpt", "value": "\"\"\" PIL doesn't have a built-in method for drawing text with a border \"\"\"\nfrom PIL import ImageFont\n\n\ndef drawTextWithBorder(draw, text, coords,\n fontname=\"Im...
python
chosen
[ { "from": "human", "value": "Add test for `refund_order` function of `facade` module\n" }, { "from": "gpt", "value": "from decimal import Decimal as D\nfrom unittest.mock import patch\n\nfrom django.test import TestCase\nfrom paypalhttp.http_response import construct_object\n\nfrom paypal.expres...
python
chosen
[ { "from": "human", "value": "Add simple rate limiting util\n" }, { "from": "gpt", "value": "from dimagi.utils.couch.cache.cache_core import get_redis_client\n\n\ndef rate_limit(key, actions_allowed=60, how_often=60):\n \"\"\"\n A simple util to be used for rate limiting, using redis as a b...
python
chosen
[ { "from": "human", "value": "Add script to guess the language of all documents\n\nInput: directory with text files\nOutput: csv file that specifies the language of each document in\nthe input dir\n" }, { "from": "gpt", "value": "import click\nimport os\nimport codecs\nimport pandas as pd\n\nfrom...
python
chosen
[ { "from": "human", "value": "Add ipython config file with notebook dir set to /work\n" }, { "from": "gpt", "value": "c = get_config()\n\n# Kernel config\nc.IPKernelApp.pylab = 'inline' # if you want plotting support always\n\n# Notebook config\nc.NotebookApp.ip = '*'\nc.NotebookApp.open_browser...
python
chosen
[ { "from": "human", "value": "Add in a kvm collector that collects the same stats as kvm_stat does\n" }, { "from": "gpt", "value": "\nfrom diamond import *\nimport diamond.collector\nimport os\n\nclass KVMCollector(diamond.collector.Collector):\n \"\"\"\n Collects /sys/kernel/debug/kvm/*\n ...
python
chosen
[ { "from": "human", "value": "Add initial word counting file.\n" }, { "from": "gpt", "value": "#!/usr/bin/python\nimport re\n# this one in honor of 4th July, or pick text file you have!!!!!!!\nfilename = 'out.txt'\n# create list of lower case words, \\s+ --> match any whitespace(s)\n# you can rep...
python
chosen
[ { "from": "human", "value": "Add sample use of RxPy.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nfrom auth_tokens import *\nfrom rx import Observable\n\n\ntry:\n import json\nexcept ImportError:\n import simplejson as json\n\nfrom twitter import Twitter, OAuth, TwitterHTTPEr...
python
chosen
[ { "from": "human", "value": "Put command-line code into separate file\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport argparse\nimport logging\nimport sys\n\nimport numpy as np\n\nfrom sos import SOS\n\ndef get_stdout():\n\n if sys.version_info.major < 3:\n return sys....
python
chosen
[ { "from": "human", "value": "Add `submitted_at` migration to `brief_responses` table\n\nRepresents when a brief response has been submitted and is therefore\na complete response, as opposed to one that may be in a draft form.\nNote, we choose not to use the word \"published\" as a brief response\nis not pub...
python
chosen
[ { "from": "human", "value": "Add nagios script for room temps" }, { "from": "gpt", "value": "\"\"\"\nGateway for B548 temps to nagios, this way I can setup alerts via it\n\nArray(\"In Air Handler\", \"Out Air Handler\", \"Out Rack\", \"In Rack\")\n0 70.25\n1 57.88\n2 88.25\n3 62.04\n\"\"\"\nimpo...
python
chosen
[ { "from": "human", "value": "Add ST to run manifest convert tests\n" }, { "from": "gpt", "value": "# Copyright (c) 2015-2017 Tigera, Inc. All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the Licens...
python
chosen
[ { "from": "human", "value": "Add unit tests for turbopump.\n" }, { "from": "gpt", "value": "import unittest\nimport turbopump\n\nclass TestStringMethods(unittest.TestCase):\n\n def test_m_dot2gpm(self):\n # 100 kg s**-1, 1000 kg m**-3 --> 1584 gal min**-1\n self.assertAlmostEqua...
python
chosen
[ { "from": "human", "value": "Add a settings module for production\n" }, { "from": "gpt", "value": "from trex.settings_global import *\n\nDEBUG = False\n\nREST_FRAMEWORK = {\n # don't use BrowsableAPIRenderer\n \"DEFAULT_RENDERER_CLASSES\": {\n \"rest_framework.renderers.JSONRenderer...
python
chosen
[ { "from": "human", "value": "Add test for non-string (integer) parameter value\n" }, { "from": "gpt", "value": "import logging\nimport luigi\nimport sciluigi as sl\nimport os\nimport time\nimport unittest\n\nlog = logging.getLogger('sciluigi-interface')\nlog.setLevel(logging.WARNING)\n\n\nclass ...
python
chosen
[ { "from": "human", "value": "Add Filter tests. Regular expressions are broken.\n" }, { "from": "gpt", "value": "import unittest\n\nfrom pypercube.filters import Filter\nfrom pypercube.filters import EQ\nfrom pypercube.filters import LT\nfrom pypercube.filters import LE\nfrom pypercube.filters im...
python
chosen
[ { "from": "human", "value": "Add tests to show what the Weekday object does\n" }, { "from": "gpt", "value": "import pytest\nfrom recurrence import Weekday\n\n\ndef test_init():\n assert repr(Weekday(3)) == 'TH'\n assert repr(Weekday(3, -2)) == '-2TH'\n assert repr(Weekday(3, 3)) == '3TH...
python
chosen
[ { "from": "system", "value": "uwsgi: Fix test to use proper Content-type for json test\n" }, { "from": "human", "value": "import ujson\n\n\ndef application(environ, start_response):\n response = {\n \"message\": \"Hello, World!\"\n }\n data = ujson.dumps(response)\n response_hea...
python
chosen
[ { "from": "human", "value": "1.3.2dev: Add upgrade script missing from r15749\n\nRefs #12719.\n\n\ngit-svn-id: 0d96b0c1a6983ccc08b3732614f4d6bfcf9cbb42@15765 af82e41b-90c4-0310-8c96-b1721e28e2e2\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) 2017 Edgewall Software\n...
python
chosen
[ { "from": "human", "value": "Add script for taking mysqldump" }, { "from": "gpt", "value": "import ConfigParser\nimport os\nimport time\nimport getpass\n\ndef get_dump():\n print \"Enter user:\"\n user = raw_input()\n\n print \"Password will not be visible:\"\n password = getpass.get...
python
chosen
[ { "from": "human", "value": "Add back catch_error which is used for CLI errors\n\nChange-Id: Ib8b975d22950d5ba6aa9d5f150403a64356a8aa3\nSigned-off-by: Jeff Peeler <d776211e63e47e40d00501ffdb86a800e0782fea@redhat.com>\n" }, { "from": "gpt", "value": "# vim: tabstop=4 shiftwidth=4 softtabstop=4\n\...
python
chosen
[ { "from": "human", "value": "Add test for size of batches\n" }, { "from": "gpt", "value": "import pytest\n\nimport theano\nimport theano.tensor as T\nimport numpy as np\n\nfrom lasagne.layers import InputLayer, ReshapeLayer, DenseLayer\nfrom lasagne.layers import get_output, get_all_param_values...
python
chosen
[ { "from": "human", "value": "Add no loop version of Program1" }, { "from": "gpt", "value": "#\n# Explain what this program does\n#\n\nnumberOne = int(input(\"Number? \"))\naction = input(\"Action (+, -, / or *)? \")\nnumberTwo = int(input(\"Number? \"))\nif action == \"+\":\n print()\n pri...
python
chosen
[ { "from": "human", "value": "Add management command to fix sheet countries\n" }, { "from": "gpt", "value": "from django.core.management.base import BaseCommand\nfrom django.db.models import F\nfrom forms.models import sheet_models\n\nclass Command(BaseCommand):\n def handle(self, *args, **opt...
python
chosen
[ { "from": "human", "value": "Implement sample module and doctest\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\ndef add(x, y):\n \"\"\"\n 引数xとyを加算した結果を返す\n >>> add(2, 3)\n 5\n \"\"\"\n return x + y\n" } ]
python
chosen
[ { "from": "human", "value": "Add example of how to define your own state relation\n" }, { "from": "gpt", "value": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom math import log\nfrom rsfmodel import rsf\n\n# This is really just the Ruina realtion, but let's pretend we invented it!\n#...
python
chosen
[ { "from": "human", "value": "Add migration to set start time to local timzeone\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.15 on 2020-02-26 07:38\nfrom __future__ import unicode_literals\nfrom datetime import datetime\nfrom timezonefinder import TimezoneF...
python
chosen
[ { "from": "human", "value": "Add one sample usage file.\n" }, { "from": "gpt", "value": "# coding: utf-8\nfrom omega_client import OmegaClient\n\nclt = OmegaClient('http://offlineforward.dataman-inc.net', 'admin@shurenyun.com', 'Dataman1234')\n\nprint clt.get_clusters()\nprint clt.get_cluster(63...
python
chosen
[ { "from": "human", "value": "Add tests for additional functionality provided by NameAtomFeedType.\n" }, { "from": "gpt", "value": "import pytest\n\nfrom django.core.urlresolvers import reverse\n\nfrom name.models import Name, Location\n\npytestmark = pytest.mark.django_db\n\n\ndef test_feed_has_...
python
chosen
[ { "from": "human", "value": "Add tests for str_is_unicode module\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\n\nfrom future import str_is_unicode\n\nimport unittest\n\nclass TestIterators(unittest.TestCase):\n def test_str(self):\n self.assertIsNot(str, byte...
python
chosen
[ { "from": "human", "value": "Add basic test for DatetimeJSONEncoder\n" }, { "from": "gpt", "value": "import datetime\nimport json\nimport unittest\n\nfrom clippings.utils import DatetimeJSONEncoder\n\n\nDATE = datetime.datetime(2016, 1, 2, 3, 4, 5)\nDATE_STRING = \"2016-01-02T03:04:05\"\n\n\ncla...
python
chosen
[ { "from": "human", "value": "Solve Code Fights is sum consecutive 2 problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Is Sum Consecutive 2 Problem\n\n\ndef isSumConsecutive2(n):\n count = 0\n nums = list(range(1, n))\n for i in range(len(nums)):\n fo...
python
chosen
[ { "from": "human", "value": "Add tests for to_ascii function.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Licensed to the StackStorm, Inc ('StackStorm') under one or more\n# contributor license agreements. See the NOTICE file distributed with\n# this work for additional informat...
python
chosen
[ { "from": "human", "value": "Add test for utcdatetime.time() method\n" }, { "from": "gpt", "value": "import utcdatetime\n\nfrom nose.tools import assert_equal\n\nimport datetime\n\n\nTEST_CASES = [\n (\n utcdatetime.utcdatetime(2015, 5, 11, 16, 43, 10, 45),\n datetime.time(16, 4...
python
chosen
[ { "from": "human", "value": "Add script for breaking titles into lines\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport sys\nimport os\nimport yaml\nimport re\n\nfile = sys.argv[1]\nmetafile = re.sub(\"-.*$\", \".yml\", file)\nproject = os.environ[\"PROJECT\"]\nmetadata = open(me...
python
chosen
[ { "from": "system", "value": "Enumerate through choices of property values\n" }, { "from": "human", "value": "from fixture import GeneratorTest\nfrom google.appengine.ext import testbed, ndb\n\n\nclass PropsTest(GeneratorTest):\n\n def testLotsaModelsGenerated(self):\n for klass in sel...
python
chosen
[ { "from": "human", "value": "Add config for POX l2_multi traces\n" }, { "from": "gpt", "value": "from config.experiment_config_lib import ControllerConfig\nfrom sts.topology import StarTopology, BufferedPatchPanel, MeshTopology, GridTopology, BinaryLeafTreeTopology\nfrom sts.controller_manager i...
python
chosen
[ { "from": "human", "value": "Add writeboard list via generic views " }, { "from": "gpt", "value": "from django.conf.urls.defaults import *\nfrom models import Writeboard\n\nwriteboard_list_dict = {\n 'queryset': Writeboard.objects.all(),\n}\n\nurlpatterns = patterns('',\n (r'$','django.views...
python
chosen
[ { "from": "human", "value": "Add utility script to get a file's digest, useful for debugging purpose\n" }, { "from": "gpt", "value": "import sys\nimport hashlib\n\nFILE_BUFFER_SIZE = 4096\n\n\ndef get_digest(file_path, digest_func='md5'):\n digester = getattr(hashlib, digest_func, None)\n ...
python
chosen
[ { "from": "human", "value": "Add script to help generate CHANGELOG.md\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\nchangelog.py helps generate the CHANGELOG.md message for a particular release.\n\"\"\"\n\nimport argparse\nimport subprocess\nimport shlex\nimport re\n\n\ndef run...
python
chosen
[ { "from": "human", "value": "Add a script to enumerate configurations for benchmarking.\n" }, { "from": "gpt", "value": "import datetime\r\nimport itertools\r\nimport os\r\nimport subprocess\r\n\r\n# Modify parameters here\r\nout_directory = datetime.datetime.now().strftime('benchmark_%Y-%m-%d_%...
python
chosen
[ { "from": "human", "value": "Add tests for the compat module.\n" }, { "from": "gpt", "value": "import unittest\n\nfrom mock import Mock, patch\n\n\nfrom collectd_haproxy import compat\n\n\nclass CompatTests(unittest.TestCase):\n\n @patch.object(compat, \"PY3\", False)\n def test_iteritems_...
python
chosen
[ { "from": "human", "value": "Add a project in the 'incubator'.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n# Copyright (c) 2013 Jérémie DECOCK (http://www.jdhp.org)\n\n# http://en.wikipedia.org/wiki/SubRip\n# http://forum.doom9.org/showthread.php?p=470941#...
python
chosen
[ { "from": "human", "value": "Add script to do investment generation payment order\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport sys\nfrom erppeek import Client\nimport configdb\nimport datetime\n\n'''\n Script que agafa les inversions en esborrany i g...
python
chosen
[ { "from": "human", "value": "Add a EXIF extract utility. Later the EXIF \"EXIF DateTimeOriginal\" and\n\"EXIF SubsecTimeOriginal\" will be used to identify the same pic by\ntaken time and subsec.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport sys,exifread\n\ndef main():\n\tif l...
python
chosen
[ { "from": "human", "value": "Add call by object illustration example with object ids.\n\nSigned-off-by: SJ Huang <55a36c562e010d4b156739b1c231e1aa17113c8e@gmail.com>\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# _*_ coding: utf-8 _*_\n\nu\"\"\" From first entry of https://github.com/...
python
chosen
[ { "from": "human", "value": "Add corresponding migration for the Identifier related_name conflict\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 depen...
python
chosen
[ { "from": "human", "value": "Test for server handler is added\n" }, { "from": "gpt", "value": "import webapp2\nimport unittest\nimport webtest\nfrom gae_server.incremental_fonts import IncrementalFonts\n\n\nclass AppTest(unittest.TestCase):\n def setUp(self):\n # Create a WSGI applicat...
python
chosen
[ { "from": "human", "value": "Add solution for 66 Plus One.\n" }, { "from": "gpt", "value": "class Solution(object):\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n digits[len(digits)-1] += 1\n if digits[l...
python
chosen
[ { "from": "human", "value": "Add a Twitter bot that creates dialog from Star Wars text using Markov models\n" }, { "from": "gpt", "value": "import tweepy\nimport markovify\nimport sys, random, time\n\nck = ''\ncs = ''\nak = ''\nase = ''\nauth = tweepy.OAuthHandler(ck, cs)\nauth.set_access_token(...
python
chosen
[ { "from": "human", "value": "Add tests for Character class\n" }, { "from": "gpt", "value": "import npc\n\nclass TestCreation:\n \"\"\"Test different instantiation behaviors\"\"\"\n\n def test_dict(self):\n char = npc.Character({\"name\": [\"hello\"]})\n assert char[\"name\"] ...
python
chosen
[ { "from": "human", "value": "Add a new script processing different iterations of a run and computing statistics\n" }, { "from": "gpt", "value": "import packages.project as project\nimport packages.primitive as primitive\nimport packages.utils as utils\nimport packages.processing\nimport packages...
python
chosen