conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Disable the admin interface in production\n" }, { "from": "human", "value": "from django.conf.urls import patterns, include, url\nfrom django.conf import settings\n\nfrom django.contrib import admin\nadmin.autodiscover()\n\nfrom treemap.views import index, settings\...
python
chosen
[ { "from": "system", "value": "Add multithreading with threading module, run until the end\n\nThe template has over 3M usages, so 5M should be a safe number.\n" }, { "from": "human", "value": "import pywikibot\nimport sys\nimport requests\nfrom app import get_proposed_edits, app\n\ndef prefill_ca...
python
chosen
[ { "from": "system", "value": "Add tests for Dungeon class\n" }, { "from": "human", "value": "from game.models import (Dungeon,\n Deck,\n Player,\n make_standard_deck)\nimport pytest\n\n\n@pytest.fixture\ndef dungeon():\n ...
python
chosen
[ { "from": "system", "value": "Add routing exception for docs\n" }, { "from": "human", "value": "import DQXUtils\nimport DQXDbTools\n\ndef application(environ, start_response):\n #For the root we do a relative redirect to index.html, hoping the app has one\n if environ['PATH_INFO'] == '/':\...
python
chosen
[ { "from": "system", "value": "Switch from url() to re_path()\n" }, { "from": "human", "value": "from django.conf.urls import url\nfrom django.contrib import admin\n\nfrom .views import ArticleView, PageView\n\n\nurlpatterns = [\n url(r\"^admin/\", admin.site.urls),\n url(r\"^articles/(?P<p...
python
chosen
[ { "from": "system", "value": "Add test for MotorAsyncIOReference await support\n" }, { "from": "human", "value": "from umongo import Document\n\n# Await syntax related tests are stored in a separate file in order to\n# catch a SyntaxError when Python doesn't support it\nasync def test_await_synt...
python
chosen
[ { "from": "system", "value": "Make linestyles2 test runnable (should probably fix this for other tests)\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nfrom boomslang import Line, Plot\nfrom ImageComparisonTestCase import ImageComparisonTestCase\nimport unittest\n\nclass LineStyles2T...
python
chosen
[ { "from": "system", "value": "backend: Fix safe_ssh command without arguments\n" }, { "from": "human", "value": "# -*- coding: utf8 -*-\n# Copyright © 2015 Philippe Pepiot\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance wi...
python
chosen
[ { "from": "system", "value": "Fix DictStream join precedence (right was overriding left improperly)\n" }, { "from": "human", "value": "from datastreams import DataStream, DataSet\n\n\nclass DictStream(DataStream):\n\n @staticmethod\n def Stream(iterable,\n transform=lambda ro...
python
chosen
[ { "from": "system", "value": "Fix random seed in unit tests\n\nSigned-off-by: Niklas Koep <342d5290239d9c5264c8f98185afedb99596601a@gmail.com>\n" }, { "from": "human", "value": "import unittest\n\n\nclass TestCase(unittest.TestCase):\n pass\n" }, { "from": "gpt", "value": "import ...
python
chosen
[ { "from": "system", "value": "Update tests for new l10n behavior\n" }, { "from": "human", "value": "# Hollywood (wof neighbourhood)\n# https://whosonfirst.mapzen.com/data/858/260/37/85826037.geojson\nassert_has_feature(\n 16, 11227, 26157, 'places',\n { 'id': 85826037, 'kind': 'neighbourho...
python
chosen
[ { "from": "system", "value": "Add geometry ABCs to init\n" }, { "from": "human", "value": "from .curve import FourierRZCurve, FourierXYZCurve, FourierPlanarCurve\nfrom .surface import FourierRZToroidalSurface, ZernikeRZToroidalSection\n\n__all__ = [\n \"FourierRZCurve\",\n \"FourierXYZCurv...
python
chosen
[ { "from": "system", "value": "Add more structures to test_full() document\n\nSigned-off-by: Squareys <0f6a03d4883e012ba4cb2c581a68f35544703cd6@googlemail.com>\n" }, { "from": "human", "value": "import os\nimport unittest\nfrom pyddl import *\nfrom pyddl.enum import *\n\n__author__ = \"Jonathan H...
python
chosen
[ { "from": "system", "value": "Rewrite summary as late as possible.\n\nFixes issue where {filename} links would sometimes not work.\n" }, { "from": "human", "value": "\"\"\"\nSummary Footnotes\n-------------\n\nFix handling of footnotes inside article summaries.\nOption to either remove them or m...
python
chosen
[ { "from": "system", "value": "Update comments in the layout test\n" }, { "from": "human", "value": "from seleniumbase import BaseCase\n\n\nclass VisualLayoutTest(BaseCase):\n\n def test_applitools_helloworld(self):\n self.open('https://applitools.com/helloworld?diff1')\n print('...
python
chosen
[ { "from": "system", "value": "Use list comprehensions to generate test data\n" }, { "from": "human", "value": "import tests.context\nimport unittest\n\nfrom meetup_loto import Loto\n\nclass TestMeetupLoto(unittest.TestCase):\n def setUp(self):\n self.api = FakeApi()\n self.loto ...
python
chosen
[ { "from": "system", "value": "Fix token refresh for spotify credentials\n" }, { "from": "human", "value": "from flask_login import UserMixin\nimport spotify\nimport spotipy\nimport db_utils\nimport application as app\n\n\nclass User(UserMixin):\n ''' User class for Flask-Login '''\n def __...
python
chosen
[ { "from": "system", "value": "Use TO_HIRAGANA to get lemmas from Hiragana table.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nimport unittest\n\nfrom romajitools import *\n\nclass RTTestCase(unittest.TestCase):\n ...
python
chosen
[ { "from": "system", "value": "Remove a redundant if and fix a syntax error\n" }, { "from": "human", "value": "import ircbotframe\nimport sys\n\nclass Handler:\n def __init__(self, host, port=6667, name=\"MediaWiki\", description=\"MediaWiki recent changes bot\", channels=[]):\n self.ch...
python
chosen
[ { "from": "system", "value": "Fix indefinite hangs when closing streaming results.\n\n * See https://github.com/KeepSafe/aiohttp/issues/739\n" }, { "from": "human", "value": "import asyncio\nimport json\nimport logging\n\nimport aiohttp.errors\n\nlog = logging.getLogger(__name__)\n\n\nclass Json...
python
chosen
[ { "from": "system", "value": "Document classes in the perception handler module.\n" }, { "from": "human", "value": "\"\"\"\nModule that holds classes that represent an agent's perception handler.\n\"\"\"\n\nimport abc\nimport world\nimport structure\n\nclass PerceptionHandler(object):\n\n @ab...
python
chosen
[ { "from": "system", "value": "Use session instead of cookie for tracking visitor UUID\n\nsession ID is only recorded after this layer of middleware, hence the need for a new UUID" }, { "from": "human", "value": "import uuid\n\nfrom django.conf import settings\nfrom django.utils import timezone\n...
python
chosen
[ { "from": "system", "value": "Rename 'public_fields' Application->Image to avoid confusion with the UI\n" }, { "from": "human", "value": "from core.models import ProjectApplication, Project, Application\nfrom rest_framework import serializers\nfrom api.v2.serializers.summaries import ProjectSumm...
python
chosen
[ { "from": "system", "value": "Add comment about import in function.\n" }, { "from": "human", "value": "# oxy.io\n# File: oxyio/settings/__init__.py\n# Desc: settings classmodule allowing for defaults + modules applied at runtime\n\nimport sys\n\nfrom . import defaults\n\n\nclass OxyioSettings(ob...
python
chosen
[ { "from": "system", "value": "Include puiseux.puiseux in global namespace\n\nBecause it's useful, we include puiseux.puiseux() in the\nproject __init__.py.\n" }, { "from": "human", "value": "\"\"\"\nabelfunctions is a Python library for computing with Abelian functions,\nalgebraic curves, and so...
python
chosen
[ { "from": "system", "value": "Improve end-user labels, values, help text." }, { "from": "human", "value": "from django import forms\nfrom django.core.exceptions import NON_FIELD_ERRORS\nfrom django.utils.dates import MONTHS\n\nfrom zebra.conf import options\nfrom zebra.widgets import NoNameSelec...
python
chosen
[ { "from": "system", "value": "Fix spreadsheets page set for RecreateSKPs bot\n\nNoTry: true\nBug: skia:9380\nChange-Id: Iab05b1baab58032a8053242fd2a8b6e8799c35cc\nReviewed-on: https://skia-review.googlesource.com/c/skia/+/238037\nReviewed-by: Eric Boren <0e499112533c8544f0505ea0d08394fb5ad7d8fa@google.com>\...
python
chosen
[ { "from": "system", "value": "Switch to absolute import for Python 2.5 (fixes GH-64)\n" }, { "from": "human", "value": "\"\"\"\nraven.contrib.django\n~~~~~~~~~~~~~~~~~~~~\n\n:copyright: (c) 2010 by the Sentry Team, see AUTHORS for more details.\n:license: BSD, see LICENSE for more details.\n\"\"...
python
chosen
[ { "from": "system", "value": "Include error message in debug.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport logging\nimport subprocess\nimport timeit\n\nLOG = logging.getLogger(__name__)\n\n\ndef run_subprocess(cmd, input_data=None, un=False):\n \"\"\"\n Run cmd comman...
python
chosen
[ { "from": "system", "value": "Add name to legislator detail page\n" }, { "from": "human", "value": "from . import views\nfrom django.conf.urls import url\n\n\nurlpatterns = [\n url(r'^find_legislator/', views.find_legislator),\n url(r'^get_latlon/', views.get_latlon, name=\"get_latlon\"),\...
python
chosen
[ { "from": "system", "value": "Rewrite previous migration in raw SQL\n\nWe shouldn’t import models into migrations because if the model changes\nlater down the line then the migration can’t be re-run at a later date\n(for example to rebuild a database from scratch).\n\nWe don’t need to encode the content bef...
python
chosen
[ { "from": "system", "value": "snapshot_scheduler: Use the correctly named env vars\n" }, { "from": "human", "value": "# -*- encoding: utf-8 -*-\n\nimport datetime as dt\nimport os\n\nimport mock\nfrom unittest.mock import patch\n\nimport snapshot_scheduler\n\n\nclass patched_datetime(dt.datetime...
python
chosen
[ { "from": "system", "value": "Fix test - s/time/updated_at/ named param\n" }, { "from": "human", "value": "import unittest\nimport StringIO\n\nfrom ztag.stream import Updater, UpdateRow\n\n\nclass UpdaterTestCase(unittest.TestCase):\n FREQUENCY = 1.0\n\n def setUp(self):\n pass\n\n ...
python
chosen
[ { "from": "system", "value": "Exclude DraftRegistration Groups from admin form\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nfrom django import forms\nfrom django.db.models import Q\nfrom django.contrib.auth.models import Group\n\nfrom osf.models import AdminProfil...
python
chosen
[ { "from": "system", "value": "Add training to basic example\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom chatterbot import ChatBot\n\n# Create a new chat bot named Charlie\nchatbot = ChatBot('Charlie')\n\n# Get a response to the input text 'How are you?'\nresponse = chatbot.g...
python
chosen
[ { "from": "system", "value": "Fix registering for already registered model\n" }, { "from": "human", "value": "from django.apps import AppConfig\n\n\nclass PaymentConfig(AppConfig):\n name = 'apps.payment'\n verbose_name = 'Payment'\n\n def ready(self):\n super(PaymentConfig, self...
python
chosen
[ { "from": "system", "value": "Use shared_task instead of deprecated periodic_task\n" }, { "from": "human", "value": "from datetime import timedelta\n\nfrom django.conf import settings\nfrom django.core.management import call_command\n\nfrom celery.task import periodic_task\n\n\n@periodic_task(ru...
python
chosen
[ { "from": "system", "value": "Fix some bugs with date parsing, as well as zero pad month and day in URL\n" }, { "from": "human", "value": "\"\"\"!backtothefuture <date> returns the delorean dashboard with the specified <date>\"\"\"\n\nimport re\nimport parsedatetime\n\n\np = parsedatetime.Calend...
python
chosen
[ { "from": "system", "value": "Fix incompatibility with recent factory_boy postgeneration.\n" }, { "from": "human", "value": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not distributed with this\n# file, you can obtain one at...
python
chosen
[ { "from": "system", "value": "Clarify on command class casing\n" }, { "from": "human", "value": "from sublime_plugin import ApplicationCommand\n\n\nclass not_pascal_case_command(ApplicationCommand):\n\n def run(self):\n print(\"not_pascal_case\")\n\n\nclass not_PascalCaseCommand(Applic...
python
chosen
[ { "from": "system", "value": "Add a length argument for InterleavingMethod.interleave and multileave\n" }, { "from": "human", "value": "class InterleavingMethod(object):\n '''\n Interleaving\n '''\n def interleave(self, a, b):\n '''\n a: a list of document IDs\n ...
python
chosen
[ { "from": "system", "value": "[Discord] Remove unused bot attribute from Duelyst cog\n\n" }, { "from": "human", "value": "\nfrom discord.ext import commands\n\nfrom utilities import checks\n\ndef setup(bot):\n\tbot.add_cog(Duelyst(bot))\n\nclass Duelyst(commands.Cog):\n\t\n\tdef __init__(self, b...
python
chosen
[ { "from": "system", "value": "Remove task for updating data\n\nNot sure if this is the best method to have it.\nSince for now is not needed, droping it from the codebase.\n" }, { "from": "human", "value": "import json\nimport logging\nimport os\nimport subprocess\n\nfrom celery import Celery\nfr...
python
chosen
[ { "from": "system", "value": "Update to run on port 5003\n\nFor development we will want to run multiple apps, so they should each bind to a different port number.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport os\nfrom app import create_app\nfrom flask.ext.script import Mana...
python
chosen
[ { "from": "system", "value": "Add automatic installation of dependencies if not found." }, { "from": "human", "value": "\"\"\"\nSimple server scripts that spawns the Jupyter notebook server process.\n\"\"\"\n\nimport subprocess\n\n\nsubprocess.call([\n 'jupyter', 'notebook', '--no-browser', '...
python
chosen
[ { "from": "system", "value": "Remove import of dead module\n" }, { "from": "human", "value": "import os\n\n# pylint: disable=unused-wildcard-import,unused-import,wildcard-import\n\nSRC_DIR = os.path.dirname(os.path.abspath(__file__)) # elife-builder/src/\n\n# once called 'THIS_DIR', now deprecat...
python
chosen
[ { "from": "system", "value": "Use the correct Info.plist in the new version of FeedbackDemo\n" }, { "from": "human", "value": "# This script should be copied into the Run Script trigger of an Xcode Bot\n\n# Utilizes `cavejohnson` for Xcode Bot scripting\n# https://github.com/drewcrawford/CaveJoh...
python
chosen
[ { "from": "system", "value": "Switch to new Wynton cluster\n" }, { "from": "human", "value": "import saliweb.backend\n\nclass Job(saliweb.backend.Job):\n runnercls = saliweb.backend.SGERunner\n\n def run(self):\n libs = {'PoseScore': 'protein_ligand_pose_score.lib',\n ...
python
chosen
[ { "from": "system", "value": "Add test case for `parse_value`\n\nThe new test case handles the string '\"\"' as input.\n" }, { "from": "human", "value": "\"\"\"\ntest_itunes.py\n\nCopyright © 2015 Alex Danoff. All Rights Reserved.\n2015-08-02\n\nThis file tests the functionality provided by the ...
python
chosen
[ { "from": "system", "value": "tests/length: Add comparison to (the square root of) the dot product\n" }, { "from": "human", "value": "import pytest # type: ignore\n\nfrom ppb_vector import Vector\n\n\n@pytest.mark.parametrize(\n \"x, y, expected\",\n [(6, 8, 10),\n (8, 6, 10),\n ...
python
chosen
[ { "from": "system", "value": "Update search tests for changes to search.py\n" }, { "from": "human", "value": "import unittest\nimport os\nimport sys\nsys.path.insert(1, os.path.join(\n os.path.dirname(os.path.abspath(__file__)),\n os.pardir,\n))\n\nfrom website import search\nimport loggin...
python
chosen
[ { "from": "system", "value": "Set SO_REUSADDR on the listening socket\n\nSo that nntpserver.py can be killed and restarted wothout delay." }, { "from": "human", "value": "#!/usr/bin/python\n\nimport socket, sys, os, signal\n\nimport nntp\n\nsignal.signal(signal.SIGCHLD, signal.SIG_IGN)\n\ns = so...
python
chosen
[ { "from": "system", "value": "Use settings SRID in migration\n" }, { "from": "human", "value": "# Generated by Django 3.1.13 on 2021-10-13 13:05\n\nimport django.contrib.gis.db.models.fields\nfrom django.db import migrations\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ...
python
chosen
[ { "from": "system", "value": "compat: Fix urlencode for Python < 3.0.\n\nThe urlencode function handles encoding in Python 3.x so our\ncompatibility layer should do so to.\n" }, { "from": "human", "value": "\"\"\"\nExports related to URL parsing.\n\nThis module exports standard library functiona...
python
chosen
[ { "from": "system", "value": "Drop back to state as return val\n\nIf we store state on Algorithm then we're not thread-safe.\n" }, { "from": "human", "value": "from __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\nfrom __future__ import u...
python
chosen
[ { "from": "system", "value": "Fix a typo in BlogPost model\n" }, { "from": "human", "value": "from django.db import models\nfrom django.contrib.auth.models import User\n\nclass BlogPost(models.Model):\n user = models.ForeignKey(User)\n title = models.CharField(max_lenght = 120)\n text =...
python
chosen
[ { "from": "system", "value": "Fix 500 error on empty passlogin values\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n#from twisted.words.xish import domish\n\nfrom base import *\nfrom bnw_core.base import get_webui_base\nimport bnw_core.bnw_objects as objs\nfrom twisted.internet imp...
python
chosen
[ { "from": "system", "value": "Add filter for low stock listings\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nimport django_filters\n\nfrom .models import Listing\n\n\nclass ListingFilter(django_filters.FilterSet):\n title = django_filters.CharFilter(lookup_typ...
python
chosen
[ { "from": "system", "value": "Allow to pass a runner to Process.\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nimport os\n\nfrom .tee import run\nfrom .exit import trace\n\ncatch_keyboard_interrupts = True\n\n\nclass Process(object):\n \"\"\"Process related func...
python
chosen
[ { "from": "system", "value": "Fix use of a too-recent NumPy feature\n" }, { "from": "human", "value": "from numpy import add, array, diff, flatnonzero, reshape, sign\n\ndef _remove_adjacent_duplicates(indices):\n return indices[diff(indices, prepend=-1) != 0]\n\ndef _choose_brackets(y):\n ...
python
chosen
[ { "from": "system", "value": "Add function to print a message\n" }, { "from": "human", "value": "#!/usr/bin/python3.4\n\nprint(\"hello\")\n" }, { "from": "gpt", "value": "#!/usr/bin/python3.4\n\ndef greeting(msg):\n print(msg)\n\nif __name__=='__main__':\n greeting(\"hello\")\n...
python
chosen
[ { "from": "system", "value": "Add flask-script package to manage deploys\n" }, { "from": "human", "value": "from flask_script import Manager\n\nfrom config.config import app\n# from mailchimp.redis_init import init_redis_with_mailchimp\n\nmanager = Manager(app)\n\n@manager.command\ndef run_local...
python
chosen
[ { "from": "system", "value": "Handle different cookie processing for Django 1.11\n" }, { "from": "human", "value": "\"\"\"\nDjango Rest Framework Authentication classes for cross-domain end-points.\n\"\"\"\n\nfrom rest_framework import authentication\n\nfrom .helpers import is_cross_domain_reque...
python
chosen
[ { "from": "system", "value": "Fix non relative import for __version__\n" }, { "from": "human", "value": "from __future__ import absolute_import\nfrom .inotify_simple import *\ntry:\n from __version__ import __version__\nexcept ImportError:\n __version__ = None\n" }, { "from": "gpt...
python
chosen
[ { "from": "system", "value": "Make sure to kill JVM on exit\n" }, { "from": "human", "value": "\"\"\"Methods related to starting and stopping the Java Gateway\"\"\"\nfrom py4j.java_gateway import JavaGateway\nimport os\n\ndef _find_lolo_jar():\n \"\"\"Attempt to automatically find a jar file ...
python
chosen
[ { "from": "system", "value": "Allow options to be passed into minimization\n" }, { "from": "human", "value": "from scipy import optimize as o\nimport clean as c\n\ndef minimize(func, guess):\n return o.minimize(func, guess)\n\ndef minimize_scalar(func, bracket=None, bounds=None, args=(), meth...
python
chosen
[ { "from": "system", "value": "Revert gunzip in python from performance insights mapping\n\nReverts ade2e1a90cc69169b8c613606b44ac7503b64503. This appears to be\ncausing significant contention on at least z840 machines. Only ~12 d8\ninstances run at any given time despite -j48.\n\nAs noted in https://github....
python
chosen
[ { "from": "system", "value": "Add : entry tidy to keep relevant info.\n" }, { "from": "human", "value": "class Parser(object):\n \"\"\"\n Parser class definition.\n\n Takes care of parsing the fail2ban log, either in \"all\" mode or \"realtime\".\n \"\"\"\n\n def __init__(self, co...
python
chosen
[ { "from": "system", "value": "Add `default_app_config` so you can just use `axes` in `INSTALLED_APPS`\n" }, { "from": "human", "value": "__version__ = '2.0.0'\n\n\ndef get_version():\n return __version__\n" }, { "from": "gpt", "value": "__version__ = '2.0.0'\n\ndefault_app_config ...
python
chosen
[ { "from": "system", "value": "Send back a mimetype for JSON response.\n" }, { "from": "human", "value": "\"\"\"celery.views\"\"\"\nfrom django.http import HttpResponse\nfrom celery.task import is_done, delay_task\nfrom celery.result import AsyncResult\nfrom carrot.serialization import serialize ...
python
chosen
[ { "from": "system", "value": "Fix if no paragraph is in page\n" }, { "from": "human", "value": "#\n# Konstrukteur - Static website generator\n# Copyright 2013 Sebastian Fastner\n#\n\n__all__ = [\"parse\"]\n\nfrom jasy.env.State import session\nfrom jasy.core import Console\nfrom bs4 import Beaut...
python
chosen
[ { "from": "system", "value": "Fix test so it doesn't have side-effects\n" }, { "from": "human", "value": "import os\n\nfrom numpy.testing import assert_array_equal, raises, run_module_suite\nimport numpy as np\n\nimport skimage.io as io\nfrom skimage.io._plugins.plugin import plugin_store\nfrom ...
python
chosen
[ { "from": "system", "value": "Fix PE backend file offset of section\n" }, { "from": "human", "value": "from ..region import Section\n\nclass PESection(Section):\n \"\"\"\n Represents a section for the PE format.\n \"\"\"\n def __init__(self, pe_section, remap_offset=0):\n supe...
python
chosen
[ { "from": "system", "value": "Add finally blocks to ensure tests always clean up\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom contextlib import contextmanager\nfrom io import BytesIO\nimport sys\nimport mock_modules\nimport yv_suggest.shared as yvs\n\...
python
chosen
[ { "from": "system", "value": "Use redis configuration when initializing data\n" }, { "from": "human", "value": "from twitterbot.twitter_bot import get_redis\n\n\ndef add_data(redis, key, data):\n for item in data:\n redis.sadd(key, item.encode('utf-8'))\n\nredis = get_redis('127.0.0.1:...
python
chosen
[ { "from": "system", "value": "Fix team activity history view (was missing imports)\n" }, { "from": "human", "value": "import iris.views\nfrom teams.models import Team\n\n\ndef activity(request, slug, *args, **kw):\n template_name = 'teams/activity.html'\n team = get_object_or_404(Team, slu...
python
chosen
[ { "from": "system", "value": "Fix a python undefined name in test scripts\n\nSigned-off-by: Laurent Bonnans <0909bc0a3d1b0c91d8e00372b9633e8e9ea958de@here.com>\n" }, { "from": "human", "value": "import platform\nimport re\nimport subprocess\n\nfrom time import sleep\n\ndef verify_provisioned(akt...
python
chosen
[ { "from": "system", "value": "Make the private settings file a bit user friendly\n" }, { "from": "human", "value": "import os\n# Quick-start development settings - unsuitable for production\n# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/\n\n# SECURITY WARNING: keep the s...
python
chosen
[ { "from": "system", "value": "Fix typo in matplotlib setup.\n" }, { "from": "human", "value": "import tables\nimport tables as tb\ntry:\n import fipy\n import fipy as fp\nexcept:\n pass\nimport numpy\nimport numpy as np\nimport scipy\nimport scipy as spy\nimport matplotlib.pylot as plt\...
python
chosen
[ { "from": "system", "value": "Move to sendMessage command for message sending. Also add 'notice' trigger, because why not\n" }, { "from": "human", "value": "from CommandTemplate import CommandTemplate\n\nclass Command(CommandTemplate):\n\ttriggers = ['say', 'do']\n\thelptext = \"Makes the bot sa...
python
chosen
[ { "from": "system", "value": "Use a more compact functional style for instantiating hashtagCounter\n" }, { "from": "human", "value": "import json\nimport sys\nfrom collections import Counter\n\nf = open(sys.argv[1], 'r')\ntopk = int(sys.argv[2]) if len(sys.argv) > 2 and sys.argv[2].isdigit() els...
python
chosen
[ { "from": "system", "value": "Add schema with Dict field" }, { "from": "human", "value": "from marshmallow import Schema, fields\n\n\nclass PetSchema(Schema):\n id = fields.Int(dump_only=True)\n name = fields.Str()\n\n\nclass SampleSchema(Schema):\n runs = fields.Nested('RunSchema', man...
python
chosen
[ { "from": "system", "value": "Use python3 in the shebang\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport os\nimport sys\n\nif __name__ == \"__main__\":\n os.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"onepageblog.settings\")\n\n from django.core.management import exec...
python
chosen
[ { "from": "system", "value": "Use __str__ instead of __repr__ so that debugging output remains the same\n" }, { "from": "human", "value": "from collections import namedtuple\n\n\nclass PackageError(Exception):\n \"\"\"Exception to be raised when user wants to exit on error.\"\"\"\n\n\nclass R...
python
chosen
[ { "from": "system", "value": "Create the Login Page > Create the Login & Logout URLs\n" }, { "from": "human", "value": "from django.conf.urls import patterns, include, url\nfrom django.contrib import admin\n\nadmin.autodiscover()\n\nfrom marketing.views import HomePage\n\nurlpatterns = patterns(...
python
chosen
[ { "from": "system", "value": "Add tests for tag parsing\n" }, { "from": "human", "value": "\nclass Tag(object):\n \"\"\"\n An IRC message tag ircv3.net/specs/core/message-tags-3.2.html\n \"\"\"\n @staticmethod\n def parse(item):\n key, sep, value = item.partition('=')\n ...
python
chosen
[ { "from": "system", "value": "Use params dictionary instead of appending to the end of URL string\n" }, { "from": "human", "value": "import json\nimport re\nimport requests\n\nclass KeyValue(object):\n\n def __init__(self, url):\n self._url = \"%s/kv\" % url\n\n def _get(self, key, ...
python
chosen
[ { "from": "system", "value": "Use msvc flags when building with msvc, and gcc flags when building with gcc\n" }, { "from": "human", "value": "import Config\n\ndbg = Config.Config('dbg', default=True, CCFLAGS=['-g', '-O0'], suffix='_DEBUG')\noptdbg = Config.Config('optdbg', CCFLAGS=['-g', '-02'],...
python
chosen
[ { "from": "system", "value": "Add test for tokenization of 'i.' for Danish.\n" }, { "from": "human", "value": "# coding: utf-8\nfrom __future__ import unicode_literals\n\nimport pytest\n\n@pytest.mark.parametrize('text', [\"ca.\", \"m.a.o.\", \"Jan.\", \"Dec.\"])\ndef test_da_tokenizer_handles_a...
python
chosen
[ { "from": "system", "value": "Enable Gunicorn max_requests config through env\n\nThis commit enables a user to alter the `max_requests` parameter\npassed through to Gunicorn without having to resort to the \"bare\"\nCMD-specification hinted at in the Advanced documentation.\n" }, { "from": "human", ...
python
chosen
[ { "from": "system", "value": "Test pair mass for non-zero mass particles\n" }, { "from": "human", "value": "from dimuon import *\nfrom nose.tools import *\nfrom math import pi\n\nclass DummyParticle:\n def __init__(self, q):\n self.q = q\n\ndef test_no_particles():\n particles = []\...
python
chosen
[ { "from": "system", "value": "Add tests for env serialization\n" }, { "from": "human", "value": "from datetime import datetime\n\nfrom changes.api.serializer import serialize\nfrom changes.config import db\nfrom changes.models import Command\nfrom changes.testutils import TestCase\n\n\nclass Com...
python
chosen
[ { "from": "system", "value": "Remove outdated test deps from dotnet" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\ntemplates_path = ['_templates']\nsource_suffix = '.rst'\nmaster_doc = 'index'\nproject = u'dotnetexample'\ncopyright = u'2015, rtfd'\nauthor = u'rtfd'\nversion = '0.1'\...
python
chosen
[ { "from": "system", "value": "Make sure we always have a string to work with" }, { "from": "human", "value": "# coding=utf-8\nimport logging\nimport subprocess\nfrom subprocess import Popen, PIPE\n\n\nclass GitCmdException(Exception):\n def __init__(self, stdout, stderr, message):\n se...
python
chosen
[ { "from": "system", "value": "Create Node class; construct insert method\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\n\nclass SinglyLinked(object):\n def __init__(self):\n pass\n\n def insert(self, val):\n # insert val at beginning of list\n pass\n\n ...
python
chosen
[ { "from": "system", "value": "Add test to check for public urls\n" }, { "from": "human", "value": "import pytest\n\npytestmark = pytest.mark.django_db\n\n\ndef test_admin_interface(client):\n response = client.get('/admin/login/')\n assert response.status_code == 200\n" }, { "from"...
python
chosen
[ { "from": "system", "value": "Revert \"* added a few keys to the configs\"\n\nThis reverts commit 66f083e386a94ad558d50fa2dd8120c01e9580a7.\n" }, { "from": "human", "value": "from six import string_types\n\nfrom great_expectations.types import Config\n\n\nclass DataContextConfig(Config):\n _a...
python
chosen
[ { "from": "system", "value": "Use full path to find mods\n" }, { "from": "human", "value": "from imp import find_module, load_module\nimport os\n\nclass SourceExtension(object):\n def __init__(self, mod):\n self.initialized = False\n self.mod = mod\n self.renew = mod.rene...
python
chosen
[ { "from": "system", "value": "Replace invalid string format '{}' by '{0}' for Python 2.6 compatibility.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nimport functools\nimport warnings\n\n\ndef deprecated(func):\n \"\"\"\n This is a decorator which can be used to mark functi...
python
chosen
[ { "from": "system", "value": "Use a class decorator to add enum values to classes\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nimport os\n\nfrom cffi import FFI\n\n\n__version__ = '2.0.0a1'\n\n\nheader_file = os.path.join(os.path.dirname(__file__), 'api.processed...
python
chosen