conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add tests for Forgot Password feature\n\n* Add tests to ensure the \"Forgot Password\" feature works appropriately.\n" }, { "from": "gpt", "value": "import requests\nfrom wqflask import user_manager\nfrom utility.elasticsearch_tools import get_user_by_unique_column\n...
python
chosen
[ { "from": "human", "value": "Create zinnia_wymeditor module with his metadatas\n" }, { "from": "gpt", "value": "\"\"\"WYMeditor for Django-blog-zinnia\"\"\"\n__version__ = '1.0'\n__license__ = 'BSD License'\n\n__author__ = 'Fantomas42'\n__email__ = 'fantomas42@gmail.com'\n\n__url__ = 'https://gi...
python
chosen
[ { "from": "human", "value": "Add a management command that runs a given script taking an input file and an output file as args.\n" }, { "from": "gpt", "value": "\"\"\"\nRun a script that takes a file input/output.\n\"\"\"\n\nimport os\nimport sys\nfrom optparse import make_option\n\nfrom django....
python
chosen
[ { "from": "human", "value": "Add tests for top destinations\n" }, { "from": "gpt", "value": "import unittest\nimport datetime\nimport json\nimport sys\n\nsys.path.append('..')\nimport sabre_dev_studio\nimport sabre_dev_studio.sabre_exceptions as sabre_exceptions\n\n'''\nrequires config.json in t...
python
chosen
[ { "from": "human", "value": "Add script to translate labels\n" }, { "from": "gpt", "value": "\"\"\"Find known body parts in sentences with predicted label 'Lichaamsdeel'.\n\nExtended body parts are saved to new text files.\n\nUsage: python classify_body_parts.py <json file with body part mapping...
python
chosen
[ { "from": "human", "value": "Add simple tests for asttools.compiler module\n\nThese tests don't do anything except ensure that exceptions aren't\nthrown during compiling.\n\nSigned-off-by: Kevin Conway <3473c1f185ca03eadc40ad288d84425b54fd7d57@gmail.com>\n" }, { "from": "gpt", "value": "\"\"\"Te...
python
chosen
[ { "from": "human", "value": "tests/thread: Add test for concurrent mutating of user instance.\n" }, { "from": "gpt", "value": "# test concurrent mutating access to a shared user instance\n#\n# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd\n\nimport _thread\n\n# the shar...
python
chosen
[ { "from": "human", "value": "[util] Check the zscale and cubedims for a given database\n" }, { "from": "gpt", "value": "# Copyright 2014 Open Connectome Project (http://openconnecto.me)\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in...
python
chosen
[ { "from": "human", "value": "Add prediction script for cross multinomial\n" }, { "from": "gpt", "value": "import sys\nimport numpy as np\nimport numpy.random as npr\nfrom calculate_phist import read_counts\nfrom calculate_phist import normalize_haplotypes\nfrom scipy.special import gammaln\nimpo...
python
chosen
[ { "from": "human", "value": "Add a test for transformer_vae\n\nPiperOrigin-RevId: 190462534\n" }, { "from": "gpt", "value": "# coding=utf-8\n# Copyright 2018 The Tensor2Tensor Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in ...
python
chosen
[ { "from": "human", "value": "Add a base class for certain types of tests\n\nThis is so training data can be reused across classes.\nIn fact nonsensefilter's test have been using this for quite some time\nbut this was not committed. Oops!\n" }, { "from": "gpt", "value": "from itertools import izi...
python
chosen
[ { "from": "human", "value": "Add basic \"does this even run\" test for trainers.\n" }, { "from": "gpt", "value": "import theanets\n\nimport util\n\n\nclass TestTrainer(util.MNIST):\n def setUp(self):\n super(TestTrainer, self).setUp()\n self.exp = theanets.Experiment(\n ...
python
chosen
[ { "from": "human", "value": "Add unit test for show_examples.py\n" }, { "from": "gpt", "value": "\"\"\"\nTests for the show_examples.py script\n\"\"\"\nimport os\n\nfrom pylearn2.testing.skip import skip_if_no_matplotlib, skip_if_no_data\nfrom pylearn2.scripts.show_examples import show_examples\...
python
chosen
[ { "from": "human", "value": "Add details to integration test as a template\n" }, { "from": "gpt", "value": "# Copyright 2020 Google LLC. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License...
python
chosen
[ { "from": "human", "value": "Add code to compile proto\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\"\"\"Script to create the protofile\n\n It compiles the proto definition and\n then creates the proto file from the text specified\n in query1.txt, query2.txt etc\n\"\"\"\nimport ...
python
chosen
[ { "from": "human", "value": "[AC-8354] Merge remote-tracking branch 'origin' into AC-8354\n" }, { "from": "gpt", "value": "# Generated by Django 2.2.10 on 2021-01-22 12:13\nfrom django.db import migrations\n\n# gender identity\nGENDER_MALE = \"Male\"\nGENDER_FEMALE = \"Female\"\nGENDER_PREFER_TO...
python
chosen
[ { "from": "human", "value": "Add solution to Rabbits and Recurrence Relations\n" }, { "from": "gpt", "value": "\"\"\"\nGiven: Positive integers n>=40 and k<=5.\n\nReturn: The total number of rabbit pairs that will be present after n months if we begin with 1 pair and in\neach generation, every p...
python
chosen
[ { "from": "human", "value": "Add test file use in the docs.\n" }, { "from": "gpt", "value": "def test_parse_bool(wish):\n parse_bool = wish\n assert not parse_bool('false')\n assert not parse_bool('FALSE')\n assert not parse_bool('0')\n assert parse_bool('true')\n assert parse_...
python
chosen
[ { "from": "human", "value": "Add check db status step\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport logging\nfrom ...util.base import BaseStep\n\nLOG = logging.getLogger(__name__)\n\n\nclass CheckDatabaseStatus(BaseStep):\n\n def __unicode__(self):\n return \"Checkin...
python
chosen
[ { "from": "human", "value": "Move data type field from sensor model to station-sensor link model to make sensors more 'global'.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.6 on 2017-06-19 20:53\nfrom __future__ import unicode_literals\n\nfrom django.db im...
python
chosen
[ { "from": "human", "value": "Convert wiki XML to Tiddlywiki import format\n" }, { "from": "gpt", "value": " \ndef WIKIXML2TW(inputfilename, outputfilename):\n \"Convert Wikimedia XML dump to TiddlyWiki import file\"\n inputfile = open(inputfilename, \"r\")\n xmlinput = unicode(inputfile...
python
chosen
[ { "from": "human", "value": "Add solution to exercise 2-10.\n" }, { "from": "gpt", "value": "# 2-10 Adding Comments\n\n# Below follows the code from exercise 2-3 and 2-4 again but now with (more) comments\n\n# 2-3 Personal Message\nname = \"Henrik\" # variable for storing user name\n\n# concate...
python
chosen
[ { "from": "human", "value": "Add a script for process trained models using bbox means and stds.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport init\nimport caffe\nimport numpy as np\nimport argparse\nimport cPickle\n\nif __name__ == '__main__':\n parser = argparse.ArgumentPars...
python
chosen
[ { "from": "human", "value": "Add management command to get domains from doc ids\n" }, { "from": "gpt", "value": "import os\nfrom optparse import make_option\n\nfrom django.core.management.base import BaseCommand\n\nfrom couchdbkit.exceptions import ResourceNotFound\nfrom dimagi.utils.couch.datab...
python
chosen
[ { "from": "human", "value": "Change 'is_active' column names to 'archived'\n\nChanged the name of the `is_active` columns to `archived` in these\ntables:\n* `service_email_reply_to`\n* `service_sms_senders`\n* `service_letter_contacts`\n\nThese columns were not being used yet, but because we describe Templa...
python
chosen
[ { "from": "human", "value": "Add a basic error propagation example.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport numpy\nimport random\n\nrandom.seed(54864218)\n\ndef f(a, b):\n coefficients = numpy.array([[2*a + b, a + b], [a - b, a - 2*b]])\n inv_coefficients = numpy....
python
chosen
[ { "from": "human", "value": "Add an API example for NaCl\n" }, { "from": "gpt", "value": "import numpy as np\nfrom phonopy import Phonopy\nfrom phonopy.interface.vasp import read_vasp\nfrom phonopy.file_IO import parse_FORCE_SETS, parse_BORN\nimport matplotlib.pyplot as plt\n\nunitcell = read_va...
python
chosen
[ { "from": "human", "value": "Add an example from kuza55.\n" }, { "from": "gpt", "value": "# Multi-GPU Keras training.\n# Captured from https://github.com/kuza55/keras-extras and\n# https://medium.com/@kuza55/transparent-multi-gpu-training-on-tensorflow-with-keras-8b0016fd9012.\n\nfrom keras.laye...
python
chosen
[ { "from": "human", "value": "Add 02title/ plugin that gets own info from global fields\n" }, { "from": "gpt", "value": "\"\"\"\nGets plugin info from global fields\n\nLow-level Far Manager API is here:\n\n * https://api.farmanager.com/en/exported_functions/getglobalinfow.html\n \n\"\"\"\n\n__ti...
python
chosen
[ { "from": "human", "value": "Add test utilities for proposed changes - feel free to add other cases\n" }, { "from": "gpt", "value": "# -*- encoding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nimport unittest\n\nfrom oabot.main import *\n\nclass TemplateEditTests(unittest.TestCase):\n\...
python
chosen
[ { "from": "human", "value": "Add test for data migration version\n\nDetect when the CURRENT_VERSION constant used by the database\nmigration code is out of sync with the version number of the\ncurrent release.\n\nChange-Id: I9e8b5ee98c6c111aaf065cb310906d6442f5f79a\n" }, { "from": "gpt", "value"...
python
chosen
[ { "from": "human", "value": "Xtheme: Add migration to add shop information\n\nAdd shop information in ThemeSettings and SavedViewConfig\n\nThe process will clone every settings for each existent shop\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.11 on 2016-1...
python
chosen
[ { "from": "human", "value": "Add test coverage of existing os-console-auth-tokens policies\n\nCurrent tests do not have good test coverage of existing policies.\nEither tests for policies do not exist or if they exist then they\ndo not cover the actual negative and positive testing.\n\nFor Example, if any p...
python
chosen
[ { "from": "human", "value": "Update genome reference model migration\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.7 on 2016-06-16 17:24\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.models.deletion\n\...
python
chosen
[ { "from": "human", "value": "Add test for correct handling of grammar in terminal\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\"\"\"\nfrom unittest import TestCase\nfrom grammpy import Term...
python
chosen
[ { "from": "human", "value": "Add unique constraint on Threat Actor title\n" }, { "from": "gpt", "value": "\n\"\"\"Add unique constraint to threat actors\n\nRevision ID: 1347acbb4dc2\nRevises: 5ada65dc60b3\nCreate Date: 2014-11-21 23:18:26.689048\n\n\"\"\"\n\n# revision identifiers, used by Alemb...
python
chosen
[ { "from": "human", "value": "Add db migration to add manager_id to base_results\n" }, { "from": "gpt", "value": "\"\"\"Add queue_manager id to Base_results\n\nRevision ID: 4bb79efa9855\nRevises: 26cfd7b0439e\nCreate Date: 2019-07-26 15:31:14.811337\n\n\"\"\"\nfrom alembic import op\nimport sqlal...
python
chosen
[ { "from": "human", "value": "Test that inheritance of setUp/tearDown/setUpClass/tearDownClass works\nas expected\n" }, { "from": "gpt", "value": "from dtest import *\nfrom dtest.util import *\n\n\n# Define setUpClass/tearDownClass/setUp/tearDown for inheritance\nclass TestInheritanceBase(DTestCa...
python
chosen
[ { "from": "human", "value": "Remove constraint on Session model\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.6 on 2017-03-11 16:37\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n ...
python
chosen
[ { "from": "human", "value": "Add py solution for 215. Kth Largest Element in an Array\n\n215. Kth Largest Element in an Array: https://leetcode.com/problems/kth-largest-element-in-an-array/\n" }, { "from": "gpt", "value": "import random\nclass Solution(object):\n def findKthLargest(self, nums...
python
chosen
[ { "from": "human", "value": "Add Python script for powerpoint file diffs\n" }, { "from": "gpt", "value": "from io import StringIO\nimport sys\n\nimport pandas as pd\n\n\nfor sheet_name in pd.ExcelFile(sys.argv[1]).sheet_names:\n output = StringIO()\n print('Sheet: %s' % sheet_name)\n pd...
python
chosen
[ { "from": "human", "value": "Add conf file for Ideasbox in Sénégal\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"Ideaxbox for FAP in Sénégal\"\"\"\nfrom .idb import * # noqa\nfrom django.utils.translation import ugettext_lazy as _\n\nIDEASCUBE_NAME = u\"Futur au Présent\"\nIDE...
python
chosen
[ { "from": "human", "value": "Add migration that adds permission for spam, metrics and prereg\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9 on 2017-01-30 22:11\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nclass Migration(m...
python
chosen
[ { "from": "human", "value": "Add anonymzed real case example\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2\n# coding: utf-8\n\n# this example is used in production, it is depending on private libraries\n# to communicate with internal APIs, but it can help you build your own\n# producti...
python
chosen
[ { "from": "human", "value": "Add helper functions for analyzing data\n" }, { "from": "gpt", "value": "import os\nimport pickle\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom datetime import datetime\n\n\ndef load_data(data_path):\n '''Return dictionary `data` from string `data_p...
python
chosen
[ { "from": "human", "value": "Solve Code Fights is digit problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Is Digit Problem\n\nimport re\n\n\ndef isDigit(symbol):\n return bool(re.search(r'\\d', symbol))\n\n\ndef main():\n tests = [\n [\"0\", True],\n ...
python
chosen
[ { "from": "human", "value": "Add migrations for previous commit\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.3 on 2016-07-16 20:22\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.utils.timezone\n\n\nclass ...
python
chosen
[ { "from": "human", "value": "Create properties files from votes.\n" }, { "from": "gpt", "value": "import enki\n\ne = enki.Enki('a', 'http://localhost:5001', 'translationsvoting')\n\ne.get_all()\n\nlines = []\nfor t in e.tasks:\n msgstr = e.task_runs_df[t.id]['msgstr'].describe()['top']\n v...
python
chosen
[ { "from": "human", "value": "Add unit test for StopWatch.\n" }, { "from": "gpt", "value": "# -*- encoding: utf-8 -*-\n\"\"\"Test 'stopwath' module.\n\"\"\"\n\n\nimport unittest\nimport time\nfrom datetime import timedelta\n\nfrom hunittest.stopwatch import StopWatch\n\n\nclass TestStopWatch(unit...
python
chosen
[ { "from": "human", "value": "migrations: Add Message indexes on (recipient_id, subject).\n\nOur previous set of indexes for the Message table did not contain\nanything to optimize queries for all the messages in a topic in an\norganization where the same topic name might appear in 10,000s of\nmessages in ma...
python
chosen
[ { "from": "human", "value": "Add tests for maintenance functions\n" }, { "from": "gpt", "value": "import unittest\nfrom datetime import timedelta\n\nimport pytest\nfrom django.utils import timezone\n\nfrom website import maintenance\nfrom osf.models import MaintenanceState\n\n\npytestmark = pyte...
python
chosen
[ { "from": "human", "value": "Add test for service grammars: hit rate against example queries\n" }, { "from": "gpt", "value": "import re\nfrom collections import defaultdict\n\nfrom pal.grammars.grammars import make_chomsky_normal_form\nfrom pal.grammars.grammars import parse_grammar_from_file\nf...
python
chosen
[ { "from": "human", "value": "Add a test that the runner script works in environments without pip\n\nThis ensures that the runner script can be used in environments where\npip is not installed.\n" }, { "from": "gpt", "value": "import os\nfrom pathlib import Path\n\nfrom pip import __version__\nfr...
python
chosen
[ { "from": "human", "value": "Add a test for sending unicode data in http headers\n" }, { "from": "gpt", "value": "#! /usr/bin/env python\n# -*- coding: iso-8859-1 -*-\n# vi:ts=4:et\n\nimport pycurl\nimport unittest\n\nfrom . import appmanager\nfrom . import util\n\nsetup_module, teardown_module ...
python
chosen
[ { "from": "human", "value": "Add spider for Victra mobile phone stores\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport json\nimport re\n\nimport scrapy\n\nfrom locations.items import GeojsonPointItem\nfrom locations.hours import OpeningHours\n\nclass VictraSpider(scrapy.Spider):...
python
chosen
[ { "from": "human", "value": "Add integration test for S3 object deletion\n\nBy default, uses the test bucket 'lsst-the-docs-test' and assumes\ncredentials for the lsst-sqre account are in 'ltd-dev' profile of\n~/.aws/credentials.\n\nFor DM-4951.\n" }, { "from": "gpt", "value": "#!/usr/bin/env py...
python
chosen
[ { "from": "human", "value": "Add new test for Parser\n\nTests the main Parser.parse() function with hello world and Fibonacci whitespace\nsamples\n" }, { "from": "gpt", "value": "import unittest\nfrom unittest.mock import patch, call\n\nimport whitepy.lexer as lexer\nfrom whitepy.parser import P...
python
chosen
[ { "from": "human", "value": "Add migration for publication_date field\n" }, { "from": "gpt", "value": "from django.db import models\nfrom django.db import migrations\nfrom django.utils import timezone\n\n\ndef fill_publication_date(apps, schema_editor):\n Entry = apps.get_model('zinnia', 'Ent...
python
chosen
[ { "from": "human", "value": "Add extra migration for the manager 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\n\n\nclass Migration(migrations.Migration):\n\n ...
python
chosen
[ { "from": "system", "value": "HBO: Add options argument to get()\n" }, { "from": "human", "value": "class Hbo():\n def handle(self, url):\n return \"hbo.com\" in url\n\n def get(self, url):\n parse = urlparse(url)\n try:\n other = parse[5]\n except Ke...
python
chosen
[ { "from": "system", "value": "Initialize the correct variable in init\n" }, { "from": "human", "value": "from mopidy.frontends.mpd.dispatcher import MpdDispatcher\nfrom mopidy.frontends.mpd.process import MpdProcess\n\nclass MpdFrontend(object):\n \"\"\"\n The MPD frontend.\n \"\"\"\n\n...
python
chosen
[ { "from": "human", "value": "Write script to parse API performance data\n" }, { "from": "gpt", "value": "import sys\nimport os\n\noutput_dir = sys.argv[1]\n\ndef filename(num_duplications):\n return os.path.join(output_dir, \"output_%s.csv\" % (str(num_duplications),))\n\ndef time_for_method(...
python
chosen
[ { "from": "human", "value": "Add script to convert ShapeFile to CSV for search\n\nUsed by customer infra to have search.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport csv\nimport ogr\nimport osr\nimport sys\nimport unicodedata\n\n\ndef usage():\n print('shape-to-csv.py PAT...
python
chosen
[ { "from": "human", "value": "Add tests for cachelib decorator\n" }, { "from": "gpt", "value": "from mock import Mock\nimport warnings\n\nfrom django.core.cache import CacheKeyWarning\nfrom django.test import SimpleTestCase, override_settings\n\nfrom matrixstore.cachelib import memoize\n\n# The l...
python
chosen
[ { "from": "human", "value": "Add ConcurrentPaginator (for the engage API)\n" }, { "from": "gpt", "value": "import math\nimport itertools\nfrom multiprocessing.pool import ThreadPool\n\nclass ConcurrentPaginator(object):\n \"\"\"\n Concurrently fetches all pages in a paginated collection.\n...
python
chosen
[ { "from": "human", "value": "Add forms for supplier and contact information\n\nForms allow us to validate basic field requirements before making\na request to the API, since the API doesn't return per-field errors\nat the moment.\n\nSupplier and contact information have separate forms, since they\nrequire s...
python
chosen
[ { "from": "human", "value": "Add fetch data py script\n\nAdd .py file with code to fetch data defined in function fetch_data()" }, { "from": "gpt", "value": "import os\r\nimport pandas as pd\r\nimport tensorflow_datasets as tfds\r\n\r\n\r\n# Example use in another file of this directory:\r\n# im...
python
chosen
[ { "from": "human", "value": "Test qlearning4k result for 2048\n" }, { "from": "gpt", "value": "from __future__ import print_function\nimport numpy as np\nimport math\nnp.random.seed(1337) # for reproducibility\n\nfrom keras.datasets import mnist\nfrom keras.models import Sequential, model_from_...
python
chosen
[ { "from": "human", "value": "Add algorithm for finding PSNE in two-player simultaneous-move games\n" }, { "from": "gpt", "value": "from numpy import array\n\ndef transpose(payoff_matrix):\n return array(payoff_matrix).transpose().tolist()\n\ndef get_best_responses(payoff_matrix):\n # Select ar...
python
chosen
[ { "from": "human", "value": "Add basic unit tests for CI job\n" }, { "from": "gpt", "value": "from yahoo_historical import Fetcher\n\n\ndef test_get_historical():\n data = Fetcher(\"AAPL\", [2007, 1, 1], [2017, 1, 1]).get_historical()\n assert len(data) > 0\n\n\ndef test_get_dividends():\n...
python
chosen
[ { "from": "human", "value": "Add script to extract the 2000 MSA to county correspondence\n" }, { "from": "gpt", "value": "\"\"\"build_2000_msa.py\n\nExtract a usable crosswalk between 2000 Metropolitan areas and counties.\nReconstitute a shapefile for the 2000 MSAs from the counties.\n\nParamete...
python
chosen
[ { "from": "human", "value": "Add a script to generate constant for binding\n" }, { "from": "gpt", "value": "import sys, re\n\nINCL_DIR = '../include'\n\ninclude = [\n ('/arm.h', 'ARM_'),\n ('/arm64.h', 'ARM64_'),\n ('/x86.h', 'X86_'),\n ('/mips.h', 'MIPS_'),\n]\n\ntemplate = {\n '...
python
chosen
[ { "from": "human", "value": "Add test for organization settings\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\n\nfrom django.core.urlresolvers import reverse\n\nfrom sentry.models import Organization\nfrom sentry.testutils import TestCase\n\n\nclass OrganizationSettings...
python
chosen
[ { "from": "human", "value": "Add a script to simplify building releases\n" }, { "from": "gpt", "value": "import os\nimport shutil\nimport subprocess\nimport sys\nfrom contextlib import contextmanager\n\n\n@contextmanager\ndef ignore_no_file():\n try:\n yield\n except FileNotFoundErr...
python
chosen
[ { "from": "human", "value": "Add initial testing module for api.py\n" }, { "from": "gpt", "value": "\"\"\"Tests the isort API module\"\"\"\nimport pytest\n\nfrom isort import api, exceptions\n\n\ndef test_sort_file_invalid_syntax(tmpdir) -> None:\n \"\"\"Test to ensure file encoding is respec...
python
chosen
[ { "from": "human", "value": "Add script to create initial database structure\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n\"\"\"Create the initial database structure.\n\nExisting tables will be ignored, and those not existing will be created.\n\n:Copyright: 2006-2018 Jochen Kuppersc...
python
chosen
[ { "from": "human", "value": "Add a python parquet file query example\n" }, { "from": "gpt", "value": "# Finds the names of people who like pandas from a parquet file\n# consisting of name & favouriteAnimal.\n# For input you can use the result of MakeParquetFile\nfrom pyspark import SparkContext\...
python
chosen
[ { "from": "human", "value": "Read file and print n largest lines\n" }, { "from": "gpt", "value": "#Program to find the n largest lines in a file\nimport operator\nimport sys\n\n#Read the file from terminal\ntest_cases = open(sys_argv[1],'r')\n\n#Remove white spaces and empty lines and make a lis...
python
chosen
[ { "from": "human", "value": "Add script to find areal units where each category is represented (and test marble)\n" }, { "from": "gpt", "value": "\"\"\"neighbourhoods_categories.py\n\nFind the tracts where each category is over-represented or all cities in the\ndataset.\n\"\"\"\nimport csv\nimpo...
python
chosen
[ { "from": "human", "value": "Move existing nhs orgs without branding onto nhs branding\n\nThis is done to make self-service branding easier to implement,\nand also because NHS branding makes much more sense for services\nin those orgs than GOV.UK branding.\n" }, { "from": "gpt", "value": "\"\"\"...
python
chosen
[ { "from": "human", "value": "Add action list permissions tests\n" }, { "from": "gpt", "value": "import pytest\n\nfrom api.base.settings.defaults import API_BASE\nfrom api_tests.requests.mixins import PreprintRequestTestMixin\n\n@pytest.mark.django_db\nclass TestPreprintRequestActionList(Preprint...
python
chosen
[ { "from": "human", "value": "Add tests for formatter xml\n" }, { "from": "gpt", "value": "import unittest, argparse\nfrom echolalia.formatter.xmler import Formatter\n\nclass XmlerTestCase(unittest.TestCase):\n\n def setUp(self):\n self.parser = argparse.ArgumentParser()\n self.data = [{'c...
python
chosen
[ { "from": "human", "value": "Create the bottom-up version of longestPath" }, { "from": "gpt", "value": "def longestChain(words):\n if words == []:\n return 0\n lendict = {}\n lenlist = []\n\n # build the dictory where\n # the key is the length of a word,\n # and the valu...
python
chosen
[ { "from": "human", "value": "Add stubs for deterministic cache tests\n" }, { "from": "gpt", "value": "import unittest\n\n\nclass TestDeterministicCache(unittest.TestCase):\n\n def test_init(self):\n pass\n\n def test_setitem(self):\n pass\n\n def test_save(self):\n ...
python
chosen
[ { "from": "human", "value": "Add python host code using pyopencl\n" }, { "from": "gpt", "value": "import pyopencl as cl\nimport numpy\nimport sys\nimport datetime\n\nclass NoiseGenerator(object):\n def __init__(self, block_dim=None):\n self.ctx = cl.create_some_context()\n self....
python
chosen
[ { "from": "human", "value": "Copy QThread code from stackoverflow\n" }, { "from": "gpt", "value": "import sys\nfrom queue import Queue\nfrom PyQt4.QtCore import *\nfrom PyQt4.QtGui import *\n\n# The new Stream Object which replaces the default stream associated with sys.stdout\n# This object jus...
python
chosen
[ { "from": "human", "value": "Add migration for oauth application" }, { "from": "gpt", "value": "# Generated by Django 3.1.8 on 2021-04-12 13:18\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('account', '0026_auto_20201221...
python
chosen
[ { "from": "human", "value": "Add building blocks Container, Context\n\nThese will be used for request/response dicts, as well as\ncontainers for plugins to pass functions and values to the\noperation function or other plugins.\n" }, { "from": "gpt", "value": "\"\"\"\nRequestContext stores state ...
python
chosen
[ { "from": "human", "value": "Solve Bhaskara's Formula in python\n" }, { "from": "gpt", "value": "import math\n\na, b, c = map(float, input().split())\n\ndelta = math.pow(b, 2) - 4 * a * c\n\nif delta >= 0 and a != 0:\n print(f'R1 = {((b * -1) + math.sqrt(delta)) / (2 * a):.5f}')\n print(f'...
python
chosen
[ { "from": "human", "value": "Add metadata example code APPENG-3048\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n#\n# Copyright (c) SAS Institute, Inc.\n#\n\n\"\"\"\nScript to set product info on a group.\n\"\"\"\n\nimport sys\nimport epdb\nsys.excepthook = epdb.excepthook()\n\nimport json...
python
chosen
[ { "from": "human", "value": "Add a script to find \"empty\" skeletons\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\n# This script checks your database for some common\n# inconsistencies or errors that may have arisen from\n# past bugs.\n\n# You may need to install psycopg2, e.g. with:\n#...
python
chosen
[ { "from": "human", "value": "Add initial unify bould script\n" }, { "from": "gpt", "value": "# Unify project builder\n# Copyright 2012 Sebastian Fastner, Mainz, Germany\n\nimport webbrowser\n\n@task(\"Open help in browser\")\ndef help():\n # Clearing cache\n webbrowser.open(\"http://unify-...
python
chosen
[ { "from": "human", "value": "Read value from nano via i2c\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport smbus\nimport time\n\n# for RPI version 1, use “bus = smbus.SMBus(0)”\nbus = smbus.SMBus(1)\n\n# This is the address we setup in the Arduino Program\naddress = 0x04\ncmd_re...
python
chosen
[ { "from": "human", "value": "Add some functional tests for the new resolver\n" }, { "from": "gpt", "value": "import json\nfrom tests.lib import create_basic_wheel_for_package\n\n\ndef assert_installed(script, **kwargs):\n ret = script.pip('list', '--format=json')\n installed = set(\n ...
python
chosen
[ { "from": "human", "value": "Add script to supervise acronyms\n" }, { "from": "gpt", "value": "#! /usr/bin/env pyton3\n\nimport fileinput\nimport json\n\n# Process the input\nwith fileinput.input() as input_files:\n for line in input_files:\n mention = json.loads(line)\n mention...
python
chosen
[ { "from": "human", "value": "Add script to change starting index in window file.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport argparse\nimport scipy.io as sio\nimport os\nimport os.path as osp\nimport numpy as np\nfrom vdetlib.vdet.dataset import index_det_to_vdet\n\nif __name_...
python
chosen
[ { "from": "human", "value": "Use Python to call our shell script test.\n\nThis allows automated tools like nose2 to run it.\n" }, { "from": "gpt", "value": "from subprocess import call\n\n# This test is simply calling a shell script, which calls a python main recipe\n# (Originally a function use...
python
chosen
[ { "from": "human", "value": "BilingualGenerator: Add script to generate a bilingual dictionary from vector list.\n\nSelect a specified number of words from each cluster, translate the words, and check if they exist in language model.\n\nInput hard coded for clusters file path, model path and sample size.\n\...
python
chosen
[ { "from": "human", "value": "Add migration that correctly sets payout account permissions for staff.\n\nBB-13581 #resolve\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.8 on 2018-12-11 08:38\nfrom __future__ import unicode_literals\n\nfrom django.db import m...
python
chosen
[ { "from": "human", "value": "Add a snippet (Python GTK+3).\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n# Copyright (c) 2015 Jérémie DECOCK (http://www.jdhp.org)\n\n\"\"\"\nThis is the simplest Python GTK+3 snippet.\n\nSee: http://python-gtk-3-tutorial.read...
python
chosen