conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add py solution for 451. Sort Characters By Frequency\n\n451. Sort Characters By Frequency: https://leetcode.com/problems/sort-characters-by-frequency/\n" }, { "from": "gpt", "value": "from collections import Counter\nclass Solution(object):\n def frequencySort(se...
python
chosen
[ { "from": "human", "value": "Add sample basic auth layers\n\nNot very flexible, these are more meant to be a sample for others\ncreating Layers. Given how similar the code is and how basic most\nhande_request() methods will be, it might be worth creating something\nsimilar to @contextmanager, so that it's ...
python
chosen
[ { "from": "human", "value": "Update enabled to be simpler and match rpc-openstack.\n" }, { "from": "gpt", "value": "DASHBOARD = 'rackspace'\n\nADD_INSTALLED_APPS = [\n 'rackspace',\n]\n\nADD_ANGULAR_MODULES = ['horizon.dashboard.rackspace']\n\n# If set to True, this dashboard will not be adde...
python
chosen
[ { "from": "human", "value": "Add script for finding sentences that cannot be parsed with our IRTG\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# *-* coding=utf-8 *-*\n\n# Compares the nolarge.graphs file (the one without #-lines) and Alto's output to find sentences that cannot be pars...
python
chosen
[ { "from": "human", "value": "Add basic spreadsheet service which can get a range from a public spreadsheet.\n\nJustification: the owners and some other more minor details about\nbenchmarks are currently stored in a spreadsheet. I need to get that\ndata to make a solid benchmark health report, and I'd like t...
python
chosen
[ { "from": "system", "value": "Install CMake in system dirs" }, { "from": "human", "value": "#!/usr/bin/env python\n# Build the project with Biicode.\n\nimport bootstrap, glob, os, shutil\nfrom download import Downloader\nfrom subprocess import check_call\n\nos_name = os.environ['TRAVIS_OS_NAME']...
python
chosen
[ { "from": "human", "value": "Create migration file for accounts app\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9 on 2016-05-07 19:02\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migrati...
python
chosen
[ { "from": "human", "value": "DOC: Add example for Top-K with Others.\n" }, { "from": "gpt", "value": "\"\"\"\nTop-K plot with Others\n----------------------\nThis example shows how to use aggregate, window, and calculate transfromations\nto display the top-k directors by average worldwide gross ...
python
chosen
[ { "from": "human", "value": "Add missing migration, bump to version 0.3.2\n\nIt's only metadata (labels), so not a dealbreaker.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migra...
python
chosen
[ { "from": "system", "value": "Update version to 0.4.1 for release\n" }, { "from": "human", "value": "\"\"\"EVELink - Python bindings for the EVE API.\"\"\"\n\nimport logging\n\nfrom evelink import account\nfrom evelink import api\nfrom evelink import char\nfrom evelink import constants\nfrom eve...
python
chosen
[ { "from": "human", "value": "Check in anaconda-mode.py so pip doesn't need to install it.\n" }, { "from": "gpt", "value": "\"\"\"\n anaconda_mode\n ~~~~~~~~~~~~~\n\n This is anaconda_mode autocompletion server.\n\n :copyright: (c) 2013-2015 by Artem Malyshev.\n :license: GPL3, see...
python
chosen
[ { "from": "human", "value": "Add some unit tests for cache object\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n'''\n tests.unit.utils.cache_test\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n Test the salt cache objects\n'''\n\n# Import Salt Testing libs\nfrom salttesting import TestCas...
python
chosen
[ { "from": "human", "value": "Convert a Spotify playylist from Exportify to yaml\n" }, { "from": "gpt", "value": "\"\"\"Convert Exportify csv Spotify playlists to yaml.\"\"\"\nimport os\nimport glob\nimport pandas\nimport yaml\n\n\ncsv_files = glob.glob(\"*.csv\")\n\nfor playlist_file in csv_file...
python
chosen
[ { "from": "human", "value": "Add human machine interface node\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport rospy\nfrom std_msgs.msg import Int32\nfrom controller.msg import control\n\n\nmux_pub = rospy.Publisher('pwm_signal_input', Int32, queue_size=10) \n\ndef controller_cal...
python
chosen
[ { "from": "human", "value": "Convert a given image to gray color model" }, { "from": "gpt", "value": "import requests\nimport json\n\n# Convert a given image to gray color model. A grayscale (or graylevel) image is simply one in which the only colors are shades of gray.\n# https://pixlab.io/#/cm...
python
chosen
[ { "from": "human", "value": "Add bias to cosine distance for two tower models\n\nSummary: Currently using two tower models with cosine distance results in bad calibration. Adding bias to the output of cosine term solves the problem.\n\nReviewed By: xianjiec\n\nDifferential Revision: D5132606\n\nfbshipit-sou...
python
chosen
[ { "from": "human", "value": "Add a management command that resets tiers state\n" }, { "from": "gpt", "value": "# This file is part of Miro Community.\n# Copyright (C) 2011 Participatory Culture Foundation\n# \n# Miro Community is free software: you can redistribute it and/or modify it\n# under t...
python
chosen
[ { "from": "human", "value": "Add script to synthesize all uploaded files.\nPatch by Dan Callahan.\n\n\ngit-svn-id: 757818eefc3e095bf4f5c16d67ad3f55b5150c3d@608 072f9a9a-8cf7-0310-8ca5-bf92c90cb7c1\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\"\"\"\nThis script touches all files known to ...
python
chosen
[ { "from": "human", "value": "Add Python Chapter 4 Challenges\n" }, { "from": "gpt", "value": "import math\n\nclass Opt:\n def __init__(self, v = None):\n self.valid = (v != None)\n self.value = v\n\ndef safe_rezi(x):\n if x == 0:\n return Opt()\n else:\n retu...
python
chosen
[ { "from": "human", "value": "Add tests to run command to merge content" }, { "from": "gpt", "value": "from mock import Mock\n\nfrom main.management.commands.merge_coverage_files import Command\nfrom main.tests.helper_methods import mock_out_unwanted_methods\n\n\ndef test_merge_coverage_handle_ca...
python
chosen
[ { "from": "human", "value": "Add unit test suite for PgBackup\n" }, { "from": "gpt", "value": "# coding: utf-8\n\"\"\"\nUnit tests for essential functions in postgresql backup.\n\"\"\"\nfrom unittest.mock import MagicMock, mock_open, patch\nimport pytest\nimport smdba.postgresqlgate\n\n\nclass T...
python
chosen
[ { "from": "human", "value": "Add PL Calculator for unrealized profit and loss calculation\n" }, { "from": "gpt", "value": "from decimal import Decimal\n\nfrom cryptex.transaction import Deposit, Withdrawal\nfrom cryptex.trade import Buy, Sell\nfrom functools import partial\n\nclass PLCalculator(...
python
chosen
[ { "from": "human", "value": "Add unit tests for package resource\n" }, { "from": "gpt", "value": "import pytest\n\nfrom mock import patch, Mock\n\nfrom spanky.resources import package\n\n\nclass TestPackageResource(object):\n\n def test_package_install(self):\n pack = package.Package('...
python
chosen
[ { "from": "human", "value": "Move R's spline to regression module\n" }, { "from": "gpt", "value": "\"\"\" Regression or prediction methods from R\n\"\"\"\nimport numpy as np\nfrom rpy2.robjects.packages import importr\nimport rpy2.robjects.numpy2ri\n\nrpy2.robjects.numpy2ri.activate()\n\nRstats ...
python
chosen
[ { "from": "human", "value": "Add test for User table initialization\n" }, { "from": "gpt", "value": "import unittest\n\nfrom app import create_app, db\nfrom app.models import User\n\n\nclass TestUtils(unittest.TestCase):\n def setUp(self):\n self.app = create_app(\"testing\")\n ...
python
chosen
[ { "from": "human", "value": "Add inital MI feature selection code\n\n" }, { "from": "gpt", "value": "import numpy as np\nimport pandas as pd\nfrom sklearn.feature_extraction.text import TfidfVectorizer\nfrom sklearn.feature_selection import chi2, SelectKBest\nfrom sklearn.neighbors import KNeigh...
python
chosen
[ { "from": "human", "value": "Add a mosaic drawer in Python\n" }, { "from": "gpt", "value": "import optparse\nimport fractions\n\nimport cairo\n\nimport turkshead\n\nwidth = 8\nheight = 6\nsize = 200\n\nimg = cairo.ImageSurface( cairo.FORMAT_RGB24, width * size, height * size )\nctx = cairo.Conte...
python
chosen
[ { "from": "human", "value": "Add tests for connection class\n" }, { "from": "gpt", "value": "\"\"\" Tests for the Connection module \"\"\"\n\nimport unittest\n\nfrom src import connection\n\nclass TestConnection(unittest.TestCase):\n \"\"\" Tests for the Connection module \"\"\"\n\n def te...
python
chosen
[ { "from": "human", "value": "Add script to split fasta files\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n__description__ = \"Split a fasta file and generate a file for each entry\"\n__author__ = \"Konrad Foerstner <konrad@foerstner.org>\"\n__copyright__ = \"2013 by Konrad Foerstner...
python
chosen
[ { "from": "human", "value": "Add simple unit tests for exceptions\n" }, { "from": "gpt", "value": "import pytest\n\nimport exceptions\n\n\ndef test_exceptions():\n # testing exception inheritance\n with pytest.raises(Exception):\n raise exceptions.CardinalException\n\n with pytes...
python
chosen
[ { "from": "human", "value": "Add Towers of Hanoi algorithm and tests\n" }, { "from": "gpt", "value": "#!/Applications/anaconda/envs/Python3/bin\n\n\ndef main():\n for i in range(1, 8):\n print(\"============================\")\n print(\"Towers of Hanoi: {} Disks\".format(i))\n ...
python
chosen
[ { "from": "human", "value": "Add solution and unit tests for problem 4\n" }, { "from": "gpt", "value": "\"\"\"\nProject Euler Problem 4\n=======================\n\nA palindromic number reads the same both ways. The largest palindrome made\nfrom the product of two 2-digit numbers is 9009 = 91 * 9...
python
chosen
[ { "from": "human", "value": "Add helper classes for using python-twitter on App Engine (currently just a\ncache implementation on top of the App Engine datastore).\n" }, { "from": "gpt", "value": "import time\n\nfrom django.utils import simplejson\nfrom google.appengine.ext import db\n\nclass _D...
python
chosen
[ { "from": "human", "value": "Add test to check that error is properly raised when a photon is emitted outside the grid." }, { "from": "gpt", "value": "import pytest\nimport numpy as np\n\nfrom .. import Model\nfrom .test_helpers import random_filename, get_test_dust\n\n\ndef test_point_source_o...
python
chosen
[ { "from": "human", "value": "Add a basic context processor which exposes common settings\n" }, { "from": "gpt", "value": "# encoding: utf-8\n\nfrom django.conf import settings\nfrom django.contrib.sites.models import Site\n\ndef site_settings(request):\n \"\"\"Expose common Django settings to...
python
chosen
[ { "from": "human", "value": "Fix for display date repeat of YYYY\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport re\n\nr=re.compile(r'(\\d\\d\\d\\d)-\\1')\n\ndef fix_repeated_date(doc):\n dates = doc['sourceResource'].get('date', None)\n if dates:\n if isinstance(da...
python
chosen
[ { "from": "human", "value": "Add failing test validating missing imapsieve capability.\n\nIssue #41\n" }, { "from": "gpt", "value": "import unittest\nimport checksieve\n\nclass TestNoRequire(unittest.TestCase):\n\n\tdef test_no_require(self):\n\t\tsieve = '''\n\t\t\trequire [\"copy\", \"environm...
python
chosen
[ { "from": "human", "value": "Add missing file in previous commit.\n" }, { "from": "gpt", "value": "# -*- encoding: utf-8 -*-\r\n##############################################################################\r\n#\r\n# Copyright (C) 2015 Compassion CH (http://www.compassion.ch)\r\n# Releasin...
python
chosen
[ { "from": "human", "value": "Add recursive also for fibonnaci\n" }, { "from": "gpt", "value": "\"\"\"Implement a function recursivly to get the desired\nFibonacci sequence value.\nYour code should have the same input/output as the\niterative code in the instructions.\"\"\"\n\ndef get_fib(positio...
python
chosen
[ { "from": "human", "value": "Add simplistic test to run through all autonomous modes\n" }, { "from": "gpt", "value": "'''\n Runs all of the autonomous modes in a basic way\n'''\n\n\ndef test_all_autonomous(robot, wpilib, fake_time):\n\n autonomous_chooser = wpilib.SmartDashboard._table.dat...
python
chosen
[ { "from": "human", "value": "Solve Code Fights twins score problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Twins Score Problem\n\n\ndef twinsScore(b, m):\n return [sum(item) for item in zip(b, m)]\n\n\ndef main():\n tests = [\n [[22, 13, 45, 32], [28,...
python
chosen
[ { "from": "human", "value": "Create script to run stats on aws.\n" }, { "from": "gpt", "value": "import boto3\nfrom indra.db.util import get_db_statistics\nfrom datetime import datetime\n\ndef main():\n utcnow = datetime.utcnow()\n fname = \"Primary_Database_Status_Report_%s.txt\" % utcnow...
python
chosen
[ { "from": "human", "value": "Add migration remove generated paths\n" }, { "from": "gpt", "value": "# Generated by Django 2.0.13 on 2020-04-06 13:40\n\nfrom django.conf import settings\nfrom django.contrib.gis.geos import Point, LineString\nfrom django.db import migrations\n\n\ndef remove_generat...
python
chosen
[ { "from": "human", "value": "Add a test to ensure access to missing attributes raises the correct\nexception\n" }, { "from": "gpt", "value": "# Copyright 2011 OpenStack LLC.\n# All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use t...
python
chosen
[ { "from": "human", "value": "Add util & lots of funciton\n" }, { "from": "gpt", "value": "# coding=utf-8\n\nimport os\n\n\"\"\"\n 公用方法\n\"\"\"\n\n\"\"\"\n 日志\n level: 级别\n msg: 信息\n\"\"\"\nlog_limit_level = 2\ndef log(level, msg, limit_level=log_limit_level):\n if 2-level > log_li...
python
chosen
[ { "from": "human", "value": "Reimplement setup and teardown of TestVCSPrompt\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\ntest_vcs_prompt\n---------------\n\"\"\"\n\nimport os\nimport pytest\n\nfrom cookiecutter import utils\n\n\n@pytest.fixture\ndef...
python
chosen
[ { "from": "human", "value": "Add simple script for renaming files using thetvdb.com\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n'''\nTODO: \n- Get episode names, numbers, seasons from URL\n- Get path to rename from stdin\n- Get thetvdb url from stdin\n'''\n\nimport os\nimport os.pa...
python
chosen
[ { "from": "human", "value": "Add document / image permissions\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.utils.utils import update_group_...
python
chosen
[ { "from": "human", "value": "Add one test for Experiment object\n\nThis was copied over from the tests for related dataobjects.\n\nMaybe all of these types of test could be factored out into the\nDataObjectTest.py testfile?\n" }, { "from": "gpt", "value": "import sys\nsys.path.insert(0,\".\")\ni...
python
chosen
[ { "from": "human", "value": "Test a variety of URIs\n" }, { "from": "gpt", "value": "[\n {\n \"message\": b\"GET / HTTP/1.1\\r\\n\\r\\n\",\n \"expected\": {\n \"request_method\": b\"GET\",\n \"request_uri\": b\"/\",\n \"http_version\": b\"HTTP/1....
python
chosen
[ { "from": "human", "value": "Add first pass at simple cli tooling\n" }, { "from": "gpt", "value": "import argparse\nimport os\nfrom nephoria.testcontroller import TestController\nimport logging\nparser = argparse.ArgumentParser(description='Euca Runtime Config Generator')\nparser.add_argument('-...
python
chosen
[ { "from": "human", "value": "Add basic test case for Queryable class\n" }, { "from": "gpt", "value": "from busbus.queryable import Queryable\n\n\ndef test_queryable():\n q = Queryable(xrange(10)).where(lambda x: x % 5 == 0)\n assert next(q) == 0\n assert next(q) == 5\n" } ]
python
chosen
[ { "from": "human", "value": "Create code to parse Tafseer files fomr Tanzil.net\n" }, { "from": "gpt", "value": "from quran_text.models import Ayah\nfrom quran_tafseer.models import TafseerText, Tafseer\n\n\ndef parse_tafseer_file(file_name, tafseer_name):\n with open(file_name, 'r') as tafse...
python
chosen
[ { "from": "human", "value": "Add script to get metrics from BERT models\n" }, { "from": "gpt", "value": "import pickle\nimport os\nimport argparse\nimport numpy as np\nimport pandas as pd\nimport tensorflow as tf\nfrom sklearn.cluster import AgglomerativeClustering, KMeans\nfrom sklearn.metrics ...
python
chosen
[ { "from": "human", "value": "Add migration that got removed during re-generation.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.28 on 2020-05-20 14:56\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nimport kolibri.core.fields\n...
python
chosen
[ { "from": "human", "value": "Add linting tests (PEP8 and PyPi)\n" }, { "from": "gpt", "value": "import sys\nimport subprocess\n\n\ndef test_pep8():\n result = subprocess.call(['pep8', '--statistics', '--show-source'])\n assert result == 0\n\n\ndef test_pypi():\n result = subprocess.call...
python
chosen
[ { "from": "human", "value": "testing: Add dEQP test merge script.\r\n\r\nThis script will allow ANGLE to process custom logic when we complete\r\na suite of dEQP tests on the bots. The first customization step we\r\ncan do is merge the myriad batch QPA files into one master QPA file.\r\n\r\nThis script is ...
python
chosen
[ { "from": "human", "value": "Add code to see what authors there are in the dataset\n" }, { "from": "gpt", "value": "import os\nfrom utils import Reader\nimport code\nimport sys\n\nauthor_dict = dict()\n\n\ndef extract_authors(tweets):\n # code.interact(local=dict(globals(), **locals()))\n\n ...
python
chosen
[ { "from": "human", "value": "Add explicit test for finals2000A.all converter\n" }, { "from": "gpt", "value": "from numpy import array, inf\nfrom skyfield.data.iers import _build_timescale_arrays\n\ndef test_build_timescale_arrays():\n mjd = array([42046.00, 42047.00, 42048.00, 42049.00])\n ...
python
chosen
[ { "from": "human", "value": "Add a source with changing shape for debuging\n" }, { "from": "gpt", "value": "# Import analysis/plotting modules\nimport analysis.event\nimport plotting.image\nimport numpy as np\n\n# Set new random seed\nnp.random.seed()\n\n# Specify the facility\nstate = {}\nstate...
python
chosen
[ { "from": "human", "value": "Fix incorrect migration that left out stat titles on result pages.\n\nThis should fix all stats on all tenants except for manual input.\n\nBB-11474 #resolve\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.8 on 2017-12-20 10:45\nfr...
python
chosen
[ { "from": "human", "value": "Split the element class from the data store so that it can be imported independently as needed\n\ngit-svn-id: 27e0aca8c7a52a9ae65dfba2e16879604119af8c@1336 93a4e39c-3214-0410-bb16-828d8e3bcd0f\n" }, { "from": "gpt", "value": "#/***************************************...
python
chosen
[ { "from": "human", "value": "Complete test coverage for content_type_resolvers\n" }, { "from": "gpt", "value": "import pytest\n\nfrom odinweb import content_type_resolvers\nfrom odinweb.testing import MockRequest\n\n\n@pytest.mark.parametrize('resolver, args, http_request, expected', (\n # Ac...
python
chosen
[ { "from": "human", "value": "Add chief deploy script for www-dev.\n" }, { "from": "gpt", "value": "\"\"\"\nDeployment for Bedrock on www-dev.allizom.org.\n\nRequires commander (https://github.com/oremj/commander) which is installed on\nthe systems that need it.\n\"\"\"\nimport os\nimport sys\n\n...
python
chosen
[ { "from": "human", "value": "Add script to broadcast local ip via mdns, for easy to find the pi address without monitor\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport socket\nimport time\n\nfrom zeroconf import *\n\ndef main():\n print \"Register SSH service ...\"\n\n service...
python
chosen
[ { "from": "system", "value": "Add staff and user permission to views\n" }, { "from": "human", "value": "#from django.core.paginator import Paginate\n\ntry:\n import floppyforms as forms\nexcept ImportError:\n from django import forms\n \n# TODO add default widgets \n\nclass BaseMongo...
python
chosen
[ { "from": "human", "value": "examples: Add LVM cache pool example\n" }, { "from": "gpt", "value": "import os\n\nimport blivet\nfrom blivet.size import Size\nfrom blivet.util import set_up_logging, create_sparse_tempfile\n\n\nset_up_logging()\nb = blivet.Blivet() # create an instance of Blivet ...
python
chosen
[ { "from": "human", "value": "Add crawler for 'Geek and Poke'\n" }, { "from": "gpt", "value": "from comics.aggregator.crawler import BaseComicCrawler\nfrom comics.meta.base import BaseComicMeta\n\nclass ComicMeta(BaseComicMeta):\n name = 'Geek and Poke'\n language = 'en'\n url = 'http://...
python
chosen
[ { "from": "human", "value": "Add a unit test for the no_NO bban\n" }, { "from": "gpt", "value": "# coding=utf-8\n\nimport re\nimport unittest\n\nfrom faker import Faker\n\nclass TestNoNO(unittest.TestCase):\n \"\"\" Tests the street address in no_NO locale \"\"\"\n\n def setUp(self):\n ...
python
chosen
[ { "from": "human", "value": "Add notebook pre processing script to replace load magics.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport json\nimport re\nfrom pathlib import Path\n\n\ndef format_script_for_cell(path):\n \"\"\"Read and format a .py file to be inserted into the ...
python
chosen
[ { "from": "human", "value": "Add function to extract zip file with passowrd\n" }, { "from": "gpt", "value": "import zipfile\n\ndef bf_extract(zfile, password):\n zip = zipfile.ZipFile(zfile)\n try:\n zip.setpassword(password)\n zip.extractall()\n except:\n pass\n ...
python
chosen
[ { "from": "human", "value": "Test script for parameter detemination.\n\nsee https://github.com/pellepl/spiffs/issues/169\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\n\"Test spiffs filesystem with a range of parameters\"\n\nimport spiffs\n\nclass SpiffsInstr(spiffs.SpiffsCharsBack):\n ...
python
chosen
[ { "from": "human", "value": "Add CyRasterize test to script\n\nDuplicates nose test I had added to the cyrasterize package\n" }, { "from": "gpt", "value": "import numpy as np\nfrom cyrasterize import CyRasterizer\nfrom numpy.testing import assert_allclose\n\n\ndef test_basic_random():\n c = C...
python
chosen
[ { "from": "human", "value": "Add jwt library in contrib\n" }, { "from": "gpt", "value": "\"\"\" JSON Web Token implementation\n\nMinimum implementation based on this spec:\nhttp://self-issued.info/docs/draft-jones-json-web-token-01.html\n\"\"\"\nimport base64\nimport hashlib\nimport hmac\n\ntry:...
python
chosen
[ { "from": "human", "value": "Convert search results to stream filter API format." }, { "from": "gpt", "value": "\"\"\"\nConvert GET search (v1.1 or higher) from searchtweets.py to 'stream' format\nas expected by twitter-streamer. This means it will enumerate each item in\nthe incoming JSON obje...
python
chosen
[ { "from": "human", "value": "Add a plane fitting roufit\n" }, { "from": "gpt", "value": "from scipy.optimize import least_squares as lsq\nimport numpy as np\n\ndef myplane(p, x, y, z):\n return(p[0] + p[1] * x + p[2] * y - z)\n\n\ndef plane_fit(x, y, z, robust=False):\n \"\"\"\n\n Fits ...
python
chosen
[ { "from": "human", "value": "Add token test for string functions\n" }, { "from": "gpt", "value": "import kindred\n\ndef test_token_str():\n\tt = kindred.Token(word=\"hat\",lemma=\"hat\",partofspeech=\"NN\",startPos=0,endPos=3)\n\n\tassert str(t) == \"hat\"\n\ndef test_token_repr():\n\tt = kindre...
python
chosen
[ { "from": "human", "value": "Add util for extracting just the tweet text.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n\"\"\"\nGiven a JSON file, return just the text of the tweet.\nExample usage:\nutils/tweet_text.py tweets.jsonl > tweets.txt\n\"\"\"\n\nfrom __future__ import print...
python
chosen
[ { "from": "human", "value": "Add top down design of ANN and Layer\n" }, { "from": "gpt", "value": "\n\nclass ANN:\n\n def __init__(self):\n pass\n\n def train(self):\n pass\n\n def predict(self):\n pass\n\n def update_weights(self):\n pass\n\n\nclass Layer...
python
chosen
[ { "from": "human", "value": "Add missing migration following status choices changes\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ...
python
chosen
[ { "from": "human", "value": "Add example for searching in titles\n" }, { "from": "gpt", "value": "from suds.client import Client\n\nurl = 'http://legislatie.just.ro/apiws/FreeWebService.svc?wsdl'\n\nprint(\"==== create client\")\nclient = Client(url)\nprint(client)\n\nprint(\"==== get token\")\n...
python
chosen
[ { "from": "human", "value": "Add utility to get mac address from host.\n" }, { "from": "gpt", "value": "import logging\nimport re\nimport socket\nfrom subprocess import Popen, PIPE\n\n\nlogger = logging.getLogger(__name__)\n\n\ndef get_mac_address(host):\n \"\"\" Returns MAC address for a hos...
python
chosen
[ { "from": "human", "value": "Add example for adding comments that runs against a real server\n" }, { "from": "gpt", "value": "import bugsy\nbz = bugsy.Bugsy(\"username\", \"password\", \"https://bugzilla-dev.allizom.org/rest\")\nbug = bugsy.Bug()\nbug.summary = \"I love cheese\"\nbug.add_comment...
python
chosen
[ { "from": "human", "value": "Add nagios check for remaining IP addresses\n\nCheck currently assumes a single external network and checks for routers\nwith allocated IP's and floating IP's allocated\n\nChange-Id: I6835de8b036ed5247994ebd904f63147dfef3d67\n" }, { "from": "gpt", "value": "#!/usr/bi...
python
chosen
[ { "from": "human", "value": "Add predication from K-Nearest Neighbors\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom sklearn.neighbors import KNeighborsClassifier\nfrom sklearn.metrics import accuracy_score, classification_report, confusion_matrix\nimport validate_dataset as vali...
python
chosen
[ { "from": "system", "value": "Add test for as_bool bug\n" }, { "from": "human", "value": "from nose2 import config\nfrom nose2.compat import unittest\n\n\nclass TestConfigSession(unittest.TestCase):\n def test_can_create_session(self):\n config.Session()\n\n\nclass TestConfig(unittest....
python
chosen
[ { "from": "human", "value": "Update submission for Day 5\n" }, { "from": "gpt", "value": "#Day 5: Count Vowels\n\n#This program counts the number of vowels in the entered string.\n#For added complexity, it reports a sum of each vowel found in a long text.\n\ninputString = raw_input(\"Enter the s...
python
chosen
[ { "from": "human", "value": "Add test for navigating backwards, after submission - failing\n" }, { "from": "gpt", "value": "from .test_happy_path import TestHappyPath\n\nclass TestbackwardsNavigationAfterSubmission(TestHappyPath):\n\n def test_backwards_navigation(self):\n self.test_ha...
python
chosen
[ { "from": "human", "value": "Split functionality of the Channel API into a separate file and refactored it a bit. Not functional.\n" }, { "from": "gpt", "value": "from django.utils import simplejson\nfrom google.appengine.api import channel, memcache\n\nclass Channel():\n token = None\n addres...
python
chosen
[ { "from": "human", "value": "[Bug] Fix SQLACHEMY_DATABASE_URI for the tests database\n" }, { "from": "gpt", "value": "import os\n\nclass Config(object):\n \"\"\" This class configures the parameters to be used in a production enviroment\"\"\"\n CSRF_ENABLED = True\n SECRET_KEY = os.envi...
python
chosen
[ { "from": "human", "value": "Add script to generate recovery time versus object size data\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n# Copyright (c) 2011 Stanford University\n#\n# Permission to use, copy, modify, and distribute this software for any\n# purpose with or without fee ...
python
chosen
[ { "from": "human", "value": "bot: Add optimized bot. Reduce the number of queries\n\nSigned-off-by: Valentin Ilie <2677a908e9239f6354e2990b8c11cc5ac25eaf8a@gmail.com>\n" }, { "from": "gpt", "value": "import praw\nimport time\n\nr = praw.Reddit('Comment parser example by u/_Daimon_')\nmulti_reddi...
python
chosen
[ { "from": "human", "value": "Print a basic calendar for the start of each month from the epoch\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom __future__ import print_function\n\nimport argparse\nimport datetime\nimport os\nimport sys\n\n\n\nos.environ['TZ'] = 'UTC'\n\n\ndef crpri...
python
chosen
[ { "from": "human", "value": "Add unit tests for vat.py\n" }, { "from": "gpt", "value": "import unittest\nfrom decimal import Decimal as D\nfrom oscar_vat_moss import vat\n\n\nclass AddressTest(unittest.TestCase):\n ADDRESSES = (\n # Submission dictionary # Expected rate\n (...
python
chosen
[ { "from": "human", "value": "Add script to plot learning curve\n" }, { "from": "gpt", "value": "#coding=utf-8\n\nimport sys\nimport argparse\nimport matplotlib.pyplot as plt\n\n\ndef parse_args():\n parser = argparse.ArgumentParser('Parse Log')\n parser.add_argument(\n '--file_path'...
python
chosen
[ { "from": "human", "value": "Add implementation of the behave feature in steps\n" }, { "from": "gpt", "value": "from behave import given, when, then\nfrom appium import webdriver\nimport os\nimport time\n\nfrom selenium.webdriver.support.ui import WebDriverWait\nfrom selenium.webdriver.common.by...
python
chosen
[ { "from": "system", "value": "Fix init of local recognizer\n" }, { "from": "human", "value": "import unittest\n\nimport os\nfrom speech_recognition import WavFile\n\nfrom mycroft.client.speech.listener import RecognizerLoop\n\n__author__ = 'seanfitz'\n\nDATA_DIR = os.path.join(os.path.abspath(os...
python
chosen
[ { "from": "human", "value": "Add an example (with wrong import path).\n" }, { "from": "gpt", "value": "import build.eve_nerd as eve_nerd\n\ndef print_route(v):\n print((\" %s to %s \" % (v.points[0].entity.system.name, v.points[-1].entity.system.name)).center(80, \"-\"))\n t = int(v.cost)\...
python
chosen
[ { "from": "human", "value": "Test ModLoop's custom Job class.\n\n" }, { "from": "gpt", "value": "import unittest\nimport modloop\nimport saliweb.test\nimport saliweb.backend\nimport os\n\nclass JobTests(saliweb.test.TestCase):\n \"\"\"Check custom ModLoop Job class\"\"\"\n\n def test_run_s...
python
chosen
[ { "from": "human", "value": "Implement extra Juniper operations in devices module\n" }, { "from": "gpt", "value": "\"\"\"\nHandler for Cisco CSR device specific information.\n\nNote that for proper import, the classname has to be:\n\n \"<Devicename>DeviceHandler\"\n\n...where <Devicename> is ...
python
chosen