conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add exercise six of chapter two" }, { "from": "gpt", "value": "'''\nCreated on 22 Aug 2017\n\nPalindrome: implement a function to check if a linked list is a palindrome\n\nAssumptions: each node of the list contains a single letter.\n\n1) Invert-copy list, gives also...
python
chosen
[ { "from": "human", "value": "Add test for object module\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport unittest\n\nclass TestObject(unittest.TestCase):\n \n def test_object(self):\n import mlbgame\n data = {\n 'string': 'string',\n 'int...
python
chosen
[ { "from": "human", "value": "Add script to add a simulation to the yaml file.\n" }, { "from": "gpt", "value": "import os\nimport yaml\nimport yt\nimport sys\n\ndata_dir = '/mnt/data/renaissance'\n\nrsl_page_root = os.environ.get(\n 'RSL_PAGE_ROOT', '/home/britton/rensimlab.github.io')\n\nsimy...
python
chosen
[ { "from": "human", "value": "Add script to run Randoop for evaluation over corpus\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport os,sys,common\nimport fetch\nimport time\n\ndef main():\n if not os.path.exists(common.CORPUS_DIR) or not os.path.exists(common.LIBS_DIR):\n print \"...
python
chosen
[ { "from": "human", "value": "Add function to convert a date from bash to iso format\n" }, { "from": "gpt", "value": "import datetime as dt\n\ndef dateParser(timestring):\n \"\"\"\n Parse a datetime string from ls -l and return a standard isotime\n \n ls -l returns dates i...
python
chosen
[ { "from": "human", "value": "Add a script to extract chromagram features from the audio samples.\n" }, { "from": "gpt", "value": "\"\"\"\nExtracts chromagram features from audio data.\n\nInput: a 2D tensor with set of audio samples\nOutput: A tensor with a chromagram for each sample\n\"\"\"\n\ni...
python
chosen
[ { "from": "human", "value": "Add py solution for 423. Reconstruct Original Digits from English\n\n423. Reconstruct Original Digits from English: https://leetcode.com/problems/reconstruct-original-digits-from-english/\n\n Approach 1:\n Use matrix operation to find the answer\n P.S. the number in the...
python
chosen
[ { "from": "human", "value": "Add Redis GET $LOOKUP plugin\n renamed\n" }, { "from": "gpt", "value": "# (c) 2012, Jan-Piet Mens <jpmens(at)gmail.com>\n#\n# This file is part of Ansible\n#\n# Ansible is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General ...
python
chosen
[ { "from": "human", "value": "Add python program to print numbers sideways.\n" }, { "from": "gpt", "value": "#! /usr/bin/env python\n\n# vim: set ai sw=4:\n\nimport sys\nimport os\nimport math\nimport argparse\n\ndef l10(num):\n return int(math.log10(num))\n\ndef ps(num):\n for d in xrange(...
python
chosen
[ { "from": "human", "value": "Add migration for show_to_others default value.\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 work for Exercise 26: The Midterm.\n" }, { "from": "gpt", "value": "def break_words(stuff):\n \"\"\"This function will break up words for us.\"\"\"\n words = stuff.split(' ')\n return words\n\ndef sort_words(words):\n \"\"\"Sorts the w...
python
chosen
[ { "from": "human", "value": "Add missing custom plugins python code.\n" }, { "from": "gpt", "value": "# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-\n\nimport snapcraft\nfrom snapcraft.plugins import autotools\n\n\nclass KodiAutotoolsPlugin(autotools.AutotoolsPlugin):\n\n def build(...
python
chosen
[ { "from": "human", "value": "Add some avahi testing utilities\n" }, { "from": "gpt", "value": "\"\"\"\nInfrastructure for testing avahi\n\"\"\"\n\nimport servicetest\nfrom servicetest import Event\nimport dbus\nimport dbus.glib\nimport avahi\n\ndef get_host_name():\n bus = dbus.SystemBus()\n s...
python
chosen
[ { "from": "human", "value": "Use Postgres long ID on user model\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nCREATE_USER_SCHEMA = \"\"\"\n CREATE FUNCTION users_user_id_generat...
python
chosen
[ { "from": "human", "value": ":memo: Add second tutorial src for python-types\n" }, { "from": "gpt", "value": "def get_full_name(first_name: str, last_name: str):\n full_name = first_name.title() + \" \" + last_name.title()\n return full_name\n\n\nprint(get_full_name(\"john\", \"doe\"))\n" ...
python
chosen
[ { "from": "human", "value": "Write dummy data out to yaml\n" }, { "from": "gpt", "value": "\"\"\"Generate dummy data to use in smif as scenario data for testing\n\"\"\"\nfrom pprint import pprint\n\nfrom energy_demand.read_write.data_loader import dummy_data_generation\nimport yaml\n\n\n\ndef ma...
python
chosen
[ { "from": "system", "value": "Include AdminProfileInline so that it is not lost if the user enables Mezzanine accounts.\n\n--HG--\nbranch : admin_site_permissions\n" }, { "from": "human", "value": "\nfrom django.contrib import admin\nfrom django.contrib.auth.admin import UserAdmin\nfrom django.c...
python
chosen
[ { "from": "human", "value": "Add quick dumb disassembler for upcoming debugger\n" }, { "from": "gpt", "value": "import MOS6502\nimport instructions\n\ndef disasm(memory):\n index = 0\n lines = []\n\n while index < len(memory):\n currInst = instructions.instructions[memory[index]]...
python
chosen
[ { "from": "human", "value": "Set `blank` attrib to True on Email.post field\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.6 on 2016-05-21 10:46\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.models.dele...
python
chosen
[ { "from": "human", "value": "Add script to fix Emmanuelle's messed up drafts.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport rethinkdb as r\nimport optparse\n\nif __name__ == \"__main__\":\n parser = optparse.OptionParser()\n parser.add_option(\"-P\", \"--port\", dest=\"p...
python
chosen
[ { "from": "human", "value": "Add test for resource cache function\n" }, { "from": "gpt", "value": "from tests.BaseTestWithDB import BaseTestWithDB\nfrom django.test import tag\nfrom django.http import QueryDict\nfrom django.urls import reverse\nfrom resources.views.views import resource_pdf_cach...
python
chosen
[ { "from": "human", "value": "Test profile schedulers gettering from buffer api\n" }, { "from": "gpt", "value": "import json\n\nfrom nose.tools import eq_, raises\nfrom mock import MagicMock, patch\n\nfrom buffer.models.profile import Profile, PATHS\n\nmocked_response = {\n 'name': 'me',\n 'ser...
python
chosen
[ { "from": "human", "value": "[12.0][MIG][WIP] Move models from l10n_br_sale_service to l10n_br_sale.\n" }, { "from": "gpt", "value": "# Copyright (C) 2014 Renato Lima - Akretion\n# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html\n\nfrom openerp import _, api, models\nfrom openerp...
python
chosen
[ { "from": "human", "value": "Add this missing OAuth2 migration.\n\nSigned-off-by: Laura <07c342be6e560e7f43842e2e21b774e61d85f047@veriny.tf>\n" }, { "from": "gpt", "value": "\"\"\"OAuth2 start\n\nRevision ID: 0a2ba8dce059\nRevises: 9f50538504b1\nCreate Date: 2017-02-11 13:48:45.564677\n\n\"\"\"\...
python
chosen
[ { "from": "human", "value": "Add the code for Etsy\n\nThey've decided not to allow foauth.org to actually access their API, but there's no reason to hide the code in case someone can learn from it.\n" }, { "from": "gpt", "value": "from werkzeug.urls import url_decode\n\nimport foauth.providers\n...
python
chosen
[ { "from": "human", "value": "[AIRFLOW-1727] Add unit tests for DataProcHook\n\nCloses #2697 from cjqian/1727\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the...
python
chosen
[ { "from": "human", "value": "Integrate salary picker with PayFast\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.7 on 2016-07-17 21:19\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.utils.timezone\n\n\nclas...
python
chosen
[ { "from": "human", "value": "Add tests for heat template apis\n\nThis patch covers 4 template api calls -\n1. Get stack template\n2. List template versions\n3. List resource types\n4. Show resource schema\n\nChange-Id: I85b16b8893264d1313e2e184011dd0ddfdaa4349\n" }, { "from": "gpt", "value": "# ...
python
chosen
[ { "from": "human", "value": "Add py solution for 560. Subarray Sum Equals K\n\n560. Subarray Sum Equals K: https://leetcode.com/problems/subarray-sum-equals-k/\n" }, { "from": "gpt", "value": "from collections import Counter\nclass Solution(object):\n def subarraySum(self, nums, k):\n ...
python
chosen
[ { "from": "human", "value": "Add back in command line test for nbgrader formgrade\n" }, { "from": "gpt", "value": "from .. import run_nbgrader\nfrom .base import BaseTestApp\n\n\nclass TestNbGraderFormgrade(BaseTestApp):\n\n def test_help(self):\n \"\"\"Does the help display without er...
python
chosen
[ { "from": "human", "value": "Add test script to put 10 random jobs with proper param range\n" }, { "from": "gpt", "value": "import httplib\nimport json\nimport random\n\nfrom dispatch import Job\n\nN_JOBS = 10\n\nurl = 'jcluster12.appspot.com'\n# url = 'localhost:8080'\n\njobs = []\nfor i in ran...
python
chosen
[ { "from": "human", "value": "Add an example test for Multi-Factor Auth Login\n" }, { "from": "gpt", "value": "from seleniumbase import BaseCase\r\n\r\n\r\nclass TestMFALogin(BaseCase):\r\n def test_mfa_login(self):\r\n self.open(\"https://seleniumbase.io/realworld/login\")\r\n s...
python
chosen
[ { "from": "human", "value": "Add test cases for newton methods\n" }, { "from": "gpt", "value": "import numpy as np\nfrom numpy.testing import assert_almost_equal, assert_allclose\nfrom numba import njit\n\nfrom quantecon.optimize import newton, newton_secant\n\n@njit\ndef func(x):\n \"\"\"\n ...
python
chosen
[ { "from": "human", "value": "Add script to queue emails from file\n" }, { "from": "gpt", "value": "from gratipay import wireup\n\nenv = wireup.env()\ndb = wireup.db(env)\n\nparticipants = []\n\nwith open('./sql/emails.txt') as f:\n emails = [line.rstrip() for line in f]\n participants = db...
python
chosen
[ { "from": "human", "value": "Add sqlite sdb smoke tests\n\nRight now sqlite sdb.get will fail for most purposes because the text\nvalues are not decoded. This exhibits that behavior (except of course\nfor the lone byte-string parameter).\n" }, { "from": "gpt", "value": "import tempfile\n\nimport...
python
chosen
[ { "from": "human", "value": "Add migration for magnetic, resume, and rfid\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nimport robocrm.fields\nimport robocrm.models\nimport django.core.validators\nim...
python
chosen
[ { "from": "human", "value": "Set up our first exmample challenge\n\nWorks with py.test or nose, py.test is prettier\n" }, { "from": "gpt", "value": "# This first example lifted from http://pytest.org/latest/getting-started.html\ndef func(x):\n return x + 1\n\ndef test_answer():\n assert fu...
python
chosen
[ { "from": "human", "value": "Solve Code Fights memory pills problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Mirror Bits (Core) Problem\n\nfrom itertools import dropwhile\n\n\ndef memoryPills(pills):\n gen = dropwhile(lambda p: len(p) % 2 == 1, pills + [\"\"] * ...
python
chosen
[ { "from": "human", "value": "Add missing migration file for latitude and longitude\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.7 on 2016-07-27 22:51\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nclass Migration(migration...
python
chosen
[ { "from": "human", "value": "Add missing migration for last commit\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.5 on 2017-02-08 21:18\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migra...
python
chosen
[ { "from": "human", "value": "Add test for labels/inputs in newrequest form\n" }, { "from": "gpt", "value": "import testing as T\n\nclass NewRequestTemplateTest(T.TemplateTestCase):\n\n authenticated = True\n newrequest_page = 'modules/newrequest.html'\n\n form_elements = ['title', 'tags...
python
chosen
[ { "from": "human", "value": "Add another balltree benchmark, this time with plot interface.\n\ngit-svn-id: a2d1b0e147e530765aaf3e1662d4a98e2f63c719@598 22fbfee3-77ab-4535-9bad-27d1bd3bc7d8\n" }, { "from": "gpt", "value": "\nfrom scikits.learn.BallTree import BallTree, knn_brute\nimport numpy as ...
python
chosen
[ { "from": "human", "value": "Add a metadata file to the tower home directory that lists the version\nof Tower\n" }, { "from": "gpt", "value": "# Copyright (c) 2014 Ansible, Inc.\n# All Rights Reserved\n\nfrom django.core.management.base import BaseCommand\n\nfrom awx import __version__ as tower_...
python
chosen
[ { "from": "human", "value": "Add another test for switching the language of the app\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\ndef test_switch_language(app):\n test_label = app.carousel.slides[1].children[1]\n\n english_text = (\n \"This app uses Kivy, a Python Fr...
python
chosen
[ { "from": "human", "value": "Add basic test for irc formatter\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"\n Pygments HTML formatter tests\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.\n :license: BSD, see L...
python
chosen
[ { "from": "human", "value": "Add helper for JS tests\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom __future__ import print_function, unicode_literals\n\nimport os\nimport sys\nimport uuid\n\nfrom datetime import timedelta\n\nfrom aspen.utils import utcnow\n\nimport gratipay\n\nf...
python
chosen
[ { "from": "human", "value": "Add script to convert JSON from Google to GPX\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"Convert JSON from Google Takeout to GPX\"\"\"\nimport json\nimport os\nimport time\nimport argparse\n\ndef write_gpx(filep, locations):\n \"\"\"Write locati...
python
chosen
[ { "from": "human", "value": "[trunk] Add Python utility function to strip trailing whitespace from .cs files. On Windows, this will also convert line endings, because of the way that Python will always write a text file with platform line endings\n" }, { "from": "gpt", "value": "#!/usr/bin/pytho...
python
chosen
[ { "from": "human", "value": "ADD profiling script for replay buffer (OCL benchmarking)\n" }, { "from": "gpt", "value": "from unittest.mock import Mock\n\nimport time\nfrom os.path import expanduser\n\nfrom tqdm import tqdm\n\nfrom avalanche.benchmarks import fixed_size_experience_split, SplitMNI...
python
chosen
[ { "from": "human", "value": "Add crawler for 'Girls With Slingshots'\n" }, { "from": "gpt", "value": "from comics.crawler.base import BaseComicCrawler\nfrom comics.crawler.meta import BaseComicMeta\n\nclass ComicMeta(BaseComicMeta):\n name = 'Girls With Slingshots'\n language = 'en'\n u...
python
chosen
[ { "from": "human", "value": "Add script to convert binary UUIDs in fixture data to strings.\n" }, { "from": "gpt", "value": "import sys\nimport re\nimport json\nimport base64\nfrom binascii import a2b_base64,hexlify\n\n# cd sli/acceptance-tests\n# find . -name *.json | xargs -I file python ~/wge...
python
chosen
[ { "from": "system", "value": "Fix typo in GStreamer test\n" }, { "from": "human", "value": "import unittest\n\nfrom mopidy.backends.gstreamer import GStreamerBackend\n\nfrom tests.backends import (BasePlaybackControllerTest,\n BaseCurrentPlaylistControllerTest)\n\nclas...
python
chosen
[ { "from": "human", "value": "Concatenate historical matches csv files\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nimport glob, os, sys\nimport pandas as pd\nd = '/home/tvl/dev/scrapy-soccerway/soccerway/data/h/'\nframes = []\nos.chdir(d)\nprint('Read csv files:')\nfor f in glob.g...
python
chosen
[ { "from": "human", "value": "auth: Add an LDAP backend using the authentication data table\n" }, { "from": "gpt", "value": "from django_auth_ldap.backend import LDAPBackend\nfrom utils.auth.backends import get_or_create_user\n\n\nclass MultiLDAPBackend(LDAPBackend):\n def get_or_create_user(s...
python
chosen
[ { "from": "human", "value": "Add command to list available tasks and help\n" }, { "from": "gpt", "value": "\"\"\"\nList all available tasks\n\"\"\"\n\nfrom management.commands import BaseCommand\nfrom utils.registry import registry, find_in_registry\nfrom utils.models import get_task_name\n\nimp...
python
chosen
[ { "from": "human", "value": "Add file for tracking Vive data\n\nThe data includes position, pitch, yaw and roll for the HMD and controllers\n" }, { "from": "gpt", "value": "import sys\nimport time\nimport openvr\n\nopenvr.init(openvr.VRApplication_Scene)\n\nposes_t = openvr.TrackedDevicePose_t *...
python
chosen
[ { "from": "human", "value": "Add binary tree inorder traversal\n" }, { "from": "gpt", "value": "class Solution:\n def inorderTraversal(self, root):\n \"\"\"\n :type root: TreeNode\n :rtype: List[int]\n \"\"\"\n if root is None:\n return []\n ...
python
chosen
[ { "from": "human", "value": "TST: Add unit tests for Beta node\n" }, { "from": "gpt", "value": "######################################################################\n# Copyright (C) 2014 Jaakko Luttinen\n#\n# This file is licensed under Version 3.0 of the GNU General Public\n# License. See LIC...
python
chosen
[ { "from": "human", "value": "Add template tag to check edit permission on votes and voting systems\n" }, { "from": "gpt", "value": "import datetime\nfrom django import template\n\nregister = template.Library()\n\n@register.filter()\ndef can_edit(vote_or_vs, user):\n return vote_or_vs.canEdit(...
python
chosen
[ { "from": "human", "value": "Add script to clear all user-defined rate limits within an account\n" }, { "from": "gpt", "value": "\"\"\"\nClears all user-defined rate limits for all projects in an account\n\nUse with an account access token that has scopes 'read' and 'write'\n\nUsage:\n\npython c...
python
chosen
[ { "from": "human", "value": "Add an Enum type that is in Python as well as SQL\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import unicode_literals\n\nimport re\n\nfrom sqlalchemy.types import SchemaType, TypeDecorator\...
python
chosen
[ { "from": "system", "value": "Fix Greasy Fork deploy script.\n" }, { "from": "human", "value": "from mechanize import Browser\n\n\ndef exec_(config, summary, script):\n USERNAME = config['USERNAME']\n PASSWORD = config['PASSWORD']\n SCRIPT_ID = config['SCRIPT_ID']\n\n LOGIN_URL = 'ht...
python
chosen
[ { "from": "human", "value": "Metrics: Add a script to print out histogram ownership.\n\nNOTRY=true\n\nReview URL: https://codereview.chromium.org/456943002\n\ngit-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@288484 0039d316-1c4b-4281-b951-d872f2087c98\n" }, { "from": "gpt", "value": "#!/usr/...
python
chosen
[ { "from": "human", "value": "Remove drops from raid logs that are not owned by the user submitting the logs\n" }, { "from": "gpt", "value": "# Generated by Django 2.1.11 on 2019-09-10 03:04\n\nfrom django.db import migrations\nfrom django.db.models import F\n\n\ndef delete_unowned_raid_drops(app...
python
chosen
[ { "from": "human", "value": "Add test for conditional compilation\n" }, { "from": "gpt", "value": "from tests.compiler import compile_snippet, STATIC_START, internal_call\nfrom thinglang.compiler.opcodes import OpcodePushStatic, OpcodeJumpConditional, OpcodeJump\n\nPREFIX = [\n OpcodePushStat...
python
chosen
[ { "from": "human", "value": "Add tests for genetics problems\n\nPiperOrigin-RevId: 162569505\n" }, { "from": "gpt", "value": "# Copyright 2017 The Tensor2Tensor Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with...
python
chosen
[ { "from": "human", "value": "Add tests for parse_date and parse_datetime\n" }, { "from": "gpt", "value": "from datetime import date, datetime\n\nimport pytz\nfrom django.test import TestCase\n\nfrom django_afip import parsers\n\n\nclass ParseDatetimeTestCase(TestCase):\n def test_parse_null(s...
python
chosen
[ { "from": "human", "value": "Increase limit on data log model for larger urls\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.6 on 2017-04-13 13:53\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migra...
python
chosen
[ { "from": "human", "value": "Implement one of Smartvel's tests using APIReaderSmartvel.\n" }, { "from": "gpt", "value": "from threading import Thread\n\nfrom rx import Observable\n\nfrom APIReaderSmartvel import APIReaderSmartvel\n\nevents = Observable.from_(APIReaderSmartvel().get_iterable())\n...
python
chosen
[ { "from": "human", "value": "Implement code to determine if a ransom note can\nbe constructed from a magazine\n\nhttps://www.hackerrank.com/challenges/ctci-ransom-note\n" }, { "from": "gpt", "value": "# https://www.hackerrank.com/challenges/ctci-ransom-note\n# Python 3\n\ndef create_word_diction...
python
chosen
[ { "from": "human", "value": "Add explorer phat motor functions mock\n" }, { "from": "gpt", "value": "# pylint: disable=W1201,C0103\n\nimport logging\n\nclass _Motor:\n def __init__(self, name=None):\n self.name = name\n if not name:\n self.name = 'all'\n se...
python
chosen
[ { "from": "human", "value": "Add test for restart restore behavior\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport pytest\n\nfrom ethereum import slogging\n\nfrom raiden.api.python import RaidenAPI\n\nlog = slogging.get_logger(__name__)\n\n\n@pytest.mark.parametrize('number_of_n...
python
chosen
[ { "from": "human", "value": "Add a script for setting pokemon.order\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2\n\nimport sqlite3\n\nconn = sqlite3.connect(\"pokedex/data/pokedex.sqlite\")\n\ncur = conn.execute(\n \"\"\"select p.id, p.name, pf.name\n from pokemon p\n join ev...
python
chosen
[ { "from": "human", "value": "Create gene families based on eggNOG 5 annotation\n" }, { "from": "gpt", "value": "import os, re, sys\n\nfams = {}\n\n#read in the output of EggNOG mapper, then make protein families out of sequences which map to the same set of COG/KOG functional categories\ninh = o...
python
chosen
[ { "from": "human", "value": "Add test for QDesktopServices split.\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\n\nimport pytest\nfrom qtpy.QtCore import QStandardPaths\nfrom qtpy.QtGui import QDesktopServices\n\n\"\"\"Test QDesktopServices split in Qt5.\"\"\"\n\ndef te...
python
chosen
[ { "from": "human", "value": "Add DN's tool for XDS.INP parsing\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport json\nimport sys\n\nclass INP2DICT(object):\n def __init__(self, xdsinp, xdsdict):\n self.xdsinp = xdsinp\n self.xdsdict = xdsdict\n self.run()\...
python
chosen
[ { "from": "human", "value": "[WIP] Update sqlite fts to fts5\n\nI think this will provide better stemming, e.g. searching for \"star\" will match\n\"Stars and Strips Forever\", which it currently doesn't.\n" }, { "from": "gpt", "value": "# Generated by Django 2.1.11 on 2019-08-07 21:43\n\nfrom d...
python
chosen
[ { "from": "human", "value": "Add migration to go with 331ce5f\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('projects', '0...
python
chosen
[ { "from": "system", "value": "Fix template name in view\n" }, { "from": "human", "value": "from django.template import RequestContext\nfrom django.template.response import TemplateResponse\n\nfrom pyconcz_2016.speakers.models import Speaker, Slot\n\n\ndef speakers_list(request, type):\n speak...
python
chosen
[ { "from": "human", "value": "Add ticketed features test file\n" }, { "from": "gpt", "value": "\"\"\"A growing set of tests designed to ensure when isort implements a feature described in a ticket\nit fully works as defined in the associated ticket.\n\"\"\"\nimport isort\n\n\ndef test_semicolon_i...
python
chosen
[ { "from": "human", "value": "Call of Duty: Black Ops plugin\n" }, { "from": "gpt", "value": "import os\nfrom lib.base_plugin import BasePlugin\nfrom lib.paths import SteamGamesPath\n\n\nclass CoDBOPlugin(BasePlugin):\n Name = \"Call of Duty: Black Ops\"\n support_os = [\"Windows\"]\n\n ...
python
chosen
[ { "from": "human", "value": "Add print view controller hierarchy command.\n" }, { "from": "gpt", "value": "\"\"\"Prints the current view controller hierarchy.\n\nUsage: pvc\n\"\"\"\ndef print_view_controller_hierarchy(debugger, command, result, internal_dict):\n debugger.HandleCommand('po [[[UI...
python
chosen
[ { "from": "human", "value": "limits: Add the queries limits test.\n\nUse a C++ payload to check if the queries limitation\nworks.\n\nFixes #180.\n\nSigned-off-by: Benoît Canet <ecd1f14f7c1c6dc7a40210bdcc3810e0107ecbc8@scylladb.com>\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom a...
python
chosen
[ { "from": "human", "value": "Add script to bring up bluetooth network\n\n<rant>\nI haven't managed to find any good documentation on this (or pretty much\nanything bluez 4.x related) at all (the blueman source implements this,\nbut it's not the easiest source in the world to follow) - this was\ncreated afte...
python
chosen
[ { "from": "human", "value": "Add in-class code for simulating motion\n" }, { "from": "gpt", "value": "### Import our stuff\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\n\n### Set up initial values\nposition = 555 # feet\nvelocity = 0 # feet/second\nacceleration = -32...
python
chosen
[ { "from": "human", "value": "Write tests for `dvc version`\n" }, { "from": "gpt", "value": "from dvc.main import main\nfrom dvc.command.version import CmdVersion\nfrom dvc.cli import parse_args\n\nfrom tests.basic_env import TestDvc\n\n\nclass TestVersion(TestDvc):\n def test_run(self):\n ...
python
chosen
[ { "from": "human", "value": "Add script to find tests that open a lot of windows\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\n# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this\n# file, You can obt...
python
chosen
[ { "from": "human", "value": "Add tests for org_home view.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2.5\n#\n# Copyright 2011 the Melange authors.\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...
python
chosen
[ { "from": "human", "value": "Add stub for CustomGeneratorMetaV2 class (which will be a fresh and decluttered implementation of CustomGeneratorMeta)\n" }, { "from": "gpt", "value": "import logging\n\nlogger = logging.getLogger('tohu')\n\n\nclass CustomGeneratorMetaV2(type):\n\n def __new__(met...
python
chosen
[ { "from": "human", "value": "Add exploration of linear interp filter freq response\n" }, { "from": "gpt", "value": "import matplotlib.pyplot as plt\nimport numpy as np\n\nfrom scipy import signal\n\nf, (ax1, ax2) = plt.subplots(2, sharex=True)\n\nfor i in np.linspace(0.0, 1.0, 11):\n # A line...
python
chosen
[ { "from": "human", "value": "Create Euler method, test it on a spring\n" }, { "from": "gpt", "value": "\"\"\"\nIntegration methods\n\"\"\"\n\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\ndef euler(at, vt, xt, dt):\n vtpdt = vt + at * dt\n xtpdt = xt + vt * dt\n return vtpdt,...
python
chosen
[ { "from": "human", "value": "Remove Duplicates from Sorted Array II\n" }, { "from": "gpt", "value": "class Solution:\n # @param A a list of integers\n # @return an integer\n def removeDuplicates(self, A):\n if not A:\n return 0\n if len(A) == 1:\n ret...
python
chosen
[ { "from": "human", "value": "Add migration that fixes status for activities that are not approved\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.15 on 2019-11-08 12:17\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\ndef corr...
python
chosen
[ { "from": "human", "value": "Convert to FITS and K\n" }, { "from": "gpt", "value": "\n# Convert the CASA cube into FITS\n\nimport os\nfrom spectral_cube import SpectralCube\nimport astropy.units as u\n\nfrom casa_tools import myexportfits\n\npath = \"/srv/astro/erickoch/M33/\"\n\nmyexportfits(im...
python
chosen
[ { "from": "human", "value": "Add migrations to compile duplicate tags\n" }, { "from": "gpt", "value": "\"\"\"\n\"\"\"\nimport os\nimport json\nfrom sqlalchemy import (create_engine, Table, Column, String, Integer,\n Float, Text, MetaData, select, ForeignKey,\n ...
python
chosen
[ { "from": "human", "value": "Add function to run a local or remote query\n" }, { "from": "gpt", "value": "# gaia_tools.query: some helper functions for querying the Gaia database\nimport numpy\nfrom astropy.table import Table\nfrom astroquery.gaia import Gaia\nimport psycopg2\n\ndef query(sql_qu...
python
chosen
[ { "from": "human", "value": "Add missing migration file for `per_page` field.\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 a simple synonym-map class.\n" }, { "from": "gpt", "value": "import os\nfrom threading import RLock\n\nfrom weavelib.exceptions import ObjectAlreadyExists\n\n\nclass SynonymRegistry(object):\n def __init__(self):\n self.synonym_lock = RLock()\n s...
python
chosen
[ { "from": "system", "value": "Refactor remote_repo, to return None\nif there is no remote.\n" }, { "from": "human", "value": "from collections import namedtuple\n\nRemote = namedtuple('Remote', ('name', 'url'))\nCommitInfo = namedtuple(\"CommitInfo\", ('commit', 'origin', 'remote_repo'))\n\n\ncl...
python
chosen
[ { "from": "human", "value": "Add a simple example of computing exploitability of uniform policy.\n" }, { "from": "gpt", "value": "# Copyright 2019 DeepMind Technologies Ltd. All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file ...
python
chosen