conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Enable Command to support memory limiting.\n" }, { "from": "human", "value": "import subprocess as sp\nimport signal\nimport threading\nimport os\n\n\nSIGTERM_TIMEOUT = 1.0\n\n\nclass Command(object):\n def __init__(self, cmd, memlimit=None):\n self.cmd = ...
python
chosen
[ { "from": "system", "value": "Allow passing engine arguments to connect().\n" }, { "from": "human", "value": "import pkg_resources\n\nfrom sqlalchemy import MetaData, Table, create_engine, orm\n\nfrom .tables import metadata\n\ndef connect(uri=None, **kwargs):\n \"\"\"Connects to the requeste...
python
chosen
[ { "from": "system", "value": "Handle absolute import for py27\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"\nCrossfolium\n-----------\n\n\"\"\"\n\nimport crossfolium.marker_function as marker_function\n\nfrom crossfolium.crossfolium import (\n Crossfilter,\n PieFilter,...
python
chosen
[ { "from": "system", "value": "Remove db if it already exists\n" }, { "from": "human", "value": "import sqlite3\nimport os\nimport pandas as pd\n\nTABLES = [['Natures', 'nature'],\n ['Experience'],\n ]\n\nPATH = os.path.dirname(__file__)+\"/\"\nCONNECTION = sqlite3.connect(PATH +...
python
chosen
[ { "from": "system", "value": "Enable django debug toolbar via env var\n" }, { "from": "human", "value": "# coding: utf-8\nfrom .base import *\n\nLOGGING['handlers']['console'] = {\n 'level': 'DEBUG',\n 'class': 'logging.StreamHandler',\n 'formatter': 'verbose'\n}\n\nINSTALLED_APPS = INS...
python
chosen
[ { "from": "system", "value": "Use the fqdn when registering with the master.\n\nNot all deployment systems will provide a specific hostname via an env\nvar so we'll avoid relying on it by asking the machine.\n" }, { "from": "human", "value": "import json\n\nimport requests\n\nfrom flask import r...
python
chosen
[ { "from": "system", "value": "Build out hash function of hash table class\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\n'''Implementation of a simple hash table.\nThe table has `hash`, `get` and `set` methods.\nThe hash function uses a very basic hash algorithm to insert the value\...
python
chosen
[ { "from": "system", "value": "Change l'ordre d'insertion des utilisateurs.\n" }, { "from": "human", "value": "# coding: utf-8\n\nfrom __future__ import unicode_literals\nfrom django.contrib.auth.models import AbstractUser, UserManager\nfrom django.db.models import BooleanField\nfrom django.utils...
python
chosen
[ { "from": "system", "value": "Remove call to open account window when loading module\n" }, { "from": "human", "value": "from ghostlines.storage.app_storage import AppStorage\nfrom ghostlines.windows.account_details_window import AccountDetailsWindow\nfrom ghostlines.windows.sign_in_window import...
python
chosen
[ { "from": "system", "value": "Make api file path OS safe\n" }, { "from": "human", "value": "import base64\r\nimport json\r\nfrom os import path\r\nimport sys\r\n\r\nsys.path.insert(0, path.dirname(path.dirname(path.abspath(__file__))))\r\n\r\napi_file = 'my_api.json'\r\n_api_file = '{}\\{}'.form...
python
chosen
[ { "from": "system", "value": "Save every request coming in the facebook webroot endpoint\n" }, { "from": "human", "value": "import http.client\nimport os\n\nfrom flask import Flask\nfrom pymongo import MongoClient\n\nMONGO_URL = os.environ.get('MONGO_URL', 'mongodb://mongo:27017/')\nMONGO_DATABA...
python
chosen
[ { "from": "system", "value": "Switch default to actual ES default (date_optional_time) and add TIME type\n" }, { "from": "human", "value": "# ElasticMapping\n# File: types.py\n# Desc: base Elasticsearch types\n\n\nclass CallableDict(dict):\n BASE = None\n OVERRIDES = None\n\n def __call...
python
chosen
[ { "from": "system", "value": "Add the deletion of the app users\n" }, { "from": "human", "value": "from django.core.management.base import BaseCommand, CommandError\nfrom app.models import Author, Location, AutoComment, Comment, Idea, Vote\n\n\nclass Command(BaseCommand):\n def handle(self, *...
python
chosen
[ { "from": "system", "value": "Add warning log level for auth checks\n" }, { "from": "human", "value": "from itsdangerous import TimedJSONWebSignatureSerializer as Serializer\nfrom flask import request as flask_request\nfrom flask import abort\n\nimport logging\nimport os\n\ndef gen_auth_token(id...
python
chosen
[ { "from": "system", "value": "Fix the test removing paths.\n" }, { "from": "human", "value": "#-*- coding:utf-8 -*-\n\n\"\"\" \nBase Recommender Models.\n\"\"\"\n\n# Authors: Marcel Caraciolo <marcel@muricoca.com>\n# Bruno Melo <bruno@muricoca.com>\n# License: BSD Style.\n\nimport unitt...
python
chosen
[ { "from": "system", "value": "Add missing import for unittest.mock.patch.\n" }, { "from": "human", "value": "\"\"\"\nPython 2 Compatibility Layer\n\nThis module exists to work around compatibility issues between Python 2 and\nPython 3. The main code-base will use Python 3 idioms and this module ...
python
chosen
[ { "from": "system", "value": "Send through serialised users with each ride api request\n" }, { "from": "human", "value": "import requests\nfrom django.conf import settings\nfrom rest_framework import serializers\nfrom rest_framework.validators import UniqueTogetherValidator\nfrom server.api.seri...
python
chosen
[ { "from": "system", "value": "Cut 0.14.1 because setup.py bug\n" }, { "from": "human", "value": "__version_info__ = (0, 14, 0)\n__version__ = '.'.join(map(str, __version_info__))\n" }, { "from": "gpt", "value": "__version_info__ = (0, 14, 1)\n__version__ = '.'.join(map(str, __version...
python
chosen
[ { "from": "system", "value": "Add a settings key to ensure index at start\n" }, { "from": "human", "value": "from pyramid.settings import asbool\n\nfrom .client import ElasticClient\n\n\ndef client_from_config(settings, prefix='elastic.'):\n \"\"\"\n Instantiate and configure an Elasticsea...
python
chosen
[ { "from": "system", "value": "Add semi-useful `__str__` for Result\n" }, { "from": "human", "value": "from subprocess import PIPE\n\nfrom .monkey import Popen\nfrom .exceptions import Failure\n\n\nclass Result(object):\n def __init__(self, stdout=None, stderr=None, exited=None):\n self...
python
chosen
[ { "from": "system", "value": "[recipes] Fix compilation for regex recipe\n\nThe error was: build/other_builds/hostpython3/desktop/hostpython3/Include/Python.h:39:19: fatal error: crypt.h: No such file or directory\n" }, { "from": "human", "value": "from pythonforandroid.recipe import CompiledCo...
python
chosen
[ { "from": "system", "value": "Use deppcopy to copy dicts\n" }, { "from": "human", "value": "import json\nfrom relay_api.core.relay import relay\nfrom relay_api.conf.config import relays\n\n\ndef init_relays():\n for r in relays:\n relays[r][\"object\"] = relay(relays[r][\"gpio\"])\n ...
python
chosen
[ { "from": "system", "value": "Implement a basic search-and-grab algorithm\n" }, { "from": "human", "value": "from sr import *\n\nprint \"Hello, world!\"\n\n" }, { "from": "gpt", "value": "import time\nfrom sr import *\n\nprint \"Hello, world!\"\n\nR = Robot()\n\n# This is the configu...
python
chosen
[ { "from": "system", "value": "Remove unnecessary defaults and simplify regexp" }, { "from": "human", "value": "#\n# linter.py\n# Linter for SublimeLinter3, a code checking framework for Sublime Text 3\n#\n# Written by Andrew Grim\n# Copyright (c) 2014 Andrew Grim\n#\n# License: MIT\n#\n\n\"\"\"T...
python
chosen
[ { "from": "system", "value": "Handle case where rule shows before severity\n\nThank you @suprMax !\n" }, { "from": "human", "value": "#\n# linter.py\n# Linter for SublimeLinter3, a code checking framework for Sublime Text 3\n#\n# Written by Jack Brewer\n# Copyright (c) 2015 Jack Brewer\n#\n# Lic...
python
chosen
[ { "from": "system", "value": "Exclude teams if owner has other teams with migrated tips\n" }, { "from": "human", "value": "from gratipay.wireup import db, env\nfrom gratipay.models.team import AlreadyMigrated\n\ndb = db(env())\n\nteams = db.all(\"\"\"\n SELECT distinct ON (t.slug) t.*::teams\...
python
chosen
[ { "from": "system", "value": "Fix issue with migrations introduced lately.\n" }, { "from": "human", "value": "# Generated by Django 2.1.4 on 2019-01-05 15:00\n\nimport django.contrib.postgres.fields\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n depe...
python
chosen
[ { "from": "system", "value": "Make the Ukrainian SSN provider realer\n\n" }, { "from": "human", "value": "# coding=utf-8\nfrom __future__ import unicode_literals\nfrom .. import Provider as SsnProvider\n\n\n# Note: as there no SSN in Ukraine\n# we get value added tax identification number (VATI...
python
chosen
[ { "from": "system", "value": "Add component test functions using pytest\n" }, { "from": "human", "value": "import sys\n\nprint(sys.path)\n" }, { "from": "gpt", "value": "import pytest\nimport requests\nfrom time import sleep\n\nCOMPONENT_INDEX_URL = \"http://identidock:5000\"\n\nCOMP...
python
chosen
[ { "from": "system", "value": "Extend UniformDH test to also verify the length of the shared master secret.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport unittest\n\nimport const\nimport uniformdh\n\nimport obfsproxy.network.buffer as obfs_buf\n\nclas...
python
chosen
[ { "from": "system", "value": "Add link to gadget for Alembic code\n" }, { "from": "human", "value": "from flask_script import Manager\nfrom flask_skeleton_api.main import app\nimport subprocess\nimport os\n\nmanager = Manager(app)\n\n\n@manager.command\ndef unittest(report=False):\n \"\"\"Run...
python
chosen
[ { "from": "system", "value": "Modify test file, still doesn't work. Messed around in pshell.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom learning_journal.models import Entry, DBSession\n\n\ndef test_create_entry(dbtransaction):\n \"\"\"Assert entry was entered into data...
python
chosen
[ { "from": "system", "value": "Remove text coloring in AlertFeed if it seems like scheduled text\n" }, { "from": "human", "value": "import asyncio\nimport json\n\nimport aiohttp\n\nimport SLA_bot.config as cf\n\nclass AlertFeed:\n source_url = 'http://pso2emq.flyergo.eu/api/v2/'\n\n async d...
python
chosen
[ { "from": "system", "value": "[py2] Fix SyntaxError due to F string\n\nSigned-off-by: Travis Thieman <f1ef50ba1343ab5680bff0994219d82815f791bd@gmail.com>\n" }, { "from": "human", "value": "from setuptools import setup\n\nv = '4.10.1'\nsetup(\n name='antlr4-python2-runtime',\n version=v,\n ...
python
chosen
[ { "from": "system", "value": "Remove join in exercise 1.3.1 not seen yet in course\n" }, { "from": "human", "value": "# Use the codon variables you defined previously\nS = \"TCT\"\nL = \"CTT\"\nY = \"TAT\"\nC = \"TGT\"\n\n# Create a list for the protein sequence CLYSY\ncodons = [C, L, Y, S, Y]\n...
python
chosen
[ { "from": "system", "value": "Fix was_published_recently reporting polls from the future\n" }, { "from": "human", "value": "from django.db import models\nfrom django.utils import timezone\nfrom datetime import timedelta\n\n\nclass Poll(models.Model):\n text = models.CharField(max_length=200)\...
python
chosen
[ { "from": "system", "value": "Revert \"Revert \"Cleans up split_response\"\"\n\nThis reverts commit c3c62feb9fbd8b7ff35d70eaaa5fecfb2093dbb0.\n" }, { "from": "human", "value": "from motobot import command, Notice, split_response, IRCBot\n\n\n@command('commands')\ndef commands_command(bot, databa...
python
chosen
[ { "from": "system", "value": "Use the new fancy refactored remote logic\n" }, { "from": "human", "value": "from twisted.internet import endpoints, reactor\nfrom txampext.multiplexing import ProxyingFactory\n\n\ndef connectProxy(namespace, identifier, _reactor=reactor):\n \"\"\"Start listening...
python
chosen
[ { "from": "system", "value": "Update exception syntax to be py3 compat\n" }, { "from": "human", "value": "import os\nimport subprocess\n\ntry:\n VERSION = __import__('pkg_resources') \\\n .get_distribution('changes').version\nexcept Exception, e:\n VERSION = 'unknown'\n\n\ndef _get_...
python
chosen
[ { "from": "system", "value": "Update the status.py to look for the output.txt in the new location\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\n#\n# Curriculum Module Status Script\n# - Run while the job is running\n# - Run -outside- of the allocation\n# - onramp_run_params.ini fil...
python
chosen
[ { "from": "system", "value": "Write test for importer initialisation\n" }, { "from": "human", "value": "\"\"\"\nTest the importing module.\nThis module relies heavily on an external service and requires\nquite a bit of mocking.\n\"\"\"\nimport json\n\nfrom django.test import TestCase\n\nfrom mol...
python
chosen
[ { "from": "system", "value": "Remove unnecessary u on string\n" }, { "from": "human", "value": "import argparse\nimport sys\n\nfrom pipreq.command import Command\n\n\ndef create_parser():\n parser = argparse.ArgumentParser(\n description='Manage Python package requirements across multi...
python
chosen
[ { "from": "system", "value": "Add paddle inertia to calculations\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\"\"\"\nProcessing routines for the waveFlapper case.\n\n\"\"\"\n\nimport foampy\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nwidth_2d = 0.1\nwidth_3d = 3.66\n\nd...
python
chosen
[ { "from": "system", "value": "Append binary file mode to write RSA exported key needed by Python 3\n" }, { "from": "human", "value": "from Crypto.PublicKey import RSA\n\nfrom django.conf import settings\nfrom django.core.management.base import BaseCommand\n\n\nclass Command(BaseCommand):\n he...
python
chosen
[ { "from": "system", "value": "Use test_docs as directory for test documents for solr server\n" }, { "from": "human", "value": "#!/usr/bin/python\n#\n# SCRIPT FOR POPULATING TEST SOLR SERVER CORE WITH TEST DOCUMENTS\n#\n# Usage: python setup-test-docs.py <Solr Endpoint Url>\n#\n# Solr endpoint UR...
python
chosen
[ { "from": "system", "value": "Fix object has no db_log_failed_attempt\n" }, { "from": "human", "value": "\"\"\"\nA utility class which wraps the RateLimitMixin 3rd party class to do bad request counting\nwhich can be used for rate limiting\n\"\"\"\nfrom ratelimitbackend.backends import RateLimit...
python
chosen
[ { "from": "system", "value": "Create tables in database before running tests\n" }, { "from": "human", "value": "from api.scrapers.item import scrape_item_by_id\nfrom api import app\n\nfrom flask.json import loads\n\nimport unittest\n\napp.config['TESTING'] = True\n\n\nclass ScrapeItem(unittest.T...
python
chosen
[ { "from": "system", "value": "Add a legacy version for older versions of Django.\n\nSigned-off-by: Chris Lamb <711c73f64afdce07b7e38039a96d2224209e9a6c@thread.com>\n" }, { "from": "human", "value": "from django.db import transaction, connection\n\nclass TransactionMiddleware(object):\n def pr...
python
chosen
[ { "from": "system", "value": "Add a url attribute to the SearchIndex for pages.\n\nThis is useful when displaying a list of search results because we\ncan create a link to the result without having to hit the database\nfor every object in the result list.\n" }, { "from": "human", "value": "\"\"\...
python
chosen
[ { "from": "system", "value": "Increase the code coverage of App.configure_platforms method\n" }, { "from": "human", "value": "import asyncio\nfrom unittest import mock\n\nimport aiohttp\nimport pytest\n\nfrom bottery.app import App\n\n\ndef test_app_session():\n app = App()\n assert isinst...
python
chosen
[ { "from": "system", "value": "Remove textblob dependency in time logic adapter\n" }, { "from": "human", "value": "from __future__ import unicode_literals\nfrom datetime import datetime\nfrom .logic_adapter import LogicAdapter\n\n\nclass TimeLogicAdapter(LogicAdapter):\n \"\"\"\n The TimeLo...
python
chosen
[ { "from": "system", "value": "[FIX] Fix issue on account.invoice about workflow_process_id: if a user duplicate an invoice, it copy also the workflow and validations (the reason of bugs)\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# © 2011 Akretion Sébastien BEAU <sebastien.beau@...
python
chosen
[ { "from": "system", "value": "Fix celery task_failure signal definition\n" }, { "from": "human", "value": "\"\"\"\nraven.contrib.celery\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n:copyright: (c) 2010 by the Sentry Team, see AUTHORS for more details.\n:license: BSD, see LICENSE for more details.\n\"\"\"\n\...
python
chosen
[ { "from": "system", "value": "Use removing rather than copying\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\n\nfrom pathlib import Path\nfrom random import shuffle\nfrom shutil import copy\n\n\n# configs\n\nN = 10000\nSAMPLED_DIR_PATH = Path('sampled/')\n\n# mkdir if doesn't exist\...
python
chosen
[ { "from": "system", "value": "Add node id to url.\n" }, { "from": "human", "value": "from django.conf.urls import url\nfrom api.wb import views\n\napp_name = 'osf'\n\nurlpatterns = [\n url(r'^move/', views.MoveFile.as_view(), name=views.MoveFile.view_name),\n url(r'^copy/', views.MoveFile....
python
chosen
[ { "from": "system", "value": "Check for the existance of the settings file and report if its not there\n" }, { "from": "human", "value": "\"\"\"\nMCServer Tools config loader\n\"\"\"\n\nimport json\nimport os.path\n\nclass CoreConfig(object):\n\t\"\"\"\n\tMCServer Tools configuration\n\t\"\"\"\n...
python
chosen
[ { "from": "system", "value": "Make title unique Talk property\n" }, { "from": "human", "value": "from app import database\n\n\nclass Talk(database.Model):\n id = database.Column(database.Integer, primary_key=True, autoincrement=True)\n title = database.Column(database.String(128), nullable...
python
chosen
[ { "from": "system", "value": "CHange name so it isn't reset\n" }, { "from": "human", "value": "\nimport sys\nimport os\n\n'''\nEasier searching for good RFI flagging values\n'''\n\ntry:\n vis = sys.argv[1]\nexcept IndexError:\n vis = raw_input(\"Input vis? : \")\n\n# Just want the number o...
python
chosen
[ { "from": "system", "value": "Fix ports for syzygy master to match previous ports.\n\n\nTBR=chrisha@chromium.org\nBUG=\n\n\nReview URL: https://chromiumcodereview.appspot.com/12315047\n\ngit-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@183944 0039d316-1c4b-4281-b951-d872f2087c98\n" }, { "from": ...
python
chosen
[ { "from": "system", "value": "Change tender init handlers names\n" }, { "from": "human", "value": "from pyramid.events import subscriber\nfrom openprocurement.tender.core.events import TenderInitializeEvent\nfrom openprocurement.tender.core.utils import get_now, calculate_business_date\n\n\n@sub...
python
chosen
[ { "from": "system", "value": "Add Options class\nAdd field filters lists\nStart proper model field introspection\n" }, { "from": "human", "value": "\nfrom .fields import Field\nfrom .views import DataView\n\nfrom django.utils.six import with_metaclass\n\n\nclass MetaView(type):\n\n def __new_...
python
chosen
[ { "from": "system", "value": "Fix object storage apiType for S3 and Swift.\n" }, { "from": "human", "value": "\"\"\"List Object Storage accounts.\"\"\"\n# :license: MIT, see LICENSE for more details.\n\nimport click\n\nimport SoftLayer\nfrom SoftLayer.CLI import environment\nfrom SoftLayer.CLI i...
python
chosen
[ { "from": "system", "value": "Fix Xm library location error.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n#\n# Xm\n#\n# The xm library is hard to find and requires this special code.\n#\n# Author P G Jones - 11/07/2012 <p.g.jones@qmul.ac.uk> : First revision\n# Author P G Jones - 22...
python
chosen
[ { "from": "system", "value": "Change Initial Version Number to '0.1.0'\n\nChange __version__ to '0.1.0'\n" }, { "from": "human", "value": "\"\"\"\nSocketdjango Project Module\n\nInteresting Docstring goes here!\n\"\"\"\n\n__version__ = '0.0.1'\n" }, { "from": "gpt", "value": "\"\"\"\...
python
chosen
[ { "from": "system", "value": "Reduce log severity of socket import messages" }, { "from": "human", "value": "'''Sockets that wrap different connection types'''\n\n# Not all platforms support all types of sockets provided here. For those that\n# are not available, the corresponding socket wrapper...
python
chosen
[ { "from": "system", "value": "Fix the SQLite URL problem\n" }, { "from": "human", "value": "import os\n\n\nif os.environ['DATABASE_URL'] is None:\n SQLALCHEMY_DATABASE_URI = 'sqlite:///meetup.db'\nelse:\n SQLALCHEMY_DATABASE_URI = os.environ['DATABASE_URL']\n\nSQLALCHEMY_TRACK_MODIFICATION...
python
chosen
[ { "from": "system", "value": "Use is_authenticated as a property.\n" }, { "from": "human", "value": "from .models import Observer\n\n\nclass ObserverMiddleware(object):\n \"\"\"\n Attaches an observer instance to every request coming from an\n authenticated user.\n \"\"\"\n def pr...
python
chosen
[ { "from": "system", "value": "Add more comments about usage.\n" }, { "from": "human", "value": "#!/usr/bin/env python3\n\n# References:\n# http://docs.python.org/3.3/library/argparse.html?highlight=argparse#argparse\n# http://bip.weizmann.ac.il/course/python/PyMOTW/PyMOTW/docs/argparse/index.htm...
python
chosen
[ { "from": "system", "value": "Make tag and key be a composite primary key\n" }, { "from": "human", "value": "from sqlalchemy import Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.schema import UniqueConstraint\n\nBase = declarative_base()\n\ncla...
python
chosen
[ { "from": "system", "value": "Change graph_type for chart_type and remove it from context\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom django.views.generic import TemplateView\nfrom chartflo.factory import ChartDataPack\n\n\nclass ChartsView(TemplateView):\n template_nam...
python
chosen
[ { "from": "system", "value": "Use MD5 to encode passwords\n" }, { "from": "human", "value": "from eve import Eve\nfrom eve_swagger import swagger\nfrom eve.auth import BasicAuth\nfrom config import *\nfrom hashlib import md5\n\nclass MyBasicAuth(BasicAuth):\n def check_auth(self, username, pa...
python
chosen
[ { "from": "system", "value": "Add missing --name flag to 'envy snapshot'\n" }, { "from": "human", "value": "from cloudenvy.envy import Envy\n\n\nclass EnvySnapshot(object):\n \"\"\"Create a snapshot of an ENVy.\"\"\"\n\n def __init__(self, argparser):\n self._build_subparser(argpars...
python
chosen
[ { "from": "system", "value": "Remove newline and carraige return characters from key files so that API calls work\n" }, { "from": "human", "value": "#!/usr/bin/python\n\ndef readKey(keyFileName):\n return open(\"../options-and-settings/api-keys/\" + keyFileName, \"r\").readline()\n\n" }, ...
python
chosen
[ { "from": "system", "value": "Add quick admin-site tests too\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport pytest\nfrom django.core.urlresolvers import reverse\nfrom members.tests.fixtures.memberlikes import MembershipApplicationFactory\nfrom members.tests.fixtures.types imp...
python
chosen
[ { "from": "system", "value": "Change the title of the example\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\"\"\"\nExample using Arabic\n===============\nGenerating a wordcloud from Arabic text\nOther dependencies: bidi.algorithm, arabic_reshaper\n\"\"\"\n\nfrom os import path\nimpo...
python
chosen
[ { "from": "system", "value": "Make debug_cache_key a part of API\n" }, { "from": "human", "value": "VERSION = (3, 0, 1)\n__version__ = '.'.join(map(str, VERSION if VERSION[-1] else VERSION[:2]))\n\n\nfrom django.apps import AppConfig\n\nfrom .simple import *\nfrom .query import *\nfrom .invalida...
python
chosen
[ { "from": "system", "value": "[FIX] Fix 'installable' syntax in manifest file\n" }, { "from": "human", "value": "# © 2016 Therp BV <http://therp.nl>\n# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).\n{\n \"name\": \"Pdf watermark\",\n \"version\": \"12.0.1.0.0\",\n \...
python
chosen
[ { "from": "system", "value": "Add board list test code.\n" }, { "from": "human", "value": "from django.test import TestCase\n\n# Create your tests here.\n" }, { "from": "gpt", "value": "from test_plus.test import TestCase\n\n\nclass BoardTest(TestCase):\n def test_get_board_list(s...
python
chosen
[ { "from": "system", "value": "Fix self.model is not set.\n" }, { "from": "human", "value": "import importlib\nimport logging\nfrom volttron.platform.agent import utils\n\n_log = logging.getLogger(__name__)\nutils.setup_logging()\n__version__ = \"0.1\"\n\n__all__ = ['Model']\n\n\nclass Model(obje...
python
chosen
[ { "from": "system", "value": "Read token from environment variable\n" }, { "from": "human", "value": "import sys\nsys.path.append('../ideascaly')\n\nfrom ideascaly.auth import AuthNonSSO\nfrom ideascaly.api import API\n\nimport unittest\n\ntesting_community = 'fiveheads.ideascale.com'\ntesting_t...
python
chosen
[ { "from": "system", "value": "Allow any ip in the get_span expected span since it's not deterministic\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport mock\nimport pytest\n\n\n@pytest.fixture\ndef default_trace_id_generator(dummy_request):\n return lambda dummy_request: '171...
python
chosen
[ { "from": "system", "value": "Make the example more informative\n" }, { "from": "human", "value": "\"\"\"\nThis example:\n\n1. Connects to the current model\n2. Deploy a bundle and waits until it reports itself active\n3. Destroys the units and applications\n\n\"\"\"\nfrom juju import jasyncio\n...
python
chosen
[ { "from": "system", "value": "Add taza, tazon and vaso global conversions\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import, unicode_literals, division\n\nimport logging\n\nlogger = logging.getLogger(__name__) # pylint: dis...
python
chosen
[ { "from": "system", "value": "Allow everyone to bam and warm, hide commands" }, { "from": "human", "value": "import discord\nimport random\nfrom discord.ext import commands\n\n\nclass Meme:\n \"\"\"\n Meme commands.\n \"\"\"\n\n def __init__(self, bot):\n self.bot = bot\n ...
python
chosen
[ { "from": "system", "value": "Exclude more unneeded files from default plan\n\nThis patch exludes more file types from the tarball uploaded to swift as\nthe default deployment plan.\n\nChange-Id: I8b6d8de8d7662604cdb871fa6a4fb872c7937e25\nCloses-Bug: #1613286\n" }, { "from": "human", "value": "#...
python
chosen
[ { "from": "system", "value": "Create missing bucket for one-day frequency\n" }, { "from": "human", "value": "import copy\n\nimport fedmsg.consumers\n\nimport logging\nlog = logging.getLogger(\"fedmsg\")\n\nclass StatsConsumer(fedmsg.consumers.FedmsgConsumer):\n \"\"\"\n The actual 'cache' ...
python
chosen
[ { "from": "system", "value": "Put correct directory for profiles in test_hmmsearch\n" }, { "from": "human", "value": "import os\nimport unittest\nimport sys\n\n# hack to allow tests to find inmembrane in directory above\nmodule_dir = os.path.abspath(os.path.dirname(__file__))\nsys.path.insert(0,...
python
chosen
[ { "from": "system", "value": "Add conv2d test for tensorflow\n" }, { "from": "human", "value": "import unittest\n\nimport numpy as np\nimport tensorflow as tf\n\nfrom common import gpu_test\n\n\nclass TestTensorflow(unittest.TestCase):\n def test_addition(self): \n op = tf.add(2...
python
chosen
[ { "from": "system", "value": "Define a complete list of language code, for easy future maintenance\n" }, { "from": "human", "value": "\"\"\"\nConstants for mots-vides\n\"\"\"\nimport os\n\nDATA_DIRECTORY = os.path.join(\n os.path.dirname(\n os.path.abspath(__file__)),\n 'datas/'\n)\...
python
chosen
[ { "from": "system", "value": "Fix code so it also works under Python 3.\n" }, { "from": "human", "value": "# Licensed to the StackStorm, Inc ('StackStorm') under one or more\n# contributor license agreements. See the NOTICE file distributed with\n# this work for additional information regarding...
python
chosen
[ { "from": "system", "value": "Fix Color enum setup when TERM isn't set\n\nThe previous version of this didn't work right because all the values\nwere the same empty string.\n\nThis works around that by creating distinct values that evaluate to \"\".\n\nAmends 94b55ead63523f7f5677989f1a4999994b205cdf\n" },...
python
chosen
[ { "from": "system", "value": "Define function and decorators for subparsers\n" }, { "from": "human", "value": "import json\n\n\ndef cli_arg(*args, **kwargs):\n \"\"\"Decorator for CLI args\"\"\"\n def _decorator(func):\n add_arg(func, *args, **kwargs)\n return func\n retur...
python
chosen
[ { "from": "system", "value": "Apply additional fix to add_user_foreign_key migration\n\nThe hack in 583fb729b1e201c830579345dca5beca4b131006 modified\n0010_add_user_foreign_key in such a way that it ended up *not* setting\na database constraint when it should have.\n\nEnable the database-enforced constraint...
python
chosen
[ { "from": "system", "value": "Update example plot script with new API\n" }, { "from": "human", "value": "import os\n\nimport matplotlib.pyplot as plt\nplt.style.use(\"ggplot\")\nplt.rcParams[\"figure.figsize\"] = 10, 5\nplt.rcParams[\"font.family\"] = \"serif\"\nplt.rcParams[\"font.size\"] = 12\...
python
chosen
[ { "from": "system", "value": "Use legal characters for stripping filenames\n" }, { "from": "human", "value": "#!/bin/python\nimport os\ndirectory = os.listdir()\nillegal_characters = \"%?_'*+$!\\\"\"\ntolowercase=True\n\nfor a in range(len(directory)):\n newname=\"\"\n for c in directory[a...
python
chosen
[ { "from": "system", "value": "Change User Agent to comply with specification\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport logging\nimport os\nimport queue\nimport threading\n\nlistening_port = 8444\nsend_outgoing_connections = True\nlisten_for_connections = True\ndata_direc...
python
chosen
[ { "from": "system", "value": "Disable tests until new repo is stable\n\nChange-Id: Ic6932c1028c72b5600d03ab59102d1c1cff1b36c\n" }, { "from": "human", "value": "# vim: tabstop=4 shiftwidth=4 softtabstop=4\n\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not ...
python
chosen
[ { "from": "system", "value": "Enable questionsets with negative sortids\n" }, { "from": "human", "value": "# vim: set fileencoding=utf-8\n\nfrom django.conf.urls.defaults import *\nfrom views import *\n\nurlpatterns = patterns('',\n url(r'^$',\n questionnaire, name='questionnaire_n...
python
chosen
[ { "from": "system", "value": "Update url for books to be more semantic\n" }, { "from": "human", "value": "from django.conf.urls.defaults import patterns, include, url\nfrom django.conf import settings\nfrom django.contrib import admin\n\nadmin.autodiscover()\n\nurlpatterns = patterns('library',\...
python
chosen
[ { "from": "system", "value": "FIX only pass S52 test\n" }, { "from": "human", "value": "from expects import expect, equal\nfrom primestg.report import Report\n\n\nwith fdescription('Report S52 example'):\n with before.all:\n\n self.data_filename = 'spec/data/MRTR000000822522_0_S52_1_20...
python
chosen