conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Change 'not implemented' log INFO to ERROR\n" }, { "from": "human", "value": "\"\"\"Utilities module for of_core OpenFlow v0x04 operations\"\"\"\nfrom kytos.core import log\nfrom kytos.core.switch import Interface\n\n\ndef update_flow_list(controller, switch):\n ...
python
chosen
[ { "from": "system", "value": "Update test for Map CTP API changes.\n" }, { "from": "human", "value": "from nose.tools import *\nimport os, glob, shutil\n\nimport sys\nsys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..'))\nfrom qipipe.staging import CTPPatientIdMap\n\n# Th...
python
chosen
[ { "from": "system", "value": "Add with back to dial, docstring\n" }, { "from": "human", "value": "from flask import Flask, request\nfrom twilio.twiml.voice_response import VoiceResponse, Dial\n\napp = Flask(__name__)\n\n# Update with your own phone number in E.164 format\nMODERATOR = '+155586753...
python
chosen
[ { "from": "system", "value": "Logging: Deal with the fact that message is now a dict, not an object.\n" }, { "from": "human", "value": "from django.conf import settings\nfrom django.core.mail import get_connection, EmailMessage\n\nfrom celery.task import task\n\n\nCONFIG = getattr(settings, 'CEL...
python
chosen
[ { "from": "system", "value": "Update tdar harvester with custom url gatheriing\n" }, { "from": "human", "value": "\"\"\"\nHarvester for the The Digital Archaeological Record (tDAR) for the SHARE project\n\nMore information at https://github.com/CenterForOpenScience/SHARE/blob/master/providers/or...
python
chosen
[ { "from": "system", "value": "Make calendar not editbale for actors\n" }, { "from": "human", "value": "from django.utils.translation import ugettext_lazy as _\nfrom django.db import models\nfrom django.db.models import DateTimeField, BooleanField, OneToOneField\n\n\nfrom agenda.models import Cal...
python
chosen
[ { "from": "system", "value": "Add initial plaette selection code.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n## @package palette.core.palette_selection\n#\n# Implementation of automatic color palette selection.\n# @author tody\n# @date 2015/08/20\n\n" }, { ...
python
chosen
[ { "from": "system", "value": "Fix crash on empty DB.\n" }, { "from": "human", "value": "from collections import deque, defaultdict\nfrom random import choice\n\nclass SequenceGenerator:\n def __init__(self, order):\n self.order = order\n self.table = defaultdict(list)\n\n def addSample(s...
python
chosen
[ { "from": "human", "value": "Add test runner for use with `python setup.py test`\n" }, { "from": "gpt", "value": "# This file mainly exists to allow `python setup.py test` to work.\nimport os\nimport sys\n\nimport dddp\nimport django\nfrom django.test.utils import get_runner\nfrom django.conf im...
python
chosen
[ { "from": "system", "value": "Add filters to the Mongo DB example.\n" }, { "from": "human", "value": "from chatterbot import ChatBot\nfrom chatterbot.filters import LanguageFilter\nimport logging\n\n\n# Uncomment the following line to enable verbose logging\n# logging.basicConfig(level=logging.I...
python
chosen
[ { "from": "system", "value": "Add is_locked calls to integration test\n" }, { "from": "human", "value": "#!/usr/bin/python\n\nfrom lockd import LockdClient\n\nlockd_client = LockdClient()\n\n# Lock\nassert lockd_client.lock(\"foo\")\n\n# Dup lock should fail\nassert not lockd_client.lock(\"foo\"...
python
chosen
[ { "from": "system", "value": "Add remove and edit on non existing dodocs directories\n" }, { "from": "human", "value": "\"\"\"Test the profile listing and creation\n\nCopyright (c) 2015 Francesco Montesano\nMIT Licence\n\"\"\"\nimport pytest\n\nimport dodocs\n\n\n# fixtures\n@pytest.fixture\ndef...
python
chosen
[ { "from": "system", "value": "Make algorithm configurable, for real this time\n" }, { "from": "human", "value": "from passlib.context import CryptContext\nfrom config import HASH_ROUNDS\n\ncrypt_context = CryptContext(\n schemes=[\"pbkdf2_sha512\"],\n all__vary_rounds=0.1,\n pbkdf2_sha5...
python
chosen
[ { "from": "system", "value": "Fix for python 3 relative import statement\n" }, { "from": "human", "value": "\"\"\"\nImport the main names to top level.\n\"\"\"\n\nfrom . import models as models\nfrom .compute_fp import compute_fixed_point\nfrom .discrete_rv import DiscreteRV\nfrom .ecdf import E...
python
chosen
[ { "from": "system", "value": "Use formencode validators in our updates app, instead of doing hacks\n" }, { "from": "human", "value": "from moksha.lib.base import Controller\nfrom moksha.api.widgets import ContextAwareWidget, Grid\nfrom tg import expose, tmpl_context\n\nclass UpdatesGrid(Grid, Co...
python
chosen
[ { "from": "system", "value": "Use the real send POST params keyword.\n" }, { "from": "human", "value": "\"\"\"\nDDD Integration for OPAL\n\"\"\"\nfrom django.conf import settings\nimport requests\n\nCHANGE_ENDPOINT = settings.DDD_ENDPOINT + 'change/'\nOUR_ENDPOINT = settings.DEFAULT_DOMAIN + '/d...
python
chosen
[ { "from": "system", "value": "Increase MySQL batch size to 10,000.\n\nThis saves 30 seconds in populate_db runtime on MySQL.\n\n(imported from commit 7fe483bf5f32cfa3d09db8ad7a9be79bd0a2a271)\n" }, { "from": "human", "value": "from django.conf import settings\n# batch_bulk_create should become o...
python
chosen
[ { "from": "system", "value": "Make sure filename is a string.\n" }, { "from": "human", "value": "from functools import wraps\nfrom logging import getLogger\nfrom os import getcwd, unlink\nfrom os.path import join, realpath, isfile\n\nfrom psutil import Process\n\n\nlogger = getLogger(__name__)\n...
python
chosen
[ { "from": "system", "value": "Update bridge recipe to limit length\n\nAlso removes bridge at the end\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport time\nfrom picraft import World, Vector, Block\n\nworld = World(ignore_errors=True)\nworld.say('Auto-bridge active')\n\nlast_pos...
python
chosen
[ { "from": "system", "value": "Add fallback to freetype-config for compatibility.\n" }, { "from": "human", "value": "import os\nfrom SCons.Script import *\n\n\ndef configure(conf):\n env = conf.env\n\n conf.CBCheckHome('freetype2',\n inc_suffix=['/include', '/include/fre...
python
chosen
[ { "from": "system", "value": "Change value field in json output\n" }, { "from": "human", "value": "#! /usr/bin/env python2\n# vim: set fenc=utf8 ts=4 sw=4 et :\nimport sys\nimport json\nimport xml.sax\n\nclass PdmlHandler( xml.sax.ContentHandler ):\n def __init__(self):\n self.CurrentData...
python
chosen
[ { "from": "system", "value": "Move flush logic into close\n" }, { "from": "human", "value": "from __future__ import absolute_import\n\nfrom tempfile import NamedTemporaryFile\n\n\nclass LogBuffer(object):\n def __init__(self, chunk_size=4096):\n self.chunk_size = chunk_size\n se...
python
chosen
[ { "from": "system", "value": "Update dtoolcore module summary line\n" }, { "from": "human", "value": "\"\"\"Tool for managing (scientific) data.\n\n\"\"\"\n\n__version__ = \"2.0.0\"\n\n\n" }, { "from": "gpt", "value": "\"\"\"API for creating and interacting with dtool datasets.\n\n\"...
python
chosen
[ { "from": "system", "value": "Fix whois ip search (rename ranges/mult var)\n" }, { "from": "human", "value": "from ipwhois import IPWhois\nimport whois\n\n'''\n############################################\n# WHOIS #\n############################################...
python
chosen
[ { "from": "system", "value": "Move data into owner gdb\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# * coding: utf8 *\n'''\nBemsPallet.py\n\nA module that contains a pallet to update the querable layers behind our UTM basemaps\n'''\n\nfrom forklift.models import Pallet\nfrom os.pat...
python
chosen
[ { "from": "system", "value": "Add a test for the identity, non-negative, and unit-norm constraints\n" }, { "from": "human", "value": "import unittest\nimport numpy as np\nfrom theano import tensor as T\n\nclass TestConstraints(unittest.TestCase):\n def setUp(self):\n self.some_values =...
python
chosen
[ { "from": "system", "value": "Return image type of file in api\n" }, { "from": "human", "value": "from rest_framework import serializers\n\nfrom grandchallenge.cases.models import Image, ImageFile\n\n\nclass ImageFileSerializer(serializers.ModelSerializer):\n class Meta:\n model = Imag...
python
chosen
[ { "from": "system", "value": "Adjust form templatetag to handle missing field var\n\nWhen a non-existant field gets passed, the templatetag was raising an\nunseemly AttributeError. This change checks to see if the passed var is\nactually a form field to avoid said error.\n" }, { "from": "human", ...
python
chosen
[ { "from": "system", "value": "Update 10_condor to use OkSkip functionality\n\ngit-svn-id: 884a03e47e2adb735d896e55bb5ad6bc3421ba19@16522 4e558342-562e-0410-864c-e07659590f8c\n" }, { "from": "human", "value": "import os\nimport osgtest.library.core as core\nimport unittest\n\nclass TestStartCondo...
python
chosen
[ { "from": "system", "value": "Remove RealTimeSearchIndex, gone in Haystack 2.something\n" }, { "from": "human", "value": "from haystack import indexes\nfrom .models import Thread\n\nclass ThreadIndex(indexes.RealTimeSearchIndex, indexes.Indexable):\n text = indexes.CharField(document=True, us...
python
chosen
[ { "from": "system", "value": "Fix in link action. Remove the `_link` method and add action to `_delete`, this fix concurrency problems.\n\nSigned-off-by: messiasthi <8562fc1efba9a3c99753c749fdfb1b6932b70fbf@gmail.com>\n" }, { "from": "human", "value": "import os\nfrom threading import Thread\n\n...
python
chosen
[ { "from": "system", "value": "Fix for data transformer giving no output.\n" }, { "from": "human", "value": "\"\"\"\nDataTransformer\n\n:Authors:\n\tBerend Klein Haneveld\n\"\"\"\n\nfrom vtk import vtkImageReslice\n\n\nclass DataTransformer(object):\n\t\"\"\"DataTransformer is a class that can tr...
python
chosen
[ { "from": "system", "value": "Add comments about pyflakes appeasement\n" }, { "from": "human", "value": "import sys\n\nif sys.version_info[0] < 3:\n from cStringIO import StringIO\n BytesIO = StringIO\nelse:\n from io import BytesIO\n from io import StringIO\n\n_ = BytesIO\n_ = Strin...
python
chosen
[ { "from": "system", "value": "Add a view to the notifications name (for reversing)\n" }, { "from": "human", "value": "from django.conf.urls import url\n\nfrom . import views\n\nurlpatterns = [\n url(r'^notifications$', views.create_notification),\n]\n" }, { "from": "gpt", "value":...
python
chosen
[ { "from": "system", "value": "Clean Azure images before snapshot\n\nFor waagent to provision the following file must not exist:\n/var/lib/waagent/provisioned\n" }, { "from": "human", "value": "import os\nimport sys\nimport logging\n\n_g_logger = logging.getLogger(__name__)\n\n\ndef main(bin_path...
python
chosen
[ { "from": "system", "value": "Add codelist xml parsing TODO\n" }, { "from": "human", "value": "from lxml import etree\n\nimport iati.core.resources\n\nclass Codelist(object):\n \"\"\"Representation of a Codelist as defined within the IATI SSOT\"\"\"\n\n def __init__(self, name=None, path=N...
python
chosen
[ { "from": "system", "value": "Allow connecting froide_campaigns to campaign app" }, { "from": "human", "value": "from .utils import connect_foirequest\n\n\ndef connect_campaign(sender, **kwargs):\n reference = kwargs.get('reference')\n if not reference:\n return\n parts = referen...
python
chosen
[ { "from": "system", "value": "Fix integrity error reusing db in tests\n\nBase `setUpClass` needs to be called first so the transaction is initialized\nbefore we mutate the data.\n\nThis solves a conflic raised when using `--reuse-db`.\n" }, { "from": "human", "value": "from django.contrib.auth.m...
python
chosen
[ { "from": "system", "value": "Make turbinia-psq the default pubsub queue name\n" }, { "from": "human", "value": "# Copyright 2016 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obt...
python
chosen
[ { "from": "system", "value": "Fix: Fix a compatible bug. Response data is binary in Python 3.\n" }, { "from": "human", "value": "# -*- encoding: utf-8 -*-\n\nimport os\nimport unittest\nfrom stonemason.service.tileserver import AppBuilder\n\n\nclass TestExample(unittest.TestCase):\n def setUp...
python
chosen
[ { "from": "system", "value": "Allow arbitrary parameters to be passed\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nimport flask\n\nfrom . import rendering\nfrom . import task1, task2\n\n\ndef app_factory():\n \"\"\"Create a new Flask instance and configure the URL map.\"\"\"\...
python
chosen
[ { "from": "system", "value": "Tweak to a noisy test module\n" }, { "from": "human", "value": "import unittest\nimport sys\nprint([m for m in sys.modules if m.startswith('urllib')])\n\nclass MyTest(unittest.TestCase):\n def test_urllib(self):\n import urllib\n print(urllib.__file...
python
chosen
[ { "from": "system", "value": "Fix the naming of the newly created resources\n" }, { "from": "human", "value": "import datetime\nimport json\nimport sys\n\nimport ffs\nimport re\n\nfrom publish.lib.helpers import filename_for_resource, download_file\nfrom publish.lib.upload import Uploader\n\n\nd...
python
chosen
[ { "from": "system", "value": "Update master version to reflect dev status.\n" }, { "from": "human", "value": "\"\"\"\ndjango-all-access is a reusable application for user registration and authentication\nfrom OAuth 1.0 and OAuth 2.0 providers such as Twitter and Facebook.\n\"\"\"\n\n\n__version_...
python
chosen
[ { "from": "system", "value": "Fix spacing in the filter script\n\nConflicting file loading directives in Vim screwed up the tab stops.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport sys\nimport re\n\nNUMBER_REGEX = re.compile(r'([0-9])([a-z])')\n\ndef to_camel_case(text):\n\t...
python
chosen
[ { "from": "system", "value": "Add docstring. 4 spaces for consistency.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\ncookiecutter.utils\n------------------\n\nHelper functions used throughout Cookiecutter.\n\"\"\"\n\nimport errno\nimport os\nimport ...
python
chosen
[ { "from": "system", "value": "Update urlpatterns to use list of url()\n" }, { "from": "human", "value": "from django.conf.urls import patterns, url\nfrom s3direct.views import get_upload_params\n\nurlpatterns = patterns('',\n url('^get_upload_params/',\n ...
python
chosen
[ { "from": "system", "value": "Return all data instead of just mask data\n" }, { "from": "human", "value": "from PIL import Image\nimport glob\n\n\ndef _get_masks():\n TRAIN_MASKS = './data/train/*_mask.tif'\n return [Image.open(file_name) for file_name in glob.glob(TRAIN_MASKS)]\n\n\n\n\n\...
python
chosen
[ { "from": "system", "value": "Set Content-Type header for S3 uploads\n\nCurrent document updates do not preserve the content type - it is reset to \"application/octet-stream\"\nWe should set the correct content type so that browsers know what to do when users access the documents.\n" }, { "from": "h...
python
chosen
[ { "from": "system", "value": "Revert trying to fix activation redirection bug\n\nThis reverts commit c2d63335062abea4cece32bd01132bcf8dce44f2.\nIt seems like the commit doesn't actually do anything to alleviate the\nbug. Since it's also more lenient with its checks, I'll rather revert\nit.\n" }, { "...
python
chosen
[ { "from": "system", "value": "Change fhir practitioner url and add organization url\n" }, { "from": "human", "value": "from __future__ import absolute_import\nfrom __future__ import unicode_literals\n\nfrom django.conf.urls import patterns, include, url\n\nfrom .views import *\n\n\nurlpatterns =...
python
chosen
[ { "from": "system", "value": "Clean the base device class.\n" }, { "from": "human", "value": "\nfrom moa.threading import CallbackQueue\nfrom moa.base import MoaBase\nfrom kivy.properties import BooleanProperty\nfrom kivy.clock import Clock\ntry:\n from Queue import Queue\nexcept ImportError:...
python
chosen
[ { "from": "system", "value": "Use six.moves to reference `reload`.\n\nPiperOrigin-RevId: 253199825\nChange-Id: Ifb9bf182572900a813ea1b0dbbda60f82495eac1\n" }, { "from": "human", "value": "# Copyright 2019 The Sonnet Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2...
python
chosen
[ { "from": "system", "value": "Add two balls to animation\n" }, { "from": "human", "value": "#!/usr/bin/env python\nfrom rgbmatrix import RGBMatrix\nimport sys, time\nfrom ball import Ball\n\nrows = 16\nchains = 1\nparallel = 1\nledMatrix = RGBMatrix(rows, chains, parallel)\n\nnumRows = 16\nheigh...
python
chosen
[ { "from": "system", "value": "Use aospy coord label constants\n" }, { "from": "human", "value": "\"\"\"aospy_user: Library of user-defined aospy objects.\"\"\"\nfrom . import regions\nfrom . import units\nfrom . import calcs\nfrom . import variables\nfrom . import runs\nfrom . import models\nfro...
python
chosen
[ { "from": "system", "value": "[antenna] Remove unnecessary logger configuration from integration tests.\n" }, { "from": "human", "value": "import logging\r\nimport os\r\nimport colorlog\r\nimport extensions\r\n\r\n\r\nif os.getenv(\"CLICOLOR_FORCE\") == \"1\":\r\n print \"Forcing colors\"\r\n...
python
chosen
[ { "from": "system", "value": "Add empty draw_heights method and docstrings to Terrain2D\n" }, { "from": "human", "value": "\"\"\"Module for displaying Terrain, both in 2D and 3D.\n\n(Not accessible outside of package; use display methods of Terrain instead.)\n\n\"\"\"\n\nfrom Tkinter import Tk, ...
python
chosen
[ { "from": "system", "value": "Fix of vendor directory search.\n" }, { "from": "human", "value": "import sys\nimport os\n\n_vendor_initialized = False\n\ndef append_paths(path, vendor_modules):\n new_path = []\n for v in vendor_modules:\n new_path.append(path + os.sep + v)\n sys.p...
python
chosen
[ { "from": "system", "value": "Debug and add test case\n" }, { "from": "human", "value": "# Sort list using recursion\n\ndef quick_sort(lst):\n\tif len(lst) == 0:\n\t\tprint []\n\n\tleft = []\n\tright = []\n\tpivot = lst[0]\n\n\t# compare first element in list to the rest\n\tfor i in range(1, len...
python
chosen
[ { "from": "system", "value": "Add test for transfer control resend otp\n" }, { "from": "human", "value": "import httpretty\n\nfrom paystackapi.tests.base_test_case import BaseTestCase\nfrom paystackapi.tcontrol import TransferControl\n\n\nclass TestTransfer(BaseTestCase):\n\n @httpretty.activ...
python
chosen
[ { "from": "system", "value": "Use find instead of split\n" }, { "from": "human", "value": "import MeCab\n\nclass MeCabParser(object):\n def __init__(self, arg=''):\n self.model = MeCab.Model_create(arg)\n \n def parse(self, s):\n tagger = self.model.createTagger()\n ...
python
chosen
[ { "from": "system", "value": "Return as array; start of finding shell fraction\n" }, { "from": "human", "value": "\nimport numpy as np\n\n\nclass Bubble2D(object):\n \"\"\"\n Class for candidate bubble portions from 2D planes.\n \"\"\"\n def __init__(self, props):\n super(Bubb...
python
chosen
[ { "from": "system", "value": "Add JSONP notice to API" }, { "from": "human", "value": "from flask import jsonify, request\nfrom functools import wraps\nimport json\n\ndef json_output(f):\n @wraps(f)\n def wrapper(*args, **kwargs):\n def jsonify_wrap(obj):\n callback = req...
python
chosen
[ { "from": "system", "value": "Fix calculation of model size\n\n" }, { "from": "human", "value": "import subprocess\nimport re\nimport os\nfrom lib.utils import loadYaml\n\nconfig = loadYaml('../config.yml')\n\ndimensionsRegex = r'{type} = +(\\-?\\d+\\.\\d+)'\ntypes = {\n 'x': ['Min X', 'Max X']...
python
chosen
[ { "from": "system", "value": "Return iterator instead of list in paginator\n" }, { "from": "human", "value": "from django.core.paginator import Paginator\n\n\nclass HCPaginator(Paginator):\n adjacent_pages = 5\n\n def page(self, number):\n self.page_num = number\n return supe...
python
chosen
[ { "from": "system", "value": "Update model used to test\n" }, { "from": "human", "value": "# -*- coding: utf-8\nfrom __future__ import unicode_literals\n\nfrom django.test import TestCase\n\nfrom shop.models.cart import BaseCartItem\n\n\nclass JSONFieldTest(TestCase):\n \"\"\"JSONField Wrappe...
python
chosen
[ { "from": "system", "value": "Mark conference and language as required\n" }, { "from": "human", "value": "from django import forms\n\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom api.forms import GrapheneModelForm\nfrom languages.models import Language\nfrom conferences.models...
python
chosen
[ { "from": "system", "value": "Create required known_hosts file if it does not exists\n" }, { "from": "human", "value": "import os\nimport logging\n\nfrom ...subprocess import check_output\n\ndef _get_known_hosts_path():\n ssh_dir = os.path.expanduser('~root/.ssh')\n if not os.path.isdir(ss...
python
chosen
[ { "from": "system", "value": "Fix missing githubIssue field when the corresponding issue already existed.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom AbstractVisitor import AbstractVisitor\n\nfrom duralex.alinea_parser import *\n\nfrom github import Github\n\nclass AddGitH...
python
chosen
[ { "from": "system", "value": "Add a testinfra group example\n" }, { "from": "human", "value": "def test_confluence_user(User):\n user = User(\"confluence\")\n\n assert user.exists\n assert user.group == \"confluence\"\n" }, { "from": "gpt", "value": "def test_confluence_user...
python
chosen
[ { "from": "system", "value": "test: Use numpy.testing.assert_allclose with small relative tolerance\n\nTo avoid having numpy.testing.assert_equal fail in some cases at the\nlevel of machine precision, use numpy.testing.assert_allclose instead\nwith a relative tolerance set small, 1e-10, to still be restrict...
python
chosen
[ { "from": "system", "value": "Fix module path (config -> config_yaml) to unbreak test.\n" }, { "from": "human", "value": "#!/usr/bin/python\n#\n# Copyright 2014 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance w...
python
chosen
[ { "from": "system", "value": "Add check for logging state\n" }, { "from": "human", "value": "# encoding: utf-8\n\n\"\"\"\n.. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>\n\"\"\"\n\nfrom __future__ import absolute_import, unicode_literals\n\nimport sqliteschema\nimport tabledata\n...
python
chosen
[ { "from": "system", "value": "Fix silly boiler plate copy issue.\n" }, { "from": "human", "value": "from .probability import (\n vs,\n Variable,\n make_variables,\n UniformDist,\n JointDist,\n JointDistByState\n)\n\nfrom .network import CausalGraph, Equation\n\nfrom .measure im...
python
chosen
[ { "from": "system", "value": "Return None if key is not found\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, recurse=None, keys=None):\n u...
python
chosen
[ { "from": "system", "value": "Set login view for login_required\n" }, { "from": "human", "value": "\"\"\"\nThe flask application package.\n\"\"\"\n\nfrom flask import Flask\nfrom flask.ext import login\nimport models\n\napp = Flask(__name__)\n\n# Flask-Login initialization\nlogin_manager = login...
python
chosen
[ { "from": "system", "value": "Add fixture for Namespace specifically.\n" }, { "from": "human", "value": "import pytest\n\n\n@pytest.fixture\ndef namespaces():\n import class_namespaces\n return class_namespaces\n\n\n@pytest.fixture\ndef compat():\n import class_namespaces.compat\n re...
python
chosen
[ { "from": "system", "value": "Load content from raw_url if empty\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"\ngithub3.gists.file\n------------------\n\nModule containing the logic for the GistFile object.\n\"\"\"\nfrom __future__ import unicode_literals\n\nimport requests\...
python
chosen
[ { "from": "system", "value": "Update to v1.6.1 for release\n\n- Replace egg distribution format with wheels (#314)\n- Internal maintenance\n" }, { "from": "human", "value": "# single source of truth for package version,\n# see https://packaging.python.org/en/latest/single_source_version/\n__vers...
python
chosen
[ { "from": "system", "value": "Add placeholder for CSV file\n" }, { "from": "human", "value": "from collections import OrderedDict\nimport os\nimport sys\nimport json\n\n\ntry:\n gb_home = os.environ[\"GB_HOME\"]\nexcept KeyError:\n raise RuntimeError(\"Please set the environment variable GB_...
python
chosen
[ { "from": "system", "value": "Add new modules to package init.\n" }, { "from": "human", "value": "\n__all__ = [\n 'api',\n 'calls',\n 'entities',\n]\n" }, { "from": "gpt", "value": "\n__all__ = [\n 'api',\n 'calls',\n 'entities',\n 'exceptions',\n 'utils',\n]\...
python
chosen
[ { "from": "system", "value": "Add testcases for jit and njit with forceobj and nopython\n" }, { "from": "human", "value": "import numba\n\nfrom numba.tests.support import TestCase\nimport unittest\n\n\nclass TestNumbaModule(TestCase):\n \"\"\"\n Test the APIs exposed by the top-level `numb...
python
chosen
[ { "from": "system", "value": "Revert \"log to file, don't email\"\n\nThis reverts commit a132890ef32c99b938021717b67c3e58c13952b0.\n" }, { "from": "human", "value": "import logging\n\nfrom django.middleware.csrf import CsrfViewMiddleware, REASON_NO_CSRF_COOKIE, REASON_BAD_TOKEN\nfrom django.conf...
python
chosen
[ { "from": "system", "value": "Revert \"Added nickname and punct, removed parens\"\n\nThis reverts commit 061de1a57a95cd2911c06bb58c29a8e488b7387e.\n" }, { "from": "human", "value": "import random\n\nateball = [\n \"It is certain.\",\n \"It is decidedly so.\",\n \"Without a d...
python
chosen
[ { "from": "system", "value": "Access the conf like a object\n" }, { "from": "human", "value": "\"\"\" Read configuration for a service from a json file \"\"\"\n\nimport io\nimport json\n\nfrom .client import Client\nfrom .error import ConfigError\n\n\ndef load(filepath=None, filecontent=None, cl...
python
chosen
[ { "from": "system", "value": "Enable the SmartyPants filter; need to document it later\n\n\ngit-svn-id: 4b29f3e8959dfd6aa2f99bd14fd314e33970d95d@74 d6b9e1ad-042d-0410-a639-15a354c1509c\n" }, { "from": "human", "value": "\"\"\"\nFilters for converting plain text to HTML and enhancing the\ntypogra...
python
chosen
[ { "from": "system", "value": "Remove some debug logging config\n" }, { "from": "human", "value": "default_app_config = 'promgen.apps.PromgenConfig'\nimport logging\nlogging.basicConfig(level=logging.DEBUG)\n" }, { "from": "gpt", "value": "default_app_config = 'promgen.apps.PromgenCon...
python
chosen
[ { "from": "system", "value": "Handle wrong order of middleware.\n" }, { "from": "human", "value": "def has_permission(request):\n user = request.user\n if user:\n if user.is_superuser:\n return True\n\n if user.is_staff and user.groups.filter(name__iexact='djedi')....
python
chosen
[ { "from": "system", "value": "Fix MorphingField: polymorphic_identy is already the string we want\n" }, { "from": "human", "value": "from marshmallow.fields import Field\n\n\nclass MorphingField(Field):\n\n # registry = {\n # }\n\n def __init__(self, many=False, fallback=None, overwrite...
python
chosen
[ { "from": "system", "value": "Fix wards code sequences restart\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom django.db import models, migrations\nfrom facilities.models import Facility\n\ndef set_min_code_value(apps, schema_editor):\n from django.db import connection\n c...
python
chosen
[ { "from": "system", "value": "Fix log test to use real user and id\n" }, { "from": "human", "value": "from nose import tools as nt\n\nfrom tests.base import AdminTestCase\n\nfrom osf.models.admin_log_entry import AdminLogEntry, update_admin_log\n\n\nclass TestUpdateAdminLog(AdminTestCase):\n ...
python
chosen
[ { "from": "system", "value": "Add migration for assigning security groups\n" }, { "from": "human", "value": "##############################################################################\n#\n# Copyright (C) 2018 Compassion CH (http://www.compassion.ch)\n# @author: Nathan Flückiger <nathan...
python
chosen
[ { "from": "system", "value": "Apply default_auto_field to app config.\n" }, { "from": "human", "value": "from django.apps import AppConfig\n\n\nclass AuditlogConfig(AppConfig):\n name = \"auditlog\"\n verbose_name = \"Audit log\"\n" }, { "from": "gpt", "value": "from django.app...
python
chosen
[ { "from": "system", "value": "[Discord] Handle package not found in pypi command\n\n" }, { "from": "human", "value": "\nfrom discord.ext import commands\n\nfrom utilities import checks\n\ndef setup(bot):\n\tbot.add_cog(Python())\n\nclass Python(commands.Cog):\n\t\n\tasync def cog_check(self, ctx...
python
chosen
[ { "from": "system", "value": "Fix gateway lag being negative in d?ping\n" }, { "from": "human", "value": "\"\"\"\nCommands used to check the health of the bot.\n\"\"\"\nimport datetime\nfrom time import monotonic\n\nfrom dog import Cog\n\nfrom discord.ext import commands\n\n\nclass Health(Cog):\...
python
chosen
[ { "from": "system", "value": "Support for multiple subjects and filtering out non-wos ids\n" }, { "from": "human", "value": "#!/usr/bin/env python3\nfrom util.misc import open_file, Benchmark\nfrom util.PajekFactory import PajekFactory\nimport ujson\n\n\nif __name__ == \"__main__\":\n import ...
python
chosen
[ { "from": "system", "value": "Use importlib.import_module instead of __import__.\n" }, { "from": "human", "value": "import builtins\nimport operator\nimport functools\n\nfrom ..compile import varary\n\n\nbuiltins.__dict__.update({\n # Runtime counterparts of some stuff in `Compiler.builtins`....
python
chosen
[ { "from": "system", "value": "Remove saved file in TestImageSaveBlock test case\n" }, { "from": "human", "value": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\nimport unittest\nimport cv\n\nimport os, sys\ncmd_folder, f = os.path.split(os.path.dirname(os.path.abspath(__file__)))\nif cmd_folder ...
python
chosen
[ { "from": "system", "value": "Add a sort of hierarchy of modules for package\n" }, { "from": "human", "value": "# Copyright (C) 2017 Google Inc.\n# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>\n\nfrom lib.page.modal import (\n create_new_object, # flake8: noqa...
python
chosen
[ { "from": "system", "value": "Handle webservice problems in ChEBI client\n" }, { "from": "human", "value": "import suds\nimport re\nimport logging\n\nlogger = logging.getLogger('suds')\nlogger.setLevel(logging.ERROR)\n\nchebi_wsdl = 'http://www.ebi.ac.uk/webservices/chebi/2.0/webservice?wsdl'\nc...
python
chosen