conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add script to subset kerning plist.\n" }, { "from": "gpt", "value": "import sys\nfrom plistlib import writePlist\nfrom defcon import Font\n\n\n__doc__ = '''\nSubset kerning in UFO given a list of glyphs provided.\nWill export new plist files that can be swapped into ...
python
chosen
[ { "from": "human", "value": "Add function to save/restore environment between configuration checks.\n" }, { "from": "gpt", "value": "from copy import deepcopy\n\ndef save_and_set(env, opts, keys=None):\n \"\"\"Put informations from option configuration into a scons environment, and\n retur...
python
chosen
[ { "from": "human", "value": "Document current pycurl exception behavior\n" }, { "from": "gpt", "value": "#! /usr/bin/env python\n# -*- coding: iso-8859-1 -*-\n# vi:ts=4:et\n\nimport pycurl\nimport sys\nimport unittest\n\nclass ErrorTest(unittest.TestCase):\n def setUp(self):\n self.cur...
python
chosen
[ { "from": "human", "value": "Add test for parsing the man page\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom __future__ import absolute_import\n\nimport unittest\n\nimport mock\n\nfrom tldr.parser import parse_page\n\n\nclass TestParse(unittest.TestCase)...
python
chosen
[ { "from": "human", "value": "Add new migration for Django 1.8\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 ('propaganda', ...
python
chosen
[ { "from": "human", "value": "Add zero system test to neural net\n" }, { "from": "gpt", "value": "from net import NeuralNet\nimport numpy as np\n\n#TODO(Wesley) More tests\n\nclass TestNeuralNet(object):\n def test_zero_system(self):\n net = NeuralNet(3, 2, 4, 1, seed=0)\n net.we...
python
chosen
[ { "from": "human", "value": "Add parser for the advisory mail recipients.\n\n* tools/dist/security/mailinglist.py: New.\n\n\ngit-svn-id: f8a4e5e023278da1e04e203c7fe051e3c4285d88@1717919 13f79535-47bb-0310-9956-ffa450edef68\n" }, { "from": "gpt", "value": "#\n# Licensed to the Apache Software Fou...
python
chosen
[ { "from": "system", "value": "Add a proper validator for disable_builtins\n\ngit-svn-id: ad91b9aa7ba7638d69f912c9f5d012e3326e9f74@2243 3942dd89-8c5d-46d7-aeed-044bccf3e60c\n" }, { "from": "human", "value": "import logging\nfrom flexget import plugin\nfrom flexget.plugin import priority, register...
python
chosen
[ { "from": "human", "value": "Write solution to DEC14 XOR question.\n" }, { "from": "gpt", "value": "# http://www.codechef.com/DEC14/problems/XORSUB\nimport operator\ndef f(p):\n\tif p == []:\n\t\treturn 0\n\telif len(p) == 1:\n\t\treturn p[0]\n\telse:\n\t\treturn reduce(operator.xor, p)\n\ndef l...
python
chosen
[ { "from": "human", "value": "Add test for python runner action wrapper process script performance.\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 additio...
python
chosen
[ { "from": "human", "value": "Add test for setopt to demonstrate that edit_config retains non-ASCII characters.\n" }, { "from": "gpt", "value": "# coding: utf-8\n\nfrom __future__ import unicode_literals\n\nimport io\n\nimport six\n\nfrom setuptools.command import setopt\nfrom setuptools.extern.s...
python
chosen
[ { "from": "system", "value": "Correct fallback for tag name\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nfrom sentry.api.serializers import Serializer, register\nfrom sentry.models import GroupTagKey, TagKey\n\n\n@register(GroupTagKey)\nclass GroupTagKeySerializer...
python
chosen
[ { "from": "human", "value": "Write bodies given by coordinates to a VTK file\n" }, { "from": "gpt", "value": "# stardard library\nimport sys, os\n\n# external libraries\nimport numpy as np\nfrom ray import imio, evaluate\n\ndef add_anything(a, b):\n return a + b\n\ndef write_synapse_to_vtk(ne...
python
chosen
[ { "from": "human", "value": "Add command to pre-generate all jpeg images\n" }, { "from": "gpt", "value": "\"\"\"Convert a video file to flv\"\"\"\n\nfrom django.core.exceptions import ImproperlyConfigured\nfrom django.core.management.base import BaseCommand, CommandError \nfrom django.conf impo...
python
chosen
[ { "from": "human", "value": "Add in small utility that creates an index on the MongoDB collection, specifically on the Steam ID number key\n" }, { "from": "gpt", "value": "#!/usr/env python3.4\nimport sys\nfrom pymongo import ASCENDING\nfrom util.mongodb import connect_to_db\nfrom argparse impor...
python
chosen
[ { "from": "human", "value": "Add a script to automate the generation of source distributions for Windows and Linux.\n" }, { "from": "gpt", "value": "\"\"\"Script to automate the creation of Windows and Linux source distributions.\n\nThe TOPKAPI_example directory is also copied and the .svn direc...
python
chosen
[ { "from": "human", "value": "Check that relationships in SsWang are up-to-date\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\"\"\"Test S-value for Table 1 in Wang_2007\"\"\"\n\n__copyright__ = \"Copyright (C) 2020-present, DV Klopfenstein. All rights reserved.\"\n__author__ = \"DV Kl...
python
chosen
[ { "from": "human", "value": "Add a command to retrieve all triggers\n" }, { "from": "gpt", "value": "from IRCResponse import IRCResponse, ResponseType\nfrom CommandInterface import CommandInterface\nimport GlobalVars\n\nclass Command(CommandInterface):\n triggers = [\"triggers\"]\n help = ...
python
chosen
[ { "from": "human", "value": "Add unit tests for core module\n" }, { "from": "gpt", "value": "\"\"\"Test CLI module\"\"\"\n\n\nimport os\nimport sys\nimport tempfile\nimport unittest\nfrom mock import mock_open, patch\nfrom context import dfman\nfrom dfman import config, const, core\n\n\nclass Te...
python
chosen
[ { "from": "human", "value": "[ADD] Rename model to prevent crash during module upgrade in tests\n" }, { "from": "gpt", "value": "# coding: utf-8\nfrom openupgradelib import openupgrade\n\n\n@openupgrade.migrate()\ndef migrate(cr, version):\n openupgrade.rename_tables(cr, [('survey', 'survey_s...
python
chosen
[ { "from": "human", "value": "Add minimal dead code elimination\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"\nDead code elimination.\n\"\"\"\n\nfrom pykit.analysis import loop_detection\n\neffect_free = set([\n 'alloca', 'load', 'new_list', 'new_tuple', 'new_dict', 'new_s...
python
chosen
[ { "from": "human", "value": "Set up test suite to ensure server admin routes are added.\n" }, { "from": "gpt", "value": "\"\"\"General functional tests for the API endpoints.\"\"\"\n\n\nfrom django.test import TestCase, Client\n# from django.urls import reverse\n\nfrom rest_framework import stat...
python
chosen
[ { "from": "human", "value": "Add script to update taking for all team owners\n" }, { "from": "gpt", "value": "import sys\n\nfrom gratipay import wireup\nfrom gratipay.models.participant import Participant\n\ndb = wireup.db(wireup.env())\n\nteams = db.all(\"\"\"\n SELECT t.*::teams\n FROM...
python
chosen
[ { "from": "human", "value": "Add basic unit test for LimitOffsetPagination\n" }, { "from": "gpt", "value": "from collections import OrderedDict\n\nfrom rest_framework.request import Request\nfrom rest_framework.test import APIRequestFactory\nfrom rest_framework.utils.urls import replace_query_pa...
python
chosen
[ { "from": "system", "value": "Fix user agent for the bnn_ sites\n" }, { "from": "human", "value": "import logging\nimport requests\n\n\ndef scrape(url, extractor):\n \"\"\"\n Function to request and parse a given URL. Returns only the \"relevant\"\n text.\n\n Parameters\n --------...
python
chosen
[ { "from": "human", "value": "Add context manager for logging\n\nAllows temporarily changing logging levels in order to suppress expected\nmessages from 3rd party dependencies.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"Context manager that enables temporary changes in logg...
python
chosen
[ { "from": "human", "value": "Add function to delete collection\n" }, { "from": "gpt", "value": "def delete_collection(ee, id):\n if 'users' not in id:\n root_path_in_gee = ee.data.getAssetRoots()[0]['id']\n id = root_path_in_gee + '/' + id\n params = {'id': id}\n items_in_...
python
chosen
[ { "from": "human", "value": "Test of new persistence layer.\n" }, { "from": "gpt", "value": "from ndtable.carray import carray, cparams\nfrom bloscpack import pack_list, unpack_file\nfrom numpy import array, frombuffer\n\ndef test_simple():\n filename = 'output'\n\n # hackish, just experim...
python
chosen
[ { "from": "human", "value": "Create initial night sensor code for Pi\n" }, { "from": "gpt", "value": "\"\"\"\n@author: Sze \"Ron\" Chau\n@e-mail: chaus3@wit.edu\n@source: https://github.com/wodiesan/sweet-skoomabot\n@desc Night sensor-->RPi for Senior Design 1\n\"\"\"\n\nimpor...
python
chosen
[ { "from": "human", "value": "Add a command to list all the documents.\n" }, { "from": "gpt", "value": "\"\"\"\nList the Documents and Folders\n\"\"\"\n\nfrom paper_to_git.commands.base import BaseCommand\nfrom paper_to_git.models import PaperDoc, PaperFolder\n\n__all__ = [\n 'ListCommand',\n ...
python
chosen
[ { "from": "human", "value": "Add simple tests for DrsSymbol and DrsIndexed\n\nBasically it is tested that the class for drudge scripts are basically\nindistinguishable from the original SymPy classes.\n" }, { "from": "gpt", "value": "\"\"\"Tests for drudge scripts.\"\"\"\n\nfrom sympy import Sym...
python
chosen
[ { "from": "human", "value": "Set 2, challenge 9 completed.\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n\n__author__ = 'Walshman23'\n\nimport sys\nsys.path.insert(1, \"../common\") # Want to locate modules in our 'common' directory\n\n\n# A block cipher transforms a fixed-sized bloc...
python
chosen
[ { "from": "human", "value": "Add migration to create roles\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nfrom corehq.apps.hqadmin.management.commands.cchq_prbac_bootstrap import cchq_prbac_bootstrap\...
python
chosen
[ { "from": "human", "value": "Add solution for porblem 31\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nLIMIT = 200\ncoins = [1, 2, 5, 10, 20, 50, 100, 200]\n\n\ndef rec_count(total, step):\n if total == LIMIT:\n return 1\n if total > LIMIT:\n return 0\n c = 0\n ...
python
chosen
[ { "from": "human", "value": "Add a simple basicmap python example\n" }, { "from": "gpt", "value": "\"\"\"\n>>> from pyspark.context import SparkContext\n>>> sc = SparkContext('local', 'test')\n>>> b = sc.parallelize([1, 2, 3, 4])\n>>> sorted(basicSquare(b).collect())\n[1, 4, 9, 12]\n\"\"\"\n\nim...
python
chosen
[ { "from": "human", "value": "Add profiling script for savings code\n\nThis is useful for finding out where the code is spending its time and\nfor testing possible performance improvements.\n" }, { "from": "gpt", "value": "\"\"\"\nBasic profiling code for working out where we're spending our time...
python
chosen
[ { "from": "system", "value": "base: Extend MediaRemovalMixin to move media files on updates\n" }, { "from": "human", "value": "import os\n\nfrom django.conf import settings\n\n\nclass MediaRemovalMixin(object):\n \"\"\"\n Removes all files associated with the model, as returned by the\n ...
python
chosen
[ { "from": "human", "value": "Add cuit validator to utils module\n" }, { "from": "gpt", "value": "# -*- coding: utf-8-*-\n\n\ndef validate_cuit(cuit):\n \"from: http://python.org.ar/pyar/Recetario/ValidarCuit by Mariano Reingart\"\n # validaciones minimas\n if len(cuit) != 13 or cuit[2] ...
python
chosen
[ { "from": "human", "value": "Add script to rewrite the agents used by scc." }, { "from": "gpt", "value": "#!/usr/bin/env python3\nfrom argparse import ArgumentParser\nimport json\nimport os.path\nimport re\nimport sys\n\nfrom generate_simplestreams import json_dump\n\n\ndef main():\n parser =...
python
chosen
[ { "from": "human", "value": "Add python script for extracting server i18n msgs\n" }, { "from": "gpt", "value": "import os\n\n# Keys indicating the fn symbols that pybabel should search for\n# when finding translations.\nkeys = '-k format -k format_time -k format_date -k format_datetime'\n\n# Ext...
python
chosen
[ { "from": "human", "value": "Add solution for Square Detector.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport sys\n\nclass QuizzesParser:\n def __init__(self, src):\n self.src = src\n with open(src) as f:\n self.raw = f.read...
python
chosen
[ { "from": "human", "value": "Add unit test for programmatic application and approval\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport pytest\nfrom members.tests.fixtures.memberlikes import MembershipApplicationFactory\nfrom members.tests.fixtures.types import MemberTypeFactory\nf...
python
chosen
[ { "from": "human", "value": "Add Jaro-Winkler distance based on code on RosettaCode\n" }, { "from": "gpt", "value": "from __future__ import division\nfrom itertools import combinations\nfrom time import time\n\n\ndef jaro(s, t):\n s_len = len(s)\n t_len = len(t)\n\n if s_len == 0 and t_...
python
chosen
[ { "from": "human", "value": "Add script to calculate recalls of track zip files.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom vdetlib.utils.protocol import proto_load, proto_dump, track_box_at_frame\nfrom vdetlib.utils.common import iou\nimport argparse\nimport numpy as np\nimp...
python
chosen
[ { "from": "human", "value": "Add test script with only a few packages\n" }, { "from": "gpt", "value": "from dependencies import extract_package\nimport xmlrpc.client as xmlrpclib\n\nimport random\nclient = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')\npackages = ['gala', 'scikit-learn', ...
python
chosen
[ { "from": "human", "value": "Improve: Add instance method unit tests\n" }, { "from": "gpt", "value": "# Imports\nimport random\nimport unittest\nfrom funky import memoize, timed_memoize\n\n\nclass Dummy(object):\n @memoize\n def a(self):\n return random.random()\n\n\nclass TestInsta...
python
chosen
[ { "from": "human", "value": "Add initial test for web response\n" }, { "from": "gpt", "value": "import unittest\nfrom unittest import mock\nfrom aiohttp.web import Request, StreamResponse\nfrom aiohttp.protocol import Request as RequestImpl\n\n\nclass TestStreamResponse(unittest.TestCase):\n\n ...
python
chosen
[ { "from": "human", "value": "Add script to replace text\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# This Python 3 script replaces text in a file, in-place.\n\n# For Windows, use:\n#!python\n\nimport fileinput\nimport os\nimport sys\n\ndef isValidFile(filename):\n return (filena...
python
chosen
[ { "from": "human", "value": "Create a PySide GUI window.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport sys\nfrom PySide import QtGui\n\napp = QtGui.QApplication(sys.argv)\n\nwid = QtGui.QWidget()\nwid.resize(250, 150)\nwid.setWindowTitle('Simple')\nwid.show()\n\nsys.exit(app.e...
python
chosen
[ { "from": "human", "value": "Use servoblaster to control servo\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport os.path\nimport subprocess\nimport time\n\ndef scaler(OldMin, OldMax, NewMin, NewMax):\n def fn(OldValue):\n return (((OldValue - OldMin) * (NewMax - NewMin)) /...
python
chosen
[ { "from": "human", "value": "Add unit test for treating Ordering as a collection\n" }, { "from": "gpt", "value": "from unittest import TestCase\n\nfrom ordering import Ordering\n\n\nclass TestOrderingAsCollection(TestCase):\n def setUp(self) -> None:\n self.ordering = Ordering[int]()\n...
python
chosen
[ { "from": "human", "value": "Add basic tag testing script\n\nChange-Id: I55d17f33a931aaa7fcdf9b5833d5dedef40f9c8a\n" }, { "from": "gpt", "value": "import sys\nimport requests\n\nfrom wikibugs import Wikibugs2\nfrom channelfilter import ChannelFilter\nimport configfetcher\n\nconf = configfetcher....
python
chosen
[ { "from": "human", "value": "Add script for appending entries to .gitignore.\n\nTBR=kjellander\n\nReview URL: https://webrtc-codereview.appspot.com/1629004\n\ngit-svn-id: 917f5d3ca488f358c4d40eaec14422cf392ccec9@4193 4adac7df-926f-26a2-2b94-8c16560cd09d\n" }, { "from": "gpt", "value": "#!/usr/bi...
python
chosen
[ { "from": "human", "value": "Add tests for createaccount command\n" }, { "from": "gpt", "value": "from unittest.mock import ANY, Mock\n\nimport requests\nfrom django.core.management import call_command\n\nfrom saleor.account.models import ServiceAccount\nfrom saleor.core.permissions import get_p...
python
chosen
[ { "from": "human", "value": "Add script to update cvsanaly databases\n" }, { "from": "gpt", "value": "from jiradb import *\n\nif __name__ == \"__main__\":\n log.setLevel(logging.DEBUG)\n # Add console log handler\n ch = logging.StreamHandler()\n ch.setLevel(logging.INFO)\n ch.setF...
python
chosen
[ { "from": "human", "value": "Add server tests for JOIN.\n" }, { "from": "gpt", "value": "\"\"\"\nSection 3.2 of RFC 2812\n<https://tools.ietf.org/html/rfc2812#section-3.2>\n\"\"\"\n\nfrom irctest import cases\nfrom irctest.irc_utils.message_parser import Message\n\nclass JoinTestCase(cases.BaseS...
python
chosen
[ { "from": "human", "value": "Add sp500_extractor_v1 version that does not use BeautifulSoup.\n\nThis version uses the lxml library to parse the HTML string via xpath. Also change urllib to requests for better efficiency. Update initial comment links to show relevant code resources.\n" }, { "from": "...
python
chosen
[ { "from": "human", "value": "Add script to plot MS flag rate and acq fail rate\n" }, { "from": "gpt", "value": "from __future__ import division\n\nimport matplotlib.pyplot as plt\nfrom astropy.table import Table\nimport numpy as np\nfrom Ska.DBI import DBI\nfrom chandra_aca import star_probs\n\n...
python
chosen
[ { "from": "human", "value": "Write initial Bible book HTML parser\n\nThis parser will be utilized by the add_language utility so as to\nwork towards eliminating PyQuery as a dependency.\n" }, { "from": "gpt", "value": "# utilities.book_parser\n# coding=utf-8\n\nfrom __future__ import unicode_lit...
python
chosen
[ { "from": "human", "value": "Add a script to convert a GRLevelX colortable file to a dict data structure (and optionally boundaries for norm) for use with Matplotlib.\n\ngit-svn-id: acf0ef94bfce630b1a882387fc03ab8593ec6522@323 150532fb-1d5b-0410-a8ab-efec50f980d4\n" }, { "from": "gpt", "value": ...
python
chosen
[ { "from": "human", "value": "Split IP validation to a module\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport socket\n\ndef parse(ip):\n # parse and validate ip address\n try:\n socket.inet_pton(socket.AF_INET,ip)\n return \"valid\"\n except socket.error, e:\...
python
chosen
[ { "from": "human", "value": "Add unit tests for AmountTaxScale serialization\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nfrom openfisca_web_api.loader.parameters import walk_node\nfrom openfisca_core.parameters import ParameterNode, Scale\n\ndef test_amount_scale():\n paramete...
python
chosen
[ { "from": "human", "value": "Add a dummy label printer server.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# It does work with Python 2.7, too.\n\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\n\ntry:\n from SocketServer import TCPServer, BaseRequ...
python
chosen
[ { "from": "human", "value": "Add test for dials.report on integrated data\n" }, { "from": "gpt", "value": "from __future__ import absolute_import, division, print_function\n\nimport os\nimport procrunner\n\n\ndef test_report_integrated_data(dials_regression, run_in_tmpdir):\n \"\"\"Simple tes...
python
chosen
[ { "from": "human", "value": "Add migration file for new database model\n" }, { "from": "gpt", "value": "# Generated by Django 3.2.5 on 2021-10-12 23:24\n\nfrom django.db import migrations, models\nimport django.db.models.deletion\n\n\nclass Migration(migrations.Migration):\n\n dependencies = ...
python
chosen
[ { "from": "human", "value": "Test case for LSPI on gridworld.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n__author__ = \"William Dabney\"\n\nfrom Domains import GridWorld\nfrom Tools import Logger\nfrom Agents import LSPI\nfrom Representations import Tabular\nfrom Policies import e...
python
chosen
[ { "from": "human", "value": "Add automatic leak detection python script in examples\n" }, { "from": "gpt", "value": "import sys\nimport rpc.ws\nimport edleak.api\nimport edleak.slice_runner\n\ndef usage():\n print('autodetect [period] [duration]')\n\ndef print_leaker(leaker):\n print('------...
python
chosen
[ { "from": "human", "value": "Add test for pygame sound play hook\n" }, { "from": "gpt", "value": "import pygame\nimport random\nfrom demodulate.cfg import *\nfrom gen_tone import *\n\nif __name__ == \"__main__\":\n\tpygame.mixer.pre_init(frequency = int(SAMPLE_FREQ), channels = 1)\n\tpygame.mixe...
python
chosen
[ { "from": "human", "value": "Add function to generate uniform addresses\n\nGiven maximum and minimum latitudes and longitudes as well as\nresolutions for latitude and longitude in degrees, this function\noutputs a .csv file with uniformly spaced latitude-longitude pairs\nbounded by the maximum and minimum l...
python
chosen
[ { "from": "human", "value": "Add border operation... Damn that was easy\n" }, { "from": "gpt", "value": "import slicer\nimport shapely.ops\nimport shapely.geometry\n\ndef border(sli, amount):\n cuts = [cut.polygon(True) for cut in sli.cuts]\n cut_outline = shapely.ops.cascaded_union(cuts) ...
python
chosen
[ { "from": "human", "value": ":rocket: Add migration file (fix fields)\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11 on 2017-05-12 14:38\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migr...
python
chosen
[ { "from": "human", "value": "Add simple recipe tagger experiment\n" }, { "from": "gpt", "value": "import nltk\nfrom nltk.classify import MaxentClassifier\n\n# Set up our training material in a nice dictionary.\ntraining = {\n 'ingredients': [\n 'Pastry for 9-inch tart pan',\n 'A...
python
chosen
[ { "from": "human", "value": "Add example OOP python script\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n#\n# Copyright 2016 BMC Software, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You...
python
chosen
[ { "from": "system", "value": "Make all end-points accepting post\n" }, { "from": "human", "value": "import bottle\nfrom bottle import response, request\nimport json\nimport jedi\nimport logging\n\n\napp = bottle.Bottle( __name__ )\nlogger = logging.getLogger( __name__ )\n\n\n@app.get( '/healthy'...
python
chosen
[ { "from": "human", "value": "Add unit test for glacier vault\n\nJust verifies the args are forwarded to layer1 properly.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# Copyright (c) 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved\n#\n# Permission is hereby granted, free ...
python
chosen
[ { "from": "human", "value": "Add solution for exercise 2b of hw3\n" }, { "from": "gpt", "value": "import sympy\n\nx1, x2 = sympy.symbols('x1 x2')\nf = 8*x1 + 12*x2 + x1**2 -2*x2**2\n\ndf_dx1 = sympy.diff(f,x1)\ndf_dx2 = sympy.diff(f,x2)\nH = sympy.hessian(f, (x1, x2))\n\nxs = sympy.solve([df_dx1...
python
chosen
[ { "from": "human", "value": "Add memoize function for python 2.x\n" }, { "from": "gpt", "value": "from functools import wraps\n\n\ndef memoize(obj):\n # This is taken from the Python Decorator Library on the official Python\n # wiki. https://wiki.python.org/moin/PythonDecoratorLibrary#Mem...
python
chosen
[ { "from": "human", "value": "Add custom command to daily check scores\n" }, { "from": "gpt", "value": "from constance import config\nfrom datetime import datetime\nfrom django.core.management.base import BaseCommand\nfrom django.core.mail import EmailMessage\nfrom django.shortcuts import get_lis...
python
chosen
[ { "from": "human", "value": "Add tests for mach angle\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n\"\"\"Test Mach angle functions.\n\nTest data is obtained from http://www.grc.nasa.gov/WWW/k-12/airplane/machang.html.\n\"\"\"\n\n\nimport nose\nimport nose.tools as nt\n\nfrom propert...
python
chosen
[ { "from": "human", "value": "Create list of random num\n" }, { "from": "gpt", "value": "#List of randoms\n\nimport random\nimport math\n\nnumList = []\n\nfor i in range(10):\n numList.append(random.randrange(1, 20))\n\nfor i in numList:\n print(\"Rand num = \" + str(i))\n" } ]
python
chosen
[ { "from": "human", "value": "Add tests for java mode\n" }, { "from": "gpt", "value": "import editor_manager\nimport editor_common\nimport curses\nimport curses.ascii\nimport keytab\nfrom ped_test_util import read_str,validate_screen,editor_test_suite,play_macro,screen_size,match_attr\n\ndef test...
python
chosen
[ { "from": "human", "value": "Add high level signing capabilities\n" }, { "from": "gpt", "value": "# Import libnacl libs\nimport libnacl.sign\n\n# Import pythonlibs\nimport unittest\n\n\nclass TestSigning(unittest.TestCase):\n '''\n '''\n def test_sign(self):\n msg = ('Well, that\...
python
chosen
[ { "from": "human", "value": "Create script that checks for dev and docs dependencies.\n" }, { "from": "gpt", "value": "from __future__ import print_function\n\nimport sys\n\ntry:\n import colorama\n def blue(text): return \"%s%s%s\" % (colorama.Fore.BLUE, text, colorama.Style.RESET_ALL)\n ...
python
chosen
[ { "from": "human", "value": "Add a small driver for plotting skeletons.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport climate\n\nimport database\nimport plots\n\n\n@climate.annotate(\n root='plot data rooted at this path',\n pattern=('plot data from files matching this p...
python
chosen
[ { "from": "human", "value": "Add an example for dynamic RPC lookup.\n" }, { "from": "gpt", "value": "import asyncio\nimport aiozmq\nimport aiozmq.rpc\n\n\nclass DynamicHandler(aiozmq.rpc.AttrHandler):\n\n def __init__(self, namespace=()):\n self.namespace = namespace\n\n def __getit...
python
chosen
[ { "from": "system", "value": "Use the custom.js as served from the CDN for try\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# Configuration file for ipython-notebook.\n\nc = get_config()\nc.NotebookApp.ip = '*'\nc.NotebookApp.open_browser = False\nc.Notebo...
python
chosen
[ { "from": "system", "value": "Fix some scope mistakes. This fix was part of the reverted commit.\n" }, { "from": "human", "value": "import commands.cmds as cmds\n\ndef handle(self, chat_raw):\n self.logger.info(\"Handling command: \" + chat_raw + \" (for player\" + self.fquid + \")\")\n _a...
python
chosen
[ { "from": "human", "value": "Add tests for the controller module\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n# Copyright (c) 2018 Future Internet Consulting and Development Solutions S.L.\n\n# This file is part of CKAN WireCloud View Extension.\n\n# CKAN WireCloud View Extension ...
python
chosen
[ { "from": "human", "value": "Add util convenience functions for accessing data without decorators\n" }, { "from": "gpt", "value": "from decorators import _backend\n\n\"\"\"Access limits and increment counts without using a decorator.\"\"\"\n\ndef get_limits(request, label, field, periods):\n ...
python
chosen
[ { "from": "system", "value": "Disable trix parser tests with Jython\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\n\nfrom rdflib.graph import ConjunctiveGraph\nimport unittest\n\nclass TestTrixParse(unittest.TestCase):\n\n def setUp(self):\n pass\n\n def tearDown(self):...
python
chosen
[ { "from": "human", "value": "Add VCF -> non-reference likelihood table script.\n" }, { "from": "gpt", "value": "from __future__ import print_function\nimport sys\nimport cyvcf\nfrom argparse import ArgumentParser, FileType\nimport toolz as tz\n\ndescription = (\"Create a table of probability of ...
python
chosen
[ { "from": "human", "value": "Implement function for displaying tuning guidance on a DIY 8-segment LEDs display\n" }, { "from": "gpt", "value": "import math\nfrom gpiozero import LED\nfrom time import sleep\n\n\ng0 = LED(12)\nf0 = LED(16)\na0 = LED(20)\nb0 = LED(21)\ne0 = LED(17)\nd0 = LED(27)\nc...
python
chosen
[ { "from": "human", "value": "Add a utility script to print duplicates" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport json\nimport os\nimport random\n\nscriptpath = os.path.dirname(__file__)\ndata_dir = os.path.join(scriptpath, 'data')\nall_json = [f for f in os.listdir(data_dir)...
python
chosen
[ { "from": "human", "value": "Add a sequence module for optimizing gating\n\n--CAR\n" }, { "from": "gpt", "value": "\"\"\"\nSequences for optimizing gating timing.\n\"\"\"\nfrom ..PulsePrimitives import *\nfrom ..Compiler import compile_to_hardware\n\ndef sweep_gateDelay(qubit, sweepPts):\n \"...
python
chosen
[ { "from": "human", "value": "Add a simple command to print all areas in all generations\n" }, { "from": "gpt", "value": "# For each generation, show every area, grouped by type\n\nfrom django.core.management.base import NoArgsCommand\nfrom mapit.models import Area, Generation, Type, NameType, Co...
python
chosen
[ { "from": "human", "value": "Copy paste artist from filename1 to filename2\n\nUtility to help consolidate groups of mp3s while preserving metadata in their filenames" }, { "from": "gpt", "value": "# Extract the artist name from songs with filenames in this format:\r\n# (number) - (artist) - (...
python
chosen
[ { "from": "human", "value": "Add script to list objects\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport os.path as osp\n\nimport rospkg\n\n\nPKG_PATH = rospkg.RosPack().get_path('jsk_arc2017_common')\n\nobject_names = ['__background__']\nwith open(osp.join(PKG_PATH, 'data/names/...
python
chosen
[ { "from": "system", "value": "Use same variable names as testing environment\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom pymisp import PyMISP\nfrom keys import misp_url, misp_key, misp_verifycert\nimport argparse\nimport tools\n\ndef init(url, key):\...
python
chosen
[ { "from": "human", "value": "Add the answer to the sixth question of Assignment 3\n" }, { "from": "gpt", "value": "\"\"\" Q6- Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i',\n'o', and 'u'. For example, if s = 'azcbobobegghakl', your...
python
chosen
[ { "from": "human", "value": "Add cli tool to delete documents.\n\nChange-Id: I16c99d4b625e627c693c6354aaaa191c5076344b\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Affero General Pub...
python
chosen