conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add stub class for future analysis class\n" }, { "from": "gpt", "value": "import camoco as co\n\nclass Analysis(object):\n '''\n Perform an analysis based on CLI arguments:\n set up, event loop, tear down\n '''\n def __init__(self):\n # ...
python
chosen
[ { "from": "human", "value": "Add aproximate pattern count algorithm\n" }, { "from": "gpt", "value": "from hamming_distance import hamming_distance\n\ndef approximate_pattern_count(text, pattern, d):\n count = 0\n pattern_length = len(pattern)\n for i in range(0, len(text) - pattern_length + 1...
python
chosen
[ { "from": "human", "value": "Fix naming of location in meeting\n\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.5 on 2017-09-11 16:58\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n...
python
chosen
[ { "from": "human", "value": "Test for wire invoice factory\n" }, { "from": "gpt", "value": "from decimal import Decimal\nfrom django.core import mail\n\nfrom corehq.apps.accounting.tests.test_invoicing import BaseInvoiceTestCase\nfrom corehq.apps.accounting import generator, utils, tasks\nfrom c...
python
chosen
[ { "from": "human", "value": "Add nose tests for BMI methods\n" }, { "from": "gpt", "value": "from nose.tools import assert_is, assert_equal\nfrom bmi_ilamb import BmiIlamb\n\ndef test_component_name():\n component = BmiIlamb()\n name = component.get_component_name()\n assert_equal(name,...
python
chosen
[ { "from": "human", "value": "Switch myisam to innodb for fulltext_record_properties\n\nThis change was made because fulltext record properties table\ncrashed on grc-dev and grc-test. The issue was resolved with\nREPAIR TABLE clause. Running the reindex script did not help.\n\nBased on https://cloud.google.c...
python
chosen
[ { "from": "human", "value": "Create migration to load POS fixture data" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom django.db import models, migrations\nfrom django.core.management import call_command\n\napp_name = 'api'\nfixture = model_name = 'PartOfSpeech'\n\n\ndef load_fixtur...
python
chosen
[ { "from": "human", "value": "Set postage for all existing templates to service default\n" }, { "from": "gpt", "value": "\"\"\"\n\nRevision ID: 0253_set_template_postage\nRevises: 0252_letter_branding_table\nCreate Date: 2019-01-30 16:47:08.599448\n\n\"\"\"\nfrom alembic import op\nimport sqlalch...
python
chosen
[ { "from": "human", "value": "Add task to delete spam accounts\n" }, { "from": "gpt", "value": "from django.db.models import Q, Count\nfrom django.core.management.base import BaseCommand\nfrom accounts.models import User\n\n\nclass Command(BaseCommand):\n def handle(self, *args, **kwargs):\n ...
python
chosen
[ { "from": "human", "value": "Add two tests for dart client\n" }, { "from": "gpt", "value": "import json\nfrom indra.literature.dart_client import jsonify_query_data\n\n\ndef test_timestamp():\n # Should ignore \"after\"\n assert jsonify_query_data(timestamp={'on': '2020-01-01',\n ...
python
chosen
[ { "from": "human", "value": "Add script to measure title length statistics\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"Script to measure title length statisics\"\"\"\nfrom itertools import cycle\nimport numpy as np\nfrom iscc_bench.readers import ALL_READERS\n\n\ndef iter_tit...
python
chosen
[ { "from": "human", "value": "Add solution for: Remove Duplicates from Sorted Array\n" }, { "from": "gpt", "value": "\"\"\"\nPlease read this as markdown:\n\n# Algorithm description\n\nProblem statement: https://leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/727/\n\nThe...
python
chosen
[ { "from": "human", "value": "Add an example how to draw Bezier curves.\n\nThe vispy.geometry.curves module provides several helper\nfunctions to generate the right vertices for a nice curved\nline.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# --------------------------------------...
python
chosen
[ { "from": "human", "value": "Add unit test for memoize_request\n" }, { "from": "gpt", "value": "# This file is part of Indico.\n# Copyright (C) 2002 - 2016 European Organization for Nuclear Research (CERN).\n#\n# Indico is free software; you can redistribute it and/or\n# modify it under the term...
python
chosen
[ { "from": "human", "value": "Create migration after upgrading to mezzanine 4\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport mezzanine.core.fields\n\n\nclass Migration(migrations.Migration):\n\n...
python
chosen
[ { "from": "human", "value": "tests: Add initial test suite for nighttrain.tasks module\n\nThis overlaps with the main test suite so far, but will be useful once\nthe task list format becomes more complex.\n" }, { "from": "gpt", "value": "# Copyright 2017 Codethink Ltd.\n#\n# Licensed under the A...
python
chosen
[ { "from": "human", "value": "Clean up an old index in sentry_groupedmessage\n\nThe original migration version 0015 was supposed to remove this, but the\nordering of the index fields in the migration script didn't match the\nactual index.\n\n0015 has:\n\n db.delete_unique('sentry_groupedmessage', ['checksum...
python
chosen
[ { "from": "human", "value": "Add module for wolfram alpha queries via their API\n\n\ngit-svn-id: 056f9092885898c4775d98c479d2d33d00273e45@330 dda364a1-ef19-0410-af65-756c83048fb2\n" }, { "from": "gpt", "value": "import requests\nimport urllib\nimport logging\n\ntry:\n from lxml import etree\n ...
python
chosen
[ { "from": "human", "value": "Add recursive binary search implementation\n" }, { "from": "gpt", "value": "\ndef binary_search(array, low, high, item):\n\n if(low>high) :\n return -1\n\n mid = (low + high)//2\n\n if(item == array[mid]):\n return mid\n elif item < array[mi...
python
chosen
[ { "from": "system", "value": "Add in basic HttpPostHandler docs\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# coding=utf-8\n\nfrom Handler import Handler\nimport urllib2\n\n\nclass HttpPostHandler(Handler):\n\n# Inititalize Handler with url and batch size\n def __init__(self, co...
python
chosen
[ { "from": "human", "value": "Convert an image to grayscale and resize it.\n" }, { "from": "gpt", "value": "#!/bin/env python3\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.ndimage import imread\n\ndef rgb2gray(img):\n\treturn np.dot(img, [0.299, 0.587, 0.114])\n\n\n\nif __na...
python
chosen
[ { "from": "human", "value": "Add test for retriever context factory\n" }, { "from": "gpt", "value": "import unittest\nfrom robotide.namespace.namespace import _RetrieverContextFactory\nfrom robot.parsing.model import ResourceFile\nfrom robot.utils.asserts import assert_equals\n\n\ndef datafileWi...
python
chosen
[ { "from": "human", "value": "Add a test case for invalid log level friendly error message during\nservice setup.\n" }, { "from": "gpt", "value": "# Licensed to the StackStorm, Inc ('StackStorm') under one or more\n# contributor license agreements. See the NOTICE file distributed with\n# this wo...
python
chosen
[ { "from": "human", "value": "Add a migration for threat actor -> threat\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: anze@reciprocityl...
python
chosen
[ { "from": "human", "value": "Test of the timing module\n" }, { "from": "gpt", "value": "from test_support import verbose\nimport timing\n\nr = range(100000)\nif verbose:\n print 'starting...'\ntiming.start()\nfor i in r:\n pass\ntiming.finish()\nif verbose:\n print 'finished'\n\nsecs = ...
python
chosen
[ { "from": "human", "value": "Add sound recording tool with arecord and lame\n" }, { "from": "gpt", "value": "# coding: utf-8\n\nimport os\nimport re\nimport shlex\nfrom subprocess import Popen, PIPE\n\n\ndef available_devices():\n devices =[]\n\n os.environ['LANG'] = 'C'\n command = 'ar...
python
chosen
[ { "from": "human", "value": "Add test for ALWAYS_PUBLIC injection behavior\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom nose.tools import assert_in\nfrom unittest import TestCase\n\nfrom framework.auth import oauth_scopes\n\nclass TestOAuthScopes(TestCase):\n\n def test_each...
python
chosen
[ { "from": "human", "value": "Add sampler for conditional LFW(crop)\n" }, { "from": "gpt", "value": "from pylearn2.utils import serial\nimport sys\n_, model_path = sys.argv\nmodel = serial.load(model_path)\nspace = model.generator.get_output_space()\nfrom pylearn2.config import yaml_parse\nfrom p...
python
chosen
[ { "from": "human", "value": "Add migration to drop now-unused supplier_framework columns\n\nThe recent addition of the framework_agreement table means that these columns\nare no longer needed. (They are no longer referred to anywhere in the API code.)\n" }, { "from": "gpt", "value": "\"\"\"Remov...
python
chosen
[ { "from": "human", "value": "migrations: Add migration to set default value of enable_read_receipts.\n\nThis migration set default value of enable_read_receipts to True\nfor existing realms which require an invitation to join.\n" }, { "from": "gpt", "value": "# Generated by Django 4.0.6 on 2022-...
python
chosen
[ { "from": "human", "value": "Add negative test for cluster show\n\nThe negative tests in tempest will check the exceptions raised\nfrom an invalid request, so this patch will follow. It will request\na invalid cluster and check the NotFound error.\n\nChange-Id: Ib602800b6e0d184b6a0b9146d79530d8d68289d4\n" ...
python
chosen
[ { "from": "system", "value": "Add parameters handling to the save method\n" }, { "from": "human", "value": "VERSION = \"0.0.8\" # Add User-Agent and optional token encoding with sense.app_secret key.\n#\"0.0.7\": Fix a bug in Feed instance_url (case of adressing a feed by type on a retrieved fee...
python
chosen
[ { "from": "human", "value": "Add test for computing nullspace of the Schur operator\n" }, { "from": "gpt", "value": "from firedrake import *\nfrom firedrake.slate.preconditioners import create_schur_nullspace\nimport numpy as np\n\nmesh = UnitCubedSphereMesh(2)\nmesh.init_cell_orientations(Spati...
python
chosen
[ { "from": "human", "value": "Add script to artificially increase the size of graphs by replicating all nodes and their links\n" }, { "from": "gpt", "value": "import sys\nimport commentjson as json\nimport os\nimport argparse\nimport numpy as np\nimport copy\n\nsys.path.append('../.')\nsys.path.a...
python
chosen
[ { "from": "human", "value": "Add unittest for utility functions of optimizer\n" }, { "from": "gpt", "value": "from unittest import TestCase\nimport numpy as np\nfrom chainer import cuda, Optimizer\nfrom chainer.optimizer import _sqnorm\n\ncuda.init()\n\nclass TestOptimizerUtility(TestCase):\n ...
python
chosen
[ { "from": "human", "value": "Add tests for simple char creation\n" }, { "from": "gpt", "value": "import npc\nimport pytest\nimport os\n\n@pytest.fixture\ndef characters(campaign, prefs):\n os.mkdir(prefs.get('paths.characters'))\n return campaign\n\n@pytest.fixture(params=['human', 'fetch'...
python
chosen
[ { "from": "human", "value": "Apply it 1 from lecture 4 added\n" }, { "from": "gpt", "value": "# Temperature Conversion Program (Celcius-Fahrenheit / Fahrenheit-Celcius)\n\n# Display program welcome\nprint('This program will convert temperatures (Fahrenheit/Celcius)')\nprint('Enter (F) to convert...
python
chosen
[ { "from": "human", "value": "Add tests for password hashing and checking\n\n" }, { "from": "gpt", "value": "import hashlib\n\nfrom virtool.utils import random_alphanumeric\nfrom virtool.users import hash_password, check_password, check_legacy_password\n\n\nclass TestHashPassword:\n\n def test...
python
chosen
[ { "from": "system", "value": "Return the function again from the hook decorator\n\nThe decorator variant of hook registration did not return anything,\nmeaning that the decorated function would end up being `None`. This was\nnot noticed, as the functions are rarely called manually, as opposed to\nbeing invo...
python
chosen
[ { "from": "human", "value": "Add rabbitmq request reply server" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport pika\n\nconnection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))\n\nchannel = connection.channel()\n\nchannel.queue_declare(queue='rpc_queue')\n\nd...
python
chosen
[ { "from": "human", "value": "Add Python 2 and 3 solution for Nov. 2013 Bronze Problem 1\n" }, { "from": "gpt", "value": "import itertools\n\ndef read_combo(file):\n\treturn [int(x) - 1 for x in file.readline().split()];\n\ndef permute(combo, size):\n\treturn [[x % size for x in permutation] for ...
python
chosen
[ { "from": "human", "value": "Add unit test for availability_zone_client\n\nThis patch adds unit test for availability_zone_client.\n\nChange-Id: I9f043f0cf864773cbd15c23f776487a729c09692\n" }, { "from": "gpt", "value": "# Copyright 2015 NEC Corporation. All rights reserved.\n#\n# Licensed u...
python
chosen
[ { "from": "human", "value": "Add Python 3.8 f-string debugging specifier.\n" }, { "from": "gpt", "value": "\"\"\"\nPython 3.8 にて導入された f-string での {xxx=} 表記についてのサンプルです。\n\nREFERENCES:: http://bit.ly/2NlJkSc\n\"\"\"\nfrom trypython.common.commoncls import SampleBase\n\n\nclass Sample(SampleBase):\...
python
chosen
[ { "from": "human", "value": "Create new utility module for drawing\n\n* wqflask/utility/pillow_utils.py: Create a module to hold some utility\nfunctions for drawing with Pillow. Initialise the module with a function to draw\nrotated text.\n" }, { "from": "gpt", "value": "from PIL import Image, I...
python
chosen
[ { "from": "human", "value": "Add test for provincial legislatures page\n" }, { "from": "gpt", "value": "from tests import PMGLiveServerTestCase\nfrom tests.fixtures import dbfixture, HouseData, CommitteeData\nfrom pmg.models import House\nfrom pmg.views import utils\n\n\nclass TestProvincialLegi...
python
chosen
[ { "from": "human", "value": "Add migration for meta names\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.3 on 2017-07-04 17:55\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n dep...
python
chosen
[ { "from": "human", "value": "Add command to get number of preregistrations by schema\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom django.core.management.base import BaseCommand\nfrom osf.models import Registration, MetaSchema\n\nPREREG_SCHEMA_NAMES = [\n 'Prereg Challenge',\...
python
chosen
[ { "from": "human", "value": "Add missing migration for Notification model\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nimport notifications.models\n\n\nclass Migration(migrations.Migration):\n\n ...
python
chosen
[ { "from": "human", "value": "ENH/DOC: Add an example doing classification on digits.\n\n\n\ngit-svn-id: a2d1b0e147e530765aaf3e1662d4a98e2f63c719@669 22fbfee3-77ab-4535-9bad-27d1bd3bc7d8\n" }, { "from": "gpt", "value": "\"\"\"\n================================\nRecognizing hand-written digits\n==...
python
chosen
[ { "from": "human", "value": "Add a tool for benchmarking read performance\n\nIt's not installed, on the assumption that it will be used by katdal\ndevelopers, not users.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom __future__ import print_function, division, absolute_import\nfr...
python
chosen
[ { "from": "human", "value": "Move GenericForeignKeys from popolo.Person to people.Person\n\nThis was missing from the work to move People to the person app\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.8 on 2018-10-29 15:10\nfrom __future__ import unicode_l...
python
chosen
[ { "from": "human", "value": "Add task to summarise concessions" }, { "from": "gpt", "value": "from datetime import date\n\nfrom django.core.management import BaseCommand\n\nfrom dmd.models import NCSOConcession\n\n\nclass Command(BaseCommand):\n def handle(self, *args, **kwargs):\n tod...
python
chosen
[ { "from": "human", "value": "Add old code from test1.\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\n\n\nimport time\n\n\ndef c_frac(n):\n s = 1\n for i in range(0, n):\n s = 1.0 + 1.0 / s\n\n return s\n\n\nstart_time = time.time()\nprint(c_frac(1000000))\nprint(\"--- %f seconds ---\...
python
chosen
[ { "from": "system", "value": "Update example scraper to use known slug.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport json\n\nimport requests\n\nAPI = 'http://localhost:8000/api/1.0'\nAUTH_PARAMS = {\n 'email': 'panda@pandaproject.net',\n 'api_key': 'edfe6c5ffd1be4d3bf...
python
chosen
[ { "from": "human", "value": "Fix uploader bugs and make medium text field; add textarea for entering text directly\n" }, { "from": "gpt", "value": "###########################################################################\n# (C) Vrije Universiteit, Amsterdam (the Netherlands) ...
python
chosen
[ { "from": "human", "value": "Rename start and end fields (4.2/4)\n\nThis is the 4.2th stage of renaming the start and end fields of\nCourseRun to start_date and end_date.\n\nThis release ONLY removes the old columns via migration. Note that this\ndoes not include removing the django model fields correspond...
python
chosen
[ { "from": "human", "value": "Add migration to create \"user created\" template\n" }, { "from": "gpt", "value": "from django.db import migrations\n\nNOTIFICATION_TYPES = ('user_created',)\nLANGUAGES = ['fi']\nDEFAULT_LANGUAGE = 'fi'\n\nFOOTER_FI = 'Tämä on automaattinen viesti Helsingin kaupungin...
python
chosen
[ { "from": "human", "value": "Add reconstruct corpus as a test\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport argparse\nimport collections\nimport random\n\nimport sys\n\n\ndef reconstruct(f_in, f_out):\n sentence_starts = []\n\n contexts = {}\n\n for line in f_in:\n ...
python
chosen
[ { "from": "human", "value": "Initialize and declare class Node\n" }, { "from": "gpt", "value": "class Node:\n\n def __init__(self):\n self.name = ''\n self.weight = 0\n self.code = ''\n\n def initSet(self, name, weight):\n self.name = name\n self.weight =...
python
chosen
[ { "from": "human", "value": "Add watchdog that monitors scripts editing" }, { "from": "gpt", "value": "import time\nfrom watchdog.observers import Observer\nfrom watchdog.events import PatternMatchingEventHandler\n\n\nclass ScriptModifiedHandler(PatternMatchingEventHandler):\n patterns = ['*....
python
chosen
[ { "from": "human", "value": "Add a state for patch a person in wonderland.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# encoding=utf8\n\nimport requests\nfrom flexbe_core import EventState, Logger\n\n\"\"\"\nCreated on 17/05/2018\n\n@author: Lucas Maurice\n\"\"\"\n\n\nclass Wonderla...
python
chosen
[ { "from": "human", "value": "Add Ansible callback plugin to profile tasks\n\nIn order to try and speed up provisioning, this changeset adds a plugin\nthat gives you the per task duration breakdown of a playbook. From here,\nwe can identify the outliers and spend a little time making them faster.\n\nExample ...
python
chosen
[ { "from": "human", "value": "Add an importer for Bromsgrove.\n\nrefs #24\n" }, { "from": "gpt", "value": "\"\"\"\nImport Bromsgrove\n\"\"\"\nimport sys\n\nfrom data_collection.management.commands import BaseShpShpImporter\n\nclass Command(BaseShpShpImporter):\n \"\"\"\n Imports the Polling...
python
chosen
[ { "from": "human", "value": "Add script to download property data from Wikidata.\n" }, { "from": "gpt", "value": "# coding=utf-8\nimport urllib, urllib2\nimport json\n\ndef fetch_wikidata_data():\n\tWIKIDATA_API_URL = 'https://www.wikidata.org/w/api.php'\n\tparam = {}\n\tparam['action'] = 'query...
python
chosen
[ { "from": "human", "value": "Add example script for image pyramids\n" }, { "from": "gpt", "value": "\"\"\"\n====================\nBuild image pyramids\n====================\n\nThis example shows how to build image pyramids.\n\"\"\"\n\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom s...
python
chosen
[ { "from": "human", "value": "Add file for constants and magic numbers\n\nThis is the file where things like default timeouts, statuses to write\nin a database and others will be stored.\nThe code is more readable and importable from any other file.\n" }, { "from": "gpt", "value": "max_db_int = 4...
python
chosen
[ { "from": "human", "value": "Add migration that sets `submitted_at` for old brief responses\n\nFor any brief response that does not have a `submitted_at` time,\nwe add one based on the `created_at` time. As we will now be looking\nat `submitted_at` rather than `created_at` to indicate a submitted\nbrief res...
python
chosen
[ { "from": "human", "value": "Implement libray to use API\n" }, { "from": "gpt", "value": "from django.db import connection\nimport requests\n\n\ndef get(http_url, user_id):\n headers = {\n 'Authorization': __auth_token(user_id)\n }\n r = requests.get(http_url, headers=headers)\n\...
python
chosen
[ { "from": "human", "value": "Add language relation to existing pages\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\ndef add_language_relation(apps, schema_editor):\n from molo.core.models import SiteLa...
python
chosen
[ { "from": "human", "value": "Add solution to lintcode question 105\n" }, { "from": "gpt", "value": "# Definition for singly-linked list with a random pointer.\n# class RandomListNode:\n# def __init__(self, x):\n# self.label = x\n# self.next = None\n# self.random = Non...
python
chosen
[ { "from": "human", "value": "Add script to clean up nodes that were templated from registrations\n\n[OSF-7956]\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport sys\nimport logging\nfrom website.app import setup_django, init_app\nfrom scripts import utils as script_utils\nfrom dja...
python
chosen
[ { "from": "human", "value": "Add tests for anpnymize methods\n" }, { "from": "gpt", "value": "from ..anonymize import obfuscate_address, obfuscate_email, obfuscate_string\n\n\ndef test_obfuscate_email():\n # given\n email = \"abc@gmail.com\"\n\n # when\n result = obfuscate_email(emai...
python
chosen
[ { "from": "human", "value": "Add script to check dataset integrity\n" }, { "from": "gpt", "value": "import os\n\nfrom collections import defaultdict\n\nimport click\n\nimport dtoolcore\n\n\n@click.command()\n@click.argument('dataset_path')\ndef main(dataset_path):\n\n uri = \"disk:{}\".format...
python
chosen
[ { "from": "human", "value": "Add migration script for user badges\n" }, { "from": "gpt", "value": "from datetime import datetime\n\nfrom sqlalchemy import MetaData, Column, ForeignKey, Table\nfrom sqlalchemy import DateTime, Integer, Unicode\n\nmetadata = MetaData()\n\n\nbadge_table = Table('bad...
python
chosen
[ { "from": "human", "value": "Add some shortcuts for Google, Facebook, Instagram\n" }, { "from": "gpt", "value": "from requests_oauth2 import OAuth2\n\n\nclass GoogleClient(OAuth2):\n site = \"https://accounts.google.com\"\n authorization_url = \"/o/oauth2/auth\"\n token_url = \"/o/oauth...
python
chosen
[ { "from": "human", "value": "Add solution for FB Melbourne 2018 Hackahton Pre-eliminary Challenge\n" }, { "from": "gpt", "value": "def triangleOrNot(a, b, c):\n n = len(a)\n result = []\n for i in range(n):\n side_a = a[i]\n side_b = b[i]\n side_c = c[i]\n pr...
python
chosen
[ { "from": "human", "value": "Add migration for session choices\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('schedule', '...
python
chosen
[ { "from": "human", "value": "Implement a basic kivy application\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"\n{{cookiecutter.repo_name}}\n============================\n\nThe root of :class:`{{cookiecutter.app_class_name}}` is created from the kv file.\n\"\"\"\n\nimport kivy...
python
chosen
[ { "from": "system", "value": "Remove the \"view/\" part for viewing signatures\n" }, { "from": "human", "value": "from django.conf.urls import patterns, include, url\nfrom rest_framework import routers\nfrom crashmanager import views\n\nrouter = routers.DefaultRouter()\nrouter.register(r'signatu...
python
chosen
[ { "from": "human", "value": "Add some tests to playlists service\n" }, { "from": "gpt", "value": "from tests.base import ApiDBTestCase\n\nfrom zou.app.models.playlist import Playlist\nfrom zou.app.services import (\n files_service,\n playlists_service,\n tasks_service\n)\n\n\nclass Play...
python
chosen
[ { "from": "human", "value": "Add test for composite association with property pages\n" }, { "from": "gpt", "value": "# flake8: noqa F401,F811\nfrom gaphor import UML\nfrom gaphor.core.modeling import Diagram\nfrom gaphor.diagram.tests.fixtures import (\n connect,\n create,\n diagram,\n ...
python
chosen
[ { "from": "human", "value": "Add basic test of Topos.beneath()\n" }, { "from": "gpt", "value": "from skyfield.api import load\nfrom skyfield.positionlib import Geocentric\nfrom skyfield.toposlib import Topos\n\ndef ts():\n yield load.timescale()\n\ndef test_beneath(ts):\n t = ts.utc(2018, ...
python
chosen
[ { "from": "human", "value": "Add tests for many to many aggregates\n" }, { "from": "gpt", "value": "import sqlalchemy as sa\nfrom sqlalchemy_utils.aggregates import aggregated\nfrom tests import TestCase\n\n\nclass TestAggregatesWithManyToManyRelationships(TestCase):\n dns = 'postgres://postg...
python
chosen
[ { "from": "human", "value": "Add script to generate random Levenshtein queries from a set of strings\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\nScript to extract and then generate random queries for fuzzy searching.\n\nUsage:\n ./extract-random-queries.py <infile> <outfil...
python
chosen
[ { "from": "human", "value": "Test health check URL response\n" }, { "from": "gpt", "value": "from tests.BaseTestWithDB import BaseTestWithDB\nfrom django.urls import reverse\n\n\nclass HealthCheckURLTest(BaseTestWithDB):\n\n def __init__(self, *args, **kwargs):\n super().__init__(*args...
python
chosen
[ { "from": "human", "value": "Add default permissions for existing services.\n" }, { "from": "gpt", "value": "\"\"\"empty message\n\nRevision ID: 0028_add_default_permissions\nRevises: 0027_add_service_permission\nCreate Date: 2016-02-26 10:33:20.536362\n\n\"\"\"\n\n# revision identifiers, used b...
python
chosen
[ { "from": "human", "value": "Add basic tests for expected links on main site homepage\n" }, { "from": "gpt", "value": "from web_test_base import *\n\nclass TestIATIStandard(WebTestBase):\n requests_to_load = {\n 'IATI Standard Homepage - no www': {\n 'url': 'http://iatistand...
python
chosen
[ { "from": "human", "value": "Add a push notification module to handle mobile client notifications\n\n(imported from commit 3061a6e2d845226d3dce5bb262deb3a896e54f07)\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\n\nfrom zerver.models import UserProfile, AppleDeviceToken\...
python
chosen
[ { "from": "human", "value": "Add migration for missing backend data\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.18 on 2019-04-29 15:44\nfrom __future__ import unicode_literals\n\nimport logging\nfrom django.db import migrations\n\n\ndef update_backend(app...
python
chosen
[ { "from": "human", "value": "Add test to obtain the clients IP address via check.tpo\n" }, { "from": "gpt", "value": "# -*- encoding: utf-8 -*-\n#\n# :authors: Arturo Filastò\n# :licence: see LICENSE\n\nfrom ooni.templates import httpt\nclass MyIP(httpt.HTTPTest):\n inputs = ['https://check.t...
python
chosen
[ { "from": "human", "value": "Add test for calling rpc from command line\n" }, { "from": "gpt", "value": "# -*- coding: utf8 -*-\n\n# Low-resource message queue framework\n# Do RPC\n# Copyright (c) 2016 Roman Kharin <romiq.kh@gmail.com>\n\n# Permission is hereby granted, free of charge, to any pe...
python
chosen
[ { "from": "human", "value": "Add tests for the mandrill execution module\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n'''\nTests for the Mandrill execution module.\n'''\n\n# Import Python Libs\nfrom __future__ import absolute_import\n\n# Import Salt Testing Libs\nfrom tests.support....
python
chosen
[ { "from": "human", "value": "Add unit tests for _parse_author_info.\n" }, { "from": "gpt", "value": "import pytest\n\nfrom pymt.framework.bmi_setup import _parse_author_info\n\n\n@pytest.mark.parametrize(\"key\", (\"author\", \"authors\"))\ndef test_author(key):\n assert _parse_author_info({k...
python
chosen
[ { "from": "human", "value": "DOC: Add viewer example for RGB line profile\n" }, { "from": "gpt", "value": "from skimage import data\nfrom skimage.viewer import ImageViewer\nfrom skimage.viewer.plugins.lineprofile import LineProfile\n\n\nimage = data.chelsea()\nviewer = ImageViewer(image)\nviewer...
python
chosen
[ { "from": "human", "value": "Add test case for notification messages.\n" }, { "from": "gpt", "value": "from . import TheInternetTestCase\nfrom helium.api import Text, click\n\nclass NotificationMessagesTest(TheInternetTestCase):\n\tdef get_page(self):\n\t\treturn \"http://the-internet.herokuapp....
python
chosen
[ { "from": "human", "value": "Add some initial tests for pack configs API endpoints.\n" }, { "from": "gpt", "value": "# Licensed to the StackStorm, Inc ('StackStorm') under one or more\n# contributor license agreements. See the NOTICE file distributed with\n# this work for additional information...
python
chosen
[ { "from": "human", "value": "Add unit tests for PowerFreqMeasurement and increase\n\ncoverage\n" }, { "from": "gpt", "value": "'''\nCreated on Jul 16, 2014\n\n@author: thomas\n'''\nimport unittest\n\nclass TestPowerFrequency (unittest.TestCase):\n\n\n def setUp(self):\n pass\n\n\n d...
python
chosen
[ { "from": "human", "value": "Create new node manager: LedgerManager\n" }, { "from": "gpt", "value": "# stdlib\nfrom typing import Any\nfrom typing import List\n\n# third party\nfrom sqlalchemy.engine import Engine\nfrom sqlalchemy.orm import sessionmaker\n\n# relative\nfrom ..node_table.ledger i...
python
chosen
[ { "from": "human", "value": "Add migration for stuck runs\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\ndef advance_stuck_runs(apps, schema_editor):\n\n # this data migration is not forward-comp...
python
chosen
[ { "from": "human", "value": "Introduce new quilt cli Command class\n\nAll cli commands should derive from this new class to simplyfy the\nregistration of new commands. The registration is done in the Command\nclass via a Meta class automatically.\n" }, { "from": "gpt", "value": "# vim: fileencod...
python
chosen