conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add test for loss function\n" }, { "from": "gpt", "value": "# coding: utf-8\nfrom __future__ import unicode_literals\n\nimport pytest\nfrom mock import MagicMock\nfrom numpy import ndarray\n\nfrom ...loss import categorical_crossentropy\n\n\n@pytest.mark.parametrize(...
python
chosen
[ { "from": "human", "value": "Add DB upgrade debugging script\n\n[skip ci]\n" }, { "from": "gpt", "value": "\"\"\"\n\n\"\"\"\nimport click\nimport gevent\nimport structlog\n\nfrom raiden.exceptions import InvalidDBData, RaidenDBUpgradeError\nfrom raiden.storage import serialize, sqlite\nfrom raid...
python
chosen
[ { "from": "human", "value": "Add tests for sentence segmentation presetting\n" }, { "from": "gpt", "value": "'''Test that the parser respects preset sentence boundaries.'''\nimport pytest\nfrom thinc.neural.optimizers import Adam\nfrom thinc.neural.ops import NumpyOps\n\nfrom ...attrs import NOR...
python
chosen
[ { "from": "human", "value": "Add test for ruby linter\n" }, { "from": "gpt", "value": "import json\nfrom lints.ruby import Ruby\n\n\ndef test_ruby():\n msg = [\n 'app/models/message:50: syntax error, unexpected end-of-input, expecting keyword_end',\n ]\n\n res = Ruby().parse_locl...
python
chosen
[ { "from": "human", "value": "Create a bouncy ball example that uses verlet integration.\n" }, { "from": "gpt", "value": "#Imports\nfrom tphysics import VerletCircle, Rectangle, Game\nfrom Tkinter import TclError\n\n#Create the game\ng = Game(\"Bouncy Ball\", 600, 600, \"grey\")\n\n#Create the wa...
python
chosen
[ { "from": "human", "value": "Add test of running the server\n" }, { "from": "gpt", "value": "import unittest\nimport asyncio\nimport io\nimport multiprocessing\nimport urllib.request\nimport time\n\nimport grole\n\ndef simple_server():\n app = grole.Grole()\n\n @app.route('/')\n def hel...
python
chosen
[ { "from": "human", "value": "Add some tests for the orientated bins\n" }, { "from": "gpt", "value": "import unittest\nimport nose.tools\nimport numpy as np\n\nimport skimage.io as io\nfrom scipy.ndimage.filters import gaussian_filter\n\nfrom mammogram.orientated_bins import orientated_bins\n\ncl...
python
chosen
[ { "from": "human", "value": "Add service factory module to return appropiate service version\n" }, { "from": "gpt", "value": "from cartodb_services.here.geocoder import HereMapsGeocoder, HereMapsGeocoderV7\nfrom cartodb_services.here.bulk_geocoder import HereMapsBulkGeocoder, HereMapsBulkGeocode...
python
chosen
[ { "from": "human", "value": "Add a common run task script for all tasks. Not supported by db_client yet\n" }, { "from": "gpt", "value": "import sys\nimport logging\nimport logging.config\nimport traceback\nimport bson.objectid\n\nimport config.global_configuration as global_conf\nimport database...
python
chosen
[ { "from": "human", "value": "Move test utils to infra module\n" }, { "from": "gpt", "value": "import random\nimport string\n\nINDENT = '\\n' + ' ' * 8\n\n\ndef generate_simple_output_program(source):\n return \"\"\"thing Program\n setup{source}\n \"\"\".format(source=INDENT + INDENT.joi...
python
chosen
[ { "from": "human", "value": "Add snippet for sending sms.\n" }, { "from": "gpt", "value": "# Download the twilio-python library from http://twilio.com/docs/libraries\nfrom twilio.rest import TwilioRestClient\nimport config\n\n# Find these values at https://twilio.com/user/account\naccount_sid = ...
python
chosen
[ { "from": "human", "value": "Add results boolean to wallpost pics\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.2 on 2016-11-15 15:03\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migrat...
python
chosen
[ { "from": "human", "value": "Add KISS-GP classification unit test.\n" }, { "from": "gpt", "value": "import math\nimport torch\nimport gpytorch\nfrom torch import nn, optim\nfrom torch.autograd import Variable\nfrom gpytorch.kernels import RBFKernel, GridInterpolationKernel\nfrom gpytorch.means i...
python
chosen
[ { "from": "human", "value": "Add test to show crypto working\n" }, { "from": "gpt", "value": "from __future__ import absolute_import, division, print_function, unicode_literals\n\nimport os\nimport base64\nimport credsmash.aes_ctr\nimport credsmash.aes_gcm\n\n\nclass DummyKeyService(object):\n ...
python
chosen
[ { "from": "human", "value": "TST: Add a test for \"ignore\" warning filters\n\nThis file currently ignores the scipy/optimize/optimize.py file\nbecause of one (or actually two identical) remaining filters there.\n\nA commented out part, can be used to find all occurances of missing\nstacklevels to `warnings...
python
chosen
[ { "from": "human", "value": "Add migrations for latest model changes.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.4 on 2017-01-09 08:14\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Mi...
python
chosen
[ { "from": "human", "value": "Implement a rough draft of Standing\n" }, { "from": "gpt", "value": "from requirement import GenEd\n\nclass Standing:\n\tdef __init__(self, credits_needed=35, credits_taken=0.0):\n\t\tself.credits_needed = credits_needed\n\t\tself.credits_taken = credits_taken\n\n\t\...
python
chosen
[ { "from": "human", "value": "Add test script to explore using pipes instead of queues\n" }, { "from": "gpt", "value": "import multiprocessing\n\ndef worker(procnum, send_end):\n '''worker function'''\n result = str(procnum) + ' represent!'\n print result\n send_end.send(result)\n\nde...
python
chosen
[ { "from": "human", "value": "Add unit tests for the tempest.common.utils.file_utils\n\nThis commit adds a positive and negative unit tests for the single\nmethod from file_utils in tempest.common.utils.\n\nPartially implements bp unit-tests\n\nChange-Id: Ic19428a10785afd8849442f4d1f8f8e0a87f549b\n" }, {...
python
chosen
[ { "from": "human", "value": "Add generic dictionary based on types\n" }, { "from": "gpt", "value": "from collections import defaultdict\n\nRequiredArg = None\n\nclass TypeParameterDict:\n\n def __init__(self, len_keys=1, **kwargs):\n self._dict = defaultdict(kwargs)\n self._len_...
python
chosen
[ { "from": "human", "value": "Add plugin to toggle vintageous\n" }, { "from": "gpt", "value": "import sublime\nimport sublime_plugin\n\n\nclass ToggleVintageousCommand(sublime_plugin.WindowCommand):\n def run(self):\n settings = sublime.load_settings('Preferences.sublime-settings')\n ...
python
chosen
[ { "from": "human", "value": "Add mgmt cmd to delete location_types from couch\n" }, { "from": "gpt", "value": "from django.core.management.base import BaseCommand\nfrom dimagi.utils.couch.database import iter_docs\nfrom corehq.apps.domain.models import Domain\n\n\nclass IterativeSaver(object):\n...
python
chosen
[ { "from": "human", "value": "Add test population script for noiseless 'dimkarakostas' endpoint\n" }, { "from": "gpt", "value": "from string import ascii_lowercase\nimport django\nimport os\n\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')\ndjango.setup()\n\nfrom breach.model...
python
chosen
[ { "from": "human", "value": "TST: Add test to check for legacy plan names\n" }, { "from": "gpt", "value": "import pytest\nimport bluesky.plans as bp\n\ndef test_legacy_plan_names():\n assert bp.outer_product_scan is bp.grid_scan\n assert bp.relative_outer_product_scan is bp.rel_grid_scan\n...
python
chosen
[ { "from": "human", "value": "Test kdfs just in case\n" }, { "from": "gpt", "value": "from zerodb.crypto import kdf\nimport ZEO\n\ntest_key = b'x' * 32\n\ntest_args_1 = dict(\n username='user1', password='password1',\n key_file=ZEO.tests.testssl.client_key,\n cert_file=ZEO.te...
python
chosen
[ { "from": "human", "value": "Add script for setting image urls\n\nIn case anyone wants to use it in the future.\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\n\nimport pymongo\nimport unicodedata as ud\n\nDB_USER = ''\nDB_PASSWORD = ''\nDB_URL = ''\n\n# Add Studs members here\nSTUDS_MEMBER...
python
chosen
[ { "from": "human", "value": "Add an example of how to use the TextDiffReporter.\n" }, { "from": "gpt", "value": "from approvaltests import Approvals\nfrom approvaltests.TextDiffReporter import TextDiffReporter\nimport os\nimport unittest\n\n\nclass Test(unittest.TestCase):\n def test(self):\n...
python
chosen
[ { "from": "human", "value": "Simplify the usage of CDF files.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n# Copyright (c) 2017 Jérémie DECOCK (http://www.jdhp.org)\n\n# This script is provided under the terms and conditions of the MIT license:\n# Permissio...
python
chosen
[ { "from": "human", "value": "Add test for icon layout\n" }, { "from": "gpt", "value": "#!/usr/bin/python\nimport pygtk\npygtk.require('2.0')\n\nfrom sugar.session.UITestSession import UITestSession\n\nsession = UITestSession()\nsession.start()\n\nimport sys\nimport random\n\nimport gtk\nimport g...
python
chosen
[ { "from": "human", "value": "Add unit tests for git_utilities\n" }, { "from": "gpt", "value": "\"\"\"Test group class\"\"\"\nimport unittest\nfrom clowder.utility.git_utilities import (\n git_ref_type,\n git_truncate_ref\n)\n\nclass GroupTest(unittest.TestCase):\n \"\"\"group test subcl...
python
chosen
[ { "from": "human", "value": "Add script to check resampling of wav files\n" }, { "from": "gpt", "value": "# Script to plot original wav file against wav file resampled at 16 kHz\n\n# Licensed under Apache v2 (see LICENSE)\n\nfrom __future__ import division\n\nimport sys\nimport os\nimport glob\n...
python
chosen
[ { "from": "human", "value": "Add first draft of FormatSpecifierParser\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\n\"\"\"Patterns and parsers for various purposes.\"\"\"\n\n__all__ = [\"FormatSpecifierParser\"]\n\nimport re\n\nclass FormatSpecifierParser:\n \"\"\"Parser for the ...
python
chosen
[ { "from": "human", "value": "Add basic test for init\n" }, { "from": "gpt", "value": "from click.testing import CliRunner\nfrom webstore_deployer.deployer import init\n\n\ndef test_init():\n runner = CliRunner()\n result = runner.invoke(init, ['testing_client_ID'])\n\n assert result.exi...
python
chosen
[ { "from": "human", "value": "Copy values from old to new field in Schedules Model\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.26 on 2019-11-24 20:52\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, transaction\n\n\ndef copy_co...
python
chosen
[ { "from": "human", "value": "Add migration for Levin class order\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 ('syntacticf...
python
chosen
[ { "from": "human", "value": "Add a script to benchmark python to arduino libraries\n" }, { "from": "gpt", "value": "import sys\nsys.path.append('/home/bat/Python-Arduino-Proto-API-v2/arduino')\nimport time\nlocations = ['/dev/ttyACM0','/dev/ttyACM1','/dev/ttyACM2','/dev/ttyACM3','/dev/ttyACM4',...
python
chosen
[ { "from": "human", "value": "Add plain hash filter for testing\n" }, { "from": "gpt", "value": "import time\n\nclass HashFilter(object):\n '''\n Plain Hash Filter for testing purposes\n '''\n def __init__(self, expiration):\n self.expiration = expiration\n self.unique_i...
python
chosen
[ { "from": "human", "value": "Add example script\nThis will give future-me a jumping off point for writing scripts to run against the DB for special cases.\n" }, { "from": "gpt", "value": "## This is an example of how to set up a script to run against a database, should you need to do so.\n## It ...
python
chosen
[ { "from": "human", "value": "Add script that makes sure workspace numbers are always in consecutive\norder by moving windows on out of order workspaces to the appropriate\nworkspace\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport i3ipc\n\n# make connection to i3 ipc \ni3 = i3ip...
python
chosen
[ { "from": "human", "value": "Remove duplicated index on table 'records' of pDNS backend\n\nRemove duplicated index `rec_name_index` on table 'records' of pDNS backend.\n\nChange-Id: I9e8723b464522a588f0e0ef6ff261b71609b0726\nCloses-Bug: 1446980\n" }, { "from": "gpt", "value": "# Copyright 2015 N...
python
chosen
[ { "from": "human", "value": "Add tests for pathways details and significant pathways\n" }, { "from": "gpt", "value": "from database import db\nfrom models import Pathway, Gene, GeneList, GeneListEntry\nfrom view_testing import ViewTest\n\n\ndef create_pathways():\n\n # not necessarily true ;)...
python
chosen
[ { "from": "human", "value": "Create command to change project slug\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Copyright (C) 2014-2016 Andrey Antukh <niwi@niwi.nz>\n# Copyright (C) 2014-2016 Jesús Espino <jespinog@gmail.com>\n# Copyright (C) 2014-2016 David Barragán <bameda@dbarr...
python
chosen
[ { "from": "human", "value": "Add script to reverse complement a set of sequences.\n" }, { "from": "gpt", "value": "import sys\nfrom argparse import ArgumentParser, FileType\nfrom Bio.Seq import Seq\n\ndef reverse_complement(seq):\n return str(Seq(seq.strip()).reverse_complement())\n\nif __nam...
python
chosen
[ { "from": "human", "value": "Add migration for previous commit\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.17 on 2018-12-09 13:15\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migratio...
python
chosen
[ { "from": "human", "value": "Test to use the new Vimba module.\n" }, { "from": "gpt", "value": "#! /usr/bin/env python\n# -*- coding:utf-8 -*- \n\n\n#\n# Application to capture images synchronously\n# from two AVT Manta cameras with the Vimba SDK\n#\n\n\n# External dependencies\nimport collectio...
python
chosen
[ { "from": "human", "value": "Add script to expand body parts\n\nThe script looks for words indicating body parts in sentences with\npredicted label Lichaamsdeel and adds the appropriate body part terms to\nthe labels per sentence. The results are written to text files in a new\ndirectory.\n" }, { "f...
python
chosen
[ { "from": "human", "value": "Add tests model land values\n" }, { "from": "gpt", "value": "from django.test import TestCase\n\nfrom geotrek.land.models import LandType, PhysicalType\n\n\nclass TestModelLand(TestCase):\n def test_physicaltype_value_no_structure(self):\n pt = PhysicalType...
python
chosen
[ { "from": "human", "value": "Add basic integrator attaching/detaching tests\n" }, { "from": "gpt", "value": "import pytest\n\nimport hoomd\nimport hoomd.md as md\n\n\ndef make_simulation(simulation_factory, two_particle_snapshot_factory):\n\n def sim_factory(particle_types=['A'], dimensions=3...
python
chosen
[ { "from": "human", "value": "Add RDS instance Type Config Rule.\n\nRequirements: comma separated DBInstance Class named \"DBInstance\" as Key on Rule parameters." }, { "from": "gpt", "value": "#\n# This file made available under CC0 1.0 Universal (https://creativecommons.org/publicdomain/zero/1....
python
chosen
[ { "from": "human", "value": "Add example script for adjusting live camera feed brightness.\n" }, { "from": "gpt", "value": "from Arlo import Arlo\n\nUSERNAME = 'user@example.com'\nPASSWORD = 'supersecretpassword'\n\ntry:\n\t# Instantiating the Arlo object automatically calls Login(), which retur...
python
chosen
[ { "from": "human", "value": "Add example showing 1d scatter plots.\n" }, { "from": "gpt", "value": "\"\"\"\nScatter plot with auxilliary 1d plots\n\nShows a scatter plot of a set of random points,\nwith auxilliary 1d plots of the data.\n\n\"\"\"\n\n# Major library imports\nfrom numpy import sort...
python
chosen
[ { "from": "human", "value": "Add a migration to remove booksales tables\n" }, { "from": "gpt", "value": "\"\"\"Remove booksales tables\n\nRevision ID: 2d257d93329\nRevises: 3ee07cd6b53\nCreate Date: 2016-04-09 13:04:55.562530\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\nrevision = '2d2...
python
chosen
[ { "from": "human", "value": "Install scanners that are not installed based on user selection\n" }, { "from": "gpt", "value": "\nimport subprocess\n\n\nSCANNER_INSTALLATION_INSTRUCTIONS = {\n \"safesql\":\"github.com/stripe/safesql\",\n ...
python
chosen
[ { "from": "system", "value": "Fix test: uncomment test commented by mistake\n" }, { "from": "human", "value": "# \"{d[1]}\".format(d={2: a, **{1: b}})\n<warning descr=\"Too few arguments for format string\">\"{d[3]}\"</warning>.format(d={2: a, **{1: b}})" }, { "from": "gpt", "value":...
python
chosen
[ { "from": "human", "value": "Add a multi AZ PostgreSQL `RDS` instance bound to container subnets\n" }, { "from": "gpt", "value": "from troposphere import (\n rds,\n Ref,\n AWS_STACK_NAME,\n)\n\nfrom .template import template\nfrom .vpc import (\n container_a_subnet,\n container_b_...
python
chosen
[ { "from": "human", "value": "tests: Add a basic test for connect().\n" }, { "from": "gpt", "value": "import pytest\nfrom pypuppetdb.errors import UnsupportedVersionError\nfrom pypuppetdb import connect\n\npytestmark = pytest.mark.unit\n\n\ndef test_connect_unknown_api_version():\n with pytest...
python
chosen
[ { "from": "human", "value": "Add tests for jupyter widget\n" }, { "from": "gpt", "value": "import mock\nimport pytest\ntry:\n import ipywidgets\nexcept ImportError:\n ipywidgets = None\n\n\n@pytest.mark.skipif(ipywidgets is None, reason='ipywidgets is not installed')\nclass TestExperimentW...
python
chosen
[ { "from": "human", "value": "Add optional actual asserted values logging\n" }, { "from": "gpt", "value": "from pytest import Item\n\n\ndef pytest_assertion_pass(item: Item,\n lineno: int,\n orig: str,\n expl: str) -> None...
python
chosen
[ { "from": "human", "value": "Add API test for SkewT.\n\nThis does no checking for the output being correct, but at least checks\nthat the code doesn't fire an exception on normal use.\n" }, { "from": "gpt", "value": "import tempfile\nimport numpy as np\nfrom matplotlib.figure import Figure\nfrom...
python
chosen
[ { "from": "human", "value": "Put together a basic flask for Dante. The start of the admin page.\n" }, { "from": "gpt", "value": "from flask import Flask\napp = Flask(__name__)\n\n@app.route(\"/\")\ndef hello():\n return \"Hello World!\"\n\n@app.route(\"/hitmehard\")\ndef ttol():\n\timport py...
python
chosen
[ { "from": "human", "value": "Write equations for sage to convert to CNF" }, { "from": "gpt", "value": "#!/usr/bin/python\n#\n# Write equations needed to feed into sage in alpha-numeric form\n#\n# Cahlen Humphreys (2015)\nfo = open(\"anf.txt\", \"wb\")\n\nptext = \"0110001010010111000010101110001...
python
chosen
[ { "from": "human", "value": "Add SearchSpider generated by `scrapy genspider` command\n" }, { "from": "gpt", "value": "import scrapy\n\n\nclass SearchSpider(scrapy.Spider):\n name = 'search'\n allowed_domains = ['linkedin.com']\n start_urls = ['http://linkedin.com/']\n\n def parse(se...
python
chosen
[ { "from": "human", "value": "Implement information gain related functions (untested).\n" }, { "from": "gpt", "value": "from scipy import stats\nfrom math import log2\nimport numpy as np\n\n\ndef majority_value(binary_targets):\n mode = stats.mode(binary_targets)\n return tuple(map(lambda x...
python
chosen
[ { "from": "human", "value": "skia: Add extra bots to the default set of try bots for changes in skia/\n\nThis adds linux_layout_rel, win_gpu, linux_gpu, mac_gpu, and\nmac_gpu_retina to the default set of bots to run on patches that touch\nskia/ when doing \"git cl try\".\n\nThis has no effect on the commit ...
python
chosen
[ { "from": "human", "value": "Move duplicated sql code into helper\n" }, { "from": "gpt", "value": "import shared\n\ndef sqlQuery(sqlStatement, *args):\n shared.sqlLock.acquire()\n shared.sqlSubmitQueue.put(sqlStatement)\n\n if args == ():\n shared.sqlSubmitQueue.put('')\n else...
python
chosen
[ { "from": "human", "value": "Add module for pulling taxonomic data from BLAST\n" }, { "from": "gpt", "value": "\"\"\"Ping the NCBI Taxonomy web service and retrieve data about a sequence.\n\nStupidly simple module... probably needs more intelligent/safe parsing of data.\n\"\"\"\nimport re\nimpor...
python
chosen
[ { "from": "human", "value": "Set is_root=True for old folders set as root_node for existing NodeSettings\n\n[#PLAT-578]\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.13 on 2018-07-11 18:05\nfrom __future__ import unicode_literals\n\nfrom django.db import mi...
python
chosen
[ { "from": "system", "value": "Make the test MongoDB database TZ aware like the production one, else some date comparisons fail, whereas they succeed in production.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nimport redis\n\nfrom mongoengine.connection import connect, disconnect...
python
chosen
[ { "from": "human", "value": "Refactor of controllers and views into heritage from abstract classes\n" }, { "from": "gpt", "value": "import abc\nfrom PyQt5 import QtWidgets\nclass BaseWidgetView(QtWidgets.QWidget):\n __metaclass__ = abc.ABCMeta\n\n def notify(self, kwargs):\n u\"\"\"...
python
chosen
[ { "from": "human", "value": "Add a simple actor example.\n\nSigned-off-by: Robert Deaton <eb00a885478926d5d594195591fb94a03acb1062@udel.edu>\n" }, { "from": "gpt", "value": "try:\n import _path\nexcept NameError:\n pass\nimport spyral\nimport sys\n\nSIZE = (600, 600)\nBG_COLOR = (0, 0, 0)\...
python
chosen
[ { "from": "system", "value": ":rocket: Change Vaccine was_applied widget to RadioSelect\n" }, { "from": "human", "value": "import datetime #for checking renewal date range.\n\nfrom django import forms\nfrom django.core.exceptions import ValidationError\nfrom django.utils.translation import ugett...
python
chosen
[ { "from": "human", "value": "Add migration for le-utils update.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.20 on 2019-09-05 04:08\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nfrom django.db import models\n\n\nclass Migrat...
python
chosen
[ { "from": "human", "value": "Add script to analyze mongo profile and determine index misses.\n" }, { "from": "gpt", "value": "# use sli\n# db.system.profile.drop()\n# db.createCollection(\"system.profile\", {capped:true, size:1024000000});\n# db.setProfilingLevel(2)\n#\n# mongodump --db sli --co...
python
chosen
[ { "from": "system", "value": "Switch trunk to 1.4.3 development" }, { "from": "human", "value": "import gettext\n\n\nclass Version(object):\n def __init__(self, canonical_version, final):\n self.canonical_version = canonical_version\n self.final = final\n\n @property\n def...
python
chosen
[ { "from": "human", "value": "Add an example of sending a link event written in python.\n" }, { "from": "gpt", "value": "#! /usr/local/bin/python\n\nimport sys\nimport time\nsys.path.append(\"/usr/testbed/lib\")\n\nfrom tbevent import *\n\nserver = \"event-server\"\nport = None\nkeyfile = ...
python
chosen
[ { "from": "human", "value": "[ENH] Add a script to generate csv files\n\nFirst, convert bson to json using mongodb's tool. Second, use this\nscript to generate csv tables.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nfrom pathlib import Path\nfrom collections import defaultdict\nimpor...
python
chosen
[ { "from": "human", "value": "Hide deprecated shaders used by old OSLObject\n" }, { "from": "gpt", "value": "##########################################################################\n#\n# Copyright (c) 2019, Image Engine Design Inc. All rights reserved.\n#\n# Redistribution and use in source ...
python
chosen
[ { "from": "human", "value": "Add script to create cover composite images for Twitter posts\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport sys\n\nfrom PIL import Image\n\nCOVER_HEIGHT = 480\nBORDER_WIDTH = 10\nBACKGROUND_COLOR = (39, 46, 111, 0)\n\n\ndef gather_covers(input_fil...
python
chosen
[ { "from": "human", "value": "Add migration to fix misspelling in verbose name.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nimport django.core.validators\n\n\nclass Migration(migrations.Migration):\...
python
chosen
[ { "from": "human", "value": "Convert a JSON dataset file and a MATLAB visual features file into a single H5 file.\n" }, { "from": "gpt", "value": "import json\nimport h5py\nimport numpy as np\nimport scipy.io\n\njdata = json.load(open(\"flickr8k/dataset.json\"))\nfeatures_struct = scipy.io.loadm...
python
chosen
[ { "from": "human", "value": "Add py solution for 646. Maximum Length of Pair Chain\n\n646. Maximum Length of Pair Chain: https://leetcode.com/problems/maximum-length-of-pair-chain/\n" }, { "from": "gpt", "value": "class Solution(object):\n def findLongestChain(self, pairs):\n \"\"\"\n ...
python
chosen
[ { "from": "human", "value": "Add test for order history view\n" }, { "from": "gpt", "value": "import pytest\n\nfrom tests.api.utils import get_graphql_content\n\n\n@pytest.mark.django_db\n@pytest.mark.count_queries(autouse=False)\ndef test_user_order_details(user_api_client, order_with_lines, co...
python
chosen
[ { "from": "human", "value": "Refactor tests for current version\n" }, { "from": "gpt", "value": "from __future__ import print_function, division\nimport augmenters2 as iaa\nimport parameters as iap\n#from skimage import\nimport numpy as np\nimport time\n\ndef main():\n seq = iaa.Sequence([iaa...
python
chosen
[ { "from": "human", "value": "Add an example chunk of code showing how to code in a synchronous way to the python library\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nfrom ipmi_command import ipmi_command\nimport os\nimport sys\npassword=os.environ['IPMIPASSWORD']\nos.environ['IPMIPASS...
python
chosen
[ { "from": "human", "value": "Add migration file for the model of CoC record\n" }, { "from": "gpt", "value": "# Generated by Django 3.0.2 on 2020-02-23 12:28\n\nimport core.models\nfrom django.conf import settings\nfrom django.db import migrations, models\nimport django.db.models.deletion\n\n\ncl...
python
chosen
[ { "from": "human", "value": "Add file fot test of start symbol setting\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\n:Author Patrik Valkovic\n:Created 10.08.2017 23:00\n:Licence GNUv3\nPart of grammpy\n\n\"\"\"\n\nfrom unittest import TestCase, main\nfrom grammpy import *\n\n\n...
python
chosen
[ { "from": "human", "value": "Add test for species filter.\n" }, { "from": "gpt", "value": "\n\"\"\"\nUnit tests for the species filter\n\n\"\"\"\nimport unittest\n\nimport numpy as np\n\nfrom ....system import lattice\nfrom .. import speciesFilter\nfrom .. import base\n\n\n######################...
python
chosen
[ { "from": "human", "value": "Add josnify file. Correct format, needs tweaks\n" }, { "from": "gpt", "value": "\"\"\"Convert files to json.\"\"\"\n\n\ndef to_json(file):\n \"\"\"Convert ini to JSON like thing.\"\"\"\n ini = open(file, 'r')\n ini = ini.readlines()\n settings_file = open...
python
chosen
[ { "from": "human", "value": "Add command to repair the file index\n" }, { "from": "gpt", "value": "from typing import Set\n\nfrom django.core.management.base import BaseCommand\n\nfrom mainapp.functions.minio import minio_client, minio_file_bucket\nfrom mainapp.models import File\n\n\nclass Comm...
python
chosen
[ { "from": "human", "value": "Add managemant command to generate sql to clean up tp truncated student ids in ORA db\n" }, { "from": "gpt", "value": "\"\"\"\nGenerate sql commands to fix truncated anonymous student ids in the ORA database\n\"\"\"\nimport sys\n\nfrom django.core.management.base imp...
python
chosen
[ { "from": "human", "value": "Create direct kinematic function for CRS robot.\n" }, { "from": "gpt", "value": "import numpy as np\n\ndef robCRSdkt(robot, pos):\n T = np.eye(4)\n pos = np.array(pos) / 180.0 * np.pi\n\n for i in range(6):\n tz = np.eye(4)\n tz[2,3] = robot.d[...
python
chosen
[ { "from": "human", "value": "Create tools directory and add convert tool\n" }, { "from": "gpt", "value": "import argparse\n\n\ndef parseDay(weekDay, sunday):\n daysOfTheWeek = {'S': 'saturday', 'S2': 'sunday', 'M': 'monday', 'T': 'tuesday',\n 'W': 'wednesday', 'R': 'thursd...
python
chosen
[ { "from": "human", "value": "Fix script for cases with leading slashes.\n" }, { "from": "gpt", "value": "# This software and any associated files are copyright 2010 Brian Carver and\n# Michael Lissner.\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the ter...
python
chosen
[ { "from": "system", "value": "Add Wikidata as shared data repository for Commons.\n\nChange-Id: Ie79e3157d016fc74e400ddc618c04f2d1d39f17d\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n__version__ = '$Id$'\n\nfrom pywikibot import family\n\n\n# The Wikimedia Commons family\nclass...
python
chosen
[ { "from": "human", "value": "Add vector2 substraction unit tests\n" }, { "from": "gpt", "value": "import pytest\nfrom ppb_vector import Vector2\n\n\ndef test_substraction_vectors():\n test_vector1 = Vector2(0, 1)\n test_vector2 = Vector2(0, 1)\n result = test_vector1 - test_vector2\n ...
python
chosen
[ { "from": "system", "value": "Support unix sockets in the Redis URL parser.\n" }, { "from": "human", "value": "import os\n\ntry:\n from urllib import parse\nexcept ImportError:\n import urlparse as parse\n\n\ndef parse_redis_url():\n config = {\n 'host': 'localhost',\n 'po...
python
chosen
[ { "from": "human", "value": "Add faster RMSE via numba\n" }, { "from": "gpt", "value": "\"\"\" Regression related functions optimized using Numba, if available\n\nIf Numba is not avaiable, functions are still usable as not JIT'd functions\n\"\"\"\n\n\n# @nb.jit()\ndef rmse(y, yhat):\n \"\"\" ...
python
chosen
[ { "from": "human", "value": "Change 'deleted' to Boolean in project_user_quotas\n\nChange-Id: I7604ba4b938d5ff73bcf3b1f9152cc6aa4f1c0c8\nCloses-Bug: #1274165\n" }, { "from": "gpt", "value": "# Copyright 2013 Mirantis Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");...
python
chosen
[ { "from": "human", "value": "Test that brain mask has plausible volume\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\nimport unittest\nfrom os.path import expanduser, join, isdir\nimport numpy as np\nfrom dipy.data.fetcher import fetch_scil_b0, read_siemens_scil_b0\nfrom createBra...
python
chosen
[ { "from": "human", "value": "Add tests for callback infrastructure\n" }, { "from": "gpt", "value": "import unittest\ntry: # Python 3.3 +\n from unittest.mock import Mock\nexcept ImportError:\n from mock import Mock\n\nfrom IPython.core import callbacks\nimport IPython.testing.tools as tt\...
python
chosen