conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Mark process member variable for internal use\n" }, { "from": "human", "value": "import multiprocessing\nimport unicornhat\nimport importlib\nimport sys\nimport os\n\n\nclass State:\n ''' Handles the Unicorn HAT state'''\n\n def __init__(self):\n self.p...
python
chosen
[ { "from": "system", "value": "Add a missing route leading to the login page.\n" }, { "from": "human", "value": "\"\"\"microauth URL Configuration\n\nThe `urlpatterns` list routes URLs to views. For more information please see:\n https://docs.djangoproject.com/en/1.9/topics/http/urls/\nExample...
python
chosen
[ { "from": "system", "value": "Refactor API to have single pandas load\n" }, { "from": "human", "value": "import pandas\nfrom .processor import CTDChemicalDiseaseProcessor, \\\n CTDGeneDiseaseProcessor, CTDChemicalGeneProcessor\n\nbase_url = 'http://ctdbase.org/reports/'\n\nurls = {\n 'chem...
python
chosen
[ { "from": "system", "value": "Set develop version back to 0.6-dev\n" }, { "from": "human", "value": "default_app_config = 'pucas.apps.PucasConfig'\n\n__version_info__ = (0, 5, 1, None)\n\n# Dot-connect all but the last. Last is dash-connected if not None.\n__version__ = '.'.join([str(i) for i in...
python
chosen
[ { "from": "system", "value": "Revert \"Also include lowercase norm exceptions\"\n\nThis reverts commit 70f4e8adf37cfcfab60be2b97d6deae949b30e9e.\n" }, { "from": "human", "value": "# coding: utf8\nfrom __future__ import unicode_literals\n\n# Here we only want to include the absolute most common w...
python
chosen
[ { "from": "system", "value": "Change test method name to better match\n" }, { "from": "human", "value": "import unittest\nfrom collections import namedtuple\n# TODO: Move this code to a module so we don't depend on PYTHONPATH and that sort\n# of ugliness.\nfrom jarvis import convert_file_to_json...
python
chosen
[ { "from": "system", "value": "Add support to Py3 for datetime\n" }, { "from": "human", "value": "import datetime\n\nfrom lino_extjs6.projects.mysite.settings import *\n\n\nclass Site(Site):\n project_name = 'extjs_demo'\n is_demo_site = True\n # ignore_dates_after = datetime.date(2019, ...
python
chosen
[ { "from": "system", "value": "Add the desktop context to the setup script.\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport sys\n\nimport fedmsg.config\nimport fmn.lib.models\n\nconfig = fedmsg.config.load_config()\nuri = config.get('fmn.sqlalchemy.uri')\nif not uri:\n raise V...
python
chosen
[ { "from": "system", "value": "Change to the root directory before executing (stops Mumble ICE file errors)\n\nThis was causing the SSO job to fail, thanks for psu3d0 for pointing it out.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\"\"\"Executes a Django cronjob\"\"\"\n\nimport os\...
python
chosen
[ { "from": "system", "value": "Update tests to use class-based interface\n" }, { "from": "human", "value": "import unittest\nfrom either_or import either_or\n\nclass nxppyTests(unittest.TestCase):\n \"\"\"Basic tests for the NXP Read Library python wrapper.\"\"\"\n\n def test_import(self):\...
python
chosen
[ { "from": "system", "value": "Fix flake8 issues in examples\n" }, { "from": "human", "value": "import random\nimport time\nfrom os import getenv\n\nfrom aiographite.aiographite import connect\nfrom aiographite.protocol import PlaintextProtocol\n\nGRAPHITE_HOST = getenv('GRAPHITE_HOST', 'localhos...
python
chosen
[ { "from": "human", "value": "Convert list, for later reference.\n" }, { "from": "gpt", "value": "def read_file(filename):\n # Open the file\n file_obj = open(filename)\n\n # Iterate over lines in the file\n for line in file_obj:\n\n # Split line by spaces (creates a list)\n ...
python
chosen
[ { "from": "system", "value": "Add inline comment regarding freeing resources\n" }, { "from": "human", "value": "\"\"\"A simple example demonstrating basic usage of pyuv_cffi\n\nThis example creates a timer handle and a signal handle, then starts the loop. The timer callback is\nrun after 1 secon...
python
chosen
[ { "from": "system", "value": "Remove compat shim as it doesn't apply\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport os\nimport sys\n\n\ndef runtests():\n test_dir = os.path.dirname(__file__)\n sys.path.insert(0, test_dir)\n os.environ['DJANGO_SETTINGS_MODULE'] = 'tests...
python
chosen
[ { "from": "system", "value": "Change region list to match config\n" }, { "from": "human", "value": "# -*- encoding: utf-8 -*-\nfrom flask import Blueprint\nfrom flask import render_template\n\nfrom lazyblacksmith.models import Activity\nfrom lazyblacksmith.models import Item\nfrom lazyblacksmith...
python
chosen
[ { "from": "system", "value": "Add assertion for forecast test\n" }, { "from": "human", "value": "import datetime\n\nfrom midas import mix\nfrom midas.midas import estimate, forecast\n\n\ndef test_estimate(gdp_data, farmpay_data):\n\n y, yl, x, yf, ylf, xf = mix.mix_freq(gdp_data.gdp, farmpay_...
python
chosen
[ { "from": "system", "value": "Add test for animation file.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport unittest\n\nfrom arc_test import ArcTest\nfrom incar_test import InCarTest\nfrom oszicar_test import OsziCarTest\nfrom outcar_test import OutCarTes...
python
chosen
[ { "from": "system", "value": "Use config redis database in sentinel connections\n" }, { "from": "human", "value": "from redis import sentinel\n\n\nclass Sentinel(object):\n\n def __init__(self, app=None):\n self.app = app\n if app is not None: # pragma: no cover\n sel...
python
chosen
[ { "from": "system", "value": "Split Protocol class in Protocol and ProtocolElement\n" }, { "from": "human", "value": "'''\nCreated on 11 jan. 2013\n\n@author: sander\n'''\nfrom abc import abstractmethod, ABCMeta\n\n\nclass Protocol(object):\n __metaclass__ = ABCMeta\n\n header_type = None\...
python
chosen
[ { "from": "system", "value": "Add arguments --domain and --region to mass init.\n" }, { "from": "human", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n# vim: set hls is ai et sw=4 sts=4 ts=8 nu ft=python:\n\n# built-in modules\n\n# 3rd-party modules\nimport click\n\n# local modules\...
python
chosen
[ { "from": "system", "value": "Include skyscanner version to be used by doc.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n__author__ = 'Ardy Dedase'\n__email__ = 'ardy.dedase@skyscanner.net'\n__version__ = '1.1.3'\n__copyright__ = \"Copyright (C) 2016 Skyscanner Ltd\"\n__license__ ...
python
chosen
[ { "from": "system", "value": "Use setting validation function in setSettingValue\n" }, { "from": "human", "value": "from . import database\n\ndef getAllSettings():\n\tdatabaseConnection = database.ConnectionManager.getConnection(\"main\")\n\tquery = databaseConnection.session.query(database.tabl...
python
chosen
[ { "from": "system", "value": "Fix documentation of fft sub-package to eliminate references to refft.\n\ngit-svn-id: 77a43f9646713b91fea7788fad5dfbf67e151ece@3226 94b884b6-d6fd-0310-90d3-974f1d3f35e1\n" }, { "from": "human", "value": "\"\"\"\\\nCore FFT routines\n==================\n\n Standard F...
python
chosen
[ { "from": "system", "value": "Stop changing schema_migrations data if the table already exists\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# ###\n# Copyright (c) 2015, Rice University\n# This software is subject to the provisions of the GNU Affero General\n# Public License versio...
python
chosen
[ { "from": "system", "value": "Make the agate table type tester more restrictive on what counts as null/true/false\n" }, { "from": "human", "value": "\nimport agate\n\nDEFAULT_TYPE_TESTER = agate.TypeTester(types=[\n agate.data_types.Number(),\n agate.data_types.Date(),\n agate.data_type...
python
chosen
[ { "from": "system", "value": "Allow for representative view display with sample configuration\n" }, { "from": "human", "value": "DB_USER = ''\nDB_HOST = ''\nDB_PASSWORD = ''\nDB_NAME = ''\n" }, { "from": "gpt", "value": "DB_USER = ''\nDB_HOST = ''\nDB_PASSWORD = ''\nDB_NAME = ''\n\nT...
python
chosen
[ { "from": "system", "value": "Remove bad INFO log \"Starting Octavia API server\"\n\nThis log is also display for health_manager and house_keeping service.\nApi service already display \"Starting API server on...\" in INFO level.\n\nChange-Id: I0a3ff91b556accdfadbad797488d17ae7a95d85b\n" }, { "from"...
python
chosen
[ { "from": "system", "value": "Fix path, use rsa-sha256 algorithm to actually use the rsa-base verification\n" }, { "from": "human", "value": "import os\nfrom email.utils import formatdate\nfrom datetime import datetime\nfrom time import mktime\n\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', '...
python
chosen
[ { "from": "system", "value": "Fix test broken in rename.\n" }, { "from": "human", "value": "import unittest\n\n\nclass ViewTests(unittest.TestCase):\n def setUp(self):\n from pyramid import testing\n self.config = testing.setUp()\n\n def tearDown(self):\n from pyramid ...
python
chosen
[ { "from": "system", "value": "Add proxyfix for X-Forwarded-For header\n" }, { "from": "human", "value": "\"\"\"pluss, a feed proxy for G+\"\"\"\nimport logging\n\nfrom pluss.app import app\n\n@app.before_first_request\ndef setup_logging():\n if not app.debug:\n # In production mode, ad...
python
chosen
[ { "from": "system", "value": "Fix trying to display result in case of not 2D vectors\n" }, { "from": "human", "value": "from sys import argv, stderr\nfrom drawer import *\nfrom kmeans import kmeans\n\n\ndef read_vectors(file_name):\n result = None\n with open(file_name, 'r') as f:\n ...
python
chosen
[ { "from": "system", "value": "Add modification operations to control groups\n" }, { "from": "human", "value": "class ControlGroup(set):\n def __init__(self, units):\n super().__init__({unit.tag for unit in units})\n\n def __hash__(self):\n return hash(tuple(sorted(list(self))...
python
chosen
[ { "from": "system", "value": "Add other planets age function\n" }, { "from": "human", "value": "# File: space_age.py\n# Purpose: Write a program that, given an age in seconds, calculates\n# how old someone is in terms of a given planet's solar years.\n# Programmer: Amal ...
python
chosen
[ { "from": "system", "value": "Fix rename view log patch for mac users\n\nfor mac users direct renaming would not work\nsince mysql for mac saves table name in lower case,\nso while renaming `tabView log` to `tabView Log` we get\n\"Table 'tabView Log' already exists\" error\n\n# more info https://stackoverfl...
python
chosen
[ { "from": "system", "value": "Handle no snr information in snr file. (for fake simualtions mainly)\n" }, { "from": "human", "value": "import os\nimport simulators\nimport numpy as np\nimport json\n\n\"\"\"Calculate Errors on the Spectrum.\n\n For a first go using an fixed SNR of 200 for all ob...
python
chosen
[ { "from": "system", "value": "Bugfix: Select local osmosis depends if user is root, to avoid permission denied on /var/lib/osmosis\n" }, { "from": "human", "value": "import yaml\nimport os\n\nLOCAL_OSMOSIS = 'localhost:1010'\nOFFICIAL_OSMOSIS = None\nOFFICIAL_BUILD = False\nWITH_OFFICIAL_OBJECT_...
python
chosen
[ { "from": "system", "value": "Set SQLALCHEMY_POOL_RECYCLE to be less than `wait_time`\n\n* should fix \"MySQL server has gone away\" errors in development mode\n" }, { "from": "human", "value": "\n# Copyright (C) 2013 Google Inc., authors, and contributors <see AUTHORS file>\n# Licensed under ht...
python
chosen
[ { "from": "system", "value": "Fix python2 django module importerror.\n" }, { "from": "human", "value": "import importlib\nimport sys\n\nfrom django.apps import apps\nfrom django.core.management.base import BaseCommand\n\nfrom webapp_health_monitor.verification_suit import VerificationSuit\n\n\nc...
python
chosen
[ { "from": "system", "value": "Clean up and finish Kiosk class\n\nThere was some redundancy because I merged it poorly\n" }, { "from": "human", "value": "class Kiosk():\n def __init__(self, visit_cost, location):\n self.visit_cost = visit_cost\n self.location = location\n ...
python
chosen
[ { "from": "system", "value": "Set prefetch count to 1000.\n" }, { "from": "human", "value": "class AMQPMixin(object):\n\n amqp_setup = False\n\n def setupAMQP(self, config):\n if not self.amqp_setup:\n # Create AMQP Connection\n # AMQP connection parameters\n ...
python
chosen
[ { "from": "system", "value": "[AC-4835] Rename merge_data_by_id, add doc-string, get rid of id as a local\n" }, { "from": "human", "value": "def merge_data_by_id(data):\n result = {}\n for datum in data:\n id = datum[\"id\"]\n item = result.get(id, {})\n item.update(da...
python
chosen
[ { "from": "system", "value": "Use port from env if available\n" }, { "from": "human", "value": "import os\nimport cherrypy\nfrom flask import Flask\n\napp = Flask(__name__)\n\n@app.route('/')\ndef hello():\n return 'Hello World!'\n\ndef run_server():\n cherrypy.tree.graft(app, '/')\n\n ...
python
chosen
[ { "from": "system", "value": "Remove uneccessary getter and setter\n" }, { "from": "human", "value": "class FacepyError(Exception):\n \"\"\"Base class for exceptions raised by Facepy.\"\"\"\n\n def __init__(self, message):\n self.message = message\n\n def _get_message(self):\n ...
python
chosen
[ { "from": "system", "value": "Create some coreutils bindings. they're not good\n" }, { "from": "human", "value": "#!/usr/bin/env python\nfrom genes.process.commands import run\nfrom genes.posix.traits import only_posix\n\n@only_posix()\ndef chgrp(path, group):\n run(['chgrp', group, path])\n\...
python
chosen
[ { "from": "system", "value": "Remove unnecessary manager declaration from File model\n" }, { "from": "human", "value": "from django.db import models\nfrom django.contrib.sites.models import Site\nfrom django.utils.translation import ugettext_lazy as _\n\n\nclass File(models.Model):\n\n site =...
python
chosen
[ { "from": "system", "value": "lit.py: Fix new test for systems that don't use / as os.path.sep\n\ngit-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@315773 91177308-0d34-0410-b5e6-96231b3b80d8\n" }, { "from": "human", "value": "# RUN: rm -rf %t && mkdir -p %t\n# RUN: echo 'lit_config.load_conf...
python
chosen
[ { "from": "system", "value": "Enable integration credential and integration type admin\n" }, { "from": "human", "value": "# -*- coding:utf-8 -*-\nfrom django.contrib import admin\nfrom .. import models\n\nadmin.site.register(models.IntegrationType, )\nadmin.site.register(models.IntegrationCreden...
python
chosen
[ { "from": "system", "value": "Add URL route for updating provider relationship\n" }, { "from": "human", "value": "from django.conf.urls import url\n\nfrom . import views\n\nurlpatterns = [\n url(r'^$', views.PreprintList.as_view(), name=views.PreprintList.view_name),\n url(r'^(?P<node_id>\...
python
chosen
[ { "from": "system", "value": "Define the port variable for reconnection" }, { "from": "human", "value": "import pymysql\n\nclass MySQL():\n\n def __init__(self, host, user, password, port):\n self._host = host\n self._user = user\n self._password = password\n self....
python
chosen
[ { "from": "system", "value": "Add TestCase for ClientListView and ClientCreateView\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\nfrom django.test import TestCase\n\n\nclass LoginRequiredTest(TestCase):\n def test_login_required(self):\n ...
python
chosen
[ { "from": "system", "value": "Stop leep test being ignored\n" }, { "from": "human", "value": "import unittest\n\nfrom leap import is_leap_year\n\n\n# Tests adapted from `problem-specifications//canonical-data.json` @ v1.5.1\n\nclass LeapTest(unittest.TestCase):\n def test_year_not_divisible_b...
python
chosen
[ { "from": "system", "value": "Add configuration module to package exports\n" }, { "from": "human", "value": "from .environments.makino import MakinoProfile\nfrom .environments.king import KingProfile\nfrom .jet import AstroJet\n\nfrom . import luminosity\nfrom . import plotting\nfrom . import si...
python
chosen
[ { "from": "system", "value": "Add unit support for spacers" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\r\n# See LICENSE.txt for licensing terms\r\n#$HeadURL$\r\n#$LastChangedDate$\r\n#$LastChangedRevision$\r\n\r\nimport shlex\r\n\r\nfrom reportlab.platypus import Spacer\r\n\r\nfrom ...
python
chosen
[ { "from": "system", "value": "Add CopyToQuerySet to available imports\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom django.db import models\nfrom django.db import connection\nfrom .copy_from import CopyMapping\nfrom .copy_to import SQLCopyToCompiler, Cop...
python
chosen
[ { "from": "system", "value": "Add root seed to model\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom downstream_node.startup import db\n\n\nclass Files(db.Model):\n __tablename__ = 'files'\n\n id = db.Column(db.Integer(), primary_key=True, autoincrem...
python
chosen
[ { "from": "system", "value": "scripts: Use the OrderedDict class for JSON objects.\n" }, { "from": "human", "value": "#!/usr/bin/env python3\n\n# Touhou Community Reliant Automatic Patcher\n# Scripts\n#\n# ----\n#\n\"\"\"Utility functions shared among all the scripts.\"\"\"\n\nimport json\nimpor...
python
chosen
[ { "from": "system", "value": "Support for targets in HDF5 datasets\n" }, { "from": "human", "value": "\"\"\"Objects for datasets serialized in HDF5 format (.h5).\"\"\"\nimport h5py\nfrom pylearn2.datasets.dense_design_matrix import DenseDesignMatrix\n\nclass HDF5Dataset(DenseDesignMatrix):\n ...
python
chosen
[ { "from": "system", "value": "Use yaafe for feature extraction\n\nRight now we extract two features (mfcc and perceptual spread)\nbut there is a lot of work to be done on the feature extraction method\nso this is probably going to change\n" }, { "from": "human", "value": "import os,sys\nimport j...
python
chosen
[ { "from": "system", "value": "refactor: Change iteration over a collection based on ags suggestion\n" }, { "from": "human", "value": "def bot_says(channel, text, slack_client):\n return slack_client.api_call(\"chat.postMessage\",\n channel=channel,\n ...
python
chosen
[ { "from": "system", "value": "Add Heroku DNS to allowed hosts\n" }, { "from": "human", "value": "from django.core.exceptions import ImproperlyConfigured\n\nfrom .settings import *\n\n\ndef get_env_variable(var_name):\n \"\"\"\n Get the environment variable or return exception.\n \"\"\"\...
python
chosen
[ { "from": "system", "value": "Fix the geos library location\n" }, { "from": "human", "value": "import os\n\nfrom .base import *\n\n# GEOS_LIBRARY_PATH = '/var/task/libgeos_c.so'\n\nALLOWED_HOSTS = ['*']\n\n# Override the database name and user if needed\nDATABASES = {\n 'default': {\n ...
python
chosen
[ { "from": "system", "value": "Print a warning about the move to '-m pudb.run'.\n" }, { "from": "human", "value": "VERSION = \"0.91.2\"\n\n\n\n\nCURRENT_DEBUGGER = [None]\ndef set_trace():\n if CURRENT_DEBUGGER[0] is None:\n from pudb.debugger import Debugger\n dbg = Debugger()\n...
python
chosen
[ { "from": "system", "value": "Remove facets from main registry project page\n" }, { "from": "human", "value": "from registry.models import *\nfrom operator import attrgetter\n\nfacet_Models = [\n BigAim,\n Category,\n ClinicalArea,\n ClinicalSetting,\n Keyword,\n SafetyTarget,\...
python
chosen
[ { "from": "system", "value": "Use `endswith` instead of string indeces.\n" }, { "from": "human", "value": "import os\nimport re\nimport sys\n\nimport settings\n\ntriggers = set()\ntimers = set()\n\nclass BadApplicationError(Exception): pass\n\ndef trigger(expression):\n def decorator(func):\n...
python
chosen
[ { "from": "system", "value": "Move API key to environment variable\n" }, { "from": "human", "value": "import unittest\nimport googlemaps\nfrom pyrules2.googlemaps import driving_roundtrip\n\nCOP = 'Copenhagen, Denmark'\nMAD = 'Madrid, Spain'\nBER = 'Berlin, Germany'\nLIS = 'Lisbon, Portugal'\n\n...
python
chosen
[ { "from": "system", "value": "Fix forgotten __ for init\n" }, { "from": "human", "value": "#! /usr/bin/env python2.7\n\nimport modules.apis.api_base as api\n\nclass SRcomAPI(api.API):\n\n def __init(self, session = None):\n super(SRcomAPI, self).__init__(\"http://www.speedrun.com/api/v...
python
chosen
[ { "from": "system", "value": "Implement Decks Assemble brawl rules on the Deckbuilding Enchant\n" }, { "from": "human", "value": "\"\"\"\nDecks Assemble\n\"\"\"\n\nfrom ..utils import *\n\n\n# Tarnished Coin\nclass TB_011:\n\tplay = ManaThisTurn(CONTROLLER, 1)\n" }, { "from": "gpt", ...
python
chosen
[ { "from": "system", "value": "Fix rollback transaction issue bby adding except for Operation Failure to rollback\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom framework.mongo import database as proxy_database\n\n\ndef begin(database=None):\n database = database or proxy_d...
python
chosen
[ { "from": "system", "value": "Use commonprefix to break dep on 3.5\n" }, { "from": "human", "value": "import http.server\nfrom threading import Thread\nimport os.path\n\n\nclass HTTPHandler:\n def __init__(self, config):\n self.config = config\n\n handler = HTTPHandler.make_http...
python
chosen
[ { "from": "system", "value": "Add Check for numba in base anaconda distribution. If not found issue meaningful warning message\n" }, { "from": "human", "value": "\"\"\"\nImport the main names to top level.\n\"\"\"\n\nfrom .compute_fp import compute_fixed_point\nfrom .discrete_rv import DiscreteR...
python
chosen
[ { "from": "system", "value": "Remove warning for Django 1.7\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport sys\nfrom django.conf import settings\nfrom django.core.management import execute_from_command_line\n\nif not settings.configured:\n settings.configure(\n DEBUG ...
python
chosen
[ { "from": "system", "value": "Disable flatfile tests until atom tests complete.\n" }, { "from": "human", "value": "#!/usr/bin/python\nimport unittest\nfrom firmant.utils import get_module\n# Import this now to avoid it throwing errors.\nimport pytz\n\nfrom firmant.configuration import settings\n...
python
chosen
[ { "from": "system", "value": "Set SRID the new way\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom django.contrib.gis.geos import Polygon\n\n\nclass ResourceLink(object):\n def __init__(self, type, href):\n self.type = type\n self.href = href\n\n\nclass Resource...
python
chosen
[ { "from": "system", "value": "Add SCRIPT_MATRIX to babelfish module imports\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n#\n# Copyright (c) 2013 the BabelFish authors. All rights reserved.\n# Use of this source code is governed by the 3-clause BSD license\n# that can be found in t...
python
chosen
[ { "from": "system", "value": "tests: Add a couple more Flag tests.\n" }, { "from": "human", "value": "import unittest\n\nfrom construct import Flag\n\nclass TestFlag(unittest.TestCase):\n\n def test_parse(self):\n flag = Flag(\"flag\")\n self.assertTrue(flag.parse(\"\\x01\"))\n\...
python
chosen
[ { "from": "system", "value": "Tweak formatting of argparse section to minimize lines extending past 80 chars.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\n# CLI frontend to Arris modem stat scraper library arris_scraper.py\n\nimport argparse\nimport arris_scraper\nimport json\nimp...
python
chosen
[ { "from": "system", "value": "Add note about how to generate trajectories\n" }, { "from": "human", "value": "\"\"\"Tools for setting up a fake directory structure for processing.\"\"\"\n\nfrom tempfile import mkdtemp\nimport os\nimport shutil\nimport json\n\nfrom pkg_resources import resource_fi...
python
chosen
[ { "from": "system", "value": "Make hive_primary_DIMENSION.id primary key, so autoincrement works.\n" }, { "from": "human", "value": "\"\"\"\nHiveDB client access via SQLAlchemy\n\"\"\"\n\nimport sqlalchemy as sq\n\nmetadata = sq.MetaData()\n\nhive_primary = sq.Table(\n 'hive_primary_DIMENSION...
python
chosen
[ { "from": "system", "value": "Set default argv to None\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport os\nimport subprocess\nimport sys\n\n\ndef main(argv):\n if len(argv) == 0 or len(argv) > 2:\n print(\"Usage: databaker_process.py <notebook_file> <input_file>\")\n ...
python
chosen
[ { "from": "system", "value": "Fix Custom class, user exit in beaker.session\nredirect to login page\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport logging\nfrom bottle import redirect\n\n\nlog = logging.getLogger('bottle-auth.custom')\n\n\nclass Custom(...
python
chosen
[ { "from": "system", "value": "Remove value which is already default\n" }, { "from": "human", "value": "from django.db import models\nfrom django.contrib.auth.models import User\nfrom django.utils.translation import gettext_lazy as _\n\n\nclass Excerpt(models.Model):\n name = models.CharField(...
python
chosen
[ { "from": "human", "value": "Add skeleton for secondary structure and write pdb module\n" }, { "from": "gpt", "value": "# import porter_paleale\n\n\ndef predict_secondary_structure(sequence):\n \"\"\"\n Predict the secondary structure of a given sequence\n\n :param sequence: Amino acid ...
python
chosen
[ { "from": "system", "value": "Add tests for ballots resource classes.\n" }, { "from": "human", "value": "\nfrom openrcv.models import ContestInfo\nfrom openrcv.utiltest.helpers import UnitCase\n\n\nclass ContestInfoTest(UnitCase):\n\n def test_get_candidates(self):\n contest = ContestI...
python
chosen
[ { "from": "system", "value": "Clean bug with static file serving\n" }, { "from": "human", "value": "from django.contrib.auth.forms import AuthenticationForm\nfrom django.contrib.sites.models import get_current_site\nfrom django.conf import settings\n\nfrom haystack.forms import SearchForm\nfrom ...
python
chosen
[ { "from": "system", "value": "Make it DRYer for people\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\n# Authentication and Authorisation\nfrom functools import wraps\n\nfrom . import http\n\n\ndef permit(test_func, response_class=http.Forbidden):\n '''Decorate a...
python
chosen
[ { "from": "system", "value": "DanielWagnerHall: Fix test as well :)\n\ngit-svn-id: aa1aa1384423cb28c2b1e29129bb3a91de1d9196@17825 07704840-8298-11de-bf8c-fd130f914ac9\n" }, { "from": "human", "value": "#!/usr/bin/python\n\n# Copyright 2012 Software Freedom Conservancy.\n#\n# Licensed under the A...
python
chosen
[ { "from": "system", "value": "Set url to serve uploaded file during development\n" }, { "from": "human", "value": "# Created by JHJ on 2016. 10. 5.\n\nfrom django.conf.urls import url\n\nfrom . import views\n\napp_name = 'board'\nurlpatterns = [\n url(r'^$', views.board_list, name='board_list...
python
chosen
[ { "from": "system", "value": "Convert reactions syslog to logger: timetracking\n" }, { "from": "human", "value": "#!/usr/bin/python\n######################################################################\n# Cloud Routes Bridge\n# ------------------------------------------------------------------...
python
chosen
[ { "from": "system", "value": "Clean out the mako temp dirs before running tests\n" }, { "from": "human", "value": "\"\"\"\nHelper functions for test tasks\n\"\"\"\nfrom paver.easy import sh, task\nfrom pavelib.utils.envs import Env\n\n__test__ = False # do not collect\n\n\n@task\ndef clean_test...
python
chosen
[ { "from": "system", "value": "ENH: Replace `NestedSequence` with a proper nested sequence protocol\n" }, { "from": "human", "value": "\"\"\"\nThis file defines the types for type annotations.\n\nThese names aren't part of the module namespace, but they are used in the\nannotations in the functio...
python
chosen
[ { "from": "system", "value": "Fix a typo of class docstring\n" }, { "from": "human", "value": "\"\"\"Handle nicovideo.jp user_session.\"\"\"\n# Copyright 2015-2016 Masayuki Yamamoto\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in ...
python
chosen
[ { "from": "system", "value": "Use django reverse function to obtain url instead of hard-coding\n" }, { "from": "human", "value": "from django.views import View\nfrom django.views.generic import TemplateView\nfrom django.contrib import auth\nfrom django.contrib import messages\nfrom django import...
python
chosen
[ { "from": "system", "value": "Fix behave tests to use install command.\n" }, { "from": "human", "value": "from behave import given\n\nfrom captainhook.checkers.utils import bash\n\n\n@given('I have installed captainhook')\ndef step_impl(context):\n bash('captainhook')\n" }, { "from": ...
python
chosen
[ { "from": "system", "value": "Add check for fixture loading\n" }, { "from": "human", "value": "from django.db.models.signals import (\n post_save,\n)\n\nfrom django.dispatch import receiver\n\nfrom rest_framework.authtoken.models import Token\n\nfrom django.conf import settings\n\nfrom .model...
python
chosen
[ { "from": "system", "value": "Delete cache key in reset command line\n" }, { "from": "human", "value": "from axes.models import AccessAttempt\n\n\ndef reset(ip=None, username=None):\n \"\"\"Reset records that match ip or username, and\n return the count of removed attempts.\n \"\"\"\n ...
python
chosen
[ { "from": "system", "value": "Add another test for Code Flow.\n" }, { "from": "human", "value": "from django.core.urlresolvers import reverse\nfrom django.test import RequestFactory\nfrom django.test import TestCase\nfrom openid_provider.tests.utils import *\nfrom openid_provider.views import *\...
python
chosen
[ { "from": "system", "value": "Enable debug level for log file\n" }, { "from": "human", "value": "#\n# Jasy - JavaScript Tooling Refined\n# Copyright 2010 Sebastian Werner\n#\n\n#\n# Configure logging\n#\n\nimport logging\n\nlogging.basicConfig(filename=\"log.txt\", level=logging.INFO, format=\"%...
python
chosen
[ { "from": "system", "value": "Add children to debug str\n" }, { "from": "human", "value": "# Copyright (c) 2017 The Regents of the University of Michigan.\n# All Rights Reserved. Licensed according to the terms of the Revised\n# BSD License. See LICENSE.txt for details.\n\nclass MutableTree:\n\n...
python
chosen
[ { "from": "system", "value": "Fix diffing on Py3 by comparing unicode strings\n" }, { "from": "human", "value": "# coding=utf-8\n\nfrom __future__ import unicode_literals\n\nfrom io import BytesIO\n\nfrom .marc import Record\nfrom .util import etree, parse_xml, show_diff\n\n\nclass Bib(object):\...
python
chosen
[ { "from": "system", "value": "Add ability to select UVM version in unit tests\n" }, { "from": "human", "value": "#!/bin/env python2.7\n\nimport argparse\nimport os\n\nparser = argparse.ArgumentParser(description=\"Run unit tests\")\nparser.add_argument(\"-g\", \"--gui\", help=\"start in GUI mode...
python
chosen