conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Use the right download URL.\n" }, { "from": "human", "value": "\n\nHOME_URL = 'https://github.com/ftobia/longshot/blob/master/longshot.py'\n\n\ndef upgrade():\n backup_self()\n download_and_overwrite()\n restart()\n\n\ndef backup_self():\n import shutil\...
python
chosen
[ { "from": "system", "value": "Remove unused field from request.\n" }, { "from": "human", "value": "import json\nfrom ._base import get_base_rdio_client\n\n\nclass _RdioExportClient(object):\n def __init__(self, base_client):\n self.base_client = base_client\n\n def get_current_user_...
python
chosen
[ { "from": "system", "value": "Make privacy checkbox on user form required via required attribute." }, { "from": "human", "value": "from django import forms\n\nfrom tower import ugettext_lazy as _lazy\n\nfrom flicks.base.util import country_choices\nfrom flicks.users.models import UserProfile\n\n...
python
chosen
[ { "from": "system", "value": "Make ImageUploadExtensionValidator work with django 1.7 migrations\n" }, { "from": "human", "value": "from django.conf import settings\nfrom django.core.validators import ValidationError\n\n# A list of allowable thumbnail file extensions.\nALLOWABLE_THUMBNAIL_EXTENS...
python
chosen
[ { "from": "system", "value": "Use proper method to determine system uptime.\n\nFixes https://github.com/dittert/pyprobe/issues/9\n" }, { "from": "human", "value": "# coding=utf-8\nfrom datetime import datetime\n\nimport psutil\n\nfrom pyprobe.sensors import *\n\n\n__author__ = 'Dirk Dittert'\n\n...
python
chosen
[ { "from": "system", "value": "Make post filtering and mapping more pythonic\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\n\nclass Posts(list):\n \"\"\"\n Represents a list of posts in a thread.\n \"\"\"\n\n def __init__(self, *...
python
chosen
[ { "from": "system", "value": "Add DispatchedState, add target, add id\n" }, { "from": "human", "value": "class Dispatched(object):\n\tdef __init__(self, w=None, cb=None):\n\t\tself.w = w\n\t\tself.cb = cb\n\t\tself.retval = None\n\t\tself.output = None\n\nclass DispatchInquiry(object):\...
python
chosen
[ { "from": "system", "value": "Set cli tests to base test class\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"Tests for `pyutrack` package.\"\"\"\n\n\nimport unittest\nfrom click.testing import CliRunner\n\nfrom pyutrack import cli\n\n\nclass TestYoutr...
python
chosen
[ { "from": "system", "value": "Make the database JSON easier to read.\n" }, { "from": "human", "value": "from __future__ import print_function\nfrom tinydb import TinyDB\nfrom core.models import Movie\n\nTABLE_POPULAR = \"popular\"\nTABLE_NAME_TO_ID = \"name_to_id_mapping\"\nTABLE_MOVIES = \"movi...
python
chosen
[ { "from": "system", "value": "Add diagnostics to blackjax namespace\n" }, { "from": "human", "value": "from .mcmc import hmc, nuts, rmh\nfrom .mcmc_adaptation import window_adaptation\n\n__version__ = \"0.3.0\"\n\n__all__ = [\n \"hmc\",\n \"nuts\",\n \"rmh\",\n \"window_adaptation\",...
python
chosen
[ { "from": "system", "value": "Fix name field for empty values\n" }, { "from": "human", "value": "from django.db import models\nfrom django.contrib.auth.models import AbstractUser\nfrom django.utils.translation import ugettext_lazy as _\nfrom django.template.defaultfilters import slugify\n\n\ncla...
python
chosen
[ { "from": "system", "value": "Add unique model fields form mixin.\n" }, { "from": "human", "value": "# encoding: utf-8\nfrom django import forms\n\n\nclass SearchForm(forms.Form):\n search = forms.CharField(\n label='', required=False,\n widget=forms.widgets.TextInput())\n" },...
python
chosen
[ { "from": "system", "value": "Check if file is executable, before executing it\n" }, { "from": "human", "value": "import os\nimport subprocess\nimport logbook\nlogger = logbook.Logger('connman-dispatcher')\n\n\ndef execute_scripts_in_dirs(paths, state):\n for path in sorted(paths):\n i...
python
chosen
[ { "from": "system", "value": "Add some debug for debian box\n" }, { "from": "human", "value": "import subprocess\nimport string\n\nclass Command(object):\n\n def execute(self, command: str):\n cliArgs = self.parseCliArgs(command)\n\n process = subprocess.Popen(cliArgs, stdin=subprocess.PI...
python
chosen
[ { "from": "system", "value": "Remove all Haystack customization of search view pending further investigations.\n" }, { "from": "human", "value": "from django.conf.urls.defaults import *\r\nfrom courant.core.search.views import *\r\n\r\nfrom haystack.forms import ModelSearchForm\r\nfrom haystack....
python
chosen
[ { "from": "system", "value": "Use more sane numbers for initial data\n" }, { "from": "human", "value": "from orbit import satellite\n\nfrom django.core.management.base import BaseCommand\n\nfrom base.tests import ObservationFactory, StationFactory\nfrom base.models import Satellite\n\n\nclass Co...
python
chosen
[ { "from": "system", "value": "Add name parameter to create_product_for_good which defaults to good.name\n" }, { "from": "human", "value": "from __future__ import unicode_literals\n\nfrom .models import Product, PriceList\n\n\ndef create_product_for_good(good, price, quantity=1):\n \"\"\"\n ...
python
chosen
[ { "from": "system", "value": "Add a module to the __all__ list.\n" }, { "from": "human", "value": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\n# Copyright (c) 2016 Jérémie DECOCK (http://www.jdhp.org)\n\n# This script is provided under the terms and conditions of the MIT license:\n# Permi...
python
chosen
[ { "from": "system", "value": "Add test case: Post method for experiment\n" }, { "from": "human", "value": "import unittest\nimport timevis\n\n\nclass TestAPIs(unittest.TestCase):\n def setUp(self):\n self.app = timevis.app.test_client()\n\n def test_api(self):\n resp = self.a...
python
chosen
[ { "from": "system", "value": "Add command to bring up dev server.\n" }, { "from": "human", "value": "from fabric.api import sudo, cd, env, run, local\n\nenv.hosts = ['ibadaw@sableamd2.cs.mcgill.ca']\n\nDEPLOY_DIR = '/var/www/mcbench/mcbench'\n\n\ndef deploy():\n with cd(DEPLOY_DIR):\n ...
python
chosen
[ { "from": "system", "value": "Test sync return for Twisted too\n" }, { "from": "human", "value": "from __future__ import absolute_import, division, print_function\n\nimport pytest\n\npytest.importorskip(\"twisted\")\n\nfrom twisted.internet.defer import Deferred, succeed, fail\n\nfrom prometheus...
python
chosen
[ { "from": "system", "value": "Remove duplicate definition of write_file\n" }, { "from": "human", "value": "import os\nimport os.path\nimport subprocess\n\n\nclass HelloWorld(object):\n BUILD = r\"\"\"#!/bin/sh\nset -e\ncd $1\n\ncat > hello << EOF\n#!/bin/sh\necho Hello world!\nEOF\n\nchmod +x...
python
chosen
[ { "from": "system", "value": "Bump version number for release 1.5\n" }, { "from": "human", "value": "\"\"\"django todo\"\"\"\n__version__ = '1.5.dev'\n\n__author__ = 'Scot Hacker'\n__email__ = 'shacker@birdhouse.org'\n\n__url__ = 'https://github.com/shacker/django-todo'\n__license__ = 'BSD Licen...
python
chosen
[ { "from": "system", "value": "Remove unneeded properties from main data object\n" }, { "from": "human", "value": "import time\n\n\nclass Data:\n def __init__(self, secs_since_epoch, depth_chart, temperature_chart, frame_path):\n # general settings\n self.width = 1296\n se...
python
chosen
[ { "from": "system", "value": "Modify to read layer colors.\n" }, { "from": "human", "value": "def read(filename):\n \"\"\"\n Reads in a corestick file and returns a dictionary keyed by core_id.\n Layer interface depths are positive and are relative to the lake bottom.\n depths are re...
python
chosen
[ { "from": "system", "value": "Fix run tests with Celery\n" }, { "from": "human", "value": "#!/usr/bin/env python\nimport sys\nfrom optparse import OptionParser\n\nfrom django.conf import settings\n\nif not settings.configured:\n settings.configure(\n DATABASES = {\n 'default...
python
chosen
[ { "from": "system", "value": "Fix class loader called in Oscar contrib package\n" }, { "from": "human", "value": "from oscar.core.loading import load_class\n\nfrom . import mixins\n\n\nProductCategoryView = load_class('catalogue.views', 'ProductCategoryView')\n\n\nclass FancyPageDetailView(mixin...
python
chosen
[ { "from": "system", "value": "mac: Upgrade libchromiumcontent to fix linking error\n" }, { "from": "human", "value": "#!/usr/bin/env python\n\nimport platform\nimport sys\n\nBASE_URL = 'http://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent'\nLIBCHROMIUMCONTENT_COMMIT = '17a0e24666d0198...
python
chosen
[ { "from": "system", "value": "Put in first proper tiny package class and unit test.\n" }, { "from": "human", "value": "from unittest import TestCase\n\n\nclass TestBuildError(TestCase):\n def test_push_message(self):\n self.fail()\n\n def test_format_as_single_string(self):\n ...
python
chosen
[ { "from": "system", "value": "Add lang, enviro in request\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nimport logging\n\nfrom icebergsdk.mixins.request_mixin import IcebergRequestBase\n\nlogger = logging.getLogger('icebergsdk.frontmodules')\n\nclass FrontModules(IcebergRequestBase...
python
chosen
[ { "from": "system", "value": "Add inbound drop policy for participant 3 based on eth_src of participant 1\n" }, { "from": "human", "value": "{\n \"inbound\": [\n {\n \"cookie\": 1,\n \"match\": \n {\n \"tcp_dst\": 4321\n },\n ...
python
chosen
[ { "from": "system", "value": "Remove layout for non-html files\n" }, { "from": "human", "value": "import logging\n\nfrom django.contrib.auth.views import redirect_to_login\nfrom django.core.exceptions import PermissionDenied\nfrom django.http import Http404\nfrom django.views.generic import View...
python
chosen
[ { "from": "system", "value": "Mark build 86 and v1.6.5 release" }, { "from": "human", "value": "version = '1.6.5'\nrevision = ' development'\nmilestone = 'Yoitsu'\nrelease_number = '85'\nprojectURL = 'https://syncplay.pl/'\n" }, { "from": "gpt", "value": "version = '1.6.5'\nrevision ...
python
chosen
[ { "from": "system", "value": "Fix python 2 unicode issue.\n" }, { "from": "human", "value": "from django.utils import six\nfrom debug_toolbar_multilang.pseudo import STR_FORMAT_PATTERN, \\\n STR_FORMAT_NAMED_PATTERN\nfrom debug_toolbar_multilang.pseudo.pseudo_language import PseudoLanguage\n\...
python
chosen
[ { "from": "system", "value": "Remove the logging setup call." }, { "from": "human", "value": "import os\nfrom ctypeslib.dynamic_module import include\nfrom ctypes import *\nimport logging\nlogging.basicConfig(level=logging.INFO)\n\nif os.name == \"nt\":\n _libc = CDLL(\"msvcrt\")\nelse:\n ...
python
chosen
[ { "from": "system", "value": "Make sure that follow-file decodes utf-8 from its input\n\nSigned-off-by: Jason Bernardino Alonso <f71c42a1353bbcdbe07e24c2a1c893f8ea1d05ee@hackorp.com>\n" }, { "from": "human", "value": "\"\"\"\nUtility functions for dhcp2nest\n\"\"\"\nfrom queue import Queue\nfrom...
python
chosen
[ { "from": "system", "value": "Add test for fragment SMILES\n" }, { "from": "human", "value": "\"\"\"\nTest topological fingerprints.\n\"\"\"\nimport unittest\n\nfrom rdkit import Chem\n\nfrom pande_gas.features import fingerprints as fp\n\n\nclass TestCircularFingerprint(unittest.TestCase):\n ...
python
chosen
[ { "from": "system", "value": "Make LoadTestShape a proper abstract class.\n" }, { "from": "human", "value": "from __future__ import annotations\nimport time\nfrom typing import Optional, Tuple, List, Type\n\nfrom . import User\nfrom .runners import Runner\n\n\nclass LoadTestShape:\n \"\"\"\n ...
python
chosen
[ { "from": "system", "value": "Fix error in search index not updating on view call.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\nfrom django.contrib.auth.decorators import login_required\nfrom django.http import HttpResponse\nfrom django.cor...
python
chosen
[ { "from": "system", "value": "Sort registrations. Separate classes of imports. Add API key display.\n" }, { "from": "human", "value": "from django.contrib import admin\nfrom server.models import *\n\n\nclass MachineGroupAdmin(admin.ModelAdmin):\n readonly_fields = ('key',)\n\n\nclass MachineA...
python
chosen
[ { "from": "system", "value": "Update forms to bootstrap 3\n\nform-horizontal needs additional helper classes in BS3\n" }, { "from": "human", "value": "from django import forms\nfrom django.template.defaultfilters import slugify\n\nfrom crispy_forms.helper import FormHelper\nfrom crispy_forms.lay...
python
chosen
[ { "from": "system", "value": "Load pygrapes.serializer.json.Json right inside pygrapes.serializer\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nfrom abstract import Abstract\n\n\n__all__ = ['Abstract']\n" }, { "from": "gpt", "value": "#!/usr/bin/e...
python
chosen
[ { "from": "system", "value": "Update RandomSampler to use the new Sampler abc\n" }, { "from": "human", "value": "\"\"\"\nRandomSampler\n-------------\n\nA random sampler that can be used for unit testing and debugging.\n\"\"\"\nimport numpy as np\n\nfrom dimod.core.sampler import Sampler\nfrom d...
python
chosen
[ { "from": "system", "value": "Add utility methods for yesterday's date\n" }, { "from": "human", "value": "\"\"\"class to convert datetime values\"\"\"\n\nimport datetime\n\nclass DatetimeConverter(object):\n \"\"\"stuff\"\"\"\n\n _EPOCH_0 = datetime.datetime(1970, 1, 1)\n\n def __init__...
python
chosen
[ { "from": "system", "value": "Mark master as working towards 0.25.0\n" }, { "from": "human", "value": "# coding: utf-8\nfrom __future__ import unicode_literals, division, absolute_import, print_function\n\n\n__version__ = '0.24.0'\n__version_info__ = (0, 24, 0)\n" }, { "from": "gpt", ...
python
chosen
[ { "from": "system", "value": "Fix a typo in the documentation of FileReaderDecorator.\n" }, { "from": "human", "value": "# Copyright (c) 2017-2018 Renata Hodovan, Akos Kiss.\n#\n# Licensed under the BSD 3-Clause License\n# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.\n# This fi...
python
chosen
[ { "from": "system", "value": "Add trailing newline to make round-tripping without diffs possible.\n" }, { "from": "human", "value": "#! /usr/bin/env python3\n\nimport sys\nimport json\n\nfor arg in sys.argv[1:]:\n with open(arg) as f:\n equajson = json.load(f)\n\n try:\n late...
python
chosen
[ { "from": "system", "value": "Use @staff_member_required decorator for the dashboard view as well\n" }, { "from": "human", "value": "from django.contrib.auth.decorators import login_required\nfrom django.http import HttpResponse\nfrom django.template import RequestContext\nfrom django.shortcuts ...
python
chosen
[ { "from": "system", "value": "Increment patch version to 0.8.7\n" }, { "from": "human", "value": "\"\"\"yolk.\n\nAuthor: Rob Cakebread <cakebread at gmail>\n\nLicense : BSD\n\n\"\"\"\n\n__version__ = '0.8.6'\n" }, { "from": "gpt", "value": "\"\"\"yolk.\n\nAuthor: Rob Cakebread <cake...
python
chosen
[ { "from": "system", "value": "Add image_handler for link harvester\n" }, { "from": "human", "value": "import logging\nimport re\nimport socket\nimport urllib\nfrom bs4 import BeautifulSoup\n\nlogger = logging.getLogger(__name__)\nWURSTBALL_RE = re.compile(r\"^https?://(www\\.)?wurstball\\.de/[0-...
python
chosen
[ { "from": "system", "value": "Add process monitoring for LBaaS agents\n\nAdd neutron-lbaas-agent (LBaaS V1) and neutron-lbaasv2-agent (LBaaS\nV2) to the neutron detection plugin. Because the string\n\"neutron-lbaas-agent\" can be both a process name and log file name,\nthe process monitor is susceptible to...
python
chosen
[ { "from": "system", "value": "Switch WebRTC recipe to Git.\n\nBUG=412012\n\nReview URL: https://codereview.chromium.org/765373002\n\ngit-svn-id: fd409f4bdeea2bb50a5d34bb4d4bfc2046a5a3dd@294546 0039d316-1c4b-4281-b951-d872f2087c98\n" }, { "from": "human", "value": "# Copyright (c) 2014 The Chromi...
python
chosen
[ { "from": "system", "value": "Add validate published on templatetag get articlebox\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\nfrom django import template\nfrom django.conf import settings\nfrom opps.articles.models import ArticleBox\n\n\nregister = template.Library()\n\n\n@regis...
python
chosen
[ { "from": "system", "value": "Fix split filter in emencia_utils templatetags that was returning a string instead of a list\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\"\"\"\nVarious usefull tags\n\"\"\"\nfrom django import template\n\nregister = template.Library()\n\n@register.f...
python
chosen
[ { "from": "system", "value": "Improve file mime type detection\n" }, { "from": "human", "value": "from constants import *\nimport os\nimport urllib\nimport mimetypes\nimport logging\n\nclass Object:\n def __init__(self, path):\n self.name = os.path.basename(path)\n self.path = p...
python
chosen
[ { "from": "system", "value": "Upgrade to a newer pipeline release\n" }, { "from": "human", "value": "from settings_common import *\n\nPACKAGE_VERSION = 0.5\n\nDEBUG = TEMPLATE_DEBUG = True\n\nDATABASE_ENGINE = 'postgresql_psycopg2'\nDATABASE_NAME = 'daisyproducer_dev'\nDATABASE_USER = 'eglic'\nD...
python
chosen
[ { "from": "system", "value": "Add UUID to bloop __all__" }, { "from": "human", "value": "from bloop.engine import Engine, ObjectsNotFound, ConstraintViolation\nfrom bloop.column import Column, GlobalSecondaryIndex, LocalSecondaryIndex\nfrom bloop.types import (\n String, Float, Integer, Binar...
python
chosen
[ { "from": "system", "value": "Change the arg values so not to use the script name as the fromaddr" }, { "from": "human", "value": "#!/usr/local/bin/python\nimport smtplib, time, threading, sys\nfrom email.mime.text import MIMEText\n\nfromaddr = sys.argv[0]\ntoaddr = sys.argv[1]\n\n\ndef createMe...
python
chosen
[ { "from": "system", "value": "Add unittest(cpu-only) and typecheck for Copy\n" }, { "from": "human", "value": "from chainer import cuda\nfrom chainer import function\n\n\nclass Copy(function.Function):\n\n \"\"\"Copy an input GPUArray onto another device.\"\"\"\n\n def __init__(self, out_d...
python
chosen
[ { "from": "system", "value": "Test whitespace in pretty printing tests.\n" }, { "from": "human", "value": "from os import walk, sep, chdir, pardir\nfrom os.path import split, join, abspath\nfrom glob import glob\n\n# System path separator (usually slash or backslash)\nsepd = {\"sep\": sep}\n\n# ...
python
chosen
[ { "from": "system", "value": "Use select_related to help with category foreign keys\n" }, { "from": "human", "value": "from django.views.generic import ListView, DateDetailView\nfrom django.shortcuts import get_object_or_404\nfrom django.utils import timezone\nfrom django.conf import settings\nf...
python
chosen
[ { "from": "system", "value": "Correct minor typo in a string.\n" }, { "from": "human", "value": "'''\nInformation about this python-fedora release\n'''\n\nfrom fedora import _\n\nNAME = 'python-fedora'\nVERSION = '0.3.6'\nDESCRIPTION = _('Python modules for interacting with Fedora services')\nLO...
python
chosen
[ { "from": "system", "value": "Package development version of upcoming v1 release for testing.\n" }, { "from": "human", "value": "from .core import *\n\n__all__ = ['OutlookAccount', 'Message', 'Contact', 'Folder']\n__version__ = '1.0.0'\n__release__ = '1.0.0'\n" }, { "from": "gpt", "v...
python
chosen
[ { "from": "system", "value": "Remove conditional sql-select on new user creation\n\nOnly create a user profile if a new user is actually\ncreated.\n" }, { "from": "human", "value": "import uuid\n\nfrom django.contrib.auth.models import User\nfrom django.db import models\nfrom django.dispatch imp...
python
chosen
[ { "from": "system", "value": "Add pytest fail check on raising pretty print exeption\n" }, { "from": "human", "value": "import pandas\n\nfrom sharepa.helpers import pretty_print\nfrom sharepa.helpers import source_counts\n\n\ndef test_pretty_print():\n some_stuff = '{\"Dusty\": \"Rhodes\"}'\n...
python
chosen
[ { "from": "system", "value": "Fix intermittent travis build error.\n" }, { "from": "human", "value": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom __future__ import print_function, unicode_literals\nimport pytest\nfrom wamopacker.process import run_command, ProcessException\nimport os\...
python
chosen
[ { "from": "system", "value": "Create initial config when starting game\n" }, { "from": "human", "value": "# -*- encoding: utf-8 -*-\n\nimport pygame\nfrom scenes import director\nfrom scenes import intro_scene\n\npygame.init()\n\n\ndef main():\n game_director = director.Director()\n scene ...
python
chosen
[ { "from": "system", "value": "Test - targets test fix mcu validity indexes\n" }, { "from": "human", "value": "# Copyright 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 c...
python
chosen
[ { "from": "system", "value": "Stop defining default_app_config on Django 3.2+" }, { "from": "human", "value": "# coding: utf-8\n\n# default_app_config was deprecated in Django 3.2. Maybe set it only when detected django version is older?\ndefault_app_config = \"modernrpc.apps.ModernRpcConfig\"\n...
python
chosen
[ { "from": "system", "value": "Allow servers command to work without a password.\n" }, { "from": "human", "value": "from BaseController import BaseController\nfrom api.util import settings\n\nclass ServerListController(BaseController):\n\n def get(self):\n servers = {\"servers\": self.r...
python
chosen
[ { "from": "system", "value": "Change channel_id to new channelId param" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\r\nfrom linepy import *\r\n\r\nclient = LineClient()\r\n#client = LineClient(authToken='AUTHTOKEN')\r\n\r\nclient.log(\"Auth Token : \" + str(client.authToken))\r\n\r\n...
python
chosen
[ { "from": "system", "value": "Use generic names in the worker rush example\n" }, { "from": "human", "value": "import sc2\nfrom sc2 import run_game, maps, Race, Difficulty\nfrom sc2.player import Bot, Computer\n\nclass WorkerRushBot(sc2.BotAI):\n async def on_step(self, state, iteration):\n ...
python
chosen
[ { "from": "system", "value": "Remove hardcoded default filename. Raise an error if no app config file was specified, or it is unreadable, or it doesn't contain the section we need.\n" }, { "from": "human", "value": "import ConfigParser\nfrom common.application import Application\nfrom keystonemi...
python
chosen
[ { "from": "system", "value": "Use dateparser for parsing scraped dates\n" }, { "from": "human", "value": "from datetime import datetime, timezone, time\n\n\ndef zero_time_with_timezone(date, tz=timezone.utc):\n return datetime.combine(date, time(tzinfo=tz))" }, { "from": "gpt", "v...
python
chosen
[ { "from": "system", "value": "Switch to start_all_workers in RPC server\n\nThis does the same as the logic present but it emits\nthe registry callback event for resources.PROCESS AFTER_SPAWN\nthat some plugins may be expecting.\n\nChange-Id: I6f9aeca753a5d3c0052f553a2ac46786ca113e1e\nRelated-Bug: #1687896\n...
python
chosen
[ { "from": "system", "value": "[Python] Update score in Game class methods\n" }, { "from": "human", "value": "class Game():\n def __init__(self):\n self._score = 0\n\n def roll(self, pins):\n pass\n\n def score(self):\n return 0\n" }, { "from": "gpt", "va...
python
chosen
[ { "from": "system", "value": "Add missing PYGMENTS_STYLES list to pyqode.core.api\n" }, { "from": "human", "value": "\"\"\"\nThis package contains the bases classes of pyqode and some utility\nfunctions.\n\n\"\"\"\nfrom .code_edit import CodeEdit\nfrom .decoration import TextDecoration\nfrom .en...
python
chosen
[ { "from": "system", "value": "Add fallbacks for e-mail handling if outbox is not defined\n" }, { "from": "human", "value": "\nimport click\nimport json\nimport logging\nimport requests\nfrom datetime import datetime\nfrom certidude import config\n\n\ndef publish(event_type, event_data):\n \"\...
python
chosen
[ { "from": "system", "value": "Fix flake8 errors: W391 blank line at end of file\n" }, { "from": "human", "value": "import subprocess\nfrom thefuck.utils import for_app, replace_command, eager\n\n\n@for_app('ifconfig')\ndef match(command):\n return 'error fetching interface information: Device...
python
chosen
[ { "from": "system", "value": "Add comments and docstring to OSMDataModel\n" }, { "from": "human", "value": "import pandas as pd\n\nfrom monitorframe.monitor import BaseDataModel\n\nfrom cosmo.filesystem import FileDataFinder\nfrom cosmo import FILES_SOURCE\nfrom cosmo.monitor_helpers import expl...
python
chosen
[ { "from": "system", "value": "Replace list with a linked list for much better performance\n" }, { "from": "human", "value": "inp = 3004953\n\nelves = list(range(1, inp + 1))\ni = 0\nwhile len(elves) > 1:\n index = (i + int(len(elves) / 2)) % len(elves)\n elves.pop(index)\n if index < i:...
python
chosen
[ { "from": "system", "value": "Change scope of watch manager.\n" }, { "from": "human", "value": "import os\nimport sys\nimport pyinotify\nimport analyzer\n\nwm = pyinotify.WatchManager()\n\nclass ProcessProfilerEvent(pyinotify.ProcessEvent):\n def process_IN_CLOSE_WRITE(self, event):\n ...
python
chosen
[ { "from": "system", "value": "Save file info in DB\n" }, { "from": "human", "value": "import tornado\nimport time\nfrom bson.json_util import dumps\nfrom tornado.options import options\n\n\nclass FilesServiceHandler(tornado.web.RequestHandler):\n def initialize(self, logger, mongodb):\n ...
python
chosen
[ { "from": "system", "value": "Fix import order (some somewhat cyclic dependencies; should fix)\n" }, { "from": "human", "value": "\"\"\"This module has functions and classes useful for setting up simulations\"\"\"\n\n########################################################################\n# ...
python
chosen
[ { "from": "system", "value": "Undo previous commit. It didn't work.\n" }, { "from": "human", "value": "def xlsx_export_action(modeladmin, request, queryset):\n\n from django.http import HttpResponse\n from import_export.formats import base_formats\n formats = modeladmin.get_export_forma...
python
chosen
[ { "from": "system", "value": "Disable global intern exception test\n" }, { "from": "human", "value": "from .. import intern\n\ndef test_global_interning():\n try:\n intern.global_intern(\"hello\")\n except AssertionError as e:\n pass\n else:\n raise Exception(\"Expe...
python
chosen
[ { "from": "system", "value": "Add (failing) test of object_reference on all ObjectProperties subclasses\n" }, { "from": "human", "value": "# Copyright (c) 2013, The MITRE Corporation. All rights reserved.\n# See LICENSE.txt for complete terms.\n\nimport cybox.utils\n\n\nclass ObjectTestCase(obje...
python
chosen
[ { "from": "system", "value": "Add nltk part to script\n" }, { "from": "human", "value": "''' \nScript used to query Wikipedia for summary of object \n'''\n\nimport sys\nimport wikipedia \n\ndef main():\n\t# Check that we have the right number of arguments \n\tif (len(sys.argv) != 2): \n\t\tprint...
python
chosen
[ { "from": "system", "value": "Revert \"Use tempfile lib for log file\"\n\nThis reverts commit 6e8f35b83fc563c8349cb3be040c61a0588ca745.\n\nThe commit caused severer issue than it fixed. In case one need to check\nthe content of log file, there is no way to tell where the log file\nlocation/name is.\n" }, ...
python
chosen
[ { "from": "system", "value": "Adjust doc strings in Fibonacci numbers implementation\n" }, { "from": "human", "value": "def fib1(amount):\n \"\"\"\n Fibonacci generator example. The second variable is used to store\n the result.\n :param amount: Amount of numbers to produce.\n :re...
python
chosen
[ { "from": "system", "value": "Change mask parameter in API.\n" }, { "from": "human", "value": "from .io import preprocess\nfrom .train import train\nfrom .encode import encode\n\n\ndef autoencode(count_matrix, kfold=None, reduced=False,\n censor_matrix=None, type='normal',\n ...
python
chosen
[ { "from": "system", "value": "Change exercise 4 question 1\n" }, { "from": "human", "value": "from learntools.core import *\nimport tensorflow as tf\n\n\nclass Q1A(ThoughtExperiment):\n _solution = \"\"\n\n\nclass Q1B(ThoughtExperiment):\n _solution = \"\"\n\nQ1 = MultipartProblem(Q1A, Q1B...
python
chosen
[ { "from": "system", "value": "Add a second Python implementation of problem 2\n" }, { "from": "human", "value": "f1, f2, s, n = 0, 1, 0, 4000000\nwhile f2 < n:\n f2, f1 = f1, f1 + f2\n if f2 % 2 == 0:\n s += f2\nprint s\n" }, { "from": "gpt", "value": "def sum_even_fibon...
python
chosen
[ { "from": "system", "value": "Save a few SQL queries.\n" }, { "from": "human", "value": "# -*- coding: utf-8 -*-\n\n\"\"\"\nbyceps.blueprints.ticket.service\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n:Copyright: 2006-2015 Jochen Kupperschmidt\n\"\"\"\n\nfrom ..party.models import Party\nfrom ..seating...
python
chosen
[ { "from": "system", "value": "Refactor code, add hints from page\n" }, { "from": "human", "value": "#!/usr/local/bin/python3\n# Python challenge - 3\n# http://www.pythonchallenge.com/pc/def/equality.html\n\nimport re\n\n\n'''\nHint:\nOne small letter surrounded by EXACTLY three big bodyguards on...
python
chosen
[ { "from": "system", "value": "Remove a redundant use of contextlib.closing() decorator\n\nRemove the unnecessary contextlib.closing() decorators from open()\ncalls. The file objects returned by open() provide context manager API\nthemselves and closing() is only necessary for external file-like\nobjects th...
python
chosen
[ { "from": "system", "value": "Make it work with last fman version (0.7) on linux\n" }, { "from": "human", "value": "from fman import DirectoryPaneCommand, show_alert\r\nimport distutils\r\nfrom distutils import dir_util, file_util\r\nimport os.path\r\n\r\nclass DuplicateFileDir(DirectoryPaneComm...
python
chosen
[ { "from": "system", "value": "Fix parsing of dates for Visir.\n\nSome dates are being wrongly parsed, so we need to specify some information about the order of things.\n" }, { "from": "human", "value": "import dateutil.parser\nimport scrapy\n\nfrom jobs.items import JobsItem\n\n\nclass VisirSpid...
python
chosen
[ { "from": "system", "value": "Send notification to the correct address\n" }, { "from": "human", "value": "import sys\nprint(sys.version_info)\nimport random\nimport time\n\nimport networkzero as nw0\n\nquotes = [\n \"Humpty Dumpty sat on a wall\",\n \"Hickory Dickory Dock\",\n \"Baa Baa...
python
chosen
[ { "from": "system", "value": "Fix a couple of typos in the program description\n" }, { "from": "human", "value": "import os\nimport re\n\n'''\n This is used to revert back a Dropbox conflict. So in this case I want to keep all the files that where\n converted to conflict copies. So I just ...
python
chosen