conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Update the example with latest interface\n\nUpdate the example with the latest interface of the function \"convert\"" }, { "from": "human", "value": "import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\nfrom onnx_coreml import convert\n\n# Step 0 - ...
python
chosen
[ { "from": "system", "value": "Set Python path inside WSGI application" }, { "from": "human", "value": "\"\"\"\nWSGI config for project.\n\nThis module contains the WSGI application used by Django's development server\nand any production WSGI deployments. It should expose a module-level variable\...
python
chosen
[ { "from": "system", "value": "Change knugen command to use array in config/data.json instead of hardcoded array.\n" }, { "from": "human", "value": "import discord\nimport asyncio\nimport random\nimport configparser\nimport json\n\ndef RunBot(config_file):\n config = configparser.ConfigParser(...
python
chosen
[ { "from": "system", "value": "Update Carbon versionadded tags to 2016.11.0 in grains/*\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n'''\nGrains for Cisco NX OS Switches Proxy minions\n\n.. versionadded: Carbon\n\nFor documentation on setting up the nxos proxy minion look in the do...
python
chosen
[ { "from": "system", "value": "Remove some accidentally committed code.\n" }, { "from": "human", "value": "try:\n import _path\nexcept NameError:\n pass\nimport pygame\nimport spyral\nimport sys\n\nSIZE = (640, 480)\nBG_COLOR = (0, 0, 0)\n\nclass Game(spyral.Scene):\n \"\"\"\n A Scene...
python
chosen
[ { "from": "system", "value": "Switch to Bot object instead of Client\n\nBetter reflects examples in discord.py project\n" }, { "from": "human", "value": "import discord\nimport asyncio\n\nclient = discord.Client()\n\n@client.event\nasync def on_ready():\n print('Logged in as')\n print(clie...
python
chosen
[ { "from": "system", "value": "Remove obsolete check for development\n" }, { "from": "human", "value": "from __future__ import division, print_function, absolute_import\n\nimport bugsnag\nimport bugsnag.django\n\ndef is_development_server(request):\n server = request.META.get('wsgi.file_wrappe...
python
chosen
[ { "from": "system", "value": "Fix namespacing for PyPi installs\n\nSee https://github.com/alphagov/performanceplatform-client/pull/5\n" }, { "from": "human", "value": "# Namespace package: https://docs.python.org/2/library/pkgutil.html\ntry:\n import pkg_resources\n pkg_resources.declare_n...
python
chosen
[ { "from": "system", "value": "Revert \"Fix a bug in caching\"\n\nThis reverts commit 2565df456ecb290f620ce4dadca19c76b0eeb1af.\n\nConflicts:\n\twidgets/card.py\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom flask import render_template\n\nfrom models.person import Person\n\n\...
python
chosen
[ { "from": "system", "value": "Add password and password_repeat fields to registration form.\n" }, { "from": "human", "value": "from django import forms\nfrom django.contrib.auth import authenticate\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom hack4lt.models import Hacker\n\n\...
python
chosen
[ { "from": "system", "value": "Remove release title from the GitHub release notes body\n" }, { "from": "human", "value": "\"\"\"\nGenerates the release notes for the latest release, in Markdown.\n\nConvert CHANGELOG.rst to Markdown, and extracts just the latest release.\n\nWrites to ``scripts/lat...
python
chosen
[ { "from": "system", "value": "Include locale in package hash\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nimport os\nimport waptpackage\nfrom waptcrypto import SSLCABundle,SSLCertificate,SSLPrivateKey\n\ndef download(remote, path, pkg):\n \"\"\"Downloads package\"\"\"\n if...
python
chosen
[ { "from": "system", "value": "Switch to round trip loader to support multiple documents.\n" }, { "from": "human", "value": "\"\"\"\n ydf/yaml_ext\n ~~~~~~~~~~~~\n\n Contains extensions to existing YAML functionality.\n\"\"\"\n\nimport collections\n\nfrom ruamel import yaml\nfrom ruamel....
python
chosen
[ { "from": "system", "value": "Use %APPDATA% for data on Windows.\n" }, { "from": "human", "value": "import os\n\n__author__ = 'jakub'\n\n\nCONFIG_DIR = os.path.expanduser('~/.httpie')\n" }, { "from": "gpt", "value": "import os\nfrom requests.compat import is_windows\n\n__author__ = ...
python
chosen
[ { "from": "system", "value": "Tag commit for v0.0.25-master generated by gitmake.py\n" }, { "from": "human", "value": "major = 0\nminor=0\npatch=0\nbranch=\"dev\"\ntimestamp=1376579871.17" }, { "from": "gpt", "value": "major = 0\nminor=0\npatch=25\nbranch=\"master\"\ntimestamp=137661...
python
chosen
[ { "from": "system", "value": "Add app run on main\n" }, { "from": "human", "value": "from flask import Flask, jsonify, render_template, request\napp = Flask(__name__)\n\n\n@app.route('/_add_numbers')\ndef add_numbers():\n ''' Because numbers must be added server side '''\n a = request.args...
python
chosen
[ { "from": "system", "value": "Remove explicit default from BooleanField\n" }, { "from": "human", "value": "from django.core.exceptions import ValidationError\nfrom django.db import models\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom conman.routes.models import Route\nfrom . i...
python
chosen
[ { "from": "system", "value": "Handle exceptions in read_png and read_npy.\n" }, { "from": "human", "value": "import numpy as np\nimport PIL\nfrom io import BytesIO\n# StringIO module is removed in python3, use io module\n\ndef read_png(res):\n import PIL.Image\n img = PIL.Image.open(BytesI...
python
chosen
[ { "from": "system", "value": "Fix token retrieval for Netflix\n" }, { "from": "human", "value": "import foauth.providers\n\n\nclass Netflix(foauth.providers.OAuth1):\n # General info about the provider\n provider_url = 'https://www.netflix.com/'\n docs_url = 'http://developer.netflix.co...
python
chosen
[ { "from": "system", "value": "Add first iteration of LazyDatabaseMixin()\n" }, { "from": "human", "value": "import logbook\n\n\n# Let's name this DatabaseBase. 'tis a silly name.\nclass DatabaseBase(object):\n \"\"\"\n Abstract class representing a persistance layer\n\n \"\"\"\n\n de...
python
chosen
[ { "from": "system", "value": "Use a fast password hasher for tests.\n\nSpeed is obviously more important than security in tests.\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nAUTHENTICATION_BACKENDS = [\n \"django.contrib.auth.backends.ModelBackend\",\n \"se...
python
chosen
[ { "from": "system", "value": "Integrate integer test function into instantiation\n\nRef #23" }, { "from": "human", "value": "\"\"\"Creates the station class\"\"\"\n\n\n\n#import ask_user from ask_user\n#import int_check from int_check\n#import reasonable_check from reasonable_check\n\n\nclass St...
python
chosen
[ { "from": "system", "value": "Add missing rpnpy.range reference for Python 3.\n\nSigned-off-by: Stephane_Chamberland <1054841519c328088796c1f3c72c14f95c4efe35@science.gc.ca>\n" }, { "from": "human", "value": "import sys\nimport ctypes as _ct\n\nif sys.version_info < (3,):\n integer_types = (i...
python
chosen
[ { "from": "system", "value": "Use JSON for other than GET request\n\nBecause internal dict parameters is not handled as expected.\n\n >>> payload = {'key1': 'value1', 'key2': 'value2', 'set': {'a': 'x', 'b': 'y'}}\n >>> r = requests.post(\"http://httpbin.org/post\", data=payload)\n >>> r.json()\n ...
python
chosen
[ { "from": "system", "value": "Fix UnicodeDecodeError on the environments where the default encoding is ascii\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\nimport re\nimport six\n\nBASIC_LATIN_RE = re.compile(r'[\\u0021-\\u007E]')\nWHITESPACE...
python
chosen
[ { "from": "system", "value": "Rework get body text method\n" }, { "from": "human", "value": "def get_body(grab, encoding='cp1251', bom=False, skip_errors=True, fix_spec_chars=True):\n return grab.doc.convert_body_to_unicode(grab.doc.body, bom, encoding, skip_errors, fix_spec_chars)\n" }, ...
python
chosen
[ { "from": "system", "value": "Add name_en field due to 'not null' constraint on the Category table\n" }, { "from": "human", "value": "import os\n\nfrom app import create_app, db\nfrom app.models import User, Category\n\nfrom flask_script import Manager\nfrom flask_migrate import Migrate, Migrate...
python
chosen
[ { "from": "system", "value": "Add attribution to slugify function.\n" }, { "from": "human", "value": "from been.core import DirectorySource, source_registry\nfrom hashlib import sha1\nimport re\nimport unicodedata\nimport time\nimport markdown\n\ndef slugify(value):\n value = unicodedata.norm...
python
chosen
[ { "from": "system", "value": "Make the verbose name for weight entries more user friendly\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n# This file is part of Workout Manager.\n# \n# Workout Manager is free software: you can redistribute it and/or modify\n# it under the terms of ...
python
chosen
[ { "from": "system", "value": "Add some info about tweepy\n" }, { "from": "human", "value": "from streamsx.topology.topology import *\nimport streamsx.topology.context\nimport sys\nimport tweets\n\n#\n# Continually stream tweets that contain\n# the terms passed on the command line.\n#\n# python3 ...
python
chosen
[ { "from": "system", "value": "Make \"register\" return False when username is already taken\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# from twisted.words.xish import domish\nfrom twisted.words.protocols.jabber.xmpp_stringprep import nodeprep\n\nfrom base import *\nimport rando...
python
chosen
[ { "from": "system", "value": "Remove extraneous quote in asserter dockstring\n" }, { "from": "human", "value": "from pprint import pformat\n\n\ndef assert_calls_equal(expected, actual):\n \"\"\"\n Check whether the given mock object (or mock method) calls are equal and\n return a nicely...
python
chosen
[ { "from": "system", "value": "Increment patch version to 0.7.2\n" }, { "from": "human", "value": "\"\"\"yolk.\n\nAuthor: Rob Cakebread <cakebread at gmail>\n\nLicense : BSD\n\n\"\"\"\n\n__version__ = '0.7.1'\n" }, { "from": "gpt", "value": "\"\"\"yolk.\n\nAuthor: Rob Cakebread <cake...
python
chosen
[ { "from": "system", "value": "Add message_type as CharField in form\n" }, { "from": "human", "value": "import time\n\nfrom django import forms\nfrom .models import Message\nfrom .utils import timestamp_to_datetime, datetime_to_timestamp\n\n\n\nclass MessageForm(forms.Form):\n text = forms.Cha...
python
chosen
[ { "from": "system", "value": "Improve database model and apperance for admin site\n" }, { "from": "human", "value": "from django.db import models\n\n# Create your models here.\n" }, { "from": "gpt", "value": "from django.db import models\nfrom django.utils import timezone\nimport dat...
python
chosen
[ { "from": "system", "value": "fix: Add parentheses to the print statement to make it Python3 compatible\n" }, { "from": "human", "value": "#!flask/bin/python\nimport os\nimport sys\nif sys.platform == 'win32':\n pybabel = 'flask\\\\Scripts\\\\pybabel'\nelse:\n pybabel = 'flask/bin/pybabel'...
python
chosen
[ { "from": "system", "value": "Clean up BlinkyPlayer a little\n" }, { "from": "human", "value": "import time\n\nclass BlinkyPlayer(object):\n FOREVER = -1\n\n def __init__(self, blinkytape):\n self._blinkytape = blinkytape\n\n def play(self, animation, num_cycles = FOREVER):\n ...
python
chosen
[ { "from": "system", "value": "Make cloud check evaluate greater than or equals\n" }, { "from": "human", "value": "from pyowm.owm import OWM\nfrom datetime import datetime, timedelta\n\nclass WeatherManager:\n def __init__(self, key, lat, lon):\n owm = OWM(key)\n self.mgr = owm.w...
python
chosen
[ { "from": "system", "value": "Change to 3 spaces in front of toctree elements\n" }, { "from": "human", "value": "import shutil\nimport os\nimport re\n\nwork = os.getcwd()\nfound = []\nregex = re.compile(r'pydarkstar\\.(.*)\\.rst')\nfor root, dirs, files in os.walk(work):\n for f in files:\n ...
python
chosen
[ { "from": "system", "value": "Create variables for HTML start and end.\n" }, { "from": "human", "value": "import sublime, sublime_plugin\nimport os\nimport re\n\nfrom .mistune import markdown\n\n\nclass CreateMinuteCommand(sublime_plugin.TextCommand):\n\tdef run(self, edit):\n\t\tregion = sublim...
python
chosen
[ { "from": "system", "value": "Add context manager and destructor for cleanup\n\nWhen exiting the context or calling cleanup() explicitly,\nthe temporary file created after downloading is removed and\nany open files closed.\n" }, { "from": "human", "value": "import re\nimport urllib\nfrom os.path...
python
chosen
[ { "from": "system", "value": "Remove superfluous type annotation, it's done by the TypeGrokker now\n" }, { "from": "human", "value": "# Copyright (c) 2007-2011 gocept gmbh & co. kg\n# See also LICENSE.txt\n# $Id$\n\"\"\"Interface definitions for the test content type.\"\"\"\n\n\nimport zope.inte...
python
chosen
[ { "from": "system", "value": "Add reload to init for config\n" }, { "from": "human", "value": "###\n# Copyright (c) 2012, spline\n# All rights reserved.\n#\n#\n###\n\n\"\"\"\nAdd a description of the plugin (to be presented to the user inside the wizard)\nhere. This should describe *what* the p...
python
chosen
[ { "from": "system", "value": "Add null and blank to sidebars\n" }, { "from": "human", "value": "from django.db import models\n\nfrom .fields import ListTextField\n\n\nclass TwoModularColumnsMixin(models.Model):\n sidebar_left = ListTextField()\n sidebar_right = ListTextField()\n\n class...
python
chosen
[ { "from": "system", "value": "Add .py extension handling and more python keywords\n" }, { "from": "human", "value": "import vx\n\nimport os.path\n\ndef mode_from_filename(file):\n root, ext = os.path.splitext(file)\n ext = ext if ext else root\n\n mode = None\n if ext == '.c':\n ...
python
chosen
[ { "from": "system", "value": "Work the Tcl version number in the path we search for.\n" }, { "from": "human", "value": "import sys, os\nv = os.path.join(sys.prefix, \"tcl\", \"tcl8.3\")\nif os.path.exists(os.path.join(v, \"init.tcl\")):\n os.environ[\"TCL_LIBRARY\"] = v\n" }, { "from"...
python
chosen
[ { "from": "system", "value": "Set plugin version to \"master\" to show which Cura branch this plugin branch should work with\n" }, { "from": "human", "value": "# Copyright (c) 2015 Ultimaker B.V.\n# Cura is released under the terms of the AGPLv3 or higher.\nfrom . import OctoPrintOutputDevicePlu...
python
chosen
[ { "from": "system", "value": "Edit path and external evaluation\n" }, { "from": "human", "value": "from pygraphc.misc.IPLoM import *\nfrom pygraphc.evaluation.ExternalEvaluation import *\n\n# set input path\nip_address = '161.166.232.17'\nstandard_path = '/home/hudan/Git/labeled-authlog/dataset/...
python
chosen
[ { "from": "system", "value": "Add username to ID Token\n" }, { "from": "human", "value": "import inspect\n\nfrom .scopes import get_userinfo_by_scopes\n\n\ndef process_id_token(payload, user, scope=None):\n if scope is None:\n # HACK: Steal the scope argument from the locals dictionary...
python
chosen
[ { "from": "system", "value": "Remove installed app on init opps core\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom django.utils.translation import ugettext_lazy as _\nfrom django.conf import settings\n\n\n\ntrans_app_label = _('Opps')\nsettings.INSTALLED_APPS += ('opps.article...
python
chosen
[ { "from": "system", "value": "Remove sys import in versioneer file\n" }, { "from": "human", "value": "\n# This file was generated by 'versioneer.py' (0.15) from\n# revision-control system data, or from the parent directory name of an\n# unpacked source archive. Distribution tarballs contain a pr...
python
chosen
[ { "from": "system", "value": "Clarify meaning of --all option for packages command\n" }, { "from": "human", "value": "# Copyright 2017-2020 TensorHub, 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 License.\...
python
chosen
[ { "from": "system", "value": "Add correct properties for payment_in_default test group\n\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# Copyright (c) 2018 The Pycroft Authors. See the AUTHORS file.\n# This file is part of the Pycroft project and licensed under the terms of\n# the ...
python
chosen
[ { "from": "system", "value": "Add radii mean and standard deviation\n" }, { "from": "human", "value": "from __future__ import division\nimport numpy as np\nimport FreeCAD as FC\nimport Part\nimport Draft\nimport os\n\n\ndoc = FC.newDocument(\"ellipses\")\nfolder = os.path.dirname(__file__) + \"....
python
chosen
[ { "from": "system", "value": "joystick: Replace tabs by space in example\n\nSigned-off-by: Francois Berder <59eaf4bb0211c66c3d7532da6d77ecf42a779d82@outlook.fr>\n" }, { "from": "human", "value": "#!/usr/bin/env python3\n\"\"\"This example shows how to use the Joystick Click wrapper of the LetMeC...
python
chosen
[ { "from": "system", "value": "Implement displaying of the current key list\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport client_wrap\n\nKEY_LONG = \"key1\"\nDATA_LONG = 1024\n\nKEY_DOUBLE = \"key2\"\nDATA_DOUBLE = 100.53\n\nKEY_STRING = \"key3\"\nDATA_STRING = \"test data\"\...
python
chosen
[ { "from": "system", "value": "Include templates and static at the installing process too\n" }, { "from": "human", "value": "from setuptools import setup\n\n\nsetup(\n name='django-setmagic',\n version='0.2',\n author='Evandro Myller',\n author_email='emyller@7ws.co',\n description...
python
chosen
[ { "from": "system", "value": "Add pytest as a dependency\n" }, { "from": "human", "value": "import distutils.core\n\n# Uploading to PyPI\n# =================\n# $ python setup.py register -r pypi\n# $ python setup.py sdist upload -r pypi\n\nversion = '0.0'\ndistutils.core.setup(\n name='k...
python
chosen
[ { "from": "system", "value": "Revert \"Specify specific version of feedparser\"\n\nThis reverts commit e2a6bc54e404538f01a980f1573a507c224d1c31.\n" }, { "from": "human", "value": "#!/usr/bin/env python\nfrom distribute_setup import use_setuptools\nuse_setuptools()\n\nfrom setuptools import setup...
python
chosen
[ { "from": "system", "value": "github: Fix GitHub integration CSRF issue.\n\nThe new GitHub dispatcher integration was apparently totally broken,\nbecause we hadn't tagged the new dispatcher endpoint as exempt from\nCSRF checking. I'm not sure why the test suite didn't catch this.\n" }, { "from": "h...
python
chosen
[ { "from": "system", "value": "ir: Add machinery to detect Cluster properties\n" }, { "from": "human", "value": "from devito.ir.support import (SEQUENTIAL, PARALLEL, PARALLEL_IF_ATOMIC, VECTOR,\n TILABLE, WRAPPABLE)\n\n__all__ = ['analyze']\n\n\ndef analyze(clusters)...
python
chosen
[ { "from": "system", "value": "Put empty string in for quickPickFile if it doesn't exist.\n" }, { "from": "human", "value": "#Package startup stuff so people can start their iPython session with\n#\n#run PyQLab /path/to/cfgFile and be up and running\n\n\n#Package imports\nimport numpy as np\n\n#L...
python
chosen
[ { "from": "system", "value": "Add support for carriage returns\n" }, { "from": "human", "value": "import datetime\nimport math\n\nfrom flask import Markup\nfrom peewee import Model, TextField, DateTimeField\n\nfrom app import db\n\n\nclass Quote(Model):\n content = TextField()\n timestamp ...
python
chosen
[ { "from": "system", "value": "Add unit tests for fail fast logic in convertCharToInt()\n" }, { "from": "human", "value": "import unittest\nfrom src import coordinate\n\nclass TestRules(unittest.TestCase):\n \"\"\" Tests for the coordinate module \"\"\"\n\n def test_get_x_board(self):\n ...
python
chosen
[ { "from": "system", "value": "Switch static_reply tests to new helpers.\n" }, { "from": "human", "value": "from twisted.internet.defer import inlineCallbacks\n\nfrom vumi.application.tests.utils import ApplicationTestCase\nfrom vumi.demos.static_reply import StaticReplyApplication\n\n\nclass Tes...
python
chosen
[ { "from": "system", "value": "Add pathts for apache deployment\n" }, { "from": "human", "value": "\"\"\"\nWSGI config for core project.\n\nIt exposes the WSGI callable as a module-level variable named ``application``.\n\nFor more information on this file, see\nhttps://docs.djangoproject.com/en/1...
python
chosen
[ { "from": "system", "value": "Use pyside instead of pyqt4\n" }, { "from": "human", "value": "__author__ = \"Richard Lindsley\"\n\nimport sys\n\nimport sip\nsip.setapi('QDate', 2)\nsip.setapi('QDateTime', 2)\nsip.setapi('QString', 2)\nsip.setapi('QTextStream', 2)\nsip.setapi('QTime', 2)\nsip.seta...
python
chosen
[ { "from": "system", "value": "Correct the VPR URL in setting\n" }, { "from": "human", "value": "'''\nCreated on 16 Dec 2013\n\n@author: huyvq\n'''\nfrom base import *\n\n# FOR DEBUG\nDEBUG = True\nDEVELOPMENT = True\nTEMPLATE_DEBUG = DEBUG\n\n# Database\n# https://docs.djangoproject.com/en/1.6/r...
python
chosen
[ { "from": "system", "value": "Create form on index view\n\n- Need to always pass a form to the view\n - make sure to create on for the `GET` view\n- Fixes #33\n" }, { "from": "human", "value": "from flask import request, render_template\n\nfrom ca import app, db\nfrom ca.forms import RequestFor...
python
chosen
[ { "from": "system", "value": "Remove unused time control support (better in Game)\n" }, { "from": "human", "value": "\n# This is just be a base class / interface to be filled out by \n# human and AI players.\n\n# TODO: Undo support?\n# TODO: Resign?\n\n# super requires inheriting from object, wh...
python
chosen
[ { "from": "system", "value": "Add letsencrypt auto renew api :octocat:\n" }, { "from": "human", "value": "\"\"\"\nThis is a simple cheatsheet webapp.\n\"\"\"\nimport os\n\nfrom flask import Flask, send_from_directory\nfrom flask_sslify import SSLify\n\nDIR = os.path.dirname(os.path.realpath(__fi...
python
chosen
[ { "from": "system", "value": "Create a catch-all route and route to the homepage.\n\nSigned-off-by: Robert Dempsey <715b5a941e732be1613fdd9d94dfd8e50c02b187@gmail.com>\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom flask import Flask\nfrom flask.ext.mongoengine import MongoEngi...
python
chosen
[ { "from": "system", "value": "Fix a bug in OutputFileQueue.close().\n\ntilequeue/queue/file.py\n\t-01a8fcb made `OutputFileQueue.read()` use `readline()` instead\n\tof `next()`, but didn't update `OutputFileQueue.close()`, which\n\tuses a list comprehension to grab the rest of the file. Since\n\t`.read()` n...
python
chosen
[ { "from": "system", "value": "Set the host to use all IPs when runap is used\n" }, { "from": "human", "value": "# Copyright 2014 Dave Kludt\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtai...
python
chosen
[ { "from": "system", "value": "Update due to logical line changes\n" }, { "from": "human", "value": "if True:\n if True:\n if True:\n self.__heap.sort(\n ) # pylint: builtin sort probably faster than O(n)-time heapify\n\n if True:\n foo =...
python
chosen
[ { "from": "system", "value": "Support for python 2 and 3" }, { "from": "human", "value": "from delayed_assert.delayed_assert import expect, assert_expectations" }, { "from": "gpt", "value": "import sys\n\nif sys.version_info > (3, 0): # Python 3 and above\n from delayed_assert.de...
python
chosen
[ { "from": "system", "value": "TST: Print out all dependency versions at the start of pytest\n" }, { "from": "human", "value": "# Copyright (c) 2016,2019 MetPy Developers.\n# Distributed under the terms of the BSD 3-Clause License.\n# SPDX-License-Identifier: BSD-3-Clause\n\"\"\"Configure pytest ...
python
chosen
[ { "from": "system", "value": "Fix tests, broken by making slowfs a script\n\nIn the tests we must run the script using python so we run with the\ncorrect python from .tox/<env>/bin/python.\n" }, { "from": "human", "value": "import logging\nimport os\nimport signal\nimport subprocess\nimport time...
python
chosen
[ { "from": "system", "value": "Use DiscoverRunner from Django 1.6 if available\n" }, { "from": "human", "value": "\"\"\"\nHook into the test runner\n\"\"\"\n\nimport subprocess\n\nfrom django.test.simple import DjangoTestSuiteRunner\nfrom django.utils import unittest\n\nfrom ixdjango.test_suite.u...
python
chosen
[ { "from": "system", "value": "Use correct path for frame template\n" }, { "from": "human", "value": "from django.http import HttpResponseRedirect, HttpResponse, Http404\nfrom django.shortcuts import render_to_response\nfrom django.template import RequestContext\nfrom django.views.generic import ...
python
chosen
[ { "from": "system", "value": "Use pytest_(un)configure to setup cache_directory\n" }, { "from": "human", "value": "collect_ignore = [\"setup.py\"]\n" }, { "from": "gpt", "value": "import tempfile\nimport shutil\n\nimport jedi\n\n\ncollect_ignore = [\"setup.py\"]\n\n\n# The following ...
python
chosen
[ { "from": "system", "value": "Fix small incompatibility with Python 3.2\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nfrom ast import *\n\nfrom .version_info import PY2\n\nif PY2:\n Try = TryExcept\n\n def argument_names(node):\n return [isinstance(arg...
python
chosen
[ { "from": "system", "value": "Use preserved games for opening move selection\n" }, { "from": "human", "value": "import random\nimport pdb\n\nfrom defines import *\n\nclass OpeningsMover(object):\n def __init__(self, o_mgr, game):\n self.o_mgr = o_mgr\n self.game = game\n\n de...
python
chosen
[ { "from": "system", "value": "Allow empty conversations to be serialized\n\nA conversation may exist without any content. The serializer then\nreturns an empty message value.\n" }, { "from": "human", "value": "def user(model):\n if not model.is_authenticated():\n return {}\n\n retur...
python
chosen
[ { "from": "system", "value": "Support passing html attributes into MenuItem\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nfrom six import text_type\n\nfrom django.utils.text import slugify\nfrom django.utils.html import format_html\n\n\nclass MenuItem(object):\n ...
python
chosen
[ { "from": "system", "value": "Add logout and auth checks\n" }, { "from": "human", "value": "from flask import Blueprint, render_template\nfrom flask_login import login_required\n\nmain = Blueprint(\"main\", __name__)\n\n\n@main.route(\"/\")\n@main.route(\"/index\")\n@login_required\ndef index():...
python
chosen
[ { "from": "system", "value": "Use stdin for assembler input\n" }, { "from": "human", "value": "#! /usr/bin/env python\n\nimport sys\nimport assembler6502_tokenizer as tokenizer\nimport assembler6502_parser as parser\n\ndef output_byte(hexcode):\n sys.stdout.write(hexcode)\n #sys.stdout.wri...
python
chosen
[ { "from": "system", "value": "Fix for python2.6: decode doesn't take keyword arguments.\n" }, { "from": "human", "value": "import os\nimport shlex\nimport sys\n\nfrom canaryd_packages import six\n# Not ideal but using the vendored in (to requests) chardet package\nfrom canaryd_packages.requests....
python
chosen
[ { "from": "system", "value": "Add apikey when creating a user\n" }, { "from": "human", "value": "# -*- coding: utf8 -*-\nfrom flask.ext.security import UserMixin, RoleMixin\nfrom ..models import db\n\nroles_users = db.Table('roles_users',\n db.Column('user_id', db.Integer(), db.ForeignKey...
python
chosen
[ { "from": "system", "value": "Fix GraphConvTensorGraph to GraphConvModel in hopv example\n" }, { "from": "human", "value": "\"\"\"\nScript that trains graph-conv models on HOPV dataset.\n\"\"\"\nfrom __future__ import print_function\nfrom __future__ import division\nfrom __future__ import unicod...
python
chosen
[ { "from": "system", "value": "Add url mapping to register.\n" }, { "from": "human", "value": "from django.conf.urls.defaults import *\nfrom django.contrib.auth.views import logout_then_login, login\nfrom django.contrib.auth.forms import AuthenticationForm\n\nurlpatterns = patterns('',\n (r'^l...
python
chosen
[ { "from": "system", "value": "Fix get_current_context typo in docstring\n" }, { "from": "human", "value": "from threading import local\n\n\n_local = local()\n\n\ndef get_current_context(silent=False):\n \"\"\"Returns the current click context. This can be used as a way to\n access the cur...
python
chosen
[ { "from": "system", "value": "Add check to print_layer_shapes to fail explicitely on model used connected to other models." }, { "from": "human", "value": "from __future__ import print_function\nimport numpy as np\nimport theano\n\n\ndef print_layer_shapes(model, input_shape):\n \"\"\"\n U...
python
chosen
[ { "from": "system", "value": "Add imports imports to trigger cx_Freeze hooks\n" }, { "from": "human", "value": "import logging\n\nlogging.basicConfig(level=logging.WARNING)\n" }, { "from": "gpt", "value": "import logging\n\n# These are required to activate the cx_Freeze hooks\nimport...
python
chosen
[ { "from": "system", "value": "Make sure things are loaded right.\n" }, { "from": "human", "value": "if __name__ == \"__main__\":\n import pycket.test.testhelper as th\n th.dumb_repl()\n\n" }, { "from": "gpt", "value": "if __name__ == \"__main__\":\n import pycket.values\n ...
python
chosen
[ { "from": "system", "value": "Make the remote push script take in the interval as an argument\n\nWe will use the interval as the channel\n" }, { "from": "human", "value": "import json,httplib\n\nconfig_data = json.load(open('conf/net/ext_service/parse.json'))\n\nsilent_push_msg = {\n \"where\"...
python
chosen
[ { "from": "system", "value": "Change status codes and messages\n" }, { "from": "human", "value": "import os\nfrom werkzeug.utils import secure_filename\nimport config\nfrom flask_restful import Resource\nfrom flask import request, abort\n\n\ndef allowed_file(filename):\n return ('.' in filena...
python
chosen
[ { "from": "system", "value": "Add total retweets to the serializer\n" }, { "from": "human", "value": "from rest_framework import serializers\n\nfrom shmitter.likes import services as likes_services\nfrom .models import Tweet\nfrom . import services as tweets_services\n\n\nclass TweetSerializer(s...
python
chosen
[ { "from": "system", "value": "[core] Fix import error for Python3\n\nImport exceptions module only for Python2.\n\nfixes #22\n" }, { "from": "human", "value": "import shlex\nimport exceptions\nimport subprocess\n\ndef bytefmt(num):\n for unit in [ \"\", \"Ki\", \"Mi\", \"Gi\" ]:\n if n...
python
chosen
[ { "from": "system", "value": "Remove control characters from printed string to prevent terminal breakage\n" }, { "from": "human", "value": "import string\nimport textwrap\nimport binascii\nfrom veryprettytable import VeryPrettyTable\nfrom plugins import BasePlugin\n\n__author__ = 'peter'\n\n\ncl...
python
chosen