conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Implement cheb_dif for getting 1D chebyshev grids and differentiation matrices.\n" }, { "from": "gpt", "value": "import numpy as np\nfrom numpy.fft import fft, ifft, fftshift, fft2, ifft2\nfrom scipy.linalg import toeplitz\n\nclass FourierChebyshevSpatialDiscretizati...
python
chosen
[ { "from": "human", "value": "Add a (bad) example of missing method.\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\n\n\"\"\"Send an invalid request with missing method member.\"\"\"\n\nfrom simpleclient import send_data_to_socket\n\nEXAMPLE = {\n \"params\": {\n \"filter\": {\n ...
python
chosen
[ { "from": "human", "value": "Add py solution for 384. Shuffle an Array\n\n384. Shuffle an Array: https://leetcode.com/problems/shuffle-an-array/\n" }, { "from": "gpt", "value": "from random import randint\nclass Solution(object):\n\n def __init__(self, nums):\n \"\"\"\n :type nu...
python
chosen
[ { "from": "human", "value": "Add ClamAV script to analyze HTTPS traffic for viruses\n" }, { "from": "gpt", "value": "import pyclamd\nfrom libmproxy.flow import decoded\n\n#http://www.eicar.org/85-0-Download.html\n\nclamd = pyclamd.ClamdUnixSocket()\ntry:\n # test if server is reachable\n c...
python
chosen
[ { "from": "system", "value": "Fix race between MQ and mongo setting QueuedAt" }, { "from": "human", "value": "from tapiriik.database import db\nfrom tapiriik.messagequeue import mq\nfrom tapiriik.sync import Sync\nfrom datetime import datetime\nfrom pymongo.read_preferences import ReadPreference...
python
chosen
[ { "from": "human", "value": "Add a mobile device test of the Skype website\n" }, { "from": "gpt", "value": "\"\"\"\nThis is a mobile device test for Chromium-based browsers (such as MS Edge)\nUsage: pytest test_skype_site.py --mobile --browser=edge\n\nDefault mobile settings for User Agent and ...
python
chosen
[ { "from": "human", "value": "Add another .py file for progress bar\n\nAdd another .py file for progress bar" }, { "from": "gpt", "value": "import sys, time\r\nfrom CmdFormat import CmdFormat\r\n\r\nclass ProgressBar(CmdFormat):\r\n def __init__(self, count = 0, total = 0, width = 80, bWithhea...
python
chosen
[ { "from": "human", "value": "Add new provider migration for osf registrations\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.7 on 2016-07-08 16:17\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nimport share.robot\n\n\nclass Migr...
python
chosen
[ { "from": "human", "value": "Create command for generating prices for flavors\n\n - itacloud-5319\n" }, { "from": "gpt", "value": "from __future__ import unicode_literals\n\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.core.management.base import BaseCommand\n\nfrom no...
python
chosen
[ { "from": "human", "value": "Add work-in-progress script to fixup a standalone plugin library.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport subprocess\nimport os\n\nplugin = 'libVelodyneHDLPlugin.dylib'\nparaviewBuildDir = '/source/paraview/build'\n\nnameprefix = '@executable...
python
chosen
[ { "from": "human", "value": "Migrate data from contact_for_research_via and into contact_for_research_methods many to many field\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nfrom django.db.models import Q\n...
python
chosen
[ { "from": "human", "value": "Add test to check if elements have at least one owner\n" }, { "from": "gpt", "value": "\"\"\"\nFor all relevant model elements, check if there is at least one \"owner\"\n(\"owner\" is a derived union).\n\nThis is needed to display all elements in the tree view.\n\"\"...
python
chosen
[ { "from": "human", "value": "Add tests for simple enums\n" }, { "from": "gpt", "value": "import unittest\nfrom richenum import EnumConstructionException, enum\n\n\nBreakfast = enum(\n COFFEE=0,\n OATMEAL=1,\n FRUIT=2)\n\n\nclass SimpleEnumTestSuite(unittest.TestCase):\n\n def test_me...
python
chosen
[ { "from": "human", "value": "Add test that, if we failed to open the log file, we don't try to write to it.\n" }, { "from": "gpt", "value": "\"\"\"Test IPython.core.logger\"\"\"\n\nimport nose.tools as nt\n\n_ip = get_ipython()\n\ndef test_logstart_inaccessible_file():\n try:\n _ip.log...
python
chosen
[ { "from": "human", "value": "Create existing comments' owners records\n" }, { "from": "gpt", "value": "# Copyright (C) 2016 Google Inc., authors, and contributors <see AUTHORS file>\n# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>\n# Created By: peter@reciprocityla...
python
chosen
[ { "from": "human", "value": "Add new image moments functions\n" }, { "from": "gpt", "value": "# Licensed under a 3-clause BSD style license - see LICENSE.rst\nfrom __future__ import (absolute_import, division, print_function,\n unicode_literals)\n\nimport numpy as np\n\nfr...
python
chosen
[ { "from": "human", "value": "Add first unit test for api\n" }, { "from": "gpt", "value": "import os\nimport sys\nimport json\nimport responses\nimport unittest\n\nCWD = os.path.dirname(os.path.abspath(__file__))\nMS_WD = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n\n# Allow impo...
python
chosen
[ { "from": "human", "value": "Fix ProgramEditor permissions to not include Program delete\n" }, { "from": "gpt", "value": "\n\"\"\"Fix ProgramEditor permissions\n\nRevision ID: 10adeac7b693\nRevises: 8f33d9bd2043\nCreate Date: 2013-10-10 00:12:57.391754\n\n\"\"\"\n\n# revision identifiers, used b...
python
chosen
[ { "from": "human", "value": "Add a test to validate the user creation\n" }, { "from": "gpt", "value": "# coding: utf-8\n\nfrom django.core.urlresolvers import reverse\nfrom django.test import TestCase\nfrom rest_framework import status\nfrom rest_framework.test import APIClient\n\nfrom ..models ...
python
chosen
[ { "from": "human", "value": "Add test for auth service pre-run time validation checks.\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 informat...
python
chosen
[ { "from": "human", "value": "Add test (which we fail at the moment)\n" }, { "from": "gpt", "value": "import os\n\nimport bugimporters.main\nfrom mock import Mock\n\n\nHERE = os.path.dirname(os.path.abspath(__file__))\n\n# Create a global variable that can be referenced both from inside tests\n# ...
python
chosen
[ { "from": "human", "value": "Create RequestHandler related to GCI.\n\n--HG--\nextra : rebase_source : 2b29958cb5939f0ea5b52fac58c7d18d7716299b\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2.5\n#\n# Copyright 2011 the Melange authors.\n#\n# Licensed under the Apache License, Version 2.0 ...
python
chosen
[ { "from": "human", "value": "Test for switching to postgres search backend\n" }, { "from": "gpt", "value": "from wolis.test_case import WolisTestCase\n\nclass SearchBackendPostgresTest(WolisTestCase):\n def test_set_search_backend(self):\n self.login('morpheus', 'morpheus')\n se...
python
chosen
[ { "from": "human", "value": "Migrate existing platform admin services to not be counted\n\nIf a service has been created by someone on our team, it’s probably a\ntest service, which shouldn’t be included in the count of live services.\n\nThis commit adds a migration to do this for existing services.\n" },...
python
chosen
[ { "from": "human", "value": "Test with many envs and large groups\n" }, { "from": "gpt", "value": "# Copyright (c) 2012 Lars Hupfeldt Nielsen, Hupfeldt IT\n# All rights reserved. This work is under a BSD license, see LICENSE.TXT.\n\nfrom .. import ConfigRoot\nfrom ..envs import EnvFactory\n\nef ...
python
chosen
[ { "from": "human", "value": "Make permission name more consistent.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.1 on 2016-10-15 15:36\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n...
python
chosen
[ { "from": "human", "value": "Add tests for artist serializers\n" }, { "from": "gpt", "value": "from unittest import TestCase\n\nfrom ..models import Artist, Hyperlink\nfrom ..serializers import ArtistSerializer, HyperlinkSerializer\n\n\nclass HyperlinkSerializerTest(TestCase):\n\n \"\"\"Tests...
python
chosen
[ { "from": "human", "value": "Add ex2.2: multiple simple requests\n" }, { "from": "gpt", "value": "from urllib.request import urlopen\nimport time\n\nURLS = [\n 'http://127.0.0.1:8000',\n 'http://127.0.0.1:8000',\n 'http://127.0.0.1:8000',\n]\n\ndef request_greetings():\n responses = ...
python
chosen
[ { "from": "human", "value": "Add outputter to display overstate stages\n" }, { "from": "gpt", "value": "'''\nDisplay clean output of an overstate stage\n'''\n\n\n#[{'group2': {'match': ['fedora17-2', 'fedora17-3'],\n# 'require': ['group1'],\n# 'sls': ['nginx', 'edit']}\n#...
python
chosen
[ { "from": "system", "value": "Fix SpiderState bug in Windows platforms\n\nThe spider state file was not opened in binary mode.\n" }, { "from": "human", "value": "import os, cPickle as pickle\n\nfrom scrapy import signals\n\nclass SpiderState(object):\n \"\"\"Store and load spider state during...
python
chosen
[ { "from": "human", "value": "Add Sin, Cos and Tan function classes\n" }, { "from": "gpt", "value": "import function\nimport math\n\n\nclass Sin(function.Function):\n\n def _evaluate(self, x):\n return math.sin(x)\n\n\nclass Cos(function.Function):\n\n def _evaluate(self, x):\n ...
python
chosen
[ { "from": "human", "value": "Add script for populating elasticsearch.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport os\nimport sys\nimport json\nimport requests\nimport multiprocessing\nimport mwparserfromhell as mwp\n\nES_URL = 'http://localhost:9200'\n\nSECTIONS_TO_REMOVE = ...
python
chosen
[ { "from": "human", "value": "DOC: Add an example for HybridContentsManager.\n" }, { "from": "gpt", "value": "# This example shows how to configure Jupyter/IPython to use the more complex\n# HybridContentsManager.\n\n# A HybridContentsManager implements the contents API by delegating requests to\...
python
chosen
[ { "from": "human", "value": "Add script to automate notebooks testing\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\n'''\nChecks notebook execution result.\nEqual to this command + error management:\njupyter nbconvert --to notebook --execute --ExecutePreprocessor.timeout=60 --outp...
python
chosen
[ { "from": "human", "value": "Add missing module for merge script\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n# coding=utf-8\n\nimport subprocess\n\nclass DiffMatcher(object):\n \n def __init__(self, listA, listB):\n self.listA = listA\n self.listB = listB\n\n\n def...
python
chosen
[ { "from": "human", "value": "Make start of ongoing and deadline activities just a date\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.17 on 2020-10-23 12:43\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migra...
python
chosen
[ { "from": "human", "value": "Add migration to populate Broadcast.base_language\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom collections import defaultdict\nfrom django.db import migrations\nfrom temba.utils import chunk_list\n\n\ndef d...
python
chosen
[ { "from": "human", "value": "Add needed track known class.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python \n'''\n@author jstober\n\nSimple class to track knowledge of states and actions. Based on \n\nL. Li, M. L. Littman, and C. R. Mansley, “Online exploration in least-squares policy ite...
python
chosen
[ { "from": "human", "value": "Add helper method for execute a commands\n" }, { "from": "gpt", "value": "\"\"\"Update conda packages on binstars with latest versions\"\"\"\nimport os\nimport six\nimport subprocess\nimport time\n\nATTEMPTS = 3\nRETRY_INTERVAL = 0.1\n\n\ndef execute(command, **kwarg...
python
chosen
[ { "from": "human", "value": "Add migration for index on departement\n" }, { "from": "gpt", "value": "\"\"\"Add index on Departement for numero\n\nRevision ID: 75704b2e975e\nRevises: 34c2049aaee2\nCreate Date: 2019-10-22 17:27:10.925104\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\nrevis...
python
chosen
[ { "from": "human", "value": "Add some Feed test cases\n" }, { "from": "gpt", "value": "from tw.api import Widget\nfrom moksha.feed import Feed\n\nclass TestFeed(object):\n\n def test_feed_subclassing(self):\n class MyFeed(Feed):\n url = 'http://lewk.org/rss'\n feed = ...
python
chosen
[ { "from": "human", "value": "Make non-commtrack location types administrative\n" }, { "from": "gpt", "value": "# One-off migration from 2016-04-04\nfrom optparse import make_option\nfrom time import sleep\nfrom django.core.management.base import BaseCommand\nfrom corehq.apps.locations.models imp...
python
chosen
[ { "from": "human", "value": "Add first version of Day One entry splitter\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# encoding: utf-8\n\"\"\"\nday_one_entry_splitter.py\n\nCreated by Rod Docking on 2017-01-01.\nAll rights reserved.\n\"\"\"\n\nimport sys\n\n\ndef main():\n \"\"\"S...
python
chosen
[ { "from": "human", "value": "Add example of using lower-level plotting methods directly\n" }, { "from": "gpt", "value": "\"\"\"\nExample of how `ax.scatter` can be used to plot linear data on a stereonet\nvarying color and/or size by other variables.\n\nThis also serves as a general example of h...
python
chosen
[ { "from": "system", "value": "progess: Introduce base class and ProgressObserver for renaming occurences.\n" }, { "from": "human", "value": "# Copyright 2008-2009 Nokia Siemens Networks Oyj\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file ex...
python
chosen
[ { "from": "human", "value": "Test passed for week day\n" }, { "from": "gpt", "value": "(day, month, year) = input().split()\n\nday = int(day); month = int(month); year = int(year)\n\nif month < 3:\n month += 12\n year -= 1\n\nc = year / 100\nk = year % 100\nweek_day = int( day + (26 * (mon...
python
chosen
[ { "from": "human", "value": "Add Notify-osd option for linux based systems\n" }, { "from": "gpt", "value": "from __future__ import unicode_literals, division, absolute_import\nimport logging\n\nfrom flexget.plugin import register_plugin, priority, DependencyError\nfrom flexget.utils.template imp...
python
chosen
[ { "from": "human", "value": "Call the new presubmit checks from chrome/ code, with a blacklist.\n\nReview URL: http://codereview.chromium.org/400014\n\ngit-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@32190 0039d316-1c4b-4281-b951-d872f2087c98\n" }, { "from": "gpt", "value": "# Copyright (c)...
python
chosen
[ { "from": "human", "value": "Create migration for draft dos1 briefs to dos2\n\nWhen DOS1 is closed for brief submissions and DOS2 opened, any supplier\nwho has a draft DOS1 brief will effectively lose it, as they'll be\nunable to publish it.\n\nThis migration will move all draft DOS1 briefs to be draft DOS2...
python
chosen
[ { "from": "human", "value": "Add 2 instance with EBS test.\n\nSeems to work even.\n\nChange-Id: Ie09d97dc86a68525783f1f9c080fed13e651ef78\nSigned-off-by: Ian Main <87edab3227c32093d388ed00258c1a5e63cfd715@redhat.com>\n" }, { "from": "gpt", "value": "# vim: tabstop=4 shiftwidth=4 softtabstop=4\n#...
python
chosen
[ { "from": "human", "value": "Add a help script to clear the test bucket\n" }, { "from": "gpt", "value": "import os\nfrom qiniu import Auth, BucketManager\n\n\nQINIU_ACCESS_KEY = os.environ.get('QINIU_ACCESS_KEY')\nQINIU_SECRET_KEY = os.environ.get('QINIU_SECRET_KEY')\nQINIU_BUCKET_NAME = os.envi...
python
chosen
[ { "from": "human", "value": "Add a test for the status server\n" }, { "from": "gpt", "value": "import os\nimport select\nimport socket\nimport time\nimport unittest\n\nfrom jobmon.protocol import *\nfrom jobmon import protocol, status_server, transport\n\nPORT = 9999\n\nclass StatusRecorder:\n ...
python
chosen
[ { "from": "human", "value": "Add a test for main\n\nMore to follow\n" }, { "from": "gpt", "value": "from git_lang_guesser import main\nfrom git_lang_guesser import git_requester\n\n\nLANGUAGE = \"language\"\n\ntest_username = \"TestUser\"\nexample_data = [\n {LANGUAGE: \"HTML\"},\n {LANGUA...
python
chosen
[ { "from": "system", "value": "Fix conditional dependencies when using wheels\n\nsee also:\nhttps://github.com/nephila/djangocms-blog/pull/80\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom setuptools import setup\nfrom djangocms_link import __version__\n\n...
python
chosen
[ { "from": "human", "value": "Fix variable referenced before assginment in vmwareapi code.\n\nAdd unitests for VMwareapi vm_util.\nfix bug #1177689\n\nChange-Id: If16109ee626c197227affba122c2e4986d92d2df\n" }, { "from": "gpt", "value": "# vim: tabstop=4 shiftwidth=4 softtabstop=4\n#\n# Copyright ...
python
chosen
[ { "from": "human", "value": "Add script for automatically updating schemas\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport os\nimport re\nimport sys\nimport subprocess as sp\n\n\ndef get_schemas(pattern):\n\n cmd = ['git', 'grep', '--name-only']\n output = sp.check_output(...
python
chosen
[ { "from": "human", "value": "Verify computer executing the script is of OS X 10.6.1 or higher type\n" }, { "from": "gpt", "value": "import platform\n\n\nclass OSXDodger(object):\n allowed_version = \"10.12.1\"\n\n def __init__(self, applications_dir):\n self.app_dir = applications_d...
python
chosen
[ { "from": "human", "value": "Add python script to get coordinates from the csv\n" }, { "from": "gpt", "value": "#! /bin/python3\n\nimport csv\nimport time\nfrom geopy.geocoders.googlev3 import GoogleV3\n\ngeocoder = GoogleV3(api_key=\"AIzaSyAy6XiyZG-6u99q-qacOz-dtT9ILbYzb-4\")\nwith open(\"../Re...
python
chosen
[ { "from": "human", "value": "Add mgmt cmd to fix bad loc-type references\n" }, { "from": "gpt", "value": "from optparse import make_option\n\nfrom django.core.management.base import BaseCommand\n\nfrom corehq.apps.locations.models import SQLLocation, LocationType\n\n\nclass Command(BaseCommand):...
python
chosen
[ { "from": "human", "value": "Add Event class as well as connect and fire methods.\n" }, { "from": "gpt", "value": "class Event:\n def __init__(self):\n self.listeners = []\n\n def connect(self, listener):\n self.listeners.append(listener)\n\n def fire(self, *args, **kwargs...
python
chosen
[ { "from": "human", "value": "Add vanilla sequential face detection example.\n" }, { "from": "gpt", "value": "\"\"\"Sequential, vanilla face detection.\"\"\"\n\nimport datetime\nimport sys\nimport cv2\nimport numpy as np\n\nimport util\nimport cascade\n\nDEVICE = int(sys.argv[1])\nWIDTH = in...
python
chosen
[ { "from": "human", "value": "Create a new file to calculate features from sets of points\n" }, { "from": "gpt", "value": "# Standard imports\nimport math\nimport logging\nimport numpy as np\nimport emission.core.common as ec\n\ndef calSpeed(point1, point2):\n distanceDelta = ec.calDistance([p...
python
chosen
[ { "from": "human", "value": "Add first test for update_language_list function\n" }, { "from": "gpt", "value": "# test_update_language_list\n\nfrom __future__ import unicode_literals\n\nimport json\nimport os\nimport os.path\n\nimport nose.tools as nose\n\nimport yvs.shared as yvs\nimport utiliti...
python
chosen
[ { "from": "human", "value": "Add example of multi-layer chart\n" }, { "from": "gpt", "value": "\"\"\"\nMultiple Marks\n==============\nThis example demonstrates creating a single chart with multiple markers\nrepresenting the same data.\n\"\"\"\nimport altair as alt\nfrom vega_datasets import dat...
python
chosen
[ { "from": "human", "value": "ADD FEATURE : simple C/C++ compiler\n" }, { "from": "gpt", "value": "from apps.decorators import on_command\nfrom apps.slackutils import cat_token\nfrom subprocess import check_output, CalledProcessError, STDOUT\nimport os\nimport re\n\n\n@on_command(['!컴파일'])\ndef r...
python
chosen
[ { "from": "human", "value": "Add tests for action groups.\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\n\nfrom traits.testing.unittest_tools import UnittestTools, unittest\n\nfrom ...image_cache import ImageCache\nfrom ...window import Window\nfrom ..action import Acti...
python
chosen
[ { "from": "human", "value": "Add post-hook to handle the difference between project name and role name.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport os\n\n# Use symlink to handle the difference between project name and role name.\nos.symlink('../../{{...
python
chosen
[ { "from": "human", "value": "Add python script for calculating fuel pitch fraction.\n" }, { "from": "gpt", "value": "import sympy as sp\nimport sys\n\n\ndef calc_spacing(R, n):\n x = sp.symbols('x')\n Af = 0\n Am = 0\n for m in range(2*n - 1):\n if m % 2 == 0:\n Af ...
python
chosen
[ { "from": "human", "value": "Add the IPython version helper\n" }, { "from": "gpt", "value": "from __future__ import (division, print_function, absolute_import,\n unicode_literals)\n\nfrom IPython import version_info\n\n\ndef ipython_version_as_string():\n \"\"\"\n Th...
python
chosen
[ { "from": "human", "value": "Add clustering metrics calculator file.\n" }, { "from": "gpt", "value": "\"Calculates Silhouette coefficient and Calinski-Harabaz index for a kmeans model.\"\nimport os, sys\nimport argparse, joblib\nfrom sklearn import metrics\n\ndef cluster_metrics(data_file_path):...
python
chosen
[ { "from": "human", "value": "Policy: Add new users to all deployments\n" }, { "from": "gpt", "value": "from core.models import *\n\ndef handle(user):\n\tdeployments = Deployment.objects.all()\n\tsite_deployments = SiteDeployments.objects.all()\n\tsite_deploy_lookup = defaultdict(list)\n\tfor sit...
python
chosen
[ { "from": "human", "value": "Add helper to run requested Python script\n" }, { "from": "gpt", "value": "import pyseidon\nimport sys\n\ndef handle_script():\n import runpy\n \"\"\"\nAllow the client to run an arbitrary Python script.\n\nHere's sample usage:\n\n```\ndef expensive_setup():\n ...
python
chosen
[ { "from": "human", "value": "Add initial block list for ad_block functionality\n" }, { "from": "gpt", "value": "\"\"\"\nFor use with SeleniumBase ad_block functionality.\n\nUsage:\n On the command line:\n \"pytest SOME_TEST.py --ad_block\"\n\n From inside a test:\n self.ad_block()\n\...
python
chosen
[ { "from": "human", "value": "Add a small tool to answer questions like \"Why does target A depend on target B\".\n\nBUG=none\nTEST=none\n\nReview URL: http://codereview.chromium.org/8672006\n\ngit-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@111430 0039d316-1c4b-4281-b951-d872f2087c98\n" }, { "f...
python
chosen
[ { "from": "human", "value": "[New] :: Check if a given sequence of moves for a robot is circular or not (py)\n" }, { "from": "gpt", "value": "from operator import add\nimport math\n\nmoves = raw_input(\"Enter the moves: \")\n\nstart_position = [0,0]\ncurrent_position = [0,0]\n\n'''\nheading = [1...
python
chosen
[ { "from": "human", "value": "Add plot of days per year with precip" }, { "from": "gpt", "value": "import matplotlib\nmatplotlib.use('agg')\nimport matplotlib.pyplot as plt\nimport psycopg2.extras\nimport pyiem.nws.vtec as vtec\nfrom pyiem.network import Table as NetworkTable\nimport numpy as np\...
python
chosen
[ { "from": "system", "value": "Fix the versioned Django, we're grabbing 1.4.1 off the requirements.txt\n" }, { "from": "human", "value": "#!/usr/bin/env python\nfrom setuptools import setup, find_packages\nfrom billy import __version__\n\nlong_description = open('README.rst').read()\n\nsetup(name...
python
chosen
[ { "from": "system", "value": "Replace list-to-set cast with normal set literal\n\nDon't know who did this but he did wrong, yo.\n" }, { "from": "human", "value": "# Copyright (c) 2016 Ultimaker B.V.\n# Uranium is released under the terms of the AGPLv3 or higher.\n\nfrom UM.Settings.Models.Settin...
python
chosen
[ { "from": "human", "value": "Add a Tasks sample that demonstrates Service accounts.\n\nReviewed in http://codereview.appspot.com/5685068/.\n\nIndex: samples/service_account/books.py\n===================================================================\nnew file mode 100644\n" }, { "from": "gpt", ...
python
chosen
[ { "from": "human", "value": "Test fail cases for custom codegen\n" }, { "from": "gpt", "value": "import pytest\n\nfrom numba import boolean, njit, int64, TypingError\nfrom slumba.numbaext import not_null, sizeof, unsafe_cast\n\n\ndef test_sizeof_invalid():\n dec = njit(int64(int64))\n\n wi...
python
chosen
[ { "from": "human", "value": "Add the serial python test\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom serial import Serial\nfrom time import sleep\n\nser = Serial('/dev/ttyUSB0', 9600)\nsleep(3) # wait for the board to reset\n\nprint \"start\"\nprint \"write\"\nser.write(\"hello...
python
chosen
[ { "from": "human", "value": "Remove the IR target type in migration.\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 = [('auvsi_suas', '00...
python
chosen
[ { "from": "system", "value": "Fix import error when [jwt] not installed.\n" }, { "from": "human", "value": "# coding: utf-8\n\nfrom __future__ import unicode_literals\n\nfrom .auth.jwt_auth import JWTAuth\nfrom .auth.oauth2 import OAuth2\nfrom .client import Client\nfrom .object import * # pyli...
python
chosen
[ { "from": "human", "value": "Add initializer for top-level '_gcloud_vendor' package.\n" }, { "from": "gpt", "value": "\"\"\"Dependencies \"vendored in\", due to dependencies, Python versions, etc.\n\nCurrent set\n-----------\n\n``apitools`` (pending release to PyPI, plus acceptable Python ver...
python
chosen
[ { "from": "system", "value": "Update test to load plugin\n\ncollectonly no longer loaded by default\n" }, { "from": "human", "value": "import re\n\nfrom nose2.tests._common import FunctionalTestCase\n\nclass CollectOnlyFunctionalTest(FunctionalTestCase):\n def test_collect_tests_in_package(se...
python
chosen
[ { "from": "human", "value": "Add a test that fails if using an old version of chromedriver\n" }, { "from": "gpt", "value": "from seleniumbase import BaseCase\n\n\nclass ChromedriverTests(BaseCase):\n\n def test_fail_if_using_an_old_chromedriver(self):\n if self.browser != \"chrome\":\n...
python
chosen
[ { "from": "human", "value": "Add fibonacci search in python\n" }, { "from": "gpt", "value": "#Fibonacci search for sorted algorithm\ndef fibSearch(arr,x):\n\n #fibonacci numbers initialization\n fib2 = 0\n fib1 = 1\n fib = fib2 + fib1\n\n n = len(arr)\n #find the smallest fibon...
python
chosen
[ { "from": "human", "value": "Add tests - now very simple and primitive\n" }, { "from": "gpt", "value": "import unittest\nfrom saw.saw import Saw\n\nclass Test_Saw(unittest.TestCase):\n\n def setUp(self):\n text = \"Starting right this second, it's way easier to merge Pull Requests! \\\...
python
chosen
[ { "from": "human", "value": "Check for multiple outcome codes occurring today\n" }, { "from": "gpt", "value": "# coding=utf-8\nimport logging\nfrom django.core.management.base import BaseCommand\nfrom django.db.models import Count, Max, Min\nfrom django.utils.timezone import now\nfrom cla_butler...
python
chosen
[ { "from": "human", "value": "Test that data volumes now survive a crash when recreating\n\nSigned-off-by: Aanand Prasad <94fc4f3e3d0be608b3ed7b8529ff28d2a445cce1@gmail.com>\n" }, { "from": "gpt", "value": "from __future__ import unicode_literals\nfrom __future__ import absolute_import\n\nimport ...
python
chosen
[ { "from": "human", "value": "Add small python script which calculates how much disk space we save by using CAS\n" }, { "from": "gpt", "value": "import os\nimport pymongo\nfrom collections import Counter\n\ndb_uri = os.getenv('SCITRAN_PERSISTENT_DB_URI', 'localhost:9001')\ndb = pymongo.MongoClien...
python
chosen
[ { "from": "human", "value": "Add auto fixture to make sure that output dir does not exists when tests are run\n" }, { "from": "gpt", "value": "from static_precompiler.settings import ROOT, OUTPUT_DIR\nimport shutil\nimport os\nimport pytest\n\n\n@pytest.fixture(autouse=True)\ndef _no_output_dir(...
python
chosen
[ { "from": "human", "value": "Add an extra file to the surrogates experiments.\n" }, { "from": "gpt", "value": "import darch.search_logging as sl\nimport darch.visualization as vi\nimport numpy as np\nimport seaborn as sns; sns.set()\n\n# checking these across time.\nlog_lst = sl.read_search_fold...
python
chosen
[ { "from": "human", "value": "TST: Add a test of spline filtering vs. matrix solving.\n" }, { "from": "gpt", "value": "\"\"\"Tests for spline filtering.\"\"\"\nfrom __future__ import division, print_function, absolute_import\n\nimport numpy as np\nimport pytest\n\nfrom numpy.testing import assert...
python
chosen
[ { "from": "human", "value": "Add unit tests for sdnvpn\n\nChange-Id: Ie4ebc4e2bc6f2e66f5f567f45f44c073cd9d313d\nSigned-off-by: Cédric Ollivier <d48310251a4a484d041bc5d09a9ac4d86d20f793@orange.com>\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n# Copyright (c) 2017 Orange and others.\n...
python
chosen
[ { "from": "human", "value": "Add a tool script to print errors statistics in output JSON files.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n\"\"\"\nMake statistics on score files (stored in JSON files).\n\"\"\"\n\nimport argparse\nimport json\nimport numpy...
python
chosen
[ { "from": "human", "value": "Add tests for file storage engine\n" }, { "from": "gpt", "value": "from jacquard.storage.file import FileStore\n\n\ndef test_get_nonexistent_key():\n # Just test this works without errors\n store = FileStore(':memory:')\n assert store.get('test') is None\n\n...
python
chosen
[ { "from": "human", "value": "Add a test case to exercise the 'target stop-hook add' command without relying on pexpect\nto spawn an lldb child command. The test is not \"correct\" in that the '** Stop Hooks **'\nmessage emitted by the Target implementation is invoked asynchronously and is using a separate:...
python
chosen
[ { "from": "human", "value": "Add some example client code\n" }, { "from": "gpt", "value": "\"\"\"\nCopyright 2015 Red Hat, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the Lice...
python
chosen
[ { "from": "human", "value": "Add tests for generic hash\n" }, { "from": "gpt", "value": "# Import nacl libs\nimport libnacl\n\n# Import python libs\nimport unittest\n\n\nclass TestGenericHash(unittest.TestCase):\n '''\n Test sign functions\n '''\n def test_keyless_generichash(self):\...
python
chosen