conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "ENH: Add `_BoolLike` to the union defining `_IntLike`\n" }, { "from": "human", "value": "from typing import Union, Tuple, Any\n\nimport numpy as np\n\n# NOTE: `_StrLike` and `_BytesLike` are pointless, as `np.str_` and `np.bytes_`\n# are already subclasses of their ...
python
chosen
[ { "from": "system", "value": "Change default baud rate to 230400 to match cantranslator.\n" }, { "from": "human", "value": "\"\"\"A virtual serial port data source.\"\"\"\nfrom __future__ import absolute_import\n\nimport logging\n\nfrom .base import BytestreamDataSource, DataSourceError\n\nLOG =...
python
chosen
[ { "from": "system", "value": "Add pagination to the reinstated search view\n" }, { "from": "human", "value": "# views.py\n\nfrom django.shortcuts import render\n\nfrom wagtail.core.models import Page\nfrom wagtail.search.models import Query\n\n\ndef search(request):\n # Search\n search_que...
python
chosen
[ { "from": "system", "value": "Refactor email task variable names\n" }, { "from": "human", "value": "from decimal import Decimal\n\nfrom django.conf import settings\nfrom django.core.mail import EmailMessage\n\nfrom celery.utils.log import get_task_logger\n\nfrom .csv_attach import CSVAttachmentW...
python
chosen
[ { "from": "system", "value": "Use list comprehension to generate MeetupPresentor list in index view\n" }, { "from": "human", "value": "from django.contrib.auth import authenticate, login, logout\nfrom django.shortcuts import render, redirect\n\nfrom meetuppizza.forms import RegistrationForm\nfro...
python
chosen
[ { "from": "system", "value": "Remove unused imports\nOnly define MsgPackEngine if we can import MsgPack\n" }, { "from": "human", "value": "\nimport json\ntry:\n import msgpack\nexcept ImportError:\n pass\n\nfrom decimal import Decimal\nfrom datetime import date, datetime, time\n\nclass Eng...
python
chosen
[ { "from": "system", "value": "Create argument to select month to import\n" }, { "from": "human", "value": "import numpy\n\n\ndef import_climate_data():\n ncols = 720\n nrows = 360\n digits = 5\n\n with open('./data/cloud/ccld6190.dat') as filein:\n lines = filein.readlines()\n...
python
chosen
[ { "from": "system", "value": "Fix typos in name of imports.\n" }, { "from": "human", "value": "from __future__ import absolute_import\nfrom .seqfile import findNextFile\n\nimport pgk_ressources as _pkg\n\n__version__ = _pkg.get_distribution(\"seqfile\").version\n\n__all__ = [ 'findNextFile' ]\n"...
python
chosen
[ { "from": "system", "value": "Allow negative values, only mask -9999\n" }, { "from": "human", "value": "import numpy\n\n\ndef import_climate_data(filepath, monthnr):\n ncols = 720\n nrows = 360\n digits = 5\n\n with open(filepath, 'r') as filein:\n lines = filein.readlines()\n...
python
chosen
[ { "from": "system", "value": "Update tests for new API routes\n" }, { "from": "human", "value": "import os\n\nimport pytest\nimport requests\n\n\n@pytest.fixture\ndef url():\n return os.getenv(\"SITE\", \"http://localhost:5000\")\n\n\ndef test_post_images(expect, url):\n params = {\"key\":...
python
chosen
[ { "from": "system", "value": "Use pgpkeys.mit.edu as our keyserver; seems to work.\n" }, { "from": "human", "value": "import celery\nimport subprocess\n\nfrom bidb.utils.tempfile import TemporaryDirectory\nfrom bidb.utils.subprocess import check_output2\n\nfrom .models import Key\n\n\n@celery.ta...
python
chosen
[ { "from": "system", "value": "Fix bug in mondegreen rule\n\n(The correct versions should all be in the left column.)\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"Mondegreens.\n\n---\nlayout: post\nsource: Garner's Modern American Usage\nsource_url: http://amzn.to/15w...
python
chosen
[ { "from": "system", "value": "Add more careful version checks\n" }, { "from": "human", "value": "# License information goes here\n# -*- coding: utf-8 -*-\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n# The line above will help with 2to3 support.\ndef most_r...
python
chosen
[ { "from": "system", "value": "Switch which name is used as a metadata key\n" }, { "from": "human", "value": "'''\nMain interface to BSE functionality\n'''\n\nfrom . import io\n\n\ndef get_basis_set(name):\n '''Reads a json basis set file given only the name\n\n The path to the basis set fi...
python
chosen
[ { "from": "system", "value": "Remove selection of all raw_log rows, since it was used for debugging\npurposes only\n" }, { "from": "human", "value": "def form():\n\tdb.raw_log.uuid.default = uuid_generator()\n\tdb.raw_log.date.default = dbdate()\n\t#don't display form items that are part of tabl...
python
chosen
[ { "from": "system", "value": "Fix typo in author FactorLibre\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n##############################################################################\n#\n# Author: Hugo Santos\n# Copyright 2015 FactorLibre\n#\n# This program is free soft...
python
chosen
[ { "from": "system", "value": "Create Page for every glyph\n" }, { "from": "human", "value": "# Some configuration\npage_format = 'A4'\nnewPage(page_format)\n\n\nclass RegisterGlyph(object):\n \n def __init__(self, glyph):\n self.glyph = glyph\n print 'Registered', self.glyph....
python
chosen
[ { "from": "system", "value": "Make sure to properly set private for existing private programs.\n" }, { "from": "human", "value": "\n\"\"\"Add private column to programs table.\n\nRevision ID: 49c670c7d705\nRevises: a3afeab3302\nCreate Date: 2013-12-09 16:44:54.222398\n\n\"\"\"\n\n# revision iden...
python
chosen
[ { "from": "system", "value": "Make timeslot a FK on talk model\n" }, { "from": "human", "value": "from django.db import models\n\nclass Event(models.Model):\n name = models.CharField(max_length=1024, unique=True)\n slug = models.SlugField(max_length=1024)\n \n def __str__(self):\n ...
python
chosen
[ { "from": "system", "value": "Revert year range end back to 2015 (2016 is not over)\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport sys\nimport os\nimport collections\n\nimport data\nimport figs\n\nclass Counter(collections.Counter):\n year_range = range(2004, 2016)\n\n de...
python
chosen
[ { "from": "system", "value": "Add default view for camera\n" }, { "from": "human", "value": "from traits.api import HasTraits, Int, Str, Tuple, Array, Range\r\n\r\n\r\nclass CameraError(Exception):\r\n def __init__(self, msg, cam):\r\n self.msg = msg\r\n self.camera_number = cam...
python
chosen
[ { "from": "system", "value": "Allow for the failure of getServiceInfo(). Not sure why it's happening,\nthough.\n" }, { "from": "human", "value": "from Zeroconf import *\r\nimport socket\r\n\r\nclass MyListener(object):\r\n\tdef __init__(self):\r\n\t\tself.r = Zeroconf()\r\n\t\tpass\r\n\r\n\tdef ...
python
chosen
[ { "from": "system", "value": "Add the language code to the translated file\n" }, { "from": "human", "value": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\nimport sys\r\nimport os.path\r\nimport codecs\r\nimport dfstrings\r\nimport time\r\n\r\ndef make_js_from_po(path):\r\n strings = []\r\n ...
python
chosen
[ { "from": "system", "value": "Fix test so it does not emit output.\n" }, { "from": "human", "value": "# Copyright 2014 Scalyr 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 obtain a copy ...
python
chosen
[ { "from": "system", "value": "Update import of serializers for python3 compatibility\n" }, { "from": "human", "value": "from handover_api.models import User, Handover, Draft\nfrom rest_framework import viewsets\nfrom serializers import UserSerializer, HandoverSerializer, DraftSerializer\n\n\ncla...
python
chosen
[ { "from": "system", "value": "Add TRIPS reading option to RAS pathway map\n" }, { "from": "human", "value": "import sys\nimport pickle\nfrom indra import reach\nfrom indra.assemblers import GraphAssembler\n\nif len(sys.argv) < 2:\n process_type = 'text'\nelse:\n process_type = sys.argv[1]\...
python
chosen
[ { "from": "system", "value": "Drop `yield from` to keep compat w/ 2.7\n" }, { "from": "human", "value": "import threading\nimport time\n\nimport pytest\n\nimport cheroot.server\nimport cheroot.wsgi\n\n\nconfig = {\n 'bind_addr': ('127.0.0.1', 54583),\n 'wsgi_app': None,\n}\n\n\ndef cheroot...
python
chosen
[ { "from": "system", "value": "Test if `__distarray__()['buffer']` returns a buffer." }, { "from": "human", "value": "import unittest\nimport distarray as da\nfrom distarray.mpi.mpibase import create_comm_of_size, InvalidCommSizeError\n\n\nclass TestDistributedArrayProtocol(unittest.TestCase):\n\...
python
chosen
[ { "from": "system", "value": "Remove 'current' tag from FiWareSeleniumTestCase\n" }, { "from": "human", "value": "from wirecloudcommons.test import WirecloudSeleniumTestCase\n\n\n__test__ = False\n\n\nclass FiWareSeleniumTestCase(WirecloudSeleniumTestCase):\n\n tags = ('current',)\n\n def ...
python
chosen
[ { "from": "system", "value": "Add print statements to debug BlogPostListView\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nfrom __future__ import unicode_literals\n\nfrom staticgen.staticgen_pool import staticgen_pool\nfrom staticgen.staticgen_views import StaticgenView\n\nfrom ....
python
chosen
[ { "from": "system", "value": "Fix type annotation for context manager\n" }, { "from": "human", "value": "from contextlib import contextmanager\nfrom contextlib import suppress\nfrom os import close\nfrom os import remove\nfrom tempfile import mkstemp\n\n\ndef create_tempfilename() -> str:\n f...
python
chosen
[ { "from": "system", "value": "Fix for Database access not allowed, use the \"django_db\" mark to enable it.\n" }, { "from": "human", "value": "from django.contrib.auth import get_user_model\n\nfrom rest_framework_json_api import serializers\nfrom rest_framework_json_api.renderers import JSONRend...
python
chosen
[ { "from": "system", "value": "Fix update_wordpress_user for missing email\n" }, { "from": "human", "value": "from django.conf import settings\n\nfrom .tasks import (\n update_wordpress_user as update_wordpress_user_task,\n update_wordpress_role as update_wordpress_role_task\n)\n\n\ndef upd...
python
chosen
[ { "from": "system", "value": "tests: Check that machine module exists and print SKIP if it doesn't.\n" }, { "from": "human", "value": "# test machine module\n\nimport machine\nimport uctypes\n\nprint(machine.mem8)\n\nbuf = bytearray(8)\naddr = uctypes.addressof(buf)\n\nmachine.mem8[addr] = 123\n...
python
chosen
[ { "from": "system", "value": "Fix tests now that we have H1 capturing\n" }, { "from": "human", "value": "import os\n\nfrom django.test import TestCase\n\nfrom search.parse_json import process_file\n\nbase_dir = os.path.dirname(os.path.dirname(__file__))\n\nclass TestHacks(TestCase):\n\n def t...
python
chosen
[ { "from": "system", "value": "Remove 'u' prefix from strings\n" }, { "from": "human", "value": "import json\nimport unittest\n\nimport awacs.aws as aws\nimport awacs.s3 as s3\n\n\nclass TestConditions(unittest.TestCase):\n def test_for_all_values(self):\n c = aws.Condition(\n ...
python
chosen
[ { "from": "system", "value": "Disable test on Python 2.6.\n" }, { "from": "human", "value": "import sys\nimport subprocess\nimport re\n\n\ndef test_runpy_invoke():\n \"\"\"\n Ensure honcho can also be invoked using runpy (python -m)\n \"\"\"\n cmd = [sys.executable, '-m', 'honcho', '...
python
chosen
[ { "from": "system", "value": "Work on master is now 1.5 dev work\n" }, { "from": "human", "value": "\"\"\"\nClient for Swift\n\nCopyright 2012 Gregory Holt\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou ...
python
chosen
[ { "from": "system", "value": "Improve my bot according to tutorial\n" }, { "from": "human", "value": "from hlt import *\nfrom networking import *\n\nmyID, gameMap = getInit()\nsendInit(\"MyPythonBot\")\n\nwhile True:\n moves = []\n gameMap = getFrame()\n for y in range(gameMap.height):\...
python
chosen
[ { "from": "system", "value": "Change urllib test to use an explicit import\n" }, { "from": "human", "value": "from __future__ import absolute_import, print_function\n\nimport unittest\nimport sys\n\nclass ImportUrllibTest(unittest.TestCase):\n def test_urllib(self):\n \"\"\"\n T...
python
chosen
[ { "from": "system", "value": "Fix the docstring of create_plugin_base: Not internal, it's the main API\n" }, { "from": "human", "value": "from types import SimpleNamespace\n\nfrom django.db import models\n\n\n__all__ = (\"Region\", \"Template\", \"create_plugin_base\")\n\n\nclass Region(SimpleNa...
python
chosen
[ { "from": "system", "value": "Fix bug in iteritems on SCAN_MODULES.\n\nChange-Id: Ifa58f29a9e69ad46b44c301244525d711b43faca\nReviewed-on: http://review.pozytywnie.pl:8080/2340\nReviewed-by: Tomasz Wysocki <f17c2dc043305c950a029074ababd304e0373387@gmail.com>\nTested-by: Tomasz Wysocki <f17c2dc043305c950a0290...
python
chosen
[ { "from": "system", "value": "Add link for distance computation\n" }, { "from": "human", "value": "import numpy as np\n\n\ndef fast_distance(lat1, lon1, lat2, lon2):\n '''Compute the arc distance assuming the earth is a sphere.'''\n g = np.sin(lat1)*np.sin(lat2)+np.cos(lat1)*np.cos(lat2)*n...
python
chosen
[ { "from": "system", "value": "Implement plugin test on exception handling\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom nailgun.test.base import BaseHandlers\n\n\nclass TestPluginStateMachine(BaseHandlers):\n\n def test_attrs_creation(self):\n pass\n" }, { "f...
python
chosen
[ { "from": "system", "value": "Fix typo preventing the Django/Datadog integration from starting\n" }, { "from": "human", "value": "from django.core.management.base import BaseCommand\n\nfrom spinach.const import DEFAULT_QUEUE, DEFAULT_WORKER_NUMBER\nfrom spinach.contrib.datadog import register_da...
python
chosen
[ { "from": "system", "value": "Raise error on undefined type\n" }, { "from": "human", "value": "from noopy import lambda_functions\nfrom noopy.endpoint import Endpoint\nfrom noopy.endpoint import methods\n\n\ndef dispatch(event, context):\n print event\n\n if event['type'] == 'APIGateway':\...
python
chosen
[ { "from": "system", "value": "Refactor to change the comparator of dict\n" }, { "from": "human", "value": "from flask import Flask\nfrom flask import request\nfrom flask import jsonify\n\nfrom y_text_recommender_system.recommender import recommend\n\napp = Flask(__name__)\n\n\nclass InvalidUsage...
python
chosen
[ { "from": "system", "value": "Add base methods for generation dictionary\n" }, { "from": "human", "value": "from flask import Flask\n\napp = Flask(__name__)\n\n\n@app.route('/')\ndef start(count):\n return 'SETUP APP'\n\n\nif __name__ == '__main__':\n app.run(host=\"172.31.27.41\", port=80...
python
chosen
[ { "from": "system", "value": "Use the Python 3 print function.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport os\nimport subprocess\nimport sys\n\n\ndef build(pkgpath):\n os.chdir(pkgpath)\n targets = [\n 'build',\n 'package',\n 'install',\n ...
python
chosen
[ { "from": "system", "value": "Split spec generation into function\n" }, { "from": "human", "value": "import os\nimport string\n\nif __name__ == '__main__':\n patch_file = 'example.patch'\n base_name, _ = os.path.splitext(patch_file)\n\n values = {\n 'name': 'kpatch-module-{}'.for...
python
chosen
[ { "from": "system", "value": "Add help text for cute\n" }, { "from": "human", "value": "import discord\nfrom discord.ext.commands import Bot\nimport json\n\nclient = Bot(\"~\", game=discord.Game(name=\"~help\"))\n\n@client.event\nasync def on_ready():\n print('We have logged in as {0.user}'.f...
python
chosen
[ { "from": "system", "value": "Add function to convert fraction to decimal\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom openprocurement.api.utils import get_now\n\n\ndef request_get_now(request):\n return get_now()\n" }, { "from": "gpt", "value": "# -*- coding: ...
python
chosen
[ { "from": "system", "value": "Fix engine check and added check for django_postgrespool.\n" }, { "from": "human", "value": "\nfrom django.conf import settings\nfrom django.db import connections\nfrom django.db.models.query import QuerySet\n\nfrom model_utils.managers import PassThroughManager\n\n...
python
chosen
[ { "from": "system", "value": "Remove need to set environment variables in test\n" }, { "from": "human", "value": "from contextlib import contextmanager\nfrom os import environ\nfrom unittest import TestCase\n\n\nclass DownloadTests(TestCase):\n def test_denies_unknown_client(self):\n w...
python
chosen
[ { "from": "system", "value": "Include uncategorised spending in overview pie chart\n\nAlso, only show last 120 days\n" }, { "from": "human", "value": "from django.db.models import Sum\r\nfrom django.views.generic import TemplateView\r\nfrom djofx.forms import OFXForm\r\nfrom djofx.views.base imp...
python
chosen
[ { "from": "system", "value": "Delete material package temp file after creation\n" }, { "from": "human", "value": "# This file is part of Indico.\n# Copyright (C) 2002 - 2021 CERN\n#\n# Indico is free software; you can redistribute it and/or\n# modify it under the terms of the MIT License; see th...
python
chosen
[ { "from": "system", "value": "Remove redundant empty line at end of file\n\nThere is no need to have multiple empty lines in the end.\n" }, { "from": "human", "value": "\"\"\"Power Digit Sum\n\n2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.\n\nWhat is the sum of the digits of ...
python
chosen
[ { "from": "system", "value": "Revert \"packages/spirvtools: stick to last working commit\"\n\nThis reverts commit cbaac43c95226b4ca5c9c1478467069966e9ef35.\n" }, { "from": "human", "value": "{\n\t'repo_type' : 'git',\n\t'rename_folder' : 'spirv-tools',\n\t'url' : 'https://github.com/KhronosGroup...
python
chosen
[ { "from": "system", "value": "[NG] Change to socketio.run() so WebSockets work on local runs.\n" }, { "from": "human", "value": "\"\"\"\nWSGI script run on Heroku using gunicorn.\nExposes the app and configures it to use Heroku environment vars.\n\"\"\"\nimport os\nfrom suddendev import create_a...
python
chosen
[ { "from": "system", "value": "Fix compatibility with PyYAML 6.0 (mandatory `Loader`)\n" }, { "from": "human", "value": "import os\nimport yaml\n\ndef config():\n my_dir = os.path.dirname(__file__)\n config_file = os.path.join(my_dir, '../../lib/shared_config.yml')\n\n with open(config_f...
python
chosen
[ { "from": "system", "value": "Clean command - tool help fix\n" }, { "from": "human", "value": "# Copyright 2014-2015 0xc0170\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 obtain a copy of the...
python
chosen
[ { "from": "system", "value": "Add the option for showing percent rather than count in plots\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\n\"\"\"Config file for the cleaning - plotting and notebook process\"\"\"\n\n\nclass CleaningConfig:\n\n # Unproces...
python
chosen
[ { "from": "system", "value": "Add all words and \"-\" to payment url\n" }, { "from": "human", "value": "from django.conf.urls import patterns, url\n\nfrom . import views\n\n\nTOKEN_PATTERN = ('(?P<token>[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}'\n '-[0-9a-z]{12})')\n\nurlpa...
python
chosen
[ { "from": "system", "value": "Set up mock data for index\n" }, { "from": "human", "value": "from app import app\nfrom flask import make_response\n\n@app.route('/')\n@app.route('/index')\ndef index():\n return make_response(open(app.root_path + '/templates/index.html').read())" }, { "f...
python
chosen
[ { "from": "system", "value": "Make an attribute call a little smarter\n" }, { "from": "human", "value": "from django.conf import settings\nfrom bakery.management.commands.publish import Command as BaseCommand\n\n\nclass Command(BaseCommand):\n\n def handle(self, *args, **options):\n # ...
python
chosen
[ { "from": "system", "value": "Fix self- > cls, make super generic (no `nc`)\n" }, { "from": "human", "value": "class Gridded:\n\n _grid_obj_classes = []\n _grids_loaded = False\n\n @classmethod\n def _load_grid_objs(cls):\n from pkg_resources import working_set\n for ep...
python
chosen
[ { "from": "system", "value": "Make `user` field read-only in `ExtraInfo` detail\n\nPreviously, server would hang trying to load an `ExtraInfo` detail page,\nbecause the `user` field was rendering as a dropdown select menu loading\nall users in the system. We fix this by making the field read-only.\n" }, ...
python
chosen
[ { "from": "system", "value": "Define more arguments for command line parser\n" }, { "from": "human", "value": "import argparse\n\nparser = argparse.ArgumentParser(prog='moocx', description='EdX MOOC Data Anaylysis')\nparser.add_argument('-v', '--version', action='version', version='0.1.0')\n\nsu...
python
chosen
[ { "from": "system", "value": "Bump minor point version to 0.1.1\n" }, { "from": "human", "value": "_author__ = 'Liav Koren'\n__email__ = 'liav.koren@gmail.com'\n__version__ = '0.1.0rc1'\n" }, { "from": "gpt", "value": "_author__ = 'Liav Koren'\n__email__ = 'liav.koren@gmail.com'\n__v...
python
chosen
[ { "from": "system", "value": "Revert test db to postgress\n" }, { "from": "human", "value": "import os\n\n\nclass Config(object):\n \"\"\"Parent configuration class.\"\"\"\n DEBUG = False\n CSRF_ENABLED = True\n SECRET_KEY = os.getenv('SECRET_KEY')\n SQLALCHEMY_DATABASE_URI = os.g...
python
chosen
[ { "from": "system", "value": "Change termination criteria for liquid phase examples to attainable value.\n\nConversion of octane was stuck at 8e-3 for quite some time...\n" }, { "from": "human", "value": "# Data sources\ndatabase(\n thermoLibraries = ['primaryThermoLibrary'],\n reactionLib...
python
chosen
[ { "from": "system", "value": "Add support for output to a file\n" }, { "from": "human", "value": "import lxml.etree as ET\nimport argparse\nimport pkg_resources\n\n\ndef convert(inxml):\n\n dom = ET.parse(inxml)\n xslt = ET.parse(pkg_resources.resource_stream('cobertura_clover_transform',\...
python
chosen
[ { "from": "system", "value": "Add get_plugin method to the plugin base.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport os\nimport glob\n\n__all__ = [ os.path.basename(f)[:-3] for f in glob.glob(os.path.dirname(__file__)+\"/*.py\")]\n\n\nclass InvalidConfigException(Exception)...
python
chosen
[ { "from": "system", "value": "Remove noise from default COBRA configs.\n\nPiperOrigin-RevId: 265733849\nChange-Id: Ie0e7c0385497852fd85c769ee85c951542c14463\n" }, { "from": "human", "value": "# Copyright 2019 DeepMind Technologies Limited.\n#\n# Licensed under the Apache License, Version 2.0 (th...
python
chosen
[ { "from": "system", "value": "Fix TypeError in Python 3\n" }, { "from": "human", "value": "import hashlib\n\n\ndef hexdigest(strings):\n m = hashlib.md5()\n for s in strings:\n m.update(s)\n return m.hexdigest()\n" }, { "from": "gpt", "value": "import hashlib\n\n\ndef...
python
chosen
[ { "from": "system", "value": ":bookmark: Bump version after fix for constrained bytes\n" }, { "from": "human", "value": "\"\"\"FastAPI framework, high performance, easy to learn, fast to code, ready for production\"\"\"\n\n__version__ = \"0.1.16\"\n\nfrom .applications import FastAPI\nfrom .rout...
python
chosen
[ { "from": "system", "value": "Use None instead of \"null\" in Highcharts boilerplate\n" }, { "from": "human", "value": "boilerplate = {\n 'chart': {\n 'renderTo': 'container',\n 'plotBackgroundColor': 'none',\n 'backgroundColor': 'none',\n },\n 'title': {'text': 'nu...
python
chosen
[ { "from": "system", "value": "Set ACL explicitly to make files readable\n" }, { "from": "human", "value": "#! /usr/bin/python\nimport os, subprocess\n\nos.chdir(os.path.dirname(os.path.abspath(__file__)))\n\nsubprocess.call([ 'python',\n os.path.join('..', 'venus', 'planet.py'),...
python
chosen
[ { "from": "system", "value": "Raise NotImplementedError for basic stuff.\n" }, { "from": "human", "value": "import reg\n\n\n@reg.generic\ndef consumer(obj):\n \"\"\"A consumer consumes steps in a stack to find an object.\n \"\"\"\n\n\n@reg.generic\ndef app(obj):\n \"\"\"Get the applicat...
python
chosen
[ { "from": "system", "value": "Add new unit tests to collection\n" }, { "from": "human", "value": "\n#\n# This source file is part of appleseed.\n# Visit http://appleseedhq.net/ for additional information and resources.\n#\n# This software is released under the MIT license.\n#\n# Copyright (c) 20...
python
chosen
[ { "from": "system", "value": "Bring the standard imports over\n" }, { "from": "human", "value": "class HashMismatch(ValueError):\n \"\"\"\n Raised when the incoming hash of a file does not match the expected.\n \"\"\"\n" }, { "from": "gpt", "value": "from __future__ import a...
python
chosen
[ { "from": "system", "value": "Use the correct excel path.\n" }, { "from": "human", "value": "\"\"\"\nThis module is a general example using test data showing usage of sparks, excel\nand the studbook structure.\n\"\"\"\nimport os\n\nfrom GTT import SPARKS\nfrom GTT import excel as ew\nfrom GTT im...
python
chosen
[ { "from": "system", "value": "Allow importing from pymp module directly\n" }, { "from": "human", "value": "import logging\nimport multiprocessing\n\nDEBUG = False # for now\n\ndef get_logger(level=None):\n logger = multiprocessing.get_logger()\n format = '[%(asctime)s][%(levelname)s/%(pr...
python
chosen
[ { "from": "system", "value": "Add info on table format helpers to warning message\n" }, { "from": "human", "value": "from dash.dash_table import * # noqa: F401, F403, E402\nimport warnings\n\nwarnings.warn(\n \"\"\"\nThe dash_table package is deprecated. Please replace\n`import dash_table` w...
python
chosen
[ { "from": "system", "value": "Make exception on reload not crash input\n" }, { "from": "human", "value": "from motobot.irc_bot import IRCBot, IRCLevel\nimport desubot\nimport threading\n\ndef worker():\n desubot.bot.run()\n\ndef main():\n desubot.bot.load_plugins('plugins')\n desubot.bo...
python
chosen
[ { "from": "system", "value": "Test for pydbus instead of dbus on startup\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nimport os\n\nfrom mopidy import config, exceptions, ext\n\n\n__version__ = '1.4.0'\n\n\nclass Extension(ext.Extension):\n\n dist_name = 'Mopid...
python
chosen
[ { "from": "system", "value": "Clarify test_containers_to_host not using libnetwork\n" }, { "from": "human", "value": "from subprocess import CalledProcessError\n\nfrom test_base import TestBase\nfrom tests.st.utils.docker_host import DockerHost\n\n\nclass TestContainerToHost(TestBase):\n def ...
python
chosen
[ { "from": "system", "value": "Replace importlib hack with __path__\n" }, { "from": "human", "value": "import sys\nimport importlib\n\nsys.modules[__package__] = importlib.import_module('.dataset', __package__)\n" }, { "from": "gpt", "value": "import os\n\n__path__.append(os.path.dirn...
python
chosen
[ { "from": "system", "value": "Add separate \"plotting\" script for general plot setup.\n\ngit-svn-id: b93d21f79df1f7407664ec6e512ac344bf52ef2a@711 f9184c78-529c-4a83-b317-4cf1064cc5e0\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# encoding: utf-8\n\"\"\"\n__init__.py\n\nCreated by G...
python
chosen
[ { "from": "system", "value": "Add accounts function, testing mode.\n" }, { "from": "human", "value": "import sys\nimport aesjsonfile\n\nsys.path.append(\"../\")\n\nimport config\n\nclass DB(object):\n def __init__(self, username, password):\n self.username = username\n self.pass...
python
chosen
[ { "from": "system", "value": "Make bot_only async, because duh\n" }, { "from": "human", "value": "from functools import wraps\n\n\ndef bot_only(func):\n @wraps(func)\n def inner(self, *args, **kwargs):\n if not self.user.bot:\n return\n return func(self, *args, **k...
python
chosen
[ { "from": "human", "value": "Implement daemon example, now to make it actually do something.\n" }, { "from": "gpt", "value": "\"\"\"\nThe main measurement program, responsible for polling the sensor periodically \nand inserting the results into a database. \n\nMust be run as root (to access the ...
python
chosen
[ { "from": "system", "value": "Add fab command for fetching episodes\n" }, { "from": "human", "value": "from fabric.api import run, env\nfrom fabric.context_managers import cd\nimport os\n\nenv.hosts = ['root@0.0.0.0:1337']\n\n\ndef update_podcasts():\n with cd('\"{}\"'.format(os.path.dirname(...
python
chosen
[ { "from": "system", "value": "Simplify - Less is more\n" }, { "from": "human", "value": "#!/usr/local/bin/python3 -u\n__author__ = 'Oliver Ratzesberger <https://github.com/fxstein>'\n__copyright__ = 'Copyright (C) 2015 Oliver Ratzesberger'\n__license__ = 'Apache License, Version 2.0'\n\n# M...
python
chosen
[ { "from": "system", "value": "Use the Election model in the elections Mixin\n" }, { "from": "human", "value": "from django.conf import settings\nfrom django.http import Http404\nfrom django.utils.translation import ugettext as _\n\n\nclass ElectionMixin(object):\n '''A mixin to add election d...
python
chosen
[ { "from": "system", "value": "Fix keep turning spinner when error occurred\n" }, { "from": "human", "value": "from bush import option\nfrom bush.spinner import Spinner\nfrom bush.aws.ec2 import EC2\nfrom bush.aws.iam import IAM\n\n\ndef run():\n (options, args) = option.parse_args(\"bush\")\n...
python
chosen
[ { "from": "system", "value": "Add latest starting time sorting\n" }, { "from": "human", "value": "from datetime import datetime\n\nfrom timetabler.schedule import Schedule\nfrom timetabler.ssc.course import Lecture, Discussion\n\n\ndef main():\n s = Schedule([\"EECE 353\", \"CPSC 304\", \"EEC...
python
chosen
[ { "from": "system", "value": "Add deploy task to deploy a new Nginx index page\n" }, { "from": "human", "value": "# Simple Tasks\n\ndef hello():\n print 'Hello ThaiPy!'\n\n\ndef hi(name='Kan'):\n print 'Hi ' + name\n\n\n# Local Commands\n\nfrom fabric.api import local, lcd\n\n\ndef deploy_...
python
chosen
[ { "from": "system", "value": "Drop fab file task for updating theme as well\n" }, { "from": "human", "value": "from fabric.api import lcd, local\nfrom fabric.decorators import runs_once\n\nimport os\n\nfabfile_dir = os.path.dirname(__file__)\n\n\ndef update_theme():\n theme_dir = os.path.join...
python
chosen
[ { "from": "system", "value": "Update the boilerplate example by adding \"has_exception()\"\n" }, { "from": "human", "value": "'''\nYou can use this as a boilerplate for your test framework.\nDefine your customized library methods in a master class like this.\nThen have all your test classes inhe...
python
chosen