conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add simple RANSAC unit test\n" }, { "from": "gpt", "value": "import numpy as np\nfrom numpy.testing import assert_equal\n\nfrom sklearn import linear_model\nfrom sklearn.utils import ransac\n\n\ndef test_ransac_inliers_outliers():\n np.random.seed(1)\n\n # Gene...
python
chosen
[ { "from": "human", "value": "Add python class for handling the plugin manifest plugin.json\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n###\n### Copyright 2014-2015, Boundary\n###\n### Licensed under the Apache License, Version 2.0 (the \"License\");\n### you may not use this file exc...
python
chosen
[ { "from": "system", "value": "Make sure we set the EMAIL_BACKEND by default\n" }, { "from": "human", "value": "\nDEFAULT_FILE_STORAGE = 'djangae.storage.BlobstoreStorage'\nFILE_UPLOAD_MAX_MEMORY_SIZE = 1024 * 1024\nFILE_UPLOAD_HANDLERS = (\n 'djangae.storage.BlobstoreFileUploadHandler',\n ...
python
chosen
[ { "from": "human", "value": "Add a command to list vaults\n" }, { "from": "gpt", "value": "import boto\n\nclass CommandListVaults(object):\n\n def execute(self, args, config):\n glacier_connection = boto.connect_glacier(aws_access_key_id=config.get('configuration', 'aws_key'), aws_secret_acc...
python
chosen
[ { "from": "human", "value": "Add command to cancel existing jobs to make it easier to resume failed scrapes.\n" }, { "from": "gpt", "value": "from regscrape_lib.util import get_db\nimport settings\n\ndef run():\n query = settings.FILTER.copy()\n query['_job_id'] = {'$exists': True}\n \n...
python
chosen
[ { "from": "human", "value": "convert: Convert the word2vec to gensim format" }, { "from": "gpt", "value": "from flask import Flask, request\nfrom flask.ext.restful import reqparse, Api, Resource\nfrom gensim.models.word2vec import Word2Vec\nimport json\n\nprint 'loading model'\nMODEL = Word2Vec....
python
chosen
[ { "from": "human", "value": "Add initial DdlStructure, DdlDocument, DdlWriter and DdlTextWriter\n\nEmpty classes for a general structure.\n\nSigned-off-by: Squareys <0f6a03d4883e012ba4cb2c581a68f35544703cd6@googlemail.com>\n" }, { "from": "gpt", "value": "from abc import abstractmethod\n\n__auth...
python
chosen
[ { "from": "human", "value": "Add Iowa Research Online harvester\n" }, { "from": "gpt", "value": "'''\nHarvester for the Iowa Research Online for the SHARE project\n\nExample API call: http://ir.uiowa.edu/do/oai/?verb=ListRecords&metadataPrefix=oai_dc\n'''\n\nfrom __future__ import unicode_litera...
python
chosen
[ { "from": "human", "value": "Add a ConstraintsContainer which doesn't do much yet.\n" }, { "from": "gpt", "value": "#------------------------------------------------------------------------------\n# Copyright (c) 2013, Enthought, Inc.\n# All rights reserved.\n#---------------------------------...
python
chosen
[ { "from": "system", "value": "Fix error in test path\n" }, { "from": "human", "value": "\n\nimport unittest\n\nfrom cura import CuraFactory\nfrom cura import CuraEngine\n\nclass CuraFactoryTestCase(unittest.TestCase):\n\n\n def test_cura_factory(self):\n\n fake_path = 'my/temp/path'\n ...
python
chosen
[ { "from": "human", "value": "Add unit tests for versioning builtins\n" }, { "from": "gpt", "value": "import unittest\n\nfrom bfg9000.builtins.version import bfg9000_required_version, bfg9000_version\nfrom bfg9000.versioning import bfg_version, VersionError\n\n\nclass TestRequiredVersion(unittest...
python
chosen
[ { "from": "human", "value": "Add script to check ci-helpers usage\n" }, { "from": "gpt", "value": "import requests\nfrom github import Github\nfrom common import get_credentials\n\nusername, password = get_credentials()\ngh = Github(username, password)\n\ngh_search_result = gh.search_code('filen...
python
chosen
[ { "from": "human", "value": "Add start of basic waiter model validation\n\nMakes it quicker to review contributions for waiter\nconfigs.\n" }, { "from": "gpt", "value": "# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0...
python
chosen
[ { "from": "human", "value": "Add a reverse-proxy view for hot-reloading\n" }, { "from": "gpt", "value": "from django.views.decorators.csrf import csrf_exempt\nfrom proxy.views import proxy_view\n\nfrom cra_helper import CRA_URL\n\n\n@csrf_exempt\ndef proxy_cra_requests(request, path):\n '''\n ...
python
chosen
[ { "from": "human", "value": "Add test for the access method.\n" }, { "from": "gpt", "value": "import __builtin__\nfrom pytest import raises\nfrom fuse import FuseOSError\nfrom mock import MagicMock, patch, call\n\nfrom gitfs.views import PassthroughView\n\n\nclass TestPassthrough(object):\n\n ...
python
chosen
[ { "from": "human", "value": "Add script to anonymize all data\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import, unicode_literals, print_function\n\nfrom factory import Faker\n\n# Django imports\nfrom django.conf import settings\nfrom django.core.ma...
python
chosen
[ { "from": "human", "value": "Debug the contents of composite resources after conversion.\n" }, { "from": "gpt", "value": "\"\"\"This prints the state of a logical file.\n\n* By default, prints errors on stdout.\n* Optional argument --log: logs output to system log.\n\"\"\"\n\nfrom django.core.ma...
python
chosen
[ { "from": "human", "value": "Add script that can check builds for completeness.\n\nIt checks against os-dependent lists which will be submitted\nin follow-up commits.\n\nChange-Id: Ieb40b19dbd85c30b28062b46320a6ee60ba672af\nReviewed-by: Bill King <2ab503764bfba23a6f2e273493fc021dc3d4cd8f@nokia.com>\n" }, ...
python
chosen
[ { "from": "human", "value": "Add Frobenius solution methods for singular points.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Aug 21 13:23:31 2014\n\n@author: Jens von der Linden\n\nImplments Frobneius expansion around a singularity to determine the \"small\"\...
python
chosen
[ { "from": "human", "value": "Add custom subclass to revert mapping\n\nTo be able to revert the custom mappings down by config-download, let's\nadd some tripleo specific subclasses which will be available in the\nregistry.\n\nChange-Id: I6bd4107e8e1a6a9abc38d2dca7a91a6823f8b6c2\nRelated-Bug: #1758065\n" },...
python
chosen
[ { "from": "human", "value": "Implement applyF_filterG function (1 test case missing)\n" }, { "from": "gpt", "value": "# Problem 8\n# 20.0 points possible (graded)\n# Implement a function that meets the specifications below.\n\n# For example, the following functions, f, g, and test code:\n\n# def...
python
chosen
[ { "from": "human", "value": "Fix 1597. Allow for curly bracket quantifiers in nltk.chunk.regexp.CHUNK_TAG_PATTERN.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import, unicode_literals\nimport unittest\n\nfrom nltk import RegexpParser\n\nclass TestChu...
python
chosen
[ { "from": "human", "value": "Add some tests for Experiment class\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import division, print_function\nimport os.path\n\nimport numpy as np\nfrom numpy.testing import assert_allclose\nimport pytest\n\nfrom pambox.speech import ...
python
chosen
[ { "from": "human", "value": "Add totally untested messenger multiplexer\n\nmessenger.mux theoretically lets you use a single messenger connection to talk with\nmultiple messenger servers. Send a hello:mux message to have the muxer claim the\nconnection. Now you can send messages that include _mux:<conID>....
python
chosen
[ { "from": "human", "value": "Test convert error during import\n\nWhen the conversion of an audio file fails during import the original should be\nimported. See #659\n" }, { "from": "gpt", "value": "# This file is part of beets.\n# Copyright 2014, Thomas Scholtes.\n#\n# Permission is hereby grant...
python
chosen
[ { "from": "human", "value": "Add initial migration for tweets app\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.6 on 2017-03-11 15:02\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.utils.timezone\nimport ...
python
chosen
[ { "from": "human", "value": "Set Stripe document type to 'passort' for old projects.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10.8 on 2019-01-23 16:31\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\ndef set_stripe_documen...
python
chosen
[ { "from": "human", "value": "Add additional backwards-compatibility for pybel.io.tsv/pybel.io.triples\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"Warnings for old TSV conversion module.\"\"\"\n\nimport warnings\n\nfrom ..triples.converters import _safe_label\n\n__all__ = [\...
python
chosen
[ { "from": "human", "value": "Add code for simple convnet\n\nBasic code to run a very very simple convnet\n" }, { "from": "gpt", "value": "import numpy as np\nimport tensorflow as tf\nimport matplotlib.pyplot as plt\nfrom sklearn.datasets import load_sample_image\nfrom sklearn.datasets import loa...
python
chosen
[ { "from": "human", "value": "Add some basic tests for PyrexTypes.widest_numeric_type().\n" }, { "from": "gpt", "value": "from __future__ import absolute_import\n\nimport unittest\n\nimport Cython.Compiler.PyrexTypes as PT\n\n\nclass TestMethodDispatcherTransform(unittest.TestCase):\n\n def te...
python
chosen
[ { "from": "human", "value": "Add tests for the daemon mode\n" }, { "from": "gpt", "value": "import inotify\nimport pytest\n\nimport os\n\nfrom botbot import daemon\n\ndef test_func():\n pass\n\n\ndef get_dbpath():\n return os.path.join('.', 'test.db')\n\ndef test_daemon_constructor(tmpdir)...
python
chosen
[ { "from": "human", "value": "Add Test of static routing\n" }, { "from": "gpt", "value": "from unittest import TestCase\nfrom kobin.routes import Router\n\n\nclass RouterTest(TestCase):\n def setUp(self):\n self.router = Router()\n\n def test_add_func_when_input_static(self):\n ...
python
chosen
[ { "from": "human", "value": "Add a thread safe convenient bit flag class.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# -----------------------------------------------------------------------------\n# Copyright 2015 by Ecpy Authors, see AUTHORS for more details.\n#\n# Distributed u...
python
chosen
[ { "from": "human", "value": "Add example for bcolz stock data\n" }, { "from": "gpt", "value": "import bcolz\nimport numpy as np\n\n\ndef field_type(c_dtyep, field, dt_orig):\n try:\n return c_dtyep[field][0]\n except KeyError:\n return dt_orig\n\n\nfloat64 = np.dtype('float64...
python
chosen
[ { "from": "human", "value": "Add tests of the improved camelcase/underscore conversion\n" }, { "from": "gpt", "value": "from unittest.case import TestCase\n\nfrom zsl.utils.string_helper import camelcase_to_underscore, underscore_to_camelcase\n\n\nclass InflectionTestCase(TestCase):\n def tes...
python
chosen
[ { "from": "human", "value": "Add script to run app\n" }, { "from": "gpt", "value": "from discovery import Endpoint, PingNode, PingServer\n\nmy_endpoint = EndPoint(u'192.168.1.192', 30303, 30303)\ntheir_endpoint = EndPoint(u'127.0.0.1', 30303, 30303)\n\nserver = PingServer(my_endpoint)\n\nlisten_...
python
chosen
[ { "from": "human", "value": "Add script to handle build tasks across all nodes. Right now running it on its own just cleans out any existing data and runs the entire build process (which takes a *long* time!). Needs to be upgraded to have a nice command line interface.\n" }, { "from": "gpt", "...
python
chosen
[ { "from": "human", "value": "Add script to summarize file size distribution.\n\nSee example at\nhttps://github.com/CenterForOpenScience/openscienceframework.org/issues/871\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"\nSummarize distribution of file sizes in OSF git repos.\n...
python
chosen
[ { "from": "human", "value": "Install packages on android device\n" }, { "from": "gpt", "value": "import os\nfrom com.android.monkeyrunner import MonkeyRunner, MonkeyDevice\n\ndef get_MainActivity(package_name):\n return package_name + 'MainActivity'\n\ndef install_package(package_path, device...
python
chosen
[ { "from": "human", "value": "Add py solution for 1219. Path with Maximum Gold\n\n1219. Path with Maximum Gold: https://leetcode.com/problems/path-with-maximum-gold/\n" }, { "from": "gpt", "value": "class Solution(object):\n def getMaximumGold(self, grid):\n \"\"\"\n :type grid: ...
python
chosen
[ { "from": "human", "value": "ENH: Add script to split the data in the pickle files.\n" }, { "from": "gpt", "value": "from __future__ import print_function\nimport numpy as np\nfrom six.moves import cPickle as pickle\nimport argparse\nimport os\n\nparser = argparse.ArgumentParser()\nparser.add_ar...
python
chosen
[ { "from": "human", "value": "Add remote resources tests stub.\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\nimport os\nimport sys\nimport unittest\nfrom unittest.mock import patch, sentinel\n\nLIB_PATH = os.path.dirname(os.path.realpath(__file__)) + '/../'\nCONFIG_PATH = os.path.join(LIB_...
python
chosen
[ { "from": "human", "value": "Add custom Mock class implementation.\n" }, { "from": "gpt", "value": "class Mock(object):\n class _MockQuery(object):\n '''Access Mock internals'''\n\n def __init__(self, mock):\n self._mock = mock\n\n @property\n def attrib...
python
chosen
[ { "from": "human", "value": "Add sample for running discovery of one SNMPv3 node\n" }, { "from": "gpt", "value": "from __future__ import print_function\nimport re\nimport requests\nfrom orionsdk import SwisClient\n\ndef main():\n npm_server = 'localhost'\n username = 'admin'\n password ...
python
chosen
[ { "from": "human", "value": "Add initial tests for admin cog\n" }, { "from": "gpt", "value": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nimport pytest\nimport pytest_mock\n\nfrom erasmus.cogs.admin import Admin\nfrom erasmus.erasmus import Erasmus\nfrom erasmus.typ...
python
chosen
[ { "from": "human", "value": "Add script to generate course specific tracking logs\n" }, { "from": "gpt", "value": "'''\nThis module will extract tracking logs for a given course and date range \nbetween when course enrollment start and when the course ended. For each log,\nthe parent_data and me...
python
chosen
[ { "from": "human", "value": "Add working 3D extruded Helmholtz demo\n" }, { "from": "gpt", "value": "from __future__ import absolute_import, division\n\nfrom firedrake import *\n\n\ndef run_hybrid_extr_helmholtz(degree, res, quads):\n nx = 2 ** res\n ny = 2 ** res\n nz = 2 ** (res - 1)\...
python
chosen
[ { "from": "system", "value": "Remove reference to old tests.\n" }, { "from": "human", "value": "# Copyright Hybrid Logic Ltd. See LICENSE file for details.\n# -*- test-case-name: flocker.test -*-\n\n\"\"\"\nFlocker is a hypervisor that provides ZFS-based replication and fail-over\nfunctionality...
python
chosen
[ { "from": "human", "value": "Add tests for unsigned arithmetic\n" }, { "from": "gpt", "value": "import numpy as np\nimport unittest\n\nfrom numba import void, uint32, int32, jit, uint64, int64, typeof, bool_\n\n@jit(void(uint32[:], uint32, uint32))\ndef prng(X, A, C):\n for i in range(X.shape...
python
chosen
[ { "from": "human", "value": "Add simple json api wrapper\n" }, { "from": "gpt", "value": "#! /usr/bin/env python2.7\n\nimport requests\n\nclass API(object):\n # This class should be inherited by more unique API specific classes\n # See kraken.py for an example\n\n def __init__(self, bas...
python
chosen
[ { "from": "human", "value": "Add tests to utils module\n" }, { "from": "gpt", "value": "from datetime import datetime\n\nfrom twisted.trial.unittest import TestCase\n\nfrom apns.utils import datetime_to_timestamp\n\n\nclass DatetimeToTimestampTestCase(TestCase):\n\n def test_datetime(self):\n...
python
chosen
[ { "from": "human", "value": "TST: Add test to cover ProgressBar and ProgressBarManager.\n" }, { "from": "gpt", "value": "from bluesky.utils import ProgressBar, ProgressBarManager\nfrom bluesky.plans import mv\nfrom bluesky import RunEngine\nfrom bluesky.examples import NullStatus, SimpleStatus, ...
python
chosen
[ { "from": "human", "value": "Test script for logic added\n" }, { "from": "gpt", "value": "# test for logic\n\nimport sys, operator, random\n\nBase1 = sys.argv[1]\nBase2 = sys.argv[2]\nBase3 = sys.argv[3]\nBase4 = sys.argv[4]\t\nBase5 = sys.argv[5]\nBase6 = sys.argv[6]\nLevel = 10\n\n#relation = ...
python
chosen
[ { "from": "human", "value": "Add first draft for Infinity class\n" }, { "from": "gpt", "value": "try:\n from functools import total_ordering\nexcept ImportError:\n # Use Python 2.6 port\n from total_ordering import total_ordering\n\n\n@total_ordering\nclass Infinity(object):\n \"\"\"...
python
chosen
[ { "from": "human", "value": "Add some IRC helper functions\n" }, { "from": "gpt", "value": "\"\"\" Collection of helper functions\n\"\"\"\n\ndef privmsg(to, msg):\n return 'PRIVMSG %s :%s' % (to, msg)\n\ndef join(channel):\n return 'JOIN %s' % channel\n\ndef leave(channel, reason=''):\n ...
python
chosen
[ { "from": "human", "value": "Add helper methods to render template blocks independently\n" }, { "from": "gpt", "value": "from django.template.loader_tags import BlockNode, ExtendsNode\nfrom django.template import loader, Context, RequestContext, TextNode\n\n# Most parts of this code has been tak...
python
chosen
[ { "from": "human", "value": "Add some Scala/Python conversion utilities\n" }, { "from": "gpt", "value": "from jnius import autoclass\n\ndef get_python_list(scala_list):\n \"\"\"Return list from elements of scala.collection.immutable.List\"\"\"\n python_list = []\n for i in range(scala_l...
python
chosen
[ { "from": "human", "value": "Add first simple system test, checks received num of packets\n" }, { "from": "gpt", "value": "import sys\nfrom os import path\nsys.path.append(path.join(path.dirname(path.dirname(path.abspath(__file__))), \"utils\", \"efushell\"))\nfrom verifymetrics import verify_me...
python
chosen
[ { "from": "human", "value": "Add a few tests for RedirectRobot.get_sd_template\n\nChange-Id: I79c8ef9129adc4bb623179429495c5bac0ecff78\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"Tests for the redirect.py script.\"\"\"\n#\n# (C) Pywikibot team, 2017\n#\n# Distributed under th...
python
chosen
[ { "from": "human", "value": "Add a script to reset the return delay time.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n# PyAX-12\n\n# The MIT License\n#\n# Copyright (c) 2010,2015,2017 Jeremie DECOCK (http://www.jdhp.org)\n#\n# Permission is hereby granted,...
python
chosen
[ { "from": "human", "value": "Add Open Sound Controller (OSC) example\n" }, { "from": "gpt", "value": "import s3g\nimport serial\nimport time\nimport optparse\nimport OSC\nimport threading\n\n\"\"\"\nControl an s3g device (Makerbot, etc) using osc!\n\nRequires these modules:\n* pySerial: http://p...
python
chosen
[ { "from": "human", "value": "Add a script to dump the .sel files\n" }, { "from": "gpt", "value": "import struct\nimport datetime\nimport argparse\nimport sys\n\nrecord_length = 128\n\ndef dump_content(filename):\n try:\n fp = open(filename, 'rb')\n except OSError as e:\n ...
python
chosen
[ { "from": "human", "value": "Add CoinFlip plugin for some coin flipping fun\n" }, { "from": "gpt", "value": "import random\nfrom plugin import CommandPlugin, PluginException\n\n\nclass CoinFlip(CommandPlugin):\n \"\"\"\n Flip a coin\n \"\"\"\n max_coin_flips = 1000000\n\n def __in...
python
chosen
[ { "from": "human", "value": "Add TIMIT dataset class for pylearn2.\n" }, { "from": "gpt", "value": "import numpy as np\nimport os\nfrom pylearn2.datasets import dense_design_matrix\nfrom pylearn2.utils import string_utils\n\nclass TIMIT(dense_design_matrix.DenseDesignMatrix):\n def __init__(s...
python
chosen
[ { "from": "human", "value": "Make this into a python package\n\ngit-svn-id: d22b6ed1b13e3e3451c5d6fab7d0adc235b2f27e@51 5128b7d6-d249-4073-bd28-aebf1259cb0a\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom setuptools import setup, find_packages\n\nsetup(name='pymorph',\n versi...
python
chosen
[ { "from": "human", "value": "Add a module for election-specific functions\n\nThis gives us an extra mechanism for customizing behaviour for different\nelections.\n" }, { "from": "gpt", "value": "from django.conf import settings\n\n# This is actually taken from Pombola's country-specific code pac...
python
chosen
[ { "from": "human", "value": "Add migration to add selected_texts_json column.\n" }, { "from": "gpt", "value": "\"\"\"empty message\n\nRevision ID: 62d4d27afcf\nRevises: 453729c2bc21\nCreate Date: 2014-11-03 14:52:53.884479\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\nrevision = '62d4d2...
python
chosen
[ { "from": "human", "value": "Add tests for AgentAddressRole and AgentAddressKind classes\n" }, { "from": "gpt", "value": "import pytest\n\nimport zmq\nfrom osbrain.core import AgentAddressKind\nfrom osbrain.core import AgentAddressRole\n\n\ndef twin_list(elements):\n result = elements[:]\n ...
python
chosen
[ { "from": "human", "value": "Add a command to transfer students from one course to another.\n\nMove only active students and also update cert item for verified students.\n" }, { "from": "gpt", "value": "from optparse import make_option\nfrom django.core.management.base import BaseCommand\nfrom d...
python
chosen
[ { "from": "human", "value": "Add script to get all Phoenix City data\n" }, { "from": "gpt", "value": "import json\nimport pymysql\n\n\ndef GetReviewsByID(business_id):\n conn = pymysql.Connect(host='localhost', user='root', passwd='',charset='utf8', db='yelpdb')\n cursor = conn.cursor()\n\...
python
chosen
[ { "from": "human", "value": "Add script to generate SiRF data for testing\n" }, { "from": "gpt", "value": "# Generate known SiRF binary data for testing purposes\n\nimport sys, struct, math\n\ndef nul(n): return chr(0) * n\n\ndef frame(mid, body):\n payload = chr(mid) + body\n n = len(pay...
python
chosen
[ { "from": "human", "value": "TST: Add a simple test for Gaussian arrays node (GaussianArrayARD).\n" }, { "from": "gpt", "value": "######################################################################\n# Copyright (C) 2013 Jaakko Luttinen\n#\n# This file is licensed under Version 3.0 of the GNU ...
python
chosen
[ { "from": "human", "value": "Migrate Auth0 data from Idp to UserProfiles.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.15 on 2018-09-20 16:54\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\ndef set_primary_auth0_user_id(ap...
python
chosen
[ { "from": "human", "value": "Add release variant type 'module'\n\nSigned-off-by: Nils Philippsen <ad3fa8d847df2b57853a376ad688e4be8041ecd4@redhat.com>\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n#\n# Copyright (c) 2016 Red Hat\n# Licensed under The MIT License (MIT)\n# http://opens...
python
chosen
[ { "from": "human", "value": "Add a little script to help figure out MIRAX\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\nimport struct, sys\n\nf = open(sys.argv[1])\n\nHEADER_OFFSET = 37\n\nf.seek(HEADER_OFFSET)\n\ntry:\n while True:\n n = struct.unpack(\"<i\", f.read(4))[0]\n ...
python
chosen
[ { "from": "human", "value": "Add utility functions for tests\n" }, { "from": "gpt", "value": "import numpy as np\n\n\ndef overwrite_labels(y):\n classes = np.unique(y)\n y[y==classes[0]] = -1\n y[y==classes[1]] = 1\n return y\n" } ]
python
chosen
[ { "from": "human", "value": "Add very simple demo unit tests\n" }, { "from": "gpt", "value": "# This is an example unit test suite for creating an AI\nfrom game import GameRunner, Board, Player\nfrom demo import BattleshipsAI\nfrom unittest import TestCase\n\nclass TestPlayer(Player):\n \"\"\...
python
chosen
[ { "from": "human", "value": "Add @memoized_property and @memoized_class_property decorators." }, { "from": "gpt", "value": "'''\nFunction helper functions.\n\nby Craig Buchek\n\nThese took a lot of trial and error to get right, but seem to be working well now.\nI read through a lot of various ot...
python
chosen
[ { "from": "human", "value": "[Incremental] Add a utility for generating simple output file maps\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom __future__ import print_function\n\nimport argparse\nimport json\nimport os\nimport sys\n\n\ndef fatal(msg):\n print(msg, file=sys.std...
python
chosen
[ { "from": "human", "value": "Add script to wait for puppet run to finish on non-build-nodes\n" }, { "from": "gpt", "value": "#\n# Copyright 2012 Cisco Systems, Inc.\n#\n# Author: Soren Hansen <sorhanse@cisco.com>\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# ...
python
chosen
[ { "from": "human", "value": "Add a tool-info module for BTOR2C\n\n- BTOR2C is a converter from BTOR2 models to C programs\n" }, { "from": "gpt", "value": "# This file is part of BenchExec, a framework for reliable benchmarking:\n# https://github.com/sosy-lab/benchexec\n#\n# SPDX-FileCopyrightTex...
python
chosen
[ { "from": "human", "value": "Move quiet_logs to separate module\n" }, { "from": "gpt", "value": "def quiet_logs(sc):\n logger = sc._jvm.org.apache.log4j\n logger.LogManager.getLogger(\"org\").setLevel(logger.Level.ERROR)\n logger.LogManager.getLogger(\"akka\").setLevel(logger.Level.ERRO...
python
chosen
[ { "from": "human", "value": "example: Add usage example of LRO_FASTESTMIRRORCACHE\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n\"\"\"\nlibrepo - download packages\n\"\"\"\n\nimport os\nimport os.path\nimport time\nimport librepo\n\nCACHE = \"fastestmirror.cache\"\n\nLIBREPOPKG = \"l...
python
chosen
[ { "from": "human", "value": "feat: Create first pass Gaussian Naive Bayes Classifer\n" }, { "from": "gpt", "value": "from feature_format import featureFormat, targetFeatureSplit\nimport pickle\nfrom sklearn.naive_bayes import GaussianNB\n\n# loading the enron data dictionary\nwith open(\"final_p...
python
chosen
[ { "from": "human", "value": "Add migration for nodes which may have previous shared a piwik_site_id\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"Update Piwik for nodes that were forked, registered or templated prior to\nOctober 2014.\n\"\"\"\n\nimport da...
python
chosen
[ { "from": "human", "value": "Add Database Migration for Column Rename\n\nMigrate the column `requests.agency_description` to `requests.agency_request_summary` and `requests.agency_description_release_date` to `requests.agency_request_summary_release_date`\n\nSigned-off-by: Joel Castillo <877468732c93e7fff2a...
python
chosen
[ { "from": "human", "value": "Add a simple echo client. (Though it has problems.)\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3.3\n\"\"\"Example echo client.\"\"\"\n\n# Stdlib imports.\nimport logging\nimport socket\nimport sys\nimport time\n\n# Local imports.\nimport scheduling\nimport...
python
chosen
[ { "from": "human", "value": "Rename base decoder to RNN decoder\n" }, { "from": "gpt", "value": "# Copyright 2017 Google Inc.\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# You may obtain a copy of th...
python
chosen
[ { "from": "system", "value": "Create test for plot_zipcode to compare generated graphs.\n" }, { "from": "human", "value": "\"\"\"\nName: Paul Briant\nDate: 12/11/16\nClass: Introduction to Python\nAssignment: Final Project\n\nDescription:\nTests for Final Project\n\"\"\"\n\nimport clean_data as ...
python
chosen
[ { "from": "human", "value": "Create test to dashboard capturista\n" }, { "from": "gpt", "value": "from django.core.urlresolvers import reverse\nfrom django.contrib.staticfiles.testing import StaticLiveServerTestCase\nfrom splinter import Browser\nfrom django.contrib.auth.models import User\nfrom...
python
chosen
[ { "from": "human", "value": "Add tests for the matcher\n" }, { "from": "gpt", "value": "from checkinchecker.checker import filter_matches\nfrom unittest import TestCase\n\nclass CheckerTests(TestCase):\n def test_match_filter_visulite(self):\n possibilities = [\n {\"id\": 0,...
python
chosen
[ { "from": "human", "value": "Add tests for temporary directory and ensure_dir\n" }, { "from": "gpt", "value": "import sys\nimport os\nsys.path.insert(0, os.path.realpath('.'))\nimport pytest\nimport string\nimport random\n\nimport create_movie as c\n\n\n@pytest.fixture\ndef tmp_dirname():\n r...
python
chosen
[ { "from": "human", "value": "Add ModelChoiceField util to use actual objects\n" }, { "from": "gpt", "value": "from django.forms import models\nfrom django.forms.fields import ChoiceField\n\n\nclass AdvancedModelChoiceIterator(models.ModelChoiceIterator):\n def choice(self, obj):\n retu...
python
chosen
[ { "from": "system", "value": "Use with statement to ensure the file is closed by Python\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nfrom setuptools import setup, find_packages\nimport simiki\n\n\nentry_points = {\n \"console_scripts\": [\n \"simiki = simiki.cli:main\",\...
python
chosen
[ { "from": "human", "value": "Add tests for all hug types\n" }, { "from": "gpt", "value": "\"\"\"tests/test_types.py.\n\nTests the type validators included with hug\n\nCopyright (C) 2015 Timothy Edmund Crosley\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this...
python
chosen
[ { "from": "human", "value": "Add py solution for 526. Beautiful Arrangement\n\n526. Beautiful Arrangement: https://leetcode.com/problems/beautiful-arrangement/\n" }, { "from": "gpt", "value": "class Solution(object):\n def countArrangement(self, N):\n \"\"\"\n :type N: int\n ...
python
chosen
[ { "from": "human", "value": "Add seconds and hours exercise\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndef toSeconds(h, m, s):\n return h * 3600 + m * 60 + s\n\ndef toHoursMinutesAndSeconds(s):\n hours = s / 3600\n minutes = s % 3600 / 60\n seconds = s...
python
chosen
[ { "from": "human", "value": "Add basic test for load_all_msgs\n" }, { "from": "gpt", "value": "import dirq\nimport mock\nimport os\nimport shutil\nimport tempfile\nimport unittest\n\nimport apel.db.loader\n\n\nschema = {\"body\": \"string\", \"signer\": \"string\",\n \"empaid\": \"strin...
python
chosen
[ { "from": "human", "value": "Add Testbed image migration script\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\n\"\"\"A scrip for migrating Testbed images from database to external storage.\"\"\"\n\nimport argparse\nfrom pathlib import Path\n\nimport psycopg2\n\n\ndef read_images(curs...
python
chosen
[ { "from": "system", "value": "Fix trivial unit test error that started when numpy version changed\n\nThe version of numpy brought in by pip changed, which changed some\ntest outputs in meaningless ways (ie, spaces), and\nthose meaningless changes broke a unit test with\n assertEquals( \"string literal\",...
python
chosen