conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add skeleton for parsing commands\n" }, { "from": "gpt", "value": "\"\"\"lazy\n\n Usage:\n lazy (new|n)\n lazy (show|s) [<id>]\n lazy (delete|d) [<id>]\n lazy (import|i) <path>\n lazy (export|e) <path> [<id>]\n\n Options:\n ...
python
chosen
[ { "from": "human", "value": "Add boilerplate with simple test sounds\n" }, { "from": "gpt", "value": "from optparse import make_option\nfrom django.conf import settings\nfrom django.core.management.base import BaseCommand, CommandError\nfrom django.contrib.auth.models import User\nfrom django.te...
python
chosen
[ { "from": "human", "value": "Add script demonstrating thread deadlock\n" }, { "from": "gpt", "value": "\n\"\"\"\n Demonstrates deadlock related to attribute iteration.\n\"\"\"\n\nfrom threading import Thread\n\nimport h5py\n\nFNAME = \"deadlock.hdf5\"\n\ndef make_file():\n with h5py.File(F...
python
chosen
[ { "from": "human", "value": "Remove the hard-coded extra 'cv' and 'program' fields\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 ...
python
chosen
[ { "from": "human", "value": "Add first revision of Nautilus extension.\n\nFeatures: Adds file properties for wizbit controlled\nand wizbit conflicting. Adds emblems to the file for\nthese states.\n" }, { "from": "gpt", "value": "from urlparse import urlparse\nfrom os.path import exists, split, i...
python
chosen
[ { "from": "human", "value": "Remove managers for article obj.\n\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.29 on 2021-08-12 12:54\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n...
python
chosen
[ { "from": "human", "value": "Add script to generate the site documentation containing the sizes of the binary shellcodes." }, { "from": "gpt", "value": "import os, re;\r\n# I got the actual size of the binary code wrong on the site once - this script should help prevent that.\r\n\r\ndsDoc_by_sAr...
python
chosen
[ { "from": "human", "value": "Test all sensors at once\n" }, { "from": "gpt", "value": "import time\nimport grove_i2c_temp_hum_mini # temp + humidity\nimport hp206c # altitude + temp + pressure\nimport grovepi # used by air sensor and dust sensor\nimport atexit # used for the dust sensor\nimport...
python
chosen
[ { "from": "human", "value": "Add unittests for the bridgedb.crypto module.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n#\n# This file is part of BridgeDB, a Tor bridge distribution system.\n#\n# :authors: Isis Lovecruft 0xA3ADB67A2CDB8B35 <isis@torproject.org>\n# please a...
python
chosen
[ { "from": "human", "value": "Add Weather class (use forecastio, geopy) - forecase(current/daily)\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nimport datetime\nimport forecastio\nfrom geopy.geocoders import GoogleV3\n\nfrom kino.template import MsgTemplate\nfrom slack.slackbot impo...
python
chosen
[ { "from": "human", "value": "Add script to count labels in a data set\n\n(Moved from embodied emotions ml code.)\n" }, { "from": "gpt", "value": "\"\"\"Count HEEM labels in data set.\n\nUsage: python count_labels.py <dir with train and test files>\n\"\"\"\nimport codecs\nfrom glob import glob\ni...
python
chosen
[ { "from": "human", "value": "Print the left view of a BST\n" }, { "from": "gpt", "value": "class BST:\n def __init__(self,val):\n self.left = None\n self.right = None\n self.data = val\n\ndef insertToBst(root,value):\n if root is None:\n root = value\n else:\...
python
chosen
[ { "from": "human", "value": "Add migration for legislator change\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 ('legislator...
python
chosen
[ { "from": "human", "value": "[algorithm] Solve hackerrank linked list problem\n" }, { "from": "gpt", "value": "# https://www.hackerrank.com/challenges/delete-duplicate-value-nodes-from-a-sorted-linked-list/problem\n\ndef RemoveDuplicates(head):\n if head is None:\n return None\n \n ...
python
chosen
[ { "from": "human", "value": "Add tool to regenerate JSON files from P4 progs\n\ntools/update_test_bmv2_jsons.py can be used to regenerate all the bmv2\nJSON files from their P4 counterpart\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2\n\nimport argparse\nimport fnmatch\nimport os\nimpo...
python
chosen
[ { "from": "human", "value": "Add taxonomy model and initiation\n" }, { "from": "gpt", "value": "import json\nimport os\n\nfrom website import settings\n\nfrom modularodm import fields, Q\nfrom modularodm.exceptions import NoResultsFound\n\nfrom framework.mongo import (\n ObjectId,\n Stored...
python
chosen
[ { "from": "human", "value": "Add benchmarks for custom generators\n" }, { "from": "gpt", "value": "from tohu.v6.primitive_generators import Integer, HashDigest, FakerGenerator\nfrom tohu.v6.derived_generators import Apply, Lookup, SelectOne, SelectMultiple\nfrom tohu.v6.custom_generator import C...
python
chosen
[ { "from": "human", "value": "Add a script for storing a config variable\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- encoding: utf-8\n\"\"\"\nStore a config variable in SSM under the key structure\n\n /{project_id}/config/{label}/{config_key}\n\nThis script can store a regula...
python
chosen
[ { "from": "human", "value": "Add toy example of reading a large XML file\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport xml.etree.cElementTree as ET\nfrom sys import argv\n\ninput_file = argv[1]\n\nNAMESPACE = \"{http://www.mediawiki.org/xml/export-0.10/}\"\n\nwith open(input_f...
python
chosen
[ { "from": "human", "value": "Add solution for problem 4\n" }, { "from": "gpt", "value": "from itertools import combinations_with_replacement\nfrom operator import mul\n\nthree_digit_numbers = tuple(range(100, 1000))\n\ncombinations = combinations_with_replacement(three_digit_numbers, 2)\n\nprodu...
python
chosen
[ { "from": "human", "value": "Add local dev settings module\n" }, { "from": "gpt", "value": "from .base_settings import *\n\nDEBUG = True\n\nLANGUAGE_CODE = 'en'\n\nTIME_FORMAT = [\n\n '%I:%M %p',\n '%H:%M %p',\n]\n\n\nTIME_INPUT_FORMATS = [\n '%I:%M %p',\n '%H:%M %p'\n]\n" } ]
python
chosen
[ { "from": "human", "value": "Add basic tests for custom_urls system\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom djangosanetesting import UnitTestCase\n\nfrom django.http import Http404\n\nfrom ella.core.custom_urls import DetailDispatcher\n\n# dummy functions to register as vi...
python
chosen
[ { "from": "human", "value": "Add a few unit tests for libvirt_conn." }, { "from": "gpt", "value": "# vim: tabstop=4 shiftwidth=4 softtabstop=4\n#\n# Copyright 2010 OpenStack LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except i...
python
chosen
[ { "from": "human", "value": "Copy SBSolarcell tests into individual file\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport numpy as np\nimport ibei\nfrom astropy import units\nimport unittest\n\ntemp_sun = 5762.\ntemp_earth = 288.\nbandgap = 1.15\n\ninput_params = {\"temp_sun\": t...
python
chosen
[ { "from": "human", "value": "Create sitemap for google news\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom django.contrib.sitemaps import GenericSitemap\nfrom django.contrib.sites.models import Site\n\n\nclass GoogleNewsSitemap(GenericSitemap):\n # That'...
python
chosen
[ { "from": "system", "value": "Add args to survey_data url\n" }, { "from": "human", "value": "from django.conf.urls.defaults import *\n\nfrom . import views\n\nurlpatterns = patterns('',\n url(r'^profile/$', views.profile_index, name='survey_profile'),\n url(r'^profile/electric/$', views.pr...
python
chosen
[ { "from": "human", "value": "Make SurfaceHandler (for sfc data)\n" }, { "from": "gpt", "value": "from glob import glob\n# Third-party modules\nimport pandas as pd\n# Hand-made modules\nfrom base import LocationHandlerBase\n\nSFC_REGEX_DIRNAME = \"sfc[1-5]\"\nKWARGS_READ_CSV_SFC_MASTER = {\n \...
python
chosen
[ { "from": "human", "value": "Add default value for the fields object and field of the social network app model\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):...
python
chosen
[ { "from": "human", "value": "Add tool for generating the JSONP required by the documentation versions.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n#\n# Copyright © 2014 Cask Data, Inc.\n#\n# Used to generate JSONP from a CDAP documentation directory on a we...
python
chosen
[ { "from": "human", "value": "Add python script to write lib svm expected data format from my collected data\n" }, { "from": "gpt", "value": "\"\"\"\nA script to write out lib svm expected data format from my collecting data\n\"\"\"\nimport os\nimport sys\nimport csv\nimport getopt\n\ncmd_usage =...
python
chosen
[ { "from": "human", "value": "Add unit test for run_nohw\n" }, { "from": "gpt", "value": "\"\"\"\nTest the \"snabb lwaftr run_nohw\" subcommand.\n\"\"\"\n\nimport unittest\n\nfrom random import randint\nfrom subprocess import call, check_call\nfrom test_env import DATA_DIR, SNABB_CMD, BaseTestCas...
python
chosen
[ { "from": "human", "value": "Add organisation for TFL Dial a Ride\n\nReferences image added in:\n- [ ] https://github.com/alphagov/notifications-admin/pull/1321\n" }, { "from": "gpt", "value": "\"\"\"empty message\n\nRevision ID: 0098_tfl_dar\nRevises: 0097_notnull_inbound_provider\nCreate Date:...
python
chosen
[ { "from": "human", "value": "Add migration version? Not sure if this is right\n" }, { "from": "gpt", "value": "\"\"\"empty message\n\nRevision ID: 3025c44bdb2\nRevises: None\nCreate Date: 2014-12-16 12:13:55.759378\n\n\"\"\"\n\n# revision identifiers, used by Alembic.\nrevision = '3025c44bdb2'\n...
python
chosen
[ { "from": "human", "value": "Add helpful script for ascii checking - fyi @bruskiza\n" }, { "from": "gpt", "value": "import json\nfiles = [\"go-ussd_public.ibo_NG.json\"]\n\n\ndef is_ascii(s):\n return all(ord(c) < 128 for c in s)\n\ncurrent_message_id = 0\nfor file_name in files:\n json_fi...
python
chosen
[ { "from": "human", "value": "Add file for tests of start symbol as not nonterminal\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\n:Author Patrik Valkovic\n:Created 10.08.2017 23:12\n:Licence GNUv3\nPart of grammpy\n\n\"\"\"\n\nfrom unittest import TestCase, main\nfrom grammpy im...
python
chosen
[ { "from": "human", "value": "Add script to create a historic->modern dictionary\n\nThe script takes as input a modern->historic variants dictionary in a\njson file (created by the generate_historic_liwc script) and\nreverses it to a dictionary that can be used to replace historic words\nwith their modern va...
python
chosen
[ { "from": "human", "value": "Add a few tests for docparse.\n\ngit-svn-id: 24f545668198cdd163a527378499f2123e59bf9f@338 ead46cd0-7350-4e37-8683-fc4c6f79bf00\n" }, { "from": "gpt", "value": "from nipype.testing import *\n\nfrom nipype.utils.docparse import reverse_opt_map, build_doc\n\nclass Foo(o...
python
chosen
[ { "from": "human", "value": "Remove old notification status column\n" }, { "from": "gpt", "value": "\"\"\"\n\nRevision ID: 0109_rem_old_noti_status\nRevises: 0108_change_logo_not_nullable\nCreate Date: 2017-07-10 14:25:15.712055\n\n\"\"\"\nfrom alembic import op\nimport sqlalchemy as sa\nfrom sq...
python
chosen
[ { "from": "human", "value": "Add an index on notifications for (service_id, created_at) to improve the performance of the notification queries.\nWe've already performed this update on production since you need to create the index concurrently, which is not allowed from the alembic script. For that reason we...
python
chosen
[ { "from": "human", "value": "Add solution class for Ghia et al. (1982)\n" }, { "from": "gpt", "value": "\"\"\"\nImplementation of the class `GhiaEtAl1982` that reads the centerline velocities\nreported in Ghia et al. (1982).\n\n_References:_\n* Ghia, U. K. N. G., Ghia, K. N., & Shin, C. T. (1982...
python
chosen
[ { "from": "human", "value": "NN: Add smile detection example script.\n" }, { "from": "gpt", "value": "# Simle detection using Haar Cascade + CNN.\nimport sensor, time, image, os, nn\n\nsensor.reset() # Reset and initialize the sensor.\nsensor.set_contrast(2)\nsensor.set_...
python
chosen
[ { "from": "human", "value": "Add decorator to make a Node class from a regular function\n" }, { "from": "gpt", "value": "\"\"\"\nNodetree decorators.\n\"\"\"\n\nimport inspect\nimport textwrap\nimport node\n\n\ndef underscore_to_camelcase(value):\n def camelcase(): \n yield str.lower\n...
python
chosen
[ { "from": "human", "value": "Add location name lookup for ajax_select.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n##\n## Author: Orcun Avsar <orc.avs@gmail.com>\n##\n## Copyright (C) 2011 S2S Network Consultoria e Tecnologia da Informacao LTDA\n##\n## This p...
python
chosen
[ { "from": "human", "value": "Work on defining RegEx to find and format molecular geometries in Gaussian output files.\n" }, { "from": "gpt", "value": "__author__ = 'Thomas Heavey'\n\nimport re\n\nfilename = \"testg.out\"\n\ndef findgeoms(filename):\n \"\"\"A function that takes a file name an...
python
chosen
[ { "from": "human", "value": "Add default ordering of progress outcome groups\n" }, { "from": "gpt", "value": "# Generated by Django 2.1.5 on 2019-07-31 07:12\n\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('poet', '0002_progressou...
python
chosen
[ { "from": "human", "value": "Add python script to parse JSON output\n" }, { "from": "gpt", "value": "#!/usr/bin/python2.7\nimport json\nimport socket\nimport sys\n\ndef readOutput(host, port):\n\tdata = None\n\ts = None\n\ttry:\n\t\ts = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n\t\ts.co...
python
chosen
[ { "from": "human", "value": "Add migration for CI fix\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.29 on 2021-09-22 07:29\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.db.models.deletion\n\n\nclass Migr...
python
chosen
[ { "from": "human", "value": "Add script to send unregister user emails\n\n...to unregistered contributors who didn't receive the email\nafter 568413a77cc51511a0f7afe081a218676a36ebb6 was deployed\n\nRelates to [OSF-7935]\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"Sends an un...
python
chosen
[ { "from": "human", "value": "Add unit tests on cache handler\n\nChange-Id: Ife6600da240f830aa0080e3f214cedf1389ea512\n" }, { "from": "gpt", "value": "# Copyright (c) 2020 OpenStack Foundation.\n# All Rights Reserved.\n\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you m...
python
chosen
[ { "from": "human", "value": "Add stub for qiprofile update test.\n" }, { "from": "gpt", "value": "import os\nimport glob\nimport shutil\nfrom nose.tools import (assert_equal, assert_is_not_none)\nimport qixnat\nfrom ... import (project, ROOT)\nfrom ...helpers.logging import logger\nfrom qipipe.h...
python
chosen
[ { "from": "human", "value": "Add test for layers module.\n" }, { "from": "gpt", "value": "import theanets\nimport numpy as np\n\n\nclass TestLayer:\n def test_build(self):\n layer = theanets.layers.build('feedforward', nin=2, nout=4)\n assert isinstance(layer, theanets.layers.La...
python
chosen
[ { "from": "human", "value": "Add tests for proxy drop executable\n" }, { "from": "gpt", "value": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this\n# file, You can obtain one at http://mozilla.org/MPL/2.0...
python
chosen
[ { "from": "human", "value": "Add script to run tests\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport argparse\nimport sys\n\nimport django\nfrom django.conf import settings\nfrom django.test.utils import get_runner\n\n\ndef runtests(test_labels):\n settings.configure(INSTALLED_...
python
chosen
[ { "from": "human", "value": "Add test for APS2 instruction merging.\n\nA reduced example of the failing situation from issue #90.\n" }, { "from": "gpt", "value": "import h5py\nimport unittest\nimport numpy as np\nfrom copy import copy\n\nfrom QGL import *\nfrom instruments.drivers import APS2Pat...
python
chosen
[ { "from": "human", "value": "Add test cases for gabor filter\n" }, { "from": "gpt", "value": "import numpy as np\nfrom numpy.testing import assert_almost_equal, assert_array_almost_equal\n\nfrom skimage.filter import gabor_kernel, gabor_filter\n\n\ndef test_gabor_kernel_sum():\n for sigmax in...
python
chosen
[ { "from": "human", "value": "Add script to count parameters of PyTorch model\n\nSigned-off-by: Tushar Pankaj <514568343cdd6c4d7c6bb94cf636e24b01176284@gmail.com>\n" }, { "from": "gpt", "value": "import sys\nimport numpy as np\nimport torch\n\nmodel = torch.load(sys.argv[1])\nparams = 0\nfor key ...
python
chosen
[ { "from": "human", "value": "tools: Add some simple MediaWiki importer.\n" }, { "from": "gpt", "value": "import os\nimport os.path\nimport argparse\nfrom sqlalchemy import create_engine\n\n\ndef main():\n parser = argparse.ArgumentParser()\n parser.add_argument('url')\n parser.add_argum...
python
chosen
[ { "from": "human", "value": "Create masked version based on pbcov cutogg\n" }, { "from": "gpt", "value": "\n'''\nCut out noisy regions by imposing a mask of the primary beam coverage.\n'''\n\nfrom astropy.io import fits\nfrom spectral_cube import SpectralCube\nfrom spectral_cube.cube_utils impor...
python
chosen
[ { "from": "human", "value": "Check consecutive elements in an array\n" }, { "from": "gpt", "value": "import unittest\n\"\"\"\nGiven an unsorted array of numbers, return true if the array only contains consecutive elements.\nInput: 5 2 3 1 4\nOuput: True (consecutive elements from 1 through 5)\nI...
python
chosen
[ { "from": "human", "value": "Add missing python 3 only file.\n\nAs title.\n" }, { "from": "gpt", "value": "\"\"\"\nUsecases with Python 3 syntax in the signatures. This is a separate module\nin order to avoid syntax errors with Python 2.\n\"\"\"\n\n\nclass TestClass1(object):\n def __init__(s...
python
chosen
[ { "from": "human", "value": "Add migration script for changing users with None as email_verifications to {}\n" }, { "from": "gpt", "value": "\"\"\" Ensure that users with User.email_verifications == None now have {} instead\n\"\"\"\n\nimport logging\nimport sys\nfrom tests.base import OsfTestCas...
python
chosen
[ { "from": "human", "value": "Add intial unit test file\n\nCurrently just tests the two primary functions, the results are a bit\nbrittle but that will allow us to detect regressions for future work.\n" }, { "from": "gpt", "value": "import pytest\nfrom main import *\n\ntest_files = [ \"examples/...
python
chosen
[ { "from": "system", "value": "Test for invalid data when loading\n" }, { "from": "human", "value": "import unittest\nfrom robot.utils.asserts import assert_true, assert_raises\n\nfrom robotide.application.chiefcontroller import ChiefController\nfrom robotide.namespace import Namespace\n\nfrom re...
python
chosen
[ { "from": "human", "value": "Add migration for unitconnection section types\n" }, { "from": "gpt", "value": "# Generated by Django 4.0.5 on 2022-06-22 05:40\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n (\"services\", \"0...
python
chosen
[ { "from": "human", "value": "Add alternate example for `match_template`.\n" }, { "from": "gpt", "value": "\"\"\"\n=================\nTemplate Matching\n=================\n\nIn this example, we use template matching to identify the occurrence of an\nimage patch (in this case, a sub-image centered...
python
chosen
[ { "from": "human", "value": "Add a solution to the phone number problem: can a phone number be represented as words in a dictionary?\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport unittest\n\nwords = set([\"dog\", \"clog\", \"cat\", \"mouse\", \"rat\", \"can\",\n \"...
python
chosen
[ { "from": "human", "value": "lib: Add a script for generating unicode name table\n\nGLib doesn't have a way to get unicode char names, so we'll have to\nreimplement this.\n" }, { "from": "gpt", "value": "#!/usr/bin/python3\n\n# Input: https://www.unicode.org/Public/UNIDATA/UnicodeData.txt\n\nimp...
python
chosen
[ { "from": "human", "value": "Add regression test with non ' ' space character as token\n\n" }, { "from": "gpt", "value": "# coding: utf-8\n\nfrom io import StringIO\n\nword2vec_str = \"\"\", -0.046107 -0.035951 -0.560418\nde -0.648927 -0.400976 -0.527124\n. 0.113685 0.439990 -0.634510\n  -1.4991...
python
chosen
[ { "from": "human", "value": "Add tests to cover no framework, no problem\n" }, { "from": "gpt", "value": "import unittest\n\nfrom .helpers import run_module\n\n\nclass MiscTests(unittest.TestCase):\n def setUp(self):\n self.name = \"benchmarker\"\n\n def test_no_framework(self):\n ...
python
chosen
[ { "from": "human", "value": "Add tests for the run() function\n" }, { "from": "gpt", "value": "import sys\nimport tempfile\nimport unittest\n\ntry:\n from StringIO import StringIO\nexcept ImportError:\n from io import StringIO\n\nimport icon_font_to_png\n\nclass TestRun(unittest.TestCase):...
python
chosen
[ { "from": "human", "value": "Add a sample python file interesting to debug\n" }, { "from": "gpt", "value": "import sys\nimport os\nimport time\nimport threading\nimport ikpdb\n\nTEST_MULTI_THREADING = False\nTEST_EXCEPTION_PROPAGATION = False\nTEST_POSTMORTEM = True\nTEST_SYS_EXIT = 0\nTEST_STEP...
python
chosen
[ { "from": "human", "value": "Add script that tests AI players\n" }, { "from": "gpt", "value": "from AI import *\nimport random\n\ndef RandomPlayer(game):\n return 0, random.choice(game.get_available_moves())\n\ndef ABPlayer(game):\n return alpha_beta_search(game, 8, -np.inf, np.inf, True, ...
python
chosen
[ { "from": "human", "value": "Add tsstats/event.py for easy event-initialization\n" }, { "from": "gpt", "value": "from collections import namedtuple\n\nEvent = namedtuple(\n 'Event', ['timestamp', 'identifier', 'action', 'arg', 'arg_is_client']\n)\n\n\ndef nick(timestamp, identifier, nick):\n ...
python
chosen
[ { "from": "human", "value": "Add tenant exporter for accounting\n" }, { "from": "gpt", "value": "import json\n\nfrom rest_framework.authtoken.models import Token\nfrom django.contrib.contenttypes.models import ContentType\nfrom django.core.management.base import BaseCommand\n\nfrom bluebottle.cl...
python
chosen
[ { "from": "human", "value": "Add migration for changing docstring of Note.is_private to unicode\n\n(instead of a bytes)\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.4 on 2016-06-28 09:13\nfrom __future__ import unicode_literals\n\nfrom django.db import migr...
python
chosen
[ { "from": "human", "value": "Create Find the Celebrity sol for Leetcode\n" }, { "from": "gpt", "value": "# The knows API is already defined for you.\n# @param a, person a\n# @param b, person b\n# @return a boolean, whether a knows b\n# def knows(a, b):\n\nclass Solution(object):\n def findCel...
python
chosen
[ { "from": "human", "value": "Add initial version of the script\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\n#stdlib\nimport json\nimport os\nimport subprocess\nfrom xml.dom.minidom import parseString\n\ndef which(cmd):\n \"\"\"Python implementation of `which` command.\"\"\"\n for ...
python
chosen
[ { "from": "system", "value": "Remove confusing navigation tabs from header.\n" }, { "from": "human", "value": "from r2.lib.pages import Reddit\nfrom r2.lib.wrapped import Templated\n\n\nclass DonatePage(Reddit):\n extra_stylesheets = Reddit.extra_stylesheets + [\"donate.less\"]\n\n def __i...
python
chosen
[ { "from": "human", "value": "Add a place to put random stuff and a list of components as a python module.\n" }, { "from": "gpt", "value": "COMPONENTS = [\t\n \"AdaBoost\",\n\t\"AutoInvert\",\n\t\"AutoMlpClassifier\",\n\t\"BiggestCcExtractor\",\n\t\"BinarizeByHT\",\n\t\"BinarizeByOtsu\",\n\t\"...
python
chosen
[ { "from": "human", "value": "Add test for redis test helper\n" }, { "from": "gpt", "value": "import json\n\nfrom twisted.trial.unittest import TestCase\nfrom twisted.internet.defer import inlineCallbacks\n\nfrom vumi_http_retry.tests.redis import create_client, zitems\n\n\nclass TestRedis(TestCa...
python
chosen
[ { "from": "human", "value": "Create BT Comm wrapper class\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n# Copyright (c) 2016 F Dou<programmingrobotsstudygroup@gmail.com>\n# See LICENSE for details.\n\n\nimport bluetooth\nimport logging\n\nclass RxBtComm(object):\n ...
python
chosen
[ { "from": "human", "value": "Solve Code Fights extract each kth problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Extract Each Kth Problem\n\n\ndef extractEachKth(inputArray, k):\n return [e for i, e in enumerate(inputArray) if (i + 1) % k != 0]\n\n\ndef main():\...
python
chosen
[ { "from": "system", "value": ":art: Add fields expicitly declared in form\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 ugettext_lazy as _\...
python
chosen
[ { "from": "human", "value": "Add solution to exercis 3.6.\n" }, { "from": "gpt", "value": "# 3-6 Guest List\n\nguest_list = [\"Albert Einstein\", \"Isac Newton\", \"Marie Curie\", \"Galileo Galilei\"]\n\nmessage = \"Hi \" + guest_list[0] + \" you are invited to dinner at 7 on saturday.\"\nprint(...
python
chosen
[ { "from": "human", "value": "Add migration removing generated objects with factories\n" }, { "from": "gpt", "value": "# Generated by Django 2.0.13 on 2020-04-06 13:40\n\nfrom django.conf import settings\nfrom django.contrib.gis.geos import Point, LineString\nfrom django.db import migrations\n\n\...
python
chosen
[ { "from": "human", "value": "Add test file for graph.py and add test of Greengraph class constructor\n" }, { "from": "gpt", "value": "from greengraph.map import Map\nfrom greengraph.graph import Greengraph\nfrom mock import patch\nimport geopy\nfrom nose.tools import assert_equal\n\nstart = \"Lo...
python
chosen
[ { "from": "human", "value": "Add a data analyzer class.\n\nMight come in handy to get statistical data of image datasets.\n" }, { "from": "gpt", "value": "\"\"\"\nDataAnalyzer\n\n:Authors:\n\tBerend Klein Haneveld\n\"\"\"\n\n\nclass DataAnalyzer(object):\n\t\"\"\"\n\tDataAnalyzer\n\t\"\"\"\n\n\t...
python
chosen
[ { "from": "human", "value": "Add new sms message generator\n" }, { "from": "gpt", "value": "def generate_new_procedure_message(procedure, ward, timeframe, doctor):\n unique_reference = str(1)\n message = str.format(\"{0} is available on {1}. Attend the ward in {2} and meet {3} in the junio...
python
chosen
[ { "from": "human", "value": "Add connect2 wifi via pyobjc\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\"\"\"\nI didn't create this but I'm storing it so I can reuse it.\nhttp://stackoverflow.com/a/34967364/4811765\n\"\"\"\nimport objc\n\nSSID = \"MyWifiNetwork\"\nPASSWORD = \"MyWifiPassw...
python
chosen
[ { "from": "human", "value": "Add utility class for evaluation\n" }, { "from": "gpt", "value": "\nclass EvaluationUtility(object):\n @staticmethod\n def convert_to_text(graph, clusters):\n # convert clustering result from graph to text\n new_clusters = {}\n for cluster_...
python
chosen
[ { "from": "human", "value": "Add framework for own SVM from scratch\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"Support Vector Machine (SVM) classification for machine learning.\n\nSVM is a binary classifier. The objective of the SVM is to find the best\nseparating hyperplane...
python
chosen
[ { "from": "human", "value": "Add ci settings file for postgresql database\n" }, { "from": "gpt", "value": "\"\"\"\nConfiguration file for running tests against a MySQL database.\n\"\"\"\n\nfrom InvenTree.settings import *\n\n# Override the 'test' database\nif 'test' in sys.argv:\n eprint('Inv...
python
chosen
[ { "from": "human", "value": "Solve Code Fights different rightmost bit problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Different Right-most Bit (Core) Problem\n\n\ndef differentRightmostBit(n, m):\n return (n ^ m) & -(n ^ m)\n\n\ndef main():\n tests = [\n [1...
python
chosen
[ { "from": "human", "value": "Add file writer utility script\n" }, { "from": "gpt", "value": "#!/bin/env python\n\nimport argparse\nimport sys\nimport os\n\nparser = argparse.ArgumentParser(description=\"Write multiple svgs from stdin to files\")\nparser.add_argument('-o', '--outfile', metavar='O...
python
chosen
[ { "from": "human", "value": "Add missing migration for invoice status\n\n- ITACLOUD-4886\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 =...
python
chosen
[ { "from": "human", "value": "Add validation function removed from main script.\n" }, { "from": "gpt", "value": "from schema import Schema\n\n\ndef validate_file_option(file_option, msg):\n msg = \"{msg} '{file}'.\".format(msg=msg, file=file_option)\n return Schema(open, error=msg).validate...
python
chosen
[ { "from": "human", "value": "Copy of Ryan's PCMToWave component.\n\nMatt\n" }, { "from": "gpt", "value": "from Axon.Component import component\nimport string\nimport struct\nfrom Axon.Ipc import producerFinished, shutdown\n\nclass PCMToWave(component):\n def __init__(self, bytespersample, sam...
python
chosen
[ { "from": "human", "value": "Add migration for user manager\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.9.13 on 2018-02-22 20:44\nfrom __future__ import unicode_literals\n\nimport kolibri.auth.models\nfrom django.db import migrations\n\n\nclass Migration(mig...
python
chosen
[ { "from": "human", "value": "Add data migration to create gesinv\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\n\ndef create_extra_users(apps, schema_editor):\n user = apps.get_model(\"auth.User\...
python
chosen
[ { "from": "human", "value": "Add solution for 136_Single Number with XOR operation.\n" }, { "from": "gpt", "value": "class Solution(object):\n def singleNumber(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: int\n \"\"\"\n\n #Using XOR to find the si...
python
chosen