conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add migration for user_assignee Case field\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.models.deletion\nfrom django.conf import settings\n\n\nclass Mig...
python
chosen
[ { "from": "human", "value": "Add missing migration for model WorkDone\n" }, { "from": "gpt", "value": "# Generated by Django 2.2.3 on 2022-03-12 09:54\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('scheduler', '0038_protect_dele...
python
chosen
[ { "from": "human", "value": "Add contrib script to resolve conflicts\n\nAsks the user when two iCalender objects conflict during a sync,\nwhich one to take.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\"\"\"Ask user to resolve a vdirsyncer sync conflict interactively.\n\nNeeds a way...
python
chosen
[ { "from": "human", "value": "Add model with observer pattern\n\nIntended for classes that contain model data, this new module will\ndefine some structural things to implement a model-view-presenter\npattern.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n#This is free and unencumbered...
python
chosen
[ { "from": "human", "value": "Add recursive binary search in python\n" }, { "from": "gpt", "value": "# recursive binary search\n# return, if present, the position of the searched element\n# returns -1 if the element is not present\n\ndef recursive_binary_search(n, e, i, j):\n if i > j:\n ...
python
chosen
[ { "from": "system", "value": "Fix for if token is valid format, but user with that token does not exist\n" }, { "from": "human", "value": "from rest_framework.authentication import BaseAuthentication\n\nfrom models import Token\nfrom seahub.base.accounts import User\n\nclass TokenAuthentication(...
python
chosen
[ { "from": "human", "value": "Add unit-test to test frozen modules.\n" }, { "from": "gpt", "value": "def unittest(data_path, temp_path):\n import ulinalg\n from vec import distance\n m = ulinalg.ones(1, 10)\n d = distance.euclidean((0, 0, 0), (0, 1, 0))\n return (abs(1.0-d) < 0.01)...
python
chosen
[ { "from": "human", "value": "Create a state for get a person by face recognition ID\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# encoding=utf8\n\nimport json\n\nimport requests\nfrom flexbe_core import EventState\nfrom rospy import logerr, loginfo\nfrom sara_msgs.msg import Entity\n...
python
chosen
[ { "from": "human", "value": "Write tests for github utils\n" }, { "from": "gpt", "value": "import unittest\nimport django.test\n\n\nclass GithubUtilsTestCase(django.test.TestCase):\n def test_get_api_repo_branch_url(self):\n self.assertEqual(\"\", \"https://api.github.com/repos/Robrech...
python
chosen
[ { "from": "human", "value": "Add code to generate .dot file from room data\n" }, { "from": "gpt", "value": "import bag_engine\n\n'''Generate .dot graph file. Format\n\ndigraph G {\n 1 [label = \"room name #1\"];\n 2 [label = \"room name #2\"];\n 1 -> 2 [label = \"door going from room 1 to roo...
python
chosen
[ { "from": "human", "value": "Add script to clear analytics tables.\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\nfrom __future__ import print_function\n\nimport sys\n\nfrom argparse import ArgumentParser\nfrom django.db import connection\nfrom django.core.management.ba...
python
chosen
[ { "from": "human", "value": "TST: Add (failing) test for predict dates." }, { "from": "gpt", "value": "\"\"\"\nTests for prediction of state space models\n\nAuthor: Chad Fulton\nLicense: Simplified-BSD\n\"\"\"\n\nfrom __future__ import division, absolute_import #, print_function\n\nimport numpy ...
python
chosen
[ { "from": "human", "value": "Test (de)assignment of roles to users\n" }, { "from": "gpt", "value": "\"\"\"\n:Copyright: 2006-2017 Jochen Kupperschmidt\n:License: Modified BSD, see LICENSE for details.\n\"\"\"\n\nfrom byceps.services.authorization import service\n\nfrom testfixtures.user import c...
python
chosen
[ { "from": "human", "value": "Add fake kernel to predict function differences using GPy\n" }, { "from": "gpt", "value": "from __future__ import division\n\nimport numpy as np\n\n\nclass DiffKernel(object):\n \"\"\"\n A fake kernel that can be used to predict differences two function values....
python
chosen
[ { "from": "human", "value": "Add unittests for date stuff.\n" }, { "from": "gpt", "value": "import locale\nimport unittest\nfrom datetime import datetime\nfrom cfg import parse_cfg_date, _fix_locale, pretty_date\n\n\nclass TestDateHandling(unittest.TestCase):\n def test_date_parsing(self):\n ...
python
chosen
[ { "from": "human", "value": "Add blob metadata migration check" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.14 on 2019-01-05 00:21\nfrom __future__ import unicode_literals\nfrom __future__ import absolute_import\nfrom __future__ import print_function\n\nimpo...
python
chosen
[ { "from": "human", "value": "Add missing migration for switch model\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.3 on 2016-12-01 09:58\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migr...
python
chosen
[ { "from": "human", "value": "Add script to find bad point indices.\n" }, { "from": "gpt", "value": "from laspy.file import File\nimport numpy as np\nimport argparse\n\nparser = argparse.ArgumentParser(description=\"\"\"Accept the path to a .LAS file, \n ...
python
chosen
[ { "from": "system", "value": "Add sudo support for auth tokens\n\nThis fixes #3525\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nimport json\n\nfrom django.http import HttpResponse\nfrom functools import wraps\n\nfrom sentry.models import ApiKey\n\n\ndef is_conside...
python
chosen
[ { "from": "human", "value": "Add script to delete old sessions\n" }, { "from": "gpt", "value": "\"\"\"Deletes old sessions to clear up space.\"\"\"\n\nimport datetime\nimport os\nimport sys\nimport time\n\n\ndef get_files(path):\n \"\"\"Returns the absolute paths of all files under a path.\"\...
python
chosen
[ { "from": "human", "value": "Add a command to generate a CSV file candidates for Google AdWords\n\nThis is for issue #585 - as I understand it, this wouldn't\nbe used directly but is helpful for creating AdWords en masse.\n" }, { "from": "gpt", "value": "import csv\nimport os\nimport sys\nfrom o...
python
chosen
[ { "from": "human", "value": "Add migrations for media files\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.13 on 2018-08-28 16:37\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):...
python
chosen
[ { "from": "human", "value": "BENCH: Add benchmark for small array coercions\n\nNote that since the benchmarks are so fast, the actual results\nare diluted behind one more python function call.\n" }, { "from": "gpt", "value": "from __future__ import absolute_import, division, print_function\n\nfr...
python
chosen
[ { "from": "human", "value": "Add tests for correct column handlers\n" }, { "from": "gpt", "value": "# Copyright (C) 2015 Google Inc., authors, and contributors <see AUTHORS file>\n# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>\n# Created By: miha@reciprocitylabs.c...
python
chosen
[ { "from": "human", "value": "Add some tests for the injector registry\n" }, { "from": "gpt", "value": "import pytest\n\nfrom fanstatic import Library, Resource, NeededResources\nfrom fanstatic.injector import InjectorPlugin\nfrom fanstatic.registry import InjectorRegistry\nfrom fanstatic import ...
python
chosen
[ { "from": "human", "value": "Add unit test for train.py\n" }, { "from": "gpt", "value": "\"\"\"\nA unit test for the train.py script\n\"\"\"\nimport os\n\nimport pylearn2\nfrom pylearn2.scripts.train import train\n\n\ndef test_train_cmd():\n \"\"\"\n Calls the train.py script with a short ...
python
chosen
[ { "from": "human", "value": "Add a bouncing character example\n" }, { "from": "gpt", "value": "import curses\nimport random\n\ndef bounce(stdscr):\n curses.curs_set(0)\n height, width = stdscr.getmaxyx()\n ypos, xpos = random.randrange(0, height - 1), random.randrange(0, width - 1)\n ...
python
chosen
[ { "from": "human", "value": "Add tests for formatter csv\n" }, { "from": "gpt", "value": "import unittest, argparse\nfrom echolalia.formatter.csver import Formatter\n\nclass CsverTestCase(unittest.TestCase):\n\n def setUp(self):\n self.parser = argparse.ArgumentParser()\n self.data = [{'c...
python
chosen
[ { "from": "human", "value": "Add migration for Ads modules\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.6 on 2016-05-20 02:26\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\nfrom dartcms.apps.modules.models import Module, Mod...
python
chosen
[ { "from": "system", "value": "Use from demoapp import tasks instead\n" }, { "from": "human", "value": "# Create your views here.\n\nfrom tasks import add\nfrom django.http import HttpResponse\n\n\ndef foo(request):\n r = add.delay(2, 2)\n return HttpResponse(r.task_id)\n" }, { "fro...
python
chosen
[ { "from": "system", "value": "Fix the dued queryset filter\n" }, { "from": "human", "value": "from datetime import date\n\nfrom django.db import models\nfrom django.db.models import Sum\n\n\nclass TotalQuerySetMixin(object):\n\n def _get_total(self, prop):\n return self.aggregate(sum=S...
python
chosen
[ { "from": "human", "value": "Read weight data from AND scale\n\n- new file: and_scale_rosserial.py\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport serial\n\nimport rospy\nfrom std_msgs.msg import Float32\n\n\nclass ANDScaleRosserial(object):\n\n \"\"\"Read data from AND sca...
python
chosen
[ { "from": "human", "value": "Add script to run all lspr convergence tests\n" }, { "from": "gpt", "value": "import os\nimport time\nimport subprocess\nimport datetime\n\nfrom check_for_meshes import check_mesh\n\n# tests to run\ntests = ['sphere_lspr.py', 'sphere_multiple_lspr.py']\n\n# specify C...
python
chosen
[ { "from": "system", "value": "documentation-crawler: Exclude privacy page from documentation checking\n" }, { "from": "human", "value": "#!/usr/bin/env python\nfrom __future__ import print_function\n\nfrom .common.spiders import BaseDocumentationSpider\n\n\nclass HelpDocumentationSpider(BaseDocu...
python
chosen
[ { "from": "human", "value": "Add usage, version, and command router.\n" }, { "from": "gpt", "value": "#! /usr/bin/env python2\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n# Copyright © 2014 Ciel <imwithye@gmail.com>\n#\n# Distributed under terms of the MIT license.\n\nimport sys\n\n# print ver...
python
chosen
[ { "from": "human", "value": "Add command to assign more abstracts to a specific user\n" }, { "from": "gpt", "value": "from __future__ import unicode_literals\nfrom django.contrib.auth.models import User\nfrom django.core.management.base import BaseCommand\nfrom django.db.models import Count\nfro...
python
chosen
[ { "from": "human", "value": "Add binary tree in python\n" }, { "from": "gpt", "value": "class Node:\n def __init__(self, key):\n self.right = None\n self.left = None\n self.key = key\n\n def addLeftChild(self, node):\n self.left = node\n\n def addRightChild(s...
python
chosen
[ { "from": "human", "value": "Add a migration for updating help_text\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.4 on 2017-09-11 07:47\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migr...
python
chosen
[ { "from": "human", "value": "Add a module to fetch leader information cluster\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nfrom ansible.module_utils.hashivault import hashivault_argspec\nfrom ansible.module_utils.hashivault import hashivault_client\nfrom ansible.module_utils.hashivaul...
python
chosen
[ { "from": "human", "value": "Add py solution for 491. Increasing Subsequences\n\n491. Increasing Subsequences: https://leetcode.com/problems/increasing-subsequences/\n" }, { "from": "gpt", "value": "class Solution(object):\n def findSubsequences(self, nums):\n \"\"\"\n :type num...
python
chosen
[ { "from": "human", "value": "Add a regression test for 5.12 compute API issue\n\nIn I147bf4d95e6d86ff1f967a8ce37260730f21d236 we wrote a breaking RPC change\nfor the 5.12 version as the accel_uuids parameter is not optional.\n\nAdding a regression test to check the issue.\n\nChange-Id: I1f3914e16294c99a625b...
python
chosen
[ { "from": "human", "value": "Remove now() constraint on DateTimeField\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 ('stats...
python
chosen
[ { "from": "human", "value": "Add mananger of files download.\n" }, { "from": "gpt", "value": "import os\nimport commands\nimport time\nimport logging\nimport sys\n\nif len(sys.argv) != 5 or (sys.argv[1:][0] not in ['pt', 'en']):\n print \"ERROR! use :\\n python scripts/data_download/rais/down...
python
chosen
[ { "from": "human", "value": "Add configure appinfo waftool for transforming the appinfo\n" }, { "from": "gpt", "value": "import json\n\nfrom waflib.Configure import conf\n\n\n@conf\ndef configure_appinfo(ctx, transforms):\n with open('appinfo.json', 'r') as appinfo_file:\n appinfo_json...
python
chosen
[ { "from": "human", "value": "Make a data migration that makes all contacts emails lowercase\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11 on 2018-03-05 16:27\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\ndef convert_names(a...
python
chosen
[ { "from": "human", "value": "Add tool to display information about an invocation info file.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# Copyright (c) 2016, Daniel Liew\n# This file is covered by the license in LICENSE-SVCB.txt\n\"\"\"\nRead an invocation info files and display info...
python
chosen
[ { "from": "human", "value": "Add Key, Value, ErrorCode classes.\n" }, { "from": "gpt", "value": "\"\"\"\n util.py\n ~~~~~~~~~~~~\n contains utility functions.\n\"\"\"\n\nimport hashlib\nfrom datetime import datetime\n\n\n# Classes\n\ndef get_timestamp():\n return datetime.utcnow()\n\...
python
chosen
[ { "from": "human", "value": "Add some tests for utils\n" }, { "from": "gpt", "value": "from sideloader.utils import args_str, create_venv_paths\n\n\ndef test_args_str_string_list():\n \"\"\" args_str should join a list of strings. \"\"\"\n assert args_str(['a', 'b']) == 'a b'\n\n\ndef test...
python
chosen
[ { "from": "human", "value": "Add a collector for powerdns statistics\n" }, { "from": "gpt", "value": "import diamond.collector\nimport subprocess\n\nclass PowerDNSCollector(diamond.collector.Collector):\n \"\"\"\n Collects all metrics exported by the powerdns nameserver using the\n pdns...
python
chosen
[ { "from": "human", "value": "Set up console monitor as a tool\n" }, { "from": "gpt", "value": "import argparse\nimport asyncio\nimport anthemav\nimport logging\n\nlog = logging.getLogger(__name__)\n\n@asyncio.coroutine\ndef console(loop):\n parser = argparse.ArgumentParser(description=console...
python
chosen
[ { "from": "human", "value": "Add start of migrator script.\n" }, { "from": "gpt", "value": "# -*- test-case-name: vumi.scripts.tests.test_model_migrator -*-\nimport sys\n\nfrom twisted.python import usage\n\nfrom vumi.utils import load_class_by_string\nfrom vumi.persist.riak_manager import RiakM...
python
chosen
[ { "from": "human", "value": "Add meta test for __init__ file\n" }, { "from": "gpt", "value": "\"\"\"\nTests for this repository.\n\"\"\"\n\nfrom pathlib import Path\n\n\ndef test_init_files() -> None:\n \"\"\"\n ``__init__`` files exist where they should do.\n\n If ``__init__`` files ar...
python
chosen
[ { "from": "human", "value": "Add tests for unicode usage in author truncation\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# encoding: utf-8\n\nimport unittest\n\nfrom ckanext.nhm.lib.helpers import dataset_author_truncate\n\n\nclass AuthorTruncateTest(unittest.TestCase):\n '''\n ...
python
chosen
[ { "from": "human", "value": "Apply different filters for web camera image\n" }, { "from": "gpt", "value": "\"\"\" Apply different filters here \"\"\"\n\nimport cv2 # import OpenCV 3 module\n\ncamera = cv2.VideoCapture(0) # get default camera\nmode = 2 # default mode, apply Canny edge detectio...
python
chosen
[ { "from": "human", "value": "Add API test for policy show\n\nChange-Id: I14aea48e014dda3850430b334afbb1f7b188a171\n" }, { "from": "gpt", "value": "# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compliance with the License. You may obtai...
python
chosen
[ { "from": "system", "value": "Remove responses references in object_documents\n" }, { "from": "human", "value": "# Copyright (C) 2016 Google Inc., authors, and contributors <see AUTHORS file>\n# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>\n# Created By: goodson@g...
python
chosen
[ { "from": "human", "value": "Add migrations that fixes pre 1.10 behavior\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10 on 2017-09-16 01:24\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.M...
python
chosen
[ { "from": "human", "value": "Add test for serializing TimeDelta using ASDF\n" }, { "from": "gpt", "value": "# Licensed under a 3-clause BSD style license - see LICENSE.rst\n# -*- coding: utf-8 -*-\n\nimport pytest\n\nfrom asdf.tests.helpers import assert_roundtrip_tree\n\nfrom astropy.time impor...
python
chosen
[ { "from": "human", "value": "Add script to recreate the tables in the book\n" }, { "from": "gpt", "value": "# Copyright 2013 Pau Haro Negre\n# based on C++ code by Carl Staelin Copyright 2009-2011\n#\n# See the NOTICE file distributed with this work for additional information\n# regarding copyri...
python
chosen
[ { "from": "human", "value": "Add test cases for user management\n" }, { "from": "gpt", "value": "from __future__ import print_function # Use print() instead of print\nfrom app.core.models import User\nfrom app import db\nfrom app.startup.create_users import find_or_create_user\n\ndef test_user_...
python
chosen
[ { "from": "human", "value": "Add G4 and G5 frameworks to database\n" }, { "from": "gpt", "value": "\"\"\"Add older G-Cloud Framewoks\n\nRevision ID: 3e6c454a6fc7\nRevises: 3acf60608a7d\nCreate Date: 2015-04-02 15:31:57.243449\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\nrevision = '3e6...
python
chosen
[ { "from": "human", "value": "Add a list of carriers in the app.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\nfrom django_countries import countries\n\nCARRIERS = {\n 'Telefonica Digital': [{'Mo...
python
chosen
[ { "from": "human", "value": "Fix column lengths to match schema\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"Fix column lengths\n\nRevision ID: 530c22761e27\nRevises: e2b28adfa135\nCreate Date: 2020-04-20 16:19:22.597712\n\n\"\"\"\n\nfrom alembic import op\nimport sqlalchemy a...
python
chosen
[ { "from": "human", "value": "Add initial start - doesn't work\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\nimport os\nimport csv\nimport cv2\nimport numpy as np\nimport sklearn\nimport copy\nimport random\nimport keras\nimport tensorflow as tf\nfrom keras.preprocessing import image\n...
python
chosen
[ { "from": "system", "value": "Use same algo to generate SECRET_KEY as Django\n\nUsing random from standard library is not cryptographically secure." }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom random import choice\n\nfrom django.core.management.base import BaseCommand\n\nfrom d...
python
chosen
[ { "from": "human", "value": "Add an exmple of svm using weighted classes\n" }, { "from": "gpt", "value": "\"\"\"\n================================================\nSVM: Separating hyperplane with weighted classes\n================================================\n\n\"\"\"\n\nimport numpy as np\n...
python
chosen
[ { "from": "human", "value": "Add a test for the Fermi query\n" }, { "from": "gpt", "value": "from astroquery import fermi\n\ndef test_query():\n \n query = fermi.FermiLAT_Query()\n result = query('M31')\n print result\n\nif __name__ == '__main__':\n test_query()" } ]
python
chosen
[ { "from": "human", "value": "Add a migration to patch up old 'UK'-coded conferences\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\ndef fix_conference_country_code(apps, schema_editor):\n Conferen...
python
chosen
[ { "from": "human", "value": "Solve Collectable Cards in python\n" }, { "from": "gpt", "value": "import sys\n\ndef gcd(a, b):\n while b > 0:\n a, b = b, a % b\n\n return a\n\nn = int(input())\n\nfor line in range(n):\n a, b = map(int, input().split())\n print(gcd(a, b))\n" } ...
python
chosen
[ { "from": "human", "value": "Print the length of the lattice\n" }, { "from": "gpt", "value": "import pytac.load_csv\nimport pytac.epics\n\ndef main():\n lattice = pytac.load_csv.load('VMX', pytac.epics.EpicsControlSystem())\n print lattice.get_length()\n\n\nif __name__=='__main__':\n ma...
python
chosen
[ { "from": "human", "value": "Revert \"Removes unused capture audio helper.\"\n\nThis reverts commit 2996177950985a96e4fb4c4179cd43bd6ea53f6c.\n" }, { "from": "gpt", "value": "import pyaudio\n\nFORMAT = pyaudio.paInt16\nCHANNELS = 1\n\ndef capture_buffers(num_buffers, chunk, rate, skip=None):\n ...
python
chosen
[ { "from": "human", "value": "Add test for date comparison.\n" }, { "from": "gpt", "value": "import unittest\n\nfrom datetime import date\n\nfrom qual.calendars import DateWithCalendar\n\nclass TestDateWtihCalendar(unittest.TestCase):\n def setUp(self):\n date_dt = date(2010, 8, 1)\n ...
python
chosen
[ { "from": "human", "value": "test: Add tests for discussions API access\n\nThis checks for expected API access [1];\ndata integrity will be checked later [2].\n\nThis work exposes that the code currently does _not_ grant access to\n_course_ staff, only _global_ staff. This is being addressed next [3].\n\nFi...
python
chosen
[ { "from": "human", "value": "Add option to reduce the ngrams from already prepared .ngrams file to train a model with smaller number of ngrams\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\n\"\"\"Reduces an ngrams file for training nplm to a smaller version of it with less ngrams\"\"...
python
chosen
[ { "from": "human", "value": "Add command to remove archived services from search index\n" }, { "from": "gpt", "value": "from django.core.management.base import BaseCommand\nfrom ...search_indexes import ServiceIndex\nfrom ...models import Service\n\n\nclass Command(BaseCommand):\n def handle(...
python
chosen
[ { "from": "human", "value": "Add migration command to create index on weighted vector field\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import connection, models, migrations\nimport cityhallmonitor.models\n\n\ndef add_docume...
python
chosen
[ { "from": "human", "value": "Edit movie form, title and plot only\n" }, { "from": "gpt", "value": "from flask_wtf import FlaskForm as Form\nfrom wtforms import StringField, BooleanField, TextAreaField\nfrom wtforms.validators import DataRequired, Length\n\nclass EditMovieForm(Form):\n title =...
python
chosen
[ { "from": "human", "value": "Delete Snapshot having Size 8 GiB and a week older\n" }, { "from": "gpt", "value": "import boto \nimport datetime\nimport dateutil\nfrom dateutil import parser\nfrom boto import ec2\n\n\nconnection=ec2.connect_to_region(\"ap-southeast-1\")\n\n\nsnapshotsID=connection...
python
chosen
[ { "from": "human", "value": "Add the ssh authorized key state, still needs absent state\n" }, { "from": "gpt", "value": "'''\nAllows for state management of ssh authorized keys\n'''\n\ndef present(\n name,\n user,\n enc='ssh-rsa',\n comment='',\n options=[],\n ...
python
chosen
[ { "from": "human", "value": "Set etag and updated_at components fields not nullable\n\nToday in production database updated_at and etag are nullable.\n\n Table \"public.components\"\n Column | Type | Modifiers\n------------------------+--------------...
python
chosen
[ { "from": "human", "value": "Add a command for scheduling all scripts.\n" }, { "from": "gpt", "value": "from django.core.management.base import BaseCommand\nfrom education.scheduling import schedule_script\nfrom script.models import Script\n\nclass Command(BaseCommand):\n\n def handle(self, *...
python
chosen
[ { "from": "human", "value": "Add generic factory test runner\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nimport sys\nimport types\nimport importlib\nimport traceback\nimport os\nimport fnmatch\nimport re\nfrom datetime import datetime\n\n\nTOTALS_TESTS_PASSED = 0\nLAST_CALL = Non...
python
chosen
[ { "from": "human", "value": "Add script for sending sense info to azure table storage\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n\"\"\"\n sends temperature, humidity and pressure \n gathered from Sense Hat on Raspberry Pi2 to Azure Table Storage\n only python works with Azure , no...
python
chosen
[ { "from": "human", "value": "Create plain black square picture\n" }, { "from": "gpt", "value": "# Create plain black square picture\nfrom PIL import Image\n\nimg = Image.new('RGB', (225, 225), color='black')\nimg.save('temp/black_square.png')\n" } ]
python
chosen
[ { "from": "human", "value": "Add speed test for hit calling\n" }, { "from": "gpt", "value": "from nose.tools import assert_greater, assert_less\n\nimport collections\nimport time\nimport cProfile\nimport pstats\n\nimport pandas as pd\nimport numpy as np\nfrom numpy.random import normal\n\n\nfrom...
python
chosen
[ { "from": "human", "value": "Add migrations to add readathon teams\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\ndef add_teams(apps, schema_editor):\n Team = apps.get_model('clubs', 'Team')\n ...
python
chosen
[ { "from": "human", "value": "Add a column to Notifications to store the reply_to_text.\nThis is text value of the sender_id, depending on the channel this will be a SMS sender, email reply to address or a letter contact block.\nThis is the first PR in a series to refactor how we send the \"reply_to\" the pr...
python
chosen
[ { "from": "system", "value": "Use translation.override as a context manager instead of a decorator.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom decimal import Decimal as D\n\nfrom django.utils import translation\nfrom django.test import TestCase\nfrom django import template\...
python
chosen
[ { "from": "human", "value": "Add tests for JSON API schema and content type negotiation\n" }, { "from": "gpt", "value": "import pytest\nfrom aiohttp import hdrs\n\nfrom aiohttp_json_api.common import JSONAPI_CONTENT_TYPE\n\n\n@pytest.mark.parametrize(\n 'resource_type',\n ('authors', 'book...
python
chosen
[ { "from": "human", "value": "Add tests for operation arguments clashing with global arguments.\n\nThis makes it possible to expand the global argument list with\nconfidence. It's worth noting this shouldn't be done lightly, as it\nprevents any argument keys being used elsewhere.\n" }, { "from": "gpt...
python
chosen
[ { "from": "human", "value": "ADD Network infrastructure unit tests\n" }, { "from": "gpt", "value": "\n\n\ndef test_create_network(client):\n result = client.post(\"/networks/\", data={\"name\": \"test_network\"})\n assert result.status_code == 200\n assert result.get_json() == {\"msg\":...
python
chosen
[ { "from": "human", "value": "Add example about node label management\n\nShow how to add/remove/change node labels.\n\nSigned-off-by: Flavio Castelli <d1035a58d87d0b7918844ad2fd699273faf2f5d5@suse.com>\n" }, { "from": "gpt", "value": "# Copyright 2016 The Kubernetes Authors.\n#\n# Licensed under ...
python
chosen
[ { "from": "human", "value": "Add function to compute url patterns\n" }, { "from": "gpt", "value": "from django.conf.urls import patterns, url\nfrom django.db.models.loading import get_models\n\nfrom .models import EasyCrudModel\nfrom .views import ListView, CreateView, DetailView, UpdateView, De...
python
chosen
[ { "from": "human", "value": "Reformat all local .json files to be human readable" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport json, os\n\nfor filename in os.listdir('.'):\n if os.path.isfile(filename) and os.path.splitext(filename)[1].lower() == '.json':\n with open(f...
python
chosen
[ { "from": "human", "value": "Add migration for UUID (pre-fill)\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nimport uuid, os\n\ndef gen_uuid(apps, schema_editor):\n WooeyJob = apps.get_model('wooe...
python
chosen
[ { "from": "human", "value": "Add an allocator for Route Distinguishers\n" }, { "from": "gpt", "value": "# vim: tabstop=4 shiftwidth=4 softtabstop=4\n# encoding: utf-8\n\n# Copyright 2014 Orange\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file e...
python
chosen
[ { "from": "human", "value": "Add test for message status escaping\n" }, { "from": "gpt", "value": "from testil import eq\n\nfrom corehq.apps.sms.models import MessagingEvent\nfrom ..standard.message_event_display import get_status_display\n\n\ndef test_get_status_display_escapes_error_message():...
python
chosen
[ { "from": "human", "value": "Add test for finalizer, which broke in 3.8 due to underlying change in Pool._repopulate_pool, which also manifests as a hang in long-running tests that manage to kill all the worker processes.\n" }, { "from": "gpt", "value": "import multiprocessing\nimport os\nfrom p...
python
chosen
[ { "from": "human", "value": "Add very basic lexer test that passes\n" }, { "from": "gpt", "value": "import unittest\nimport sure\nimport lexer\n\nclass TestLexer(unittest.TestCase):\n def _lex_data(self, data):\n lex = lexer.Lexer() \n lex.input(data)\n token_list = list(...
python
chosen
[ { "from": "human", "value": "Test controller message default reply.\n" }, { "from": "gpt", "value": "import mock\nfrom libmproxy import controller\n\n\nclass TestMaster:\n def test_default_handler(self):\n m = controller.Master(None)\n msg = mock.MagicMock()\n m.handle(ms...
python
chosen