conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add a class to encapsulate these results\n" }, { "from": "gpt", "value": "from github3.models import GitHubCore\nfrom github3.repos import Repository\n\n\nclass CodeSearchResult(GitHubCore):\n def __init__(self, data, session=None):\n super(CodeSearchResult...
python
chosen
[ { "from": "human", "value": "Add some python code to parse a HTTP-date\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport re\n\nmonths = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split()\nhttp_month_pattern = '(%s)' % '|'.join(months)\nhttp_time_pattern = '\\d\\d:\\d\\d:\\...
python
chosen
[ { "from": "human", "value": "Add tests for polymorphic types\n" }, { "from": "gpt", "value": "\"\"\"\nTests of polymorphic behaviours\n\"\"\"\nimport odin\nfrom odin.resources import create_resource_from_dict\n\n\nclass AbstractResource(odin.Resource):\n class Meta:\n abstract = True\n...
python
chosen
[ { "from": "human", "value": "[IMP] Add option file for EPayment administrator\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n##\n##\n## This file is part of CDS Indico.\n## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.\n##\n## CDS Indico is free software; you can redistribute...
python
chosen
[ { "from": "human", "value": "Write an example of the use of the Netgen reader.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# \n# This example shows how to read and write mesh files using the low-level ViennaGrid\n# wrapper for Python (viennagrid.wrapper).\n\nfrom __future__ import pr...
python
chosen
[ { "from": "human", "value": "Change class name to Connection\n\nSigned-off-by: Tran Ly Vu <0555cc0f3d5a46ac8c0e84ddf31443494c66bd55@gmail.com>\n" }, { "from": "gpt", "value": "from sqlalchemy import create_engine\nfrom sqlalchemy_utils import functions\nfrom sqlalchemy.orm import sessionmaker\n\...
python
chosen
[ { "from": "human", "value": "Add a multiple client integration test\n\nIt appears to have found an issue right away:\nClients are not disconnected even if the process spawning them has\nexited.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2.7\nfrom __future__ import absolute_import, div...
python
chosen
[ { "from": "human", "value": "Implement a function called closest_power\n" }, { "from": "gpt", "value": "# Problem 4\n# 10.0 points possible (graded)\n# Implement a function called closest_power that meets the specifications below.\n\n# For example,\n\n# closest_power(3,12) returns 2\n# closest_p...
python
chosen
[ { "from": "human", "value": "Introduce Vyatta VPN agent cmd in monkey patched eventlet module\n\nCommit [1] introduced an entry for reference vpn agent in cmd/eventlet module\nso that they get monkey patched in an uniform way. This commit introduces the\nsame for vyatta vpn agent.\n\n[1] I2d7081dbd4cb532332...
python
chosen
[ { "from": "human", "value": "Add Tests for Changes of Certificate\n" }, { "from": "gpt", "value": "\"\"\"Tests for changes on certificates by Edraak\"\"\"\n\nfrom django.test.utils import override_settings\n\nfrom lms.djangoapps.certificates.api import get_certificate_url\nfrom lms.djangoapps.ce...
python
chosen
[ { "from": "human", "value": "Add test for exception handling problem.\n" }, { "from": "gpt", "value": "from tests.integration import _IntegrationTest\nfrom bioagents import Bioagent, BioagentException\nfrom kqml import KQMLList, KQMLPerformative\n\n\nclass TestErrorHandling(_IntegrationTest):\n ...
python
chosen
[ { "from": "human", "value": "Add file for Code Fights array packing problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Are Equally Strong Problem\n\n\ndef arrayPacking():\n pass\n\n\ndef main():\n tests = [\n [],\n []\n ]\n\n for t in tests:...
python
chosen
[ { "from": "human", "value": "Test the new filtering decorators\n" }, { "from": "gpt", "value": "from unittest import mock, TestCase\n\nfrom .. import filters\nfrom ..message import ReceivedMessage\n\n\nclass TestCommandBlacklist(TestCase):\n def setUp(self):\n self.connection = object(...
python
chosen
[ { "from": "human", "value": "Add the tests for auxiliary.py modules.\n" }, { "from": "gpt", "value": "import numpy as np\n\ndef test_array_reshape_to_dims():\n from research_pyutils import array_reshape_to_dims\n a = np.array([[1, 2], [3, 4], [5, 6], [7, 8]])\n sh = a.shape\n tot = s...
python
chosen
[ { "from": "human", "value": "Load the timeseries data for a particular day/user combination\n\nSo that we can perform analysis on it\n" }, { "from": "gpt", "value": "import json\nimport bson.json_util as bju\nimport emission.core.get_database as edb\nimport sys\n\nif __name__ == '__main__':\n ...
python
chosen
[ { "from": "human", "value": "Put AVS Request Header into separate module\n\nSigned-off-by: Mike Erdahl <e22fb0dee4cdb72a0a7b2cad0d8115432499e3b7@ti.com>\n" }, { "from": "gpt", "value": "avsRequestHeader = {\n \"messageHeader\": {\n \"deviceContext\": [\n {\n ...
python
chosen
[ { "from": "system", "value": "Bugfix: Install the plugin to the app.\n" }, { "from": "human", "value": "#!/usr/bin/python\n\nimport json\n\nimport bottle\nfrom bottle_mongo import MongoPlugin\n\n\napp = bottle.Bottle()\n\napp.config.load_config('settings.ini')\n\nbottle.install(MongoPlugin(\n ...
python
chosen
[ { "from": "human", "value": "Clear outdated cached results in old scenarios\n\nTheir values will be reclalculated and cached in the new format\nby the front-end whenever they are loaded next.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfro...
python
chosen
[ { "from": "human", "value": "Add data migration to backfill YaraResult.has_matches\n" }, { "from": "gpt", "value": "from django.db import migrations\nfrom django.db.models import Case, Value, When\n\n\ndef backfill_has_matches(apps, schema_editor):\n YaraResult = apps.get_model('yara', 'YaraR...
python
chosen
[ { "from": "human", "value": "Read data and split inputs and outputs\n" }, { "from": "gpt", "value": "from os import listdir\nfrom os.path import join\n\ndef file_paths(data_path):\n return [join(data_path, name) for name in listdir(data_path)]\n\ndef training_data(data_path):\n paths = file_pa...
python
chosen
[ { "from": "human", "value": "Add a crasher for the documented issue of calling \"Py_DECREF(self->xxx)\";\n" }, { "from": "gpt", "value": "\"\"\"\nGeneral example for an attack against code like this:\n\n Py_DECREF(obj->attr); obj->attr = ...;\n\nhere in Module/_json.c:scanner_init().\n\nExpla...
python
chosen
[ { "from": "human", "value": "Add a tool for cleaning up the messy C output by the pruner.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n'''\nScript for reflowing C code.\n\nThis script is intended to be run on arbitrarily messy - but valid - C code,\nwhich it then attempts to reforma...
python
chosen
[ { "from": "human", "value": "Add digital micrography svg to the RecreateSKPs bot\n\nBug: skia:10752\nChange-Id: I15d6bb189d44eddbd8bbe2133a2bd705f5313a75\nReviewed-on: https://skia-review.googlesource.com/c/skia/+/319028\nReviewed-by: Chris Dalton <ef7fc3a08ada7d31f16e9a18b5f3c728256e041e@google.com>\nCommi...
python
chosen
[ { "from": "human", "value": "Add a working example of StratifiedKFold cross-validation on MNIST with Keras.\n\nCompute the mean/std of the loss and accuracy metrics over the folds.\n" }, { "from": "gpt", "value": "import numpy as np\nnp.random.seed(1337) # for reproducibility\n\nfrom keras.data...
python
chosen
[ { "from": "human", "value": "Add tests for str_to_bool module.\n" }, { "from": "gpt", "value": "\"\"\"Test class for str_to_bool module.\"\"\"\n\nfrom django.test import SimpleTestCase\nfrom utils.str_to_bool import str_to_bool\n\n\nclass StrToBoolTest(SimpleTestCase):\n \"\"\"Test class for ...
python
chosen
[ { "from": "system", "value": "BUG: Make sure computations do not get executed at import time, so that\nthe tests still run.\n" }, { "from": "human", "value": "\"\"\"\nBenchmark for the LARS algorithm.\n\nWork in progress\n\"\"\"\n\nfrom datetime import datetime\nimport numpy as np\nfrom scikits....
python
chosen
[ { "from": "human", "value": "Add tool for tidying the Icelandic pron_dict CSV file.\n" }, { "from": "gpt", "value": "#! /usr/bin/python2\n# -*- coding: utf-8 -*-\n#\n# Copyright 2015 Google Inc. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you m...
python
chosen
[ { "from": "human", "value": "Add solution to lintcode question 104\n" }, { "from": "gpt", "value": "\"\"\"\nDefinition of ListNode\nclass ListNode(object):\n\n def __init__(self, val, next=None):\n self.val = val\n self.next = next\n\"\"\"\nclass Solution:\n \"\"\"\n @para...
python
chosen
[ { "from": "human", "value": "Support module to help work with checked-out CVS trees.\n" }, { "from": "gpt", "value": "\"\"\"Utility class and function to get information about the CVS repository\nbased on checked-out files.\n\"\"\"\n\nimport os\n\n\ndef get_repository_list(paths):\n d = {}\n ...
python
chosen
[ { "from": "system", "value": "Comment out relational for now; working on workflows, parallelism first\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\r\n# Copyright (c) 2015-2016, Exa Analytics Development Team\r\n# Distributed under the terms of the Apache License 2.0\r\n\"\"\"\r\nRe...
python
chosen
[ { "from": "human", "value": "Add pyunit for deepwater example (huge FC network).\n" }, { "from": "gpt", "value": "from __future__ import print_function\nfrom builtins import range\nimport sys, os\nsys.path.insert(1, os.path.join(\"..\",\"..\",\"..\"))\nimport h2o\nfrom tests import pyunit_utils\...
python
chosen
[ { "from": "human", "value": "Add script for generating sprint dates\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# encoding: utf-8\n\"\"\"\nsprint_dates.py\n\nCreated by Rod Docking on 2017-06-13.\nCopyright (c) 2017 Canada's Michael Smith Genome Sciences Centre.\nAll rights reserved....
python
chosen
[ { "from": "human", "value": "Add tests to excercise the vary callback utility\n" }, { "from": "gpt", "value": "from pyramid_authsanity.util import add_vary_callback\n\nclass TestAddVaryCallback(object):\n def _makeOne(self, *varies):\n return add_vary_callback(varies)\n\n def test_a...
python
chosen
[ { "from": "human", "value": "Add forward function of FCN8s\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport os.path as osp\n\nfrom chainer import cuda\nimport chainer.serializers as S\nfrom chainer import Variable\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy.m...
python
chosen
[ { "from": "human", "value": "Add initial mention processing code\n" }, { "from": "gpt", "value": "import json\nfrom indra.statements import Activation, Agent\n\ndef process_mentions(fname):\n with open(fname, 'r') as fh:\n jd = json.load(fh)\n mentions = jd['mentions']\n\n ev...
python
chosen
[ { "from": "human", "value": "Add utility functions to get a list of favourites\n" }, { "from": "gpt", "value": "\"\"\"\nUtilities to help handling favourites\n\"\"\"\n\nfrom django.http import Http404\n\nfrom django.core.urlresolvers import resolve\n\ndef get_favourites(request):\n \"\"\"\n ...
python
chosen
[ { "from": "human", "value": "Add skeleton for statistics-sanity check tests\n" }, { "from": "gpt", "value": "\nfrom nose.tools import assert_equal, assert_almost_equal, assert_true, \\\n assert_false, assert_raises, assert_is_instance\n\nfrom subprocess import call\n\nfrom ksatools import loa...
python
chosen
[ { "from": "human", "value": "Add a script that prints submodules info in Glockfile compatible format\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport re\nimport subprocess\n\ndef main():\n source = open(\".gitmodules\").read()\n paths = re.findall(r\"path = (.*)\", source)\n\n ...
python
chosen
[ { "from": "human", "value": "Add iterative binary search algorithm implementation\n" }, { "from": "gpt", "value": "def iterative_binary_search(array, item):\n\n low = 0\n high = len(array) - 1\n\n while(low<=high):\n\n mid = (low+high)//2\n\n if (item == array[mid]):\n ...
python
chosen
[ { "from": "human", "value": "Migrate STAR index process type\n" }, { "from": "gpt", "value": "from django.db import migrations\n\nfrom resolwe.flow.migration_ops import ResolweProcessChangeType\n\n\nclass Migration(migrations.Migration):\n \"\"\"\n Change the ``alignment-star-index`` proce...
python
chosen
[ { "from": "human", "value": "Add tests for permission class\n" }, { "from": "gpt", "value": "import pytest\nfrom django.conf import settings\nfrom django.contrib.auth.models import AnonymousUser, Group\n\nfrom grandchallenge.cases.permissions import ImagePermission\nfrom tests.factories import U...
python
chosen
[ { "from": "human", "value": "ZA: Add a data migration to add ParliamentarySession objects\n\nFor Kenya, we've created instances of a `ParliamentarySession` model\nto represent a term of a particular house of parliament. (The name is\na bit misleading - it should probably be `Term` instead.) This was\nintrod...
python
chosen
[ { "from": "human", "value": "Add quick script for formatting a flat json file\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport json\nimport sys\n\n\ndef main():\n if len(sys.argv) < 3:\n print('Usage: {} INFILE OUTFILE'.format(sys.argv[0]))\n sys.exit()\n \n ...
python
chosen
[ { "from": "human", "value": "Add directory for Rule.is_valid tests\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\n:Author Patrik Valkovic\n:Created 23.06.2017 16:39\n:Licence GNUv3\nPart of grammpy\n\n\"\"\"" } ]
python
chosen
[ { "from": "human", "value": "[RM-11742] Add tests for argparse purgedata\n\nSigned-off-by: Travis Rhoden <e5e44d6dbac12e32e01c3bb8b67940d8b42e225b@redhat.com>\n" }, { "from": "gpt", "value": "import pytest\n\nfrom ceph_deploy.cli import get_parser\n\n\nclass TestParserPurgeData(object):\n\n d...
python
chosen
[ { "from": "human", "value": "Implement static grains for the Philips HUE\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n'''\nGenerate baseline proxy minion grains\n'''\n__proxyenabled__ = ['philips_hue']\n\n__virtualname__ = 'hue'\n\n\ndef __virtual__():\n if 'proxy' not in __opts_...
python
chosen
[ { "from": "human", "value": "Add test for the sponsor views\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2.5\n#\n# Copyright 2010 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 Licen...
python
chosen
[ { "from": "human", "value": "Add last metastatus check test\n" }, { "from": "gpt", "value": "# Copyright 2015-2016 Yelp Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the...
python
chosen
[ { "from": "human", "value": "Add python interface around C implementation of levinson.\n\n\n" }, { "from": "gpt", "value": "#! /usr/bin/env python\n\n# Last Change: Sun Sep 14 03:00 PM 2008 J\n\nimport numpy as np\n\nfrom c_lpc import levinson as c_levinson\n\ndef levinson(r, order, axis = -1):\...
python
chosen
[ { "from": "human", "value": "Add offlineevent migration to require dates\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport datetime\n\n\nclass Migration(migrations.Migration):\n\n dependencies ...
python
chosen
[ { "from": "human", "value": "Add a script for easy backups of CATMAID's database\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\n# This is a small helper script to back up a CATMAID\n# database.\n\n# For example, I'm calling this script from cron with the following\n# crontab entry, which ...
python
chosen
[ { "from": "human", "value": "Support setting default modes in channels\n" }, { "from": "gpt", "value": "from twisted.plugin import IPlugin\nfrom txircd.module_interface import IModuleData, ModuleData\nfrom txircd.utils import ModeType\nfrom zope.interface import implements\n\nclass DefaultModes(...
python
chosen
[ { "from": "human", "value": "Add outstanding migrations from wagtail\n\n" }, { "from": "gpt", "value": "# Generated by Django 2.1.8 on 2019-05-07 13:32\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('cms', '0001_initial'),\n ]...
python
chosen
[ { "from": "human", "value": "Add a command to flush memcache\n" }, { "from": "gpt", "value": "import logging\nfrom rc_django.cache_implementation.memcache import MemcachedCache\n\n\nlogger = logging.getLogger(__name__)\n\nclass Command(BaseCommand):\n\n def handle(self, *args, **options):\n ...
python
chosen
[ { "from": "human", "value": "Add a util to generate sentences from a file\n" }, { "from": "gpt", "value": "\"\"\"Read lines from a file, feed them into the markov generator, and then\ngenerate a few lines.\n\nUsage:\n python from_file.py <input_filename> <num_lines_to_generate>\n\"\"\"\nimport ...
python
chosen
[ { "from": "human", "value": "Add test for the lightgbm package\n" }, { "from": "gpt", "value": "import unittest\n\nimport lightgbm as lgb\n\nfrom sklearn.datasets import load_iris\n\nclass TestLightgbm(unittest.TestCase):\n # Based on the \"simple_example\" from their documentation:\n # ht...
python
chosen
[ { "from": "human", "value": "Add script for configuring unity settings\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport os\nimport os.path\nimport subprocess\n\nfrom subprocess import Popen, PIPE\n\ndef _set_value(plist_path, key, value):\n subprocess.call(['plutil', '-replace',...
python
chosen
[ { "from": "human", "value": "Fix atomdetails failure column size\n\nfailure and revert_failure fields in atomdetails is defined as a JSON type,\nbut its data type is 'text' in mysql, which is limited to 64kbytes.\nJSON data type should have the same size as a LONGTEXT.\n\nCloses-Bug: #1959243\nChange-Id: I6...
python
chosen
[ { "from": "system", "value": "Add my own public IP address to INTERNAL_IPS for `obi` testing." }, { "from": "human", "value": "# Debug-toolbar related\n\nINSTALLED_APPS += ('debug_toolbar', )\nMIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware', )\nINTERNAL_IPS = ('127.0.0.1...
python
chosen
[ { "from": "human", "value": "Test ability to download from lbrynet\n\nThis tries to download a small image with a five minute timeout. After this, the bot waits ten minutes and tries again. Any failures get posted to slack." }, { "from": "gpt", "value": "import xmlrpclib\nimport json\nfrom datet...
python
chosen
[ { "from": "human", "value": "Add test stub for agriculture\n" }, { "from": "gpt", "value": "import pandas as pd\nimport pytz\n\nfrom pandas_market_calendars.exchange_calendar_cme_agriculture import CMEAgricultureExchangeCalendar\n\n\ndef test_time_zone():\n assert CMEAgricultureExchangeCalend...
python
chosen
[ { "from": "human", "value": "Add a unit-test for thread_safe_print.py.\n" }, { "from": "gpt", "value": "import thread_safe_print\n\nfrom six.moves import queue\nimport thread_pool\nimport io_expectation as expect\nimport sys\nimport unittest\n\nclass TestThreadSafePrint(unittest.TestCase):\n\n ...
python
chosen
[ { "from": "human", "value": "Add code fight shape area solution\n" }, { "from": "gpt", "value": "def shapeArea(n):\n if n < 1 or n > 10**4:\n raise ValueError\n if n == 1:\n return 1\n else:\n innerArea = shapeArea(n - 1)\n return innerArea + (n - 1) * 4\n\n\...
python
chosen
[ { "from": "human", "value": "[TDF] Add a profiles tutorial in Python\n" }, { "from": "gpt", "value": "## \\file\n## \\ingroup tutorial_tdataframe\n## \\notebook -nodraw\n## This tutorial illustrates how to use TProfiles in combination with the\n## TDataFrame. See the documentation of TProfile an...
python
chosen
[ { "from": "human", "value": "Add 3 test cases for singleNumber problem.\n" }, { "from": "gpt", "value": "import unittest\nfrom singleNumber import Solution\n\nclass TestSingleNumber(unittest.TestCase):\n def setUp(self):\n self.solution = Solution()\n\n def testArrayOfSingleIntRetur...
python
chosen
[ { "from": "human", "value": "ENH: Add a free standing test for freeimage.\n" }, { "from": "gpt", "value": "import os\n\nimport scikits.image as si\nimport scikits.image.io as sio\n\nsio.use_plugin('matplotlib', 'imshow')\nsio.use_plugin('freeimage', 'imread')\n\nimg = sio.imread(os.path.join(si....
python
chosen
[ { "from": "human", "value": "Add a configuration file for Gunicorn.\n" }, { "from": "gpt", "value": "\"\"\"gunicorn WSGI server configuration.\"\"\"\n\n# Based on https://github.com/rdegges/django-skel/blob/master/gunicorn.py.ini.\n\nimport os\nfrom multiprocessing import cpu_count\n\n\ndef max_...
python
chosen
[ { "from": "human", "value": "Add CLI command 'run routes' to list all of the routes\n" }, { "from": "gpt", "value": "import logging\nimport click\n\nfrom catwatch.app import create_app\n\napp = create_app()\n\n\n@click.command()\ndef cli():\n \"\"\" List all of the available routes. \"\"\"\n ...
python
chosen
[ { "from": "human", "value": "Add management command to create homepage user\n" }, { "from": "gpt", "value": "#add homepage user from settings\n#add popular user\nfrom settings import HOMEPAGE_USERNAME\nfrom apps.profile.models import create_profile\nfrom django.contrib.auth.models import User\nf...
python
chosen
[ { "from": "human", "value": "Add crawler for \"Hjalmar\" from bt.no\n" }, { "from": "gpt", "value": "from comics.aggregator.crawler import CrawlerBase, CrawlerImage\nfrom comics.core.comic_data import ComicDataBase\n\n\nclass ComicData(ComicDataBase):\n name = \"Hjalmar (bt.no)\"\n languag...
python
chosen
[ { "from": "human", "value": "Create a management command to output a given template\n" }, { "from": "gpt", "value": "from django.core.management.base import LabelCommand\nfrom django.template.loader import render_to_string\nfrom django.template import RequestContext\nfrom django.http import Http...
python
chosen
[ { "from": "human", "value": "Add an test script for recieving a custom Gait stream\n" }, { "from": "gpt", "value": "\"\"\"Example program to show how to read a marker time series from LSL.\"\"\"\n\nfrom pylsl import StreamInlet, resolve_stream\nimport sys\nimport os\nfrom collections import dequ...
python
chosen
[ { "from": "human", "value": "Test for new function for reading output\n" }, { "from": "gpt", "value": "'''Unit tests for Aronnax'''\n\nfrom contextlib import contextmanager\nimport os.path as p\nimport re\n\nimport numpy as np\nfrom scipy.io import FortranFile\n\nimport aronnax as aro\nfrom aron...
python
chosen
[ { "from": "human", "value": "Change file name. Add timing and verbose flag. Still using letters more times than possible.\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport re\nimport argparse\nimport time\n\n# Let's time the execution for display in -v\nstart_time = time.time()\n\n# S...
python
chosen
[ { "from": "human", "value": "Test to get the invoice.\n" }, { "from": "gpt", "value": "import pytest\nfrom decimal import Decimal\nfrom django.core.urlresolvers import reverse\nfrom rest_framework.test import APIClient\nfrom wightinvoices.invoice import factories\n\n\npytestmark = pytest.mark.dj...
python
chosen
[ { "from": "human", "value": "Add unit test for pk dict serializer\n" }, { "from": "gpt", "value": "from datetime import timedelta\n\nimport pytest\nfrom rest_framework_json_api.serializers import DurationField, IntegerField\n\nfrom timed.serializers import PkDictSerializer\n\n\nclass MyPkDictSer...
python
chosen
[ { "from": "human", "value": "Add settings override for staging environment\n" }, { "from": "gpt", "value": "# To activate these settings as the current local_settings, create a symlink\n# called local_settings.py pointing to this file.\n\nfrom secret_settings import STAGING_DB_PASSWORD\n\nimport...
python
chosen
[ { "from": "human", "value": "Add 100% unit test for IgnorBody protocol.\n" }, { "from": "gpt", "value": "from mock import Mock\nfrom nose.tools import eq_\nfrom twisted.trial import unittest\nfrom twisted.web.client import Response\n\nfrom autopush.protocol import IgnoreBody\n\n\nclass ProtocolT...
python
chosen
[ { "from": "human", "value": "Add basic test for LinearModel\n" }, { "from": "gpt", "value": "# coding: utf8\nfrom __future__ import unicode_literals\n\nimport numpy\n\nfrom ...linear.linear import LinearModel\n\n\ndef test_init():\n model = LinearModel(3)\n keys = numpy.ones((5,), dtype=\"...
python
chosen
[ { "from": "system", "value": "Use find_packages to deal with vendoring\n" }, { "from": "human", "value": "import multiprocessing # noqa # stop tests breaking tox\nfrom setuptools import setup\n\nimport tvrenamr\n\n\nsetup(\n name=tvrenamr.__title__,\n version=tvrenamr.__version__,\n de...
python
chosen
[ { "from": "human", "value": "Add some old models deleted in logos/ migration\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 ...
python
chosen
[ { "from": "human", "value": "Add our awesome core-ns download script\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# core-ns-download\n# Check and download zip archive with zone information but only\n# if required.\n\nimport requests\nimport os, zipfile\nimport argparse\nfrom io import...
python
chosen
[ { "from": "system", "value": "[FIX] Correct author\n(../trunk-generic/ rev 29.1.22)\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n##############################################################################\n#\n# Author: Guewen Baconnier\n# Copyright 2013 Camptocamp SA\n#\n...
python
chosen
[ { "from": "human", "value": "Return 'Hello World' by wsgiref\n" }, { "from": "gpt", "value": "def app(env, start_response):\n start_response('200 OK', [('Content-Type','text/html')])\n return [b\"Hello World\"]\n\nif __name__ == '__main__':\n try:\n from wsgiref.simple_server imp...
python
chosen
[ { "from": "human", "value": "Store limiting magnitude in session, if requested from filter.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\n\nclass StarFilterMiddleware(object):\n \"\"\"\n Stores star filter data in user's session.\n ...
python
chosen
[ { "from": "human", "value": "Add harvester for the London School of Hygene and Tropical Medicine\n\nCloses [#SHARE-123]\n" }, { "from": "gpt", "value": "'''\nHarvester for the LSHTM Research Online for the SHARE project\n\nExample API call: http://researchonline.lshtm.ac.uk/cgi/oai2?verb=ListRec...
python
chosen
[ { "from": "human", "value": "Add example for remote cluster without kube client on server\n" }, { "from": "gpt", "value": "# Copyright 2016 The Kubernetes 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 L...
python
chosen
[ { "from": "human", "value": "Write functional test for seed\n" }, { "from": "gpt", "value": "import unittest\n\nfrom cupy import random\nfrom cupy import testing\n\n\nclass TestResetSeed(unittest.TestCase):\n\n @testing.for_float_dtypes(no_float16=True)\n def test_reset_seed(self, dtype):\...
python
chosen
[ { "from": "human", "value": "Add (failing!) tests for GenericPacketBody\n\nSee #40\n" }, { "from": "gpt", "value": "from io import BytesIO\nfrom nose.tools import assert_equal, assert_raises\n\nfrom encryptit.packets import GenericPacketBody\nfrom encryptit.exceptions import MalformedPacketError...
python
chosen
[ { "from": "human", "value": "Add python script to plot the S curve\n\nRudimentary version to help debugging\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport matplotlib.pyplot as plt\nimport sys\n\nx = []\n\ny = []\n\ninfile = open(sys.argv[1])\n\nfor line...
python
chosen
[ { "from": "human", "value": "Add a set of annotations specific to AutoGraph.\n\nPiperOrigin-RevId: 202972265\n" }, { "from": "gpt", "value": "# Copyright 2017 The TensorFlow Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use t...
python
chosen
[ { "from": "human", "value": "Add initial file for template compilation\n" }, { "from": "gpt", "value": "'''blox/compile.py\n\nCreates an optimized programattically generated template from an html file\n\nCopyright (C) 2015 Timothy Edmund Crosley\n\nPermission is hereby granted, free of charge, ...
python
chosen
[ { "from": "human", "value": "Write the tests for categories.Object and categories.Morphism.\n\nThe tests do not pass at the moment. The goal is to define the desired\nbehaviour of the methods in Morphism by means of tests.\n" }, { "from": "gpt", "value": "from sympy.categories import Object, Mo...
python
chosen
[ { "from": "human", "value": "[PyROOT] Add tutorial for pretty printing feature\n" }, { "from": "gpt", "value": "## \\file\n## \\ingroup tutorial_pyroot\n## \\notebook -nodraw\n## This tutorial illustrates the pretty printing feature of PyROOT, which reveals\n## the content of the object if a str...
python
chosen
[ { "from": "human", "value": "Add a new example, showing the list of leaders\n" }, { "from": "gpt", "value": "import requests\n\nr = requests.get(\"https://stepic.org/api/leaders\")\n\nprint \"Current leaders:\\n\"\n\nfor leader in r.json()[\"leaders\"]:\n user = requests.get(\"https://stepic....
python
chosen
[ { "from": "human", "value": "Make blitting work (the basics anyway)\n" }, { "from": "gpt", "value": "\nclass Color(object):\n def __init__(self, *args):\n if len(args) == 4:\n r, g, b, a = args\n else:\n raise NotImplementedError(\"implement me\")\n ...
python
chosen
[ { "from": "human", "value": "Add basic tests for swf_identity() helper\n" }, { "from": "gpt", "value": "import json\nfrom mock import patch\nimport unittest\n\nfrom sure import expect\n\nfrom simpleflow.swf.helpers import swf_identity\n\n\n@patch(\"socket.gethostname\")\n@patch(\"getpass.getuser...
python
chosen
[ { "from": "human", "value": "Add migration with Reminder model\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.7 on 2016-07-26 18:50\nfrom __future__ import unicode_literals\n\nfrom django.conf import settings\nfrom django.db import migrations, models\nimport ...
python
chosen
[ { "from": "human", "value": "Support loading capabilites YAML into Python classes.\n" }, { "from": "gpt", "value": "import re\nfrom os import path\nimport yaml\n\n\nwith open(path.join(path.dirname(__file__), 'capabilities.yml')) as f:\n PROFILES = yaml.load(f)\n\n\nclass Profile(object):\n\n...
python
chosen
[ { "from": "human", "value": "Add an example to publish data on the Safecast API\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\r\n# -*- coding: utf-8 -*-\r\n\"\"\"\r\nLog measurements to Safecast open-data API (https://api.safecast.org).\r\n\r\nRequire the SafecastPy packages:\r\n htt...
python
chosen