conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "human", "value": "Put up a structure to extraction library.\n\nDo this so we have a skelton to fill in.\n" }, { "from": "gpt", "value": "\"\"\"\n### CODE OWNERS: Shea Parkes\n\n### OBJECTIVE:\n Extraction methods for relevant items.\n\n### DEVELOPER NOTES:\n <none>\n\"\"\"\n\nimport...
python
chosen
[ { "from": "human", "value": "Add tests for seat map\n" }, { "from": "gpt", "value": "import unittest\nimport datetime\nimport json\nimport sys\n\nsys.path.append('..')\nimport sabre_dev_studio\nimport sabre_dev_studio.sabre_exceptions as sabre_exceptions\n\n'''\nrequires config.json in the same ...
python
chosen
[ { "from": "human", "value": "Add a script to test the Thorlabs polarization rotator.\n" }, { "from": "gpt", "value": "# Import a whole load of stuff\r\nfrom System.IO import *\r\nfrom System.Drawing import *\r\nfrom System.Runtime.Remoting import *\r\nfrom System.Threading import *\r\nfrom Syste...
python
chosen
[ { "from": "human", "value": "Add basic framework for W2V\n" }, { "from": "gpt", "value": "import sys\nfrom os.path import isdir, isfile\nfrom corpus import Corpus\n\n\nclass W2VCorpus(Corpus):\n\n def __init__(self, dict_loc, vec_loc):\n Corpus.__init__(self)\n Corpus.load(self,...
python
chosen
[ { "from": "human", "value": "Tests: Add a set of advection tests for meridional and zonal advection\n" }, { "from": "gpt", "value": "from parcels import Grid, Particle, JITParticle, AdvectionRK4, Geographic, GeographicPolar\nimport numpy as np\nimport pytest\nfrom datetime import timedelta as de...
python
chosen
[ { "from": "human", "value": "Add script to run a mongo shell in the MongoLab environment\n" }, { "from": "gpt", "value": "#! /usr/bin/env python\n\nfrom os import environ\nfrom subprocess import check_call\nfrom urlparse import urlparse\n\nif 'MONGOLAB_URI' in environ:\n print 'Using', enviro...
python
chosen
[ { "from": "human", "value": "Add a command to filter responses for plagiarism\n" }, { "from": "gpt", "value": "import csv\n\nfrom django.core.management.base import BaseCommand\n\nfrom ...views.plagiarism import PlagiarismFeedbackView\n\n\nclass Command(BaseCommand):\n help = 'Parses a CSV fo...
python
chosen
[ { "from": "human", "value": "Add epub to file preset and localfile extension\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n# Generated by Django 1.11.11 on 2018-04-10 18:39\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations\nfrom django.db import models\n\n\...
python
chosen
[ { "from": "human", "value": "Add a script to generate a universe resource\n\nThe generate_universe_resource.py script can be used to generate\nresource files for universe. It takes as argument a plugin name and a\nversion and uses them to download the plugins from their canonical URLs\nand generate sha256 c...
python
chosen
[ { "from": "human", "value": "ENH: Add initial Python package configuration\n" }, { "from": "gpt", "value": "from __future__ import print_function\nfrom os import sys, path\n\ntry:\n from skbuild import setup\nexcept ImportError:\n print('scikit-build is required to build from source.', fil...
python
chosen
[ { "from": "human", "value": "Add new tests for sqlcache.py\n" }, { "from": "gpt", "value": "from botbot import sqlcache\n\nimport os\nfrom itertools import combinations\nfrom string import ascii_letters\n\ndef get_dbpath():\n return os.path.join('.', 'test.db')\n\ndef test_FileDatabase_constr...
python
chosen
[ { "from": "human", "value": "Add URLs for demo project\n" }, { "from": "gpt", "value": "\"\"\"Urls for the zinnia-ckeditor demo\"\"\"\nfrom django.conf import settings\nfrom django.contrib import admin\nfrom django.conf.urls import url\nfrom django.conf.urls import include\nfrom django.conf.urls...
python
chosen
[ { "from": "human", "value": "Add script to add an arbitrary service instance to the deploy_queue\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# Copyright 2015-2020 Yelp Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in ...
python
chosen
[ { "from": "human", "value": "Add py solution for 454. 4Sum II\n\n454. 4Sum II: https://leetcode.com/problems/4sum-ii/\n" }, { "from": "gpt", "value": "from collections import Counter\nclass Solution(object):\n def fourSumCount(self, A, B, C, D):\n \"\"\"\n :type A: List[int]\n ...
python
chosen
[ { "from": "human", "value": "Add a script for updating the CSV files\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport requests\n\n\nURLS = (\n ('2017_candidates_presidency.csv',\n 'https://docs.google.com/a/mysociety.org/spreadsheets/d/10RBG4fIluYn2jBgCRBBQ--6yHTtppYrB2ef-...
python
chosen
[ { "from": "human", "value": "Make sure there is no pending migrations\n" }, { "from": "gpt", "value": "# Generated by Django 2.2.19 on 2021-05-03 20:51\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('shuup', '0086_attribu...
python
chosen
[ { "from": "human", "value": "Test the repr() of object\n" }, { "from": "gpt", "value": "from butter.eventfd import Eventfd\nfrom butter.fanotify import Fanotify\nfrom butter.inotify import Inotify\nfrom butter.signalfd import Signalfd\nfrom butter.timerfd import Timerfd\nimport pytest\n\n\n@pyte...
python
chosen
[ { "from": "human", "value": "Add recipe & source base classes and fake recipe generator\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\nimport random\n\nclass Recipe:\n '''\n Represents an individual recipe, made up of the following attributes:\n\n * title\n A string c...
python
chosen
[ { "from": "human", "value": "Add helper for Python 2/3 compatibility.\n" }, { "from": "gpt", "value": "# Copyright Least Authority Enterprises.\n# See LICENSE for details.\n\n\"\"\"\nHelpers for Python 2/3 compatibility.\n\"\"\"\n\nfrom twisted.python.compat import _PY3\n\ndef encode_environ(env...
python
chosen
[ { "from": "human", "value": "Add python utility to adjust timelines\n\nIt's kind of a pain to adjust all the times in a file or a section by a\nparticular amount, so this python file will do it for you.\n" }, { "from": "gpt", "value": "#!/usr/bin/python\nfrom __future__ import print_function\nim...
python
chosen
[ { "from": "human", "value": "Add valid and invalid xml\nInvalid XML is currently only invalid due to an incorrect version\nnumber.\n" }, { "from": "gpt", "value": "\"\"\"A module containing tests for the library representation of validation.\"\"\"\n\n\nvalid_xml = \"\"\"\n<?xml version=\"1.0\"?>...
python
chosen
[ { "from": "human", "value": "Create migration for the models.\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 ]\n\n operations...
python
chosen
[ { "from": "human", "value": "Add Segmenter. Not working yet\n" }, { "from": "gpt", "value": "import copy\nimport package.app as app\nimport cv2\nimport numpy as np\nfrom package.image import Image, CS_BGR\n\n__author__ = 'luigolas'\n\n\nclass Segmenter():\n compatible_color_spaces = []\n\n ...
python
chosen
[ { "from": "human", "value": "Add solution to lintcode question 120\n" }, { "from": "gpt", "value": "class Solution:\n # @param start, a string\n # @param end, a string\n # @param dict, a set of string\n # @return an integer\n def ladderLength(self, start, end, dict):\n # wr...
python
chosen
[ { "from": "human", "value": "Add new command line tool for injesting from YAML description to NetCDF\n" }, { "from": "gpt", "value": "\nimport click\nimport os\nimport os.path\nimport yaml\nfrom create_tiles import calc_target_names, create_tiles\nfrom geotiff_to_netcdf import create_or_replace\...
python
chosen
[ { "from": "human", "value": "Add time-sensitive test for compound generator for a large scan.\n\nTests that point preparation for ~100 million points (before region\nfiltering) happens within a few seconds.\n" }, { "from": "gpt", "value": "import os\nimport sys\nsys.path.append(os.path.join(os.p...
python
chosen
[ { "from": "human", "value": "Add py solution for 650. 2 Keys Keyboard\n\n650. 2 Keys Keyboard: https://leetcode.com/problems/2-keys-keyboard/\n" }, { "from": "gpt", "value": "class Solution(object):\n def minSteps(self, n):\n \"\"\"\n :type n: int\n :rtype: int\n \...
python
chosen
[ { "from": "human", "value": "Add script to aggregate metrics\n" }, { "from": "gpt", "value": "import sys\nimport csv\nimport os\nSRC_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + '/src'\nsys.path.append(SRC_DIR)\nfrom aggregator import ReportAggregator\n\ndef check_argumen...
python
chosen
[ { "from": "human", "value": "Add script to validate identification section date and filename date\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport glob\nimport sys, os\nsys.path.append(os.path.join(os.path.dirname(__file__), '..', 'pccora'))\nfrom pccora import *\n\ndef dump_val...
python
chosen
[ { "from": "human", "value": "Write models for analytics tables\n" }, { "from": "gpt", "value": "'''Models definition for database tables creation\n'''\n\nfrom ckan.common import config\nfrom sqlalchemy import (Column, Integer, String, ForeignKey, create_engine, types)\nfrom sqlalchemy.orm import...
python
chosen
[ { "from": "human", "value": "Add configuration file for Andrew to test changes on\n" }, { "from": "gpt", "value": "from experiment_config_lib import ControllerConfig\nfrom sts.topology import MeshTopology\nfrom sts.control_flow import Fuzzer\nfrom sts.input_traces.input_logger import InputLogger...
python
chosen
[ { "from": "human", "value": "Add a utility for diffing dicts\n" }, { "from": "gpt", "value": "class DictDiffer(object):\n \"\"\"\n Calculate the difference between two dictionaries as:\n\n (1) items added\n (2) items removed\n (3) keys same in both but changed values\n...
python
chosen
[ { "from": "system", "value": "Remove the only remaining reference to `u'` string prefix\n" }, { "from": "human", "value": "# vim:fileencoding=utf-8:noet\nfrom __future__ import (unicode_literals, division, absolute_import, print_function)\n\nimport os\nimport sys\n\n\nsys.path.insert(0, os.path....
python
chosen
[ { "from": "human", "value": "Test the Request and Response classes\n" }, { "from": "gpt", "value": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n# Copyright © 2016 <>\n#\n# Distributed under terms of the MIT license.\n\n\"\"\"\nTest the Request and Response classes\n\"\...
python
chosen
[ { "from": "human", "value": "Test interface for showing plots\n" }, { "from": "gpt", "value": "from PySide import QtCore, QtGui\nimport os,sys\nfrom bgsub import SpectrumData\nfrom matplotlib import pyplot as plt\n\npath = \"/home/danielle/Documents/LMCE_one\"\n\nfile_list = [f for f in sorted(o...
python
chosen
[ { "from": "system", "value": "Update _get_shell to work with Windows\n\n- _get_shell assumed the parent process would always be the shell process, in Powershell the\n parent process is Python, with the grandparent being the shell\n- Switched to walking the process tree so the same code path can be used in ...
python
chosen
[ { "from": "human", "value": "Change style for each execution of the experiment" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n\nimport subprocess\nimport os\n\nimg_dir = 'samples/'\nout_dir = 'outputs/'\next = '.jpg'\nsem_ext = '.png'\nc_images = ['arthur', 'matheus', 'sergio', 'morgan']...
python
chosen
[ { "from": "human", "value": "Add script to run experiment\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nif __name__ == '__main__':\n import argparse\n from glob import glob\n import os.path\n\n from sklearn.feature_extraction.text import CountVectorizer\n from termcolo...
python
chosen
[ { "from": "human", "value": "Introduce Port resource request extension\n\nThe resources needed by a port are expressed to nova via\nresource_request extending the port.\nIf the port requested by nova boot has resource_request attribute, that\nmeans that placement must enforce the minimum bandwidth requireme...
python
chosen
[ { "from": "human", "value": "Add mgmt cmd to re-save a list of form/case IDs\n\nhttps://manage.dimagi.com/default.asp?263644\n" }, { "from": "gpt", "value": "from __future__ import print_function\nfrom __future__ import absolute_import\nfrom __future__ import unicode_literals\n\nimport csv\nimpo...
python
chosen
[ { "from": "human", "value": "Add example post body processer\n" }, { "from": "gpt", "value": "'''A simple post reading server example.\n\nTo test run this server with `hug -f post_body_example`\nthen run the following from ipython:\n import requests\n\n requests.post('http://localhost:8000...
python
chosen
[ { "from": "human", "value": "Save daily vertically integrated moisture transport for HOWI index\n" }, { "from": "gpt", "value": "import sys\nsys.path.append('/home/jwalker/dynamics/python/atmos-tools')\nsys.path.append('/home/jwalker/dynamics/python/atmos-read')\n\nimport numpy as np\nimport xra...
python
chosen
[ { "from": "human", "value": "Remove original permissions from broadcast users\n\nThe broadcast user permissions are changing, so to avoid confusion and\npermissions which exist in the database but don't display on the\nfrontend we are going to remove all existing permissions for users of\nbroadcast services...
python
chosen
[ { "from": "system", "value": "Fix JSON decode error message\n" }, { "from": "human", "value": "from __future__ import print_function\n\nimport argparse\nimport sys\n\nimport simplejson\n\n\ndef check_json(argv=None):\n parser = argparse.ArgumentParser()\n parser.add_argument('filenames', n...
python
chosen
[ { "from": "human", "value": "Add script for updating previously imported artists with the streamable property (so we don't have to query tracks to find out who's streamable)\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport psycopg2 as ordbms\nimport urllib, urllib2\nimport xml.etre...
python
chosen
[ { "from": "human", "value": "Add 'senedd' to choices for organisation_type\n" }, { "from": "gpt", "value": "# Generated by Django 2.2.16 on 2020-12-18 09:12\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n (\"organisations\"...
python
chosen
[ { "from": "human", "value": "Allow running with \"python -m html_sanitizer\"\n" }, { "from": "gpt", "value": "from __future__ import unicode_literals\n\nimport io\nimport sys\n\nfrom .sanitizer import Sanitizer\n\n\nsanitizer = Sanitizer()\n\nif len(sys.argv) > 1:\n for filename in sys.argv[1...
python
chosen
[ { "from": "human", "value": "Add tests for RESTful server\n" }, { "from": "gpt", "value": "import datetime\n\nfrom flask.ext.testing import TestCase\nimport mongomock\nimport mock\n\nfrom server import app, get_db\n\nclass BaseTest(TestCase):\n def create_app(self):\n app.config['TESTI...
python
chosen
[ { "from": "human", "value": "Add unit tests for the new ActionResourceManager methods\n" }, { "from": "gpt", "value": "# Copyright 2019 Extreme Networks, 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 Licens...
python
chosen
[ { "from": "human", "value": "Add functional test to ensure response keys are not shadowed\n" }, { "from": "gpt", "value": "# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this fil...
python
chosen
[ { "from": "human", "value": "Add a simple test for setuptools.command.build\n" }, { "from": "gpt", "value": "from setuptools.dist import Distribution\nfrom setuptools.command.build import build\n\n\ndef test_distribution_gives_setuptools_build_obj(tmpdir_cwd):\n \"\"\"\n Check that the set...
python
chosen
[ { "from": "human", "value": "Add preliminary test suite for core.py\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"Testing CLI module\n\nOnly supports Python 3.x now\"\"\"\n\nimport unittest\n\n# Resolve import problem\nimport os\nos.chdir(\"../\")\n\nfrom vocabtool import core\...
python
chosen
[ { "from": "human", "value": "Add aws s3 into tests\n" }, { "from": "gpt", "value": "import pytest\nfrom into import into, resource, S3, discover, CSV, s3\nimport pandas as pd\nimport pandas.util.testing as tm\nimport datashape\n\nsa = pytest.importorskip('sqlalchemy')\npytest.importorskip('psyco...
python
chosen
[ { "from": "human", "value": "Add name space replacement utility.\n" }, { "from": "gpt", "value": "import os, subprocess\nimport re\n\ndef fix_input_file_spaces():\n path = '../../fludata/VIDRL-Melbourne-WHO-CC/raw-data/'\n for ab in os.listdir(path):\n ab_path = '{}{}/'.format(path,...
python
chosen
[ { "from": "human", "value": "Add an early gpio testing script\n" }, { "from": "gpt", "value": "# from www.thirdeyevis.com/pi-page-2.php\n\nimport RPi.GPIO as GPIO\nimport time\n\nGPIO.setmode(GPIO.BOARD)\nGPIO.setup(7, GPIO.OUT)\nGPIO.setup(11, GPIO.OUT)\nGPIO.setup(12, GPIO.IN, pull_up_down=GPI...
python
chosen
[ { "from": "human", "value": "Add 'smoke test' for single blog post page\n" }, { "from": "gpt", "value": "from tests import PMGLiveServerTestCase\nfrom tests.fixtures import dbfixture, PostData\nimport urllib2\n\n\nclass TestBlogPages(PMGLiveServerTestCase):\n def setUp(self):\n super(T...
python
chosen
[ { "from": "human", "value": "Add a few basic tests for Experiment code.\n" }, { "from": "gpt", "value": "import theanets\nimport numpy as np\n\nimport util\n\n\nclass TestExperiment(util.MNIST):\n def test_create_autoencoder(self):\n exp = theanets.Experiment(\n theanets.Aut...
python
chosen
[ { "from": "human", "value": "Add rudimentary unit test for SoftU2FDevice\n" }, { "from": "gpt", "value": "\nimport os\nimport base64\nimport struct\nimport tempfile\nimport unittest\n\nfrom u2flib_host.soft import SoftU2FDevice\nfrom u2flib_host.constants import INS_ENROLL, INS_SIGN\n\nCLIENT_PA...
python
chosen
[ { "from": "human", "value": "Add basic working prototype of SMACH/Jinja2 template-based code generation.\n" }, { "from": "gpt", "value": "#----------------------------------------------------------------------------------------\n# BEGIN: READ_HEXAPOD_CURRENT_POSE\n# TEMPLATE: ReadTransformState\...
python
chosen
[ { "from": "human", "value": "Add example for hv grid\n" }, { "from": "gpt", "value": "from tools.pypsa_io import oedb_session, get_pq_sets,\\\n get_timerange, import_components, import_pq_sets, create_powerflow_problem,\\\n add_coordinates, plot_line_loading\n\nfrom egoio.db_tables.calc_eg...
python
chosen
[ { "from": "human", "value": "Add management command for granting superuser access\n" }, { "from": "gpt", "value": "\"\"\"Management command to grant or revoke superuser access for one or more users\"\"\"\n\nfrom optparse import make_option\nfrom django.contrib.auth.models import User\nfrom djang...
python
chosen
[ { "from": "human", "value": "Add module for parsing IRC messages\n" }, { "from": "gpt", "value": "from collections import namedtuple\n\nIRCMsg = namedtuple('IRCMsg', 'prefix cmd params postfix')\n\ndef parse(line):\n \"\"\" Parses line and returns a named tuple IRCMsg\n with fields (pr...
python
chosen
[ { "from": "human", "value": "Add tests for software model crud routes\n" }, { "from": "gpt", "value": "from test.base import ApiDBTestCase\n\nfrom zou.app.models.software import Software\n\nfrom zou.app.utils import fields\n\n\nclass SoftwareTestCase(ApiDBTestCase):\n\n def setUp(self):\n ...
python
chosen
[ { "from": "human", "value": "Move python test script to tests (part 2)" }, { "from": "gpt", "value": "#!/usr/bin/env python\nimport sys, dbus, dbus.glib\n\n#import pdb\n\n# Get the D-Bus Session Bus\nbus = dbus.SessionBus()\n\n#Access the ICEcore Daemon Object\nobj = bus.get_object(\"org.gnome.T...
python
chosen
[ { "from": "human", "value": "Implement two methods in the USResident class\n" }, { "from": "gpt", "value": "## DO NOT MODIFY THE IMPLEMENTATION OF THE Person CLASS ##\r\nclass Person(object):\r\n def __init__(self, name):\r\n #create a person with name name\r\n self.name = name\...
python
chosen
[ { "from": "human", "value": "Implement unit tests for logger class\n" }, { "from": "gpt", "value": "import pytest\nfrom mugloar import dragon, logger\n\n@pytest.fixture\ndef log_instance():\n \"\"\"Returns a Logger instance\"\"\"\n return logger.Logger()\n\n@pytest.fixture\ndef knight():\n...
python
chosen
[ { "from": "human", "value": "Add test for random number generators.\n" }, { "from": "gpt", "value": "\"\"\"\nRandom and quasi-random generator tests.\n\"\"\"\n\nfrom __future__ import division\nfrom __future__ import absolute_import\nfrom __future__ import print_function\n\nimport numpy.testing ...
python
chosen
[ { "from": "human", "value": "Add some initial tests. These require the server to be running.\n" }, { "from": "gpt", "value": "import os\nimport time\n\nimport pytest\nimport requests\nimport json\nimport yaml\n\n\nHERE = os.path.dirname(os.path.abspath(__file__))\n\n\n@pytest.fixture()\ndef sess...
python
chosen
[ { "from": "human", "value": "Add tests for init function.\n" }, { "from": "gpt", "value": "from flexmock import flexmock\nimport flask_uploads\nfrom flask_uploads import Upload\nfrom . import TestCase\n\n\nclass TestWithoutResizer(TestCase):\n def test_upload_class_has_correct_attributes(self...
python
chosen
[ { "from": "human", "value": "Add alt implementation to try and see if it works better\n" }, { "from": "gpt", "value": "import requests\nfrom datetime import date\nfrom urlparse import urljoin\nfrom bs4 import BeautifulSoup\n\n\ndef find_csrf_token(text):\n soup = BeautifulSoup(text, \"lxml\")...
python
chosen
[ { "from": "human", "value": "[svn] Add a reminder to write a HTML formatter test.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\n\"\"\"\n Pygments HTML formatter tests\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n :copyright: 2006 by Georg Brandl.\n :license: BSD, see LICENSE for mo...
python
chosen
[ { "from": "human", "value": "Add string to callable util functions\n" }, { "from": "gpt", "value": "def get_class(class_string, exception=Exception):\n \"\"\"\n Convert a string version of a function name to the callable object.\n \"\"\"\n if not hasattr(class_string, '__bases__'):\n...
python
chosen
[ { "from": "human", "value": "Add custom text2svm preprocessor with a blvd-minded tokenizer.\n" }, { "from": "gpt", "value": "import os\nimport re\nimport unicodedata\n\nfrom libshorttext.converter import *\n\n\ndef tokenizer(text):\n\n def trim_links(input_text):\n input_text = re.sub(...
python
chosen
[ { "from": "human", "value": "Add py solution for 572. Subtree of Another Tree\n\n572. Subtree of Another Tree: https://leetcode.com/problems/subtree-of-another-tree/\n" }, { "from": "gpt", "value": "# Definition for a binary tree node.\n# class TreeNode(object):\n# def __init__(self, x):\n# ...
python
chosen
[ { "from": "human", "value": "NXP-13818: Extend cx_Freeze build class with the exe-command option to allow using a different command from build_exe to build executables from Python scripts\n" }, { "from": "gpt", "value": "\"\"\"cx_Freeze extension\n\nExtends the 'build' command with the 'exe-comm...
python
chosen
[ { "from": "human", "value": "api: Add test cases for X-TBA-App-Id\n" }, { "from": "gpt", "value": "import unittest2\nimport webtest\nimport json\nimport webapp2\n\nfrom google.appengine.ext import testbed\n\nfrom controllers.api.api_event_controller import ApiEventController\n\nclass TestApiCont...
python
chosen
[ { "from": "system", "value": "Correct test criteria for time format for scheduled skill.\n\nNow matches current behaviour, previous behaviour is not a good idea since it depended on Locale.\n" }, { "from": "human", "value": "from datetime import datetime, timedelta\nimport unittest\n\nfrom mycro...
python
chosen
[ { "from": "human", "value": "Add script for capturing meeting report nids from dump.\n" }, { "from": "gpt", "value": "import os\nimport json\nimport time, datetime\nimport parsers\nimport logging\nimport csv\nimport re\nimport requests\nfrom sqlalchemy import types\nfrom backend.app import app, ...
python
chosen
[ { "from": "human", "value": "Add forgotten migration for Organization.admin_users field's blank=True.\n" }, { "from": "gpt", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\nfrom django.conf import settings\n\n\nclass Migrati...
python
chosen
[ { "from": "human", "value": "Create scripts making downstream aggragation and stats easier.\n" }, { "from": "gpt", "value": "import camoco as co\nimport glob\nimport pandas as pd\nimport os\n\ndef read_FDR(glob_path):\n dfs = []\n for x in glob.glob(glob_path):\n df = pd.read_table(...
python
chosen
[ { "from": "human", "value": "Add admin task to reindex all marks\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nimport convenience as c\nimport jobs\n\ndef main():\n c.load_settings()\n logger = c.logger(\"reindex_all_bookmarks\")\n db = c.db()\n records = db.marks.find({\...
python
chosen
[ { "from": "human", "value": "Add python answer to q3\n" }, { "from": "gpt", "value": "import sys\n\ndef prependAbbrev(front, abbr):\n if type(front) is type(abbr[0]):\n return [front + abbr[0]] + abbr[1:]\n else:\n return [front] + abbr\n\ndef prefixAll(p, lst):\n return [...
python
chosen
[ { "from": "human", "value": "Add a helper script which will transform a file full of SQL commands into a\nheader file suitable for inclusion in a standard C file and use with the\nSubversion SQLite APIs. The goal here is that we can maintain our SQL schema\ndirectly as such, and let this script do the appr...
python
chosen
[ { "from": "human", "value": "Add simple tests for __import__ for future optimizations to importlib.\n" }, { "from": "gpt", "value": "from . import util\nfrom .source import util as source_util\nimport gc\nimport decimal\nimport imp\nimport importlib\nimport sys\nimport timeit\n\n\ndef bench_cach...
python
chosen
[ { "from": "human", "value": "完成了第83题: Remove Duplicates from Sorted List\n" }, { "from": "gpt", "value": "# Definition for singly-linked list.\n# class ListNode(object):\n# def __init__(self, x):\n# self.val = x\n# self.next = None\n\n\nclass Solution(object):\n def delete...
python
chosen
[ { "from": "human", "value": "Add view for bct analysis\n" }, { "from": "gpt", "value": "from flask import session, render_template, Blueprint\nfrom lexos.helpers import constants\nfrom lexos.views.base_view import detect_active_docs\nfrom lexos.models.filemanager_model import FileManagerModel\n\...
python
chosen
[ { "from": "human", "value": "Add script to shutdown Raspberry Pi on button press\n\nSigned-off-by: Greg Meiste <8a8f45e57c045ec63dc7e56e5eda862ea8c7cd4f@gmail.com>\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\n# Copyright (C) 2014 Gregory S. Meiste <http://gregmeiste.com>\n#\n# Lice...
python
chosen
[ { "from": "human", "value": "T1424: Rewrite the config load script\n\nRewrite of the load functionality of vyatta-load-config.pl, removing the\ndependency on Vyatta::Config.\n" }, { "from": "gpt", "value": "#!/usr/bin/env python3\n#\n# Copyright (C) 2019 VyOS maintainers and contributors\n#\n# T...
python
chosen
[ { "from": "human", "value": "Add functional tests for telemetry alarm crud\n\nChange-Id: I77399eb47761c8de04095c06cd67d5d09e644df4\n" }, { "from": "gpt", "value": "# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compliance with the Licen...
python
chosen
[ { "from": "human", "value": "Add an helper to render device conf templates\n\nChange-Id: Ida10d2963969b12aeb04ef034fa7814ffaf2c8ed\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom jinja2 import Environment, FileSystemLoader\nimport yaml\n\nimport os\nimport sys\n\n\ndef main():\n ...
python
chosen
[ { "from": "human", "value": "Add alexa skill basic functionality\n" }, { "from": "gpt", "value": "import json\r\nimport time\r\n\r\nimport requests\r\nimport unidecode\r\nfrom flask import Flask\r\nfrom flask_ask import Ask, question, session, statement\r\n\r\nAPP = Flask(__name__)\r\nASK = Ask(...
python
chosen
[ { "from": "human", "value": "Add new ordered set class\n" }, { "from": "gpt", "value": "\"\"\"\nCode from http://code.activestate.com/recipes/576694/\n\"\"\"\n\nimport collections\n\nclass OrderedSet(collections.MutableSet):\n\n def __init__(self, iterable=None):\n self.end = end = [] ...
python
chosen
[ { "from": "human", "value": "Add multiline echo server example script\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n\nfrom gaidaros import *\nserver = Gaidaros(end_request = lambda x: '\\n\\n' in x, split_request = lambda x: return(x[:x.find('\\n\\n') + 1], x[x.find('\\n\\n') + 1:]))\n...
python
chosen
[ { "from": "human", "value": "Add a few fizz buzz attempts\n" }, { "from": "gpt", "value": "#!/usr/bin/env python\n# pylint: disable=C0111\n# pylint: disable=C0103\n# pylint: disable=C0330\n\nMAX = 31\n\ndef simple():\n print ('--- SIMPLE -----')\n for i in range(1, MAX):\n output = ...
python
chosen
[ { "from": "human", "value": "Add an example on the library usage\n" }, { "from": "gpt", "value": "# Example on how to use the ofxclient library without the\n# web interface. It's admittedly clunky but doable -- it's\n# free so get over it >=)\nimport ofxclient\nfrom pprint import pprint\n\n# ht...
python
chosen
[ { "from": "human", "value": "Add unfinished scripts that assist in deft disambiguation\n\ngit history was completley farbed through carelessness. the original deft\nbranch was deleted and a new branch was created\n" }, { "from": "gpt", "value": "import logging\nfrom collections import defaultdic...
python
chosen
[ { "from": "human", "value": "Create a jinja2 env for rendering templates\n" }, { "from": "gpt", "value": "from jinja2 import (\n select_autoescape,\n Environment,\n FileSystemLoader,\n)\n\n\ntemplate_env = Environment(\n loader=FileSystemLoader(\"templates\"),\n autoescape=select_...
python
chosen
[ { "from": "human", "value": "Add tests for the IATI Datastore\nThis adds a 200 response and link checks for the IATI Datastore\n" }, { "from": "gpt", "value": "import pytest\nfrom web_test_base import *\n\nclass TestIATIDatastore(WebTestBase):\n urls_to_get = [\n \"http://datastore.iat...
python
chosen
[ { "from": "human", "value": "Add first unit tests for sqlite db\n" }, { "from": "gpt", "value": "'''\nModule for testing the SQLite DB.\nFairly similar to the test_api tests...\n'''\nimport os\nimport sys\nimport json\nimport unittest\n\nCWD = os.path.dirname(os.path.abspath(__file__))\nMS_WD = ...
python
chosen
[ { "from": "human", "value": "Add road sort key tests\n" }, { "from": "gpt", "value": "import unittest\n\n\nclass RoadSortKeyTest(unittest.TestCase):\n\n def _call_fut(self, props, zoom=15, shape=None, fid=None):\n from TileStache.Goodies.VecTiles.transform import road_sort_key\n ...
python
chosen