conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Remove unused fields from model and drop columns from db\n" }, { "from": "gpt", "value": "\"\"\"Remove unused fields\n\nRevision ID: 1010\nRevises: 1000\nCreate Date: 2017-10-04 15:14:48.532073\n\n\"\"\"\nfrom alembic import op\nimport sqlalchemy as sa\nfrom sqlalche...
python
chosen
[ { "from": "human", "value": "Add initial version of forge download scraper\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport scrapy\nfrom scrapy.contrib.spiders import CrawlSpider, Rule\nfrom scrapy.contrib.linkextractors import LinkExtractor\nfrom scrapy.selector import Selector\...
python
chosen
[ { "from": "human", "value": "Add the usage example of sqlalchemy ORM.\n" }, { "from": "gpt", "value": "# encoding: utf8\nfrom __future__ import print_function\n\nfrom sqlalchemy.orm import sessionmaker\nfrom sqlalchemy import create_engine, Column, Integer, String\nfrom sqlalchemy.ext.declarativ...
python
chosen
[ { "from": "human", "value": "Add script to print time of most recent gobble.\n" }, { "from": "gpt", "value": "from datetime import datetime\nfrom optparse import OptionParser\nfrom urllib2 import urlopen\n\nfrom BeautifulSoup import BeautifulSoup\n\n\nif __name__ == '__main__':\n usage = \"%p...
python
chosen
[ { "from": "human", "value": "Add example, Jeffress net with 180 neurons\n" }, { "from": "gpt", "value": "\"\"\"\nIn this test we create a bigger Jeffress model.\n\n - It consists of 180 output neurons.\n - The axonal delay between the input neurons and the inter-layer neurons are sampled from 0m...
python
chosen
[ { "from": "human", "value": "Add a script to help to refactor source code.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport re,glob,os,sys\n\ndef rename(dir_path, search_pattern):\n for file_path in glob.iglob(os.path.join(dir_path, search_pattern)):\n title, ext = os.p...
python
chosen
[ { "from": "human", "value": "Add py solution for 322. Coin Change\n\n322. Coin Change: https://leetcode.com/problems/coin-change/\n" }, { "from": "gpt", "value": "class Solution(object):\n def coinChange(self, coins, amount):\n \"\"\"\n :type coins: List[int]\n :type amou...
python
chosen
[ { "from": "human", "value": "Add tool-info module for CBMC Path\n\nThis module inherits from CBMC's tool-info module, except that it\nreturns \"CBMC Path\" as the tool name. The --paths switch is specified in\nthe wrapper script `cbmc`, which invokes `cbmc-binary`.\n" }, { "from": "gpt", "value"...
python
chosen
[ { "from": "human", "value": "Add a script that moves files to Azure storage using Copy Blob API\n" }, { "from": "gpt", "value": "import sys\nimport time\nfrom azure.storage import BlobService\nfrom azure import WindowsAzureMissingResourceError\n\nfrom CREDENTIALS import account_name, account_key...
python
chosen
[ { "from": "human", "value": "Add management command to fill data for given ticket nums\n\n`fill_data` management command takes input file which has a list of\nticket numbers and outputs a csv with all details of given ticket numbers\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom ...
python
chosen
[ { "from": "human", "value": "Add test case for Trust Middleware\n\nThis patch adds a test case for Trust Middleware in order to verify its correctness.\n\nChange-Id: I26a65d8ac617e3011dc2be104138e9d177c98c80\nCloses-Bug: #1469947\n" }, { "from": "gpt", "value": "# Licensed under the Apache Licen...
python
chosen
[ { "from": "human", "value": "Test views return response for searched query\n" }, { "from": "gpt", "value": "from django.test import TestCase, Client\nfrom ..models import Category, Book\n\n\n\nclass CompassTest(TestCase):\n @classmethod\n def setUpClass(cls):\n cls.client = Client()...
python
chosen
[ { "from": "human", "value": "Add tests to agent module. Just sunny day case for now\n" }, { "from": "gpt", "value": "import json\n\nimport pytest\nimport zmq\n\nfrom zephyrus.addresses import Participants\nfrom zephyrus.agent import Agent\nfrom zephyrus.message import Message\nfrom zephyrus.test...
python
chosen
[ { "from": "human", "value": "Add test module for tools module\n" }, { "from": "gpt", "value": "from windpowerlib.tools import smallest_difference\nimport collections\n\n\nclass TestTools:\n\n @classmethod\n def setup_class(self):\n self.return_tuple = collections.namedtuple('selecte...
python
chosen
[ { "from": "human", "value": "Add test for reading and writing avro bytes to hdfs\n" }, { "from": "gpt", "value": "import posixpath\nimport subprocess\n\nimport numpy as np\nimport pandas as pd\nimport pandas.util.testing as pdt\n\nimport cyavro\n\nfrom utils import *\n\n\navroschema = \"\"\" {\"...
python
chosen
[ { "from": "human", "value": "Add timing test of password scrambling with pbkdf2, sha-256 and hmac(sha-256)\n" }, { "from": "gpt", "value": "import binascii, hashlib, hmac, os, time\n\ndef scramble_with_kdf(passw, salt, iters):\n return hashlib.pbkdf2_hmac('sha256', passw, salt, iters, 32)\n\n...
python
chosen
[ { "from": "human", "value": "Implement importer as a management command.\n\nHeroku has limitations on the ammount of time that a request\nshould take.\n\nBy using a management command the application can workaround\nthe time it takes to perform the import.\n" }, { "from": "gpt", "value": "import...
python
chosen
[ { "from": "system", "value": "Add auth step to baseprovider for Redis connection pools\n" }, { "from": "human", "value": "import json\nimport tornadoredis.pubsub\nimport tornadoredis\nfrom .base_provider import BaseProvider\nfrom .redis_settings import get_redis_host, get_redis_port, get_redis_d...
python
chosen
[ { "from": "human", "value": "Add an example of event monitoring.\n" }, { "from": "gpt", "value": "import time\n\nfrom examples.common import print_devices\n\nimport blivet\nfrom blivet.events.manager import event_manager\nfrom blivet.util import set_up_logging\n\n\ndef print_changes(event, chang...
python
chosen
[ { "from": "human", "value": "Add test to source folder.\n" }, { "from": "gpt", "value": "import unittest\nimport nose.tools\nfrom sklearn import manifold, datasets\n\nfrom mia.coranking import trustworthiness, continuity, LCMC, coranking_matrix\nfrom mia.utils import *\n\n\nclass CorankingTest(u...
python
chosen
[ { "from": "human", "value": "Load content from a given directory.\n\nCurrently, the directory is hard-coded.\n" }, { "from": "gpt", "value": "from os import listdir, path\nbasedir = '../../website.content/'\nfor app in listdir(basedir):\n module = __import__(app,{},{},fromlist=['load'])\n ...
python
chosen
[ { "from": "human", "value": "Add IcedID downloader ida string decoding\n" }, { "from": "gpt", "value": "def gen_key(k):\r\n\treturn(((k << 0x1d) | (k >> 3)) & 0xffffffff)\r\n\r\n#Unpacked of 32a683ac11d966d73fedf4e249573022891ac902086167e4d20b18be28bd2c1d\r\nfor addr in XrefsTo(0x40233e, flags=0...
python
chosen
[ { "from": "human", "value": "Add tests for indexed access compilation\n" }, { "from": "gpt", "value": "from tests.compiler import compile_local, A_ID, LST_ID, SELF_ID, VAL1_ID\nfrom thinglang.compiler.opcodes import OpcodePushLocal, OpcodePushIndexImmediate, OpcodePushIndex, OpcodePushMember\n\n...
python
chosen
[ { "from": "human", "value": "TST: Add initial test for the optimal_parameters function.\n" }, { "from": "gpt", "value": "import pytest\nimport odl\nimport odl.contrib.fom\nimport odl.contrib.param_opt\nfrom odl.util.testutils import simple_fixture\n\nspace = simple_fixture('space',\n ...
python
chosen
[ { "from": "human", "value": "Add data migration for existing zotero user and node settings models - \"personal\" library is the only library that was previously available, but now group libraries are accessible.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11...
python
chosen
[ { "from": "human", "value": "Add abstracted server and client library\n" }, { "from": "gpt", "value": "# Server and Client Abstraction Library\n\nimport socket\n\nHOST = \"userinterface.local\"\nPORT = 12345\n\nclass Server(object):\n\t\"\"\"A server-serving class\"\"\"\n\ts = socket.socket(sock...
python
chosen
[ { "from": "human", "value": "Add script to sort results. This is useful for sorting by the\n\"total_time\" key.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\nSort a result list by a particular top level key.\nThe key must have a total order (e.g. strings, ints, floats)\n\"\"\"\...
python
chosen
[ { "from": "human", "value": "Add test cases for Pane.\n" }, { "from": "gpt", "value": "import unittest\nimport copy\n\nfrom xie.graphics.shape import Pane\n\nclass PaneTestCase(unittest.TestCase):\n\tdef setUp(self):\n\t\tself.generateTestData()\n\n\tdef tearDown(self):\n\t\tpass\n\n\tdef genera...
python
chosen
[ { "from": "human", "value": "Develop key_proliferate function to create new keys.\n" }, { "from": "gpt", "value": "import numpy as np\nfrom key import Key\n\ndef remove_duplicates(values):\n output = []\n seen = []\n for value in values:\n if not np.any([np.all(value == x) for x ...
python
chosen
[ { "from": "human", "value": "Move get_battery_percentage to module method\nAdd test\n" }, { "from": "gpt", "value": "import ev3.ev3dev\nimport unittest\nfrom util import get_input\n\n\nclass TestI2CS(unittest.TestCase):\n\n def test_battery(self):\n print(ev3.ev3dev.get_battery_percent...
python
chosen
[ { "from": "human", "value": "Add tests for issue types\n" }, { "from": "gpt", "value": "from taiga.requestmaker import RequestMaker, RequestMakerException\nfrom taiga.models.base import InstanceResource, ListResource\nfrom taiga.models.models import IssueType, IssueTypes\nfrom taiga import Taiga...
python
chosen
[ { "from": "human", "value": "Add test that gets all the car params\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\nimport unittest\nfrom selfdrive.car.fingerprints import all_known_cars\nfrom selfdrive.car.car_helpers import interfaces\nfrom selfdrive.car.fingerprints import _FINGERPRIN...
python
chosen
[ { "from": "human", "value": "Add a sample code for still images\n" }, { "from": "gpt", "value": "from FaceAlignment import FaceAlignment\nimport numpy as np\nimport cv2\nimport utils\n\nmodel = FaceAlignment(112, 112, 1, 1, True)\nmodel.loadNetwork(\"../data/DAN-Menpo-tracking.npz\")\n\ncascade ...
python
chosen
[ { "from": "human", "value": "Add a script for profiling the app\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\nfrom werkzeug.contrib.profiler import ProfilerMiddleware\nfrom app import app\n\napp.config['PROFILE'] = True\napp.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30...
python
chosen
[ { "from": "human", "value": "Add fullstack tests of the resource protectables RESTAPI\n\nChange-Id: Ibe660a07311544f82246e82538b565847488040b\nCloses-Bug: #1578888\n" }, { "from": "gpt", "value": "# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\r\n# not use this file ...
python
chosen
[ { "from": "human", "value": "Add boilerplate to access youtube api\n" }, { "from": "gpt", "value": "#! /usr/bin/env python\nimport os\nimport sys\n\nimport httplib2\nfrom apiclient.discovery import build # pylint: disable=import-error\nfrom oauth2client.client import flow_from_clientsecrets\nfr...
python
chosen
[ { "from": "human", "value": "Add integ smoke tests to verify basic service calls\n\nVerify we can make a successful servie call to each supported\nservice (except support).\n\nThe point of these tests to verify nothing's majorly broken. This\nwill make a Describe/List call to a service and verify we get a\...
python
chosen
[ { "from": "human", "value": "Feature: Add migrations for url and referer length\n" }, { "from": "gpt", "value": "# Generated by Django 2.2.14 on 2020-08-25 08:00\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('core', '000...
python
chosen
[ { "from": "human", "value": "Add role to example deploy.\n" }, { "from": "gpt", "value": "from pyinfra.modules import server, pkg\n\n\n# OpenBSD packages?\npkg.packages(\n ['py-pip', 'git'],\n sudo=True,\n op='core_packages' # this and above binds these three operations to run as one\n)...
python
chosen
[ { "from": "human", "value": "Test whether a Cyrillic text correctly appears in a Unicode literal.\n" }, { "from": "gpt", "value": "#! -*- coding: koi8-r -*-\nassert u\"\".encode(\"utf-8\") == '\\xd0\\x9f\\xd0\\xb8\\xd1\\x82\\xd0\\xbe\\xd0\\xbd'\n" } ]
python
chosen
[ { "from": "human", "value": "WIP: Add PipeServer class to manage a pipe server process\n" }, { "from": "gpt", "value": "'''Wraps a process to make it act as a pipe server. Takes care of supressing\nconsole windows under Windows and other housekeeping.\n'''\n\nfrom subprocess import Popen\nfrom s...
python
chosen
[ { "from": "human", "value": "Add python wrapper for WebP image format support\n\nSigned-off-by: Yong Tang <765086fe2e0c1f980161f127fec596800f327f62@outlook.com>\n" }, { "from": "gpt", "value": "# Copyright 2018 The TensorFlow Authors. All Rights Reserved.\n#\n# Licensed under the Apache License,...
python
chosen
[ { "from": "human", "value": "Implement test for the cli\n" }, { "from": "gpt", "value": "import pytest\nfrom click.testing import CliRunner\n\nfrom cli import main\n\n\n@pytest.fixture\ndef runner():\n return CliRunner()\n\n\n@pytest.fixture(params=['fr', 'en', 'tlh'])\ndef lang(request):\n ...
python
chosen
[ { "from": "human", "value": "Add a demo to showcase how to handle local commands with Assistant Library.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# Copyright 2017 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file exce...
python
chosen
[ { "from": "human", "value": "Add script for setting up rethinkdb\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport rethinkdb as r\n\nconn = r.connect()\nr.db_create('muzhack').run(conn)\nr.db('muzhack').table_create('users').run(conn)\nr.db('muzhack').table_create('projects').run(co...
python
chosen
[ { "from": "human", "value": "Add a manage.py command to add read flags up to the current pointer\n\nThis is required because our migration is going to go in two phases.\nWhen we do the database migration (on pushing to master), we update\nall messages at that point. But prod doesn't know about the new\nflag...
python
chosen
[ { "from": "human", "value": "Add a script for building the sbt images\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- encoding: utf-8 -*-\n\"\"\"\nBuild a Docker image for one of our sbt applications.\n\nUsage:\n build_sbt_image.py --project=<PROJECT> [--version=<VERSION>] [--env=...
python
chosen
[ { "from": "human", "value": "Add scratch Reddit comment scraper\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport praw\n\n# Connect to Reddit\n# ----------------------------\n\nuser_agent = \"Quick comment thread scraper by /u/mediaarts\"\nr = praw.Reddit(...
python
chosen
[ { "from": "human", "value": "Add default settings module for API\n" }, { "from": "gpt", "value": "# Eve W-Space\n# Copyright (C) 2013 Andrew Austin and other contributors\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Gene...
python
chosen
[ { "from": "human", "value": "Add migration to update Language extensions\n" }, { "from": "gpt", "value": "from django.db import migrations\n\n\ndef update_language_extensions(apps, schema_editor):\n Language = apps.get_model('judge', 'Language')\n\n extension_mapping = {\n 'ADA': 'a...
python
chosen
[ { "from": "human", "value": "Add tests for class based views\n" }, { "from": "gpt", "value": "import asyncio\nimport pytest\n\nfrom aiohttp import web\nfrom aiohttp.web_urldispatcher import View\nfrom unittest import mock\n\n\ndef test_ctor():\n request = mock.Mock()\n view = View(request)...
python
chosen
[ { "from": "human", "value": "Add the ability to create Tar files\n" }, { "from": "gpt", "value": "import os\nimport sys\nimport tarfile\nimport cStringIO\n\nclass GlideinTar:\n \"\"\"\n potential exception needs to be caught by calling routine\n \"\"\"\n def __init__(self):\n ...
python
chosen
[ { "from": "human", "value": "Create DoFn to group and batch data based on Execution equality\n" }, { "from": "gpt", "value": "# Copyright 2020 Google LLC\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#...
python
chosen
[ { "from": "human", "value": "Add RTM v2 client example too\n" }, { "from": "gpt", "value": "# ------------------\n# Only for running this script here\nimport sys\nfrom os.path import dirname\n\nsys.path.insert(1, f\"{dirname(__file__)}/../../..\")\n# ------------------\n\nimport logging\n\nloggi...
python
chosen
[ { "from": "human", "value": "Add script to annotate allele frequencies.\n" }, { "from": "gpt", "value": "from cyvcf2 import VCF, Writer\n\n\ndef subclone_vaf(gt):\n \"\"\"Calculate subclone allele frequency\"\"\"\n if np.all(gt[:2] == [1, 1]):\n return 1.0\n elif np.all(gt[:2] ==...
python
chosen
[ { "from": "human", "value": "Add script to import activities\n" }, { "from": "gpt", "value": "import pandas as pd\n\nfrom django.core.management.base import BaseCommand\n\nfrom lowfat.models import Fund\n\nclass Command(BaseCommand):\n help = \"Add activities\"\n\n def add_arguments(self, ...
python
chosen
[ { "from": "human", "value": "Create script that helps to create an admin user.\n" }, { "from": "gpt", "value": "from getpass import getpass\nfrom md5 import md5\n\nfrom redis import Redis\n\ndef main():\n database = Redis()\n database.set(\"user:admin:password\", md5(getpass()).hexdigest()...
python
chosen
[ { "from": "human", "value": "Read ampstat -m -i <device> and print out the mac addresses on the powerline network\n" }, { "from": "gpt", "value": "import shlex\nimport sys\nimport re\nfrom subprocess import Popen, PIPE\n\ndef extractMacAddress(ampStatLine):\n macAddr = None\n items = ampSt...
python
chosen
[ { "from": "human", "value": "Add new migrations with db indexes\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.7 on 2017-06-30 09:41\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport echoices.fields\nimport publicat...
python
chosen
[ { "from": "human", "value": "Add test for file based configuration\n" }, { "from": "gpt", "value": "from unittest.mock import call\nfrom unittest.mock import Mock\nfrom unittest.mock import patch\n\nfrom osfclient import cli\n\n\n@patch('osfclient.cli.os.path.exists', return_value=True)\n@patch(...
python
chosen
[ { "from": "human", "value": "Create URL routes to the two server app views\n" }, { "from": "gpt", "value": "''' Servers URL Configuration\n'''\n\nfrom django.conf.urls import url\nfrom . import views\n\nurlpatterns = [\n url(r'^$', views.index, name=\"servers\"),\n url(r'^(?P<slug>.+)/', v...
python
chosen
[ { "from": "human", "value": "Add Q6 for Section II\n" }, { "from": "gpt", "value": "D = {'a': 0, 'b': 1, 'c': 2}\n# Attempting to access a key that does not exist\n# will result in a KeyError Exception\ntry:\n D['d']\nexcept KeyError as err:\n print('KeyError for', err)\n# Assign to a non-...
python
chosen
[ { "from": "human", "value": "Add dummy wrapper for correlation filters\n" }, { "from": "gpt", "value": "import numpy as np\nfrom menpofit.math.correlationfilter import mccf, imccf\n\n\n# TODO: document me!\nclass IncrementalCorrelationFilterThinWrapper(object):\n r\"\"\"\n \"\"\"\n def ...
python
chosen
[ { "from": "human", "value": "Add partial index for non-null external ids\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 ('ms...
python
chosen
[ { "from": "human", "value": "Add basic script without the ability to send the data anywhere\n" }, { "from": "gpt", "value": "from modularodm import Q\n\nfrom website.app import init_app\nfrom website.models import User, Node, Institution\n\n\ndef get_institutions():\n institutions = Instituti...
python
chosen
[ { "from": "human", "value": "Send mass email Django command\n" }, { "from": "gpt", "value": "import sys\nimport json\nimport requests\n\nfrom bs4 import BeautifulSoup\nfrom django.core.management.base import BaseCommand, CommandError\n\nfrom users.models import UserProfile\nfrom lovelace.setting...
python
chosen
[ { "from": "human", "value": "Complete converter for VASP prototype\n\nPrototyping autoconverter for VASP files. Does not yet handle URIs\noutside of data.materialsdatafacility.org.\n" }, { "from": "gpt", "value": "import os\nimport json\nimport sys\nfrom tqdm import tqdm\nfrom parsers.utils impo...
python
chosen
[ { "from": "human", "value": "Add bitbucket identity creation tests\n" }, { "from": "gpt", "value": "from urllib.parse import urlparse\n\nfrom django.urls import reverse\n\nfrom tests.utils import BaseViewTest\n\n\nclass BitbucketIdentityTest(BaseViewTest):\n def test_wrong_provider_raises_404...
python
chosen
[ { "from": "human", "value": "Add a command that imports the 2013 election boundaries\n\nThis uses the generic mapit_import script via\ndjango.core.management.call_command.\n" }, { "from": "gpt", "value": "# This script imports the boundaries for the 2013 Kenyan election into\n# MapIt - it uses t...
python
chosen
[ { "from": "human", "value": "Add basic tests for spans\n" }, { "from": "gpt", "value": "import unittest\nimport datetime\nimport hiro\nfrom sifr.span import Minute, Year, Month, Day, Hour\n\n\nclass SpanTests(unittest.TestCase):\n def test_minute(self):\n with hiro.Timeline().freeze(da...
python
chosen
[ { "from": "human", "value": "[tests] Add unit tests for the store class\n" }, { "from": "gpt", "value": "# pylint: disable=C0103,C0111,W0703\n\nimport unittest\n\nfrom bumblebee.store import Store\n\nclass TestStore(unittest.TestCase):\n def setUp(self):\n self.store = Store()\n ...
python
chosen
[ { "from": "human", "value": "Add Utility Method For Retrieving Error Vertices\n" }, { "from": "gpt", "value": "# Copyright (c) 2012-2013 SHIFT.com\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy of\n# this software and associated documentation files (the \"Soft...
python
chosen
[ { "from": "human", "value": "[vigir_ltl_specification][test] Add unit tests for ts_specification\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport unittest\n\nfrom vigir_ltl_specification.ts_specification import *\n\nclass SpecificationConstructionTests(unittest.TestCase):\n \"...
python
chosen
[ { "from": "human", "value": "Add forgotten migration for relation related_name change\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.2 on 2017-04-18 07:45\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.m...
python
chosen
[ { "from": "human", "value": "Add script to run a series of experiments\n\nThe script does Gibbs sampling for different values of nTopics.\n" }, { "from": "gpt", "value": "import logging\nimport glob\nfrom multiprocessing import Process\n\nfrom CPTCorpus import CPTCorpus\nfrom CPT_Gibbs import Gi...
python
chosen
[ { "from": "human", "value": "Create a searchable index on the request text field.\n" }, { "from": "gpt", "value": "\"\"\"Create request search column and trigger.\n\nRevision ID: 5563ca9e7626\nRevises: 30d3af507801\nCreate Date: 2014-03-06 13:13:52.831868\n\n\"\"\"\n\n# revision identifiers, use...
python
chosen
[ { "from": "human", "value": "Add automated tests for proposal_speaker_manage.\n" }, { "from": "gpt", "value": "from django.contrib.auth import get_user_model\nfrom django.urls import reverse\nfrom django.utils.crypto import get_random_string\n\nfrom symposion.speakers.models import Speaker\n\nfr...
python
chosen
[ { "from": "human", "value": "Debug script to modify jbrowse track config manually.\n" }, { "from": "gpt", "value": "\"\"\"Functions for manipulating JBrowse configs.\n\nNOTE: User responsible for managing backups / not breaking anything.\n\"\"\"\n\nimport json\n\nTRACK_LIST_CONFIG = '/dep_data/t...
python
chosen
[ { "from": "human", "value": "Add script to scrape top 10k players\n" }, { "from": "gpt", "value": "import csv\nimport time\n\nimport requests\nimport lxml.html\n\n\ntop10k = {}\nfor page_index in range(1, 201):\n print('Requesting page {}'.format(page_index))\n url = 'https://osu.ppy.sh/p/...
python
chosen
[ { "from": "human", "value": "Add a migration for model meta options that should have been added earlier\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 ...
python
chosen
[ { "from": "human", "value": "tests/basics: Add test for containment of a subclass of a native type.\n" }, { "from": "gpt", "value": "# test containment operator on subclass of a native type\n\nclass mylist(list):\n pass\n\nclass mydict(dict):\n pass\n\nclass mybytes(bytes):\n pass\n\nl ...
python
chosen
[ { "from": "human", "value": "Add functions for generating missing data in worst case scenario absence of previous data\n" }, { "from": "gpt", "value": "# Copyright 2021 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compl...
python
chosen
[ { "from": "human", "value": "Add first skeleton of selenium-based test\n" }, { "from": "gpt", "value": "import unittest\nimport time\nimport re\n\nfrom selenium import webdriver\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver.support.ui import Select\nfrom selenium.common.e...
python
chosen
[ { "from": "human", "value": "Add example for outwardly-propagating cylindrical flame\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\nOutwardly-propagating cylindrical geometry for a strained lean methane flame.\nThe converged axial velocity profile is plotted. The stagnation poin...
python
chosen
[ { "from": "human", "value": "Add tests for VerifyUserAdmin fieldsets\n" }, { "from": "gpt", "value": "from django.contrib.admin.sites import AdminSite\nfrom django.test import TestCase\n\nfrom ..admin import VerifyUserAdmin\nfrom .factories import UserFactory\nfrom .models import User\n\n\nclass...
python
chosen
[ { "from": "human", "value": "Add tests for authentication helpers.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"Tests for vumi.transports.httprpc.auth.\"\"\"\n\nfrom twisted.web.resource import IResource\nfrom twisted.cred.credentials import UsernamePassword\nfrom twisted.cr...
python
chosen
[ { "from": "human", "value": "Test FileParser returns correct object type" }, { "from": "gpt", "value": "#!/usr/bin/env python\n#encoding:utf-8\n#author:dbr/Ben\n#project:tvnamer\n#repository:http://github.com/dbr/tvnamer\n#license:Creative Commons GNU GPL v2\n# http://creativecommons.org/licens...
python
chosen
[ { "from": "human", "value": "Test to ensure equations with line breaks are parsed correctly\n\n" }, { "from": "gpt", "value": "import os\nimport unittest\nimport tempfile\nfrom io import StringIO\n\nfrom pysd.py_backend.xmile.xmile2py import translate_xmile\n\n\n\nclass TestEquationStringParsing...
python
chosen
[ { "from": "human", "value": "Add framework for wordcloud visualisation\n" }, { "from": "gpt", "value": "import sys\nfrom os.path import isdir, isfile\nfrom corpus import Corpus\nfrom lda_corpus import LDACorpus\n\n\nclass WordCloud(object):\n\n def __init__(self, lda_corpus):\n self.co...
python
chosen
[ { "from": "human", "value": "Solve 328 wtf so easy\n" }, { "from": "gpt", "value": "# Definition for singly-linked list.\n# class ListNode(object):\n# def __init__(self, x):\n# self.val = x\n# self.next = None\n\n\nclass Solution(object):\n def oddEvenList(self, head):\n ...
python
chosen
[ { "from": "human", "value": "Add test (work on progress)\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"\n\n\"\"\"\nfrom __future__ import print_function\n\nimport pytest\nimport numpy as np\nimport itertools\n\nfrom tunacell.simu.main import SimuParams, D...
python
chosen
[ { "from": "human", "value": "Add a test for paramter sharing\n" }, { "from": "gpt", "value": "import unittest\n\nimport chainer\nimport chainer.links as L\nimport numpy as np\n\nimport async\n\n\nclass TestAsync(unittest.TestCase):\n\n def setUp(self):\n pass\n\n def test_shared_lin...
python
chosen
[ { "from": "human", "value": "Fix FK issue in distributions table for alembic migrations\n\nSquashed commit of the following:\n\ncommit b8cf7592d73981236df528f964c20d80f8498cea\nAuthor: Olivier Yiptong <olivier@olivieryiptong.com>\nDate: Wed May 20 17:43:05 2015 -0400\n\n fix FK issue in distributions t...
python
chosen
[ { "from": "human", "value": "Add helper module with humanize_time function\n" }, { "from": "gpt", "value": "\"\"\"Generally useful helper functions, possibly for use in plugins.\"\"\"\n\ndef humanize_time(delta):\n \"\"\"\n Converts a timespan provided as a datetime object into a human-rea...
python
chosen
[ { "from": "human", "value": "Remove empty orphans while migrating\n" }, { "from": "gpt", "value": "from django.db import migrations, models\nfrom django.db.models import Count\n\n\ndef forwards(apps, schema_editor):\n Course = apps.get_model(\"catalog\", \"Course\")\n empty_orphans = Cours...
python
chosen
[ { "from": "human", "value": "Create sample for new functions\n" }, { "from": "gpt", "value": "from thrift.transport import TSocket\nfrom thrift.transport import TTransport\nfrom thrift.protocol import TBinaryProtocol\nfrom modeldb.thrift.modeldb import ModelDBService\n\n# create connection to th...
python
chosen
[ { "from": "human", "value": "[AC-9046] Remove migrations that arenot relevant to the work\n" }, { "from": "gpt", "value": "# Generated by Django 2.2.10 on 2021-11-05 12:29\n\nfrom django.db import migrations\n\n\ndef update_url_to_community(apps, schema_editor):\n people_url = \"/people\"\n me...
python
chosen
[ { "from": "human", "value": "Add command to find datasource mismatches\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\nfrom __future__ import print_function\n\nimport csv\nfrom datetime import datetime\n\nfrom django.core.management.base import BaseCommand\n\nfrom corehq...
python
chosen
[ { "from": "human", "value": "Add py solution for 412. Fizz Buzz\n\n412. Fizz Buzz: https://leetcode.com/problems/fizz-buzz/\n" }, { "from": "gpt", "value": "import sys\nclass Solution(object):\n def fizzBuzz(self, n):\n \"\"\"\n :type n: int\n :rtype: List[str]\n \...
python
chosen
[ { "from": "human", "value": "Add script to ensure the correct tile size of a file\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n#\n# This is a helper script to ensure an image has the correct tile size.\n# It uses pgmagick[1] to read and (if needed) correct the image. To use\n# it on a num...
python
chosen