conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Test for the save_character() function\n\n" }, { "from": "gpt", "value": "import unittest\n\nimport database.main\nfrom tests.create_test_db import engine, session, Base\ndatabase.main.engine = engine\ndatabase.main.session = session\ndatabase.main.Base = Base\nimpor...
python
chosen
[ { "from": "human", "value": "Add US state capitals from vega-lite.\n" }, { "from": "gpt", "value": "\"\"\"\nU.S. state capitals overlayed on a map of the U.S\n================================================-\nThis is a geographic visualization that shows US capitals\noverlayed on a map.\n\"\"\"...
python
chosen
[ { "from": "human", "value": "Add a management command to create realm administrators.\n\n(imported from commit ab2dd580a206f29086c0d5a4e717c1bfd65a7435)\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\n\nimport sys\nfrom optparse import make_option\n\nfrom django.core.man...
python
chosen
[ { "from": "human", "value": "Add some example code for creation of disk partitions.\n" }, { "from": "gpt", "value": "import logging\nimport sys\nimport os\n\nfrom common import set_up_logging\nfrom common import create_sparse_file\nfrom common import tear_down_disk_images\nfrom common import pri...
python
chosen
[ { "from": "human", "value": "Add simple implementation for a pre-commit hook\n\nThis will be routed via the main entryway, mothermayi\n" }, { "from": "gpt", "value": "import mothermayi.entryway\nimport mothermayi.git\n\ndef handle_plugins(entries):\n for entry in entries:\n result = en...
python
chosen
[ { "from": "human", "value": "Add tests for inplace subset\n" }, { "from": "gpt", "value": "import numpy as np\nimport pytest\nfrom sklearn.utils.testing import (\n assert_array_equal\n)\nfrom scipy import sparse\n\nfrom anndata.tests.helpers import (\n gen_adata,\n subset_func,\n asa...
python
chosen
[ { "from": "system", "value": "Fix syntax error in collector test\n" }, { "from": "human", "value": "#!/usr/bin/python\n# coding=utf-8\n################################################################################\n\nfrom test import CollectorTestCase\nfrom test import get_collector_config\nfr...
python
chosen
[ { "from": "human", "value": "Add tests for the management views\n" }, { "from": "gpt", "value": "import unittest\nfrom pyramid import testing\n\nclass ManagementViewsTest(unittest.TestCase):\n def setUp(self):\n self.config = testing.setUp()\n\n def tearDown(self):\n testing....
python
chosen
[ { "from": "human", "value": "DOC: Add a script that uses the Flickr API.\n" }, { "from": "gpt", "value": "import os\nimport photomosaic as pm\nimport photomosaic.flickr\nimport matplotlib.pyplot as plt\n\n\n# For these published examples we use os.environ to keep our API key private.\n# Just set...
python
chosen
[ { "from": "human", "value": "test: Add tests for mpi4py.dl module\n" }, { "from": "gpt", "value": "from mpi4py import dl\nimport mpiunittest as unittest\nimport sys\nimport os\n\nclass TestDL(unittest.TestCase):\n\n def testDL1(self):\n if sys.platform == 'darwin':\n libm = ...
python
chosen
[ { "from": "human", "value": "TST: Add some coverage for olog callback.\n" }, { "from": "gpt", "value": "from bluesky import Msg\nfrom bluesky.callbacks.olog import logbook_cb_factory\n\ntext = []\n\n\ndef f(**kwargs):\n text.append(kwargs['text'])\n\n\ndef test_default_template(fresh_RE):\n ...
python
chosen
[ { "from": "human", "value": "Add script to draw NACA foil\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\nThis script generates a force and velocity vector diagram for a cross-flow\nturbine.\n\"\"\"\n\nimport gizeh as gz\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\nd...
python
chosen
[ { "from": "human", "value": "Send ERROR when the user disconnects\n" }, { "from": "gpt", "value": "from twisted.plugin import IPlugin\nfrom txircd.module_interface import IModuleData, ModuleData\nfrom zope.interface import implements\n\nclass ErrorResponse(ModuleData):\n implements(IPlugin, I...
python
chosen
[ { "from": "human", "value": "Add script to delete Bit.ly raw results from S3\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport argparse\nimport boto3\nimport os\nfrom typing import List\n\nfrom mediawords.util.log import create_logger\n\nl = create_logger(__name__)\n\n\ndef delet...
python
chosen
[ { "from": "human", "value": "recipe-server: Add migration to reset signatures\n\nFixes #452\n" }, { "from": "gpt", "value": "\"\"\"\nRemoves signatures, so they can be easily recreated during deployment.\n\nThis migration is intended to be used between \"eras\" of signatures. As\nthe serializati...
python
chosen
[ { "from": "human", "value": "Add Migration File this time.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.6 on 2017-03-30 05:56\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n...
python
chosen
[ { "from": "human", "value": "Add unit test for Pattern filterer.\n" }, { "from": "gpt", "value": "# :coding: utf-8\n# :copyright: Copyright (c) 2013 Martin Pengelly-Phillips\n# :license: See LICENSE.txt.\n\nimport pytest\n\nfrom bark.log import Log\nfrom bark.filterer.pattern import Pattern\n\n\...
python
chosen
[ { "from": "human", "value": "Add example from listing 11.4\n" }, { "from": "gpt", "value": "\"\"\"\nListing 11.4: An eight-element radix sort\n\"\"\"\n\nfrom io import open\nimport numpy as np\nimport pyopencl as cl\nimport utility\n\nNUM_SHORTS = 8\n\nkernel_src = '''\n__kernel void radix_sort8...
python
chosen
[ { "from": "human", "value": "Create pretty table of tie averages + function for pretty averages\n" }, { "from": "gpt", "value": "from s5v2 import *\nfrom prettytable import PrettyTable\n\ndef my_table(): # no arguments are passed in, which seems a bit weird. We're hard-coding a function that onl...
python
chosen
[ { "from": "human", "value": "[IMP] document: Remove annoying SQL view that prevents some operations\n" }, { "from": "gpt", "value": " # -*- coding: utf-8 -*-\n##############################################################################\n#\n# This program is free software: you can redistribute ...
python
chosen
[ { "from": "human", "value": "Add a directives file for pygments support.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom docutils import nodes\nfrom docutils.parsers.rst import directives, Directive\nfrom pygments.formatters import HtmlFormatter\nfrom pygments import highlight\nfr...
python
chosen
[ { "from": "human", "value": "Add datetime header to Crank\n" }, { "from": "gpt", "value": "\"\"\"\nutil\n===\nCommon utilities across the Crank system.\n\"\"\"\nfrom datetime import datetime\n\n\nDATETIME_FORMAT = '%Y %b %d @ %H%M'\n\n\ndef get_timestamp_header():\n return datetime.now().strf...
python
chosen
[ { "from": "human", "value": "Example: Create a folder in a datacenter if not exists\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\nWritten by Chinmaya Bharadwaj\nGithub: https://github.com/chinmayb/\nEmail: acbharadwaj@gmail.com\n\nCreate a folder in a datacenter\n\"\"\"\nfrom _...
python
chosen
[ { "from": "human", "value": "Add module for mocking node.get() with Responses\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# This work was created by participants in the DataONE project, and is\n# jointly copyrighted by participating institutions in DataONE....
python
chosen
[ { "from": "human", "value": "Add py solution for 409. Longest Palindrome\n\n409. Longest Palindrome: https://leetcode.com/problems/longest-palindrome/\n" }, { "from": "gpt", "value": "from collections import Counter\nclass Solution(object):\n def longestPalindrome(self, s):\n \"\"\"\n ...
python
chosen
[ { "from": "human", "value": "Write a function that print something n times including relatives spaces\n" }, { "from": "gpt", "value": "\"\"\"Module docstring.\n\nThis serves as a long usage message.\n\"\"\"\nimport sys\nimport getopt\n\ndef main():\n # parse command line options\n try:\n ...
python
chosen
[ { "from": "human", "value": "Add a fontname to TachyFont Jar file mapper." }, { "from": "gpt", "value": "\"\"\"\n Copyright 2014 Google 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 Lic...
python
chosen
[ { "from": "human", "value": "Add integration tests for pylast.py\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\nIntegration (not unit) tests for pylast.py\n\"\"\"\nimport datetime\nimport time\nimport unittest\n\nimport pylast\n\nclass TestSequenceFunctions(unittest.TestCase):\n...
python
chosen
[ { "from": "human", "value": "Add management command for removing content rotation's settings on sections\n" }, { "from": "gpt", "value": "from __future__ import absolute_import, unicode_literals\n\nfrom django.core.management.base import BaseCommand\nfrom molo.core.models import SectionPage\n\n\...
python
chosen
[ { "from": "human", "value": "Automate the update of the version number in setup.py.\n" }, { "from": "gpt", "value": "import fileinput\nimport re\nimport sys\n\npattern = re.compile(\"\\s*version='([0-9.]+)',\")\nline = \"\"\nmaj = \"\" \nmin = \"\" \nver = \"\" \n\nfor line in fileinput.FileInpu...
python
chosen
[ { "from": "human", "value": "Add tests for the registry's root object's Component interface\n\nNot much to test, really, just characterizing what the implementation\ndoes. All the methods are no-ops that return hardcoded values.\n" }, { "from": "gpt", "value": "import pytest\nimport dbus\n\nCOM...
python
chosen
[ { "from": "human", "value": "Add test for symbol selection\n" }, { "from": "gpt", "value": "import pytest\n\nfrom tests.symbols import get_symbols\nfrom thinglang.compiler.errors import NoMatchingOverload\nfrom thinglang.compiler.references import Reference\nfrom thinglang.lexer.values.identifie...
python
chosen
[ { "from": "human", "value": "Add 'git cl format' presubmit check to src/device\n\nReview URL: https://codereview.chromium.org/1097743004\n\nCr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#325940}\n" }, { "from": "gpt", "value": "# Copyright 2015 The Chromium Authors. All rights re...
python
chosen
[ { "from": "human", "value": "Add new abstraction with recursion\n" }, { "from": "gpt", "value": "import networkx as nx\nimport os\nfrom pygraphc.preprocess.CreateGraphModel import CreateGraphModel\nfrom pygraphc.clustering.Louvain import Louvain\n\n\nclass AutoAbstraction(object):\n def __ini...
python
chosen
[ { "from": "human", "value": "Add Rother District Council logo for letters\n" }, { "from": "gpt", "value": "\"\"\"empty message\n\nRevision ID: 0180_another_letter_org\nRevises: 0179_billing_primary_const\nCreate Date: 2017-06-29 12:44:16.815039\n\n\"\"\"\n\n# revision identifiers, used by Alembi...
python
chosen
[ { "from": "human", "value": "Add a test for UnionFind fix.\n" }, { "from": "gpt", "value": "from nose.tools import *\n\nimport networkx as nx\n\ndef test_unionfind():\n # Fixed by: 2cddd5958689bdecdcd89b91ac9aaf6ce0e4f6b8\n # Previously (in 2.x), the UnionFind class could handle mixed type...
python
chosen
[ { "from": "system", "value": "Check if hook parameter is passed to the url\n" }, { "from": "human", "value": "from flask import Flask\nfrom flask import request\nfrom flask import jsonify\nimport json\nimport subprocess\n\napp = Flask(__name__)\nconfig = None\n\n@app.route('/', methods=['POST'])...
python
chosen
[ { "from": "human", "value": "Add test for sender_callable check\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport pytest\n\nfrom webhooks.exceptions import SenderNotCallable\nfrom webhooks import webhook, unhashed_hook\n\n\ndef test_callable_sender():\n\n ...
python
chosen
[ { "from": "human", "value": "Add py solution for 462. Minimum Moves to Equal Array Elements II\n\n462. Minimum Moves to Equal Array Elements II: https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/\n\nCould be optimized to O(n) by q-select\n" }, { "from": "gpt", "value": "clas...
python
chosen
[ { "from": "human", "value": "Fix error in PoolStatusEntry model\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 ('ec2spotmana...
python
chosen
[ { "from": "human", "value": "Solve py set discard remove pop\n" }, { "from": "gpt", "value": "num_elements = int(input())\ns = set(map(int, input().split()))\nnum_operations = int(input())\nfor _ in range(num_operations):\n operation = input().split(\" \")\n if(operation[0] == \"pop\"):\n ...
python
chosen
[ { "from": "human", "value": "Add script for generating chords, used to make some of the sounds.\n" }, { "from": "gpt", "value": "from collections import OrderedDict\nfrom itertools import cycle\nimport sys\n\n# build the pitch table\nnote_names = ['A', 'A#/Bb', 'B', 'C', 'C#/Db', 'D', 'D#/Eb', '...
python
chosen
[ { "from": "human", "value": "Add script to get certificate expiration date\n" }, { "from": "gpt", "value": "from cryptography import x509\nfrom cryptography.hazmat.backends import default_backend\n\nfrom bluebottle.clients import properties\nfrom bluebottle.clients.models import Client\nfrom blu...
python
chosen
[ { "from": "human", "value": "Add script for generate events.\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\n\nfrom random import randint\n\noutput = \"\"\nfilename = \"data\"\n\n\nclass Generator:\n\n def gen_date(self):\n return str(randint(2013, 2015)) + \"-\" \\\n +...
python
chosen
[ { "from": "human", "value": "Add Consumer Product Safety Commission.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport datetime\nimport logging\nimport os\nfrom urllib.parse import urljoin\n\nfrom bs4 import BeautifulSoup\nfrom utils import utils, inspector\n\n# https://www.cpsc.g...
python
chosen
[ { "from": "human", "value": "Add news date and title scrapper from ist's news page.\n" }, { "from": "gpt", "value": "from urllib.request import urlopen\nfrom bs4 import BeautifulSoup\nimport sys, io\n\nsys.stdout = io.TextIOWrapper(sys.stdout.buffer,'cp437','backslashreplace')\n\nhtml = urlopen(...
python
chosen
[ { "from": "human", "value": "Add experimental polling DB backend.\n\nSigned-off-by: Chris Lamb <711c73f64afdce07b7e38039a96d2224209e9a6c@thread.com>\n" }, { "from": "gpt", "value": "import time\nimport datetime\n\nfrom django.db import connection, models, ProgrammingError\n\nfrom ..job import Jo...
python
chosen
[ { "from": "human", "value": "Add a script useful for downloading large avatar images from Atom feeds\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\nimport PIL.Image\nimport io\nimport json\nimport requests\n\nimport post_list\nimport web_cache\n\n\n# Split this file into two modules, b...
python
chosen
[ { "from": "human", "value": "Add script to bump symbol versions\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n#\n# Bump symbol versions of libvirt0\n\n# Usage: ./bump-symbol-versions 1.2.16~rc2\n\nimport os\nimport re\nimport sys\nimport shutil\nimport subprocess\n\n#import gbp.git.GitRepo...
python
chosen
[ { "from": "human", "value": "Add another example that works offline\n" }, { "from": "gpt", "value": "import pytest\r\n\r\n\r\n@pytest.mark.offline\r\ndef test_request_fixture(request):\r\n sb = request.getfixturevalue('sb')\r\n sb.open(\"data:text/html,<p>Hello<br><input></p>\")\r\n sb....
python
chosen
[ { "from": "human", "value": "Add problem 40, decimal fraction digits\n" }, { "from": "gpt", "value": "from time import time\n\n\ndef main():\n fractional_part = ''\n\n i = 1\n while len(fractional_part) < 1000000:\n fractional_part += str(i)\n i += 1\n\n prod = 1\n f...
python
chosen
[ { "from": "human", "value": "Add script to convexify the energies of a conservation tracking JSON model\n" }, { "from": "gpt", "value": "import sys\nimport commentjson as json\nimport os\nimport argparse\nimport numpy as np\n\ndef listify(l):\n return [[e] for e in l]\n\ndef convexify(l):\n\t...
python
chosen
[ { "from": "human", "value": "Add missed language update migrations\n\nThis migration should have been included in `2627b1c`.\n" }, { "from": "gpt", "value": "# Generated by Django 3.0.2 on 2020-01-20 14:22\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\...
python
chosen
[ { "from": "human", "value": "Add default value of access requests enabled to exsisting projects made before model added\n\n[#PLAT-835]\n\nAlso alter permissions on noderequestaction model, since choices were altered from when the original migration was made\n" }, { "from": "gpt", "value": "# -*-...
python
chosen
[ { "from": "human", "value": "Add code to test van der pol model\n" }, { "from": "gpt", "value": "\nfrom __future__ import division\n\nimport sys\nimport numpy as np\nsys.path.append('/media/ixaxaar/Steam/src/nest/local/lib/python2.7/site-packages/')\nimport nest\nimport nest.raster_plot\nimport ...
python
chosen
[ { "from": "human", "value": "Add script to get list of HRS station IDs\n\nFrom providers that license their data as Creative Commons\n" }, { "from": "gpt", "value": "import pandas as pd\nfrom kiwis_pie import KIWIS\n\nk = KIWIS('http://www.bom.gov.au/waterdata/services')\n\ndef get_cc_hrs_statio...
python
chosen
[ { "from": "human", "value": "Add Script to generate a container schema from DockerFile\n" }, { "from": "gpt", "value": "#!/usr/bin/env/python\r\n\r\nfrom datetime import datetime\r\nimport os\r\nimport argparse\r\nimport re\r\nfrom graphviz import Digraph\r\n\r\nPATH = os.path.dirname(os.path.ab...
python
chosen
[ { "from": "human", "value": "Add tests for the Django directory\n" }, { "from": "gpt", "value": "from jacquard.directory.base import UserEntry\nfrom jacquard.directory.django import DjangoDirectory\n\nimport pytest\nimport unittest.mock\n\ntry:\n import sqlalchemy\nexcept ImportError:\n sq...
python
chosen
[ { "from": "human", "value": "Add a baseline set of _MultiCall performance tests\n\nThis begins an effort to incorporate run-time speed tests using\n`pytest-benchmark`. This initial test set audits the `_MultiCall`\nloop with hookimpls, hookwrappers and the combination of both.\nThe intention is to eventuall...
python
chosen
[ { "from": "human", "value": "Add test of simple textcat workflow\n" }, { "from": "gpt", "value": "from __future__ import unicode_literals\nfrom ...language import Language\n\ndef test_simple_train():\n nlp = Language()\n\n nlp.add_pipe(nlp.create_pipe('textcat'))\n nlp.get_pipe('textcat...
python
chosen
[ { "from": "human", "value": "Add revision for new boardmoderator columns\n" }, { "from": "gpt", "value": "\"\"\"Add board moderator roles\n\nRevision ID: da8b38b5bdd5\nRevises: 90ac01a2df\nCreate Date: 2016-05-03 09:32:06.756899\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\nrevision = '...
python
chosen
[ { "from": "human", "value": "Add a spider for Planned Parenthood\n\nFixes #184\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport scrapy\nimport json\nimport re\n\nfrom locations.items import GeojsonPointItem\n\n\nclass PlannedParenthoodSpider(scrapy.Spider):\n name = \"planned_...
python
chosen
[ { "from": "human", "value": "Add forgotten migration for newly introduced default ordering\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.2 on 2017-07-04 19:55\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nimport localized_fie...
python
chosen
[ { "from": "human", "value": "Add in a script to run the linter manually\n\nExample uses:\n$ runlint.py file1.js file2.js\n$ runlint.py --autofix file3.js\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport optparse\nimport sys\n\nfrom closure_linter import checker\nfrom closure_lint...
python
chosen
[ { "from": "human", "value": "Add script to get evidence sources\n" }, { "from": "gpt", "value": "from util import pklload\nfrom collections import defaultdict\nimport indra.tools.assemble_corpus as ac\n\n\nif __name__ == '__main__':\n # Load cached Statements just before going into the model\...
python
chosen
[ { "from": "human", "value": "Implement preview of entries for restricted users in EntryPreviewMixin\n" }, { "from": "gpt", "value": "\"\"\"Preview mixins for Zinnia views\"\"\"\nfrom django.http import Http404\nfrom django.utils.translation import ugettext as _\n\nfrom zinnia.managers import PUB...
python
chosen
[ { "from": "human", "value": "Add migration for moving recomended articles recomended section\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nfrom molo.core.models import ArticlePage, ArticlePageRecommendedSect...
python
chosen
[ { "from": "human", "value": "Add example showing scraping/parsing of an HTML table into a Python dict\n" }, { "from": "gpt", "value": "#\n# htmlTableParser.py\n#\n# Example of parsing a simple HTML table into a list of rows, and optionally into a little database\n#\n# Copyright 2019, Paul McGuir...
python
chosen
[ { "from": "human", "value": "Fix cascades for RecurringEventOverride table\n\nSummary: We weren't defining an `ON DELETE CASCADE` cascade on the RecurringEventOverride table. This made it impossible to run the account reset script for accounts which had recurring event overrides. Fix this.\n\nTest Plan: Ran...
python
chosen
[ { "from": "human", "value": "Add script that extracts clips from HDF5 file.\n" }, { "from": "gpt", "value": "from pathlib import Path\nimport wave\n\nimport h5py\n\n\nDIR_PATH = Path('/Users/harold/Desktop/Clips')\nINPUT_FILE_PATH = DIR_PATH / 'Clips.h5'\nCLIP_COUNT = 5\n\n\ndef main():\n\n w...
python
chosen
[ { "from": "human", "value": "Set all events to show banner text\n" }, { "from": "gpt", "value": "\"\"\"empty message\n\nRevision ID: 0060 set all show_banner_text\nRevises: 0059 add show_banner_text\nCreate Date: 2021-10-03 00:31:22.285217\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\nr...
python
chosen
[ { "from": "human", "value": "Add tests for previous commit\n\ninb4 this is backwards\n" }, { "from": "gpt", "value": "from django.test import SimpleTestCase\nfrom mock import ANY, patch\n\nfrom corehq.apps.es.tests.utils import es_test\nfrom corehq.elastic import SerializationError, get_es_new\n...
python
chosen
[ { "from": "human", "value": "perftest: Add simple Python web server for performance testing\n\nIn order to profile bottlenecks in CCF's HTTP communication, a simple\nPython webserver comes very handy. One can reason that the existing HTTP\nserver in CCF does not meet the performance requirements, if the\npe...
python
chosen
[ { "from": "human", "value": "Print with vs without a comma\n" }, { "from": "gpt", "value": "end1 = \"C\"\nend2 = \"H\"\nend3 = \"E\"\nend4 = \"E\"\nend5 = \"S\"\nend6 = \"E\"\nend7 = \"B\"\nend8 = \"U\"\nend9 = \"R\"\nend10 = \"G\"\nend11 = \"E\"\nend12 = \"R\"\n# Printing without a comma\nprint...
python
chosen
[ { "from": "human", "value": "Add script to upload files to shell applet\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: latin-1 -*-\n\nimport os, sys, time, subprocess, json, requests\n\nHEADERS = {\n 'Content-type': 'application/json',\n 'Accept': 'application/json',...
python
chosen
[ { "from": "human", "value": "Add test to validate against schema\n\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# encoding: utf-8\n#\n# This file is part of ckanext-doi\n# Created by the Natural History Museum in London, UK\n\nimport ckanext.doi.api as doi_api\nimport ckanext.doi.lib ...
python
chosen
[ { "from": "human", "value": "Add unit test for drawing routines\n" }, { "from": "gpt", "value": "import batoid\nimport time\nimport os\nimport yaml\nimport numpy as np\nimport pytest\nfrom test_helpers import timer\n\n# Use matplotlib with a non-interactive backend.\nimport matplotlib as mpl\nmp...
python
chosen
[ { "from": "human", "value": "Add simple BIRD client class\n" }, { "from": "gpt", "value": "# coding: utf-8\n\nimport subprocess\n\nimport netaddr\n\nimport lglass.route\n\nclass BirdClient(object):\n\tdef __init__(self, executable=\"birdc\"):\n\t\tself.executable = executable\n\t\n\tdef send(sel...
python
chosen
[ { "from": "human", "value": "Test threading in app server rather than in serverTest.\n" }, { "from": "gpt", "value": "import _10gen\nimport ed.appserver.AppContext\nimport ed.lang.python.Python\nimport java.io.File\n\n# FIXME: this test produces a lot of output\n_10gen.__instance__ = ed.lang.pyt...
python
chosen
[ { "from": "human", "value": "Add code to fix the python 2.6.6 auth failure issue.\n\n\ngit-svn-id: 293778eaa97c8c94097d610b1bd5133a8f478f36@10708 4f837ed2-42f5-46e7-a7a5-fa17313484d4\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n# $Id: fix_auth_failure.py,v 1.1 2011-02-15 20:28:38 ba...
python
chosen
[ { "from": "human", "value": "Make getting started easier with a handy script\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport subprocess\n\n\ndef sudo(command_text):\n parts = ['sudo']\n parts.extend(command_text.split(command_text))\n subprocess.call(parts)\n\n\ndef apt...
python
chosen
[ { "from": "human", "value": "Add example of how to read from a external GPS outputting NMEA messages.\n\nParsing using pynmea2\n" }, { "from": "gpt", "value": "from __future__ import print_function\nimport requests\nimport argparse\nimport time\nimport logging\nimport sys\nimport serial\nimport ...
python
chosen
[ { "from": "human", "value": "Test template for the Damage class\n\n" }, { "from": "gpt", "value": "import unittest\nfrom damage import Damage\n\n\nclass DamageTests(unittest.TestCase):\n def test_init(self):\n dmg = Damage(phys_dmg=1.34, magic_dmg=1.49391)\n expected_phys_dmg = ...
python
chosen
[ { "from": "system", "value": "MAINT: Make version compatible with PEP386\n" }, { "from": "human", "value": "from .base import CA, RDA, CCA\n\n__all__ = ['CA', 'RDA', 'CCA']\n\n#\n#from numpy.testing import Tester\n#test = Tester().test\n\n__version__ = '0.1-dev'\n" }, { "from": "gpt", ...
python
chosen
[ { "from": "human", "value": "Add join_segmentations example to the gallery\n" }, { "from": "gpt", "value": "\"\"\"\n==========================================\nFind the intersection of two segmentations\n==========================================\n\nWhen segmenting an image, you may want to comb...
python
chosen
[ { "from": "human", "value": "Add example of sending push notification via Firebase Cloud Messaging\n" }, { "from": "gpt", "value": "import requests\n\nurl = 'https://fcm.googleapis.com/fcm/send'\nheaders = {'Content-Type': 'application/json',\n 'Authorization': 'key=AIza...(copy code h...
python
chosen
[ { "from": "human", "value": "Add start of Python solution for day 9 (parsing only)\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python3\n\n\ndef parse_input(text):\n \"\"\"Parse a list of destinations and weights\n\n Returns a list of tuples (source, dest, weight).\n\n Edges in thi...
python
chosen
[ { "from": "human", "value": "Add simple parser to return some activity numbers from our git log.\n" }, { "from": "gpt", "value": "#!/usr/bin/python\nimport sys\nimport getopt\nimport re\nimport email.utils\nimport datetime\n\nclass Usage(Exception):\n def __init__(self, msg):\n self.ms...
python
chosen
[ { "from": "human", "value": "Test long jid passed on CLI\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n# Import Salt Libs\nfrom salt.utils import args\n\n# Import Salt Testing Libs\nfrom salttesting import TestCase, skipIf\nfrom salttesting.mock import NO_MOCK, NO_MOCK_REASON\nfrom...
python
chosen
[ { "from": "human", "value": "Add tests for user utilities sum_ and prod_\n" }, { "from": "gpt", "value": "\"\"\"Tests for user utility functions.\"\"\"\n\nfrom drudge import Vec, sum_, prod_\nfrom drudge.term import parse_terms\n\n\ndef test_sum_prod_utility():\n \"\"\"Test the summation and ...
python
chosen
[ { "from": "human", "value": "Add a login view that automatically starts the oauth2 flow for authenticating using the IdM server\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n# Copyright (c) 2012-2013 CoNWeT Lab., Universidad Politécnica de Madrid\n\n# This file is part of Wirecloud...
python
chosen
[ { "from": "human", "value": "Add test script for checking to see if scrobbling works on new installs\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n##### CONFIG #####\n\nSERVER = \"turtle.libre.fm\"\nUSER = \"testuser\"\nPASSWORD = \"password\"\n\n\n##################\n\nimport gobble...
python
chosen
[ { "from": "human", "value": "Add organizer permissions to staff group\n\nBB-16555 #resolve\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.15 on 2019-11-11 12:19\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nfrom bluebottle.uti...
python
chosen
[ { "from": "human", "value": "Create tests for JavaScript parser.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# -*- coding: UTF-8 -*-\n\nimport pytest # type: ignore\n\nfrom sensibility.language import Language\nfrom sensibility.language.javascript import javascript\nfrom sensibilit...
python
chosen
[ { "from": "human", "value": "Add example of slide-hold-slide test\n" }, { "from": "gpt", "value": "import numpy as np\nimport matplotlib.pyplot as plt\nimport rsf\n\nmodel = rsf.RateState()\n\n# Set model initial conditions\nmodel.mu0 = 0.6 # Friction initial (at the reference velocity)\nmodel.a...
python
chosen
[ { "from": "system", "value": "Make new test fail correctlyish\n" }, { "from": "human", "value": "from _utils import _output_eq, IntegrationSpec\n\n\nclass ShellCompletion(IntegrationSpec):\n \"\"\"\n Shell tab-completion behavior\n \"\"\"\n\n def no_input_means_just_task_names(self):...
python
chosen
[ { "from": "human", "value": "Add SSH auto detect feature\n" }, { "from": "gpt", "value": "\"\"\"\nThis module is used to auto-detect the type of a device in order to automatically create a\nNetmiko connection.\n\nThe will avoid to hard coding the 'device_type' when using the ConnectHandler facto...
python
chosen
[ { "from": "human", "value": "Test for the gaussian output layer, going through all same fit() and predict() tests as the linear output.\n" }, { "from": "gpt", "value": "import unittest\nfrom nose.tools import (assert_is_not_none, assert_raises, assert_equal)\n\nfrom sknn.mlp import MultiLayerPer...
python
chosen
[ { "from": "human", "value": "Remove control_id column from assessments table\n" }, { "from": "gpt", "value": "# Copyright (C) 2016 Google Inc.\n# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>\n\n\"\"\"\nRemove control_id column from assessments table\n\nCreate Date...
python
chosen
[ { "from": "human", "value": "Add initial working solution 4\n" }, { "from": "gpt", "value": "class Solution(object):\n def findMedianSortedArrays(self, nums1, nums2):\n \"\"\"\n :type nums1: List[int]\n :type nums2: List[int]\n :rtype: float\n \"\"\"\n ...
python
chosen