conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Use sure in app tests\n" }, { "from": "human", "value": "from django.test import TestCase\nfrom django.core.urlresolvers import reverse\n\n\nclass IndexViewCase(TestCase):\n \"\"\"Index view case\"\"\"\n\n def setUp(self):\n self.url = reverse('home')\n...
python
chosen
[ { "from": "system", "value": "Make it possible to import ipython_widgets without having a kernel or comm manager\n" }, { "from": "human", "value": "from .widgets import *\n\n# Register a comm target for Javascript initialized widgets..\nfrom IPython import get_ipython\nip = get_ipython()\nif ip ...
python
chosen
[ { "from": "system", "value": "Add missing import of sys.\n" }, { "from": "human", "value": "import unittest\n\nif sys.platform.startswith('darwin'):\n from nativeconfig.config import NSUserDefaultsConfig\n from test.config import TestConfigMixin\n\n\n class MyNSUserDefaultsConfig(NSUser...
python
chosen
[ { "from": "system", "value": "Replace function call with set literal\n\n- Add assert statement so we do not have a \"statement with no effect\"\n" }, { "from": "human", "value": "from timewreport.interval import TimeWarriorInterval\n\n\ndef test_interval_should_be_hashable():\n a = TimeWarrio...
python
chosen
[ { "from": "system", "value": "Fix isincluded for List operators.\n" }, { "from": "human", "value": "\"\"\"Utilities for using the PPP datamodel.\"\"\"\n\nfrom . import Resource, Triple, Missing, Intersection, List, Union, And, Or, Exists, First, Last, Sort\n\ndef contains_missing(tree):\n def...
python
chosen
[ { "from": "system", "value": "Fix a typo in a docstring\n" }, { "from": "human", "value": "\"\"\"PyGotha speakers.\"\"\"\n\nfrom flask import abort, Blueprint, g, render_template\n\nfrom pygotham.frontend import route\nfrom pygotham.models import User\n\n__all__ = ('blueprint',)\n\nblueprint = B...
python
chosen
[ { "from": "system", "value": "Revert \"remove the dest tree and recreate it\"\n\nThis reverts commit becc4657acea505594836e62c49de2b4cb0160a9.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport os\nimport sys\nimport shutil\n\nfrom version import full_version\nfrom optparse impor...
python
chosen
[ { "from": "system", "value": "Add a test for CHPump\n" }, { "from": "human", "value": "# Filename: test_ch.py\n# pylint: disable=locally-disabled,C0111,R0904,C0301,C0103,W0212\nfrom km3pipe.testing import TestCase, patch, Mock\nfrom km3pipe.io.ch import CHPump\n\n__author__ = \"Tamas Gal\"\n__co...
python
chosen
[ { "from": "system", "value": "Set root route to point to admin\n" }, { "from": "human", "value": "from django.conf.urls import patterns, include, url\n\nfrom django.contrib import admin\nadmin.autodiscover()\n\nurlpatterns = patterns('',\n # Examples:\n # url(r'^$', 'thrive_refugee.views.h...
python
chosen
[ { "from": "system", "value": "Add comment about kaggle_gcp module path.\n" }, { "from": "human", "value": "import os\n\nkaggle_proxy_token = os.getenv(\"KAGGLE_DATA_PROXY_TOKEN\")\nbq_user_jwt = os.getenv(\"KAGGLE_BQ_USER_JWT\")\nif kaggle_proxy_token or bq_user_jwt:\n from google.auth import...
python
chosen
[ { "from": "system", "value": "Fix bug, use instance and not classes as storage\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# Licensed to the Apache Software Foundation (ASF) under one\n# or more contributor license agreements. See the NOTICE file\n# dist...
python
chosen
[ { "from": "system", "value": "Add url, id and trags to the EntriesSerializer\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n#\n# (c) 2014 Bjoern Ricks <bjoern.ricks@gmail.com>\n#\n# See LICENSE comming with the source of 'trex' for details.\n#\n\nfrom rest_framework.serializers impo...
python
chosen
[ { "from": "system", "value": "Move process scheduling out of main.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nimport schedule\nfrom feed import load_feed\nfrom twitter import send_queued_tweet\nimport time\nimport os\n\n\nRSS_FEED_LIST = os.environ['RSS_FEED_LIST']\nLOAD_FEED_...
python
chosen
[ { "from": "system", "value": "Add help text for roll command\n" }, { "from": "human", "value": "import random\nimport re\n\nfrom cardinal.decorators import command\n\n\ndef parse_roll(arg):\n # some people might separate with commas\n arg = arg.rstrip(',')\n\n if match := re.match(r'^(\...
python
chosen
[ { "from": "system", "value": "Implement formatted list of keys and values in output\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport client_wrap\n\ndef main():\n client = client_wrap.ClientWrap(\"get_test.log\", \"ipc:///var/run/zero-cache/0\", 0)\n\n key_str = client.Get...
python
chosen
[ { "from": "system", "value": "Improve variable names for clarity\n" }, { "from": "human", "value": "import logging, os, zc.buildout, sys, shutil\n\nclass ZipEggs:\n def __init__(self, buildout, name, options):\n self.name, self.options = name, options\n if options['target'] is N...
python
chosen
[ { "from": "system", "value": "Fix worker exception handler for non workerexceptions\n" }, { "from": "human", "value": "from rq import Connection, Queue, Worker\n\n\ndef worker_exc_handler(job, exc_type, exc_value, traceback):\n job.meta['exc_code'] = exc_type.code\n job.meta['exc_message']...
python
chosen
[ { "from": "system", "value": "Remove admin restictions to movies endpoint\n" }, { "from": "human", "value": "from .serializers import MovieSerializer\nfrom .models import Movie\n\nfrom rest_framework import generics\nfrom rest_framework.response import Response\nfrom rest_framework.views import ...
python
chosen
[ { "from": "system", "value": "Fix migrations dependency issue caused by 990563e.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ...
python
chosen
[ { "from": "system", "value": "Make exception messages more descriptive\n" }, { "from": "human", "value": "\"\"\"This module defines error classes for typedjsonrpc.\"\"\"\n\n\nclass Error(Exception):\n \"\"\"Base class for all errors.\"\"\"\n code = 0\n message = None\n data = None\n\...
python
chosen
[ { "from": "system", "value": "Use timezones=[] to underline that we only care about dates.\n" }, { "from": "human", "value": "import unittest\nfrom hypothesis import given\nfrom hypothesis.extra.datetime import datetimes\n\nimport qual\n\nfrom datetime import date\n\nclass TestIsoUtils(unittest....
python
chosen
[ { "from": "system", "value": "Use next method of reader object\n" }, { "from": "human", "value": "import csv\nfrom datetime import datetime\n\nfrom django.shortcuts import render\nfrom django.utils import timezone\nfrom django.views.generic import TemplateView\n\nfrom .forms import FeedbackUploa...
python
chosen
[ { "from": "system", "value": "Add a test for one schedule fragment.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport pytest\n\nimport manipulator_util\n\n\nclass TestManipulatorManager(object):\n\n def pytest_funcarg__manager(self, request):\n return manipulator_util....
python
chosen
[ { "from": "system", "value": "Add test for qisrc list\n\nChange-Id: I04c08f60044ffb0ba2ff63141d085e4dc2545455\n" }, { "from": "human", "value": "from qisys import ui\n\ndef test_list_tips_when_empty(qisrc_action, record_messages):\n qisrc_action(\"init\")\n qisrc_action(\"list\")\n asse...
python
chosen
[ { "from": "system", "value": "Fix port number for eventing stats\n\nChange-Id: Ifaa7e9957f919febb1a297683077cd1c71c6aa9d\nReviewed-on: http://review.couchbase.org/84633\nTested-by: Build Bot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>\nReviewed-by: Mahesh Mandhare <f05f25073b6d9a2858c6a374b80c0...
python
chosen
[ { "from": "system", "value": "Add a minimum value to fibonacci example\n" }, { "from": "human", "value": "from girder_worker.app import app\n\n\n@app.task\n@app.argument('n', app.types.Integer)\ndef fibonacci(n):\n \"\"\"Compute the nth fibonacci number recursively.\"\"\"\n if n == 1 or n ...
python
chosen
[ { "from": "system", "value": "Add a wait to see if we can get Travis passing again.\n" }, { "from": "human", "value": "\"\"\"\nUnit tests for pyelasticsearch\n\nThese require an elasticsearch server running on the default port\n(localhost:9200).\n\"\"\"\nimport unittest\n\nfrom nose.tools import...
python
chosen
[ { "from": "system", "value": "Use unittest in the mechanize related tests.\n" }, { "from": "human", "value": "\nfrom nose.tools import with_setup, raises\nfrom urllib2 import URLError\nfrom wsgi_intercept.mechanize_intercept import Browser\nimport wsgi_intercept\nfrom wsgi_intercept import test_...
python
chosen
[ { "from": "system", "value": "Make trailing slash optional for API URLs.\n\nAdmin website URLs will still redirect to canonical version with trailing slash.\n" }, { "from": "human", "value": "\"\"\"hub URL Configuration\n\nThe `urlpatterns` list routes URLs to views. For more information please ...
python
chosen
[ { "from": "system", "value": "Fix typo in man pages\n" }, { "from": "human", "value": "#!/usr/bin/python\n\n# Format the output from various oiio command line \"$tool --help\" invocations,\n# and munge such that txt2man generates a simple man page with not-too-horrible\n# formatting.\n\nfrom __f...
python
chosen
[ { "from": "system", "value": "Fix error on Firefox 6 where pages are not open if this preference is True (default).\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport subprocess\n\nfrom selenium.webdriver import Firefox\nfrom selenium.webdriver.firefox.fire...
python
chosen
[ { "from": "system", "value": "Fix IndexError bug in _hydrate\n" }, { "from": "human", "value": "import requests\n\nAPI_URL = 'http://data.police.uk/api/'\n\n\nclass APIError(Exception):\n pass\n\n\ndef api_request(method):\n r = requests.get(API_URL + method)\n if r.status_code != 200:\...
python
chosen
[ { "from": "system", "value": "Fix test warning about wrong assert function\n" }, { "from": "human", "value": "import unittest\n\nfrom ..framework import cli_test_suite\nfrom .util import DEFAULT_MANAGEMENT_KEY\n\n\n@cli_test_suite\ndef additional_tests(ykman_cli):\n class Misc(unittest.TestCa...
python
chosen
[ { "from": "system", "value": "Comment about form field names for Google Autocomplete\n" }, { "from": "human", "value": "from flask.ext.wtf import Form\nfrom wtforms.fields import (\n StringField,\n IntegerField,\n SubmitField\n)\nfrom wtforms.validators import InputRequired, Length\n\n\...
python
chosen
[ { "from": "system", "value": "Change shortname and class name\n" }, { "from": "human", "value": "'''\nHarvester for the DSpace on LibLiveCD for the SHARE project\n\nExample API call: http://bbytezarsivi.hacettepe.edu.tr/oai/request?verb=ListRecords&metadataPrefix=oai_dc\n'''\nfrom __future__ imp...
python
chosen
[ { "from": "system", "value": "Update context checker by using accessor instead\n" }, { "from": "human", "value": "\"\"\"Utils for preprocessors.\"\"\"\n\n\ndef validate_context(func):\n \"\"\"Validate context in the preprocessor.\"\"\"\n def transform_wrapper(self, *args, **kwargs):\n ...
python
chosen
[ { "from": "system", "value": "Revert \"Make the name of an organization required\"\n\nThis reverts commit 02140561a29a2b7fe50f7bf2402da566e60be641.\n" }, { "from": "human", "value": "from rest_framework import serializers\n\nfrom bluebottle.organizations.models import Organization\nfrom bluebott...
python
chosen
[ { "from": "system", "value": "Send error-type info to pillow error DD metrics\n" }, { "from": "human", "value": "from celery.schedules import crontab\nfrom celery.task import periodic_task\nfrom django.conf import settings\nfrom django.db.models import Count\n\nfrom corehq.util.datadog.gauges im...
python
chosen
[ { "from": "system", "value": "Add proper support for constructor calls to MethodCall\n" }, { "from": "human", "value": "from thinglang.lexer.symbols.base import LexicalAccess\nfrom thinglang.parser.tokens import BaseToken, DefinitionPairToken\nfrom thinglang.parser.tokens.collections import Lis...
python
chosen
[ { "from": "system", "value": "Access to actual or predicted weather done\n" }, { "from": "human", "value": "\"\"\"\nDefinition of a source than add dumb data\n\n\"\"\"\nfrom src.source import Source\n\nclass SourceMock(Source):\n \"\"\"Add a funny key with a funny value in the given dict\"\"\...
python
chosen
[ { "from": "system", "value": "Use scoped session for celery tasks\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport sys\nimport yaml\n\nfrom celery.signals import worker_process_init\nfrom pyvac.helpers.sqla import create_engine\nfrom pyvac.helpers.ldap import LdapCache\nfrom py...
python
chosen
[ { "from": "system", "value": "Update init file in models.geometry" }, { "from": "human", "value": "r\"\"\"\n\n**openpnm.models.geometry**\n\n----\n\nThis submodule contains pore-scale models that calculate geometrical properties\n\n\"\"\"\n\nfrom . import pore_size\nfrom . import pore_seed\nfrom...
python
chosen
[ { "from": "system", "value": "Fix doc string injection of deprecated wrapper\n" }, { "from": "human", "value": "import warnings\nimport functools\n\n\n__all__ = ['deprecated']\n\n\nclass deprecated(object):\n \"\"\"Decorator to mark deprecated functions with warning.\n\n Adapted from <http...
python
chosen
[ { "from": "system", "value": "Fix test for initial registration page flow\n" }, { "from": "human", "value": "import requests\n\n\ndef test_notifications_admin_index():\n response = requests.request(\"GET\", \"http://notifications-admin.herokuapp.com/index\")\n assert response.status_code =...
python
chosen
[ { "from": "system", "value": "Make session cookies have secure and httponly flags by default.\n" }, { "from": "human", "value": "# Copyright 2016 David Tomaschik <david@systemoverlord.com>\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except...
python
chosen
[ { "from": "system", "value": "Fix 'Template is not iterable' error\n" }, { "from": "human", "value": "\n#From http://stackoverflow.com/questions/2687173/django-how-can-i-get-a-block-from-a-template\nfrom django.template import Context\nfrom django.template.loader_tags import BlockNode, ExtendsNo...
python
chosen
[ { "from": "system", "value": "Use backend picker in storefront search form\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nfrom django import forms\nfrom django.utils.translation import pgettext\nfrom .backends import elasticsearch\n\n\nclass SearchForm(forms.Form):...
python
chosen
[ { "from": "system", "value": "Fix a typo in the contents constraints creation.\n" }, { "from": "human", "value": "#------------------------------------------------------------------------------\n# Copyright (c) 2013, Enthought, Inc.\n# All rights reserved.\n#-----------------------------------...
python
chosen
[ { "from": "system", "value": "Clean up arpack build, use the Spack f77 compiler.\n" }, { "from": "human", "value": "from spack import *\n\nclass Arpack(Package):\n \"\"\"FIXME: put a proper description of your package here.\"\"\"\n homepage = \"http://www.caam.rice.edu/software/ARPACK/\"\n...
python
chosen
[ { "from": "system", "value": "Add RandomState to help generate different values, with test\n" }, { "from": "human", "value": "from nose.tools import assert_equal\n\nimport genson\n\ndef test_gaussian_random_seed():\n gson = \\\n \"\"\"\n {\n \"gaussian_random_seed\" : gaussian(0,...
python
chosen
[ { "from": "system", "value": "Update to include vintage in string representation for Wine.\n" }, { "from": "human", "value": "from django.db import models\n\nclass Winery(models.Model):\n title = models.CharField(max_length=150)\n\n def __str__(self):\n return self.title\n\nclass Wi...
python
chosen
[ { "from": "system", "value": "Set feed update timeouts in a more modern way.\n" }, { "from": "human", "value": "import urllib2\nfrom django.core.management.base import BaseCommand\nfrom django_website.apps.aggregator.models import Feed\n\nclass Command(BaseCommand):\n \"\"\"\n Mark people ...
python
chosen
[ { "from": "system", "value": "Add new test for division\n" }, { "from": "human", "value": "import unittest\n\nfrom app.calculator import Calculator\n\n\nclass TestCalculator(unittest.TestCase):\n\n def setUp(self):\n self.calc = Calculator()\n\n def test_calculator_addition_method_r...
python
chosen
[ { "from": "system", "value": "Swap opcodes for if-else and unless-else.\n\nOops.\n" }, { "from": "human", "value": "..compile = import\n..parse.syntax = import\n\n\ncompile.r.builtins !! 'else' = (self, cond, otherwise) ->\n '''\n a if b else c\n a unless b else c\n\n Ternary cond...
python
chosen
[ { "from": "system", "value": "Fix up ICIJ loader as-is\n" }, { "from": "human", "value": "from normality import slugify, stringify\nfrom csv import DictReader\nfrom zipfile import ZipFile\n\n\ndef load_file(context, zip, name):\n fh = zip.open(name)\n _, section, _ = name.rsplit(\".\", 2)\...
python
chosen
[ { "from": "system", "value": "Remove the builtins arguments to the {tal,metal}.execute calls.\n\n\ngit-svn-id: 8b0eea19d26e20ec80f5c0ea247ec202fbcc1090@107 5646265b-94b7-0310-9681-9501d24b2df7\n" }, { "from": "human", "value": "import warnings\n\nfrom dtml import tal, metal, tales, context\n\nfr...
python
chosen
[ { "from": "system", "value": "Use shlex to split parameters\n" }, { "from": "human", "value": "# coding: utf-8\n# 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 http://mozil...
python
chosen
[ { "from": "system", "value": "Change field order and customize Maintenance add_view\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import, unicode_literals\nfrom django.utils.translation import ugettext_lazy as _\nfrom django_services import admin\nfr...
python
chosen
[ { "from": "system", "value": "Fix eventplot for 1d arguments.\n" }, { "from": "human", "value": "__author__ = 'jgosmann'\n\nfrom prettyplotlib.utils import remove_chartjunk, maybe_get_ax\nfrom prettyplotlib.colors import set2\n\n\ndef eventplot(*args, **kwargs):\n ax, args, kwargs = maybe_get...
python
chosen
[ { "from": "system", "value": "Allow running the app from cli\n" }, { "from": "human", "value": "from flask import Flask, render_template\n\napp = Flask(__name__)\n\n\n@app.route('/')\ndef hello():\n return render_template('hello.html')\n" }, { "from": "gpt", "value": "from flask i...
python
chosen
[ { "from": "system", "value": "Consolidate bit_count / popCount methods\n\nFixes https://github.com/fonttools/fonttools/issues/2331\n" }, { "from": "human", "value": "__all__ = ['popCount']\n\n\ndef popCount(v):\n \"\"\"Return number of 1 bits (population count) of an integer.\n\n If the in...
python
chosen
[ { "from": "system", "value": "Enable disk cache for PhJS\n" }, { "from": "human", "value": "# Copyright (C) Ivan Kravets <me@ikravets.com>\n# See LICENSE for details.\n\nfrom subprocess import check_output\nfrom urllib import unquote\n\n\ndef application(env, start_response):\n status = \"200...
python
chosen
[ { "from": "system", "value": "jsonpickle.handler: Remove usage of built-in 'type' name\n\n'type' is a built-in function so use 'cls' instead of 'type'.\n\nSigned-off-by: David Aguilar <9de348c050f7cd1ca590883733c4e531ce610bf4@gmail.com>\n" }, { "from": "human", "value": "class BaseHandler(object...
python
chosen
[ { "from": "system", "value": "Repair 500 viewing contact person\n" }, { "from": "human", "value": "import os\nfrom django.core.urlresolvers import NoReverseMatch\nfrom fluent_contents.models import ContentItem\nfrom fluent_pages.urlresolvers import app_reverse, PageTypeNotMounted\nfrom icekit.pu...
python
chosen
[ { "from": "system", "value": "Correct imports in loc package.\n" }, { "from": "human", "value": "import re\n\nfrom pypods.datasource import DataSource\nfrom pypods.loc.locchannelhandler import LocChannelHandler\n\n\nclass LocDataSource(DataSource):\n def __init__(self):\n super(LocData...
python
chosen
[ { "from": "system", "value": "Make empty tag form valid" }, { "from": "human", "value": "from django.utils.translation import ugettext_lazy as _\nfrom django import forms\nfrom django.contrib.admin.widgets import ForeignKeyRawIdWidget\n\nfrom taggit.forms import TagField\nfrom taggit.utils impor...
python
chosen
[ { "from": "system", "value": "Add utility function to get client IP from request" }, { "from": "human", "value": "from django.shortcuts import render\n\n\ndef get_next(request):\n # This is not a view\n return request.GET.get(\"next\", request.META.get(\"HTTP_REFERER\", \"/\"))\n\n\ndef re...
python
chosen
[ { "from": "system", "value": "Remove shebang line from non-script.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nfrom twisted.protocols import amp\nfrom twisted.cred.error import UnauthorizedLogin\n\n# commands to server side\n\nclass Login(amp.Command):\n arguments = [(\"userna...
python
chosen
[ { "from": "system", "value": "Allow periods and dashes in profile page\n" }, { "from": "human", "value": "\"\"\"\nURLConf for Django user profile management.\n\nRecommended usage is to use a call to ``include()`` in your project's\nroot URLConf to include this URLConf for any URL beginning with\...
python
chosen
[ { "from": "system", "value": "Add check for Heroku before .env import\n\nHeroku was rightfully breaking when loadenv() was called as it already\nhad the proper environment variables. Add a check for Heroku before\nloading the variables.\n" }, { "from": "human", "value": "'''\nThe user login modu...
python
chosen
[ { "from": "system", "value": "Add password change url patterns\n" }, { "from": "human", "value": "from django.conf.urls import url\nfrom django.contrib.auth.views import login, logout, logout_then_login\nfrom .views import SignInView\n\n\nurlpatterns = [\n\n # Authentication\n # ==========...
python
chosen
[ { "from": "system", "value": "Test archive_list returns a dictionary\n" }, { "from": "human", "value": "\"\"\"Test djangopress templatetags.\"\"\"\nfrom django.template import Template, Context\n\n\ndef test_archive_list_tag():\n \"\"\"Test the archive_list tag.\"\"\"\n template_snippet = ...
python
chosen
[ { "from": "system", "value": "Fix Rule: pass convs argument to match\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport json\nfrom webob.exc import status_map\nfrom webob import Response\nfrom .core import cases\nfrom . import filters\n\n__all__ = ['redirect_to', 'http_error', 't...
python
chosen
[ { "from": "system", "value": "Make test_translations test our tree\n\nIn order to run the correct classes, Python test framework adjusts\nsys.path. However, these changes are not propagated to subprocesses.\nTherefore, the test actually tries to test installed Swift, not\nthe one in which it is running.\n\n...
python
chosen
[ { "from": "system", "value": "Change admin columns for slots\n" }, { "from": "human", "value": "\"\"\"Admin for schedule-related models.\"\"\"\n\nfrom pygotham.admin.utils import model_view\nfrom pygotham.schedule import models\n\n# This line is really long because pep257 needs it to be on one l...
python
chosen
[ { "from": "system", "value": "Add version and version_info to exported public API\n" }, { "from": "human", "value": "import re\nimport sys\nfrom collections import namedtuple\n\nfrom .connection import connect, Connection\nfrom .cursor import Cursor\nfrom .pool import create_pool, Pool\n\n\n__al...
python
chosen
[ { "from": "system", "value": "Fix import for new script location.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport sys\n\nimport numpy as np\nimport torch\nfrom learn_pivots_tm import PivotLearnerModel, StraightThroughLayer\n\ndef main(args):\n if len(args) < 1:\n sys...
python
chosen
[ { "from": "system", "value": "Update resolver tests to match new resolver\n" }, { "from": "human", "value": "import gflags\nimport unittest2\n\nfrom mlabns.util import message\nfrom mlabns.util import resolver\n\nclass ResolverTestCase(unittest2.TestCase):\n\n def testDefaultConstructor(self):\...
python
chosen
[ { "from": "system", "value": "Add DHL waybill checksum validation\n" }, { "from": "human", "value": "from .base import Shipper\n\n\nclass DHL(Shipper):\n barcode_pattern = r'^\\d{10}$'\n shipper = 'DHL'\n" }, { "from": "gpt", "value": "from .base import Shipper\n\n\nclass DHL(S...
python
chosen
[ { "from": "system", "value": "MEN-963: Update integrarion tests to use new versioning schema.\n\nSigned-off-by: Maciej Mrowiec <0c5b7bd73e5de492f16f5039ef275802502d5ce2@gmail.com>\n" }, { "from": "human", "value": "import os\nimport logging\n\napi_version = os.getenv(\"MENDER_API_VERSION\", \"0....
python
chosen
[ { "from": "system", "value": "Select ovh-eu entrypoint for test integration\n" }, { "from": "human", "value": "# Test for one implementation of the interface\nfrom unittest import TestCase\nfrom lexicon.providers.ovh import Provider\nfrom lexicon.common.options_handler import env_auth_options\nf...
python
chosen
[ { "from": "system", "value": "Fix a bug involving how mock_state is set\n" }, { "from": "human", "value": "import random\n\nfrom ...mock.mock_abstract_device import MockAbstractDevice\nfrom ..tc335 import TC335\n\n\"\"\"\nMock Lakeshore 335 Temperature Controller\n\"\"\"\n\nclass MockTC335(MockA...
python
chosen
[ { "from": "system", "value": "Make use of Django's StreamingHttpResponse for large CSV exports\n" }, { "from": "human", "value": "import unicodecsv\nfrom django.http import HttpResponse\nfrom django.utils.encoding import smart_str\n\n\ndef export_as_csv_action(description=\"Export selected objec...
python
chosen
[ { "from": "system", "value": "ENH: Add diagnose to f2py package. This makes the tests a bit easier to fix.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\n__all__ = ['run_main','compile','f2py_testing']\n\nimport os\nimport sys\nimport commands\n\nfrom info import __doc__\n\nimport f...
python
chosen
[ { "from": "system", "value": "Add list_display on FileAdmin and download_link def\n" }, { "from": "human", "value": "from django.contrib import admin\nfrom django.contrib.auth import get_user_model\nfrom django.utils import timezone\nfrom django.utils.translation import ugettext_lazy as _\n\nfro...
python
chosen
[ { "from": "system", "value": "Add basic cache test example\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nfrom django.contrib.auth.models import User\nfrom noseperf.testcases import DjangoPerformanceTest\n\n\nclass DjangoSampleTest(DjangoPerformanceTest):\n def t...
python
chosen
[ { "from": "system", "value": "Revert \"Drop extra trailing slash from notices_url\"\n\nThis reverts commit 1eb4d00e005f22ae452ce9d36b9fce69fa9b96f7.\n" }, { "from": "human", "value": "# Python\nimport simplejson\nimport urllib2\n\n# Django\nfrom django.apps import apps\nfrom django.conf import s...
python
chosen
[ { "from": "system", "value": "Use format in export url\n" }, { "from": "human", "value": "from django.conf.urls import url\n\nfrom . import views\n\nurlpatterns = [\n url(r'^(?P<slug>[-\\w_]+)/$',\n views.PlanDetailView.as_view(), name='plan-detail'),\n url('^export/all/$',\n ...
python
chosen
[ { "from": "system", "value": "Add information on Copy command.\n\nAdding extra information to track down mysterious mac build failures.\n\ntbr=bradnelson@google.com\n\ngit-svn-id: 721b910a23eff8a86f00c8fd261a7587cddf18f8@9679 fcba33aa-ac0c-11dd-b9e7-8d5594d729c2\n" }, { "from": "human", "value":...
python
chosen
[ { "from": "system", "value": "Remove the missing view references.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom django.conf import settings\nfrom django.conf.urls import patterns, include, url\nfrom django.views.generic import RedirectView\n\nfrom .views import (AwayView, Disc...
python
chosen
[ { "from": "system", "value": "Add phone and email to user serializer\n" }, { "from": "human", "value": "#from phonenumber_field.serializerfields import PhoneNumberField\nfrom rest_framework import serializers\nfrom drf_extra_fields.geo_fields import PointField\n\nfrom .models import User\n\n\ncl...
python
chosen
[ { "from": "system", "value": "Update StringIO import for Python3 compat\n" }, { "from": "human", "value": "# USEFUL FUNCTIONS DESIGNED FOR TESTS ##############################################################\nimport glob\nimport os\nimport uuid\nfrom django.core.files.base import ContentFile\nfr...
python
chosen
[ { "from": "system", "value": "Fix error type for Python 2\n" }, { "from": "human", "value": "import argparse\nimport os\nfrom six.moves.urllib import request\nimport zipfile\n\n\n\"\"\"Download the MSCOCO dataset (images and captions).\"\"\"\n\n\nurls = [\n 'http://images.cocodataset.org/zips...
python
chosen
[ { "from": "system", "value": "Add support for arguments in request() in tests\n" }, { "from": "human", "value": "import os\nimport tempfile\n\nfrom flask import json\n\nimport tsserver\n\n\n# If set to True, each time the test is run, new database is created as a\n# temporary file. If the value ...
python
chosen
[ { "from": "system", "value": "Create default config if one doesn't exist\n\nFixes #20\n" }, { "from": "human", "value": "import os\nimport sys\n\nimport yaml\n\nfrom photoshell import ui\n\n\nconfig_path = os.path.join(os.environ['HOME'], '.photoshell.yaml')\n\nwith open(config_path, 'r') as con...
python
chosen
[ { "from": "system", "value": "Update test for current evidence aggregation\n" }, { "from": "human", "value": "from nose.plugins.attrib import attr\nfrom indra.sources.tas import process_from_web\n\n\n@attr('slow')\ndef test_processor():\n tp = process_from_web(affinity_class_limit=10)\n as...
python
chosen
[ { "from": "system", "value": "Change Game form score input to select\n" }, { "from": "human", "value": "from django import forms\nfrom django_select2.forms import ModelSelect2MultipleWidget\nfrom django_superform import ModelFormField, SuperForm\n\nfrom .models import Team, Game\nfrom .utils imp...
python
chosen
[ { "from": "system", "value": "Update slack username for JD\n" }, { "from": "human", "value": "import time\nimport random\n\ncrontable = []\noutputs = []\n\nbuddies = [\"tim.jenks\", \"mark.simpson\", \"scott\", \"malcolm.brown\", \"ian.hutchinson\", \"jonty\", \"oliver.norton\", \"vimarsh.raina\...
python
chosen
[ { "from": "system", "value": "Move the notification code to separate methods\n\nDealing with state changes is likely to become a significant bit of\ncode, so move it out into separate methods.\n\nRight now we only log these events, but at least the 'alarm becomes\ntriggered' one is going to need to do activ...
python
chosen
[ { "from": "system", "value": "Add missing docstring for read_key_or_key_file\n" }, { "from": "human", "value": "\"\"\"\nUtility functions.\n\"\"\"\nfrom threema.gateway.key import Key\n\n__all__ = ('read_key_or_key_file',)\n\n\ndef read_key_or_key_file(key, expected_type):\n # Read key file (...
python
chosen