conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Use correct property for falcon 2.0.\n" }, { "from": "human", "value": "from string import Template\n\ndoc_template = Template(open(\"api/views/index.html\", \"r\").read())\n\nclass DocsResource(object):\n def on_get(self, request, response):\n response.se...
python
chosen
[ { "from": "system", "value": "Set up creating files for unused items\n" }, { "from": "human", "value": "\"\"\"\nIncludes execution logic for the commands\n\"\"\"\n\nimport os\nimport csv\nimport random\n\ndef run_create(count):\n\tfile_list = [filename for filename in os.listdir('.') if os.path....
python
chosen
[ { "from": "system", "value": "Use refresh only if required in parameters (?refresh=something)\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nfrom contextlib import closing\nfrom sqlite3 import connect\nfrom bottle import template, route, run\n\n@route('/virustotal/<db>')\ndef virus(...
python
chosen
[ { "from": "system", "value": "Add additional HTML tags to reST filter\n" }, { "from": "human", "value": "\"\"\"Template filters for use across apps.\"\"\"\n\nimport bleach\nfrom docutils import core\n\n__all__ = 'rst_to_html'\n\n_ALLOWED_TAGS = bleach.ALLOWED_TAGS + ['h1', 'h2', 'h3', 'h4', 'h5'...
python
chosen
[ { "from": "system", "value": "Allow plot_mask to take nibabel image\n" }, { "from": "human", "value": "import os.path as op\nimport numpy as np\nimport nibabel as nib\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\ndef plot_mask_distribution(fname, ax=None, hist=False):\n \"\"\"Plo...
python
chosen
[ { "from": "system", "value": "Set propper link attribute 'sizes' in templatetag\n\nThere seems to be a typo in the templatetag generator on lines 26 and 30.\r\n\r\nThe attribute 'sizes=' written as 'size ='. This break w3c tests as that attribute is not available in the link tag." }, { "from": "huma...
python
chosen
[ { "from": "system", "value": "Remove duplicated slash in virus_scan" }, { "from": "human", "value": "from django.contrib.sites.shortcuts import get_current_site\nfrom django.urls import reverse\nfrom django.core.signing import TimestampSigner\n\n\nclass BaseEngine:\n def __init__(self):\n ...
python
chosen
[ { "from": "system", "value": "Update mtgox api endpoint to use SSL\n" }, { "from": "human", "value": "\"\"\"Bitccoin ticker module for ppbot.\n@package ppbot\n\nDisplays the current bitcoin pricing from mtgox\n\n@syntax btc\n\n\"\"\"\nimport requests\nimport string\nimport json\nfrom xml.dom.min...
python
chosen
[ { "from": "system", "value": "Make new URL tag forward compatible\n" }, { "from": "human", "value": "from django.conf.urls.defaults import RegexURLPattern\n\ndef url(pattern, name=None, extra={}):\n \n def url_annotator(view):\n view.pattern = RegexURLPattern(pattern, view, extra, n...
python
chosen
[ { "from": "system", "value": "Add [--] to usage statement\n\nSigned-off-by: Zack Cerza <f801c831581d4150a2793939287636221d62131e@inktank.com>\n" }, { "from": "human", "value": "import docopt\n\nimport teuthology.misc\nimport teuthology.schedule\n\ndoc = \"\"\"\nusage: teuthology-schedule -h\n ...
python
chosen
[ { "from": "system", "value": "Add filter for users on watchlist\n" }, { "from": "human", "value": "from django.contrib import admin\nfrom .models import Card, FaqQuestion, Banner, Rule\n\nadmin.site.register(Card)\nadmin.site.register(FaqQuestion)\nadmin.site.register(Rule)\nadmin.site.register(...
python
chosen
[ { "from": "system", "value": "Add a argument and fix a error.\n" }, { "from": "human", "value": "# coding: utf-8\nimport oslo_i18n\n\n\ndef reset_i18n(domain=\"app\", localedir=None):\n global _translators, _, _C, _P, _LI, _LW, _LE, _LC\n\n # Enable lazy translation\n oslo_i18n.enable_l...
python
chosen
[ { "from": "system", "value": "Fix how we check for Windows in platform_libname.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nimport ctypes\nimport ctypes.util\nimport os\nimport sys\n\n\ndef find_libc():\n if sys.platform == 'win32':\n return ctypes.util.find_msvcrt()\...
python
chosen
[ { "from": "system", "value": "Move type initialization to its own method\n" }, { "from": "human", "value": "from abc import ABCMeta, abstractmethod\n\n\nclass DriverBase(metaclass=ABCMeta):\n\n def __init__(self, obj):\n self.obj = obj\n\n def __repr__(self):\n return '{}(typ...
python
chosen
[ { "from": "system", "value": "Fix bug where dirty_ndb was silently failing.\n" }, { "from": "human", "value": "\"\"\"\nJust some useful Flask stuff for ndb.\n\"\"\"\nfrom google.appengine.ext import ndb\nfrom flask import g\n\nfrom app import app\n\n\ndef put_later(*objs):\n \"\"\"\n Any n...
python
chosen
[ { "from": "system", "value": "Add documentaiton decorator for Enterprise.\n" }, { "from": "human", "value": "def passive(cls):\n\tpassive_note = '''\n\n\t.. note:: This object is a \"passive\" object. Any changes you make to it will not be reflected in the core and vice-versa. If you wish to upd...
python
chosen
[ { "from": "system", "value": "Add a Currency.is_base field (currently unused)\n" }, { "from": "human", "value": "from django.db import models\nfrom django.utils.translation import gettext_lazy as _\n\n\nclass Currency(models.Model):\n code = models.CharField(_('code'), max_length=3)\n name...
python
chosen
[ { "from": "system", "value": "Change default colormap in ezplot\n\nFrom 'jet' to 'viridis'\n" }, { "from": "human", "value": "\"\"\"\nMisc. functions not quantum related.\n\"\"\"\n\nimport matplotlib.pyplot as plt\nfrom matplotlib import cm\nfrom numpy import (atleast_2d, squeeze, array, shape, ...
python
chosen
[ { "from": "system", "value": "Add renaming file to correct file name" }, { "from": "human", "value": "#!/usr/bin/env python\n__author__ = 'Jacob Bieker'\nimport os\nDATA_DIRECTORY = os.path.join(\"test_file\")\nDATA = os.listdir(DATA_DIRECTORY)\nfile_name_dict = {}\n\nfor file_name in DATA:\n ...
python
chosen
[ { "from": "system", "value": "Replace abc.abstractproperty with property and abc.abstractmethod\n\nReplace abc.abstractproperty with property and abc.abstractmethod,\nas abc.abstractproperty has been deprecated since python3.3[1]\n\n[1]https://docs.python.org/3.8/whatsnew/3.3.html?highlight=deprecated#abc\n...
python
chosen
[ { "from": "system", "value": "Add migration for new fields in Venue\n" }, { "from": "human", "value": "from django.db import models\n\nclass Facility(models.Model):\n name = models.CharField(max_length=30)\n\n def __unicode__(self):\n return self.name\n\nclass Address(models.Model):...
python
chosen
[ { "from": "system", "value": "Use less stupid debug log format\n" }, { "from": "human", "value": "from flask import Flask\n\n\napp = Flask(__name__)\n\n\nimport makerbase.tags\nimport makerbase.views\n" }, { "from": "gpt", "value": "from flask import Flask\n\n\napp = Flask(__name__)\...
python
chosen
[ { "from": "system", "value": "Remove accidentally duplicated test code.\n" }, { "from": "human", "value": "import unittest\n\nfrom ..Utils import build_hex_version\n\nclass TestCythonUtils(unittest.TestCase):\n def test_build_hex_version(self):\n self.assertEqual('0x001D00A1', build_he...
python
chosen
[ { "from": "system", "value": "Set logging level to WARNING for incoming release\n" }, { "from": "human", "value": "import json\nimport logging\nimport re\nimport requests\n\n__all__ = ['config', 'session', 'submit', 'SubmitInfo', 'username']\n\nlogging.basicConfig(format='%(asctime)s %(levelname...
python
chosen
[ { "from": "system", "value": "Create TaggedImage, unique marker for image\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport uuid\nimport os\nfrom datetime import datetime\n\nfrom django.db import models\nfrom django.utils.translation import ugettext_lazy as _\nfrom django.utils ...
python
chosen
[ { "from": "system", "value": "Abort when user is not authenticated or not an admin\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom functools import wraps\nfrom flask import abort\n\n\ndef admin_required(f):\n @wraps(f)\n def decorated_function(*args, **kwargs):\n ...
python
chosen
[ { "from": "system", "value": "Set with add, update, discard, remove, union, intersection, difference\n" }, { "from": "human", "value": "# Set\n#Removes the duplicates from the given group of values to create the set.\nflight_set = {500,520,600,345,520,634,600,500,200,200}\nprint(\"Flight Set : \...
python
chosen
[ { "from": "system", "value": "Allow apps to be specified from the command line\n" }, { "from": "human", "value": "import os\n\nos.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'\n\nfrom django.core import management\n\napps = [\n 'test',\n 'core',\n 'exporting',\n 'formatters',\...
python
chosen
[ { "from": "system", "value": "Check if the result from Bugzilla has an error when trying to get a token\n" }, { "from": "human", "value": "import requests\nfrom bug import Bug\n\nclass BugsyException(Exception):\n \"\"\"If trying to do something to a Bug this will be thrown\"\"\"\n def __i...
python
chosen
[ { "from": "system", "value": "Fix old variable STACK_START name (not used anymore)\n" }, { "from": "human", "value": "# State identifiers (begin and end).\n\nNO_STATE = -1\n\nBIND_START = 0\nBIND_END = BIND_START + 1\n\nINTER_SSH_START = 10\nINTER_SSH_END = INTER_SSH_START + 1\n\nGIT_SETUP_START...
python
chosen
[ { "from": "system", "value": "Fix import into refmanage namespace\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"\n===============================\nBase Library (:mod:`refmanage`)\n===============================\n\n.. currentmodule:: refmanage\n\"\"\"\n\nfrom version import _...
python
chosen
[ { "from": "system", "value": "Add by_slug view for single events.\n" }, { "from": "human", "value": "from been.couch import CouchStore\nfrom flask import render_template\nfrom wake import app\n\nstore = CouchStore().load()\n\n@app.route('/')\ndef wake():\n return render_template('stream.html'...
python
chosen
[ { "from": "system", "value": "Test coverage for SQLAlchemyError handling in status view\n" }, { "from": "human", "value": "from tests.bases import BaseApplicationTest\n\n\nclass TestStatus(BaseApplicationTest):\n\n def test_should_return_200_from_elb_status_check(self):\n status_respon...
python
chosen
[ { "from": "system", "value": "Update unittest to be complient with a newer version of pytest\n" }, { "from": "human", "value": "import os\nimport sys\nimport tempfile\n\nCURRENT_DIR = os.path.dirname(os.path.abspath(__file__))\nSCRIPTS_DIR = os.path.join(CURRENT_DIR, '..', 'scripts')\nsys.path.a...
python
chosen
[ { "from": "system", "value": "Allow a pool size of 100\n" }, { "from": "human", "value": "\"\"\"Create a connection to the database.\"\"\"\n\nfrom sqlalchemy import create_engine\nfrom sqlalchemy.orm import sessionmaker, scoped_session\nfrom sqlalchemy.ext.declarative import declarative_base\nim...
python
chosen
[ { "from": "system", "value": "Fix docstring, return the settlement\n" }, { "from": "human", "value": "from .base import Base\n\n\nclass Capture(Base):\n @classmethod\n def get_resource_class(cls, client):\n from ..resources.captures import Captures\n return Captures(client)\n...
python
chosen
[ { "from": "system", "value": "Send broken link emails out; send them from mr_website\n" }, { "from": "human", "value": "from settings import *\n\nOHLOH_API_KEY='SXvLaGPJFaKXQC0VOocAg'\nDEBUG=False\nADMINS=[\n ('All OH devs', 'devel@lists.openhatch.org'),\n]\n\nINVITE_MODE=True # Enabled on pr...
python
chosen
[ { "from": "system", "value": "Remove images URL cleaning because will be done later during parsing\n" }, { "from": "human", "value": "\"\"\"(c) All rights reserved. ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE, Switzerland, VPSI, 2018\"\"\"\n\n\nfrom bs4 import BeautifulSoup\nimport re\n\n\nclass Ba...
python
chosen
[ { "from": "system", "value": "Add request argument for RequestContext\n\nSee: cb2055bbcb345e367b6bdfe177a407546286695c@097353695e3178a38403b204ae4889c8a32bf997\n" }, { "from": "human", "value": "#This file is part of Tryton & Nereid. The COPYRIGHT file at the top level of\n#this repository conta...
python
chosen
[ { "from": "system", "value": "Create the Account List > List Accounts - Create View\n" }, { "from": "human", "value": "from django.shortcuts import render\n\n# Create your views here.\n" }, { "from": "gpt", "value": "from django.views.generic import ListView\nfrom django.contrib.auth...
python
chosen
[ { "from": "system", "value": "Return jsonapi error when parsing filters failed.\n\nChange-Id: I4bd26823d9e29b31ab8fdc47b8ef2bb65071d27b\nReviewed-on: https://review.socialwifi.com/14069\nReviewed-by: Piotr Maliński <5f24252672783b9dd319151f284628d8f524ff27@socialwifi.com>\nTested-by: Jakub Skiepko <27b91008...
python
chosen
[ { "from": "system", "value": "Change version number to reflect most recent changes\n" }, { "from": "human", "value": "# Copyright (C) 2011 Smarkets Limited <support@smarkets.com>\n#\n# This module is released under the MIT License:\n# http://www.opensource.org/licenses/mit-license.php\n\n__versi...
python
chosen
[ { "from": "system", "value": "Add filtering and ordering to PostListView\n" }, { "from": "human", "value": "from django.core.urlresolvers import reverse\nfrom django.views.generic.detail import DetailView\nfrom django.views.generic.list import ListView\nfrom django.views.generic.edit import Crea...
python
chosen
[ { "from": "system", "value": "Update email subject with datetime so as to not have it end up in a thread in email client.\n" }, { "from": "human", "value": "import smtplib\nfrom email.mime.text import MIMEText\n\n\ndef process_email(data):\n table_template = open('table_template.html', 'r').r...
python
chosen
[ { "from": "system", "value": "Update to use relative imports." }, { "from": "human", "value": "\"\"\"\nData models for the core Sana data engine. These should be extended as \nrequired. \n\n:Authors: Sana dev team\n:Version: 2.0\n\"\"\"\n\nfrom sana.core.models.concept import Concept, Relationsh...
python
chosen
[ { "from": "system", "value": "Add tests for API login\n" }, { "from": "human", "value": "import json\nimport mock\n\nfrom rest_framework import status\n\nfrom bluebottle.test.utils import BluebottleTestCase\nfrom bluebottle.test.factory_models.accounts import BlueBottleUserFactory\nfrom django.c...
python
chosen
[ { "from": "system", "value": "Fix media-combining in formsets on Django 2.2\n" }, { "from": "human", "value": "\"\"\"\nInternal utils\n\"\"\"\nimport django\n\n\ndef add_media(dest, media):\n \"\"\"\n Optimized version of django.forms.Media.__add__() that doesn't create new objects.\n\n ...
python
chosen
[ { "from": "system", "value": "Return command output log in `create_sandbox_instance()`\n" }, { "from": "human", "value": "# -*- encoding: utf-8 -*-\n#\n# Copyright (c) 2015, OpenCraft\n#\n\n# Imports #####################################################################\n\nfrom pprint import ppri...
python
chosen
[ { "from": "system", "value": "Replace formlayout GUI with tkinter\n\nSeparate buttons for selecting input and output, and for running\nthe interleave procedure.\n" }, { "from": "human", "value": "import PyPDF2\nfrom formlayout import fedit\n\ndef main():\n\tpaths = [('Input', ''), ('Output', '')...
python
chosen
[ { "from": "system", "value": "Set release version to v0.2.3\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# -----------------------------------------------------------------------------\n# Copyright (c) Spyder Project Contributors\n#\n# Licensed under the terms of the MIT License\n...
python
chosen
[ { "from": "system", "value": "Replace subcategory__ prefix to endpoint response field names.\n" }, { "from": "human", "value": "from .models import Star\nfrom employees.models import Employee\nfrom rest_framework import serializers\n\n\nclass EmployeeSimpleSerializer(serializers.ModelSerializer)...
python
chosen
[ { "from": "system", "value": "Remove LiveWindow call from CommandBasedRobot\n\nLiveWindow is automatically updated regardless of mode as part of 2018\nWPILib IterativeRobot changes, so calling LiveWindow.run() manually is\nunnecessary.\n" }, { "from": "human", "value": "import hal\n\nfrom wpilib...
python
chosen
[ { "from": "system", "value": "Add more constraints to active feedback schemas\n" }, { "from": "human", "value": "from django.conf import settings\n\nfrom apps.feedback.models import FeedbackRelation\n\ndef context_settings(request):\n context_extras = {}\n if hasattr(settings, 'GOOGLE_ANAL...
python
chosen
[ { "from": "system", "value": "Mark as 1.6.6 beta 1\n" }, { "from": "human", "value": "version = '1.6.6'\nrevision = ' development'\nmilestone = 'Yoitsu'\nrelease_number = '87'\nprojectURL = 'https://syncplay.pl/'\n" }, { "from": "gpt", "value": "version = '1.6.6'\nrevision = ' beta 1...
python
chosen
[ { "from": "system", "value": "Add simple test for celery time to start timer\n" }, { "from": "human", "value": "from __future__ import absolute_import\nfrom __future__ import print_function\n\nimport datetime\n\nfrom freezegun import freeze_time\n\nfrom corehq.celery_monitoring.heartbeat import ...
python
chosen
[ { "from": "system", "value": "Remove extra parameters to \"attack()\"\n\nThe `results` and `errors` structures aren't needed as input parameters.\r\nAll we need to ensure is that these are returned by `attack()`." }, { "from": "human", "value": "# This file should serve as a template\n# We will ...
python
chosen
[ { "from": "system", "value": "Allow reply_to to not be set in messages to the MPD frontend\n" }, { "from": "human", "value": "import logging\n\nfrom mopidy.frontends.base import BaseFrontend\nfrom mopidy.frontends.mpd.dispatcher import MpdDispatcher\nfrom mopidy.frontends.mpd.thread import MpdTh...
python
chosen
[ { "from": "system", "value": "Add low and high to docstring and __repr__\n" }, { "from": "human", "value": "from __future__ import division\nfrom __future__ import unicode_literals\nfrom __future__ import print_function\nfrom __future__ import absolute_import\nfrom builtins import * # NOQA\nfro...
python
chosen
[ { "from": "system", "value": "Configure the command that's executed.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom flask import Flask, render_template\nfrom sh import git\n\napp = Flask(__name__)\n\nversion = git(\"rev-parse\", \"--short\", \"HEAD\").s...
python
chosen
[ { "from": "system", "value": "Change imports to work with new scheme\n" }, { "from": "human", "value": "import hive\nimport threading\nimport time\nimport sys\nimport worker\n\n# import pash from another directory\nimport pash\n\nclass ErrWorker(worker.Worker):\n\tdef work(self, command):\n\t\tp...
python
chosen
[ { "from": "system", "value": "Use imp.find_module in test for spyder-line-profiler\n" }, { "from": "human", "value": "from xvfbwrapper import Xvfb\n\nvdisplay = Xvfb()\nvdisplay.start()\nimport spyder_line_profiler\nvdisplay.stop()\n" }, { "from": "gpt", "value": "\"\"\"\nTest whethe...
python
chosen
[ { "from": "system", "value": "Use assertRaisesRegex instead of assertRaisesRegexp for Python 3.11 compatibility.\n" }, { "from": "human", "value": "import os, sys, shutil\nimport tempfile\nimport unittest\nimport netCDF4\n\n\nclass test_filepath(unittest.TestCase):\n\n def setUp(self):\n ...
python
chosen
[ { "from": "system", "value": "[NG] Fix broken import in model tests.\n" }, { "from": "human", "value": "import pytest\nfrom suddendev.models import GameController\n\n\ndef test_create_game(session):\n pass\n" }, { "from": "gpt", "value": "import pytest\nfrom suddendev.models impor...
python
chosen
[ { "from": "system", "value": "Add note about why lldbRecorder is used, and a FIXME to use kernel hooks in the future\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\n# record.py - List a calling context tree.\n\nimport argparse\nfrom cct import CCT\nimport json\nfrom lldbRecorder impo...
python
chosen
[ { "from": "system", "value": "Change local web server's URL\n" }, { "from": "human", "value": "from os.path import join, dirname\nfrom dotenv import load_dotenv, find_dotenv\n\ndotenv_path = join(dirname(__file__), '.env')\nload_dotenv(find_dotenv())\n\nclient = dict(id = '8dfcc6ca-304f-4351-a2c...
python
chosen
[ { "from": "system", "value": "Fix unicode error in new test\n" }, { "from": "human", "value": "'''Test Span.as_doc() doesn't segfault'''\nfrom ...tokens import Doc \nfrom ...vocab import Vocab\nfrom ... import load as load_spacy\n\n\ndef test_issue1537():\n string = 'The sky is blue . The man...
python
chosen
[ { "from": "system", "value": "Add skip attribute for CayleyClient send test.\n" }, { "from": "human", "value": "from unittest import TestCase\nfrom pyley import CayleyClient, GraphObject\n\n\nclass CayleyClientTests(TestCase):\n def test_send(self):\n client = CayleyClient()\n g...
python
chosen
[ { "from": "system", "value": "Write stimuli schedule to csv file.\n" }, { "from": "human", "value": "#!/usr/bin/python\n\nimport csv\nimport pprint\n\np = 0\n\n# read schedule (from SCRT)\nschedule_f = 'schedule_' + str(p)\ninf = open(schedule_f,'r')\nfor line in inf.readlines():\n line = lin...
python
chosen
[ { "from": "system", "value": "Patch binfile name only when needed in open_archive\n" }, { "from": "human", "value": "# coding: utf-8\nfrom __future__ import absolute_import\nfrom __future__ import unicode_literals\n\nimport contextlib\n\nfrom pkg_resources import iter_entry_points\nfrom ..opener...
python
chosen
[ { "from": "system", "value": "Utils: Refactor get_console_size to close file after reading\n" }, { "from": "human", "value": "import os\n\n\ndef get_console_size():\n '''\n returns no of rows, no of cols\n '''\n return map(int, os.popen('stty size', 'r').read().split())\n\n\ndef get_...
python
chosen
[ { "from": "system", "value": "Change serializer to omit dates\n" }, { "from": "human", "value": "from rest_framework import serializers\n\nfrom .models import AuthenticationSession\n\n\nclass AuthenticationSessionSerializer(serializers.ModelSerializer):\n class Meta:\n model = Authenti...
python
chosen
[ { "from": "system", "value": "Add get_json method to provide json output\n" }, { "from": "human", "value": "# !/usr/bin/env python\n# coding: utf-8\n\n\"\"\"\nConverts a list or a list with a given regex grammar which contains a tree structure into a valid JSON.\n\nThis module works with both Py...
python
chosen
[ { "from": "system", "value": "Fix the blog content form\n\nThe form plays a trick on the 'text' field: it hides it, and creates a\nnicer-looking 'content' field. When submitting the form, the content of\nthe 'content' field is injected into the 'text' field.\n\nThis works great, until Django 1.10.\n\nWith D...
python
chosen
[ { "from": "system", "value": "Add alternate function to create or update database item\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom .common import session_scope\n\n\ndef commit_db_item(db_item, add=False):\n with session_scope() as session:\n ...
python
chosen
[ { "from": "system", "value": "Return dict with selected utxo list and total" }, { "from": "human", "value": "\n'''Communicate with local or remote peercoin-daemon via JSON-RPC'''\n\nfrom operator import itemgetter\n\ntry:\n from peercoin_rpc import Client\nexcept:\n raise EnvironmentError(...
python
chosen
[ { "from": "system", "value": "Change juliet_module to load before other modules for dependency reasons\n" }, { "from": "human", "value": "import os\nimport imp\n\nmodules = {}\n\ndef load_modules(path=\"./modules/\"): # Consider adding recursive sorting at some point in the future\n names = o...
python
chosen
[ { "from": "system", "value": "Support for splitting outputs for PyTables and Postgres indexing\nbenchmarks all in one.\n\n\n\ngit-svn-id: 92c705c98a17f0f7623a131b3c42ed50fcde59b4@2885 1b98710c-d8ec-0310-ae81-f5f2bcd8cb94\n" }, { "from": "human", "value": "\"\"\"\nSplit out a monolithic file with...
python
chosen
[ { "from": "system", "value": "Fix people list breaking due to deleted photo.\n" }, { "from": "human", "value": "from django.utils.html import format_html\n\nfrom wagtailmodeladmin.options import ModelAdmin, wagtailmodeladmin_register\n\nfrom .models import Person\n\n\nclass PeopleAdmin(ModelAdmi...
python
chosen
[ { "from": "system", "value": "Add LIMIT 1 to speed up query\n" }, { "from": "human", "value": "from typing import List\n\nfrom mediawords.db.handler import DatabaseHandler\nfrom mediawords.util.log import create_logger\nfrom mediawords.util.perl import decode_object_from_bytes_if_needed\n\nl = c...
python
chosen
[ { "from": "system", "value": "Fix deprecation warnings due to invalid escape sequences.\n" }, { "from": "human", "value": "import six\nimport sys\nimport test_helper\nimport unittest\n\nfrom authy import AuthyException\nfrom authy.api import AuthyApiClient\nfrom authy.api.resources import Tokens...
python
chosen
[ { "from": "system", "value": "Add coco_test_data.py to lit ignore list\n" }, { "from": "human", "value": "import os\nimport sys\n\nimport lit.formats\nimport lit.util\n\nimport lit.llvm\n\n# Configuration file for the 'lit' test runner.\nlit.llvm.initialize(lit_config, config)\n\n# name: The nam...
python
chosen
[ { "from": "system", "value": "Update exception handling in LxmlParser\n" }, { "from": "human", "value": "#encoding: utf-8\n\nfrom lxml.html import parse, fromstring\n\nclass LxmlParser(object):\n def __init__(self, url=None, string=None):\n if url:\n self.root = parse(url).g...
python
chosen
[ { "from": "system", "value": "Refactor the initialization a bit to make configuration easier.\n" }, { "from": "human", "value": "import json\nimport requests\n\n\nclass TemperatureWatch(object):\n thermostat_url = None\n alert_high = 80\n alert_low = 60\n _last_response = None\n\n ...
python
chosen
[ { "from": "system", "value": "Update StatViewSet to generic, add necessary mixins\n" }, { "from": "human", "value": "# from django.contrib.auth.models import User\nfrom django.shortcuts import get_object_or_404\nfrom rest_framework import viewsets, permissions # , serializers\nfrom .models impo...
python
chosen
[ { "from": "system", "value": "Use permissions attribute to detect ironic service\n\nHorizon implements a logic to enable/disable panel by permissions\ndefined in each panel class. This change replaces the current redundant\nlogic by that built-in feature to simplify how we define requirements\nof the Ironic...
python
chosen
[ { "from": "system", "value": "Make a table for the front page\n" }, { "from": "human", "value": "from wate import app\nimport db_ops\n\n@app.route('/')\ndef index():\n users = db_ops.users_everything_get()\n header = db_ops.COMPLETE_USER_SCHEMA\n\n retval = \"\"\n\n # First, print t...
python
chosen
[ { "from": "system", "value": "Revert \"[FIX] website_quote: make 'Pay & Confirm' work without website_sale\"\n\nNo dependency change in stable version\n\nThis reverts commit 65a589eb54a1421baa71074701bea2873a83c75f.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# Part of Odoo. See ...
python
chosen
[ { "from": "system", "value": "Fix relative import for py3\n" }, { "from": "human", "value": "from __future__ import unicode_literals\nimport datetime\nfrom django.http import HttpResponse, HttpResponseBadRequest\nfrom django.core.exceptions import ValidationError\nfrom django.views.decorators.cs...
python
chosen
[ { "from": "system", "value": "Fix minor function call naming bug\n" }, { "from": "human", "value": "import unittest\nimport time\nimport pandas as pd\nfrom bert_trainer import BERTTrainer\nfrom utils import *\n\nclass TestBERT(unittest.TestCase):\n\n def test_init(self):\n trainer = BE...
python
chosen
[ { "from": "system", "value": "Test now fails properly without feature.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\n\nfrom rollyourown.seo.admin import register_seo_admin, get_inline\nfrom django.contrib import admin\nfrom userapp.seo import Coverage, WithSi...
python
chosen
[ { "from": "system", "value": "Fix building static media on Django 1.11.\n\nOur wrapper script for building static media attempted to honor the\nexit code of the `collectstatic` management command, passing it along to\n`sys.exit()` so that we wouldn't have a failure show up as a successful\nresult.\n\nHoweve...
python
chosen
[ { "from": "system", "value": "Example: Use the preferred import style\n\n[Using Flask Extensions](http://flask.readthedocs.org/en/latest/extensions/#using-extensions) suggests to import like ``from flask.ext import foo``." }, { "from": "human", "value": "from flask import Flask, render_template\...
python
chosen
[ { "from": "system", "value": "Add shutil dependency to get the terminal size\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"Utilities for Halo library.\n\"\"\"\nimport platform\nimport six\nimport codecs\n\nfrom colorama import init, Fore\nfrom termcolor import colored\n\ninit...
python
chosen
[ { "from": "system", "value": "Test all the code paths\n" }, { "from": "human", "value": "import unittest\nimport cbs\n\n\nclass AttrSettings():\n PROJECT_NAME = 'fancy_project'\n\n\nclass MethodSettings():\n def PROJECT_NAME(self):\n return 'fancy_project'\n\n\nclass TestApply(unitt...
python
chosen
[ { "from": "system", "value": "Modify db client to __new__\n\nchange db singlton from instance() staticmethod to __new__()\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# Copyright 2012 Ethan Zhang<http://github.com/Ethan-Zhang> \n#\n# Licensed under the Ap...
python
chosen
[ { "from": "system", "value": "Remove l2 from lm_default_config since it is currently unused\n" }, { "from": "human", "value": "lm_default_config = {\n ### GENERAL\n 'seed': None,\n 'verbose': True,\n 'show_plots': True,\n \n ### TRAIN\n 'train_config': {\n # Classifie...
python
chosen
[ { "from": "system", "value": "Views: Add stub unit tests for stub views funcs.\n" }, { "from": "human", "value": "import unittest\n\nfrom mongows import views\nfrom tests import MongoWSTestCase\n\nclass ViewsTestCase(MongoWSTestCase):\n\n def test_hello(self):\n rv = self.app.get('/')\...
python
chosen
[ { "from": "system", "value": "Fix test_using_ofx_printer_with_stringio for python 2.7\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nfrom ofxparse import OfxParser, OfxPrinter\nfrom unittest import TestCase\nfrom io import StringIO\nfrom os import close, remove\nfro...
python
chosen
[ { "from": "system", "value": "Remove duplicate libx path insertion\n" }, { "from": "human", "value": "# coding: utf-8\n\nimport os\nimport sys\n\nsys.path.insert(0, 'libx')\n\nif os.environ.get('SERVER_SOFTWARE', '').startswith('Google App Engine'):\n sys.path.insert(0, 'lib.zip')\nelse:\n imp...
python
chosen
[ { "from": "system", "value": "Bump version to turn on SET_MAX_FPS.\n\nReview URL: http://codereview.chromium.org/1875002\n\ngit-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@46239 0039d316-1c4b-4281-b951-d872f2087c98\n" }, { "from": "human", "value": "#!/usr/bin/python2.4\n# Copyright 2008-9 ...
python
chosen