conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Add test cases for Malayalam transliteration\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\nfrom __future__ import unicode_literals\n\nimport unittest\nimport unicodedata\n\nimport epitran\n\n\nclass TestMalayalamGeneral(unittest.TestCase):\n def setU...
python
chosen
[ { "from": "human", "value": "Add example plugin for parser secure logs\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding:utf-8 -*-\n\nimport sys\nsys.path.insert(0, \"..\")\nimport re\n\nfrom libs.manager import Plugin\nfrom libs.mail import send_mail\n\nclass SecureCheck(Plug...
python
chosen
[ { "from": "human", "value": "Add py solution for 477. Total Hamming Distance\n\n477. Total Hamming Distance: https://leetcode.com/problems/total-hamming-distance/\n" }, { "from": "gpt", "value": "from collections import Counter\nclass Solution(object):\n def totalHammingDistance(self, nums):\...
python
chosen
[ { "from": "system", "value": "Remove the auth contenttypes thing for now, needs improvement\n" }, { "from": "human", "value": "\"\"\"\nSouth-specific signals\n\"\"\"\n\nfrom django.dispatch import Signal\nfrom django.conf import settings\n\n# Sent at the start of the migration of an app\npre_mig...
python
chosen
[ { "from": "human", "value": "Add a couple set benchmarks\n" }, { "from": "gpt", "value": "\"\"\"\nBenchmark various operations on sets.\n\"\"\"\n\nfrom __future__ import division\n\nimport numpy as np\n\nfrom numba import jit\n\n\n# Set benchmarks\n# Notes:\n# - unless we want to benchmark marsh...
python
chosen
[ { "from": "human", "value": "Add disabled Ping integration test\n" }, { "from": "gpt", "value": "import uuid\n\nfrom kitten.server import KittenServer\nfrom kitten.request import KittenRequest\n\nfrom mock import MagicMock\nimport gevent\n\n\nclass TestPropagation(object):\n def setup_method(...
python
chosen
[ { "from": "human", "value": "Add script for checkpoint averaging\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom __future__ import print_function\n\nimport os\nimport sys\nimport argparse\n\nimport numpy as np\n\n# Parse arguments\nparser = argparse.ArgumentParser()\nparser.add_ar...
python
chosen
[ { "from": "human", "value": "Add migration for feedback tags\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10 on 2016-08-27 01:39\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nimport taggit.managers\n\n\nclass Migration(migratio...
python
chosen
[ { "from": "human", "value": "Add example of running an isolated step without using Swarm\n\nTBR=csharp@chromium.org\nBUG=\n\n\nReview URL: https://chromiumcodereview.appspot.com/11070006\n\ngit-svn-id: d5a9b8648c52d490875de6588c8ee7ca688f9ed1@160586 0039d316-1c4b-4281-b951-d872f2087c98\n" }, { "from...
python
chosen
[ { "from": "human", "value": "Add script to print num configs\n\nPiperOrigin-RevId: 240189946\n" }, { "from": "gpt", "value": "# coding=utf-8\n# Copyright 2019 The TensorFlow Datasets Authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file exc...
python
chosen
[ { "from": "human", "value": "Implement Parametizer class for defining and cleaning GET parameters\n\nA subclass can define class-level variables and clean_* methods for cleaning\ninput parameter values\n" }, { "from": "gpt", "value": "def clean_bool(value, allow_none=False):\n if isinstance(v...
python
chosen
[ { "from": "human", "value": "Add a debugging plugin to log the size of the queue.\n" }, { "from": "gpt", "value": "\nimport logging\n\nlogger = logging.getLogger(__name__)\n\nfrom arke.collect import Collect\n\nclass queue_monitor(Collect):\n default_config = {'interval': 60,\n ...
python
chosen
[ { "from": "human", "value": "Add example to show random search vs gp\n" }, { "from": "gpt", "value": "from time import time\n\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom sklearn.base import clone\nfrom sklearn.datasets import load_digits\nfrom sklearn.ensemble import RandomFores...
python
chosen
[ { "from": "human", "value": "Add basic tests of number str() formatting.\n\n\ngit-svn-id: 77a43f9646713b91fea7788fad5dfbf67e151ece@5396 94b884b6-d6fd-0310-90d3-974f1d3f35e1\n" }, { "from": "gpt", "value": "import numpy as np\nfrom numpy.testing import *\n\nclass TestPrint(TestCase):\n\n def t...
python
chosen
[ { "from": "human", "value": "Remove obsolete locales, pa and fy\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\n\ndef remove_pa_fy(apps, schema_editor):\n Locale = apps.get_model('base', 'Locale')...
python
chosen
[ { "from": "human", "value": "Add example tests for core ModelAdmin\n" }, { "from": "gpt", "value": "from django.contrib.admin.sites import AdminSite\nfrom django.test import TestCase\n\nfrom .. import admin\nfrom .. import factories\nfrom .. import models\n\n\nclass UUIDModelAdminMixinTestCase(T...
python
chosen
[ { "from": "human", "value": "Add a files total size scriptwq\n" }, { "from": "gpt", "value": "fp=open(\"qdisksync.cache\")\nfsize_all=0\nfor line in fp:\n\titems=line.split(\"\\t\")\n\tfsize_all+=int(items[1])\nfp.close()\nprint(\"Size:\"+str(fsize_all/1024.0/1024.0)+\"MB\")\n" } ]
python
chosen
[ { "from": "human", "value": "Add functional test for OSUtils\n\nTest involved detecting special UNIX files\n" }, { "from": "gpt", "value": "# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may...
python
chosen
[ { "from": "human", "value": "Add unit test for the ssh password regex matching\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n'''\n :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)`\n :copyright: © 2013 by the SaltStack Team, see AUTHORS for more details.\n :license: A...
python
chosen
[ { "from": "human", "value": "Add a simple script for plotting iteration behaviors\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport numpy as np\nimport matplotlib.pyplot as plt\n\n\ndef update_accu_one(U, X):\n U = 1*U + l*(u - 1*X)\n X = (1*U)\n return (U, X)\n\n\ndef upda...
python
chosen
[ { "from": "human", "value": "Add exercise 6 checking code\n" }, { "from": "gpt", "value": "from learntools.core import *\nimport tensorflow as tf\n\n\n# Free\nclass Q1(CodingProblem):\n _solution = \"\"\n _hint = \"\"\n def check(self):\n pass\n\n\nclass Q2A(ThoughtExperiment):\n...
python
chosen
[ { "from": "human", "value": "Add a default configuration with instructions\n" }, { "from": "gpt", "value": "# Copy this file to config.py and fill in your own values\nSECRET_KEY = 'Genjric Noguchen'\nDEBUG = True\nFACEBOOK_APP_ID = '1234567890'\nFACEBOOK_APP_SECRET = '10abef0bc0'" } ]
python
chosen
[ { "from": "human", "value": "Test script to create an xml restart file\n\ngit-svn-id: 5cda8128732f5b679951344c24659131be7d2dfc@2733 fa922fa7-2fde-0310-acd8-f43f465a7996\n" }, { "from": "gpt", "value": "from hoomd_script import *\n\ninit.read_xml('cubes.xml')\n\nlj = pair.lj(r_cut=2**(1.0/6.0));\...
python
chosen
[ { "from": "human", "value": "Add spider for Merrill Lynch offices\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nimport scrapy\nfrom locations.items import GeojsonPointItem\nimport json\n\n\nclass MerrillLynchSpider(scrapy.Spider):\n name = 'merrilllynch'\n allowed_domains = ['m...
python
chosen
[ { "from": "human", "value": "Add back facility code sequence migrations\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom django.db import models, migrations\nfrom facilities.models import Facility\n\ndef set_min_code_value(apps, schema_editor):\n from django.db import connection...
python
chosen
[ { "from": "human", "value": "Add integration tests for signals and connection loss.\n" }, { "from": "gpt", "value": "from .. import monkey; monkey.patch_all()\n\nfrom nose.tools import eq_ as eq\n\nimport os\nimport nose\n\nfrom .. import connection, run\n\nfrom .util import assert_raises\n\ndef...
python
chosen
[ { "from": "human", "value": "Add a very simple performance testing tool.\n" }, { "from": "gpt", "value": "\"\"\"\nSimple peformance tests.\n\"\"\"\n\nimport sys\nimport time\n\nimport couchdb\n\n\ndef main():\n\n print 'sys.version : %r' % (sys.version,)\n print 'sys.platform : %r' % (sys....
python
chosen
[ { "from": "human", "value": "Add test for Docdata gateway\n" }, { "from": "gpt", "value": "from bluebottle.payments_docdata.gateway import DocdataClient, Amount, Shopper, Name, Destination, Address, Merchant\n\nfrom bunch import bunchify\nfrom mock import patch, Mock\n\nfrom bluebottle.test.util...
python
chosen
[ { "from": "human", "value": "Add file for tests of rule invalid add\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\"\"\"\n:Author Patrik Valkovic\n:Created 23.06.2017 16:39\n:Licence GNUv3\nPart of grammpy\n\n\"\"\"\n\nfrom unittest import TestCase, main\nfrom grammpy import Rule as _R...
python
chosen
[ { "from": "human", "value": "Fix on ggm user import script\n" }, { "from": "gpt", "value": "import MySQLdb\n\nfrom django.core.management.base import NoArgsCommand, BaseCommand \nfrom django.db import transaction\nfrom django.contrib.auth.models import User\nfrom django.contrib.auth import authe...
python
chosen
[ { "from": "system", "value": "Change code to use vim_get_func('fnameescape')\n\nPrevious version had problems with paths containing backslashes and/or\ndouble quotes.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n\ndef source_plugin():\n\timport os\n\timport vim\n\n\tvim.command(...
python
chosen
[ { "from": "human", "value": "Add unit test for Splitter.\n" }, { "from": "gpt", "value": "import os\nimport os.path\n\nimport pytest\n\nfrom psyrun.core import load_infile, load_results, save_outfile\nfrom psyrun.pspace import Param\nfrom psyrun.split import Splitter\n\n\n@pytest.mark.parametriz...
python
chosen
[ { "from": "human", "value": "Add a little package-em-up script for the Subversion book.\n\ngit-svn-id: f8a4e5e023278da1e04e203c7fe051e3c4285d88@849264 13f79535-47bb-0310-9956-ffa450edef68\n" }, { "from": "gpt", "value": "#!/usr/bin/env python2\n\nimport sys\nimport os\nimport shutil\n\ndef die(m...
python
chosen
[ { "from": "human", "value": "TEST\nNew test/example for the new feature supporting custom getter/setter for\nproperties\n[RC]\n\n" }, { "from": "gpt", "value": "# Author: Roberto Cavada <cavada@fbk.eu>\n#\n# Copyright (c) 2006 by Roberto Cavada\n#\n# pygtkmvc is free software; you can redistr...
python
chosen
[ { "from": "human", "value": "Add python implementation for merge sort method\n" }, { "from": "gpt", "value": "# python implementation of merge sort\n\ndef merge_sort(arr):\n\tif len(arr) > 1:\n\t\tmiddle = len(arr)/2\n\t\tleft = arr[:middle]\n\t\tright = arr[middle:]\n\n\t\tmerge_sort(left)\n\t\...
python
chosen
[ { "from": "human", "value": "Add test script using Carrizo data\n" }, { "from": "gpt", "value": "import dem\nimport tasks\nfrom celery import *\n\ncarrizo = dem.DEMGrid('tests/data/carrizo.tif')\n\nd = 100\nmax_age = 10**3.5\nage_step = 1\nnum_ages = max_age/age_step\nnum_angles = 180\nages = np...
python
chosen
[ { "from": "human", "value": "Add tests for utility methods\n" }, { "from": "gpt", "value": "from utils import reverse_complement, gc_content, distance\n\n\ndef test_reverse_complement():\n assert reverse_complement('ATCG') == 'CGAT'\n assert reverse_complement('AAAA') == 'TTTT'\n assert...
python
chosen
[ { "from": "human", "value": "Add Processor interface for post processing of schemas.\n" }, { "from": "gpt", "value": "# :coding: utf-8\n# :copyright: Copyright (c) 2013 Martin Pengelly-Phillips\n# :license: See LICENSE.txt.\n\nfrom abc import ABCMeta, abstractmethod\n\n\nclass Processor(object):...
python
chosen
[ { "from": "human", "value": "Test for use of BASE <..>\n" }, { "from": "gpt", "value": "from rdflib import ConjunctiveGraph, Literal\nfrom StringIO import StringIO\nimport unittest\n\n\ntest_data = \"\"\"\n@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n@prefix rdf: <http://www.w3.org...
python
chosen
[ { "from": "human", "value": "Add a basic presubmit script." }, { "from": "gpt", "value": "# Copyright (c) 2012 The Chromium Authors. All rights reserved.\n# Use of this source code is governed by a BSD-style license that can be\n# found in the LICENSE file.\n_EXCLUDED_PATHS = (\n)\n\ndef _Common...
python
chosen
[ { "from": "human", "value": "Add a test case for colormap behavior change.\n" }, { "from": "gpt", "value": "from awscfncli2.cli.utils.colormaps import STACK_STATUS_TO_COLOR\n\n\ndef test_stack_status_to_color():\n assert STACK_STATUS_TO_COLOR['UPDATE_COMPLETE'] == {'fg': 'green'}\n assert ...
python
chosen
[ { "from": "human", "value": "Add a python script to filter out all DICOM constants.\n" }, { "from": "gpt", "value": "# DICOM_constant_filter.py\r\n# Strip out a list of all constant names from the list of source files in the location provided\r\n# and output C source of an array of {char*,int}\r...
python
chosen
[ { "from": "human", "value": "Add a solution for problem 35.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n\"\"\"\n A solution for problem 35 from Project Euler.\n https://projecteuler.net/problem=35\n\n The number, 197, is called a circular prime because all rotations of the...
python
chosen
[ { "from": "system", "value": "Add a few naming guidelines for the converter library.\n\nPiperOrigin-RevId: 204199604\n" }, { "from": "human", "value": "# Copyright 2016 The TensorFlow Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may...
python
chosen
[ { "from": "human", "value": "Add tests for the handshake functions.\n" }, { "from": "gpt", "value": "import unittest\n\nfrom .handshake import *\nfrom .handshake import accept # private API\n\n\nclass HandshakeTests(unittest.TestCase):\n\n def test_accept(self):\n # Test vector f...
python
chosen
[ { "from": "human", "value": "Add FindMinn.py file, which contains O(n) and O(n**2) methods in finding the minimum number in a random list.\n\nAdd author and email.\n" }, { "from": "gpt", "value": "__author__ = \"Claytonbat\"\nfrom random import randrange\nimport time\ndef findMin(alist):\n ov...
python
chosen
[ { "from": "human", "value": "Add sample for set chlauth\n" }, { "from": "gpt", "value": "'''\n This sample will create a new local queue.\n MQWeb runs on localhost and is listening on port 8081.\n'''\nimport sys\nimport json\nimport httplib\nimport socket\nimport argparse\n\nparser = argparse.Ar...
python
chosen
[ { "from": "human", "value": "Add script to process EnergyPlus SQL and create json result files.\n" }, { "from": "gpt", "value": "\nimport os\nimport pandas as pd\nimport sqlite3\nimport json\n\n\ninput_path=''\ninput_filenames = [\"0101000000.sql\", \"1000000000.sql\"]\n\n\n\ndef sql_query(input...
python
chosen
[ { "from": "system", "value": "Add sale_security.xml file entry in update_xml section\n\nbzr revid: mga@tinyerp.com-b44d9932402c4941921f83487b823e7359d324c0" }, { "from": "human", "value": "{\n\t\"name\" : \"Sales Management\",\n\t\"version\" : \"1.0\",\n\t\"author\" : \"Tiny\",\n\t\"website\" : ...
python
chosen
[ { "from": "human", "value": "Add module of IO examples.\n\nGetting this into the manual is the next step.\n" }, { "from": "gpt", "value": "\nimport fiona\n\n# This module contains examples of opening files to get feature collections in\n# different ways.\n#\n# It is meant to be run from the dist...
python
chosen
[ { "from": "human", "value": "Add testing code for tomography module\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\r\n\"\"\"\r\nCreated on Wed Aug 29 18:53:24 2012\r\n\r\n@author: csferrie\r\n\"\"\"\r\n\r\n## FEATURES ####################################################################...
python
chosen
[ { "from": "human", "value": "Solve Code Fights build palindrome problem\n" }, { "from": "gpt", "value": "#!/usr/local/bin/python\n# Code Fights Build Palindrome Problem\n\n\ndef buildPalindrome(st):\n if st == st[::-1]:\n return st\n for i in range(len(st)):\n s = st + st[i::...
python
chosen
[ { "from": "human", "value": "Add BM string search algorithm implementation\n" }, { "from": "gpt", "value": "# -*- coding:utf-8 -*-\n\n\ndef build_bad_char_map(pattern_s, sz=256):\n bcmap = [-1] * sz\n for i,s in enumerate(pattern_s):\n bcmap[ord(s)] = i\n return bcmap\n\ndef buil...
python
chosen
[ { "from": "human", "value": "git: Add hook to prevent student changes to top level files/dirs\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport subprocess\nimport sys\n\nif __name__ == '__main__':\n\n ref_name = sys.argv[1]\n old_commit = sys.argv[2]\n new_commit = sys.a...
python
chosen
[ { "from": "human", "value": "Add tests for Network IP availability API's new policy rules\n\nRelated-blueprint: bp/secure-rbac-roles\nChange-Id: I21a016a6aa58dc78fc67af093933caaf94991fbd\n" }, { "from": "gpt", "value": "# Copyright (c) 2021 Red Hat Inc.\n#\n# Licensed under the Apache License, V...
python
chosen
[ { "from": "human", "value": "Add script to split data into train/validation/test datasets\n" }, { "from": "gpt", "value": "import os\nimport random\nimport shutil\n\ntrain_split_percent, validation_split_percent, test_split_percentage = 70, 20, 10\n\ndataset_dir = '/Users/tom/projects-workspace/...
python
chosen
[ { "from": "human", "value": "Add the start of a test of the RP class.\n" }, { "from": "gpt", "value": "import eos_defns\nimport SR1d\nfrom numpy.testing import assert_allclose\n\ndef test_standard_sod():\n \"\"\"\n Relativistic Sod test.\n \n Numbers are taken from the General Matlab...
python
chosen
[ { "from": "human", "value": "Add small script to get public ip\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n\"\"\"Get your public IP address from a UDP socket connection\n\"\"\"\n\nimport socket as _socket\n\n\ndef get_my_ip(host, port=80):\n s = _socket.socket(_socket.AF_INET, _...
python
chosen
[ { "from": "human", "value": "Add framework for counting command\n" }, { "from": "gpt", "value": "import discord\nfrom stickord.registry import Command\n\n@Command(['tellen', 'tel'])\nasync def counting(cont, mesg, client, *args, **kwargs):\n count, auth, when = (0, discord.User, None)\n if...
python
chosen
[ { "from": "human", "value": "Add script to download slack archives\n" }, { "from": "gpt", "value": "\"\"\"A script to download slack archives.\"\"\"\n\nfrom os.path import abspath, dirname, join\n\nfrom splinter import Browser\nfrom splinter.exceptions import ElementDoesNotExist\nimport yaml\n\n...
python
chosen
[ { "from": "human", "value": "Add plugin for finding bidirecitonal sypanses missing edges.\n" }, { "from": "gpt", "value": "from tulip import *\nimport tulipplugins\nimport tulippaths as tp\nfrom FileOutputPlugin import FileOutputPlugin\n\n\nclass BidirectionalSynapseCleanup(FileOutputPlugin):\n ...
python
chosen
[ { "from": "human", "value": "Add a script to speed test the feedback.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n#import httplib\nimport json\nimport os\nimport sys\nimport time\nimport urllib2\n\nimport ipaddr\n\nnb_ip = 250\n#nb_ip = 20\nnb_test = 500\nserver = \"iconnect2.iro.umo...
python
chosen
[ { "from": "human", "value": "Add Time Laps python file\n\nAdd Time Laps python file, exciting. Reference:\nhttp://www.makeuseof.com/tag/raspberry-pi-camera-module/\n" }, { "from": "gpt", "value": "import time\n\nimport picamera\n\n \n\nVIDEO_DAYS = 1\n\nFRAMES_PER_HOUR = 60\n\nFRAMES = FRAMES_PE...
python
chosen
[ { "from": "human", "value": "Add migration to remove fields from contacts" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('con...
python
chosen
[ { "from": "human", "value": "Create script runing predictions for each rep and each fold\n" }, { "from": "gpt", "value": "import synthetic_data_experiments as sde\n\nimport logging\n\nif __name__ == \"__main__\":\n args = sde.get_integrous_arguments_values()\n \n for repeat_idx in xrang...
python
chosen
[ { "from": "human", "value": "Add small script to print out db stats\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# Dump stats for raw and queue.\n\nimport os\nimport time\nimport pymongo\nimport json\n\nconn = pymongo.Connection()\n\n# db -> collections\ndbs = {\n 'raw' : ['comm...
python
chosen
[ { "from": "human", "value": "Add debugpanel for Muffin Debugtoolbar\n" }, { "from": "gpt", "value": "import logging\nimport jinja2\nimport datetime as dt\n\nfrom muffin_debugtoolbar.panels import DebugPanel\nfrom muffin_debugtoolbar.utils import LoggingTrackingHandler\n\n\nLOGGER = logging.getLo...
python
chosen
[ { "from": "human", "value": "Add stub test file for Distributed Array Protocol." }, { "from": "gpt", "value": "import unittest\nimport distarray as da\nfrom distarray.mpi.mpibase import create_comm_of_size, InvalidCommSizeError\n\n\nclass TestDistributedArrayProtocol(unittest.TestCase):\n\n d...
python
chosen
[ { "from": "system", "value": "Add test for hooks kwarg to PluggableTestProgram\n" }, { "from": "human", "value": "from nose2.tests._common import FunctionalTestCase\n\n\nclass TestPluggableTestProgram(FunctionalTestCase):\n def test_run_in_empty_dir_succeeds(self):\n proc = self.runIn(...
python
chosen
[ { "from": "human", "value": "Implement a model to store references to program's static content.\n" }, { "from": "gpt", "value": "# Copyright 2013 the Melange authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with th...
python
chosen
[ { "from": "human", "value": "Add derived generator Apply which allows to apply a function to a set of input generators\n" }, { "from": "gpt", "value": "from .base import TohuBaseGenerator\n\n\nclass Apply(TohuBaseGenerator):\n\n def __init__(self, func, *arg_gens, **kwarg_gens):\n self...
python
chosen
[ { "from": "human", "value": "Allow came swap between two applications." }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport os\nimport sys\nimport httplib\nimport json\n\nif len(sys.argv) != 3:\n print \"\"\"ERROR: wrong number of arguments.\n\nUsage: tsuru swap-cname app1-name app2-n...
python
chosen
[ { "from": "human", "value": "Add 2d plot example for batch iteration optimizers\n" }, { "from": "gpt", "value": "\"\"\"Visualizes batch ('population') optimizers as 2D plots.\"\"\"\n\nimport numpy as np\nfrom heuristic_optimization.optimizers import ParticleSwarmOptimizer\n\ntry:\n import mat...
python
chosen
[ { "from": "human", "value": "Read from serial, write to CVS\n" }, { "from": "gpt", "value": "__author__ = 'miahi'\n\n## Serial logger for APC Smart UPS\n\nimport serial\nimport csv\nimport time\nimport datetime\n\nPORT = 'COM2'\nBAUDRATE = 2400\nSLEEP_SECONDS = 3\n\n\nclass APCSerial(object):\n ...
python
chosen
[ { "from": "human", "value": "Add module for analyzing stimulus waveforms\n" }, { "from": "gpt", "value": "import numpy as np\n\n\ndef square_pulses(trace, baseline=None):\n \"\"\"Return a list of (start, stop, amp) tuples describing square pulses\n in the stimulus.\n \n A pulse is de...
python
chosen
[ { "from": "system", "value": "Add an additional description for 'token_ttl'\n\nThe unit of 'token_ttl' is not clear\nin the help text in nova/conf/consoleauth.py.\nSo add the unit (in seconds) in the help text.\n\nTrivialFix\nChange-Id: Id6506b7462c303223bac8586e664e187cb52abd6\n" }, { "from": "huma...
python
chosen
[ { "from": "human", "value": "Add openfda1 get drugs practice\n" }, { "from": "gpt", "value": "import http.client\nimport json\n\nheaders = {'User-Agent': 'http-client'}\n\n\nconn = http.client.HTTPSConnection(\"api.fda.gov\")\n\n# Get a https://api.fda.gov/drug/label.json drug label from this U...
python
chosen
[ { "from": "human", "value": "Add text to speech example.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\"\"\"Asks for coffee using different Python modules.\n\nRequires macspeechX module:\n* https://pypi.python.org/pypi/macspeechX/\n* http://old.nabble.com/Re:-...
python
chosen
[ { "from": "human", "value": "Add concurrent.future ti Python prototypes\n" }, { "from": "gpt", "value": "# concurrent.futures - Launch parallel tasks\nimport concurrent.futures as ft\n\ndef main():\n with ft.ThreadPoolExecutor(max_workers=1) as executor:\n future = executor.submit(fnc,...
python
chosen
[ { "from": "human", "value": "Create Json unit test file\n" }, { "from": "gpt", "value": "'''\n\nCreated on: June 5th, 2016\n@author: Numair Mansur (numair.mansur@gmail.com)\n\n'''\n\n\nimport unittest\nclass TestJsonMethods(unittest.TestCase):\n\n def test_json_base_solver(self):\n ass...
python
chosen
[ { "from": "human", "value": "Add automatic SDAddress migration to new version.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.10 on 2018-10-31 23:40\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nfrom config.restype import RESTYPE...
python
chosen
[ { "from": "human", "value": "Add search manager from metronom\n" }, { "from": "gpt", "value": "import re\n\nfrom django.db import models\nfrom django.db.models import Q\n\n\ndef normalize_query(query_string,\n findterms=re.compile(r'\"([^\"]+)\"|(\\S+)').findall,\n ...
python
chosen
[ { "from": "human", "value": "Work on parts of functional API\n" }, { "from": "gpt", "value": "def layerize(begin_update=None, **kwargs):\n '''Wrap a function into a layer'''\n if begin_update is not None:\n return FunctionLayer(begin_update, *args, **kwargs)\n def wrapper(begin_u...
python
chosen
[ { "from": "human", "value": "CVE-2020-14215: Add migration to clear INVITED_AS_REALM_ADMIN.\n\nThis migration fixes any PreregistrationUser objects that might have\nbeen already corrupted to have the administrator role by the buggy\noriginal version of migration 0198_preregistrationuser_invited_as.\n\nSince...
python
chosen
[ { "from": "system", "value": "Add Tags to SNS::Topic per 2019-11-31 changes\n" }, { "from": "human", "value": "# Copyright (c) 2012-2013, Mark Peek <mark@peek.org>\n# All rights reserved.\n#\n# See LICENSE file for full license.\n\nfrom . import AWSObject, AWSProperty\nfrom .compat import policy...
python
chosen
[ { "from": "human", "value": "Add sleep functionality testing code\n" }, { "from": "gpt", "value": "#!/usr/bin/python\n\n\"\"\"Puts sensor to sleep and waits for it to wakeup\"\"\"\n\nimport minimalmodbus\nimport serial\nfrom time import sleep\nfrom sys import exit\n\nADDRESS = 1\nSLEEPTIME = 33\...
python
chosen
[ { "from": "human", "value": "Add tests for load_for_view_safely and parse_safely\n" }, { "from": "gpt", "value": "from crosscompute.exceptions import DataTypeError\nfrom crosscompute.types import DataType\nfrom pytest import raises\n\n\nclass ADataType(DataType):\n\n @classmethod\n def loa...
python
chosen
[ { "from": "human", "value": "Add a helper tool for updating keystone\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport os\nimport sys\n\nfrom optparse import OptionParser\n\npossible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),\n ...
python
chosen
[ { "from": "human", "value": "Add a file to test JIT related issues\n" }, { "from": "gpt", "value": "import afnumpy\nfrom asserts import *\n\ndef test_conditionals():\n a = afnumpy.arange(10, dtype=\"float32\") - 5.\n b = afnumpy.ones((10), dtype=\"float32\")\n afnumpy.arrayfire.backend....
python
chosen
[ { "from": "system", "value": "Add some notes on current state of priority plugin\n" }, { "from": "human", "value": "from __future__ import unicode_literals, division, absolute_import\nimport logging\n\nfrom flexget import plugin\nfrom flexget.event import event\n\nlog = logging.getLogger('priori...
python
chosen
[ { "from": "human", "value": "Add plugin for parse nginx error\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# -*- coding:utf-8 -*-\n\nimport re\nfrom manager import Plugin\n\nclass NginxError(Plugin):\n\n def __init__(self, **kwargs):\n self.keywords = ['nginx', 'error']\n ...
python
chosen
[ { "from": "human", "value": "Add forgotten migration to OSBS app\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 ('osbs', '00...
python
chosen
[ { "from": "human", "value": "Add simple led chaser example.\n\nChange-Id: I18a5dc49d115d9f222ea2445a086fc9994adce06\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\"\"\"Demonstrates on board LED support with correct polarity.\n\nImplements simple LED chaser.\n\"\"\"\n\nfrom time import...
python
chosen
[ { "from": "human", "value": "Add a DB migration to create Templates.hidden column\n\nCreates the column as nullable, sets the value to false for all\nexisting templates and template versions and then applies a\nnot-nullable constraint.\n\nAll future Templates are created with `False` as the default set\nin ...
python
chosen
[ { "from": "human", "value": "Add new letter rates from 1st of October 2018\n" }, { "from": "gpt", "value": "\"\"\"empty message\n\nRevision ID: 0226_new_letter_rates\nRevises: 0225_another_letter_org\n\n\"\"\"\n\nrevision = '0226_new_letter_rates'\ndown_revision = '0225_another_letter_org'\n\nim...
python
chosen
[ { "from": "human", "value": "Add a config class for an opt out helper\n" }, { "from": "gpt", "value": "from vumi.config import Config, ConfigBool, ConfigList\n\n\nclass OptOutHelperConfig(Config):\n case_sensitive = ConfigBool(\n \"Whether case sensitivity should be enforced when check...
python
chosen
[ { "from": "human", "value": "Complete population script and seeding\n" }, { "from": "gpt", "value": "import os\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tango_with_django_project.settings')\n\nimport django\ndjango.setup()\n\nfrom rango.models import Category, Page\n\ndef populate():\n ...
python
chosen
[ { "from": "human", "value": "Add Python script to create .alfredsnippets file from plist.\n" }, { "from": "gpt", "value": "from __future__ import unicode_literals\n\nimport binascii\nimport json\nimport os\nimport plistlib\nimport sys\nimport unicodedata\nimport zipfile\n\n\ndef make_random_uid(...
python
chosen
[ { "from": "human", "value": "TST: Test runs with no descriptors or no events.\n" }, { "from": "gpt", "value": "import event_model\nfrom intake_bluesky.core import documents_to_xarray\n\n\ndef test_no_descriptors():\n run_bundle = event_model.compose_run()\n start_doc = run_bundle.start_doc...
python
chosen
[ { "from": "human", "value": "Add Basic Admin Functionality for Estimators, EvaluationResult and DataSet\n" }, { "from": "gpt", "value": "from django.contrib import admin\n\nfrom estimators.models import DataSet, Estimator, EvaluationResult\n\nadmin.site.register(Estimator)\nadmin.site.register(D...
python
chosen