conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Create test case for tail from file\n" }, { "from": "gpt", "value": "\"\"\"\nTests for the tail implementation\n\"\"\"\n\nfrom tail import FileTail\n\ndef test_tail_from_file():\n \"\"\"Tests that tail works as advertised from a file\"\"\"\n\n from unittest.moc...
python
chosen
[ { "from": "human", "value": "Add page extension for tracking page creation and modification dates.\n\nThis can be used in conjunction with a response processor to set the \"last-modified\" or \"etag\" response headers.\n" }, { "from": "gpt", "value": "\"\"\"\nTrack the modification date for page...
python
chosen
[ { "from": "human", "value": "Add missing tests for messaging notifer plugin\n\nChange-Id: I1a206fdbbb89c03b04eafe0ad850441094e363e5\n" }, { "from": "gpt", "value": "# Copyright 2014 Mirantis Inc.\n# All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); y...
python
chosen
[ { "from": "human", "value": "Add script to normalize the spelling in a dataset\n\nAdded a script that normalizes the spelling in a dataset consisting of\nfiles containing <sentence_id> \\t <sentence> \\t <label(s)>\n" }, { "from": "gpt", "value": "\"\"\"Create multilabel data set with normalized...
python
chosen
[ { "from": "human", "value": "Add solution for compare version numbers\n" }, { "from": "gpt", "value": "\"\"\"\nSource : https://oj.leetcode.com/problems/compare-version-numbers/\nAuthor : Changxi Wu\nDate : 2015-01-23\n\nCompare two version numbers version1 and version2.\n\nif version1 > versi...
python
chosen
[ { "from": "human", "value": "Test driving robot via serial input\n" }, { "from": "gpt", "value": "import nengo\n\nimport nengo_pushbot\nimport numpy as np\n\nmodel = nengo.Network()\nwith model:\n input = nengo.Node(lambda t: [0.5*np.sin(t), 0.5*np.cos(t)])\n\n a = nengo.Ensemble(nengo.LIF...
python
chosen
[ { "from": "human", "value": "contrib: Add a python script to start sysmobts-remote and dump docs\n\nThis starts sysmobts-remote and dumps the documentation about the\nVTY to the doc/ directory.\n\n$ ./contrib/dump_docs.py\nthis writes doc/vty_reference.xml\n" }, { "from": "gpt", "value": "#!/usr...
python
chosen
[ { "from": "human", "value": "Add starter code for Lahman db\n" }, { "from": "gpt", "value": "################################################\n# WORK IN PROGRESS: ADD LAHMAN DB TO PYBASEBALL\n# TODO: Make a callable function that retrieves the Lahman db\n# Considerations: users should have a way...
python
chosen
[ { "from": "system", "value": "Add a body to posts\n" }, { "from": "human", "value": "from django.contrib.auth.models import User\nfrom django.db import models\n\n\nclass Discussion(models.Model):\n user = models.ForeignKey(User)\n name = models.CharField(max_length=255)\n slug = models....
python
chosen
[ { "from": "human", "value": "Create database import script for the Picks table (each NFLPool Player's picks for a given season)\n" }, { "from": "gpt", "value": "import sqlite3\n\nconn = sqlite3.connect('nflpool.sqlite')\ncur = conn.cursor()\n\n# Do some setup\ncur.executescript('''\nDROP TABLE I...
python
chosen
[ { "from": "system", "value": "Add column order and importable objects lists\n" }, { "from": "human", "value": "# Copyright (C) 2013 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: dan@recipro...
python
chosen
[ { "from": "human", "value": "Add little script calculate sample spectra.\n" }, { "from": "gpt", "value": "'''\nCreated on Oct 12, 2015\n\n@author: wirkert\n'''\n\nimport pickle\nimport logging\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport luigi\n\nimport tasks_regression as rt\n...
python
chosen
[ { "from": "human", "value": "[RM-11742] Add argparse tests for ceph-deploy admin\n\nSigned-off-by: Travis Rhoden <e5e44d6dbac12e32e01c3bb8b67940d8b42e225b@redhat.com>\n" }, { "from": "gpt", "value": "import pytest\n\nfrom ceph_deploy.cli import get_parser\n\n\nclass TestParserAdmin(object):\n\n ...
python
chosen
[ { "from": "human", "value": "Add to support the chinese library\n" }, { "from": "gpt", "value": "# Naver Search Workflow for Alfred 2\n# Copyright (C) 2013 Jinuk Baek\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public Lice...
python
chosen
[ { "from": "human", "value": "Add missing migration (updating validators=)\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.7 on 2016-07-22 22:03\nfrom __future__ import unicode_literals\n\nimport django.core.validators\nfrom django.db import migrations, models\...
python
chosen
[ { "from": "human", "value": "Add test for kline result of exact amount\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# coding=utf-8\n\nfrom binance.client import Client\nimport pytest\nimport requests_mock\n\n\nclient = Client('api_key', 'api_secret')\n\n\ndef test_exact_amount():\n ...
python
chosen
[ { "from": "human", "value": "Remove learner_testimonials column from course_metadata course run table\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.15 on 2018-11-07 17:16\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nclas...
python
chosen
[ { "from": "human", "value": "Add celery based job runner\n" }, { "from": "gpt", "value": "import os\nfrom time import time\nimport logging\n\nimport pandas as pd\n\nfrom celery import Celery\nfrom billiard import current_process\n\n\napp = Celery()\n\n@app.task(autoretry_for=(Exception,), max_re...
python
chosen
[ { "from": "human", "value": "Add test of randomized select algorithm\n\nSimilar to the sorting algorithm tests, selection_test.py checks\nthe runtime and correctness of the randomized selection algorithm\nfor exponentially increasing n.\n\nBecause it checks for correctness with quicksort, it can't test for\...
python
chosen
[ { "from": "human", "value": "Add example script to store & read datetime\n" }, { "from": "gpt", "value": "import h5py\nimport numpy as np\n\narr = np.array([np.datetime64('2019-09-22T17:38:30')])\n\nwith h5py.File('datetimes.h5', 'w') as f:\n # Create dataset\n f['data'] = arr.astype(h5py....
python
chosen
[ { "from": "human", "value": "Add example of connecting OGR to matplotlib through shapely and numpy\n\ngit-svn-id: 30e8e193f18ae0331cc1220771e45549f871ece9@749 b426a367-1105-0410-b9ff-cdf4ab011145\n" }, { "from": "gpt", "value": "import ogr\nimport pylab\nfrom numpy import asarray\n\nfrom shapely...
python
chosen
[ { "from": "human", "value": "Add migration for Registration changed\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.4 on 2016-04-18 13:50\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migra...
python
chosen
[ { "from": "human", "value": "Add migration for blank true.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.7 on 2017-05-31 18:40\nfrom __future__ import unicode_literals\n\nimport kolibri.core.fields\nfrom django.db import migrations\n\n\nclass Migration(migra...
python
chosen
[ { "from": "human", "value": "Add test for microstructure generator\n\naddress #242\n\nAdd tests for microstructure generator to test new functionality. These\ntests change that correct quantities of the volume fraction are\ngenerated and that in appropriate sets of parameters fail.\n" }, { "from": "...
python
chosen
[ { "from": "human", "value": "Convert caffemodel of FCN8s to chainer model\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom __future__ import print_function\nimport argparse\nimport os.path as osp\n\nimport caffe\nimport chainer.functions as F\nimport chainer.serializers as S\n\nimp...
python
chosen
[ { "from": "human", "value": "Write tests for new functionality; several destinations\n" }, { "from": "gpt", "value": "from numpy import testing\nimport unittest\nimport numpy as np\nfrom numpy import pi\n\nfrom robot_arm import RobotArm\n\n\nclass TestRobotArm(unittest.TestCase):\n\n def setU...
python
chosen
[ { "from": "human", "value": "Implement a rudimentary API for LLTK\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n# -*- coding: UTF-8 -*-\n\nimport lltk\nimport lltk.generic\nimport lltk.caching\nimport lltk.exceptions\n\nfrom flask import Flask\nfrom flask import jsonify, request\n\n__autho...
python
chosen
[ { "from": "human", "value": "Add script to rotate a solid angle in the xz plane\n" }, { "from": "gpt", "value": "'''\nRotates the protein by a solid angle on the plane xz\n'''\n\nimport numpy\nimport os\n\nfrom argparse import ArgumentParser\n\nfrom move_prot_helper import (read_vertex, read_pqr...
python
chosen
[ { "from": "human", "value": "scripts: Include a helpful MOD analyser script\n" }, { "from": "gpt", "value": "# mod_info.py\n# \n# Display information about a Protracker module.\n# \n# Written & released by Keir Fraser <keir.xen@gmail.com>\n# \n# This is free and unencumbered software released in...
python
chosen
[ { "from": "human", "value": "Write unit test for utility functions\n" }, { "from": "gpt", "value": "from __future__ import unicode_literals\n\ntry:\n import io\n StringIO = io.StringIO\nexcept ImportError:\n import StringIO\n StringIO = StringIO.StringIO\nimport os\nimport shutil\nim...
python
chosen
[ { "from": "human", "value": "Add pytest option for specifying the typing module to use\n" }, { "from": "gpt", "value": "import sys\n\n\ndef pytest_addoption(parser):\n parser.addoption('--typing', action='store', default='typing')\n\n\ndef pytest_configure(config):\n if config.option.typin...
python
chosen
[ { "from": "human", "value": "Add helper functions for to/from bytes/unicode\n" }, { "from": "gpt", "value": "from . import str_mode\n\nif str_mode == 'bytes':\n unicode_type = unicode\nelse: # str_mode == 'unicode'\n unicode_type = str\n\ndef recursive_unicode(obj):\n if isinstance(obj...
python
chosen
[ { "from": "human", "value": "Add tests for shell utils.\n" }, { "from": "gpt", "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 regarding copyright ownersh...
python
chosen
[ { "from": "human", "value": "Add verbose names to UserProfile fields.\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 ('accou...
python
chosen
[ { "from": "human", "value": "Add initial test for binheap\n" }, { "from": "gpt", "value": "import pytest\nfrom binheap import Binheap\n\n\ndef test_init_bh():\n b = Binheap()\n assert b.binlist is []\n c = Binheap([1, 2])\n assert c.binlist == [1, 2]\n" } ]
python
chosen
[ { "from": "human", "value": "Test case for two classes with the same name in one module.\n" }, { "from": "gpt", "value": "class A(object):\n def method(self):\n return 1\n\nA().method() ## type int\n\n\nclass A(object):\n def method(self):\n return \"test\"\n\nA().method() ##...
python
chosen
[ { "from": "human", "value": "Add renderer for base64 content\n" }, { "from": "gpt", "value": "import base64\n\nfrom rest_framework import renderers\n\n\nclass Base64Renderer(renderers.BaseRenderer):\n media_type = \"image/png;base64\"\n format = \"base64\"\n charset = \"utf-8\"\n ren...
python
chosen
[ { "from": "human", "value": "Add test for import time.\n" }, { "from": "gpt", "value": "import subprocess\nimport sys\nimport pytest\n\nAVG_ITERATIONS = 15\n\n# Maximum expected import time for rasa module when running on a Travis VM.\n# Keep in mind the hardware configuration where tests are ru...
python
chosen
[ { "from": "human", "value": "Test admin views in order to catch stupid errors" }, { "from": "gpt", "value": "from django.apps import apps\nfrom django.contrib import admin\nfrom django.contrib.auth import get_user_model\nfrom django.core.urlresolvers import reverse\nfrom django.test import TestC...
python
chosen
[ { "from": "system", "value": "Use textual defaults for status constants\n" }, { "from": "human", "value": "import logging\nimport time\n\nfrom mopidy.exceptions import MpdNotImplemented\nfrom mopidy.models import Playlist\n\nlogger = logging.getLogger('backends.base')\n\nclass BaseBackend(object...
python
chosen
[ { "from": "human", "value": "Add script to automate review markdown file creation\n" }, { "from": "gpt", "value": "import sys\nimport os\nimport subprocess\n\ninitial_layout = [\n \"---\",\n \"layout: default\",\n \"permalink: 'reviews/{}.html'\",\n \"title: '{}'\",\n \"---\\n\",\...
python
chosen
[ { "from": "human", "value": "Add py solution for 654. Maximum Binary Tree\n\n654. Maximum Binary Tree: https://leetcode.com/problems/maximum-binary-tree/\n\n Approach 1:\n 1. Modify the method to accept (nums, start, end), and the method\n will return the subtree of nums[start:end]\n 2. Find the...
python
chosen
[ { "from": "human", "value": "Add py solution for 680. Valid Palindrome II\n\n680. Valid Palindrome II: https://leetcode.com/problems/valid-palindrome-ii/\n" }, { "from": "gpt", "value": "class Solution(object):\n def validPalindromeIdx(self, s, i, j, todelete):\n while i < j:\n ...
python
chosen
[ { "from": "human", "value": "Add an utility getting the free proxy from the certain site.\n" }, { "from": "gpt", "value": "import json\nimport time\nimport traceback\n\nimport requests\nfrom lxml import etree\n\n\ndef updateProxy():\n with open('F:\\liuming\\Shadowsocks\\gui-config.json', enc...
python
chosen
[ { "from": "human", "value": "Test 'python -m setuptools_scm' invocation (__main__.py).\n" }, { "from": "gpt", "value": "import os.path\n\nmainfile = os.path.join(\n os.path.dirname(__file__), \"..\", \"setuptools_scm\", \"__main__.py\")\nwith open(mainfile) as f:\n code = compile(f.read(),...
python
chosen
[ { "from": "human", "value": "Add a library for data visualization and add a dummy function\n" }, { "from": "gpt", "value": "'''\nCreated on Sep 6, 2017\n\n@author: Hossein\n\nThis file handles all the visualizations. It assumes that the status are ready and it \ncontains the function to generate...
python
chosen
[ { "from": "human", "value": "Add a new script to move existing entries to their correct location\n\nNow that we have moved it out of the usercache into its own class\n" }, { "from": "gpt", "value": "import logging\nimport arrow\n\nimport emission.core.get_database as edb\nimport emission.core.wr...
python
chosen
[ { "from": "human", "value": "python-bindings: Add test case for last commit (should probably be squashed)\n" }, { "from": "gpt", "value": "import summer\nimport unittest\n\nclass TestDataTypes (unittest.TestCase):\n def testitem(self):\n i = summer.ItemData ()\n i['title'] = 'he...
python
chosen
[ { "from": "human", "value": "Move user management to a new file\n" }, { "from": "gpt", "value": "from flask import Flask, render_template, flash, request, Markup, session, redirect, url_for, escape, Response, current_app, send_file\nfrom werkzeug.security import generate_password_hash, check_pas...
python
chosen
[ { "from": "human", "value": "Add test_get for api data (and missing file).\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom django.conf import settings\nfrom django.test import TestCase\nfrom django.test.client import Client\nfrom django.utils import simplejson as json\n\nfrom redd...
python
chosen
[ { "from": "human", "value": "Add new local dependency of scripts.\n" }, { "from": "gpt", "value": "\"\"\"Utility functions not closely tied to other spec_tools types.\"\"\"\n# Copyright (c) 2018-2019 Collabora, Ltd.\n# Copyright (c) 2013-2019 The Khronos Group Inc.\n#\n# Licensed under the Apach...
python
chosen
[ { "from": "human", "value": "Add a script to parse incoming CDN log entries\n" }, { "from": "gpt", "value": "#!/usr/bin/python -u\nimport sys\nimport redis\nimport csv\nimport posixpath\nimport datetime\nimport logging\nimport logging.handlers\n\nfrom email.utils import parsedate\n\n\nPRECISIONS...
python
chosen
[ { "from": "human", "value": "Move pool.Connection tests into own file\n" }, { "from": "gpt", "value": "\"\"\"\nTests for Connection class in the pool module\n\n\"\"\"\nimport mock\ntry:\n import unittest2 as unittest\nexcept ImportError:\n import unittest\nimport weakref\n\nfrom queries im...
python
chosen
[ { "from": "human", "value": "Add external client for pushing values\n" }, { "from": "gpt", "value": "import argparse\nimport ReplicatorClient\n\nPORT = 3000\n\ndef main():\n parser = argparse.ArgumentParser()\n parser.add_argument(\"host\", help=\"the ip of the host\")\n args = parser.p...
python
chosen
[ { "from": "system", "value": "Send subtitles_published signal for bulk approvals\n\nThis fixes pculture/amara-enterprise#608\n" }, { "from": "human", "value": "from django.contrib.contenttypes.models import ContentType\nfrom subtitles.models import SubtitleLanguage\nfrom teams.signals import api...
python
chosen
[ { "from": "human", "value": "Add automated Snowrunner save file renaming\n" }, { "from": "gpt", "value": "\"\"\"Automate Snowrunner save file renaming described in https://steamcommunity.com/sharedfiles/filedetails/?id=2530914231\"\"\"\nimport argparse\nimport csv\nimport os\nimport shutil\n\nde...
python
chosen
[ { "from": "human", "value": "Solve Code Fights concatenate arrays problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Concatenate Arrays Problem\n\n\ndef concatenateArrays(a, b):\n return a + b\n\n\ndef main():\n tests = [\n [[2, 2, 1], [10, 11], [2, 2, 1...
python
chosen
[ { "from": "human", "value": "Add py solution for 654. Maximum Binary Tree\n\n654. Maximum Binary Tree: https://leetcode.com/problems/maximum-binary-tree/\n" }, { "from": "gpt", "value": "# Definition for a binary tree node.\n# class TreeNode(object):\n# def __init__(self, x):\n# self...
python
chosen
[ { "from": "human", "value": "Implement simple for loop and SUBVN\n" }, { "from": "gpt", "value": "from .helpers import codetest\n\n\nclass TestWhile(object):\n \"\"\"\n tests for the lua if then else and various comparisons\n \"\"\"\n\n def test_simple_while(self):\n ret = cod...
python
chosen
[ { "from": "system", "value": "Add \"lzma\" to \"python-imports\" test\n" }, { "from": "human", "value": "import curses\nimport readline\n\nimport bz2\nassert(bz2.decompress(bz2.compress(b'IT WORKS IT WORKS IT WORKS')) == b'IT WORKS IT WORKS IT WORKS')\n\nimport zlib\nassert(zlib.decompress(zlib....
python
chosen
[ { "from": "human", "value": "Add beginnings of Player class implementation\n" }, { "from": "gpt", "value": "# card-fight-thingy - Simplistic battle card game... thingy\n#\n# The MIT License (MIT)\n#\n# Copyright (c) 2015 The Underscores\n#\n# Permission is hereby granted, free of charge, to any ...
python
chosen
[ { "from": "human", "value": "Add source file to repository.\n" }, { "from": "gpt", "value": "import PyPDF2\nfrom formlayout import fedit\n\npaths = [('Input', ''), ('Output', '')]\n\npathsRead = fedit(paths, \n title=\"Interleave pdf\",\n comment=\"Enter the ful...
python
chosen
[ { "from": "human", "value": "Add combine cooccurrence script for Food project\n" }, { "from": "gpt", "value": "import argparse\nimport os\nimport codecs\nfrom collections import Counter\n\nif __name__ == '__main__':\n\tparser = argparse.ArgumentParser(description='Merges cooccurrences files down...
python
chosen
[ { "from": "human", "value": "Add scripts directory with lie_workflow script\n" }, { "from": "gpt", "value": "import sys\n\nfrom autobahn.twisted.wamp import ApplicationRunner\nfrom twisted.internet.defer import inlineCallbacks, returnValue\nfrom twisted.internet import reactor\n\nfr...
python
chosen
[ { "from": "human", "value": "Add migration script to add the 'github_repo_id' field\n" }, { "from": "gpt", "value": "\"\"\"Backfills tables to populate GitHub's repo ID.\"\"\"\n\nimport rethinkdb as r\n\nimport db.plugins\nimport db.util\n\nr_conn = db.util.r_conn\n\n\ndef backfill_github_plugin...
python
chosen
[ { "from": "human", "value": "Fix typo in Macro help text\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('opal', '0028_auto_...
python
chosen
[ { "from": "human", "value": "Implement lecture & say methods in the ArrogantProfessor class using inheritance\n" }, { "from": "gpt", "value": "# Problem 6-1\n# 10.0 points possible (graded)\n\n\nclass Person(object):\n def __init__(self, name):\n self.name = name\n def say(self, stu...
python
chosen
[ { "from": "human", "value": "Introduce fuse module to mount Registry Ellipticsbased FS\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nfrom __future__ import with_statement\n\nimport logging\nimport os\nimport sys\nimport stat\n\nimport yaml\nfrom fuse import FUSE, FuseOSError, Operation...
python
chosen
[ { "from": "human", "value": "Add basic test and fixtures for themes.\n" }, { "from": "gpt", "value": "import os\nimport textwrap\nimport shutil\nimport pytest\n\n\n@pytest.fixture(scope='function')\ndef theme_project_tmpdir(tmpdir):\n\n # Copy themes-project to a temp dir, and copy demo-proje...
python
chosen
[ { "from": "human", "value": "Add config environment variables test\n" }, { "from": "gpt", "value": "import os\nimport unittest\n\nfrom config import get_config\n\n\nclass ConfigTest(unittest.TestCase):\n def setUp(self):\n os.environ['DESTALINATOR_STRING_VARIABLE'] = 'test'\n os...
python
chosen
[ { "from": "human", "value": "Create script to make PHAT patch fitting queue\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# encoding: utf-8\n\"\"\"\nMake a CANFAR queue for patch fitting.\n\n>>> from canque import Submission\n>>> sub = Submission(user_name, script_path)\n>>> sub.add_jo...
python
chosen
[ { "from": "human", "value": "Add mock object for easier testing\n" }, { "from": "gpt", "value": "from bot import Tofbot\n\nclass TestTofbot(Tofbot):\n\n def __init__(self, nick, name, chan, origin):\n chans = [chan]\n Tofbot.__init__(self, nick, name, chans, debug=False)\n ...
python
chosen
[ { "from": "human", "value": "Add site engine for ProjectFuture\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Copyright (C) 2019-2020 Tobias Gruetzmacher\n\nfrom __future__ import absolute_import, division, print_function\n\nfrom .common import _ParserScraper\n\n\nclass ProjectFutur...
python
chosen
[ { "from": "human", "value": "Add script to automate plugin testing on Windows\n\n* Opens Anki for you\n* Polls every second for a change to the watched file (uses time last modified)\n* Restarts Anki automatically\n" }, { "from": "gpt", "value": "import os, time, sys, time\nfrom shutil import co...
python
chosen
[ { "from": "system", "value": "Add blank line to fix flake8-isort" }, { "from": "human", "value": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this file,\n# You can obtain one at http://mozilla.org/MPL/2.0...
python
chosen
[ { "from": "human", "value": "Add small script to test motor feedback\n" }, { "from": "gpt", "value": "\"\"\"Helps eye-ball rpc-based motor control\"\"\"\n\nimport time\n\nfrom ev3control.rpc import Robot\n\n# for convenience set the time to one second\nduration = 1000\nspeed = 50\n\nwith Robot(N...
python
chosen
[ { "from": "human", "value": "Build Fix - Merged db migrations\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.2 on 2016-10-31 12:57\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 test for file-based datasets.\n" }, { "from": "gpt", "value": "import os\nimport shutil\nimport tempfile\nimport unittest\n\nfrom lobster.cmssw import dataset\nfrom lobster import fs, se\n\nclass TestDataset(unittest.TestCase):\n @classmethod\n def setUpCla...
python
chosen
[ { "from": "human", "value": "Add a test suite for comments in the dict structure\n" }, { "from": "gpt", "value": "import collections\nimport logging\nimport pytest\nfrom mappyfile.pprint import PrettyPrinter\n\n\ndef test_comment():\n d = collections.Order/edDict()\n d[\"name\"] = \"Test\"...
python
chosen
[ { "from": "human", "value": "Add a script to compute tile coverage for city bounding boxes\n" }, { "from": "gpt", "value": "from tilepack.builder import cover_bbox\n\nimport argparse\nimport os\nimport requests\n\ndef main():\n parser = argparse.ArgumentParser()\n parser.add_argument('min_...
python
chosen
[ { "from": "human", "value": "Test method calls, with return value or side effect\n" }, { "from": "gpt", "value": "import unittest\n\nfrom pykka import Actor\n\nclass MethodCallTest(unittest.TestCase):\n def setUp(self):\n class ActorWithMethods(Actor):\n foo = 'bar'\n ...
python
chosen
[ { "from": "human", "value": "Add smoke test of the yamlicious command.\n" }, { "from": "gpt", "value": "import io\nimport subprocess\nimport unittest\nimport yaml\n\n\nclass Command(unittest.TestCase):\n\n stdin = u''\n expected = {}\n\n def runTest(self):\n stdout = io.StringIO\n\n prc...
python
chosen
[ { "from": "human", "value": "Add shot attempt item class definition\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport uuid\n\nfrom db.common import Base\nfrom db.specific_event import SpecificEvent\n\n\nclass ShotAttempt(Base, SpecificEvent):\n __tablen...
python
chosen
[ { "from": "human", "value": "Add backwards compatible Distributed Joblib hook\n\nDepending on the versions of Distributed, Joblib, and scikit-learn,\nthere are different strategies for registering the Joblib backend. Try\ngoing with the standard Distributed technique first, which may fail for\nDistributed 1...
python
chosen
[ { "from": "human", "value": "Add test for old upsert syntax\n" }, { "from": "gpt", "value": "from django.db import models\n\nfrom psqlextra import HStoreField\nfrom psqlextra.query import ConflictAction\n\nfrom .fake_model import get_fake_model\n\n\ndef test_upsert():\n \"\"\"Tests whether si...
python
chosen
[ { "from": "human", "value": "Add solution to lintcode question 40\n" }, { "from": "gpt", "value": "class MyQueue:\n\n def __init__(self):\n self.stack1 = []\n self.stack2 = []\n\n def push(self, element):\n # write your code here\n self.stack1.append(element)\n\...
python
chosen
[ { "from": "human", "value": "Add service module for custom actions\n" }, { "from": "gpt", "value": "from zou.app.models.custom_action import CustomAction\nfrom zou.app.utils import cache, fields\n\n\ndef clear_custom_action_cache():\n cache.cache.delete_memoized(get_custom_actions)\n\n\n@cach...
python
chosen
[ { "from": "human", "value": "Add tests for zoom mode\n" }, { "from": "gpt", "value": "from PyQt4 import QtCore\nfrom PyQt4 import QtGui\nfrom PyQt4.QtTest import QTest\nfrom pyqode.core import frontend, style\nfrom pyqode.core.frontend import modes\n\n\neditor = None\nmode = None\n\n\ndef setup_...
python
chosen
[ { "from": "human", "value": "Add migration for byte string fix\n\nChanging the `PhoneDevice.key` default requires a model state migration.\n\nSee: 268c0d6 (Merge pull request #281 from Ameriks/byte_string_fix)\n" }, { "from": "gpt", "value": "from django.db import migrations, models\n\nimport tw...
python
chosen
[ { "from": "human", "value": "Create view for repeater tx and repater rx\n" }, { "from": "gpt", "value": "from django.db import connection\n\ndef create_repeater_tx_view():\n \"\"\"\n \"\"\"\n from django.db import connection\n cursor = connection.cursor()\n cursor.execute('''\n ...
python
chosen
[ { "from": "human", "value": "Create Populate Nxt Ptr in each node REC\n" }, { "from": "gpt", "value": "# Definition for binary tree with next pointer.\n# class TreeLinkNode(object):\n# def __init__(self, x):\n# self.val = x\n# self.left = None\n# self.right = None\n# ...
python
chosen
[ { "from": "human", "value": "Add new exception for >1 value provided for a single valued parameter\n" }, { "from": "gpt", "value": "\"\"\"Exception for missing query parameter.\"\"\"\n\n\nclass QueryParameterMultipleValuesError(Exception):\n \"\"\"Exception for missing parameter in a GET quer...
python
chosen
[ { "from": "human", "value": "Add unit tests for spiral scan\n" }, { "from": "gpt", "value": "from __future__ import division\nimport numpy as np\nfrom acq4.devices.Scanner.scan_program.spiral import SpiralScan\n\n\ndef test_spiral():\n r1 = 10e-6\n r2 = 20e-6\n a1 = 1.\n a2 = 30.\n ...
python
chosen
[ { "from": "human", "value": "Add 2 skill types: Skill Boost and Cute/Cool/Passion Focus\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 = ...
python
chosen
[ { "from": "human", "value": "Add tests for 'deprecated' decorator with functions and methods.\n" }, { "from": "gpt", "value": "#------------------------------------------------------------------------------\n# Copyright (c) 2005-2014, Enthought, Inc.\n# All rights reserved.\n#\n# This software i...
python
chosen
[ { "from": "human", "value": "Add Logger class that acts as a convenient holder of common log information.\n\nAlso deals with emitting logs by calling global handle.\n" }, { "from": "gpt", "value": "# :coding: utf-8\n# :copyright: Copyright (c) 2013 Martin Pengelly-Phillips\n# :license: See LICEN...
python
chosen
[ { "from": "human", "value": "Add a test for memory allocation\n" }, { "from": "gpt", "value": "'Test of memory allocation'\n\nimport numpy as np\nfrom nose.tools import assert_raises\nfrom videocore.assembler import qpu, assemble\nfrom videocore.driver import Driver, DriverError, \\\n ...
python
chosen
[ { "from": "human", "value": "Add test for typing module\n" }, { "from": "gpt", "value": "\"\"\"tests/test_typing.py.\n\nTests to ensure hugs interacts as expected with the Python3.5+ typing module\n\nCopyright (C) 2016 Timothy Edmund Crosley\n\nPermission is hereby granted, free of charge, to an...
python
chosen
[ { "from": "human", "value": "Add convenience function to convert from tag/value format to RDF.\n\nSigned-off-by: Philippe Ombredanne <ca95c4a6a4931f366cbdaf5878c5016609417d37@nexb.com>" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# Copyright (C) 2017 BMW AG\n# Author: Thom...
python
chosen
[ { "from": "human", "value": "Add basic test for LocalSyncClient\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nimport os\nimport tempfile\n\nfrom s3backup.local_sync_client import LocalSyncClient\n\n\nclass TestLocalSyncClient(object):\n\n def test_keys(self):\n local_dir ...
python
chosen