conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add test for fake data generation\n" }, { "from": "gpt", "value": "from yunity.utils.tests.abc import BaseTestCase\nfrom yunity.utils.tests.fake import faker as default_faker, Faker\nfrom yunity.utils.validation import Validator, OfType, HasKey, IsReasonableLengthStr...
python
chosen
[ { "from": "human", "value": "Add script to train a word2vec model\n" }, { "from": "gpt", "value": "from __future__ import print_function\nimport sys\nimport os\nimport logging\n\nfrom nltk.tokenize import sent_tokenize, word_tokenize\nfrom gensim.models import Word2Vec\n\nlogging.basicConfig(lev...
python
chosen
[ { "from": "human", "value": "Add test for ensuring procedures have the correct owner\n" }, { "from": "gpt", "value": "from django.test import TestCase, Client\nfrom rest_framework import status\nfrom rest_framework.authtoken.models import Token\nfrom nose.tools import assert_equals, assert_true\...
python
chosen
[ { "from": "human", "value": "testsuite: Add tests for wikipedia bot in contrib_bots.\n\nAdd test file 'Test_wikipedia.py'.\n\nSince wikipedia links for the same query may different according\nto relevance. This test will also be written by mocking HTTP\ntraffic. But this can work for now.\n" }, { "f...
python
chosen
[ { "from": "human", "value": "Mask dilation to include missing flux near some edges\n" }, { "from": "gpt", "value": "\n'''\nDilate the existing clean mask.\n'''\n\nfrom astropy.io import fits\nfrom skimage.morphology import disk\nfrom scipy import ndimage as nd\n\n\nmask = fits.open(\"M33_14B-088...
python
chosen
[ { "from": "human", "value": "Test script for docker swarm api on p3\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"Test for docker client API on P3.\"\"\"\n\nimport logging\nimport os\n\nfrom ..docker_client import DockerClient\n\nlogging.basicConfig(level=os.getenv('SIP_DOCKER_...
python
chosen
[ { "from": "human", "value": "Add main Twitter stream capture script\n" }, { "from": "gpt", "value": "# This uses Tweepy, a Python library for accessing the Twitter API:\n# http://www.tweepy.org. Install with `pip install tweepy`.\n\nfrom tweepy.streaming import StreamListener\nfrom tweepy import...
python
chosen
[ { "from": "human", "value": "Add test for RemotePCA (run locally)\n" }, { "from": "gpt", "value": "import unittest\nfrom unittest.mock import patch, MagicMock\n\nfrom Orange.data import DiscreteVariable, Domain\nfrom Orange.data.sql.table import SqlTable\nfrom Orange.projection.pca import Remote...
python
chosen
[ { "from": "human", "value": "Add test script to add attachement to event\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom pymisp import PyMISP\nfrom keys import priv\nimport argparse\nimport os\nimport glob\nimport base64\nimport json\nimport time\n\nurl = ...
python
chosen
[ { "from": "human", "value": "Add script that fixes paths in coverage.xml for use in PyCharm\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"PyCharm can't resolve the relative paths written by pytest's coverage plugin.\nThis converts them to absolute, which ...
python
chosen
[ { "from": "human", "value": "Add a Python PoC keylogger\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Sep 17 01:16:23 2016\n\n@author: John Troony\n\"\"\"\n\nimport sys\nfrom ctypes import *\nfrom ctypes.wintypes import MSG\nfrom ctypes.wintypes import DWORD\n\...
python
chosen
[ { "from": "human", "value": "Add a simple test for the push model\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n## @file testsuite/python/modDataSeqTest.py\n## @date feb. 2016\n## @author PhRG - opticalp.fr\n##\n## Test the data push system \n\n#\n# Copyright (c) 2016 Ph. Renau...
python
chosen
[ { "from": "human", "value": "Add a method which will plot the countour map of a GMM on a map of the world as well as the best location and true position if given\n" }, { "from": "gpt", "value": "import numpy as np\nimport matplotlib as mpl\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.base...
python
chosen
[ { "from": "human", "value": "Add a script to invoke the mail sending.\n" }, { "from": "gpt", "value": "from argparse import ArgumentParser\nfrom teammails import informal_to_teams\n\n\ndef parse_args():\n args = ArgumentParser()\n\n args.add_argument(\"--nodebug\", help=\"do really send th...
python
chosen
[ { "from": "human", "value": "Add status bar module to server." }, { "from": "gpt", "value": "import rumps\nimport threading\n\nfrom server import CamsketchServer\n\nclass CamsketchStatusBarApp(rumps.App):\n def __init__(self, address):\n super(CamsketchStatusBarApp, self).__init__(\"Ca...
python
chosen
[ { "from": "human", "value": "Add migration file for preview path field\n" }, { "from": "gpt", "value": "\"\"\"empty message\n\nRevision ID: 818f7bda2528\nRevises: bf1347acdee2\nCreate Date: 2018-04-10 22:45:19.462757\n\n\"\"\"\nfrom alembic import op\nimport sqlalchemy as sa\n\n\n# revision iden...
python
chosen
[ { "from": "human", "value": "Add tempest code coverage for ceilometer driver\n\nChange-Id: I6dc9200d1096823e9046fbfcae3222ffb2c21ff5\nCloses-Bug: #1378133\n" }, { "from": "gpt", "value": "# Copyright 2014 OpenStack Foundation\n# All Rights Reserved.\n#\n# Licensed under the Apache License, Ve...
python
chosen
[ { "from": "human", "value": "USE STANDARD MARKDOWN GRAMMER!!!!! ESPECIALLY CODE!!\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n#encoding:utf-8\nimport os\nimport time\n\ndef add_tab(path):\n with open(path,'r') as f:\n flag = False\n data = ''\n tmp = '111'\n ...
python
chosen
[ { "from": "human", "value": "Add solution to lintcode problem 181\n" }, { "from": "gpt", "value": "class Solution:\n \"\"\"\n @param a, b: Two integer\n return: An integer\n \"\"\"\n def bitSwapRequired(self, a, b):\n # write your code here\n return bin((a^b) & 0xfff...
python
chosen
[ { "from": "system", "value": "Exclude unusable users from stats\n" }, { "from": "human", "value": "from . import models\nfrom django.conf import settings\n\ndef groups(request):\n return {\n 'about_group': models.Group.objects.filter(id=settings.ABOUT_GROUP_ID).first(),\n ...
python
chosen
[ { "from": "human", "value": "Add a management command for adding egap registration schema.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport logging\n\nfrom django.core.management.base import BaseCommand\nfrom osf.models import RegistrationSchema\nfrom website.project.metadata.sch...
python
chosen
[ { "from": "human", "value": "Add a script to filter a hallofjustice csv a few ways so we can find data quality issues prior to import.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport os\nimport sys\nimport logging\nimport csv\nimport argparse\nfrom signal import signal, SIGPIPE...
python
chosen
[ { "from": "human", "value": "Add not yet working compiler\n" }, { "from": "gpt", "value": "import sys\nimport os\nimport subprocess\n\ndef compile(code):\n output = \"\"\".section .bss\n .lcomm mem, 8192\n .set startidx, mem + 4096\n.section .text\n.global _start\n_start:\n movq $0, ...
python
chosen
[ { "from": "human", "value": "Add an example for Win10 version of Calculator.\n" }, { "from": "gpt", "value": "\"\"\"\nExample script for Calculator on Windows 10\n\nRequirements:\n - Windows 10\n - pywinauto 0.6.1+\n\nWin10 version of Calculator is very specific. Few different processes (!)\no...
python
chosen
[ { "from": "human", "value": "Add negative tests about update-volume API\n\nAs the following part of API-WG guidline[1],\n\n If a request contains a reference to a nonexistent resource in the\n body (not URI), the code should be 400 Bad Request. Do not use 404\n NotFound because :rfc:`7231#section-6.5.4` (se...
python
chosen
[ { "from": "human", "value": "Convert README from markdown to RST.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n#\n# register.py\n#\n# purpose: Automagically creates a Rst README.txt\n# author: Filipe P. A. Fernandes\n# e-mail: ocefpaf@gmail\n# web: http://ocefpaf.github.io...
python
chosen
[ { "from": "human", "value": "Patch sys.modules for collectd import\n\nSo that we can test the plugin independent of collectd.\n" }, { "from": "gpt", "value": "from ..helpers import *\n\nclass TestFastly(object):\n def setup(self):\n self.collectd = MagicMock()\n self.modules = p...
python
chosen
[ { "from": "system", "value": "Allow Connection.send to take unicode message\n" }, { "from": "human", "value": "import asyncio\n\nfrom .message import Message\n\n\nclass Connection:\n \"\"\"\n Communicates with an IRC network.\n\n Incoming data is transformed into Message objects, and se...
python
chosen
[ { "from": "human", "value": "Add script to compare the error between real data and DagSim simulations\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\n## Copyright 2017 Eugenio Gianniti\n##\n## Licensed under the Apache License, Version 2.0 (the \"License\");\n## you may not use this f...
python
chosen
[ { "from": "human", "value": "Add some polynomial-related functions. These will be useful later.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nfrom sympy import Poly, legendre_poly, diff\nfrom sympy.abc import x\n\nfrom mpmath import polyroots\n\ndef gauss_legendre_points(n):\n ...
python
chosen
[ { "from": "human", "value": "Add a test for decimal declination conversion.\n" }, { "from": "gpt", "value": "\"\"\"Test code for visibilty.py.\"\"\"\n\nimport pytest\nfrom visibility import decdeg2dms, StarObsPlot, VisibilityPlot\n\n\n@pytest.mark.parametrize(\"test_input,expected\", [\n (0, ...
python
chosen
[ { "from": "human", "value": "Add command to mark users as inactive.\n\nThis is useful when testing the sigup workflow, as this script enables you\nto run through a MIT signup without manually creating a new inactive user\nin the database.\n\n(imported from commit c22649cc7c561c2fbe8682d1b17d7e5aba9ac04e)\n"...
python
chosen
[ { "from": "human", "value": "Add test to validate json of templates\n" }, { "from": "gpt", "value": "\"\"\"Test validity of json in templates\"\"\"\nimport pytest\nimport json\n\nfrom jinja2 import Template\nfrom jinja2.exceptions import TemplateNotFound\n\nfrom foremast.utils import get_templat...
python
chosen
[ { "from": "human", "value": "Add script to create probes file\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"This script create the probe specification file to match experiments.\"\"\"\n\nfrom __future__ import division, print_function\nimport numpy as np\nimport pandas as pd\n\nH...
python
chosen
[ { "from": "human", "value": "Add Gridded loader module (to be moved)\n" }, { "from": "gpt", "value": "class Gridded:\n\n _grid_obj_classes = []\n _grids_loaded = False\n\n @classmethod\n def _load_grid_objs(cls):\n from pkg_resources import working_set\n for ep in worki...
python
chosen
[ { "from": "human", "value": "Make instance a timestamped model\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nimport django.utils.timezone\nimport model_utils.fields\n\n\nclass Migration(migrations.Mi...
python
chosen
[ { "from": "human", "value": "Test the unary operator changes to the compiler\n" }, { "from": "gpt", "value": "\"\"\"Test compiler changes for unary ops (+, -, ~) introduced in Python 2.2\"\"\"\n\nimport unittest\nfrom test_support import run_unittest\n\nclass UnaryOpTestCase(unittest.TestCase):\...
python
chosen
[ { "from": "human", "value": "Add py solution for 424. Longest Repeating Character Replacement\n\n424. Longest Repeating Character Replacement: https://leetcode.com/problems/longest-repeating-character-replacement/\n" }, { "from": "gpt", "value": "from collections import Counter\nclass Solution(o...
python
chosen
[ { "from": "system", "value": "Allow doctest runner to keep going after failures\n\nIt will still return an error code, but there is little need to halt the\nrunning of the three different doctest modules if an early one fails,\nwhich may in fact mask the real reason for failure in an IPy internal\nmethod.\n...
python
chosen
[ { "from": "human", "value": "Add script to award a badge to a user\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n\"\"\"Award a badge to a user.\n\n:Copyright: 2006-2018 Jochen Kupperschmidt\n:License: Modified BSD, see LICENSE for details.\n\"\"\"\n\nimport click\n\nfrom byceps.servi...
python
chosen
[ { "from": "human", "value": "Migrate old proposal messages to new feedback.\n\nMigrate `symposion.reviews.models.ProposalMessage` objects to\n`conf_site.reviews.models.ProposalFeedback` objects.\n" }, { "from": "gpt", "value": "# Generated by Django 2.0.13 on 2019-05-13 22:09\n\nfrom django.db i...
python
chosen
[ { "from": "human", "value": "Add API test for receiver show\n\nAdd API test for receiver show\n\nChange-Id: I6d01189cdba772c1c085549a4a9838d43ce39a73\n" }, { "from": "gpt", "value": "# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compli...
python
chosen
[ { "from": "human", "value": "Add a hook for key_base to find this tool\n\nFor the dev command, really." }, { "from": "gpt", "value": "import os\nimport sys\n\n\ndef get_path(version=2014):\n '''Get the path to these shaders for stuffing into Maya envvars.'''\n\n return os.path.abspath(os.p...
python
chosen
[ { "from": "human", "value": ":memo: Add mitration file for changing ObservedSymptom field\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11 on 2017-05-29 12:35\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nimport samples.custom.m...
python
chosen
[ { "from": "human", "value": "Add a state for read an entity position in Wonderland.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# encoding=utf8\n\nfrom flexbe_core import EventState, Logger\nimport json\n\nclass Wonderland_Read_Entity_Position(EventState):\n\t'''\n\tRead the 3D posit...
python
chosen
[ { "from": "human", "value": "Add two state variable example\n" }, { "from": "gpt", "value": "import numpy as np\nimport matplotlib.pyplot as plt\nimport rsf\n\nmodel = rsf.ExternalSystem()\n\n# Set model initial conditions\nmodel.mu0 = 0.6 # Friction initial (at the reference velocity)\nmodel.a ...
python
chosen
[ { "from": "human", "value": "Add tests for existing status api client\n\nEssentially copies the tests found in the performance_platform\napi client.\n" }, { "from": "gpt", "value": "from app.notify_client.status_api_client import StatusApiClient\n\n\ndef test_get_count_of_live_services_and_organ...
python
chosen
[ { "from": "human", "value": "Add py solution for 554. Brick Wall\n\n554. Brick Wall: https://leetcode.com/problems/brick-wall/\n" }, { "from": "gpt", "value": "from collections import Counter\nclass Solution(object):\n def leastBricks(self, wall):\n \"\"\"\n :type wall: List[Lis...
python
chosen
[ { "from": "human", "value": "Add tests for data_uri module\n\nAddress reviewer comments\n" }, { "from": "gpt", "value": "import os\nimport unittest\n\nfrom node import data_uri\n\nTEST_TXT_FILE = \"data_uri_test.txt\"\nTEST_CONTENTS = \"foo\\n\"\n\nclass TestDataURI(unittest.TestCase):\n\n de...
python
chosen
[ { "from": "human", "value": "Test serialisation of infinite values\n" }, { "from": "gpt", "value": "from rdflib import Graph, Namespace, URIRef, Literal\nfrom rdflib.compare import to_isomorphic\nimport unittest\n\n\nclass TestIssueXXXX(unittest.TestCase):\n\n def test_issuexxxx(self):\n ...
python
chosen
[ { "from": "human", "value": "Add basic block tag implementation\n" }, { "from": "gpt", "value": "\nimport ast\n\nfrom .klass import build_method\nfrom .library import Library\n\nregister = Library()\n\n\ndef parse_args(bits):\n '''\n Parse tag bits as if they're function args\n '''\n ...
python
chosen
[ { "from": "human", "value": "Migrate rendered kickstarts to solve cobbler single-threading issues\n\nChange-Id: I431878dd1fbab44c5415739db1c6bb89788a5803\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport xmlrpclib\nimport logging\n\nfrom compass.utils import setting_wrapper as setting...
python
chosen
[ { "from": "system", "value": "Use META.SERVER_NAME in template view. …\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom django.contrib.auth.models import User\nfrom django.http import HttpResponse\nfrom django.views.generic.base import TemplateView\nfrom django.views.decorators.c...
python
chosen
[ { "from": "human", "value": "Add example to illustrate boundaries.\n" }, { "from": "gpt", "value": "import numpy as np\nimport matplotlib.pyplot as plt\n\nimport lulu.lulu_base as base\n\nc = base.ConnectedRegion(shape=(5,5),\n value=1, start_row=1,\n ...
python
chosen
[ { "from": "human", "value": "Add test for GeoJSON serializer\n" }, { "from": "gpt", "value": "import json\n\nfrom django.test import TestCase\nfrom django.core.serializers import serialize\n\nfrom frontend.models import PCT\nfrom api.geojson_serializer import as_geojson_stream\n\n\nclass GeoJSON...
python
chosen
[ { "from": "human", "value": "Add letter org for Brighton and Hove\n" }, { "from": "gpt", "value": "\"\"\"empty message\n\nRevision ID: 0236_another_letter_org\nRevises: 0235_add_postage_to_pk\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\nrevision = '0236_another_letter_org'\ndown_revisi...
python
chosen
[ { "from": "human", "value": "Add HTML hyperlink (<a> tag) finder/getter\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport urllib2\nfrom HTMLParser import HTMLParser\n\n# HTML Hyperlink(s) getter\nclass GetHyperlinks(HTMLParser):\n\n def __init__(self):\...
python
chosen
[ { "from": "human", "value": "Add migration for the is_draft column\n" }, { "from": "gpt", "value": "\"\"\"Add is_draft status to queries and dashboards\n\nRevision ID: 65fc9ede4746\nRevises: \nCreate Date: 2016-12-07 18:08:13.395586\n\n\"\"\"\nfrom alembic import op\nimport sqlalchemy as sa\nfro...
python
chosen
[ { "from": "human", "value": "Add tests for equilibrium profiles.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Nov 5 09:44:38 2015\n\n@author: jensv\n\"\"\"\n\nimport numpy as np\nimport numpy.testing as test\nimport scipy.integrate as integrate\nimport equil_...
python
chosen
[ { "from": "human", "value": "Implement a post gen python script to rename the kv file\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"Rename the generated kv file to be compatible with the original kivy kv file\ndetection of `App.load_kv`.\n\"\"\"\n\nimpo...
python
chosen
[ { "from": "human", "value": "Revert \"Revert \"Revert \"Revert \"Added the number assignment test for numeric.\"\"\"\"\n\nThis reverts commit 91151bc6fd2c48c83656452e7c8f8f7e8b7b4218.\n" }, { "from": "gpt", "value": "from __future__ import absolute_import, print_function\n\nfrom random import ra...
python
chosen
[ { "from": "human", "value": "Add python script to take image frame from live camera feed\n" }, { "from": "gpt", "value": "#Import needed libraries\nimport numpy as np\nimport cv2\n\ncap=cv2.VideoCapture(0)\n\ni=0\nret=True\nwhile(i<1):\n\n ret, frame =cap.read()\n# print(\"Camera is still runn...
python
chosen
[ { "from": "human", "value": "Add a basic runner program\n\nIt just lists validations right now. Ultimately it will run them and\npotentially provide a HTTP API.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport sys\nimport glob\n\ndef die(msg):\n print msg\n sys.exit(1)\n\nd...
python
chosen
[ { "from": "human", "value": "INFRA-6746: Add dedicated server monitoring modulec\n\n- Then you can add or remove OVH monitoring\n" }, { "from": "gpt", "value": "#!/usr/bin/python\nfrom __future__ import (absolute_import, division, print_function)\n__metaclass__ = type\n\nfrom ansible.module_uti...
python
chosen
[ { "from": "human", "value": "Add node log migration script for branded preprints\n" }, { "from": "gpt", "value": "import sys\nimport logging\n\nfrom website.app import init_app\nfrom website.models import NodeLog, PreprintService\nfrom scripts import utils as script_utils\nfrom modularodm import...
python
chosen
[ { "from": "human", "value": "Add migration for UserProfile.user's change to OneToOneField\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nfrom django.conf import settings\n\n\nclass Migration(migration...
python
chosen
[ { "from": "human", "value": "Add ROSEdu chat logs script\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python3\nimport requests\nfrom datetime import datetime, timedelta\n\nurl = \"http://data.softwareliber.ro/irc-logs/%23rosedu/%23rosedu.{0:02d}-{1:02d}-{2}.log\"\n\nnow = datetime.now()\nye...
python
chosen
[ { "from": "system", "value": "Add missing package requirement of argparse.\n" }, { "from": "human", "value": "#!/usr/bin/env python\nfrom setuptools import setup, find_packages\nfrom cron_sentry.version import VERSION\n\nsetup(\n name='cron-sentry',\n version=VERSION,\n author='Yipit Co...
python
chosen
[ { "from": "human", "value": "Add a state listing all entities in a room\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# encoding=utf8\n\nfrom flexbe_core import EventState, Logger\nimport json\n\n\nclass Wonderland_Objects_In_A_Room(EventState):\n\t'''\n\tReturn all objects in a room\n...
python
chosen
[ { "from": "human", "value": "Add solution to challenge 2.\n" }, { "from": "gpt", "value": "import base64\n\ndef fixed_xor(hex_a, hex_b):\n decoded_a = base64.b16decode(hex_a, True)\n decoded_b = base64.b16decode(hex_b, True)\n xor_result = [chr(ord(a) ^ ord(b)) for a, b in zip(decoded_a...
python
chosen
[ { "from": "human", "value": "Add Android test runner script for WebRTC.\n\nThe Android test execution toolchain scripts in Chromium\nhas been causing headaches for us several times. Mostly\nbecause they're tailored at running Chrome tests only.\n\nWrapping their script in our own avoids the pain of\nupstrea...
python
chosen
[ { "from": "human", "value": "Add mgmt command for refreshing cached geometries\n" }, { "from": "gpt", "value": "#\n# Copyright 2012-2014 John Whitlock\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# Yo...
python
chosen
[ { "from": "human", "value": "Check in my script for creating test IDs\n\n[skip ci]\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- encoding: utf-8 -*-\n\"\"\"\nCreates an identifier in the same scheme as the ID minter.\n\nUseful for creating test IDs.\n\nABSOLUTELY NOT FOR PRODUCTI...
python
chosen
[ { "from": "human", "value": "Add tests for output as bytes and testing that the host line is second\n" }, { "from": "gpt", "value": "from django.test import TestCase\n\nfrom revproxy import connection\n\n\nclass TestOutput(TestCase):\n\n def setUp(self):\n self.connection = connection....
python
chosen
[ { "from": "human", "value": "Add unit tests for package component form [WAL-450]\n" }, { "from": "gpt", "value": "from django.test import TestCase\n\nfrom .. import factories\nfrom ... import admin, models\n\n\nclass TestPackageComponentForm(TestCase):\n\n def test_package_component_form_is_v...
python
chosen
[ { "from": "human", "value": "Solve problem 2 in Python\n" }, { "from": "gpt", "value": "def is_palindrome(number):\n\n reversed_number = 0\n n = number\n\n while(n):\n reversed_number = reversed_number * 10 + (n % 10)\n #print(\"reversed_number:\", reversed_number)\n n //= 10\n #p...
python
chosen
[ { "from": "human", "value": "Add a benchmark for measuring start up delays of lldb, including:\n\no create a fresh target; and\no set the first breakpoint\n\nExample (using lldb to set a breakpoint on lldb's Driver::MainLoop function):\n\n./dotest.py -v +b -x '-F Driver::MainLoop()' -p TestStartupDelays.py\...
python
chosen
[ { "from": "human", "value": "Add script to reproduce custom TAS dump\n" }, { "from": "gpt", "value": "import os\nimport pickle\nfrom collections import defaultdict\nfrom indra.sources import tas\nfrom indra.databases import drugbank_client\n\n\ndef normalize_drug(drug):\n flags = score_drug(d...
python
chosen
[ { "from": "human", "value": "Add unit tests for queue_two_stacks\n" }, { "from": "gpt", "value": "import unittest\n\nfrom aids.stack.queue_two_stacks import QueueUsingTwoStacks\n\nclass QueueTwoStacksTestCase(unittest.TestCase):\n '''\n Unit tests for the Queue data structure implemented u...
python
chosen
[ { "from": "human", "value": "Validate qingcloud defaults to verifying SSL\n" }, { "from": "gpt", "value": "import copy\n\nfrom salt.cloud.clouds import qingcloud\nfrom tests.support.mixins import LoaderModuleMockMixin\nfrom tests.support.mock import MagicMock, patch\nfrom tests.support.unit impo...
python
chosen
[ { "from": "human", "value": "Add utility for copying clifiles when new points are needed." }, { "from": "gpt", "value": "\"\"\"Utility script that copies neighboring clifiles when it is discovered\nthat we need new ones!\"\"\"\nimport psycopg2\nimport os\nimport sys\nimport shutil\n\n\ndef missi...
python
chosen
[ { "from": "human", "value": "Add directory for tests of removing unit rules\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\n:Author Patrik Valkovic\n:Created 24.08.2017 11:32\n:Licence GNUv3\nPart of grammpy-transforms\n\n\"\"\"" } ]
python
chosen
[ { "from": "human", "value": "Add missing tests for rally/cmd/manage.py\n\nChange-Id: Id0e6659b957a346ab7d9aed4ff295e61f7eed515\n" }, { "from": "gpt", "value": "# Copyright 2013: Mirantis Inc.\n# All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you m...
python
chosen
[ { "from": "human", "value": " Remove commons.request.\n Tests are now mocking flask_restful.request module.\n" }, { "from": "gpt", "value": "from grapher import commons, errors\nfrom grapher.repositories.base import EntityRepository\n\n\nclass CachedRepository(EntityRepository):\n data = {}\n...
python
chosen
[ { "from": "human", "value": "Add data migration for settings and logs\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\ndef convert_logs(apps, schema_editor):\n '''\n Adds a unit to users who h...
python
chosen
[ { "from": "human", "value": "Add first version of the Effects base class\n" }, { "from": "gpt", "value": "\nclass Effects:\n def attack(self, player, dices):\n pass\n\n def defend(self, player, dmg, dodge):\n pass\n\n def dispute(self, player, attrName):\n pass\n" ...
python
chosen
[ { "from": "human", "value": "Add factory for Submission model\n" }, { "from": "gpt", "value": "import factory\nfrom factory import fuzzy\n\nfrom datetime import date, datetime, timezone\n\nfrom dataactcore.models import jobModels\n\n\nclass SubmissionFactory(factory.Factory):\n class Meta:\n ...
python
chosen
[ { "from": "human", "value": "Add support for Euclidean distance\n" }, { "from": "gpt", "value": "from math import sqrt\nfrom .distance_abstract import DistanceAbstract\n\n\nclass EuclideanDistance(DistanceAbstract):\n def measure(cls, list1, list2):\n distance = 0\n min_len = mi...
python
chosen
[ { "from": "human", "value": "Revert \"Got rid of tuples\"\n\nThis reverts commit 958ab35bcf408502f1347db5720241c489de8260.\n" }, { "from": "gpt", "value": "import string\nimport sklearn\nimport numpy as np\nfrom titleParse import *\nimport os\nfrom sklearn import svm\nimport re\nfrom featureHelp...
python
chosen
[ { "from": "human", "value": "Add a 15/1 bit codec.\n" }, { "from": "gpt", "value": "\ndef encode(x):\n \"encode an integer using a 15-bit+continuation-bit encodeing\"\n r = []\n while True:\n r.append(x & 32767)\n x >>= 15\n if x == 0:\n break\n r = r[...
python
chosen
[ { "from": "human", "value": "Add script for adding/updating RTP launch records\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- mode: python; coding: utf-8 -*-\n# Copyright 2021 The HERA Collaboration\n# Licensed under the 2-clause BSD license.\n\nimport numpy as np\nfrom astropy.ti...
python
chosen
[ { "from": "human", "value": "Add helper module for tests\n\nCurrently the module contains a base class for all quilt tests.\n" }, { "from": "gpt", "value": "# vim: fileencoding=utf-8 et sw=4 ts=4 tw=80:\n\n# python-quilt - A Python implementation of the quilt patch system\n#\n# Copyright (C) 201...
python
chosen
[ { "from": "human", "value": "[All] Add a simple multiple-window example\n" }, { "from": "gpt", "value": "import webview\nimport threading\n\n\"\"\"\nThis example demonstrates how to create and manage multiple windows\n\"\"\"\n\ndef create_new_window():\n # Create new window and store its uid\...
python
chosen
[ { "from": "human", "value": "Add calculator for uts tree size\n\ngit-svn-id: 0c5512015aa96f7d3f5c3ad598bd98edc52008b1@12008 dc4e9af1-7f46-4ead-bba6-71afc04862de\n" }, { "from": "gpt", "value": "\n# Estimate number of nodes for geometric uts with linear shape\n\nb_0 = 4.0\ngen_mx = 22\n\n# level ...
python
chosen
[ { "from": "human", "value": "testsuite: Add tests for thesaurus bot in contrib_bots.\n\nAdd test file 'test_thesaurus.py'.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom __future__ import absolute_import\nfrom __future__ import print_function\n\nimport os\nimport sys\n\nour_dir =...
python
chosen
[ { "from": "human", "value": "Add 0049 - ProviderConfiguration migration+RunPython\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\ndef create_provider_configuration(apps, schema_editor):\n Provider...
python
chosen
[ { "from": "human", "value": "Add a script to call for allocation result externally\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nfrom django import setup\nsetup()\nfrom service.monitoring import get_allocation_result_for\nfrom core.models import Identity, Instance, AtmosphereUser\nfrom...
python
chosen
[ { "from": "human", "value": "Solve Largest Palindrome Product with brute force (Time Limit Exceeded)\n" }, { "from": "gpt", "value": "# Find the largest palindrome made from the product of two n-digit numbers.\n\n# Since the result could be very large, you should return the largest palindrome mo...
python
chosen
[ { "from": "human", "value": "Add missed migration for 12d09f5.\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 ('people', '00...
python
chosen
[ { "from": "human", "value": "Test ICDS login doesn't 500\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\nfrom django.test import TestCase\nfrom django.test.utils import override_settings\nfrom django.urls import reverse\n\n\nclass TestViews(TestCase):\n @override_sett...
python
chosen