conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Add support for allocating aligned NumPy arrays.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nimport numpy as np\n\n\n_npeval_syms = {'__builtins__': None,\n 'exp': np.exp, 'log': np.log,\n 'sin': np.sin, 'asin': np.arc...
python
chosen
[ { "from": "system", "value": "Use Babel's `format_decimal` instead of deprecated `format_number`\n" }, { "from": "human", "value": "\"\"\"\nbyceps.util.templatefunctions\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nProvide and register custom template global functions.\n\n:Copyright: 2006-2021 Jochen Kuppe...
python
chosen
[ { "from": "system", "value": "Create test for matrix post endpoint\n" }, { "from": "human", "value": "\"\"\"\nTest the post methods.\n\"\"\"\n\n\ndef test_matrix_creation_endpoint(client):\n response = client.post('/matrix', {\n 'bibliography': '12312312',\n 'fields': 'title,des...
python
chosen
[ { "from": "system", "value": "Add some color to SVG key/values\n" }, { "from": "human", "value": "#import PIL\nimport cairosvg\nfrom django.template import Template, Context\n\n\n\ndef make_svg(context):\n svg_tmpl = Template(\"\"\"\n <svg xmlns=\"http://www.w3.org/2000/svg\"\n width=...
python
chosen
[ { "from": "system", "value": "Refactor to lerp param names.\n" }, { "from": "human", "value": "def lerp(fromValue, toValue, step):\n return fromValue + (toValue - fromValue) * step" }, { "from": "gpt", "value": "def lerp(fromValue, toValue, percent):\n return fromValue + (toVal...
python
chosen
[ { "from": "system", "value": "Update URLs to include recent results\n" }, { "from": "human", "value": "__author__ = 'ankesh'\n\nfrom django.conf.urls import patterns, url\nimport views\n\nurlpatterns = patterns('',\n url(r'^(?P<filename>[a-zA-Z0-9]+)/$', views.show_result, name='showResult'),...
python
chosen
[ { "from": "system", "value": "Set resource and client when it is needed\n" }, { "from": "human", "value": "from bush.aws.session import create_session\n\n\nclass AWSBase:\n # USAGE = \"\"\n # SUB_COMMANDS = []\n\n def __init__(self, options, resource_name):\n self.name = resource...
python
chosen
[ { "from": "system", "value": "Add newline at end of file.\n" }, { "from": "human", "value": "from unittest import TestCase\n\nimport eduid_IdP_html\n\n__author__ = 'ft'\n\n\nclass TestLoad_settings(TestCase):\n\n def test_load_settings(self):\n settings = eduid_IdP_html.load_settings()...
python
chosen
[ { "from": "system", "value": "Fix error message in example project\n" }, { "from": "human", "value": "import hashlib\nfrom rest_framework.response import Response\n\n\ndef auto_logout(*args, **kwargs):\n \"\"\"Do not compare current user with new one\"\"\"\n return {'user': None}\n\n\ndef ...
python
chosen
[ { "from": "system", "value": "Change encoding name for no reason\n" }, { "from": "human", "value": "# encoding=utf-8\nfrom __future__ import unicode_literals\n\nimport socket\nfrom time import sleep\n\n\ndef mount(s, at, uuid=None, label=None, name=None):\n for name, value in ((b'uuid', uuid)...
python
chosen
[ { "from": "system", "value": "Make a copy of dicts before deleting things from them when printing.\n" }, { "from": "human", "value": "import json\n\nfrom base64 import b64encode\n\n\n# http://stackoverflow.com/a/4256027/212555\ndef del_none(o):\n \"\"\"\n Delete keys with the value ``None`...
python
chosen
[ { "from": "system", "value": "Increase the cloning timeout limit\n" }, { "from": "human", "value": "from config_secret import SecretConfig\n\n\nclass Config:\n SECRET_KEY = SecretConfig.SECRET_KEY\n\n # MongoDB config\n MONGO_DBNAME = SecretConfig.MONGO_DBNAME\n MONGO_HOST = SecretCo...
python
chosen
[ { "from": "system", "value": "Fix to CHT station name\n" }, { "from": "human", "value": "from data_importers.management.commands import BaseHalaroseCsvImporter\n\n\nclass Command(BaseHalaroseCsvImporter):\n council_id = \"CHT\"\n addresses_name = (\n \"2022-05-05/2022-02-25T12:48:35...
python
chosen
[ { "from": "system", "value": "Use page_unpublished signal in frontend cache invalidator\n" }, { "from": "human", "value": "from django.db import models\nfrom django.db.models.signals import post_delete\n\nfrom wagtail.wagtailcore.models import Page\nfrom wagtail.wagtailcore.signals import page_p...
python
chosen
[ { "from": "system", "value": "Fix import path for rest plugins\n" }, { "from": "human", "value": "import sys\nimport os\n\nsys.path.append(os.path.join(os.path.dirname(__file__), \"../\"))\nfrom http_test_suite import HTTPTestSuite\n\nfrom mozdef_util.utilities.dot_dict import DotDict\n\nimport ...
python
chosen
[ { "from": "system", "value": "Fix bug in unit tests\n" }, { "from": "human", "value": "import unittest\nfrom pydirections.route_requester import DirectionsRequest\nfrom pydirections.exceptions import InvalidModeError, InvalidAPIKeyError, InvalidAlternativeError\n\nclass TestOptionalParameters(un...
python
chosen
[ { "from": "system", "value": "Allow running jobsteps to be deallocated\n" }, { "from": "human", "value": "from __future__ import absolute_import, division, unicode_literals\n\nfrom changes.api.base import APIView\nfrom changes.constants import Status\nfrom changes.config import db\nfrom changes....
python
chosen
[ { "from": "system", "value": "Initialize database if it does not exist\n" }, { "from": "human", "value": "from heutagogy import app\nimport heutagogy.persistence\nimport os\nfrom datetime import timedelta\n\napp.config.from_object(__name__)\napp.config.update(dict(\n USERS={\n 'myuser'...
python
chosen
[ { "from": "system", "value": "NXDRIVE-170: Remove long timeout to make file blacklisting bug appear, waiting for the fix\n" }, { "from": "human", "value": "import os\n\nfrom nxdrive.tests.common import IntegrationTestCase\nfrom nxdrive.client import LocalClient\n\n\nclass TestIntegrationCopy(Int...
python
chosen
[ { "from": "system", "value": "utils.lang.js: Switch class system to use JPlus types machinery\n" }, { "from": "human", "value": "##\n# Copyright (c) 2013 Sprymix Inc.\n# All rights reserved.\n#\n# See LICENSE for details.\n##\n\n\n# Import languages to register them\nfrom metamagic.utils.lang im...
python
chosen
[ { "from": "system", "value": "Add configuration file option with default to ~/tldt.ini\n" }, { "from": "human", "value": "import argparse\n\nimport tldt\n\n\ndef main():\n parser = argparse.ArgumentParser(description=\"cacat\")\n parser.add_argument(\"head_repo\")\n parser.add_argument(...
python
chosen
[ { "from": "system", "value": "Rename ResCountry class to CompassionCountry\n" }, { "from": "human", "value": "# -*- encoding: utf-8 -*-\n##############################################################################\n#\n# Copyright (C) 2014-2015 Compassion CH (http://www.compassion.ch)\n# ...
python
chosen
[ { "from": "system", "value": "Make user query case insensitive" }, { "from": "human", "value": "import kerberos\nimport logging\n\nfrom django.conf import settings\nfrom django.contrib.auth import get_user_model\nfrom django.contrib.auth.backends import ModelBackend\n\n\nlogger = logging.getLogg...
python
chosen
[ { "from": "system", "value": "Fix for missing default in currency filter\n" }, { "from": "human", "value": "from decimal import Decimal as D\nfrom decimal import InvalidOperation\n\nfrom babel.numbers import format_currency\nfrom django import template\nfrom django.conf import settings\nfrom dja...
python
chosen
[ { "from": "system", "value": "Add a test for extracting service domain from a link\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport os\nimport webapp\nimport unittest\n\nclass WebappTestExtractingServiceDomainsFromLinks(unittest.TestCase):\n\n #def setUp(self):\n # self....
python
chosen
[ { "from": "system", "value": "Change bulk order email address to Tory\n" }, { "from": "human", "value": "import logging\n\nfrom django.core.mail import EmailMessage\nfrom django.http import JsonResponse\nfrom django.middleware import csrf\nfrom django.views.decorators.csrf import csrf_exempt\nfr...
python
chosen
[ { "from": "system", "value": "[ADD] Add 'team' to Folder type options\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n# Copyright 2017-TODAY LasLabs Inc.\n# License MIT (https://opensource.org/licenses/MIT).\n\nimport properties\n\nfrom .. import BaseModel\n\n\nclass Folder(BaseModel...
python
chosen
[ { "from": "system", "value": "Fix to mounting mdadm raid arrays\n" }, { "from": "human", "value": "\nfrom kokki import *\n\nif env.config.mdadm.arrays:\n Package(\"mdadm\")\n\nExecute(\"mdadm-update-conf\",\n action = \"nothing\",\n command = (\"(\"\n \"echo DEVICE partitions > /...
python
chosen
[ { "from": "system", "value": "Set expected exception class in \"except\" block\n\nFix issue E722 of flake8\n" }, { "from": "human", "value": "import subprocess\n\n\ndef run(command):\n try:\n subprocess.check_call(command, shell=True)\n except:\n pass\n" }, { "from": ...
python
chosen
[ { "from": "system", "value": "Add a ruler to column 72\n" }, { "from": "human", "value": "# encoding: utf-8\n\nimport Natural.util as util\nimport sublime, sublime_plugin\n\n\nclass PerformEventListener(sublime_plugin.EventListener):\n \"\"\"Suggest subroutine completions for the perform stat...
python
chosen
[ { "from": "system", "value": "Add authentication to base TestCase\n" }, { "from": "human", "value": "import unittest\nimport os\nimport yaml\nfrom functools import wraps\nfrom cmd import init_db, seed_db\nfrom models import db\nfrom scuevals_api import create_app\n\n\nclass TestCase(unittest.Tes...
python
chosen
[ { "from": "system", "value": "Remove tuple, since string is sufficient here\n\nAs discovered in [discussion around issue #1184](https://github.com/biolab/orange3/issues/1184#issuecomment-214215811), the tuple is not necessary here. Only a single string is necessary, as is documented in the setuptools offici...
python
chosen
[ { "from": "system", "value": "Add try except to the method that parse idea datetime\n" }, { "from": "human", "value": "# IdeaScaly\n# Copyright 2015 Jorge Saldivar\n# See LICENSE for details.\n\nimport six\nimport dateutil.parser\n\nfrom datetime import datetime\n\n\ndef parse_datetime(str_date)...
python
chosen
[ { "from": "system", "value": "Truncate rather than replace to prevent erroneous substitutions.\n" }, { "from": "human", "value": "from django.urls import reverse\nfrom six.moves.urllib.parse import urljoin\n\nfrom kolibri.utils.conf import OPTIONS\n\n\ndef reverse_remote(\n baseurl, viewname,...
python
chosen
[ { "from": "system", "value": "Update default settings to development.\n" }, { "from": "human", "value": "\"\"\"\nWSGI config for job_runner project.\n\nThis module contains the WSGI application used by Django's development server\nand any production WSGI deployments. It should expose a module-le...
python
chosen
[ { "from": "system", "value": "Fix the syntax for NickServ logins\n" }, { "from": "human", "value": "from module_interface import Module, ModuleType\nfrom message import IRCResponse, ResponseType\nfrom pyheufybot import globalvars\n\nclass NickServIdentify(Module):\n def __init__(self):\n ...
python
chosen
[ { "from": "system", "value": "app: Drop 'metamagic.app' package. Long live Node.\n" }, { "from": "human", "value": "##\n# Copyright (c) 2010 Sprymix Inc.\n# All rights reserved.\n#\n# See LICENSE for details.\n##\n\n\nfrom metamagic import app\nfrom metamagic.exceptions import MetamagicError\n\n...
python
chosen
[ { "from": "system", "value": "Revert \"The order of the formats matters. Use OrderedDict instead of dict\"\n\nI can't rely on the order of dict. The control flow is more complex.\n\nThis reverts commit 3389ed71971ddacd185bbbf8fe667a8651108c70.\n" }, { "from": "human", "value": "#!/usr/bin/env py...
python
chosen
[ { "from": "system", "value": "Add standalone method for using from command line\n" }, { "from": "human", "value": "from collections import Counter\nfrom matplotlib import pyplot as plt\nimport datetime\n\ndef create_timeline( data ):\n if len(data) == 0:\n print \"Dataset empty.\"\n ...
python
chosen
[ { "from": "system", "value": "Use the available fixtures for demo_fixtures.\n" }, { "from": "human", "value": "from lino.projects.std.settings import *\n\n\nclass Site(Site):\n\n title = \"Cool Polls\"\n\n def get_installed_apps(self):\n yield super(Site, self).get_installed_apps()\...
python
chosen
[ { "from": "system", "value": "Add environ vars for joyent" }, { "from": "human", "value": "from fabric.api import run, sudo\nfrom fabric.contrib.files import append\n\nfrom fab_deploy.base import setup as base_setup\n\n\nclass JoyentMixin(object):\n\n def _set_profile(self):\n append('...
python
chosen
[ { "from": "system", "value": "Use max poll delay to avoid OSErrors\n" }, { "from": "human", "value": "# Just to insure requirement\nimport colorlog # noqa\n\n# Development mode: use a local OSF dev version and more granular logging\nDEV_MODE = False # TODO (abought): auto-set flag when using `...
python
chosen
[ { "from": "system", "value": "Remove now asks for site file to be deleted\n" }, { "from": "human", "value": "#deletes wahji content\nimport os, shutil, platform\n\ndef rem(loc):\n\n\tos.chdir(loc)\n\t\n\tprint \"deleting content\"\n\t\t\n\t\"\"\"delete them folder and its contents\"\"\"\n\tshuti...
python
chosen
[ { "from": "system", "value": "Fix the urlparse import in Python 2. (This is used for saving/loading tokens in files.) The urlparse that you can import from urllib2 is actually the urlparse module, but what we want is the urlparse function inside that module.\n" }, { "from": "human", "value": "...
python
chosen
[ { "from": "system", "value": "[REF] openacademy: Add domain ir and ilike\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom openerp import fields,models\n\nclass Session(models.Model):\n _name = 'openacademy.session'\n\n name = fields.Char(required=True)\n start_date = fie...
python
chosen
[ { "from": "system", "value": "Change to a secret secret key\n" }, { "from": "human", "value": "from .common import *\nimport dj_database_url\n\n# Settings for production environment\nDEBUG = False\n\n# Update database configuration with $DATABASE_URL.\ndb_from_env = dj_database_url.config(conn_m...
python
chosen
[ { "from": "system", "value": "Add totally untested pools ;)\n" }, { "from": "human", "value": "import abc\n\n\ndef do_flow(flow, result=None):\n for item in flow:\n print(item, result)\n result = item(result)\n return result\n\n\nclass MapTask(object):\n\n def __init__(sel...
python
chosen
[ { "from": "system", "value": "Add \"Yes\" as an option for parsing bools\n\nCURA-2204\n" }, { "from": "human", "value": "# Copyright (c) 2016 Ultimaker B.V.\r\n# Uranium is released under the terms of the AGPLv3 or higher.\r\n\r\n## Convert a value to a boolean\r\n#\r\n# \\param \\type{bool|s...
python
chosen
[ { "from": "system", "value": "Fix on/off if there is no 'off' field.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n#from twisted.words.xish import domish\n\nfrom base import *\nimport random\n\nimport bnw_core.bnw_objects as objs\n\n@require_auth\n@defer.inlineCallbacks\ndef cmd_on...
python
chosen
[ { "from": "system", "value": "Fix pylint: Unnecessary parens after u'print' keyword (superfluous-parens)\n" }, { "from": "human", "value": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport grp\nimport pwd\nimport inspect\nimport argparse\n\n\ndef list_all_users_in_group(groupname):\n ...
python
chosen
[ { "from": "system", "value": "Move cache key out of base class\n" }, { "from": "human", "value": "import json\nimport webapp2\n\nfrom controllers.api.api_base_controller import ApiBaseController\n\nfrom helpers.model_to_dict import ModelToDict\n\nfrom models.match import Match\n\n\nclass ApiMatc...
python
chosen
[ { "from": "system", "value": "Use appropriate package for mxchip_az3166\n" }, { "from": "human", "value": "# Copyright 2014-present PlatformIO <contact@platformio.org>\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with t...
python
chosen
[ { "from": "system", "value": "Fix a test failure on non-UTF-8 locales: bad_coding2.py is encoded\nin utf-8.\n" }, { "from": "human", "value": "\nimport test.test_support, unittest\nimport os\n\nclass CodingTest(unittest.TestCase):\n def test_bad_coding(self):\n module_name = 'bad_codin...
python
chosen
[ { "from": "system", "value": "Compress the images to be sent\n" }, { "from": "human", "value": "import matplotlib\n# Do not use X for plotting\nmatplotlib.use('Agg')\n\nimport matplotlib.pyplot as plt\nfrom matplotlib.dates import DateFormatter\nfrom matplotlib.ticker import FormatStrFormatter\n...
python
chosen
[ { "from": "system", "value": "Move BAE secret into try catch block\n" }, { "from": "human", "value": "##################################\n# Added for BAE\n##################################\n\ntry:\n CACHES = {\n 'default': {\n 'BACKEND': 'django.core.cache.backends.memcache...
python
chosen
[ { "from": "system", "value": "Make periodic expired task deletion more efficient\n\nSummary: Also adds tracking for the number of tasks deleted at each run.\n\nTest Plan: None\n\nReviewers: paulruan\n\nReviewed By: paulruan\n\nSubscribers: changesbot, anupc\n\nDifferential Revision: https://tails.corp.dropb...
python
chosen
[ { "from": "system", "value": "Remove default arguments for user_id, client_id and type\n" }, { "from": "human", "value": "from .rest import RestClient\n\n\nclass DeviceCredentials(object):\n\n \"\"\"Auth0 connection endpoints\n\n Args:\n domain (str): Your Auth0 domain, e.g: 'userna...
python
chosen
[ { "from": "system", "value": "Set urls for bucketlist items endpoints\n" }, { "from": "human", "value": "from flask_restful import Api\nfrom flask_migrate import Migrate, MigrateCommand\nfrom flask_script import Manager\nfrom app import app\nfrom app import db\nfrom app.auth import Register, Log...
python
chosen
[ { "from": "system", "value": "Correct the geographic field name" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\" ``SQLAlchemy`` model definition for the watercourses.\"\"\"\nfrom geoalchemy import GeometryColumn, GeometryDDL, LineString\nfrom sqlalchemy import Column, Unicode, In...
python
chosen
[ { "from": "system", "value": "Fix pep8 new line in test https check\n\nSigned-off-by: Brandon Myers <9cda508be11a1ae7ceef912b85c196946f0ec5f3@mozilla.com>\n" }, { "from": "human", "value": "from tests.scoring_engine.engine.checks.check_test import CheckTest\n\n\nclass TestHTTPSCheck(CheckTest):\...
python
chosen
[ { "from": "system", "value": "Fix null Edinburgh journey code or destination\n" }, { "from": "human", "value": "from django.contrib.gis.geos import Point\nfrom busstops.models import Service\nfrom ...models import Vehicle, VehicleLocation, VehicleJourney\nfrom ..import_live_vehicles import Impor...
python
chosen
[ { "from": "system", "value": "Use a decorator to wrap the actual checks\n" }, { "from": "human", "value": "import os\nimport uuid\nimport time\nimport json\n\nfrom flask import Flask\n\napp = Flask(__name__)\napp.debug = True\n\ndef check(endpoint):\n def actual_check(function):\n star...
python
chosen
[ { "from": "system", "value": "Fix List to use the new decoding system\n" }, { "from": "human", "value": "import io\r\nfrom .base import Field, DynamicValue, FullyDecoded\r\n\r\n\r\nclass SubStructure(Field):\r\n def __init__(self, structure, *args, **kwargs):\r\n self.structure = struc...
python
chosen
[ { "from": "system", "value": "Add Python 3 compatibility to Android symbol checker\n\nMake the script that checks for undefined Android symbols compatible\nwith both Python 2 and Python 3, to allow for future updates to the\ndefault system Python on our build machines.\n\nI'd like to land this before https:...
python
chosen
[ { "from": "system", "value": "Add the creation of the data dir for the sqlite file.\n" }, { "from": "human", "value": "from .base import *\n\nDEBUG = False\n\nDATABASES = {\n 'default': {\n 'ENGINE': 'django.db.backends.sqlite3',\n 'NAME': os.path.abspath(os.path.join(\n ...
python
chosen
[ { "from": "system", "value": "Add convenience function to read tempdir files.\n" }, { "from": "human", "value": "from mock import patch\nimport pytest\nimport os\nimport shutil\nimport tempfile\n\n\nclass Directory:\n def __init__(self, directory):\n self.directory = directory\n\n d...
python
chosen
[ { "from": "system", "value": "Add a slot for legislator role\n" }, { "from": "human", "value": "\"\"\" these are helper classes for object creation during the scrape \"\"\"\nfrom pupa.models.person import Person\nfrom pupa.models.organization import Organization\nfrom pupa.models.membership impo...
python
chosen
[ { "from": "system", "value": "Return .sites to INSTALLED_APPS until we drop allauth\n" }, { "from": "human", "value": "INSTALLED_APPS = (\n 'django.contrib.auth',\n 'django.contrib.contenttypes',\n 'django.contrib.sessions',\n 'django.contrib.messages',\n 'django.contrib.staticfil...
python
chosen
[ { "from": "system", "value": "Put the build stuff back in /build\n" }, { "from": "human", "value": "details_source = './source/details/'\nxml_source = './source/raw_xml/'\ncourse_dest = './source/courses/'\ninfo_path = './courses/info.json'\nterm_dest = './courses/terms/'\nmappi...
python
chosen
[ { "from": "system", "value": "Add Injection into __all__ list of top level package\n" }, { "from": "human", "value": "\"\"\"Dependency injector.\"\"\"\n\nfrom .catalog import AbstractCatalog\nfrom .catalog import override\n\nfrom .providers import Provider\nfrom .providers import Delegate\nfrom ...
python
chosen
[ { "from": "system", "value": "Upgrade release number to 0.6.0 (oq-engine 1.3.0)\n" }, { "from": "human", "value": "# coding=utf-8\n# Copyright (c) 2010-2014, GEM Foundation.\n#\n# OpenQuake Risklib is free software: you can redistribute it and/or\n# modify it under the terms of the GNU Affero Ge...
python
chosen
[ { "from": "system", "value": "Update git hash in test\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nfrom simtk import openmm\n\n# Check major version number\nassert openmm.Platform.getOpenMMVersion() == '7.1', \"openmm.Platform.getOpenMMVersion() = %s\" % openmm.Platform.getOpenMMV...
python
chosen
[ { "from": "system", "value": "Exclude beta, gamma, zeta functions\n" }, { "from": "human", "value": "# SymPy symbols to exclude\nexclude = ('C', 'O', 'S', 'N', 'E', 'E1', 'Q')\n\n# Aliases for SymPy symbols\naliases = {'delta': 'DiracDelta', 'step': 'Heaviside', 'u': 'Heaviside',\n 'j...
python
chosen
[ { "from": "system", "value": "Remove all previous aliases when initializing\n" }, { "from": "human", "value": "import aiohttp\nimport os.path\nfrom datetime import datetime\nfrom aioes import Elasticsearch\n\nfrom .importer import import_data\nfrom .kudago import KudaGo\nfrom .utils import read_...
python
chosen
[ { "from": "system", "value": "Update to newest version of rl.py.\n" }, { "from": "human", "value": "\"\"\"This is the agent which currently takes the action with proper q learning.\"\"\"\n\nimport time\nstart = time.time()\nfrom tqdm import tqdm\nimport env\nimport os\nimport rl\nenv.make(\"text...
python
chosen
[ { "from": "system", "value": "Handle 5 as a factor\n" }, { "from": "human", "value": "def raindrops(number):\n if is_three_a_factor(number):\n return \"Pling\"\n return \"{}\".format(number)\n\ndef is_three_a_factor(number):\n return number % 3 == 0\n" }, { "from": "gpt",...
python
chosen
[ { "from": "system", "value": "Replace execfile with py3-compatible equivalent\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nimport os\nimport stat\nfrom os.path import join, abspath\nfrom subprocess import call\n\ndef prepare(globs, locs):\n # RTD defaults the current working ...
python
chosen
[ { "from": "system", "value": "Fix inconsistency in parameters with base class\n" }, { "from": "human", "value": "from abc import ABCMeta, abstractmethod\n\n\nclass Driver(metaclass=ABCMeta):\n @abstractmethod\n def create(self):\n pass\n\n @abstractmethod\n def resize(self, id...
python
chosen
[ { "from": "system", "value": "Fix execute_command_assert_success return code logging\n" }, { "from": "human", "value": "import os\nimport pwd\nimport subprocess\nfrom .exceptions import CommandFailed\n \ndef get_user_shell():\n return pwd.getpwuid(os.getuid()).pw_shell\n\ndef execute_comma...
python
chosen
[ { "from": "system", "value": "Print args when generating stats\n" }, { "from": "human", "value": "import argparse\nimport webbrowser\n\nfrom .groupserializer import GroupSerializer\nfrom .statistic import all_statistics\nfrom .statistics import *\n\ndef gstat_stats():\n parser = argparse.Argu...
python
chosen
[ { "from": "system", "value": "Address review comment: Don't state the obvious.\n" }, { "from": "human", "value": "# Copyright Hybrid Logic Ltd. See LICENSE file for details.\n\n\"\"\"\nInterfaces that filesystem APIs need to expose.\n\"\"\"\n\nfrom __future__ import absolute_import\n\nfrom zope...
python
chosen
[ { "from": "system", "value": "Fix main menu url reversing in admin\n" }, { "from": "human", "value": "from django.template import Library, Variable\nfrom django.template import TemplateSyntaxError, VariableDoesNotExist\nfrom django.template.defaulttags import URLNode\n\nfrom ..models import Menu...
python
chosen
[ { "from": "system", "value": "UPDATE init; add utf-8 encoding\n" }, { "from": "human", "value": "########\n# Copyright (c) 2014 GigaSpaces Technologies Ltd. All rights reserved\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in complian...
python
chosen
[ { "from": "system", "value": "Change email subject. Not much of an ALERT if it happens every day.\n" }, { "from": "human", "value": "#!/usr/bin/env python3\n\nimport datetime\nimport os\nimport sys\nimport smtplib\nfrom email.mime.text import MIMEText\n\ndef timeString():\n return str(datetim...
python
chosen
[ { "from": "system", "value": "Allow getting number of results found with len()\n" }, { "from": "human", "value": "import scholarly\nimport requests\n\n_EXACT_SEARCH = '/scholar?q=\"{}\"'\n_START_YEAR = '&as_ylo={}'\n_END_YEAR = '&as_yhi={}'\ndef search(query, exact=True, start_year=None, end_yea...
python
chosen
[ { "from": "system", "value": "ZON-3167: Fix test, needs to select proper header for header-module to be enabled (belongs to commit:eb1b6fa)\n" }, { "from": "human", "value": "import zeit.content.article.edit.browser.testing\n\n\nclass HeaderModules(zeit.content.article.edit.browser.testing.Edito...
python
chosen
[ { "from": "system", "value": "Fix to import_module_from_string() to prevent multiple imports\n" }, { "from": "human", "value": "import importlib\nimport logging\nfrom typing import Sequence, Tuple, Callable\n\nimport pkg_resources\n\nlogger = logging.getLogger(__name__)\n\n\ndef import_module_fr...
python
chosen
[ { "from": "system", "value": "Add url to access the index view.\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'^$', 'purepython.views.home...
python
chosen
[ { "from": "system", "value": "Remove ':memory:' as that is default\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport os\nimport sys\nimport django\n\nfrom django.conf import settings\n\n\ndef main():\n import warnings\n warnings.filterwarnings('error', category=Deprecation...
python
chosen
[ { "from": "system", "value": "Create mixins package for testing\n" }, { "from": "human", "value": "# Copyright (C) 2016 Google Inc.\n# Licensed under http://www.apache.org/licenses/LICENSE-2.0 <see LICENSE file>\n\n" }, { "from": "gpt", "value": "# Copyright (C) 2016 Google Inc.\n# L...
python
chosen
[ { "from": "system", "value": "Rename to be consistent with backend name\n" }, { "from": "human", "value": "\"\"\"\nGoogle App Engine support using User API\n\"\"\"\nfrom __future__ import absolute_import\n\nfrom google.appengine.api import users\n\nfrom social.backends.base import BaseAuth\nfrom...
python
chosen
[ { "from": "system", "value": "Add link url to access position inc/dec views\n\n--HG--\nextra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%409\n" }, { "from": "human", "value": "from django.conf.urls.defaults import *\nfrom django.views.generic.simple import direct_to_template\...
python
chosen
[ { "from": "system", "value": "Add custom exception for track-related errors\n\nThe new exception type (`TrackError`) will be used when a track cannot\nbe played or found.\n" }, { "from": "human", "value": "\"\"\"\nexceptions.py\n\nCopyright © 2015 Alex Danoff. All Rights Reserved.\n2015-08-02\n\...
python
chosen
[ { "from": "system", "value": "Add new helper function to encrypt for KMS\n" }, { "from": "human", "value": "import os\n\n\ndef env_or_default(var, default=None):\n \"\"\"Get environment variable or provide default.\n\n Args:\n var (str): environment variable to search for\n d...
python
chosen
[ { "from": "system", "value": "Add more tricky case test for apply_threshold\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\nimport numpy\nfrom nose.tools import raises\n\nfrom openfisca_core.formula_helpers import apply_threshold as apply_threshold\nfrom openfisca_core.tools import...
python
chosen
[ { "from": "system", "value": "Use Phonon instead of Nominatim for geo coding\n\nPhonon is more fault tolerant to spelling mistakes.\n" }, { "from": "human", "value": "from geopy import Nominatim\nfrom geopy.extra.rate_limiter import RateLimiter\n\n\nclass GeoCodePipeline(object):\n\n def open...
python
chosen
[ { "from": "system", "value": "Handle playback changes in FrontPanel\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nimport logging\n\nfrom mopidy.core import CoreListener\n\nimport pykka\n\nimport .menu import BrowseMenu\nimport .painter import Painter\n\nlogger = l...
python
chosen
[ { "from": "system", "value": "Add event key to upcoming match notification" }, { "from": "human", "value": "import calendar\nimport datetime\n\nfrom consts.notification_type import NotificationType\nfrom notifications.base_notification import BaseNotification\n\n\nclass UpcomingMatchNotification...
python
chosen
[ { "from": "system", "value": "Rename the name of topo.\n" }, { "from": "human", "value": "'''\nSDN project testing topo\n s1\n / \\\n s2--s3\n | |\n host.. host...\n\n'''\nfrom mininet.topo import Topo\n\nclass LoopTopo( Topo ):\n\n\tdef __init__( self , n=2 ):\n\n\t\t# ...
python
chosen
[ { "from": "system", "value": "Check whether Vim is available\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport sys\nfrom args import get_args\nfrom subprocess import Popen, PIPE\n\nif __name__ == '__main__':\n # Get the arguments passed by user\n a...
python
chosen